-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into gregor/update-flow-go-latest
- Loading branch information
Showing
10 changed files
with
877 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import EVM | ||
|
||
access(all) | ||
fun main(hexEncodedTx: String): String { | ||
fun main(hexEncodedTx: String): EVM.Result { | ||
let account = getAuthAccount<auth(Storage) &Account>(Address(0xCOA)) | ||
|
||
let coa = account.storage.borrow<&EVM.CadenceOwnedAccount>( | ||
from: /storage/evm | ||
) ?? panic("Could not borrow reference to the COA!") | ||
let txResult = EVM.run(tx: hexEncodedTx.decodeHex(), coinbase: coa.address()) | ||
|
||
return String.encodeHex(txResult.data) | ||
return EVM.run(tx: hexEncodedTx.decodeHex(), coinbase: coa.address()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import EVM | ||
|
||
access(all) | ||
fun main(hexEncodedTx: String): [UInt64; 2] { | ||
fun main(hexEncodedTx: String): EVM.Result { | ||
let account = getAuthAccount<auth(Storage) &Account>(Address(0xCOA)) | ||
|
||
let coa = account.storage.borrow<&EVM.CadenceOwnedAccount>( | ||
from: /storage/evm | ||
) ?? panic("Could not borrow reference to the COA!") | ||
let txResult = EVM.run(tx: hexEncodedTx.decodeHex(), coinbase: coa.address()) | ||
|
||
return [txResult.errorCode, txResult.gasUsed] | ||
return EVM.run(tx: hexEncodedTx.decodeHex(), coinbase: coa.address()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const { assert } = require('chai') | ||
const conf = require('./config') | ||
const helpers = require('./helpers') | ||
const web3 = conf.web3 | ||
|
||
it('returns a null result for missing filter', async () => { | ||
// check that null is returned when the filter could not be found. | ||
let response = await helpers.callRPCMethod('eth_getFilterLogs', ['0xffa1']) | ||
|
||
assert.equal(200, response.status) | ||
assert.isUndefined(response.body['result']) | ||
}) | ||
|
||
it('create logs filter and call eth_getFilterLogs', async () => { | ||
// deploy contract | ||
let deployed = await helpers.deployContract('storage') | ||
let contractAddress = deployed.receipt.contractAddress | ||
|
||
// create logs filter on the address of the deployed contract | ||
let response = await helpers.callRPCMethod('eth_newFilter', [{ 'address': contractAddress }]) | ||
|
||
assert.equal(200, response.status) | ||
assert.isDefined(response.body['result']) | ||
let filterID = response.body['result'] | ||
|
||
// make contract function call that emits a log | ||
let res = await helpers.signAndSend({ | ||
from: conf.eoa.address, | ||
to: contractAddress, | ||
data: deployed.contract.methods.sum(15, 20).encodeABI(), | ||
gas: 1000000, | ||
gasPrice: 0 | ||
}) | ||
assert.equal(res.receipt.status, conf.successStatus) | ||
|
||
// check the matching items from the logs filter | ||
response = await helpers.callRPCMethod('eth_getFilterLogs', [filterID]) | ||
|
||
assert.equal(200, response.status) | ||
assert.equal(1, response.body['result'].length) | ||
|
||
let logs = response.body['result'] | ||
assert.equal(contractAddress.toLowerCase(), logs[0].address) | ||
assert.lengthOf(logs[0].topics, 4) | ||
assert.equal( | ||
'35', | ||
web3.eth.abi.decodeParameter("int256", logs[0].data) | ||
) | ||
|
||
// make contract function call that emits another log | ||
res = await helpers.signAndSend({ | ||
from: conf.eoa.address, | ||
to: contractAddress, | ||
data: deployed.contract.methods.sum(30, 20).encodeABI(), | ||
gas: 1000000, | ||
gasPrice: 0 | ||
}) | ||
|
||
assert.equal(res.receipt.status, conf.successStatus) | ||
|
||
// check the matching items from the logs filter include both logs | ||
// from the above 2 contract function calls | ||
response = await helpers.callRPCMethod('eth_getFilterLogs', [filterID]) | ||
|
||
assert.equal(200, response.status) | ||
assert.equal(2, response.body['result'].length) | ||
logs = response.body['result'] | ||
console.log() | ||
|
||
assert.equal(contractAddress.toLowerCase(), logs[1].address) | ||
assert.lengthOf(logs[1].topics, 4) | ||
assert.equal( | ||
'50', | ||
web3.eth.abi.decodeParameter("int256", logs[1].data) | ||
) | ||
|
||
}).timeout(10 * 1000) |
Oops, something went wrong.