-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adapt to eip-1193 provider changes #170
Changes from all commits
b8f0d9f
0e2c7e1
ef23c17
16852d0
bde6337
e9270df
57588a0
48cf432
7f42661
4c1b618
53ed08d
07ff2d9
6cda797
6c4895d
60c5a88
a7d1093
3a7ea87
b01abdc
4de508a
1f0ff57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
"@metamask/auto-changelog": "^3.3.0", | ||
"@metamask/eth-json-rpc-middleware": "^13.0.0", | ||
"@metamask/eth-block-tracker": "~10.0.0 || ^10.1.1", | ||
"ganache-cli": "^6.12.2", | ||
"ganache": "^7.9.2", | ||
"sinon": "^15.2.0", | ||
"tape": "^5.7.0" | ||
}, | ||
|
@@ -52,8 +52,14 @@ | |
"ethereumjs-util>ethereum-cryptography>keccak": false, | ||
"ethereumjs-util>ethereum-cryptography>secp256k1": false, | ||
"ethjs-query>babel-runtime>core-js": false, | ||
"ganache-cli>ethereumjs-util>ethereum-cryptography>keccak": false, | ||
"ganache-cli>ethereumjs-util>ethereum-cryptography>secp256k1": false | ||
"ganache>keccak": false, | ||
"ganache>secp256k1": false, | ||
"ganache>@trufflesuite/bigint-buffer": false, | ||
"ganache>@trufflesuite/uws-js-unofficial>bufferutil": false, | ||
"ganache>@trufflesuite/uws-js-unofficial>utf-8-validate": false, | ||
"ganache>bufferutil": false, | ||
"ganache>leveldown": false, | ||
"ganache>utf-8-validate": false | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,21 @@ const { | |
test('LogFilter - basic', asyncTest(async (t) => { | ||
|
||
const tools = createTestSetup() | ||
const { sendAsync } = tools | ||
const { request } = tools | ||
|
||
// deploy log-echo contract | ||
const coinbase = await sendAsync({ method: 'eth_coinbase' }) | ||
const { contractAddress } = await deployLogEchoContract({ tools, from: coinbase }) | ||
const accounts = await request({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was throwing |
||
method: "eth_accounts", | ||
params: [] | ||
}); | ||
const fromAccount = accounts[0]; | ||
const { contractAddress } = await deployLogEchoContract({ tools, from: fromAccount }) | ||
t.ok(contractAddress, 'got deployed contract address') | ||
|
||
// create filter | ||
const blockNumber = await sendAsync({ method: 'eth_blockNumber' }) | ||
const blockNumber = await request({ method: 'eth_blockNumber' }) | ||
const targetTopic = '0xaabbcce106361d4f6cd9098051596d565c1dbf7bc20b4c3acb3aaa4204aabbcc' | ||
const filterId = await sendAsync({ | ||
const filterId = await request({ | ||
method: 'eth_newFilter', | ||
params: { | ||
address: contractAddress, | ||
|
@@ -30,17 +34,17 @@ test('LogFilter - basic', asyncTest(async (t) => { | |
t.ok(filterId, `got filter id: ${filterId} (${typeof filterId})`) | ||
|
||
// trigger filter | ||
const triggeringTxHash = await sendAsync({ | ||
const triggeringTxHash = await request({ | ||
method: 'eth_sendTransaction', | ||
params: { | ||
from: coinbase, | ||
params: [{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was throwing |
||
from: fromAccount, | ||
to: contractAddress, | ||
data: targetTopic | ||
} | ||
}] | ||
}) | ||
await tools.trackNextBlock() | ||
// check filter | ||
const filterChanges = await sendAsync({ | ||
const filterChanges = await request({ | ||
method: 'eth_getFilterChanges', | ||
params: [filterId] | ||
}) | ||
|
@@ -51,30 +55,34 @@ test('LogFilter - basic', asyncTest(async (t) => { | |
const matchedTopic = matchingFilter.topics[0] | ||
t.equal(matchedTopic, targetTopic, 'topic matches expected') | ||
|
||
await sendAsync({ method: 'eth_uninstallFilter', params: [filterId] }) | ||
await request({ method: 'eth_uninstallFilter', params: [filterId] }) | ||
})) | ||
|
||
test('LogFilter - multiple blocks', asyncTest(async (t) => { | ||
|
||
const tools = createTestSetup() | ||
const { sendAsync } = tools | ||
const { request } = tools | ||
|
||
// deploy log-echo contract | ||
const coinbase = await sendAsync({ method: 'eth_coinbase' }) | ||
const { contractAddress } = await deployLogEchoContract({ tools, from: coinbase }) | ||
const accounts = await request({ | ||
method: "eth_accounts", | ||
params: [] | ||
}); | ||
const fromAcccount = accounts[0]; | ||
const { contractAddress } = await deployLogEchoContract({ tools, from: fromAcccount }) | ||
t.ok(contractAddress, 'got deployed contract address') | ||
|
||
// create filter | ||
const blockNumber = await sendAsync({ method: 'eth_blockNumber' }) | ||
const blockNumber = await request({ method: 'eth_blockNumber' }) | ||
const targetTopic = '0x112233e106361d4f6cd9098051596d565c1dbf7bc20b4c3acb3aaa4204112233' | ||
const filterId = await sendAsync({ | ||
const filterId = await request({ | ||
method: 'eth_newFilter', | ||
params: { | ||
params: [{ | ||
address: contractAddress, | ||
topics: [targetTopic], | ||
fromBlock: blockNumber, | ||
toBlock: 'latest' | ||
} | ||
}] | ||
}) | ||
t.ok(filterId, `got filter id: ${filterId} (${typeof filterId})`) | ||
|
||
|
@@ -87,13 +95,13 @@ test('LogFilter - multiple blocks', asyncTest(async (t) => { | |
await tools.trackNextBlock() | ||
|
||
// trigger filter | ||
const triggeringTxHash = await sendAsync({ | ||
const triggeringTxHash = await request({ | ||
method: 'eth_sendTransaction', | ||
params: { | ||
from: coinbase, | ||
params: [{ | ||
from: fromAcccount, | ||
to: contractAddress, | ||
data: targetTopic | ||
} | ||
}] | ||
}) | ||
await tools.trackNextBlock() | ||
|
||
|
@@ -104,7 +112,7 @@ test('LogFilter - multiple blocks', asyncTest(async (t) => { | |
await tools.trackNextBlock() | ||
|
||
// check filter | ||
const filterChanges = await sendAsync({ | ||
const filterChanges = await request({ | ||
method: 'eth_getFilterChanges', | ||
params: [filterId] | ||
}) | ||
|
@@ -115,23 +123,23 @@ test('LogFilter - multiple blocks', asyncTest(async (t) => { | |
const matchedTopic = matchingFilter.topics[0] | ||
t.equal(matchedTopic, targetTopic, 'topic matches expected') | ||
|
||
await sendAsync({ method: 'eth_uninstallFilter', params: [filterId] }) | ||
await request({ method: 'eth_uninstallFilter', params: [filterId] }) | ||
})) | ||
|
||
test('BlockFilter - basic', asyncTest(async (t) => { | ||
|
||
const tools = createTestSetup() | ||
const { sendAsync } = tools | ||
const { request } = tools | ||
|
||
// await first block | ||
await tools.trackNextBlock() | ||
|
||
// create filter | ||
const filterId = await sendAsync({ method: 'eth_newBlockFilter', }) | ||
const filterId = await request({ method: 'eth_newBlockFilter', }) | ||
t.ok(filterId, `got filter id: ${filterId} (${typeof filterId})`) | ||
|
||
// check filter | ||
const filterChanges1 = await sendAsync({ | ||
const filterChanges1 = await request({ | ||
method: 'eth_getFilterChanges', | ||
params: [filterId] | ||
}) | ||
|
@@ -140,17 +148,16 @@ test('BlockFilter - basic', asyncTest(async (t) => { | |
// await one block | ||
await tools.forceNextBlock() | ||
await tools.trackNextBlock() | ||
|
||
// check filter | ||
const filterChanges2 = await sendAsync({ | ||
const filterChanges2 = await request({ | ||
method: 'eth_getFilterChanges', | ||
params: [filterId] | ||
}) | ||
t.equal(filterChanges2.length, 1, 'only one matched filter') | ||
const matchingFilter1 = filterChanges2[0] | ||
t.equal(matchingFilter1.length, 2 + 32 * 2, 'result is correct length for block hash') | ||
// check filter | ||
const filterChanges3 = await sendAsync({ | ||
const filterChanges3 = await request({ | ||
method: 'eth_getFilterChanges', | ||
params: [filterId] | ||
}) | ||
|
@@ -163,7 +170,7 @@ test('BlockFilter - basic', asyncTest(async (t) => { | |
await tools.trackNextBlock() | ||
|
||
// check filter | ||
const filterChanges4 = await sendAsync({ | ||
const filterChanges4 = await request({ | ||
method: 'eth_getFilterChanges', | ||
params: [filterId] | ||
}) | ||
|
@@ -174,7 +181,7 @@ test('BlockFilter - basic', asyncTest(async (t) => { | |
t.equal(matchingFilter3.length, 2 + 32 * 2, 'result is correct length for block hash') | ||
t.notEqual(matchingFilter2, matchingFilter3, 'hashes are different') | ||
|
||
await sendAsync({ | ||
await request({ | ||
method: 'eth_uninstallFilter', | ||
params: [filterId] | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,14 +53,18 @@ test('subscriptions - newHeads', asyncTest(async (t) => { | |
test('subscriptions - log', asyncTest(async (t) => { | ||
|
||
const tools = createTestSetup() | ||
const { sendAsync, subs, blockTracker } = tools | ||
const { request, subs, blockTracker } = tools | ||
|
||
// deploy log-echo contract | ||
const coinbase = await sendAsync({ method: 'eth_coinbase' }) | ||
const { contractAddress } = await deployLogEchoContract({ tools, from: coinbase }) | ||
const accounts = await request({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was throwing |
||
method: "eth_accounts", | ||
params: [] | ||
}); | ||
const fromAcccount = accounts[0]; | ||
const { contractAddress } = await deployLogEchoContract({ tools, from: fromAcccount }) | ||
t.ok(contractAddress, 'got deployed contract address') | ||
// deploy secondary "wrong" log contract | ||
const wrongContractAddress = (await deployLogEchoContract({ tools, from: coinbase })).contractAddress | ||
const wrongContractAddress = (await deployLogEchoContract({ tools, from: fromAcccount })).contractAddress | ||
|
||
// create subscription | ||
const subResults = [] | ||
|
@@ -79,27 +83,27 @@ test('subscriptions - log', asyncTest(async (t) => { | |
t.equal(typeof subId, 'string', `got sub id as hex string (${typeof subId})`) | ||
|
||
// trigger matching log | ||
const triggeringTxHash = await sendAsync({ | ||
const triggeringTxHash = await request({ | ||
method: 'eth_sendTransaction', | ||
params: { from: coinbase, to: contractAddress, data: targetTopic } | ||
params: [{ from: fromAcccount, to: contractAddress, data: targetTopic }] | ||
}) | ||
await tools.trackNextBlock() | ||
|
||
// trigger non-matching log | ||
await sendAsync({ | ||
await request({ | ||
method: 'eth_sendTransaction', | ||
params: { | ||
from: coinbase, | ||
params: [{ | ||
from: fromAcccount, | ||
to: contractAddress, | ||
data: wrongTopic | ||
} | ||
}] | ||
}) | ||
await tools.trackNextBlock() | ||
|
||
// trigger non-matching contract | ||
await sendAsync({ | ||
await request({ | ||
method: 'eth_sendTransaction', | ||
params: { from: coinbase, to: wrongContractAddress, data: targetTopic } | ||
params: [{ from: fromAcccount, to: wrongContractAddress, data: targetTopic }] | ||
}) | ||
await tools.trackNextBlock() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New ganache config has been added to fix.