Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
# That file is used for some automated workflows, and maps controller to owning team(s).

* @MetaMask/core-platform @MetaMask/networks

packages/bitcoin-wallet-snap @MetaMask/networks
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Each snap in this repository has its own README with installation and usage inst

<!-- start package list -->

- [`@metamask/bitcoin-wallet-snap`](packages/bitcoin-wallet-snap)
- [`@metamask/sample-snap`](packages/sample-snap)

<!-- end package list -->
137 changes: 136 additions & 1 deletion eslint-suppressions.json
Original file line number Diff line number Diff line change
@@ -1 +1,136 @@
{}
{
"packages/bitcoin-wallet-snap/integration-test/client-request.test.ts": {
"@typescript-eslint/no-explicit-any": {
"count": 1
},
"jest/no-disabled-tests": {
"count": 1
},
"no-restricted-syntax": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/integration-test/cron-sync.test.ts": {
"n/no-sync": {
"count": 1
},
"no-restricted-syntax": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/integration-test/keyring-request.test.ts": {
"no-restricted-syntax": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/integration-test/keyring.test.ts": {
"jest/no-disabled-tests": {
"count": 1
},
"no-restricted-syntax": {
"count": 3
}
},
"packages/bitcoin-wallet-snap/scripts/build-preinstalled-snap.js": {
"n/no-sync": {
"count": 2
}
},
"packages/bitcoin-wallet-snap/scripts/populate-en-locale.js": {
"n/no-sync": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/snap.config.ts": {
"import-x/no-nodejs-modules": {
"count": 1
},
"no-restricted-globals": {
"count": 14
}
},
"packages/bitcoin-wallet-snap/src/handlers/KeyringHandler.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 4
}
},
"packages/bitcoin-wallet-snap/src/handlers/RpcHandler.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 2
},
"@typescript-eslint/no-explicit-any": {
"count": 12
}
},
"packages/bitcoin-wallet-snap/src/handlers/UserInputHandler.ts": {
"no-restricted-syntax": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/handlers/mappings.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 3
},
"@typescript-eslint/no-explicit-any": {
"count": 17
}
},
"packages/bitcoin-wallet-snap/src/handlers/validation.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 4
}
},
"packages/bitcoin-wallet-snap/src/infra/SnapClientAdapter.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/infra/jsx/components/SendForm.tsx": {
"id-length": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/infra/jsx/confirmations/SignMessageConfirmationView.tsx": {
"id-length": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/infra/jsx/confirmations/SignPsbtConfirmationView.tsx": {
"id-length": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/infra/jsx/send-flow/ReviewTransactionView.tsx": {
"id-length": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/infra/jsx/send-flow/SendFormView.tsx": {
"id-length": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/infra/jsx/unified-send-flow/UnifiedSendFormView.tsx": {
"id-length": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/store/BdkAccountRepository.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/store/InMemoryCache.test.ts": {
"@typescript-eslint/no-explicit-any": {
"count": 1
}
},
"packages/bitcoin-wallet-snap/src/use-cases/SendFlowUseCases.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
},
"@typescript-eslint/no-explicit-any": {
"count": 5
}
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@
"simple-git-hooks": "^2.8.0",
"ts-jest": "^29.4.1",
"tsx": "^4.20.5",
"typescript": "~5.7.3",
"typescript": "~5.8.3",
"typescript-eslint": "^8.48.0",
"yargs": "^17.7.2"
},
"resolutions": {
"@metamask/snaps-sdk": "^11.0.0",
"@metamask/snaps-sdk": "11.1.1",
Comment thread
gabrieledm marked this conversation as resolved.
"elliptic@6.5.4": "^6.5.7",
"fast-xml-parser@^4.3.4": "^4.4.1",
"hash-base@npm:^3.0.0": "3.1.0",
"ripemd160@npm:^2.0.1": "2.0.2",
"ws@7.4.6": "^7.5.10"
},
"simple-git-hooks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { FeeType, BtcAccountType, BtcScope } from '@metamask/keyring-api';
import type { Snap } from '@metamask/snaps-jest';
import { installSnap } from '@metamask/snaps-jest';

