Skip to content

Commit

Permalink
fix contract execution env
Browse files Browse the repository at this point in the history
  • Loading branch information
Geo25rey committed Apr 12, 2024
1 parent fb409c0 commit 3763874
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/services/new/contractEngineV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,37 @@ class VmContext {

console.log(tx)


const blockHeader = await this.engine.self.chainBridge.blockHeaders.findOne({
id: tx.anchored_id
})
const requiredAuths = tx.required_auths.map(e => typeof e === 'string' ? e : e.value).map(e => {
if(tx.src === 'hive') {
//Format should be human readable
return `hive:${e}`
} else {
//i.e did:key:123etcetc
return e
}
})

const callOutput = await this.vm.call({
contract_id,
action: tx.data.action,
payload: JSON.stringify(tx.data.payload),
env: {

} as any
'anchor.id': tx.anchored_id,
'anchor.height': tx.anchored_height,
'anchor.block': tx.anchored_block,
'anchor.timestamp': blockHeader.ts.getTime(),


'msg.sender': requiredAuths[0],
//Retain the type info as well.
//TODO: properly parse and provide authority type to contract
//Such as ACTIVE vs POSTING auth
'msg.required_auths': requiredAuths,
'tx.origin': requiredAuths[0],
}
})

return callOutput
Expand Down Expand Up @@ -257,7 +279,7 @@ export class ContractEngineV2 {
//Such as ACTIVE vs POSTING auth
'msg.required_auths': tx.required_auths,
'tx.origin': requiredAuths[0],
} as any
}
})


Expand Down

0 comments on commit 3763874

Please sign in to comment.