forked from ArweaveTeam/SmartWeave
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-api-things.js
More file actions
22 lines (19 loc) · 910 Bytes
/
test-api-things.js
File metadata and controls
22 lines (19 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
export async function handle (state, input) {
const txId = SmartWeave.transaction.id
const txOwner = SmartWeave.transaction.owner
const txTarget = SmartWeave.transaction.target
const txQuantity = SmartWeave.transaction.quantity
const txReward = SmartWeave.transaction.reward
const txTags = SmartWeave.transaction.tags
const blockHeight = SmartWeave.block.height
const blockIndepHash = SmartWeave.block.indep_hash
const contractId = SmartWeave.contract.id
const ownerBytes = SmartWeave.arweave.utils.b64UrlToBuffer(txOwner)
const from =
SmartWeave.arweave.utils.bufferToB64Url(
await SmartWeave.arweave.utils.crypto.hash(ownerBytes)
)
const from2 = SmartWeave.utils.wallets.ownerToAddress(txOwner)
state.log = [...state.log, { blockHeight, blockIndepHash, txId, txOwner: txOwner, txTarget, txQuantity, txReward, txTags, from, from2, contractId }]
return { state }
}