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: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v21.7.3
v22.17.0
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Thank you for your interest in contributing to the Snap Solana Wallet project! T

- [MetaMask Flask](https://consensyssoftware.atlassian.net/wiki/x/IQCOB10) is required for testing the snap locally
- [NVM](https://github.com/creationix/nvm) to manage Node.js and avoid compatibility issues between different projects
- Node.js `21.7.3` as specified in `.nvmrc`
- Node.js `v22.17.0` as specified in `.nvmrc`
- Yarn `3.8.6` is required due to MetaMask package compatibility

## 🚀 Quick Start
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"yarn lint:fix"
]
},
"resolutions": {
"@metamask/snaps-sdk": "8.1.0"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"@metamask/key-tree": "9.1.2",
"@metamask/keyring-api": "^18.0.0",
"@metamask/keyring-snap-sdk": "^4.0.0",
"@metamask/snaps-cli": "^7.2.0",
"@metamask/snaps-jest": "8.12.0",
"@metamask/snaps-sdk": "^7.1.0",
"@metamask/snaps-cli": "^8.1.0",
"@metamask/snaps-jest": "9.2.0",
"@metamask/snaps-sdk": "^8.1.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "11.4.0",
"@noble/ed25519": "2.1.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snap-solana-wallet.git"
},
"source": {
"shasum": "CGJCQcU/gwXmG51oX44op5db6mwEBogWvzfbBJZ26bs=",
"shasum": "ZHnbLwNwlfVGCNclPGBifht43erMlK4dGRZkBNDzmB4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down Expand Up @@ -39,14 +39,14 @@
"endowment:cronjob": {
"jobs": [
{
"expression": "* * * * *",
"duration": "PT30S",
"request": {
"method": "refreshSend",
"params": {}
}
},
{
"expression": "* * * * *",
"duration": "PT20S",
"request": {
"method": "refreshConfirmationEstimation",
"params": {}
Expand Down Expand Up @@ -90,6 +90,6 @@
"snap_dialog": {},
"snap_getPreferences": {}
},
"platformVersion": "7.1.0",
"platformVersion": "8.1.0",
"manifestVersion": "0.1"
}
70 changes: 53 additions & 17 deletions packages/snap/src/features/send/render.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { installSnap } from '@metamask/snaps-jest';
import type { CaipAssetType } from '@metamask/keyring-api';
import { getMockAccount, installSnap } from '@metamask/snaps-jest';

import type { SpotPrices } from '../../core/clients/price-api/types';
import {
Expand Down Expand Up @@ -37,20 +38,21 @@ const solanaKeyringAccounts = [
MOCK_SOLANA_KEYRING_ACCOUNT_1,
];

const solanaAccountBalances = {
[KnownCaip19Id.SolLocalnet]: {
amount: '0.123456789',
unit: SOL_SYMBOL,
},
'solana:123456789abcdef/token:address1': {
amount: '0.123456789',
unit: '',
},
'solana:123456789abcdef/token:address2': {
amount: '0.123456789',
unit: '',
},
};
const solanaAccountBalances: Record<string, { amount: string; unit: string }> =
{
[KnownCaip19Id.SolLocalnet]: {
amount: '0.123456789',
unit: SOL_SYMBOL,
},
'solana:123456789abcdef/token:address1': {
amount: '0.123456789',
unit: '',
},
'solana:123456789abcdef/token:address2': {
amount: '0.123456789',
unit: '',
},
};

const mockSpotPrices: SpotPrices = {
[KnownCaip19Id.SolLocalnet]: {
Expand Down Expand Up @@ -175,8 +177,14 @@ describe('Send', () => {

const initialState = {
keyringAccounts: {
[MOCK_SOLANA_KEYRING_ACCOUNT_0.id]: MOCK_SOLANA_KEYRING_ACCOUNT_0,
[MOCK_SOLANA_KEYRING_ACCOUNT_1.id]: MOCK_SOLANA_KEYRING_ACCOUNT_1,
[MOCK_SOLANA_KEYRING_ACCOUNT_0.id]: {
...MOCK_SOLANA_KEYRING_ACCOUNT_0,
entropySource: 'default',
},
[MOCK_SOLANA_KEYRING_ACCOUNT_1.id]: {
...MOCK_SOLANA_KEYRING_ACCOUNT_1,
entropySource: 'alternative',
},
},
assets: {
[MOCK_SOLANA_KEYRING_ACCOUNT_0.id]: solanaAccountBalances,
Expand All @@ -202,6 +210,34 @@ describe('Send', () => {
...mockPreferences,
secretRecoveryPhrase: MOCK_SEED_PHRASE,
unencryptedState: initialState,
accounts: [
getMockAccount({
address: MOCK_SOLANA_KEYRING_ACCOUNT_0.address,
selected: true,
assets: Object.keys(solanaAccountBalances) as CaipAssetType[],
scopes: [Network.Localnet],
}),
getMockAccount({
address: MOCK_SOLANA_KEYRING_ACCOUNT_1.address,
selected: false,
assets: Object.keys(solanaAccountBalances) as CaipAssetType[],
scopes: [Network.Localnet],
}),
],
assets: {
[KnownCaip19Id.SolLocalnet]: {
symbol: 'SOL',
name: 'Solana',
},
'solana:123456789abcdef/token:address1': {
symbol: 'EURO-COIN',
name: 'Euro Coin',
},
'solana:123456789abcdef/token:address2': {
symbol: 'USDC',
name: 'USDC',
},
},
},
});

Expand Down
10 changes: 4 additions & 6 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,11 @@ export const onCronjob: OnCronjobHandler = async ({ request }) => {
const result = await withCatchAndThrowSnapError(async () => {
/**
* Don't run cronjobs if client is locked or inactive
* - We dont want to call cronjobs if the client is locked
* - We Dont want to call cronjobs if the client is inactive (except if we havent run a cronjob in the last 15 minutes)
* - We don't want to call cronjobs if the client is locked
* - We don't want to call cronjobs if the client is inactive
* (except if we haven't run a cronjob in the last 30 minutes)
*/
const { locked, active } =
(await getClientStatus()) as GetClientStatusResult & {
active: boolean | undefined; // FIXME: Remove this once the snap SDK is updated
};
const { locked, active } = await getClientStatus();

logger.log('[🔑 onCronjob] Client status', { locked, active });

Expand Down
Loading
Loading