Skip to content

Support Multi-SRP in SeedlessOnboardingController #5

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
11d6552
feat: added 'encryptionKey' and 'encryptionSalt' to state
lwin-kyaw Apr 22, 2025
5a2953c
feat: add new private method, 'verifyPassword` to verify password val…
lwin-kyaw Apr 22, 2025
3aa52ba
feat: updated vault encryption scheme
lwin-kyaw Apr 22, 2025
5347ab5
feat: add new method 'addNewSeedPhraseBackup' for multi-srp
lwin-kyaw Apr 22, 2025
3301236
fix: fixed vaultEncKey and password check
lwin-kyaw Apr 22, 2025
534f04c
test: updated tests for multi-srp and new vault encryption scheme
lwin-kyaw Apr 22, 2025
57636e6
lint: removed unused imports
lwin-kyaw Apr 22, 2025
b15d1d9
feat: locked controller and clear secrets on keyring lock state
lwin-kyaw Apr 22, 2025
6cae65b
fix: removed password cache value from Controller
lwin-kyaw Apr 22, 2025
f8dd9fb
test: fixed and updated tests
lwin-kyaw Apr 22, 2025
4e3447e
Merge remote-tracking branch 'origin/feat/seedless-onboarding-control…
lwin-kyaw Apr 24, 2025
9198631
feat: sync SeedlessOnboardingController lock with Keyring
lwin-kyaw Apr 24, 2025
9716513
feat: allow multiple backupState in updateBackupMetadataState method
lwin-kyaw Apr 25, 2025
ad56538
feat: change order of seedPhrases in fetchAllSeedPhrase method
lwin-kyaw Apr 25, 2025
f2b5d96
fix: use Keyring Encryptor as vault encryptor
lwin-kyaw Apr 29, 2025
9b2cb7b
chore: added controller tgz to git
lwin-kyaw Apr 29, 2025
b22516f
fix: encryptor type
ieow Apr 29, 2025
31d7796
fix: remove un-needed typing
ieow Apr 29, 2025
4dcc584
Merge pull request #7 from Web3Auth/fix/encryptor-type
lwin-kyaw Apr 29, 2025
ea742ec
chore: updated tgz
lwin-kyaw Apr 29, 2025
885b798
fix: remove web encryptor from controller
ieow Apr 30, 2025
816abb7
feat: update package.tgz
ieow Apr 30, 2025
5de4c1d
fix: make setUnlocked public
ieow Apr 30, 2025
51da766
feat: update package.tgz
ieow Apr 30, 2025
37f7a80
fix: cannot write private member
ieow Apr 30, 2025
e26e29b
feat: update package.tgz
ieow Apr 30, 2025
bc23413
Merge remote-tracking branch 'origin/fix/encryptor-type' into fix/enc…
lwin-kyaw May 6, 2025
b5931c1
fix: fixed tests
lwin-kyaw May 6, 2025
3065919
Merge pull request #8 from Web3Auth/fix/encryptor-type
lwin-kyaw May 6, 2025
e160282
Merge remote-tracking branch 'origin/feat/seedless-onboarding-control…
lwin-kyaw May 6, 2025
b7201c3
Merge remote-tracking branch 'origin/feat/seedless-multi-srp' into fe…
lwin-kyaw May 6, 2025
c1619fc
fix: removed 'assertIsUnlocked' check in 'setLock' method
lwin-kyaw May 6, 2025
fcb4aa2
Merge remote-tracking branch 'origin/feat/seedless-onboarding-control…
lwin-kyaw May 7, 2025
765bfcc
feat: updated seedless-onboarding-controller tgz package
lwin-kyaw May 7, 2025
4ea5e37
Merge remote-tracking branch 'origin/feat/seedless-onboarding-control…
lwin-kyaw May 12, 2025
e856469
chore: used 'some' instead of 'find' to check the existing backup data
lwin-kyaw May 12, 2025
264641d
feat: update metadata class to support multiple secret types
lwin-kyaw May 13, 2025
fd81fc4
test: updated tests
lwin-kyaw May 13, 2025
da85dbd
chore: updated seedless-onboarding-controller tgz package
lwin-kyaw May 13, 2025
25eef94
chore: update 'ISecretMetadata' to include SecretType
lwin-kyaw May 13, 2025
0aeb958
Merge remote-tracking branch 'origin/feat/seedless-onboarding-control…
lwin-kyaw May 13, 2025
ed12037
chore: updated tgz package
lwin-kyaw May 13, 2025
0b67570
feat: add 'version' to SecretMetadata
lwin-kyaw May 14, 2025
ceda10e
feat: make 'data' field to Generic in SecretMetadata
lwin-kyaw May 14, 2025
cda6764
test: updated tests
lwin-kyaw May 14, 2025
7edfcb7
Merge remote-tracking branch 'origin/feat/seedless-multi-srp' into fe…
lwin-kyaw May 14, 2025
7104c8c
Merge pull request #12 from Web3Auth/feat/secret-metadata-type
chaitanyapotti May 14, 2025
607badb
Merge remote-tracking branch 'origin/feat/seedless-onboarding-control…
lwin-kyaw May 22, 2025
d00bf53
chore: removed redundant unittests
lwin-kyaw May 22, 2025
e280b1e
docs: updated ChangeLog
lwin-kyaw May 22, 2025
7320a8f
feat: fetch SeedPhrases backup with cached encryption key
lwin-kyaw May 29, 2025
0537c4f
Merge remote-tracking branch 'origin/main' into feat/seedless-multi-srp
lwin-kyaw May 29, 2025
5f8ef7b
fix: fixed lint
lwin-kyaw May 29, 2025
3308a1b
Merge remote-tracking branch 'upstream/feat/seedless-onboarding-contr…
lwin-kyaw May 29, 2025
dbd6206
docs: updated change log
lwin-kyaw May 29, 2025
e357ab5
chore: removed tgz package
lwin-kyaw May 29, 2025
a21e531
Release/413.0.0 (#5872)
bergarces May 29, 2025
fa1ad82
Includes `origin` for `wallet_sendCalls` security alert requests (#5876)
vinistevam May 29, 2025
01869a6
Fix block tracker not resolving for failed requests (#5860)
mcmire May 29, 2025
1c132ff
feat: Seedless Onboarding Controller (#5874)
lwin-kyaw May 29, 2025
9a037b4
Update packages/seedless-onboarding-controller/src/SecretMetadata.ts
chaitanyapotti May 29, 2025
eb04c53
Release 414.0.0 (#5878)
vinistevam May 29, 2025
7ad1c94
Merge remote-tracking branch 'origin/main' into feat/seedless-multi-srp
lwin-kyaw May 29, 2025
47cf7b9
Merge remote-tracking branch 'upstream/feat/seedless-multi-srp' into …
lwin-kyaw May 29, 2025
b71ca77
fix: fixed lint
lwin-kyaw May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/core-monorepo",
"version": "412.0.0",
"version": "414.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"@metamask/eslint-config-jest": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/eth-block-tracker": "^11.0.3",
"@metamask/eth-block-tracker": "^12.0.1",
"@metamask/eth-json-rpc-provider": "^4.1.8",
"@metamask/json-rpc-engine": "^10.0.3",
"@metamask/utils": "^11.2.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [66.0.0]

### Added

- Add optional parameter to track DeFi metrics when positions are being fetched ([#5868](https://github.com/MetaMask/core/pull/5868))
- Add phishing protection for NFT metadata URLs in `NftController` ([#5598](https://github.com/MetaMask/core/pull/5598))
- NFT metadata URLs are now scanned for malicious content using the `PhishingController`
- Malicious URLs in NFT metadata fields (image, externalLink, etc.) are automatically sanitized
Expand Down Expand Up @@ -1674,7 +1677,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[66.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[65.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[64.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[63.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/assets-controllers",
"version": "65.0.0",
"version": "66.0.0",
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -91,7 +91,7 @@
"@metamask/providers": "^21.0.0",
"@metamask/snaps-controllers": "^11.2.1",
"@metamask/snaps-sdk": "^6.22.0",
"@metamask/transaction-controller": "^56.2.0",
"@metamask/transaction-controller": "^56.3.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
Expand Down
9 changes: 8 additions & 1 deletion packages/bridge-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [29.0.0]

### Changed

- **BREAKING:** Bump `@metamask/assets-controller` peer dependency to `^66.0.0` ([#5872](https://github.com/MetaMask/core/pull/5872))

## [28.0.0]

### Changed
Expand Down Expand Up @@ -281,7 +287,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[29.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[28.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[27.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[26.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/bridge-controller",
"version": "28.0.0",
"version": "29.0.0",
"description": "Manages bridge-related quote fetching functionality for MetaMask",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -65,14 +65,14 @@
},
"devDependencies": {
"@metamask/accounts-controller": "^29.0.0",
"@metamask/assets-controllers": "^65.0.0",
"@metamask/assets-controllers": "^66.0.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eth-json-rpc-provider": "^4.1.8",
"@metamask/network-controller": "^23.5.0",
"@metamask/remote-feature-flag-controller": "^1.6.0",
"@metamask/snaps-controllers": "^11.2.1",
"@metamask/superstruct": "^3.1.0",
"@metamask/transaction-controller": "^56.2.0",
"@metamask/transaction-controller": "^56.3.0",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand All @@ -86,7 +86,7 @@
},
"peerDependencies": {
"@metamask/accounts-controller": "^29.0.0",
"@metamask/assets-controllers": "^65.0.0",
"@metamask/assets-controllers": "^66.0.0",
"@metamask/network-controller": "^23.0.0",
"@metamask/remote-feature-flag-controller": "^1.6.0",
"@metamask/snaps-controllers": "^11.0.0",
Expand Down
9 changes: 8 additions & 1 deletion packages/bridge-status-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [26.0.0]

### Changed

- **BREAKING:** Bump `@metamask/bridge-controller` peer dependency to `^29.0.0` ([#5872](https://github.com/MetaMask/core/pull/5872))

## [25.0.0]

### Changed
Expand Down Expand Up @@ -268,7 +274,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[26.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[25.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[24.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[23.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge-status-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/bridge-status-controller",
"version": "25.0.0",
"version": "26.0.0",
"description": "Manages bridge-related status fetching functionality for MetaMask",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -60,12 +60,12 @@
"devDependencies": {
"@metamask/accounts-controller": "^29.0.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/bridge-controller": "^28.0.0",
"@metamask/bridge-controller": "^29.0.0",
"@metamask/gas-fee-controller": "^23.0.0",
"@metamask/multichain-transactions-controller": "^1.0.0",
"@metamask/network-controller": "^23.5.0",
"@metamask/snaps-controllers": "^11.2.1",
"@metamask/transaction-controller": "^56.2.0",
"@metamask/transaction-controller": "^56.3.0",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand All @@ -79,7 +79,7 @@
},
"peerDependencies": {
"@metamask/accounts-controller": "^29.0.0",
"@metamask/bridge-controller": "^28.0.0",
"@metamask/bridge-controller": "^29.0.0",
"@metamask/gas-fee-controller": "^23.0.0",
"@metamask/multichain-transactions-controller": "^1.0.0",
"@metamask/network-controller": "^23.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/earn-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@metamask/accounts-controller": "^29.0.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/network-controller": "^23.5.0",
"@metamask/transaction-controller": "^56.2.0",
"@metamask/transaction-controller": "^56.3.0",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/eth-json-rpc-infura` to `^10.2.0` ([#5867](https://github.com/MetaMask/core/pull/5867))
- Block tracker errors will no longer be wrapped under "PollingBlockTracker - encountered an error while attempting to update latest block" ([#5860](https://github.com/MetaMask/core/pull/5860))
- Bump dependencies ([#5867](https://github.com/MetaMask/core/pull/5867), [#5860](https://github.com/MetaMask/core/pull/5860))
- Bump `@metamask/eth-block-tracker` to `^12.0.1`
- Bump `@metamask/eth-json-rpc-infura` to `^10.2.0`
- Bump `@metamask/eth-json-rpc-middleware` to `^17.0.1`

### Fixed

Expand All @@ -20,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Other 4xx responses now throw a generic HTTP client error
- Invalid JSON responses now throw a "Parse" error
- Rather than throwing an error, NetworkController now corrects an invalid initial `selectedNetworkClientId` to point to the default RPC endpoint of the first network sorted by chain ID ([#5851](https://github.com/MetaMask/core/pull/5851))
- Fix the block tracker so that it will now reject if an error is thrown while making the request instead of hanging ([#5860](https://github.com/MetaMask/core/pull/5860))

## [23.5.0]

Expand Down
4 changes: 2 additions & 2 deletions packages/network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"@metamask/base-controller": "^8.0.1",
"@metamask/controller-utils": "^11.9.0",
"@metamask/error-reporting-service": "^0.0.0",
"@metamask/eth-block-tracker": "^11.0.3",
"@metamask/eth-block-tracker": "^12.0.1",
"@metamask/eth-json-rpc-infura": "^10.2.0",
"@metamask/eth-json-rpc-middleware": "^16.0.1",
"@metamask/eth-json-rpc-middleware": "^17.0.1",
"@metamask/eth-json-rpc-provider": "^4.1.8",
"@metamask/eth-query": "^4.0.0",
"@metamask/json-rpc-engine": "^10.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ export function testsForRpcMethodsThatCheckForBlockHashInResponse(
});

it('hits the RPC endpoint and does not reuse the result of a previous request if the latest block number was updated since', async () => {
const pollingInterval = 1234;
const requests = [{ method }, { method }];
const mockResults = [{ blockHash: '0x100' }, { blockHash: '0x200' }];

await withMockedCommunications({ providerType }, async (comms) => {
// Note that we have to mock these requests in a specific order. The
// first block tracker request occurs because of the first RPC
// request. The second block tracker request, however, does not occur
// because of the second RPC request, but rather because we call
// `clock.runAll()` below.
comms.mockNextBlockTrackerRequest({ blockNumber: '0x1' });
comms.mockRpcCall({
request: requests[0],
Expand All @@ -78,13 +74,32 @@ export function testsForRpcMethodsThatCheckForBlockHashInResponse(
});

const results = await withNetworkClient(
{ providerType },
async (client) => {
const firstResult = await client.makeRpcCall(requests[0]);
{
providerType,
getBlockTrackerOptions: () => ({
pollingInterval,
}),
},
async ({ blockTracker, makeRpcCall, clock }) => {
const waitForTwoBlocks = new Promise<void>((resolve) => {
let numberOfBlocks = 0;

// Start the block tracker
blockTracker.on('latest', () => {
numberOfBlocks += 1;
// eslint-disable-next-line jest/no-conditional-in-test
if (numberOfBlocks === 2) {
resolve();
}
});
});

const firstResult = await makeRpcCall(requests[0]);
// Proceed to the next iteration of the block tracker so that a new
// block is fetched and the current block is updated.
client.clock.runAll();
const secondResult = await client.makeRpcCall(requests[1]);
await clock.tickAsync(pollingInterval);
await waitForTwoBlocks;
const secondResult = await makeRpcCall(requests[1]);
return [firstResult, secondResult];
},
);
Expand Down
39 changes: 27 additions & 12 deletions packages/network-controller/tests/provider-api-tests/block-param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,14 @@ export function testsForRpcMethodSupportingBlockParam(
}

it('hits the RPC endpoint and does not reuse the result of a previous request if the latest block number was updated since', async () => {
const pollingInterval = 1234;
const requests = [
{ method, params: buildMockParams({ blockParamIndex, blockParam }) },
{ method, params: buildMockParams({ blockParamIndex, blockParam }) },
];
const mockResults = ['first result', 'second result'];

await withMockedCommunications({ providerType }, async (comms) => {
// Note that we have to mock these requests in a specific order.
// The first block tracker request occurs because of the first RPC
// request. The second block tracker request, however, does not
// occur because of the second RPC request, but rather because we
// call `clock.runAll()` below.
comms.mockNextBlockTrackerRequest({ blockNumber: '0x100' });
// The block-ref middleware will make the request as specified
// except that the block param is replaced with the latest block
Expand All @@ -178,13 +174,32 @@ export function testsForRpcMethodSupportingBlockParam(
});

const results = await withNetworkClient(
{ providerType },
async (client) => {
const firstResult = await client.makeRpcCall(requests[0]);
// Proceed to the next iteration of the block tracker so that a
// new block is fetched and the current block is updated.
client.clock.runAll();
const secondResult = await client.makeRpcCall(requests[1]);
{
providerType,
getBlockTrackerOptions: () => ({
pollingInterval,
}),
},
async ({ blockTracker, makeRpcCall, clock }) => {
const waitForTwoBlocks = new Promise<void>((resolve) => {
let numberOfBlocks = 0;

// Start the block tracker
blockTracker.on('latest', () => {
numberOfBlocks += 1;
// eslint-disable-next-line jest/no-conditional-in-test
if (numberOfBlocks === 2) {
resolve();
}
});
});

const firstResult = await makeRpcCall(requests[0]);
// Proceed to the next iteration of the block tracker so that a new
// block is fetched and the current block is updated.
await clock.tickAsync(pollingInterval);
await waitForTwoBlocks;
const secondResult = await makeRpcCall(requests[1]);
return [firstResult, secondResult];
},
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { JSONRPCResponse } from '@json-rpc-specification/meta-schema';
import type { InfuraNetworkType } from '@metamask/controller-utils';
import { BUILT_IN_NETWORKS } from '@metamask/controller-utils';
import type { BlockTracker } from '@metamask/eth-block-tracker';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import EthQuery from '@metamask/eth-query';
import type { Hex } from '@metamask/utils';
Expand Down Expand Up @@ -388,9 +389,7 @@ export async function withMockedCommunications(
}

type MockNetworkClient = {
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
blockTracker: any;
blockTracker: BlockTracker;
provider: SafeEventEmitterProvider;
clock: sinon.SinonFakeTimers;
// TODO: Replace `any` with type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,11 @@ export function testsForRpcMethodAssumingNoBlockParam(
}

it('hits the RPC endpoint and does not reuse the result of a previous request if the latest block number was updated since', async () => {
const pollingInterval = 1234;
const requests = [{ method }, { method }];
const mockResults = ['first result', 'second result'];

await withMockedCommunications({ providerType }, async (comms) => {
// Note that we have to mock these requests in a specific order. The
// first block tracker request occurs because of the first RPC request.
// The second block tracker request, however, does not occur because of
// the second RPC request, but rather because we call `clock.runAll()`
// below.
comms.mockNextBlockTrackerRequest({ blockNumber: '0x1' });
comms.mockRpcCall({
request: requests[0],
Expand All @@ -118,13 +114,32 @@ export function testsForRpcMethodAssumingNoBlockParam(
});

const results = await withNetworkClient(
{ providerType },
async (client) => {
const firstResult = await client.makeRpcCall(requests[0]);
{
providerType,
getBlockTrackerOptions: () => ({
pollingInterval,
}),
},
async ({ blockTracker, makeRpcCall, clock }) => {
const waitForTwoBlocks = new Promise<void>((resolve) => {
let numberOfBlocks = 0;

// Start the block tracker
blockTracker.on('latest', () => {
numberOfBlocks += 1;
// eslint-disable-next-line jest/no-conditional-in-test
if (numberOfBlocks === 2) {
resolve();
}
});
});

const firstResult = await makeRpcCall(requests[0]);
// Proceed to the next iteration of the block tracker so that a new
// block is fetched and the current block is updated.
client.clock.runAll();
const secondResult = await client.makeRpcCall(requests[1]);
await clock.tickAsync(pollingInterval);
await waitForTwoBlocks;
const secondResult = await makeRpcCall(requests[1]);
return [firstResult, secondResult];
},
);
Expand Down
Loading
Loading