diff --git a/packages/starknet-snap/package.json b/packages/starknet-snap/package.json index 3a691581..68c97388 100644 --- a/packages/starknet-snap/package.json +++ b/packages/starknet-snap/package.json @@ -39,7 +39,6 @@ "chai-as-promised": "^7.1.1", "concurrently": "^7.1.0", "cross-env": "^7.0.3", - "envify": "^4.1.0", "eslint": "^8.13.0", "mocha": "^9.2.2", "nyc": "^15.1.0", @@ -54,9 +53,10 @@ "dependencies": { "@metamask/snaps-sdk": "3.0.1", "async-mutex": "^0.3.2", + "dotenv": "^16.4.5", "ethereum-unit-converter": "^0.0.17", "ethers": "^5.5.1", - "starknet": "^5.14.0", + "starknet": "6.6.6", "starknet_v4.22.0": "npm:starknet@4.22.0" }, "publishConfig": { diff --git a/packages/starknet-snap/snap.config.js b/packages/starknet-snap/snap.config.js index 1e6bb254..f3cb5cd0 100644 --- a/packages/starknet-snap/snap.config.js +++ b/packages/starknet-snap/snap.config.js @@ -1,16 +1,14 @@ -import envify from "envify/custom"; +import * as dotenv from "dotenv"; +dotenv.config(); module.exports = { - cliOptions: { - dist: 'dist', - outfileName: 'bundle.js', - src: './src/index.ts', - }, - bundlerCustomizer: (bundler) => { - bundler.transform( - envify({ - SNAP_ENV: process.env.SNAP_ENV, - }), - ); - }, -}; \ No newline at end of file + bundler: "webpack", + environment: { + SNAP_ENV: process.env.SNAP_ENV ?? "prod", + }, + input: "./src/index.ts", + server: { + port: 8081, + }, + polyfills: true +}; diff --git a/packages/starknet-snap/snap.manifest.json b/packages/starknet-snap/snap.manifest.json index 5a73fd31..c0e50222 100644 --- a/packages/starknet-snap/snap.manifest.json +++ b/packages/starknet-snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/ConsenSys/starknet-snap.git" }, "source": { - "shasum": "A3cyal6PKAzEQQ3ptdBUK106XMp5jQVh4kydh87u7AA=", + "shasum": "YbuYD0p5mRtllKx98NNZ9YIz+G7QBvd3iW1S6Vc1kjg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/starknet-snap/src/createAccount.ts b/packages/starknet-snap/src/createAccount.ts index 535a893e..033bba30 100644 --- a/packages/starknet-snap/src/createAccount.ts +++ b/packages/starknet-snap/src/createAccount.ts @@ -98,7 +98,7 @@ export async function createAccount(params: ApiParams, silentMode = false) { privateKey, ); logger.log(`createAccount:\nestimateDeployFee: ${toJson(estimateDeployFee)}`); - if (Number(getBalanceResp.result[0]) < Number(estimateDeployFee.suggestedMaxFee)) { + if (Number(getBalanceResp[0]) < Number(estimateDeployFee.suggestedMaxFee)) { const gasFeeStr = ethers.utils.formatUnits(estimateDeployFee.suggestedMaxFee.toString(10), 18); const gasFeeFloat = parseFloat(gasFeeStr).toFixed(6); // 6 decimal places for ether const gasFeeInEther = Number(gasFeeFloat) === 0 ? '0.000001' : gasFeeFloat; @@ -110,14 +110,9 @@ export async function createAccount(params: ApiParams, silentMode = false) { } } - const deployResp = await deployAccount( - network, - contractAddress, - contractCallData, - publicKey, - privateKey, - estimateDeployFee?.suggestedMaxFee, - ); + const deployResp = await deployAccount(network, contractAddress, contractCallData, publicKey, privateKey, { + maxFee: estimateDeployFee?.suggestedMaxFee, + }); if (deployResp.contract_address && deployResp.transaction_hash) { const userAccount: AccContract = { diff --git a/packages/starknet-snap/src/estimateFee.ts b/packages/starknet-snap/src/estimateFee.ts index f86db237..6fc8e05c 100644 --- a/packages/starknet-snap/src/estimateFee.ts +++ b/packages/starknet-snap/src/estimateFee.ts @@ -1,19 +1,18 @@ import { toJson } from './utils/serializer'; -import { Invocations, TransactionType } from 'starknet'; +import { Invocations, TransactionType, constants } from 'starknet'; import { validateAndParseAddress } from '../src/utils/starknetUtils'; import { ApiParams, EstimateFeeRequestParams } from './types/snapApi'; import { getNetworkFromChainId } from './utils/snapUtils'; import { getKeysFromAddress, getCallDataArray, - estimateFee as estimateFeeUtil, getAccContractAddressAndCallData, estimateFeeBulk, addFeesFromAllTransactions, isAccountDeployed, } from './utils/starknetUtils'; -import { PROXY_CONTRACT_HASH } from './utils/constants'; +import { PRICE_UNIT, PROXY_CONTRACT_HASH } from './utils/constants'; import { logger } from './utils/logger'; export async function estimateFee(params: ApiParams) { @@ -40,6 +39,9 @@ export async function estimateFee(params: ApiParams) { throw new Error(`The given sender address is invalid: ${requestParamsObj.senderAddress}`); } + const priceUnit = requestParamsObj.priceUnit ?? PRICE_UNIT.WEI; + const txVersion = + priceUnit === PRICE_UNIT.FRI ? constants.TRANSACTION_VERSION.V3 : constants.TRANSACTION_VERSION.V1; const contractAddress = requestParamsObj.contractAddress; const contractFuncName = requestParamsObj.contractFuncName; const contractCallData = getCallDataArray(requestParamsObj.contractCallData); @@ -62,12 +64,9 @@ export async function estimateFee(params: ApiParams) { //Estimate deploy account fee if the signer has not been deployed yet const accountDeployed = await isAccountDeployed(network, publicKey); - let bulkTransactions: Invocations = [ - { - type: TransactionType.INVOKE, - payload: txnInvocation, - }, - ]; + + const transactions: Invocations = []; + if (!accountDeployed) { const { callData } = getAccContractAddressAndCallData(publicKey); const deployAccountpayload = { @@ -77,39 +76,30 @@ export async function estimateFee(params: ApiParams) { addressSalt: publicKey, }; - bulkTransactions = [ - { - type: TransactionType.DEPLOY_ACCOUNT, - payload: deployAccountpayload, - }, - { - type: TransactionType.INVOKE, - payload: txnInvocation, - }, - ]; + transactions.push({ + type: TransactionType.DEPLOY_ACCOUNT, + payload: deployAccountpayload, + }); } - let estimateFeeResp; - - if (accountDeployed) { - // This condition branch will be removed later when starknet.js - // supports estimateFeeBulk in rpc mode - estimateFeeResp = await estimateFeeUtil(network, senderAddress, senderPrivateKey, txnInvocation); - logger.log(`estimateFee:\nestimateFeeUtil estimateFeeResp: ${toJson(estimateFeeResp)}`); - } else { - const estimateBulkFeeResp = await estimateFeeBulk(network, senderAddress, senderPrivateKey, bulkTransactions); - logger.log(`estimateFee:\nestimateFeeBulk estimateBulkFeeResp: ${toJson(estimateBulkFeeResp)}`); - estimateFeeResp = addFeesFromAllTransactions(estimateBulkFeeResp); - } + transactions.push({ + type: TransactionType.INVOKE, + payload: txnInvocation, + }); + + const estimateBulkFeeResp = await estimateFeeBulk(network, senderAddress, senderPrivateKey, transactions, { + version: txVersion, + }); + logger.log(`estimateFee:\nestimateFeeBulk estimateBulkFeeResp: ${toJson(estimateBulkFeeResp)}`); + + const estimateFeeResp = addFeesFromAllTransactions(estimateBulkFeeResp); logger.log(`estimateFee:\nestimateFeeResp: ${toJson(estimateFeeResp)}`); const resp = { suggestedMaxFee: estimateFeeResp.suggestedMaxFee.toString(10), overallFee: estimateFeeResp.overall_fee.toString(10), - gasConsumed: estimateFeeResp.gas_consumed?.toString(10) ?? '0', - gasPrice: estimateFeeResp.gas_price?.toString(10) ?? '0', - unit: 'wei', + unit: priceUnit.toLowerCase(), includeDeploy: !accountDeployed, }; logger.log(`estimateFee:\nresp: ${toJson(resp)}`); diff --git a/packages/starknet-snap/src/getErc20TokenBalance.ts b/packages/starknet-snap/src/getErc20TokenBalance.ts index aed4a349..5cadb9d0 100644 --- a/packages/starknet-snap/src/getErc20TokenBalance.ts +++ b/packages/starknet-snap/src/getErc20TokenBalance.ts @@ -39,7 +39,7 @@ export async function getErc20TokenBalance(params: ApiParams) { logger.log(`getErc20Balance:\nresp: ${toJson(resp)}`); - return resp.result[0]; + return resp[0]; } catch (err) { logger.error(`Problem found: ${err}`); throw err; diff --git a/packages/starknet-snap/src/getValue.ts b/packages/starknet-snap/src/getValue.ts index a113c018..145f9395 100644 --- a/packages/starknet-snap/src/getValue.ts +++ b/packages/starknet-snap/src/getValue.ts @@ -37,7 +37,7 @@ export async function getValue(params: ApiParams) { logger.log(`getValue:\nresp: ${toJson(resp)}`); - return resp.result; + return resp; } catch (err) { logger.error(`Problem found: ${err}`); throw err; diff --git a/packages/starknet-snap/src/types/snapApi.ts b/packages/starknet-snap/src/types/snapApi.ts index f261458a..b7022f56 100644 --- a/packages/starknet-snap/src/types/snapApi.ts +++ b/packages/starknet-snap/src/types/snapApi.ts @@ -13,6 +13,7 @@ import { DeclareSignerDetails, typedData, } from 'starknet'; +import { PRICE_UNIT } from '../utils/constants'; export interface ApiParams { state: SnapState; @@ -113,6 +114,7 @@ export interface EstimateFeeRequestParams extends BaseRequestParams { contractFuncName: string; contractCallData?: string; senderAddress: string; + priceUnit?: PRICE_UNIT; } export interface EstimateAccountDeployFeeRequestParams extends BaseRequestParams { diff --git a/packages/starknet-snap/src/utils/constants.ts b/packages/starknet-snap/src/utils/constants.ts index 02a2eb84..d36e8dc5 100644 --- a/packages/starknet-snap/src/utils/constants.ts +++ b/packages/starknet-snap/src/utils/constants.ts @@ -15,6 +15,11 @@ export const TRANSFER_SELECTOR_HEX = '0x83afd3f4caedc6eebf44246fe54e38c95e3179a5 export const ACCOUNT_CLASS_HASH_V0 = '0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2'; // from argent-x repo +export enum PRICE_UNIT { + WEI = 'WEI', + FRI = 'FRI', +} + interface IDappConfig { dev: string; staging: string; @@ -40,7 +45,7 @@ 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', + nodeUrl: 'https://starknet-goerli.g.alchemy.com/starknet/version/rpc/v0_7/1Bw_6sofLIpDzAROgFM1KXIISP2jUAVO', voyagerUrl: 'https://goerli.voyager.online', accountClassHash: '', // from argent-x repo }; diff --git a/packages/starknet-snap/src/utils/starknetUtils.ts b/packages/starknet-snap/src/utils/starknetUtils.ts index 7e52561b..f432956c 100644 --- a/packages/starknet-snap/src/utils/starknetUtils.ts +++ b/packages/starknet-snap/src/utils/starknetUtils.ts @@ -21,19 +21,18 @@ import { GetTransactionResponse, Invocations, validateAndParseAddress as _validateAndParseAddress, - EstimateFeeDetails, DeclareContractPayload, DeclareContractResponse, - InvocationsDetails, Signer, Signature, stark, - InvocationsSignerDetails, Abi, + UniversalDetails, DeclareSignerDetails, DeployAccountSignerDetails, + InvocationsSignerDetails, + ProviderInterface, } from 'starknet'; -import type { Hex } from '@noble/curves/abstract/utils'; import { Network, SnapState, Transaction, TransactionType } from '../types/snapState'; import { ACCOUNT_CLASS_HASH_V0, PROXY_CONTRACT_HASH, TRANSFER_SELECTOR_HEX } from './constants'; import { getAddressKey } from './keyPair'; @@ -48,23 +47,14 @@ export const getCallDataArray = (callDataStr: string): string[] => { .filter((x) => x.length > 0); }; -export const getProvider = (network: Network, forceSequencer = false): Provider => { +export const getProvider = (network: Network): ProviderInterface => { let providerParam: ProviderOptions = {}; - // same precedence as defined in starknet.js Provider class constructor - if (network.nodeUrl && !forceSequencer) { - providerParam = { - rpc: { - nodeUrl: network.nodeUrl, - }, - }; - } else if (network.baseUrl) { - providerParam = { - sequencer: { - baseUrl: network.baseUrl, - }, - }; - } - return new Provider(providerParam); + providerParam = { + nodeUrl: network.nodeUrl, + }; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + return new Provider(providerParam) as unknown as ProviderInterface; }; export const callContract = async ( @@ -89,11 +79,11 @@ export const declareContract = async ( senderAddress: string, privateKey: string | Uint8Array, contractPayload: DeclareContractPayload, - transactionsDetail?: InvocationsDetails, + invocationsDetails?: UniversalDetails, ): Promise => { const provider = getProvider(network); - const account = new Account(provider, senderAddress, privateKey); - return account.declare(contractPayload, transactionsDetail); + const account = new Account(provider, senderAddress, privateKey, '1'); + return account.declare(contractPayload, { ...invocationsDetails, skipValidate: false, blockIdentifier: 'latest' }); }; export const estimateFee = async ( @@ -101,10 +91,15 @@ export const estimateFee = async ( senderAddress: string, privateKey: string | Uint8Array, txnInvocation: Call | Call[], + invocationsDetails?: UniversalDetails, ): Promise => { const provider = getProvider(network); - const account = new Account(provider, senderAddress, privateKey); - return account.estimateInvokeFee(txnInvocation, { blockIdentifier: 'latest' }); + const account = new Account(provider, senderAddress, privateKey, '1'); + return account.estimateInvokeFee(txnInvocation, { + ...invocationsDetails, + skipValidate: false, + blockIdentifier: 'latest', + }); }; export const estimateFeeBulk = async ( @@ -112,13 +107,15 @@ export const estimateFeeBulk = async ( senderAddress: string, privateKey: string | Uint8Array, txnInvocation: Invocations, - invocationsDetails: EstimateFeeDetails = { blockIdentifier: 'latest' }, + invocationsDetails?: UniversalDetails, ): Promise => { - // ensure always calling the sequencer endpoint since the rpc endpoint and - // starknet.js are not supported yet. const provider = getProvider(network); - const account = new Account(provider, senderAddress, privateKey); - return account.estimateFeeBulk(txnInvocation, invocationsDetails); + const account = new Account(provider, senderAddress, privateKey, '1'); + return account.estimateFeeBulk(txnInvocation, { + ...invocationsDetails, + skipValidate: false, + blockIdentifier: 'latest', + }); }; export const executeTxn = async ( @@ -127,11 +124,15 @@ export const executeTxn = async ( privateKey: string | Uint8Array, txnInvocation: Call | Call[], abis?: Abi[], - invocationsDetails?: InvocationsDetails, + invocationsDetails?: UniversalDetails, ): Promise => { const provider = getProvider(network); - const account = new Account(provider, senderAddress, privateKey); - return account.execute(txnInvocation, abis, invocationsDetails); + const account = new Account(provider, senderAddress, privateKey, '0'); + return account.execute(txnInvocation, abis, { + ...invocationsDetails, + skipValidate: false, + blockIdentifier: 'latest', + }); }; export const deployAccount = async ( @@ -140,17 +141,21 @@ export const deployAccount = async ( contractCallData: RawCalldata, addressSalt: num.BigNumberish, privateKey: string | Uint8Array, - maxFee: num.BigNumberish, + invocationsDetails?: UniversalDetails, ): Promise => { const provider = getProvider(network); - const account = new Account(provider, contractAddress, privateKey); + const account = new Account(provider, contractAddress, privateKey, '1'); const deployAccountPayload = { classHash: PROXY_CONTRACT_HASH, contractAddress: contractAddress, constructorCalldata: contractCallData, addressSalt, }; - return account.deployAccount(deployAccountPayload, { maxFee }); + return account.deployAccount(deployAccountPayload, { + ...invocationsDetails, + skipValidate: false, + blockIdentifier: 'latest', + }); }; export const estimateAccountDeployFee = async ( @@ -159,21 +164,26 @@ export const estimateAccountDeployFee = async ( contractCallData: RawCalldata, addressSalt: num.BigNumberish, privateKey: string | Uint8Array, + invocationsDetails?: UniversalDetails, ): Promise => { const provider = getProvider(network); - const account = new Account(provider, contractAddress, privateKey); + const account = new Account(provider, contractAddress, privateKey, '1'); const deployAccountPayload = { classHash: PROXY_CONTRACT_HASH, contractAddress: contractAddress, constructorCalldata: contractCallData, addressSalt, }; - return account.estimateAccountDeployFee(deployAccountPayload); + return account.estimateAccountDeployFee(deployAccountPayload, { + ...invocationsDetails, + skipValidate: false, + blockIdentifier: 'latest', + }); }; export const getSigner = async (userAccAddress: string, network: Network): Promise => { - const resp = await callContract(network, userAccAddress, 'getSigner'); - return resp.result[0]; + const resp = await callContract(network, userAccAddress, 'get_owner'); + return resp[0]; }; export const getTransactionStatus = async (transactionHash: num.BigNumberish, network: Network) => { @@ -304,9 +314,17 @@ export const getMassagedTransactions = async ( txnHash: txnResp.transaction_hash || txn.hash, txnType: txn.type?.toLowerCase(), chainId: network.chainId, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore senderAddress: txnResp.sender_address || txnResp.contract_address || txn.contract_address || '', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore contractAddress: txnResp.calldata?.[1] || txnResp.contract_address || txn.contract_address || '', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore contractFuncName: num.toBigInt(txnResp.calldata?.[2] || '') === bigIntTransferSelectorHex ? 'transfer' : '', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore contractCallData: txnResp.calldata?.slice(6, txnResp.calldata?.length - 1) || [], timestamp: txn.timestamp, status: '', //DEPRECATION @@ -361,12 +379,12 @@ export const postData = async (url = '', data = {}) => { return response.json(); // parses JSON response into native JavaScript objects }; -export function getFullPublicKeyPairFromPrivateKey(privateKey: Hex) { +export function getFullPublicKeyPairFromPrivateKey(privateKey: string) { return encode.addHexPrefix(encode.buf2hex(ec.starkCurve.getPublicKey(privateKey, false))); } export const getTypedDataMessageSignature = ( - privateKey: Hex, + privateKey: string, typedDataMessage: typedData.TypedData, signerUserAddress: string, ) => { @@ -374,15 +392,15 @@ export const getTypedDataMessageSignature = ( return ec.starkCurve.sign(msgHash, privateKey); }; -export const getSignatureBySignatureString = (signatureStr: Hex) => { +export const getSignatureBySignatureString = (signatureStr: string) => { return ec.starkCurve.Signature.fromDER(signatureStr); }; export const verifyTypedDataMessageSignature = ( - fullPublicKey: Hex, + fullPublicKey: string, typedDataMessage: typedData.TypedData, signerUserAddress: num.BigNumberish, - signatureStr: Hex, + signatureStr: string, ) => { const signature = getSignatureBySignatureString(signatureStr); const msgHash = typedData.getMessageHash(typedDataMessage, signerUserAddress); @@ -483,7 +501,7 @@ export const isAccountDeployed = async (network: Network, publicKey: string) => return accountDeployed; }; -export const addFeesFromAllTransactions = (fees: EstimateFee[]): EstimateFee => { +export const addFeesFromAllTransactions = (fees: EstimateFee[]) => { let overall_fee_bn = num.toBigInt(0); let suggestedMaxFee_bn = num.toBigInt(0); @@ -513,6 +531,8 @@ export const signTransactions = async ( abis: Abi[], ): Promise => { const signer = new Signer(privateKey); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore const signatures = await signer.signTransaction(transactions, transactionsDetail, abis); return stark.signatureToDecimalArray(signatures); }; @@ -536,7 +556,7 @@ export const signDeclareTransaction = async ( }; export const signMessage = async ( - privateKey: Hex, + privateKey: string, typedDataMessage: typedData.TypedData, signerUserAddress: string, ) => { @@ -547,5 +567,7 @@ export const signMessage = async ( export const getStarkNameUtil = async (network: Network, userAddress: string) => { const provider = getProvider(network); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore return provider.getStarkName(userAddress); }; diff --git a/packages/starknet-snap/test/constants.test.ts b/packages/starknet-snap/test/constants.test.ts index 1b8b430b..780f579c 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 { EstimateFee, GetTransactionResponse, constants, num } from 'starknet'; import { AccContract, Erc20Token, @@ -341,45 +341,43 @@ export const mainnetTxn1: Transaction = { eventIds: [], }; -export const getBalanceResp = { - result: ['0x0', '0x0'], -}; +export const getBalanceResp = ['0x0', '0x0']; export const estimateDeployFeeResp = { overall_fee: num.toBigInt('0x0'), gas_consumed: num.toBigInt('0x0'), suggestedMaxFee: num.toBigInt('0x0'), gas_price: num.toBigInt('0x0'), -}; +} as EstimateFee; export const estimateDeployFeeResp2 = { overall_fee: num.toBigInt('0xaff3f0a7'), gas_consumed: num.toBigInt('0x18e1'), suggestedMaxFee: num.toBigInt('0x0107ede8fa'), gas_price: num.toBigInt('0x071287'), -}; +} as EstimateFee; export const estimateDeployFeeResp3 = { overall_fee: num.toBigInt('0x1160f77b2edd'), gas_consumed: num.toBigInt('0x18e1'), suggestedMaxFee: num.toBigInt('0x1a117338c64b'), gas_price: num.toBigInt('0xb2d3297d'), -}; +} as EstimateFee; export const estimateDeployFeeResp4 = { overall_fee: num.toBigInt('0x1160f77b2edd'), suggestedMaxFee: num.toBigInt('0x1a117338c64b'), -}; +} as EstimateFee; export const estimateFeeResp = { overall_fee: num.toBigInt('0x0dc3e44d89e6'), suggestedMaxFee: num.toBigInt('0x14a5d6744ed9'), -}; +} as EstimateFee; export const estimateFeeResp2 = { overall_fee: num.toBigInt('0x0dc3e44d89e6'), suggestedMaxFee: num.toBigInt('0x14a5d6744ed9'), -}; +} as EstimateFee; export const unfoundUserAddress = '0x018dfa1955a0154524203f81c5668d6a78c708375ee8908dcb55a49c6ec87190'; export const unfoundUserPrivateKey = '0x610d87a5c02459f8643f9ad6a9bc70597d1a8a0ab4d645346b7eadc5266ad4d'; @@ -654,7 +652,7 @@ export const getTxnFromSequencerResp1 = { ], transaction_hash: '0x1366c2f9f46b1a86ba0c28b5a08fa0aa3750c4d1cbe06e97e72bd46ae2ac1f9', version: '0x0', -}; +} as unknown as GetTransactionResponse; export const getTxnFromSequencerResp2 = { status: 'ACCEPTED_ON_L1', @@ -680,7 +678,7 @@ export const getTxnFromSequencerResp2 = { contract_address: '0x5a98ec74a40383cf99896bfea2ec5e6aad16c7eed50025a5f569d585ebb13a2', transaction_hash: '0x6beceb86579dc78749bdaaf441501edc21e218e020236e2ebea1b6a96d0bac7', version: '0x0', -}; +} as unknown as GetTransactionResponse; export const expectedMassagedTxn4: Transaction = { chainId: '0x534e5f474f45524c49', diff --git a/packages/starknet-snap/test/src/estimateFee.test.ts b/packages/starknet-snap/test/src/estimateFee.test.ts index b6443ac3..54387cd1 100644 --- a/packages/starknet-snap/test/src/estimateFee.test.ts +++ b/packages/starknet-snap/test/src/estimateFee.test.ts @@ -1,107 +1,136 @@ import chai, { expect } from 'chai'; import sinon from 'sinon'; import sinonChai from 'sinon-chai'; +import { constants } from 'starknet'; +import { Mutex } from 'async-mutex'; + import { WalletMock } from '../wallet.mock.test'; +import { account2, estimateDeployFeeResp4, estimateFeeResp, getBip44EntropyStub } from '../constants.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 { PRICE_UNIT, STARKNET_TESTNET_NETWORK } from '../../src/utils/constants'; import { getAddressKeyDeriver } from '../../src/utils/keyPair'; -import { - account2, - estimateDeployFeeResp4, - estimateFeeResp, - estimateFeeResp2, - getBip44EntropyStub, - getBalanceResp, -} from '../constants.test'; -import { Mutex } from 'async-mutex'; import { ApiParams, EstimateFeeRequestParams } from '../../src/types/snapApi'; chai.use(sinonChai); const sandbox = sinon.createSandbox(); describe('Test function: estimateFee', function () { - const walletStub = new WalletMock(); - - const state: SnapState = { - accContracts: [account2], - erc20Tokens: [], - networks: [STARKNET_TESTNET_NETWORK], - transactions: [], - }; - const requestObject: EstimateFeeRequestParams = { - contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', - contractFuncName: 'balanceOf', - contractCallData: '0x7426b2da7a8978e0d472d64f15f984d658226cb55a4fd8aa7689688a7eab37b', - senderAddress: account2.address, - }; - const apiParams: ApiParams = { - state, - requestParams: requestObject, - wallet: walletStub, - saveMutex: new Mutex(), + const setupMock = async () => { + const walletStub = new WalletMock(); + walletStub.reset(); + walletStub.rpcStubs.snap_getBip44Entropy.callsFake(getBip44EntropyStub); + const getSignerSpy = sandbox.stub(utils, 'getSigner'); + const estimateFeeSpy = sandbox.stub(utils, 'estimateFeeBulk'); + return { + walletStub, + getSignerSpy, + estimateFeeSpy, + }; }; - beforeEach(async function () { - walletStub.rpcStubs.snap_getBip44Entropy.callsFake(getBip44EntropyStub); - apiParams.keyDeriver = await getAddressKeyDeriver(walletStub); - sandbox.stub(utils, 'callContract').resolves(getBalanceResp); - }); + const setupRequestParams = async (walletStub: WalletMock, requestObject?: EstimateFeeRequestParams) => { + const state: SnapState = { + accContracts: [account2], + erc20Tokens: [], + networks: [STARKNET_TESTNET_NETWORK], + transactions: [], + }; + + if (!requestObject) { + requestObject = { + contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', + contractFuncName: 'balanceOf', + contractCallData: '0x7426b2da7a8978e0d472d64f15f984d658226cb55a4fd8aa7689688a7eab37b', + senderAddress: account2.address, + priceUnit: PRICE_UNIT.WEI, + }; + } + const apiParams: ApiParams = { + state, + requestParams: requestObject, + wallet: walletStub, + saveMutex: new Mutex(), + keyDeriver: await getAddressKeyDeriver(walletStub), + }; + + return { + apiParams, + }; + }; afterEach(function () { - walletStub.reset(); sandbox.restore(); }); - it('should estimate the fee correctly', async function () { - sandbox.stub(utils, 'getSigner').callsFake(async () => { - return account2.publicKey; - }); - sandbox.stub(utils, 'estimateFee').callsFake(async () => { - return estimateFeeResp; - }); - // The following will be commented out later when starknet.js - // supports estimateFeeBulk in rpc mode - // sandbox.stub(utils, 'estimateFeeBulk').callsFake(async () => { - // return [estimateFeeResp]; - // }); + it('estimates the fee with WEI correctly', async function () { + const { walletStub, getSignerSpy, estimateFeeSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub); + + getSignerSpy.resolves(account2.publicKey); + estimateFeeSpy.resolves([estimateFeeResp]); + const result = await estimateFee(apiParams); + + expect(estimateFeeSpy).to.have.been.calledWith( + sinon.match.any, + account2.address, + sinon.match.any, + sinon.match.any, + { version: constants.TRANSACTION_VERSION.V1 }, + ); expect(result.suggestedMaxFee).to.be.eq(estimateFeeResp.suggestedMaxFee.toString(10)); + expect(result.unit).to.be.eq(PRICE_UNIT.WEI.toLowerCase()); }); - it('should estimate the fee including deploy txn correctly', async function () { - sandbox.stub(utils, 'getSigner').throws(new Error()); - sandbox.stub(utils, 'estimateFeeBulk').callsFake(async () => { - return [estimateDeployFeeResp4, estimateFeeResp]; + it('estimates the fee with FRI correctly', async function () { + const { walletStub, getSignerSpy, estimateFeeSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub, { + contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', + contractFuncName: 'balanceOf', + contractCallData: '0x7426b2da7a8978e0d472d64f15f984d658226cb55a4fd8aa7689688a7eab37b', + senderAddress: account2.address, + priceUnit: PRICE_UNIT.FRI, }); - const expectedSuggestedMaxFee = estimateDeployFeeResp4.suggestedMaxFee + estimateFeeResp.suggestedMaxFee; + + getSignerSpy.resolves(account2.publicKey); + estimateFeeSpy.resolves([estimateFeeResp]); + const result = await estimateFee(apiParams); - expect(result.suggestedMaxFee).to.be.eq(expectedSuggestedMaxFee.toString(10)); + + expect(estimateFeeSpy).to.have.been.calledWith( + sinon.match.any, + account2.address, + sinon.match.any, + sinon.match.any, + { version: constants.TRANSACTION_VERSION.V3 }, + ); + expect(result.suggestedMaxFee).to.be.eq(estimateFeeResp.suggestedMaxFee.toString(10)); + expect(result.unit).to.be.eq(PRICE_UNIT.FRI.toLowerCase()); }); - it('should estimate the fee without gas consumed and gas price correctly', async function () { - sandbox.stub(utils, 'getSigner').callsFake(async () => { - return account2.publicKey; - }); - sandbox.stub(utils, 'estimateFee').callsFake(async () => { - return estimateFeeResp2; - }); - // The following will be commented out later when starknet.js - // supports estimateFeeBulk in rpc mode - // sandbox.stub(utils, 'estimateFeeBulk').callsFake(async () => { - // return [estimateFeeResp2]; - // }); + it('estimates the fee including deploy txn', async function () { + const { walletStub, getSignerSpy, estimateFeeSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub); + + getSignerSpy.rejects(new Error()); + estimateFeeSpy.resolves([estimateDeployFeeResp4, estimateFeeResp]); + const result = await estimateFee(apiParams); - expect(result.suggestedMaxFee).to.be.eq(estimateFeeResp.suggestedMaxFee.toString(10)); + + expect(result.suggestedMaxFee).to.be.eq( + (estimateDeployFeeResp4.suggestedMaxFee + estimateFeeResp.suggestedMaxFee).toString(), + ); }); - it('should throw error if estimateFee failed', async function () { - sandbox.stub(utils, 'getSigner').callsFake(async () => { - return account2.publicKey; - }); - sandbox.stub(utils, 'estimateFee').throws(new Error()); - apiParams.requestParams = requestObject; + it('throws an error if estimateFee failed', async function () { + const { walletStub, getSignerSpy, estimateFeeSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub); + + getSignerSpy.resolves(account2.publicKey); + estimateFeeSpy.rejects(new Error('some error')); let result; try { @@ -113,16 +142,17 @@ describe('Test function: estimateFee', function () { } }); - it('should throw an error if the function name is undefined', async function () { - sandbox.stub(utils, 'getSigner').callsFake(async () => { - return account2.publicKey; - }); - apiParams.requestParams = { + it('throws an error if the function name is undefined', async function () { + const { walletStub, getSignerSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub, { contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractFuncName: undefined, contractCallData: '0x7426b2da7a8978e0d472d64f15f984d658226cb55a4fd8aa7689688a7eab37b', senderAddress: account2.address, - }; + }); + + getSignerSpy.resolves(account2.publicKey); + let result; try { result = await estimateFee(apiParams); @@ -133,16 +163,17 @@ describe('Test function: estimateFee', function () { } }); - it('should throw an error if the contract address is invalid', async function () { - sandbox.stub(utils, 'getSigner').callsFake(async () => { - return account2.publicKey; - }); - apiParams.requestParams = { + it('throws an error if the contract address is invalid', async function () { + const { walletStub, getSignerSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub, { contractAddress: 'wrongAddress', contractFuncName: 'balanceOf', contractCallData: '0x7426b2da7a8978e0d472d64f15f984d658226cb55a4fd8aa7689688a7eab37b', senderAddress: account2.address, - }; + }); + + getSignerSpy.resolves(account2.publicKey); + let result; try { result = await estimateFee(apiParams); @@ -153,16 +184,17 @@ describe('Test function: estimateFee', function () { } }); - it('should throw an error if the sender address is invalid', async function () { - sandbox.stub(utils, 'getSigner').callsFake(async () => { - return account2.publicKey; - }); - apiParams.requestParams = { + it('throws an error if the sender address is invalid', async function () { + const { walletStub, getSignerSpy } = await setupMock(); + const { apiParams } = await setupRequestParams(walletStub, { contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', contractFuncName: 'balanceOf', contractCallData: '0x7426b2da7a8978e0d472d64f15f984d658226cb55a4fd8aa7689688a7eab37b', senderAddress: 'wrongAddress', - }; + }); + + getSignerSpy.resolves(account2.publicKey); + let result; try { result = await estimateFee(apiParams); diff --git a/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts b/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts index ef75e4e0..841977bd 100644 --- a/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts +++ b/packages/starknet-snap/test/src/getErc20TokenBalance.test.ts @@ -34,7 +34,7 @@ describe('Test function: getErc20TokenBalance', function () { it('should get the ERC-20 token balance correctly', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['0x64a'] }; //1610 in decimal + return ['0x64a']; //1610 in decimal }); const requestObject: GetErc20TokenBalanceRequestParams = { tokenAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', @@ -65,7 +65,7 @@ describe('Test function: getErc20TokenBalance', function () { it('should throw error if userAddress is empty', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['0x64a'] }; //1610 in decimal + return ['0x64a']; //1610 in decimal }); const requestObject: GetErc20TokenBalanceRequestParams = { tokenAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', @@ -85,7 +85,7 @@ describe('Test function: getErc20TokenBalance', function () { it('should throw error if tokenAddress is empty', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['0x64a'] }; //1610 in decimal + return ['0x64a']; //1610 in decimal }); const requestObject: GetErc20TokenBalanceRequestParams = { tokenAddress: '', @@ -105,7 +105,7 @@ describe('Test function: getErc20TokenBalance', function () { it('should throw error if userAddress is invalid', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['0x64a'] }; //1610 in decimal + return ['0x64a']; //1610 in decimal }); const requestObject: GetErc20TokenBalanceRequestParams = { tokenAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', @@ -125,7 +125,7 @@ describe('Test function: getErc20TokenBalance', function () { it('should throw error if tokenAddress is invalid', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['0x64a'] }; //1610 in decimal + return ['0x64a']; //1610 in decimal }); const requestObject: GetErc20TokenBalanceRequestParams = { tokenAddress: 'wrongAddress', diff --git a/packages/starknet-snap/test/src/getValue.test.ts b/packages/starknet-snap/test/src/getValue.test.ts index bc55a7d4..a46001e2 100644 --- a/packages/starknet-snap/test/src/getValue.test.ts +++ b/packages/starknet-snap/test/src/getValue.test.ts @@ -34,7 +34,7 @@ describe('Test function: getValue', function () { it('should call the contract correctly', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['1'] }; + return ['1']; }); const requestObject: GetValueRequestParams = { contractAddress: '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10', diff --git a/packages/starknet-snap/test/src/signDeclareTransaction.test.ts b/packages/starknet-snap/test/src/signDeclareTransaction.test.ts index 8dc2986b..24686331 100644 --- a/packages/starknet-snap/test/src/signDeclareTransaction.test.ts +++ b/packages/starknet-snap/test/src/signDeclareTransaction.test.ts @@ -13,7 +13,7 @@ import { createAccountProxyTxn, getBip44EntropyStub, account1, signature3 } from import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; import { ApiParams, SignDeclareTransactionRequestParams } from '../../src/types/snapApi'; -import { constants } from 'starknet'; +import { DeclareSignerDetails, constants } from 'starknet'; import * as utils from '../../src/utils/starknetUtils'; chai.use(sinonChai); @@ -35,17 +35,19 @@ describe('Test function: signDeclareTransaction', function () { saveMutex: new Mutex(), }; + const declarePayload = { + classHash: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', + senderAddress: account1.address, + chainId: constants.StarknetChainId.SN_MAIN, + nonce: '0x1', + version: '0x0', + maxFee: 100, + } as unknown as DeclareSignerDetails; + const requestObject: SignDeclareTransactionRequestParams = { chainId: STARKNET_MAINNET_NETWORK.chainId, signerAddress: account1.address, - transaction: { - classHash: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', - senderAddress: account1.address, - chainId: constants.StarknetChainId.SN_MAIN, - nonce: '0x1', - version: '0x0', - maxFee: 100, - }, + transaction: declarePayload, enableAutherize: true, }; diff --git a/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts b/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts index ee9fc7fa..e7b5302a 100644 --- a/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts +++ b/packages/starknet-snap/test/src/signDeployAccountTransaction.test.ts @@ -13,7 +13,7 @@ import { createAccountProxyTxn, getBip44EntropyStub, account1, signature3 } from import { getAddressKeyDeriver } from '../../src/utils/keyPair'; import { Mutex } from 'async-mutex'; import { ApiParams, SignDeployAccountTransactionRequestParams } from '../../src/types/snapApi'; -import { constants } from 'starknet'; +import { DeployAccountSignerDetails, constants } from 'starknet'; import * as utils from '../../src/utils/starknetUtils'; chai.use(sinonChai); @@ -35,19 +35,21 @@ describe('Test function: signDeployAccountTransaction', function () { saveMutex: new Mutex(), }; + const declareNDeployPayload = { + classHash: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', + contractAddress: account1.address, + constructorCalldata: [], + addressSalt: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', + chainId: constants.StarknetChainId.SN_MAIN, + nonce: '0x1', + version: '0x0', + maxFee: 100, + } as unknown as DeployAccountSignerDetails; + const requestObject: SignDeployAccountTransactionRequestParams = { chainId: STARKNET_MAINNET_NETWORK.chainId, signerAddress: account1.address, - transaction: { - classHash: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', - contractAddress: account1.address, - constructorCalldata: [], - addressSalt: '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', - chainId: constants.StarknetChainId.SN_MAIN, - nonce: '0x1', - version: '0x0', - maxFee: 100, - }, + transaction: declareNDeployPayload, enableAutherize: true, }; diff --git a/packages/starknet-snap/test/utils/starknetUtils.test.ts b/packages/starknet-snap/test/utils/starknetUtils.test.ts index e4a70e1a..204e8956 100644 --- a/packages/starknet-snap/test/utils/starknetUtils.test.ts +++ b/packages/starknet-snap/test/utils/starknetUtils.test.ts @@ -29,7 +29,7 @@ describe('Test function: callContract', function () { it('should get the signer of an user account correctly', async function () { sandbox.stub(utils, 'callContract').callsFake(async () => { - return { result: ['0x795d62a9896b221af17bedd8cceb8d963ac6864857d7476e2f8c03ba0c5df9'] }; + return ['0x795d62a9896b221af17bedd8cceb8d963ac6864857d7476e2f8c03ba0c5df9']; }); const result = await utils.getSigner(userAddress, STARKNET_TESTNET_NETWORK); diff --git a/yarn.lock b/yarn.lock index b34a2a25..e2511ab5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3155,15 +3155,16 @@ __metadata: "@consensys/starknet-snap@file:../starknet-snap::locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui": version: 2.5.2 - resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=180251&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui" + resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=c9e0f9&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui" dependencies: "@metamask/snaps-sdk": 3.0.1 async-mutex: ^0.3.2 + dotenv: ^16.4.5 ethereum-unit-converter: ^0.0.17 ethers: ^5.5.1 - starknet: ^5.14.0 + starknet: 6.6.6 starknet_v4.22.0: "npm:starknet@4.22.0" - checksum: 983f842b9dba2bec7cfcd8907f9dd8d420befc61e045b7138f1786f1662ff6c4f3279b8db49193cf2ae39dff0b9173a5475d1b072f918fda72d54d9d05d4bfd5 + checksum: fa3dc727767684fad1788e3fec62d5b3b4e7ba2ac333360303cfceac46186f71cfb6b87d2fce866cda27f9b36e3977ff0405e73fa389d567d5ee38671a99377c languageName: node linkType: hard @@ -3187,7 +3188,7 @@ __metadata: chai-as-promised: ^7.1.1 concurrently: ^7.1.0 cross-env: ^7.0.3 - envify: ^4.1.0 + dotenv: ^16.4.5 eslint: ^8.13.0 ethereum-unit-converter: ^0.0.17 ethers: ^5.5.1 @@ -3198,7 +3199,7 @@ __metadata: sinon: ^13.0.2 sinon-chai: ^3.7.0 standard-version: ^9.5.0 - starknet: ^5.14.0 + starknet: 6.6.6 starknet_v4.22.0: "npm:starknet@4.22.0" ts-node: ^10.8.1 typescript: ^4.6.3 @@ -5481,15 +5482,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:~1.0.0": - version: 1.0.0 - resolution: "@noble/curves@npm:1.0.0" - dependencies: - "@noble/hashes": 1.3.0 - checksum: 6bcef44d626c640dc8961819d68dd67dffb907e3b973b7c27efe0ecdd9a5c6ce62c7b9e3dfc930c66605dced7f1ec0514d191c09a2ce98d6d52b66e3315ffa79 - languageName: node - linkType: hard - "@noble/ed25519@npm:^1.6.0": version: 1.7.3 resolution: "@noble/ed25519@npm:1.7.3" @@ -5504,14 +5496,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.0": - version: 1.3.0 - resolution: "@noble/hashes@npm:1.3.0" - checksum: d7ddb6d7c60f1ce1f87facbbef5b724cdea536fc9e7f59ae96e0fc9de96c8f1a2ae2bdedbce10f7dcc621338dfef8533daa73c873f2b5c87fa1a4e05a95c2e2e - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.3, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:~1.3.2": +"@noble/hashes@npm:1.3.3, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:~1.3.2, @noble/hashes@npm:~1.3.3": version: 1.3.3 resolution: "@noble/hashes@npm:1.3.3" checksum: 8a6496d1c0c64797339bc694ad06cdfaa0f9e56cd0c3f68ae3666cfb153a791a55deb0af9c653c7ed2db64d537aa3e3054629740d2f2338bb1dcb7ab60cd205b @@ -5525,13 +5510,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:~1.3.0": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 - languageName: node - linkType: hard - "@noble/secp256k1@npm:1.7.1, @noble/secp256k1@npm:^1.5.5, @noble/secp256k1@npm:^1.7.1, @noble/secp256k1@npm:~1.7.0": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" @@ -5786,6 +5764,13 @@ __metadata: languageName: node linkType: hard +"@scure/base@npm:~1.1.3": + version: 1.1.6 + resolution: "@scure/base@npm:1.1.6" + checksum: d6deaae91deba99e87939af9e55d80edba302674983f32bba57f942e22b1726a83c62dc50d8f4370a5d5d35a212dda167fb169f4b0d0c297488d8604608fc3d3 + languageName: node + linkType: hard + "@scure/bip32@npm:1.1.5": version: 1.1.5 resolution: "@scure/bip32@npm:1.1.5" @@ -5828,6 +5813,16 @@ __metadata: languageName: node linkType: hard +"@scure/starknet@npm:~1.0.0": + version: 1.0.0 + resolution: "@scure/starknet@npm:1.0.0" + dependencies: + "@noble/curves": ~1.3.0 + "@noble/hashes": ~1.3.3 + checksum: 2df4234ff7ae025b72c0e7eb5af81e35bb5790d72f9dc7746bd91183527081df3e637579616fa7717d4227abf67e11380cf266bea43144231325503f52644087 + languageName: node + linkType: hard + "@sinclair/typebox@npm:^0.24.1": version: 0.24.51 resolution: "@sinclair/typebox@npm:0.24.51" @@ -9029,6 +9024,20 @@ __metadata: languageName: node linkType: hard +"abi-wan-kanabi@npm:^2.2.1": + version: 2.2.1 + resolution: "abi-wan-kanabi@npm:2.2.1" + dependencies: + ansicolors: ^0.3.2 + cardinal: ^2.1.1 + fs-extra: ^10.0.0 + yargs: ^17.7.2 + bin: + generate: dist/generate.js + checksum: 1567dd8c962a735d79f546b463bbce063fe202f823112bc8713ac14213e814417cbdc25cdd95299889aae5664ed44febf843833924e754a992e705053084fda0 + languageName: node + linkType: hard + "abort-controller@npm:^3.0.0": version: 3.0.0 resolution: "abort-controller@npm:3.0.0" @@ -9397,6 +9406,13 @@ __metadata: languageName: node linkType: hard +"ansicolors@npm:^0.3.2, ansicolors@npm:~0.3.2": + version: 0.3.2 + resolution: "ansicolors@npm:0.3.2" + checksum: e84fae7ebc27ac96d9dbb57f35f078cd6dde1b7046b0f03f73dcefc9fbb1f2e82e3685d083466aded8faf038f9fa9ebb408d215282bcd7aaa301d5ac3c486815 + languageName: node + linkType: hard + "anymatch@npm:^2.0.0": version: 2.0.0 resolution: "anymatch@npm:2.0.0" @@ -11118,6 +11134,18 @@ __metadata: languageName: node linkType: hard +"cardinal@npm:^2.1.1": + version: 2.1.1 + resolution: "cardinal@npm:2.1.1" + dependencies: + ansicolors: ~0.3.2 + redeyed: ~2.1.0 + bin: + cdl: ./bin/cdl.js + checksum: e8d4ae46439cf8fed481c0efd267711ee91e199aa7821a9143e784ed94a6495accd01a0b36d84d377e8ee2cc9928a6c9c123b03be761c60b805f2c026b8a99ad + languageName: node + linkType: hard + "case-sensitive-paths-webpack-plugin@npm:^2.3.0, case-sensitive-paths-webpack-plugin@npm:^2.4.0": version: 2.4.0 resolution: "case-sensitive-paths-webpack-plugin@npm:2.4.0" @@ -13442,6 +13470,13 @@ __metadata: languageName: node linkType: hard +"dotenv@npm:^16.4.5": + version: 16.4.5 + resolution: "dotenv@npm:16.4.5" + checksum: 301a12c3d44fd49888b74eb9ccf9f07a1f5df43f489e7fcb89647a2edcd84c42d6bc349dc8df099cd18f07c35c7b04685c1a4f3e6a6a9e6b30f8d48c15b7f49c + languageName: node + linkType: hard + "dotenv@npm:^8.0.0": version: 8.6.0 resolution: "dotenv@npm:8.6.0" @@ -13660,18 +13695,6 @@ __metadata: languageName: node linkType: hard -"envify@npm:^4.1.0": - version: 4.1.0 - resolution: "envify@npm:4.1.0" - dependencies: - esprima: ^4.0.0 - through: ~2.3.4 - bin: - envify: bin/envify - checksum: ee48873a56a117b812fb5e4d50870bf4440f5ba3462db4f4677e041fbdf2d05c70d72baa59af5f584373ab54d751b6543087a9afd4313774e058f020486728b8 - languageName: node - linkType: hard - "err-code@npm:^2.0.2": version: 2.0.3 resolution: "err-code@npm:2.0.3" @@ -14189,7 +14212,7 @@ __metadata: languageName: node linkType: hard -"esprima@npm:^4.0.0, esprima@npm:^4.0.1": +"esprima@npm:^4.0.0, esprima@npm:^4.0.1, esprima@npm:~4.0.0": version: 4.0.1 resolution: "esprima@npm:4.0.1" bin: @@ -14750,6 +14773,16 @@ __metadata: languageName: node linkType: hard +"fetch-cookie@npm:^3.0.0": + version: 3.0.1 + resolution: "fetch-cookie@npm:3.0.1" + dependencies: + set-cookie-parser: ^2.4.8 + tough-cookie: ^4.0.0 + checksum: 01657ccdf6305c3bf9b2375a9aedd6930f803acc77583c02e96a0b3d84068cc9406d2ad4d061a8c4d9c106c021de51dd2aa505a0a05a4477a1a859052f2537a0 + languageName: node + linkType: hard + "fetch-retry@npm:^5.0.2": version: 5.0.4 resolution: "fetch-retry@npm:5.0.4" @@ -18887,10 +18920,10 @@ __metadata: languageName: node linkType: hard -"lossless-json@npm:^2.0.8": - version: 2.0.9 - resolution: "lossless-json@npm:2.0.9" - checksum: 26aebc8c697b6db20a85b8524a46f9d9b7f428cea1b2b504f833b67c162724d089179e5b0666d9b6a81cd92c8acd4c55ae4d66447e83f8883aafc0c51e5df797 +"lossless-json@npm:^4.0.1": + version: 4.0.1 + resolution: "lossless-json@npm:4.0.1" + checksum: 41e89f5b7800cf5f863776542c82d8a19a696e5537865699d5ee062726d069561f7b857e838195496f2a43afe64a7dce475be5a2565822881f39feb0eda5d218 languageName: node linkType: hard @@ -19298,16 +19331,6 @@ __metadata: languageName: node linkType: hard -"micro-starknet@npm:~0.2.1": - version: 0.2.3 - resolution: "micro-starknet@npm:0.2.3" - dependencies: - "@noble/curves": ~1.0.0 - "@noble/hashes": ~1.3.0 - checksum: f1ae152348d1ca0bd0b4d09cb7901aee5cb1e815dcbfb6c3a623d107c169fad00808e154e7ca8abf2b16639a83044bc602c66fc3e0eb0de89a5c81815ff9b2ef - languageName: node - linkType: hard - "microevent.ts@npm:~0.1.1": version: 0.1.1 resolution: "microevent.ts@npm:0.1.1" @@ -23051,6 +23074,15 @@ __metadata: languageName: node linkType: hard +"redeyed@npm:~2.1.0": + version: 2.1.1 + resolution: "redeyed@npm:2.1.1" + dependencies: + esprima: ~4.0.0 + checksum: 39a1426e377727cfb47a0e24e95c1cf78d969fbc388dc1e0fa1e2ef8a8756450cefb8b0c2598f63b85f1a331986fca7604c0db798427a5775a1dbdb9c1291979 + languageName: node + linkType: hard + "redux-persist@npm:^6.0.0": version: 6.0.0 resolution: "redux-persist@npm:6.0.0" @@ -24069,6 +24101,13 @@ __metadata: languageName: node linkType: hard +"set-cookie-parser@npm:^2.4.8": + version: 2.6.0 + resolution: "set-cookie-parser@npm:2.6.0" + checksum: bf11ebc594c53d84588f1b4c04f1b8ce14e0498b1c011b3d76b5c6d5aac481bbc3f7c5260ec4ce99bdc1d9aed19f9fc315e73166a36ca74d0f12349a73f6bdc9 + languageName: node + linkType: hard + "set-value@npm:^2.0.0, set-value@npm:^2.0.1": version: 2.0.1 resolution: "set-value@npm:2.0.1" @@ -24652,6 +24691,24 @@ __metadata: languageName: unknown linkType: soft +"starknet@npm:6.6.6": + version: 6.6.6 + resolution: "starknet@npm:6.6.6" + dependencies: + "@noble/curves": ~1.3.0 + "@scure/base": ~1.1.3 + "@scure/starknet": ~1.0.0 + abi-wan-kanabi: ^2.2.1 + fetch-cookie: ^3.0.0 + isomorphic-fetch: ^3.0.0 + lossless-json: ^4.0.1 + pako: ^2.0.4 + ts-mixer: ^6.0.3 + url-join: ^4.0.1 + checksum: b1a2ddab6f393be61c65bb5d426ddd631be6958f30671ba71aaeea237af1a1c5163941c9149e20f5701975855bccf0ab184f2a21ceee7ad5a4b974a46b7ffc1c + languageName: node + linkType: hard + "starknet@npm:^4.22.0, starknet_v4.22.0@npm:starknet@4.22.0": version: 4.22.0 resolution: "starknet@npm:4.22.0" @@ -24671,20 +24728,6 @@ __metadata: languageName: node linkType: hard -"starknet@npm:^5.14.0": - version: 5.16.0 - resolution: "starknet@npm:5.16.0" - dependencies: - "@noble/curves": ~1.0.0 - isomorphic-fetch: ^3.0.0 - lossless-json: ^2.0.8 - micro-starknet: ~0.2.1 - pako: ^2.0.4 - url-join: ^4.0.1 - checksum: 745e68d698aacb4836fb638a907b9844c566f0a3a169a80722eef73c7d0c48fe1a31a458f32ed248bc63587e4b3811067ae37e3e573d84bec1a205cd45e678db - languageName: node - linkType: hard - "state-toggle@npm:^1.0.0": version: 1.0.3 resolution: "state-toggle@npm:1.0.3" @@ -25640,7 +25683,7 @@ __metadata: languageName: node linkType: hard -"through@npm:2, through@npm:>=2.2.7 <3, through@npm:~2.3.4": +"through@npm:2, through@npm:>=2.2.7 <3": version: 2.3.8 resolution: "through@npm:2.3.8" checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd @@ -25862,6 +25905,13 @@ __metadata: languageName: node linkType: hard +"ts-mixer@npm:^6.0.3": + version: 6.0.4 + resolution: "ts-mixer@npm:6.0.4" + checksum: 36b1af526befd74345e736e9aa16f5c28876ebcea07784da14d929149fd7e6028cfd2fe9304c8efe8cb91b588443a9cc9e991df58e4c6e602326edbaae2af3ab + languageName: node + linkType: hard + "ts-node@npm:^10.8.1": version: 10.9.1 resolution: "ts-node@npm:10.9.1" @@ -27916,7 +27966,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.7.1": +"yargs@npm:^17.7.1, yargs@npm:^17.7.2": version: 17.7.2 resolution: "yargs@npm:17.7.2" dependencies: