From 168484d5c1f1303f03a0db7f286a8e98ed50eb6a Mon Sep 17 00:00:00 2001 From: Stanley Yuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:02:24 +0800 Subject: [PATCH] feat: deprecate goerli network (#217) * feat: deprecate goerli network remove goerli network from snap state and ui * chore: change update message --- packages/starknet-snap/src/index.ts | 21 +++-- packages/starknet-snap/src/utils/constants.ts | 74 ++-------------- packages/starknet-snap/src/utils/snapUtils.ts | 35 +++++++- packages/starknet-snap/test/constants.test.ts | 46 +++++----- .../test/src/addErc20Token.test.ts | 18 ++-- .../starknet-snap/test/src/addNetwork.test.ts | 86 +++++++++---------- .../test/src/createAccount.test.ts | 24 +++--- .../test/src/declareContract.test.ts | 8 +- .../test/src/estimateAccountDeployFee.test.ts | 8 +- .../test/src/estimateFee.test.ts | 4 +- .../test/src/estimateFees.test.ts | 8 +- .../starknet-snap/test/src/executeTxn.test.ts | 8 +- .../test/src/extractPrivateKey.test.ts | 4 +- .../test/src/extractPublicKey.test.ts | 4 +- .../test/src/getCurrentNetwork.test.ts | 12 +-- .../test/src/getErc20TokenBalance.test.ts | 4 +- .../test/src/getStarkName.test.ts | 4 +- .../test/src/getStoredErc20Tokens.test.ts | 4 +- .../test/src/getStoredNetworks.test.ts | 4 +- .../test/src/getStoredTransactions.test.ts | 24 +++--- .../test/src/getStoredUserAccounts.test.ts | 4 +- .../test/src/getTransactionStatus.test.ts | 4 +- .../test/src/getTransactions.test.ts | 8 +- .../starknet-snap/test/src/getValue.test.ts | 4 +- .../test/src/recoverAccounts.test.ts | 12 +-- .../test/src/sendTransaction.test.ts | 6 +- .../test/src/signDeclareTransaction.test.ts | 8 +- .../src/signDeployAccountTransaction.test.ts | 8 +- .../test/src/signMessage.test.ts | 6 +- .../test/src/signTransaction.test.ts | 8 +- .../test/src/switchNetwork.test.ts | 14 +-- .../test/src/verifySignedMessage.test.ts | 4 +- .../starknet-snap/test/utils/keyPair.test.ts | 14 --- .../test/utils/snapUtils.test.ts | 67 ++++++++++++++- .../test/utils/starknetUtils.test.ts | 20 +++-- .../TransactionListItem.stories.tsx | 2 +- .../TransactionsList.stories.tsx | 18 ++-- packages/wallet-ui/src/utils/constants.ts | 23 ++--- packages/wallet-ui/src/utils/utils.ts | 12 +-- yarn.lock | 2 +- 40 files changed, 301 insertions(+), 343 deletions(-) diff --git a/packages/starknet-snap/src/index.ts b/packages/starknet-snap/src/index.ts index b8bfc9b9..498cfc4a 100644 --- a/packages/starknet-snap/src/index.ts +++ b/packages/starknet-snap/src/index.ts @@ -22,10 +22,17 @@ import { PRELOADED_TOKENS, STARKNET_INTEGRATION_NETWORK, STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK, + STARKNET_TESTNET_NETWORK, } from './utils/constants'; -import { dappUrl, getNetworkFromChainId, isSameChainId, upsertErc20Token, upsertNetwork } from './utils/snapUtils'; +import { + dappUrl, + getNetworkFromChainId, + isSameChainId, + upsertErc20Token, + upsertNetwork, + removeNetwork, +} from './utils/snapUtils'; import { getStoredNetworks } from './getStoredNetworks'; import { getStoredTransactions } from './getStoredTransactions'; import { getTransactions } from './getTransactions'; @@ -92,9 +99,12 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ origin, request }) => if (isDev) { await upsertNetwork(STARKNET_INTEGRATION_NETWORK, snap, saveMutex, state); } else { - await upsertNetwork(STARKNET_TESTNET_NETWORK, snap, saveMutex, state); await upsertNetwork(STARKNET_SEPOLIA_TESTNET_NETWORK, snap, saveMutex, state); } + + // remove the testnet network (migration) + await removeNetwork(STARKNET_TESTNET_NETWORK, snap, saveMutex, state); + for (const token of PRELOADED_TOKENS) { await upsertErc20Token(token, snap, saveMutex, state); } @@ -238,10 +248,7 @@ export const onInstall: OnInstallHandler = async () => { export const onUpdate: OnUpdateHandler = async () => { const component = panel([ text('Features released with this update:'), - text('**Home Page**: You can now see your account and balance on the Snap homepage.'), - text( - 'To get to the Starknet Snap homepage, from the MetaMask menu, click **Snaps**, then click on the Starknet Snap.', - ), + text('- Deprecation of the Starknet Goerli Testnet'), ]); await snap.request({ diff --git a/packages/starknet-snap/src/utils/constants.ts b/packages/starknet-snap/src/utils/constants.ts index 02a2eb84..866a5de9 100644 --- a/packages/starknet-snap/src/utils/constants.ts +++ b/packages/starknet-snap/src/utils/constants.ts @@ -36,13 +36,14 @@ export const STARKNET_MAINNET_NETWORK: Network = { accountClassHash: '', // from argent-x repo }; +// Keep this constants for unit test export const STARKNET_TESTNET_NETWORK: Network = { - name: 'Goerli Testnet (deprecated soon)', - chainId: constants.StarknetChainId.SN_GOERLI, - baseUrl: 'https://alpha4.starknet.io', - nodeUrl: 'https://starknet-goerli.infura.io/v3/60c7253fb48147658095fe0460ac9ee9', - voyagerUrl: 'https://goerli.voyager.online', - accountClassHash: '', // from argent-x repo + name: 'Goerli Testnet (deprecated)', + chainId: '0x534e5f474f45524c49', + baseUrl: '', + nodeUrl: '', + voyagerUrl: '', + accountClassHash: '', }; // TODO: Importing directly from constants when upgrading to starknet.js v6 @@ -80,14 +81,6 @@ export const ETHER_MAINNET: Erc20Token = { chainId: STARKNET_MAINNET_NETWORK.chainId, }; -export const ETHER_TESTNET: Erc20Token = { - address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', - name: 'Ether', - symbol: 'ETH', - decimals: 18, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const ETHER_SEPOLIA_TESTNET: Erc20Token = { address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', name: 'Ether', @@ -104,14 +97,6 @@ export const DAI_MAINNET: Erc20Token = { chainId: STARKNET_MAINNET_NETWORK.chainId, }; -export const DAI_TESTNET: Erc20Token = { - address: '0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9', - name: 'DAI', - symbol: 'DAI', - decimals: 18, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const DAI_SEPOLIA_TESTNET: Erc20Token = { address: '0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9', name: 'DAI', @@ -120,14 +105,6 @@ export const DAI_SEPOLIA_TESTNET: Erc20Token = { chainId: SN_SEPOLIA.chainId, }; -export const WBTC_TESTNET: Erc20Token = { - address: '0x12d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56', - name: 'Wrapped BTC', - symbol: 'WBTC', - decimals: 8, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const STRK_MAINNET: Erc20Token = { address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d', name: 'Starknet Token', @@ -136,14 +113,6 @@ export const STRK_MAINNET: Erc20Token = { chainId: STARKNET_MAINNET_NETWORK.chainId, }; -export const STRK_TESTNET: Erc20Token = { - address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d', - name: 'Starknet Token', - symbol: 'STRK', - decimals: 18, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const STRK_SEPOLIA_TESTNET: Erc20Token = { address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d', name: 'Starknet Token', @@ -160,14 +129,6 @@ export const USDC_MAINNET: Erc20Token = { chainId: STARKNET_MAINNET_NETWORK.chainId, }; -export const USDC_TESTNET: Erc20Token = { - address: '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8', - name: 'USD Coin', - symbol: 'USDC', - decimals: 6, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const USDC_SEPOLIA_TESTNET: Erc20Token = { address: '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8', name: 'USD Coin', @@ -184,14 +145,6 @@ export const USDT_MAINNET: Erc20Token = { chainId: STARKNET_MAINNET_NETWORK.chainId, }; -export const USDT_TESTNET: Erc20Token = { - address: '0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8', - name: 'Tether USD', - symbol: 'USDT', - decimals: 6, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const USDT_SEPOLIA_TESTNET: Erc20Token = { address: '0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8', name: 'Tether USD', @@ -208,32 +161,19 @@ export const TEST_TOKEN_MAINNET: Erc20Token = { chainId: STARKNET_MAINNET_NETWORK.chainId, }; -export const TEST_TOKEN_TESTNET: Erc20Token = { - address: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', - name: 'Test Token', - symbol: 'TEST', - decimals: 18, - chainId: STARKNET_TESTNET_NETWORK.chainId, -}; - export const PRELOADED_TOKENS = [ ETHER_MAINNET, - ETHER_TESTNET, ETHER_SEPOLIA_TESTNET, USDC_MAINNET, - USDC_TESTNET, USDC_SEPOLIA_TESTNET, USDT_MAINNET, - USDT_TESTNET, USDT_SEPOLIA_TESTNET, STRK_MAINNET, - STRK_TESTNET, STRK_SEPOLIA_TESTNET, ]; export const PRELOADED_NETWORKS = [ STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_INTEGRATION_NETWORK, ]; diff --git a/packages/starknet-snap/src/utils/snapUtils.ts b/packages/starknet-snap/src/utils/snapUtils.ts index c7ff3e1c..2a6d4ac3 100644 --- a/packages/starknet-snap/src/utils/snapUtils.ts +++ b/packages/starknet-snap/src/utils/snapUtils.ts @@ -27,7 +27,7 @@ import { MAXIMUM_TOKEN_SYMBOL_LENGTH, PRELOADED_NETWORKS, PRELOADED_TOKENS, - STARKNET_TESTNET_NETWORK, + STARKNET_SEPOLIA_TESTNET_NETWORK, VOYAGER_API_TXNS_URL_SUFFIX, VOYAGER_API_TXN_URL_SUFFIX, } from './constants'; @@ -430,6 +430,35 @@ export async function upsertNetwork(network: Network, wallet, mutex: Mutex, stat }); } +export async function removeNetwork(network: Network, wallet, mutex: Mutex, state: SnapState = undefined) { + return mutex.runExclusive(async () => { + if (!state) { + state = await wallet.request({ + method: 'snap_manageState', + params: { + operation: 'get', + }, + }); + } + + if (state.currentNetwork && isSameChainId(state.currentNetwork.chainId, network.chainId)) { + state.currentNetwork = undefined; // fallback to default network + } + + const storedNetwork = getNetwork(state, network.chainId); + if (storedNetwork) { + state.networks = state.networks.filter((net) => !isSameChainId(net.chainId, network.chainId)); + await wallet.request({ + method: 'snap_manageState', + params: { + operation: 'update', + newState: state, + }, + }); + } + }); +} + export function getErc20Token(state: SnapState, tokenAddress: string, chainId: string) { const bigIntTokenAddress = num.toBigInt(tokenAddress); return state.erc20Tokens?.find( @@ -485,7 +514,7 @@ export async function upsertErc20Token(erc20Token: Erc20Token, wallet, mutex: Mu } export function getNetworkFromChainId(state: SnapState, targerChainId: string | undefined) { - const chainId = targerChainId || STARKNET_TESTNET_NETWORK.chainId; + const chainId = targerChainId || STARKNET_SEPOLIA_TESTNET_NETWORK.chainId; const network = getNetwork(state, chainId); if (!network) { throw new Error(`can't find the network in snap state with chainId: ${chainId}`); @@ -649,7 +678,7 @@ export async function removeAcceptedTransaction( } export function getCurrentNetwork(state: SnapState) { - return state.currentNetwork || STARKNET_TESTNET_NETWORK; + return state.currentNetwork || STARKNET_SEPOLIA_TESTNET_NETWORK; } export async function setCurrentNetwork(network: Network, wallet, mutex: Mutex, state: SnapState = undefined) { diff --git a/packages/starknet-snap/test/constants.test.ts b/packages/starknet-snap/test/constants.test.ts index 1b8b430b..f9d40a44 100644 --- a/packages/starknet-snap/test/constants.test.ts +++ b/packages/starknet-snap/test/constants.test.ts @@ -1,5 +1,5 @@ import { JsonBIP44CoinTypeNode } from '@metamask/key-tree'; -import { constants, num } from 'starknet'; +import { num } from 'starknet'; import { AccContract, Erc20Token, @@ -9,11 +9,7 @@ import { ExecutionStatus, FinailityStatus, } from '../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../src/utils/constants'; export const invalidNetwork: Network = { name: 'Network with emot', @@ -31,7 +27,7 @@ export const account1: AccContract = { derivationPath: "m / bip32:44' / bip32:9004' / bip32:0' / bip32:0", deployTxnHash: '0x5da2d94a324bc56f80cf1fb985c22c85769db434ed403ae71774a07103d229b', publicKey: '0x0154c7b20442ee954f50831702ca844ec185ad484c21719575d351583deec90b', - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const account2: AccContract = { @@ -41,7 +37,7 @@ export const account2: AccContract = { derivationPath: "m / bip32:44' / bip32:9004' / bip32:0' / bip32:0", deployTxnHash: '0x5bc00132b8f2fc0f673dc232594b26727e712b204a2716f9dc28a8c5f607b5e', publicKey: '0x019e59f349e1aa813ab4556c5836d0472e5e1ae82d1e5c3b3e8aabfeb290befd', - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const account3: AccContract = { @@ -51,7 +47,7 @@ export const account3: AccContract = { derivationPath: "m / bip32:44' / bip32:9004' / bip32:0' / bip32:0", deployTxnHash: '', publicKey: '0x0797efd8e3971dfca4f928485860896201320ce2997ca4789d9343204219599d', - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const account4: AccContract = { @@ -61,7 +57,7 @@ export const account4: AccContract = { derivationPath: "m / bip32:44' / bip32:9004' / bip32:0' / bip32:0", deployTxnHash: '0x3b690b4c9dd639881a46f6a344ee90254562175ed7a7f5a028f69b8c32ccb47', publicKey: '', - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const token1: Erc20Token = { @@ -69,7 +65,7 @@ export const token1: Erc20Token = { name: 'Starknet ERC-20 sample', symbol: 'SNET', decimals: 18, - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const token2: Erc20Token = { @@ -77,7 +73,7 @@ export const token2: Erc20Token = { name: 'ArgentX Test Token', symbol: 'TT', decimals: 18, - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const token3: Erc20Token = { @@ -85,7 +81,7 @@ export const token3: Erc20Token = { name: 'Test Token with 10 decimal places', symbol: 'TT', decimals: 10, - chainId: constants.StarknetChainId.SN_GOERLI, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; export const signature1 = @@ -170,7 +166,7 @@ export const getTxnStatusAcceptL2Resp = { }; export const createAccountProxyTxn: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: createAccountProxyResp.contract_address, contractCallData: [], contractFuncName: '', @@ -198,7 +194,7 @@ export const createAccountProxyTxnOnSepolia: Transaction = { }; export const initAccountTxn: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: account1.address, contractCallData: [], //[account1.publicKey, num.toHex(constants.ZERO)], contractFuncName: '', //'initialize', @@ -212,7 +208,7 @@ export const initAccountTxn: Transaction = { }; export const RejectedTxn: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: account1.address, contractCallData: [], //[account1.publicKey, num.toHex(constants.ZERO)], contractFuncName: '', //'initialize', @@ -226,7 +222,7 @@ export const RejectedTxn: Transaction = { }; export const RejectedTxn2: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: account1.address, contractCallData: [], //[account1.publicKey, num.toHex(constants.ZERO)], contractFuncName: '', //'initialize', @@ -242,7 +238,7 @@ export const RejectedTxn2: Transaction = { }; export const unsettedTransactionInMassagedTxn: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: '0x7394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractCallData: ['0x14361d05e560796ad3152e083b609f5205f3bd76039327326746ba7f769a666', '0xde0b6b3a7640000', '0x0'], contractFuncName: 'transfer', @@ -286,7 +282,7 @@ export const txn2: Transaction = { }; export const txn3: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractCallData: ['0x0256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', '1000000000000000000', '0'], contractFuncName: 'transfer', @@ -300,7 +296,7 @@ export const txn3: Transaction = { }; export const txn4: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractCallData: ['0x0256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', '2000000000000000000', '0'], contractFuncName: 'transfer', @@ -314,7 +310,7 @@ export const txn4: Transaction = { }; export const txn5: Transaction = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractCallData: ['0x0256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', '2000000000000000000', '0'], contractFuncName: 'transfer', @@ -683,7 +679,7 @@ export const getTxnFromSequencerResp2 = { }; export const expectedMassagedTxn4: Transaction = { - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractCallData: ['0x0256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', '2000000000000000000', '0'], contractFuncName: 'transfer', @@ -699,7 +695,7 @@ export const expectedMassagedTxn4: Transaction = { }; export const expectedMassagedTxn5: Transaction = { - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractCallData: ['0x0256d8f49882cc9366037415f48fa9fd2b5b7344ded7573ebfcef7c90e3e6b75', '2000000000000000000', '0'], contractFuncName: 'transfer', @@ -718,7 +714,7 @@ export const expectedMassagedTxns: Transaction[] = [ { txnHash: '0x1366c2f9f46b1a86ba0c28b5a08fa0aa3750c4d1cbe06e97e72bd46ae2ac1f9', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x5a98ec74a40383cf99896bfea2ec5e6aad16c7eed50025a5f569d585ebb13a2', contractAddress: '0x7394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractFuncName: 'transfer', @@ -733,7 +729,7 @@ export const expectedMassagedTxns: Transaction[] = [ { txnHash: '0x6beceb86579dc78749bdaaf441501edc21e218e020236e2ebea1b6a96d0bac7', txnType: 'deploy', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x5a98ec74a40383cf99896bfea2ec5e6aad16c7eed50025a5f569d585ebb13a2', contractAddress: '0x5a98ec74a40383cf99896bfea2ec5e6aad16c7eed50025a5f569d585ebb13a2', contractFuncName: '', diff --git a/packages/starknet-snap/test/src/addErc20Token.test.ts b/packages/starknet-snap/test/src/addErc20Token.test.ts index a8319fe6..250df0b5 100644 --- a/packages/starknet-snap/test/src/addErc20Token.test.ts +++ b/packages/starknet-snap/test/src/addErc20Token.test.ts @@ -5,11 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import { addErc20Token } from '../../src/addErc20Token'; import { SnapState } from '../../src/types/snapState'; import * as snapUtils from '../../src/utils/snapUtils'; -import { - DEFAULT_DECIMAL_PLACES, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { DEFAULT_DECIMAL_PLACES, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { Mutex } from 'async-mutex'; import { AddErc20TokenRequestParams, ApiParams } from '../../src/types/snapApi'; @@ -21,7 +17,7 @@ describe('Test function: addErc20Token', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -55,7 +51,7 @@ describe('Test function: addErc20Token', function () { expect(state.erc20Tokens.length).to.be.eq(0); }); - it('should add the ERC-20 token in SN_GOERLI correctly', async function () { + it('should add the ERC-20 token in SN_SEPOLIA correctly', async function () { const requestObject: AddErc20TokenRequestParams = { tokenAddress: '0x244c20d51109adcf604fde1bbf878e5dcd549b3877ac87911ec6a158bd7aa62', tokenName: 'Starknet ERC-20 sample', @@ -70,7 +66,7 @@ describe('Test function: addErc20Token', function () { expect(state.erc20Tokens[0].symbol).to.be.eq(requestObject.tokenSymbol); }); - it('should add the ERC-20 token (with undefined tokenDecimals) in SN_GOERLI with default token decimal places correctly', async function () { + it('should add the ERC-20 token (with undefined tokenDecimals) in SN_SEPOLIA with default token decimal places correctly', async function () { const requestObject: AddErc20TokenRequestParams = { tokenAddress: '0x244c20d51109adcf604fde1bbf878e5dcd549b3877ac87911ec6a158bd7bb99', tokenName: 'Starknet ERC-20 sample 2', @@ -84,7 +80,7 @@ describe('Test function: addErc20Token', function () { expect(state.erc20Tokens[1].decimals).to.be.eq(DEFAULT_DECIMAL_PLACES); }); - it('should add the ERC-20 token (with empty string tokenDecimals) in SN_GOERLI with default token decimal places correctly', async function () { + it('should add the ERC-20 token (with empty string tokenDecimals) in SN_SEPOLIA with default token decimal places correctly', async function () { const requestObject: AddErc20TokenRequestParams = { tokenAddress: '0x244c20d51109adcf604fde1bbf878e5dcd549b3877ac87911ec6a158bd7cc99', tokenName: 'Starknet ERC-20 sample 2', @@ -99,7 +95,7 @@ describe('Test function: addErc20Token', function () { expect(state.erc20Tokens[1].decimals).to.be.eq(DEFAULT_DECIMAL_PLACES); }); - it('should update the ERC-20 token in SN_GOERLI correctly', async function () { + it('should update the ERC-20 token in SN_SEPOLIA correctly', async function () { const requestObject: AddErc20TokenRequestParams = { tokenAddress: '0x244c20d51109adcf604fde1bbf878e5dcd549b3877ac87911ec6a158bd7aa62', tokenName: 'Starknet ERC-20 sample', @@ -114,7 +110,7 @@ describe('Test function: addErc20Token', function () { expect(state.erc20Tokens[0].symbol).to.be.eq(requestObject.tokenSymbol); }); - it('should not update snap state with the duplicated ERC-20 token in SN_GOERLI', async function () { + it('should not update snap state with the duplicated ERC-20 token in SN_SEPOLIA', async function () { const requestObject: AddErc20TokenRequestParams = { tokenAddress: '0x244c20d51109adcf604fde1bbf878e5dcd549b3877ac87911ec6a158bd7aa62', tokenName: 'Starknet ERC-20 sample', diff --git a/packages/starknet-snap/test/src/addNetwork.test.ts b/packages/starknet-snap/test/src/addNetwork.test.ts index 47bea7db..764229ef 100644 --- a/packages/starknet-snap/test/src/addNetwork.test.ts +++ b/packages/starknet-snap/test/src/addNetwork.test.ts @@ -4,11 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import * as snapUtils from '../../src/utils/snapUtils'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { addNetwork } from '../../src/addNetwork'; import { Mutex } from 'async-mutex'; import { AddNetworkRequestParams, ApiParams } from '../../src/types/snapApi'; @@ -21,7 +17,7 @@ describe('Test function: addNetwork', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -46,53 +42,53 @@ describe('Test function: addNetwork', function () { it('should add the network correctly', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI', + networkName: 'Starknet Unit SN_SEPOLIA', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI.starknet.io', - networkNodeUrl: 'https://alpha-unit-SN_GOERLI.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA.starknet.io', + networkNodeUrl: 'https://alpha-unit-SN_SEPOLIA.starknet.io', }; apiParams.requestParams = requestObject; const result = await addNetwork(apiParams); expect(result).to.be.eql(true); expect(stateStub).to.be.calledOnce; - expect(state.networks.length).to.be.eql(4); + expect(state.networks.length).to.be.eql(3); }); it('should update the network correctly', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI 2', + networkName: 'Starknet Unit SN_SEPOLIA 2', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', - networkNodeUrl: 'https://alpha-unit-SN_GOERLI.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', + networkNodeUrl: 'https://alpha-unit-SN_SEPOLIA.starknet.io', }; apiParams.requestParams = requestObject; const result = await addNetwork(apiParams); expect(result).to.be.eql(true); expect(stateStub).to.be.calledOnce; - expect(state.networks.length).to.be.eql(4); + expect(state.networks.length).to.be.eql(3); }); it('should not update snap state with the duplicated network', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI 2', + networkName: 'Starknet Unit SN_SEPOLIA 2', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', - networkNodeUrl: 'https://alpha-unit-SN_GOERLI.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', + networkNodeUrl: 'https://alpha-unit-SN_SEPOLIA.starknet.io', }; apiParams.requestParams = requestObject; const result = await addNetwork(apiParams); expect(result).to.be.eql(true); expect(stateStub).to.be.callCount(0); - expect(state.networks.length).to.be.eql(4); + expect(state.networks.length).to.be.eql(3); }); it('should throw an error if upsertNetwork failed', async function () { sandbox.stub(snapUtils, 'upsertNetwork').throws(new Error()); const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI 2', + networkName: 'Starknet Unit SN_SEPOLIA 2', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', - networkNodeUrl: 'https://alpha-unit-SN_GOERLI.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', + networkNodeUrl: 'https://alpha-unit-SN_SEPOLIA.starknet.io', }; apiParams.requestParams = requestObject; let result; @@ -109,7 +105,7 @@ describe('Test function: addNetwork', function () { const requestObject: AddNetworkRequestParams = { networkName: undefined, networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -125,9 +121,9 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network chain id is undefined', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI 2', + networkName: 'Starknet Unit SN_SEPOLIA 2', networkChainId: undefined, - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -143,7 +139,7 @@ describe('Test function: addNetwork', function () { it('should throw an error if both the network base url and node url are empty string', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI 2', + networkName: 'Starknet Unit SN_SEPOLIA 2', networkChainId: '0x534e5f474f777', networkBaseUrl: '', networkNodeUrl: '', @@ -161,9 +157,9 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network name is not in ASCII chars', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'аррӏе SN_GOERLI', + networkName: 'аррӏе SN_SEPOLIA', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -179,9 +175,9 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network name is longer than 64 chars', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + networkName: 'Starknet Unit SN_SEPOLIA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -199,7 +195,7 @@ describe('Test function: addNetwork', function () { const requestObject: AddNetworkRequestParams = { networkName: ' ', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -215,9 +211,9 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network chainId is not in hex string', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI', + networkName: 'Starknet Unit SN_SEPOLIA', networkChainId: '534e5f474f777', - networkBaseUrl: 'https://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'https://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -233,9 +229,9 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network base URL is not valid', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI', + networkName: 'Starknet Unit SN_SEPOLIA', networkChainId: '0x534e5f474f777', - networkBaseUrl: 'wss://alpha-unit-SN_GOERLI-2.starknet.io', + networkBaseUrl: 'wss://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -251,10 +247,10 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network node URL is not valid', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI', + networkName: 'Starknet Unit SN_SEPOLIA', networkChainId: '0x534e5f474f777', networkBaseUrl: '', - networkNodeUrl: 'wss://alpha-unit-SN_GOERLI-2.starknet.io', + networkNodeUrl: 'wss://alpha-unit-SN_SEPOLIA-2.starknet.io', }; apiParams.requestParams = requestObject; let result; @@ -269,10 +265,10 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network Voyager URL is not valid', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI', + networkName: 'Starknet Unit SN_SEPOLIA', networkChainId: '0x534e5f474f777', networkBaseUrl: '', - networkNodeUrl: 'http://alpha-unit-SN_GOERLI-2.starknet.io', + networkNodeUrl: 'http://alpha-unit-SN_SEPOLIA-2.starknet.io', networkVoyagerUrl: 'wss://test.com', }; apiParams.requestParams = requestObject; @@ -288,9 +284,9 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network chainId is one of the preloaded network chainId', async function () { const requestObject: AddNetworkRequestParams = { - networkName: 'Starknet Unit SN_GOERLI', - networkChainId: '0x534e5f474f45524c49', - networkBaseUrl: 'http://alpha-unit-SN_GOERLI-2.starknet.io', + networkName: 'Starknet Unit SN_SEPOLIA', + networkChainId: '0x534e5f5345504f4c4941', + networkBaseUrl: 'http://alpha-unit-SN_SEPOLIA-2.starknet.io', networkNodeUrl: '', }; apiParams.requestParams = requestObject; @@ -306,10 +302,10 @@ describe('Test function: addNetwork', function () { it('should throw an error if the network name is one of the preloaded network name', async function () { const requestObject: AddNetworkRequestParams = { - networkName: STARKNET_TESTNET_NETWORK.name, - networkChainId: STARKNET_TESTNET_NETWORK.chainId, - networkBaseUrl: STARKNET_TESTNET_NETWORK.baseUrl, - networkNodeUrl: STARKNET_TESTNET_NETWORK.nodeUrl, + networkName: STARKNET_SEPOLIA_TESTNET_NETWORK.name, + networkChainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, + networkBaseUrl: STARKNET_SEPOLIA_TESTNET_NETWORK.baseUrl, + networkNodeUrl: STARKNET_SEPOLIA_TESTNET_NETWORK.nodeUrl, }; apiParams.requestParams = requestObject; let result; diff --git a/packages/starknet-snap/test/src/createAccount.test.ts b/packages/starknet-snap/test/src/createAccount.test.ts index d47648f7..8fa80403 100644 --- a/packages/starknet-snap/test/src/createAccount.test.ts +++ b/packages/starknet-snap/test/src/createAccount.test.ts @@ -6,11 +6,7 @@ import * as utils from '../../src/utils/starknetUtils'; import * as snapUtils from '../../src/utils/snapUtils'; import { createAccount } from '../../src/createAccount'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, createAccountProxyResp, @@ -38,7 +34,7 @@ describe('Test function: createAccount', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_MAINNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -150,7 +146,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(2); }); - it('should create and store an user account with proxy in state correctly in SN_GOERLI in silent mode', async function () { + it('should create and store an user account with proxy in state correctly in SN_SEPOLIA in silent mode', async function () { sandbox.stub(utils, 'deployAccount').callsFake(async () => { return createAccountProxyResp; }); @@ -166,7 +162,7 @@ describe('Test function: createAccount', function () { const result = await createAccount(apiParams, true); const { publicKey: expectedPublicKey } = await utils.getKeysFromAddress( apiParams.keyDeriver, - STARKNET_TESTNET_NETWORK, + STARKNET_SEPOLIA_TESTNET_NETWORK, state, createAccountProxyResp.contract_address, ); @@ -181,7 +177,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(3); }); - it('should not create any user account with proxy in state in SN_GOERLI if not in silentMode and user rejected', async function () { + it('should not create any user account with proxy in state in SN_SEPOLIA if not in silentMode and user rejected', async function () { walletStub.rpcStubs.snap_dialog.resolves(false); const requestObject: CreateAccountRequestParams = { deploy: true }; apiParams.requestParams = requestObject; @@ -192,7 +188,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(3); }); - it('should not create any user account with proxy in state in SN_GOERLI if account already initialized with a signer', async function () { + it('should not create any user account with proxy in state in SN_SEPOLIA if account already initialized with a signer', async function () { sandbox.stub(utils, 'deployAccount').callsFake(async () => { return createAccountProxyResp; }); @@ -215,7 +211,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(3); }); - it('should not create any user account with proxy in state in SN_GOERLI if account does not have enough ETH balance', async function () { + it('should not create any user account with proxy in state in SN_SEPOLIA if account does not have enough ETH balance', async function () { sandbox.stub(utils, 'deployAccount').callsFake(async () => { return createAccountProxyResp; }); @@ -236,7 +232,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(3); }); - it('should not create any user account with proxy in state in SN_GOERLI if account does not have enough ETH balance for suggestedMaxFee > 0.000001 ETH', async function () { + it('should not create any user account with proxy in state in SN_SEPOLIA if account does not have enough ETH balance for suggestedMaxFee > 0.000001 ETH', async function () { sandbox.stub(utils, 'deployAccount').callsFake(async () => { return createAccountProxyResp; }); @@ -257,7 +253,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(3); }); - it('should not create any user account with proxy in state in SN_GOERLI if get account ETH balance throws error', async function () { + it('should not create any user account with proxy in state in SN_SEPOLIA if get account ETH balance throws error', async function () { sandbox.stub(utils, 'deployAccount').callsFake(async () => { return createAccountProxyResp; }); @@ -276,7 +272,7 @@ describe('Test function: createAccount', function () { expect(state.transactions.length).to.be.eq(3); }); - it('should skip upsert account and transaction if deployTxn response code has no transaction_hash in SN_GOERLI', async function () { + it('should skip upsert account and transaction if deployTxn response code has no transaction_hash in SN_SEPOLIA', async function () { sandbox.stub(utils, 'deployAccount').callsFake(async () => { return createAccountFailedProxyResp; }); diff --git a/packages/starknet-snap/test/src/declareContract.test.ts b/packages/starknet-snap/test/src/declareContract.test.ts index 30eaf7d9..1dfbda95 100644 --- a/packages/starknet-snap/test/src/declareContract.test.ts +++ b/packages/starknet-snap/test/src/declareContract.test.ts @@ -5,11 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import { declareContract } from '../../src/declareContract'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, getBip44EntropyStub, account1 } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; @@ -24,7 +20,7 @@ describe('Test function: declareContract', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_MAINNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/estimateAccountDeployFee.test.ts b/packages/starknet-snap/test/src/estimateAccountDeployFee.test.ts index 9e38e1df..37efd5d1 100644 --- a/packages/starknet-snap/test/src/estimateAccountDeployFee.test.ts +++ b/packages/starknet-snap/test/src/estimateAccountDeployFee.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import { estimateAccDeployFee } from '../../src/estimateAccountDeployFee'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { estimateDeployFeeResp3, estimateDeployFeeResp4, getBip44EntropyStub } from '../constants.test'; import { Mutex } from 'async-mutex'; @@ -20,11 +20,11 @@ describe('Test function: estimateAccountDeployFee', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const requestObject: EstimateAccountDeployFeeRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, }; const apiParams: ApiParams = { state, @@ -57,7 +57,7 @@ describe('Test function: estimateAccountDeployFee', function () { return estimateDeployFeeResp4; }); apiParams.requestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, addressIndex: 2, }; const result = await estimateAccDeployFee(apiParams); diff --git a/packages/starknet-snap/test/src/estimateFee.test.ts b/packages/starknet-snap/test/src/estimateFee.test.ts index b6443ac3..2d5908d4 100644 --- a/packages/starknet-snap/test/src/estimateFee.test.ts +++ b/packages/starknet-snap/test/src/estimateFee.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import { estimateFee } from '../../src/estimateFee'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { account2, @@ -27,7 +27,7 @@ describe('Test function: estimateFee', function () { const state: SnapState = { accContracts: [account2], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const requestObject: EstimateFeeRequestParams = { diff --git a/packages/starknet-snap/test/src/estimateFees.test.ts b/packages/starknet-snap/test/src/estimateFees.test.ts index 5e004d03..5e557ce4 100644 --- a/packages/starknet-snap/test/src/estimateFees.test.ts +++ b/packages/starknet-snap/test/src/estimateFees.test.ts @@ -4,7 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import { estimateFees } from '../../src/estimateFees'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account2, estimateDeployFeeResp2, estimateDeployFeeResp3, getBip44EntropyStub } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import * as utils from '../../src/utils/starknetUtils'; @@ -20,7 +20,7 @@ describe('Test function: estimateFees', function () { const state: SnapState = { accContracts: [account2], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -47,7 +47,7 @@ describe('Test function: estimateFees', function () { }); apiParams.requestParams = { senderAddress: account2.address, - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, invocations: [ { type: TransactionType.INVOKE, @@ -76,7 +76,7 @@ describe('Test function: estimateFees', function () { sandbox.stub(utils, 'estimateFeeBulk').throws(new Error()); apiParams.requestParams = { senderAddress: account2.address, - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, invocations: [ { type: TransactionType.INVOKE, diff --git a/packages/starknet-snap/test/src/executeTxn.test.ts b/packages/starknet-snap/test/src/executeTxn.test.ts index a8da31fd..c2768cc4 100644 --- a/packages/starknet-snap/test/src/executeTxn.test.ts +++ b/packages/starknet-snap/test/src/executeTxn.test.ts @@ -5,11 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import { executeTxn } from '../../src/executeTxn'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, getBip44EntropyStub, account1 } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; @@ -24,7 +20,7 @@ describe('Test function: executeTxn', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_MAINNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/extractPrivateKey.test.ts b/packages/starknet-snap/test/src/extractPrivateKey.test.ts index 7345723a..f3a65eb9 100644 --- a/packages/starknet-snap/test/src/extractPrivateKey.test.ts +++ b/packages/starknet-snap/test/src/extractPrivateKey.test.ts @@ -4,7 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import { extractPrivateKey } from '../../src/extractPrivateKey'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account1, getBip44EntropyStub, unfoundUserAddress } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import * as utils from '../../src/utils/starknetUtils'; @@ -19,7 +19,7 @@ describe('Test function: extractPrivateKey', function () { const state: SnapState = { accContracts: [account1], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/extractPublicKey.test.ts b/packages/starknet-snap/test/src/extractPublicKey.test.ts index 0039af89..1204a754 100644 --- a/packages/starknet-snap/test/src/extractPublicKey.test.ts +++ b/packages/starknet-snap/test/src/extractPublicKey.test.ts @@ -4,7 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import { extractPublicKey } from '../../src/extractPublicKey'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account1, getBip44EntropyStub, unfoundUserAddress, unfoundUserPublicKey } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import * as utils from '../../src/utils/starknetUtils'; @@ -19,7 +19,7 @@ describe('Test function: extractPublicKey', function () { const state: SnapState = { accContracts: [account1], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getCurrentNetwork.test.ts b/packages/starknet-snap/test/src/getCurrentNetwork.test.ts index 97b74b64..5420e0ae 100644 --- a/packages/starknet-snap/test/src/getCurrentNetwork.test.ts +++ b/packages/starknet-snap/test/src/getCurrentNetwork.test.ts @@ -3,11 +3,7 @@ import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getCurrentNetwork } from '../../src/getCurrentNetwork'; import { Mutex } from 'async-mutex'; import { ApiParams } from '../../src/types/snapApi'; @@ -20,7 +16,7 @@ describe('Test function: getStoredNetworks', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], currentNetwork: STARKNET_MAINNET_NETWORK, }; @@ -48,10 +44,10 @@ describe('Test function: getStoredNetworks', function () { expect(result).to.be.eql(STARKNET_MAINNET_NETWORK); }); - it('should get STARKNET_TESTNET_NETWORK if current network is undefined', async function () { + it('should get STARKNET_SEPOLIA_TESTNET_NETWORK if current network is undefined', async function () { state.currentNetwork = undefined; const result = await getCurrentNetwork(apiParams); expect(stateStub).not.to.have.been.called; - expect(result).to.be.eql(STARKNET_TESTNET_NETWORK); + expect(result).to.be.eql(STARKNET_SEPOLIA_TESTNET_NETWORK); }); }); diff --git a/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts b/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts index ef75e4e0..36eb5349 100644 --- a/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts +++ b/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import { getErc20TokenBalance } from '../../src/getErc20TokenBalance'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { Mutex } from 'async-mutex'; import { ApiParams, GetErc20TokenBalanceRequestParams } from '../../src/types/snapApi'; @@ -17,7 +17,7 @@ describe('Test function: getErc20TokenBalance', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getStarkName.test.ts b/packages/starknet-snap/test/src/getStarkName.test.ts index 3bfa6a08..ab0c6cf2 100644 --- a/packages/starknet-snap/test/src/getStarkName.test.ts +++ b/packages/starknet-snap/test/src/getStarkName.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import { getStarkName } from '../../src/getStarkName'; import * as utils from '../../src/utils/starknetUtils'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { Mutex } from 'async-mutex'; import { ApiParams, GetStarkNameRequestParam } from '../../src/types/snapApi'; @@ -17,7 +17,7 @@ describe('Test function: getStarkName', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getStoredErc20Tokens.test.ts b/packages/starknet-snap/test/src/getStoredErc20Tokens.test.ts index a895b867..f294a05f 100644 --- a/packages/starknet-snap/test/src/getStoredErc20Tokens.test.ts +++ b/packages/starknet-snap/test/src/getStoredErc20Tokens.test.ts @@ -4,7 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import { getStoredErc20Tokens } from '../../src/getStoredErc20Tokens'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { token1, token2 } from '../constants.test'; import * as snapUtils from '../../src/utils/snapUtils'; import { Mutex } from 'async-mutex'; @@ -18,7 +18,7 @@ describe('Test function: getStoredErc20Tokens', function () { const state: SnapState = { accContracts: [], erc20Tokens: [token1, token2], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getStoredNetworks.test.ts b/packages/starknet-snap/test/src/getStoredNetworks.test.ts index a8d6e326..450c1c5b 100644 --- a/packages/starknet-snap/test/src/getStoredNetworks.test.ts +++ b/packages/starknet-snap/test/src/getStoredNetworks.test.ts @@ -3,7 +3,7 @@ import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getStoredNetworks } from '../../src/getStoredNetworks'; import * as snapUtils from '../../src/utils/snapUtils'; import { Mutex } from 'async-mutex'; @@ -17,7 +17,7 @@ describe('Test function: getStoredNetworks', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getStoredTransactions.test.ts b/packages/starknet-snap/test/src/getStoredTransactions.test.ts index 353f215b..96442294 100644 --- a/packages/starknet-snap/test/src/getStoredTransactions.test.ts +++ b/packages/starknet-snap/test/src/getStoredTransactions.test.ts @@ -3,11 +3,7 @@ import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState, VoyagerTransactionType } from '../../src/types/snapState'; -import { - STARKNET_TESTNET_NETWORK, - STARKNET_MAINNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getStoredTransactions } from '../../src/getStoredTransactions'; import { createAccountProxyTxn, initAccountTxn, invalidNetwork, txn1, txn2, txn3 } from '../constants.test'; import * as snapUtils from '../../src/utils/snapUtils'; @@ -22,7 +18,7 @@ describe('Test function: getStoredTransactions', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK, invalidNetwork], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK, invalidNetwork], transactions: [txn1, txn2, txn3, createAccountProxyTxn, initAccountTxn], }; const apiParams: ApiParams = { @@ -41,7 +37,7 @@ describe('Test function: getStoredTransactions', function () { sandbox.restore(); }); - it('should get the stored transactions of SN_GOERLI correctly', async function () { + it('should get the stored transactions of SN_SEPOLIA correctly', async function () { const requestObject: GetStoredTransactionsRequestParams = {}; apiParams.requestParams = requestObject; const result = await getStoredTransactions(apiParams); @@ -124,9 +120,9 @@ describe('Test function: getStoredTransactions', function () { expect(result).to.be.eql([txn1]); }); - it('should not get any stored transactions of SN_GOERLI of an unfound sender address correctly', async function () { + it('should not get any stored transactions of SN_SEPOLIA of an unfound sender address correctly', async function () { const requestObject: GetStoredTransactionsRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', senderAddress: '0x7ec3edbb88ce9d4d1ed62ccee34cf46a405bd15be0409ac9a23ffc1f36e190c', txnsInLastNumOfDays: 2, @@ -137,9 +133,9 @@ describe('Test function: getStoredTransactions', function () { expect(result.length).to.be.eq(0); }); - it('should get the stored DEPLOY transactions of SN_GOERLI correctly', async function () { + it('should get the stored DEPLOY transactions of SN_SEPOLIA correctly', async function () { const requestObject: GetStoredTransactionsRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, txnType: VoyagerTransactionType.DEPLOY, }; apiParams.requestParams = requestObject; @@ -149,9 +145,9 @@ describe('Test function: getStoredTransactions', function () { expect(result).to.be.eql([createAccountProxyTxn]); }); - it('should get the stored INVOKE transactions of SN_GOERLI correctly', async function () { + it('should get the stored INVOKE transactions of SN_SEPOLIA correctly', async function () { const requestObject: GetStoredTransactionsRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, txnType: VoyagerTransactionType.INVOKE, }; apiParams.requestParams = requestObject; @@ -164,7 +160,7 @@ describe('Test function: getStoredTransactions', function () { it('should throw error if getTransactions failed', async function () { sandbox.stub(snapUtils, 'getTransactions').throws(new Error()); const requestObject: GetStoredTransactionsRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, txnType: VoyagerTransactionType.INVOKE, }; apiParams.requestParams = requestObject; diff --git a/packages/starknet-snap/test/src/getStoredUserAccounts.test.ts b/packages/starknet-snap/test/src/getStoredUserAccounts.test.ts index 7e3d80c2..eb5d87b7 100644 --- a/packages/starknet-snap/test/src/getStoredUserAccounts.test.ts +++ b/packages/starknet-snap/test/src/getStoredUserAccounts.test.ts @@ -4,7 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import { getStoredUserAccounts } from '../../src/getStoredUserAccounts'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account1, account2, account3, account4 } from '../constants.test'; import * as snapUtils from '../../src/utils/snapUtils'; import { Mutex } from 'async-mutex'; @@ -18,7 +18,7 @@ describe('Test function: getStoredUserAccounts', function () { const state: SnapState = { accContracts: [account1, account2, account3, account4], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getTransactionStatus.test.ts b/packages/starknet-snap/test/src/getTransactionStatus.test.ts index 6b914b4a..b65a4ccf 100644 --- a/packages/starknet-snap/test/src/getTransactionStatus.test.ts +++ b/packages/starknet-snap/test/src/getTransactionStatus.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import { getTransactionStatus } from '../../src/getTransactionStatus'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getTxnStatusResp } from '../constants.test'; import { Mutex } from 'async-mutex'; import { ApiParams, GetTransactionStatusRequestParams } from '../../src/types/snapApi'; @@ -18,7 +18,7 @@ describe('Test function: getTransactionStatus', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/getTransactions.test.ts b/packages/starknet-snap/test/src/getTransactions.test.ts index 938f706a..76bb52e2 100644 --- a/packages/starknet-snap/test/src/getTransactions.test.ts +++ b/packages/starknet-snap/test/src/getTransactions.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import * as snapUtils from '../../src/utils/snapUtils'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, expectedMassagedTxn4, @@ -38,7 +38,7 @@ describe('Test function: getTransactions', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK], transactions: [ { ...unsettedTransactionInMassagedTxn }, { ...txn1 }, @@ -221,7 +221,7 @@ describe('Test function: getTransactions.updateStatus', function () { }); it('should update status correctly', async function () { - await updateStatus(txns[0], STARKNET_TESTNET_NETWORK); + await updateStatus(txns[0], STARKNET_SEPOLIA_TESTNET_NETWORK); expect(getTransactionStatusStub.callCount).to.be.eq(1); expect(txns[0].finalityStatus).to.be.eq(getTxnStatusAcceptL2Resp.finalityStatus); expect(txns[0].executionStatus).to.be.eq(getTxnStatusAcceptL2Resp.executionStatus); @@ -234,7 +234,7 @@ describe('Test function: getTransactions.updateStatus', function () { getTransactionStatusStub = sandbox.stub(utils, 'getTransactionStatus').throws(new Error()); }); it('should not throw error', async function () { - await updateStatus(txns[0], STARKNET_TESTNET_NETWORK); + await updateStatus(txns[0], STARKNET_SEPOLIA_TESTNET_NETWORK); expect(txns[0].finalityStatus).to.be.eq(unsettedTransactionInMassagedTxn.finalityStatus); expect(txns[0].executionStatus).to.be.eq(unsettedTransactionInMassagedTxn.executionStatus); expect(txns[0].status).to.be.eq(unsettedTransactionInMassagedTxn.status); diff --git a/packages/starknet-snap/test/src/getValue.test.ts b/packages/starknet-snap/test/src/getValue.test.ts index bc55a7d4..e59914ae 100644 --- a/packages/starknet-snap/test/src/getValue.test.ts +++ b/packages/starknet-snap/test/src/getValue.test.ts @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import { getValue } from '../../src/getValue'; import * as utils from '../../src/utils/starknetUtils'; import { SnapState } from '../../src/types/snapState'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { Mutex } from 'async-mutex'; import { ApiParams, GetValueRequestParams } from '../../src/types/snapApi'; @@ -17,7 +17,7 @@ describe('Test function: getValue', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/recoverAccounts.test.ts b/packages/starknet-snap/test/src/recoverAccounts.test.ts index 9150d9f8..0902f054 100644 --- a/packages/starknet-snap/test/src/recoverAccounts.test.ts +++ b/packages/starknet-snap/test/src/recoverAccounts.test.ts @@ -5,11 +5,7 @@ import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; import * as snapUtils from '../../src/utils/snapUtils'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, testnetAccAddresses, @@ -34,7 +30,7 @@ describe('Test function: recoverAccounts', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK, INVALID_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK, INVALID_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -90,7 +86,7 @@ describe('Test function: recoverAccounts', function () { expect(state.accContracts.length).to.be.eq(expectedCalledTimes); }); - it('should recover accounts in SN_GOERLI correctly', async function () { + it('should recover accounts in SN_SEPOLIA correctly', async function () { state.accContracts = []; const maxScanned = 5; const maxMissed = 3; @@ -122,7 +118,7 @@ describe('Test function: recoverAccounts', function () { expect(state.accContracts.length).to.be.eq(expectedCalledTimes); }); - it('should recover accounts in SN_GOERLI with same parameters correctly', async function () { + it('should recover accounts in SN_SEPOLIA with same parameters correctly', async function () { const maxScanned = 5; const maxMissed = 3; const validPublicKeys = 2; diff --git a/packages/starknet-snap/test/src/sendTransaction.test.ts b/packages/starknet-snap/test/src/sendTransaction.test.ts index 9cf547d4..debd95b8 100644 --- a/packages/starknet-snap/test/src/sendTransaction.test.ts +++ b/packages/starknet-snap/test/src/sendTransaction.test.ts @@ -8,7 +8,7 @@ import * as snapUtils from '../../src/utils/snapUtils'; import { SnapState } from '../../src/types/snapState'; import { sendTransaction } from '../../src/sendTransaction'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account1, createAccountProxyResp, @@ -36,7 +36,7 @@ describe('Test function: sendTransaction', function () { const state: SnapState = { accContracts: [account1], erc20Tokens: [token2, token3], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -255,7 +255,7 @@ describe('Test function: sendTransaction', function () { }, { type: 'copyable', - value: 'Goerli Testnet (deprecated soon)', + value: 'Sepolia Testnet', }, ], }, diff --git a/packages/starknet-snap/test/src/signDeclareTransaction.test.ts b/packages/starknet-snap/test/src/signDeclareTransaction.test.ts index 8dc2986b..63d8a99d 100644 --- a/packages/starknet-snap/test/src/signDeclareTransaction.test.ts +++ b/packages/starknet-snap/test/src/signDeclareTransaction.test.ts @@ -4,11 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { signDeclareTransaction } from '../../src/signDeclareTransaction'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, getBip44EntropyStub, account1, signature3 } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; @@ -25,7 +21,7 @@ describe('Test function: signDeclareTransaction', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_MAINNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts b/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts index ee9fc7fa..b4c05462 100644 --- a/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts +++ b/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts @@ -4,11 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { signDeployAccountTransaction } from '../../src/signDeployAccountTransaction'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, getBip44EntropyStub, account1, signature3 } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; @@ -25,7 +21,7 @@ describe('Test function: signDeployAccountTransaction', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_MAINNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/signMessage.test.ts b/packages/starknet-snap/test/src/signMessage.test.ts index 8b47fcb9..435bdb81 100644 --- a/packages/starknet-snap/test/src/signMessage.test.ts +++ b/packages/starknet-snap/test/src/signMessage.test.ts @@ -7,7 +7,7 @@ import { SnapState } from '../../src/types/snapState'; import { signMessage } from '../../src/signMessage'; import typedDataExample from '../../src/typedData/typedDataExample.json'; import { ArraySignatureType } from 'starknet'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account1, getBip44EntropyStub, @@ -29,7 +29,7 @@ describe('Test function: signMessage', function () { const state: SnapState = { accContracts: [account1], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { @@ -40,7 +40,7 @@ describe('Test function: signMessage', function () { }; const requestObject: SignMessageRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, signerAddress: account1.address, typedDataMessage: typedDataExample, enableAutherize: true, diff --git a/packages/starknet-snap/test/src/signTransaction.test.ts b/packages/starknet-snap/test/src/signTransaction.test.ts index 088fe21a..565d156c 100644 --- a/packages/starknet-snap/test/src/signTransaction.test.ts +++ b/packages/starknet-snap/test/src/signTransaction.test.ts @@ -4,11 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { signTransaction } from '../../src/signTransaction'; import { SnapState } from '../../src/types/snapState'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { createAccountProxyTxn, getBip44EntropyStub, account1, signature3 } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; @@ -25,7 +21,7 @@ describe('Test function: signMessage', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_MAINNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/src/switchNetwork.test.ts b/packages/starknet-snap/test/src/switchNetwork.test.ts index 57ced9a8..a3f12795 100644 --- a/packages/starknet-snap/test/src/switchNetwork.test.ts +++ b/packages/starknet-snap/test/src/switchNetwork.test.ts @@ -4,11 +4,7 @@ import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import * as snapUtils from '../../src/utils/snapUtils'; -import { - STARKNET_MAINNET_NETWORK, - STARKNET_TESTNET_NETWORK, - STARKNET_SEPOLIA_TESTNET_NETWORK, -} from '../../src/utils/constants'; +import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { Mutex } from 'async-mutex'; import { SwitchNetworkRequestParams, ApiParams } from '../../src/types/snapApi'; import { switchNetwork } from '../../src/switchNetwork'; @@ -21,9 +17,9 @@ describe('Test function: switchNetwork', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], + networks: [STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], - currentNetwork: STARKNET_TESTNET_NETWORK, + currentNetwork: STARKNET_SEPOLIA_TESTNET_NETWORK, }; const apiParams: ApiParams = { state, @@ -56,7 +52,6 @@ describe('Test function: switchNetwork', function () { expect(stateStub).to.be.calledOnce; expect(dialogStub).to.be.calledOnce; expect(state.currentNetwork).to.be.eql(STARKNET_MAINNET_NETWORK); - expect(state.networks.length).to.be.eql(3); }); it('should skip autherize when enableAutherize is false or omit', async function () { @@ -69,7 +64,6 @@ describe('Test function: switchNetwork', function () { expect(stateStub).to.be.calledOnce; expect(dialogStub).to.be.callCount(0); expect(state.currentNetwork).to.be.eql(STARKNET_MAINNET_NETWORK); - expect(state.networks.length).to.be.eql(3); }); it('should throw an error if network not found', async function () { @@ -94,7 +88,7 @@ describe('Test function: switchNetwork', function () { it('should throw an error if setCurrentNetwork failed', async function () { sandbox.stub(snapUtils, 'setCurrentNetwork').throws(new Error()); const requestObject: SwitchNetworkRequestParams = { - chainId: STARKNET_TESTNET_NETWORK.chainId, + chainId: STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, enableAutherize: true, }; apiParams.requestParams = requestObject; diff --git a/packages/starknet-snap/test/src/verifySignedMessage.test.ts b/packages/starknet-snap/test/src/verifySignedMessage.test.ts index e87d5aa4..8d3cc22b 100644 --- a/packages/starknet-snap/test/src/verifySignedMessage.test.ts +++ b/packages/starknet-snap/test/src/verifySignedMessage.test.ts @@ -6,7 +6,7 @@ import { WalletMock } from '../wallet.mock.test'; import { SnapState } from '../../src/types/snapState'; import typedDataExample from '../../src/typedData/typedDataExample.json'; import { verifySignedMessage } from '../../src/verifySignedMessage'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { account1, getBip44EntropyStub, signature1, signature2, unfoundUserAddress } from '../constants.test'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import * as utils from '../../src/utils/starknetUtils'; @@ -22,7 +22,7 @@ describe('Test function: verifySignedMessage', function () { const state: SnapState = { accContracts: [account1], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; const apiParams: ApiParams = { diff --git a/packages/starknet-snap/test/utils/keyPair.test.ts b/packages/starknet-snap/test/utils/keyPair.test.ts index f1945784..a6fee8a4 100644 --- a/packages/starknet-snap/test/utils/keyPair.test.ts +++ b/packages/starknet-snap/test/utils/keyPair.test.ts @@ -4,8 +4,6 @@ import sinonChai from 'sinon-chai'; import { getAddressKey, getAddressKeyDeriver, grindKey } from '../../src/utils/keyPair'; import { bip44Entropy } from '../constants.test'; import { WalletMock } from '../wallet.mock.test'; -// import { getAccContractAddressAndCallData, getKeysFromAddressIndex } from '../../src/utils/starknetUtils'; -// import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; chai.use(sinonChai); @@ -22,18 +20,6 @@ describe('Test function: getAddressKey', function () { walletStub.reset(); }); - // it('should get the first 10 addresses and derived keys from the BIP-44 entropy', async function () { - // const deriveStarkNetAddress = await getBIP44AddressKeyDeriver(bip44Entropy); - // for (let i = 0; i < 10; i++) { - // const result = await getKeysFromAddressIndex(deriveStarkNetAddress, '', null, i); - // const { address } = getAccContractAddressAndCallData( - // STARKNET_TESTNET_NETWORK.accountClassHash, - // result.publicKey, - // ); - // console.log(`result ${i}:\npublicKey: ${result.publicKey}\nprivateKey: ${result.privateKey}\naddress: ${address}`); - // } - // }); - it('should get the ground address key from the BIP-44 entropy correctly', async function () { const deriveStarkNetAddress = await getBIP44AddressKeyDeriver(bip44Entropy); const privateKey = (await deriveStarkNetAddress(0)).privateKey; diff --git a/packages/starknet-snap/test/utils/snapUtils.test.ts b/packages/starknet-snap/test/utils/snapUtils.test.ts index 7b14317d..b631b306 100644 --- a/packages/starknet-snap/test/utils/snapUtils.test.ts +++ b/packages/starknet-snap/test/utils/snapUtils.test.ts @@ -1,5 +1,14 @@ import { expect } from 'chai'; -import { dappUrl } from '../../src/utils/snapUtils'; +import { Mutex } from 'async-mutex'; + +import { dappUrl, removeNetwork } from '../../src/utils/snapUtils'; +import { WalletMock } from '../wallet.mock.test'; +import { Network, SnapState } from '../../src/types/snapState'; +import { + STARKNET_SEPOLIA_TESTNET_NETWORK, + STARKNET_TESTNET_NETWORK, + STARKNET_MAINNET_NETWORK, +} from '../../src/utils/constants'; describe('Snap Utils', () => { it('should return the proper dapp URL based on the environment', () => { @@ -22,3 +31,59 @@ describe('Snap Utils', () => { expect(dappUrl(undefined)).to.be.equal('https://snaps.consensys.io/starknet'); }); }); + +describe('removeNetwork', () => { + const setupStubs = ( + currentNetwork?: Network, + defaultNetworks: Network[] = [STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK], + ) => { + const walletStub = new WalletMock(); + const state: SnapState = { + accContracts: [], + erc20Tokens: [], + networks: defaultNetworks, + transactions: [], + currentNetwork: currentNetwork, + }; + walletStub.rpcStubs.snap_manageState.resolves(state); + return { walletStub, state }; + }; + + it('removes the network if the target network found', async function () { + const { walletStub, state } = setupStubs(); + + await removeNetwork(STARKNET_TESTNET_NETWORK, walletStub, new Mutex()); + + expect(state.networks).to.be.eql([STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK]); + }); + + it('does not remove the network if the target network not found', async function () { + const { walletStub, state } = setupStubs(); + + await removeNetwork(STARKNET_TESTNET_NETWORK, walletStub, new Mutex()); + + expect(state.networks).to.be.eql([STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK]); + }); + + it('set current network to undefined if current network is equal to target network', async function () { + const { walletStub, state } = setupStubs(STARKNET_TESTNET_NETWORK); + + expect(state.currentNetwork).to.be.eql(STARKNET_TESTNET_NETWORK); + + await removeNetwork(STARKNET_TESTNET_NETWORK, walletStub, new Mutex()); + + expect(state.networks).to.be.eql([STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK]); + expect(state.currentNetwork).to.be.eql(undefined); + }); + + it('does not set current network to undefined if current network is not equal to target network', async function () { + const { walletStub, state } = setupStubs(STARKNET_MAINNET_NETWORK); + + expect(state.currentNetwork).to.be.eql(STARKNET_MAINNET_NETWORK); + + await removeNetwork(STARKNET_TESTNET_NETWORK, walletStub, new Mutex()); + + expect(state.networks).to.be.eql([STARKNET_SEPOLIA_TESTNET_NETWORK, STARKNET_MAINNET_NETWORK]); + expect(state.currentNetwork).to.be.eql(STARKNET_MAINNET_NETWORK); + }); +}); diff --git a/packages/starknet-snap/test/utils/starknetUtils.test.ts b/packages/starknet-snap/test/utils/starknetUtils.test.ts index e4a70e1a..0fdde06b 100644 --- a/packages/starknet-snap/test/utils/starknetUtils.test.ts +++ b/packages/starknet-snap/test/utils/starknetUtils.test.ts @@ -3,7 +3,7 @@ import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import { WalletMock } from '../wallet.mock.test'; import * as utils from '../../src/utils/starknetUtils'; -import { STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; +import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { getTxnFromVoyagerResp1, @@ -32,7 +32,7 @@ describe('Test function: callContract', function () { return { result: ['0x795d62a9896b221af17bedd8cceb8d963ac6864857d7476e2f8c03ba0c5df9'] }; }); - const result = await utils.getSigner(userAddress, STARKNET_TESTNET_NETWORK); + const result = await utils.getSigner(userAddress, STARKNET_SEPOLIA_TESTNET_NETWORK); expect(result).to.be.eq('0x795d62a9896b221af17bedd8cceb8d963ac6864857d7476e2f8c03ba0c5df9'); }); @@ -41,7 +41,7 @@ describe('Test function: callContract', function () { return getTxnsFromVoyagerResp; }); - const result = await utils.getTransactionsFromVoyager(userAddress, 10, 1, STARKNET_TESTNET_NETWORK); + const result = await utils.getTransactionsFromVoyager(userAddress, 10, 1, STARKNET_SEPOLIA_TESTNET_NETWORK); expect(result).to.be.eql(getTxnsFromVoyagerResp); }); @@ -50,7 +50,7 @@ describe('Test function: callContract', function () { return getTxnFromVoyagerResp1; }); - const result = await utils.getTransactionFromVoyager(userAddress, STARKNET_TESTNET_NETWORK); + const result = await utils.getTransactionFromVoyager(userAddress, STARKNET_SEPOLIA_TESTNET_NETWORK); expect(result).to.be.eql(getTxnFromVoyagerResp1); }); }); @@ -63,7 +63,7 @@ describe('Test function: getKeysFromAddress', function () { const state: SnapState = { accContracts: [], erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], + networks: [STARKNET_SEPOLIA_TESTNET_NETWORK], transactions: [], }; @@ -89,14 +89,20 @@ describe('Test function: getKeysFromAddress', function () { }); it('should return address keys correctly', async function () { - const result = await utils.getKeysFromAddress(keyDeriver, STARKNET_TESTNET_NETWORK, state, account1.address, 5); + const result = await utils.getKeysFromAddress( + keyDeriver, + STARKNET_SEPOLIA_TESTNET_NETWORK, + state, + account1.address, + 5, + ); expect(result).to.be.eq(getKeysFromAddressIndexResult); }); it('should throw error when address keys not found', async function () { let result = null; try { - result = await utils.getKeysFromAddress(keyDeriver, STARKNET_TESTNET_NETWORK, state, account2.address, 5); + result = await utils.getKeysFromAddress(keyDeriver, STARKNET_SEPOLIA_TESTNET_NETWORK, state, account2.address, 5); } catch (err) { result = err; } finally { diff --git a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx index 0c155a4a..56404145 100644 --- a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx +++ b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.stories.tsx @@ -10,7 +10,7 @@ export default { const transaction: Transaction = { txnHash: '0x1321951d3102d45abd6dd9ac556b6a86190c78b1026279a8d44cb18c0008eb6', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', diff --git a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx index 125256ca..a663e1da 100644 --- a/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx +++ b/packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionsList.stories.tsx @@ -11,7 +11,7 @@ const transactions: Transaction[] = [ { txnHash: '0x3d82342a73d5562d65986c40b88123913a8f0b72be390b3d54377ca3216825d', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x5ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -24,7 +24,7 @@ const transactions: Transaction[] = [ { txnHash: '0x1321951d3102d45abd6dd9ac556b6a86190c78b1026279a8d44cb18c0008eb6', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -37,7 +37,7 @@ const transactions: Transaction[] = [ { txnHash: '0x3b07b90f722dfd18623dcb5b21e0efc8a72625bac50eacd58cde4b02e75f2c9', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x5ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -50,7 +50,7 @@ const transactions: Transaction[] = [ { txnHash: '0x61f7c1c7bc55f18414cc876bb80dfd340cbeda29035c696ce37ef8ec256a466', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -63,7 +63,7 @@ const transactions: Transaction[] = [ { txnHash: '0x33e94af9ee3ab7ddcd1aa9fe63942eee9ea5be474061d4ddac6deb466f3b12f', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -76,7 +76,7 @@ const transactions: Transaction[] = [ { txnHash: '0x58b04d593d8f7e7166e16d15a67f843fb02c5d17a77aae74e8baf42cd017070', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -89,7 +89,7 @@ const transactions: Transaction[] = [ { txnHash: '0x81fab4268648483028b9be3353d6551ca35041fb2a03c2f372b19f3ab109b1', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -102,7 +102,7 @@ const transactions: Transaction[] = [ { txnHash: '0x2b16c4989c0fa7baf91082e4d4af6f82d3111c86a4265bc8a2889401099cd3d', txnType: 'invoke', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: 'transfer', @@ -115,7 +115,7 @@ const transactions: Transaction[] = [ { txnHash: '0x40a693f71f1e9d384e178dbafe5d1d99ccbc6b8fe64b49986a70058c6b68983', txnType: 'deploy', - chainId: '0x534e5f474f45524c49', + chainId: '0x534e5f5345504f4c4941', senderAddress: '0x05ccc9fc2d7ce9e2b0f2cee1a4b898570bb4d03ba23ad6f72f0db971bd04552c', contractAddress: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', contractFuncName: '', diff --git a/packages/wallet-ui/src/utils/constants.ts b/packages/wallet-ui/src/utils/constants.ts index f0806b8a..8dfaeaf4 100644 --- a/packages/wallet-ui/src/utils/constants.ts +++ b/packages/wallet-ui/src/utils/constants.ts @@ -8,22 +8,8 @@ export const TOKENS: any = { '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': { coingeckoId: 'ethereum', }, - }, - [constants.StarknetChainId.TESTNET]: { - '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7': { - coingeckoId: 'ethereum', - }, - '0x12d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56': { - coingeckoId: 'wrapped-bitcoin', - }, - '0x386e8d061177f19b3b485c20e31137e6f6bc497cc635ccdfcab96fadf5add6a': { - coingeckoId: 'tether', - }, - '0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9': { - coingeckoId: 'dai', - }, - '0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426': { - coingeckoId: 'usd-coin', + '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d': { + coingeckoId: 'starknet', }, }, [SEPOLIA_CHAINID]: { @@ -42,6 +28,9 @@ export const TOKENS: any = { '0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426': { coingeckoId: 'usd-coin', }, + '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d': { + coingeckoId: 'starknet', + }, }, }; @@ -51,8 +40,6 @@ export const COINGECKO_API = 'https://api.coingecko.com/api/v3/'; export const STARKNET_MAINNET_EXPLORER = 'https://voyager.online/'; -export const STARKNET_TESTNET_EXPLORER = 'https://goerli.voyager.online/'; - export const STARKNET_SEPOLIA_TESTNET_EXPLORER = 'https://sepolia.voyager.online/'; export const SNAPS_DOC_URL = 'https://docs.metamask.io/guide/snaps.html'; diff --git a/packages/wallet-ui/src/utils/utils.ts b/packages/wallet-ui/src/utils/utils.ts index f7ce4141..7aaa7a98 100644 --- a/packages/wallet-ui/src/utils/utils.ts +++ b/packages/wallet-ui/src/utils/utils.ts @@ -3,7 +3,6 @@ import { ethers } from 'ethers'; import { DECIMALS_DISPLAYED_MAX_LENGTH, STARKNET_MAINNET_EXPLORER, - STARKNET_TESTNET_EXPLORER, STARKNET_SEPOLIA_TESTNET_EXPLORER, SEPOLIA_CHAINID, TIMEOUT_DURATION, @@ -16,19 +15,12 @@ export const shortenAddress = (address: string, num = 3) => { return !!address && `${address.substring(0, num + 2)}...${address.substring(address.length - num - 1)}`; }; -export const openExplorerTab = ( - address: string, - type = 'contract', - chainId = constants.StarknetChainId.TESTNET as string, -) => { - let explorerUrl = STARKNET_TESTNET_EXPLORER; +export const openExplorerTab = (address: string, type = 'contract', chainId = SEPOLIA_CHAINID) => { + let explorerUrl = STARKNET_SEPOLIA_TESTNET_EXPLORER; switch (chainId) { case constants.StarknetChainId.MAINNET: explorerUrl = STARKNET_MAINNET_EXPLORER; break; - case constants.StarknetChainId.TESTNET: - explorerUrl = STARKNET_TESTNET_EXPLORER; - break; case SEPOLIA_CHAINID: explorerUrl = STARKNET_SEPOLIA_TESTNET_EXPLORER; break; diff --git a/yarn.lock b/yarn.lock index 4816c30b..72c01d43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3163,7 +3163,7 @@ __metadata: ethers: ^5.5.1 starknet: ^5.14.0 starknet_v4.22.0: "npm:starknet@4.22.0" - checksum: 2e9cf4fa50d9b385d0e53073f2611445e796e2bcb79407d6e47fbc0ba101881fd159910fb29968afec9e04e8ea753e511220640e99ca983571331d377c94b976 + checksum: 983f842b9dba2bec7cfcd8907f9dd8d420befc61e045b7138f1786f1662ff6c4f3279b8db49193cf2ae39dff0b9173a5475d1b072f918fda72d54d9d05d4bfd5 languageName: node linkType: hard