import { BlockchainTestUtils } from './blockchain-utils';
import { MNEMONIC, ORIGIN, TEST_ADDRESS_REGTEST } from './constants';
import { CurrencyUnit, TrackingSnapEvent } from '../src/entities';
import { Caip19Asset } from '../src/handlers/caip';
import { BlockchainTestUtils } from './blockchain-utils';
import { MNEMONIC, ORIGIN, TEST_ADDRESS_REGTEST } from './constants';

const ACCOUNT_INDEX = 1;

Expand All @@ -28,7 +28,7 @@ describe('OnClientRequestHandler', () => {
snap.mockJsonRpc((request) => {
if (request.method === 'snap_manageAccounts') {
const params = request.params as Record<string, unknown> | undefined;
if (params && params.method === 'getSelectedAccounts') {
if (params?.method === 'getSelectedAccounts') {
return createdAccountId ? [createdAccountId] : [];
}
return null;
Expand Down Expand Up @@ -90,7 +90,6 @@ describe('OnClientRequestHandler', () => {
response.response as { result: { transactionId: string } }
).result;

/* eslint-disable @typescript-eslint/naming-convention */
expect(response).toTrackEvent({
event: TrackingSnapEvent.TransactionSubmitted,
properties: {
Expand All @@ -101,7 +100,6 @@ describe('OnClientRequestHandler', () => {
tx_id: transactionId,
},
});
/* eslint-enable @typescript-eslint/naming-convention */

await blockchain.mineBlocks(6);

Expand All @@ -112,7 +110,6 @@ describe('OnClientRequestHandler', () => {

expect(finalSyncResponse).toRespondWith(null);

/* eslint-disable @typescript-eslint/naming-convention */
expect(finalSyncResponse).toTrackEvent({
event: TrackingSnapEvent.TransactionFinalized,
properties: {
Expand All @@ -123,7 +120,6 @@ describe('OnClientRequestHandler', () => {
tx_id: transactionId,
},
});
/* eslint-enable @typescript-eslint/naming-convention */
});

it('fails if incorrect PSBT', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { BtcAccountType, BtcScope } from '@metamask/keyring-api';
import type { Snap } from '@metamask/snaps-jest';
import { installSnap } from '@metamask/snaps-jest';

import { TrackingSnapEvent } from '../src/entities';
import { BlockchainTestUtils } from './blockchain-utils';
import { MNEMONIC, ORIGIN } from './constants';
import { TrackingSnapEvent } from '../src/entities';

const ACCOUNT_INDEX = 2;

Expand All @@ -30,7 +30,7 @@ describe('CronHandler', () => {
snap.mockJsonRpc((request) => {
if (request.method === 'snap_manageAccounts') {
const params = request.params as Record<string, unknown> | undefined;
if (params && params.method === 'getSelectedAccounts') {
if (params?.method === 'getSelectedAccounts') {
return [...accountsToSync];
}
return null;
Expand Down Expand Up @@ -89,7 +89,6 @@ describe('CronHandler', () => {
});
expect(syncResponse).toRespondWith(null);

/* eslint-disable @typescript-eslint/naming-convention */
expect(syncResponse).toTrackEvent({
event: 'Transaction Received',
properties: {
Expand All @@ -100,7 +99,6 @@ describe('CronHandler', () => {
tx_id: txid,
},
});
/* eslint-enable @typescript-eslint/naming-convention */

// send a transaction to the account
txid = await blockchain.sendToAddress(account.address, 5);
Expand All @@ -114,7 +112,6 @@ describe('CronHandler', () => {

expect(syncResponse).toRespondWith(null);

/* eslint-disable @typescript-eslint/naming-convention */
expect(syncResponse).toTrackEvent({
event: TrackingSnapEvent.TransactionReceived,
properties: {
Expand All @@ -125,6 +122,5 @@ describe('CronHandler', () => {
tx_id: txid,
},
});
/* eslint-enable @typescript-eslint/naming-convention */
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ services:
image: blockstream/esplora
container_name: esplora
ports:
- "50001:50001"
- "8094:80"
- '50001:50001'
- '8094:80'
volumes:
- ./init-esplora.sh:/init-esplora.sh
entrypoint:
- bash
- -c
- "/srv/explorer/run.sh bitcoin-regtest explorer"
- '/srv/explorer/run.sh bitcoin-regtest explorer'
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { BtcScope } from '@metamask/keyring-api';
import type { Snap } from '@metamask/snaps-jest';
import { assertIsConfirmationDialog, installSnap } from '@metamask/snaps-jest';

import { BlockchainTestUtils } from './blockchain-utils';
import { MNEMONIC, ORIGIN } from './constants';
import { AccountCapability } from '../src/entities';
import { Caip19Asset } from '../src/handlers/caip';
import type { FillPsbtResponse } from '../src/handlers/KeyringRequestHandler';
import { BlockchainTestUtils } from './blockchain-utils';
import { MNEMONIC, ORIGIN } from './constants';

const ACCOUNT_INDEX = 3;
const submitRequestMethod = 'keyring_submitRequest';
Expand All @@ -30,7 +30,7 @@ describe('KeyringRequestHandler', () => {
snap.mockJsonRpc((request) => {
if (request.method === 'snap_manageAccounts') {
const params = request.params as Record<string, unknown> | undefined;
if (params && params.method === 'getSelectedAccounts') {
if (params?.method === 'getSelectedAccounts') {
return createdAccountId ? [createdAccountId] : [];
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { BtcAccountType, BtcScope } from '@metamask/keyring-api';
import type { Snap } from '@metamask/snaps-jest';
import { installSnap } from '@metamask/snaps-jest';

import { AccountCapability, CurrencyUnit } from '../src/entities';
import { Caip19Asset } from '../src/handlers/caip';
import {
FUNDING_TX,
MNEMONIC,
Expand All @@ -12,8 +14,6 @@ import {
scopeToCoinType,
accountTypeToPurpose,
} from './constants';
import { AccountCapability, CurrencyUnit } from '../src/entities';
import { Caip19Asset } from '../src/handlers/caip';

const ACCOUNT_INDEX = 0;

Expand All @@ -35,7 +35,7 @@ describe('Keyring', () => {
snap.mockJsonRpc((request) => {
if (request.method === 'snap_manageAccounts') {
const params = request.params as Record<string, unknown> | undefined;
if (params && params.method === 'getSelectedAccounts') {
if (params?.method === 'getSelectedAccounts') {
return [];
}
return null;
Expand Down Expand Up @@ -105,7 +105,6 @@ describe('Keyring', () => {
methods: Object.values(AccountCapability),
});

// eslint-disable-next-line jest/no-conditional-in-test
if ('result' in response.response) {
accounts[TEST_ADDRESS_REGTEST] = response.response
.result as KeyringAccount;
Expand Down Expand Up @@ -158,7 +157,6 @@ describe('Keyring', () => {
methods: Object.values(AccountCapability),
});

// eslint-disable-next-line jest/no-conditional-in-test
if ('result' in response.response) {
accounts[expectedAddress] = response.response.result as KeyringAccount;
}
Expand Down Expand Up @@ -230,7 +228,6 @@ describe('Keyring', () => {
methods: Object.values(AccountCapability),
});

// eslint-disable-next-line jest/no-conditional-in-test
if ('result' in response.response) {
accounts[expectedAddress] = response.response.result as KeyringAccount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ const config = {
};

export default config;

Loading
Loading