diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 256ecf8b4..ec24c59d6 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -21,7 +21,7 @@ jobs: # TODO - periodically check if conditional services are supported; https://github.com/actions/runner/issues/822 services: devnet: - image: ${{ (inputs.use-devnet) && 'shardlabs/starknet-devnet-rs:0.0.4-seed0' || '' }} + image: ${{ (inputs.use-devnet) && 'shardlabs/starknet-devnet-rs:0.0.5-seed0' || '' }} ports: - 5050:5050 diff --git a/.github/workflows/manual-tests-testnet.yml b/.github/workflows/manual-tests-testnet.yml index 65d0c9d2f..234d61943 100644 --- a/.github/workflows/manual-tests-testnet.yml +++ b/.github/workflows/manual-tests-testnet.yml @@ -7,7 +7,7 @@ jobs: strategy: max-parallel: 1 matrix: - name: [rpc-goerli] + name: [rpc-sepolia] uses: ./.github/workflows/_test.yml secrets: diff --git a/.github/workflows/pr-push-main.yml b/.github/workflows/pr-push-main.yml index ba64e23a6..d39d245ea 100644 --- a/.github/workflows/pr-push-main.yml +++ b/.github/workflows/pr-push-main.yml @@ -40,7 +40,7 @@ jobs: strategy: max-parallel: 1 matrix: - name: [rpc-goerli] + name: [rpc-sepolia] uses: ./.github/workflows/_test.yml secrets: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f915e625..63f20a94f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,8 +44,8 @@ By default the tests are executed in your local Devnet and everything should run If you want to use a specific RPC node, you have to set some global variables before executing the tests: ```bash -export TEST_RPC_URL=http://192.168.1.44:9545/rpc/v0.5 # example of a Pathfinder node located in your local network -export TEST_RPC_URL=https://starknet-testnet.public.blastapi.io/rpc/v0.5 # example of a public testnet node +export TEST_RPC_URL=http://192.168.1.44:9545/rpc/v0_7 # example of a Pathfinder node located in your local network +export TEST_RPC_URL=https://starknet-sepolia.public.blastapi.io/rpc/v0_7 # example of a public Sepolia testnet node export TEST_ACCOUNT_ADDRESS=0x065A822f0000000000000000000000000c26641 export TEST_ACCOUNT_PRIVATE_KEY=0x02a80000000000000000000000001754438a ``` diff --git a/__mocks__/cairo/helloCairo2/hellocairo b/__mocks__/cairo/helloCairo2/hello.cairo similarity index 100% rename from __mocks__/cairo/helloCairo2/hellocairo rename to __mocks__/cairo/helloCairo2/hello.cairo diff --git a/__tests__/account.starknetId.test.ts b/__tests__/account.starknetId.test.ts index 15f17fd85..2529c6199 100644 --- a/__tests__/account.starknetId.test.ts +++ b/__tests__/account.starknetId.test.ts @@ -24,46 +24,34 @@ describe('deploy and test Wallet', () => { beforeAll(async () => { // Deploy Starknet id contract - const idResponse = await account.declareAndDeploy( - { - contract: compiledStarknetId, - casm: compiledStarknetIdCasm, - constructorCalldata: [account.address, 0], - }, - { maxFee: 1e18 } - ); + const idResponse = await account.declareAndDeploy({ + contract: compiledStarknetId, + casm: compiledStarknetIdCasm, + constructorCalldata: [account.address, 0], + }); identityAddress = idResponse.deploy.contract_address; // Deploy pricing contract - const pricingResponse = await account.declareAndDeploy( - { - contract: compiledPricing, - casm: compiledPricingCasm, - constructorCalldata: [devnetERC20Address], - }, - { maxFee: 1e18 } - ); + const pricingResponse = await account.declareAndDeploy({ + contract: compiledPricing, + casm: compiledPricingCasm, + constructorCalldata: [devnetERC20Address], + }); const pricingAddress = pricingResponse.deploy.contract_address; // Deploy naming contract - const namingResponse = await account.declareAndDeploy( - { - contract: compiledNaming, - casm: compiledNamingCasm, - constructorCalldata: [identityAddress, pricingAddress, 0, account.address], - }, - { maxFee: 1e18 } - ); + const namingResponse = await account.declareAndDeploy({ + contract: compiledNaming, + casm: compiledNamingCasm, + constructorCalldata: [identityAddress, pricingAddress, 0, account.address], + }); namingAddress = namingResponse.deploy.contract_address; // Deploy multicall contract - const multicallResponse = await account.declareAndDeploy( - { - contract: compiledSidMulticall, - casm: compiledSidMulticallCasm, - }, - { maxFee: 1e18 } - ); + const multicallResponse = await account.declareAndDeploy({ + contract: compiledSidMulticall, + casm: compiledSidMulticallCasm, + }); multicallAddress = multicallResponse.deploy.contract_address; const { transaction_hash } = await account.execute( @@ -97,8 +85,7 @@ describe('deploy and test Wallet', () => { calldata: ['1'], }, ], - undefined, - { maxFee: 1e18 } + undefined ); await provider.waitForTransaction(transaction_hash); @@ -130,8 +117,7 @@ describe('deploy and test Wallet', () => { ], }, ], - undefined, - { maxFee: 1e18 } + undefined ); await provider.waitForTransaction(transaction_hash_verifier); }); diff --git a/__tests__/account.test.ts b/__tests__/account.test.ts index 8ad3849c0..399ac13b0 100644 --- a/__tests__/account.test.ts +++ b/__tests__/account.test.ts @@ -375,8 +375,12 @@ describe('deploy and test Wallet', () => { }; const details = { maxFee: 0n }; - await expect(account.execute(transaction, details)).rejects.toThrow(/zero/); - await expect(account.execute(transaction, undefined, details)).rejects.toThrow(/zero/); + await expect(account.execute(transaction, details)).rejects.toThrow( + /zero|Transaction must commit to pay a positive amount on fee./ + ); + await expect(account.execute(transaction, undefined, details)).rejects.toThrow( + /zero|Transaction must commit to pay a positive amount on fee./ + ); }); test('execute with custom nonce', async () => { @@ -415,28 +419,44 @@ describe('deploy and test Wallet', () => { expect(toBigInt(response.number as string).toString()).toStrictEqual('57'); }); - test('sign and verify EIP712 message fail', async () => { - const signature = await account.signMessage(typedDataExample); - const [r, s] = stark.formatSignature(signature); + describeIfDevnet('EIP712 verification', () => { + // currently only in Devnet-rs, because can fail in Sepolia. + // to test in all cases once PR#989 implemented. + test('sign and verify EIP712 message fail', async () => { + const signature = await account.signMessage(typedDataExample); + const [r, s] = stark.formatSignature(signature); - // change the signature to make it invalid - const r2 = toBigInt(r) + 123n; + // change the signature to make it invalid + const r2 = toBigInt(r) + 123n; - const signature2 = new Signature(toBigInt(r2.toString()), toBigInt(s)); + const signature2 = new Signature(toBigInt(r2.toString()), toBigInt(s)); - if (!signature2) return; + if (!signature2) return; - const verifMessageResponse: boolean = await account.verifyMessage(typedDataExample, signature2); - expect(verifMessageResponse).toBe(false); + const verifMessageResponse: boolean = await account.verifyMessage( + typedDataExample, + signature2 + ); + expect(verifMessageResponse).toBe(false); - const wrongAccount = new Account(provider, '0x037891', '0x026789', undefined, TEST_TX_VERSION); // non existing account - await expect(wrongAccount.verifyMessage(typedDataExample, signature2)).rejects.toThrow(); - }); + const wrongAccount = new Account( + provider, + '0x037891', + '0x026789', + undefined, + TEST_TX_VERSION + ); // non existing account + await expect(wrongAccount.verifyMessage(typedDataExample, signature2)).rejects.toThrow(); + }); - test('sign and verify message', async () => { - const signature = await account.signMessage(typedDataExample); - const verifMessageResponse: boolean = await account.verifyMessage(typedDataExample, signature); - expect(verifMessageResponse).toBe(true); + test('sign and verify message', async () => { + const signature = await account.signMessage(typedDataExample); + const verifMessageResponse: boolean = await account.verifyMessage( + typedDataExample, + signature + ); + expect(verifMessageResponse).toBe(true); + }); }); describe('Contract interaction with Account', () => { diff --git a/__tests__/cairo1.test.ts b/__tests__/cairo1.test.ts index 87680558a..20f636226 100644 --- a/__tests__/cairo1.test.ts +++ b/__tests__/cairo1.test.ts @@ -1,4 +1,3 @@ -import type { Abi } from 'abi-wan-kanabi'; import { type BigNumberish, type Calldata, @@ -26,7 +25,6 @@ import { compiledHelloSierra, compiledHelloSierraCasm, describeIfDevnet, - describeIfTestnet, getTestAccount, getTestProvider, } from './config/fixtures'; @@ -549,65 +547,3 @@ describeIfDevnet('Cairo 1 Devnet', () => { }); }); }); - -describeIfTestnet('Testnet', () => { - describe('TS validation for testnet', () => { - const provider = getTestProvider(); - const account = getTestAccount(provider); - const classHash: any = '0x022332bb9c1e22ae13ae7fd9f3101eced4644533c6bfe51a25cf8dea028e5045'; - const contractAddress: any = - '0x00305ef61e86F4566b8726d8867EF252d4f37F4B6418Cad4288052738ee22A5d'; - let cairo1Contract: Contract; - initializeMatcher(expect); - - beforeAll(async () => { - const cairoClass = await provider.getClassByHash(classHash); - // TODO: Fix typing and responses for abi - cairo1Contract = new Contract(cairoClass.abi as Abi, contractAddress, account); - }); - - test('GetClassByHash', async () => { - const classResponse = await provider.getClassByHash(classHash); - expect(classResponse).toMatchSchemaRef('SierraContractClass'); - }); - - test('GetClassAt', async () => { - const classResponse = await provider.getClassAt(contractAddress); - expect(classResponse).toMatchSchemaRef('SierraContractClass'); - }); - - test('Cairo 1 Contract Interaction - felt252', async () => { - const result = await cairo1Contract.test_felt252(100); - expect(result).toBe(101n); - }); - - test('Cairo 1 Contract Interaction - uint 8, 16, 32, 64, 128', async () => { - let result = await cairo1Contract.test_u8(100n); - expect(result).toBe(107n); - result = await cairo1Contract.test_u16(100n); - expect(result).toBe(106n); - result = await cairo1Contract.test_u32(100n); - expect(result).toBe(104n); - result = await cairo1Contract.test_u64(255n); - expect(result).toBe(258n); - result = await cairo1Contract.test_u128(255n); - expect(result).toBe(257n); - }); - - test('Cairo 1 - uint256 struct', async () => { - const myUint256 = uint256(2n ** 256n - 2n); - const result = await cairo1Contract.test_u256(myUint256); - expect(result).toBe(2n ** 256n - 1n); - }); - - test('Cairo 1 - uint256 by a bignumber', async () => { - const result = await cairo1Contract.test_u256(2n ** 256n - 2n); - expect(result).toBe(2n ** 256n - 1n); - }); - - test('Cairo 1 Contract Interaction - bool', async () => { - const tx = await cairo1Contract.test_bool(true); - expect(tx).toBe(true); - }); - }); -}); diff --git a/__tests__/cairo1v2.test.ts b/__tests__/cairo1v2.test.ts index a83685d0c..a246d4cd6 100644 --- a/__tests__/cairo1v2.test.ts +++ b/__tests__/cairo1v2.test.ts @@ -1174,7 +1174,7 @@ describe('Cairo 1', () => { describe('Cairo2.6.0 Sierra1.5.0', () => { test('declare Sierra 1.5.0', async () => { - const declare260Response = await account.declare({ + const declare260Response = await account.declareIfNot({ contract: compiledC260, casm: compiledC260Casm, }); diff --git a/__tests__/config/fixtures.ts b/__tests__/config/fixtures.ts index bb8132383..8314031b9 100644 --- a/__tests__/config/fixtures.ts +++ b/__tests__/config/fixtures.ts @@ -10,6 +10,7 @@ import { } from '../../src/types'; import { ETransactionVersion } from '../../src/types/api'; import { toHex } from '../../src/utils/num'; +import { wait } from '../../src/utils/provider'; const readContract = (name: string): LegacyCompiledContract => json.parse( @@ -108,11 +109,28 @@ export const createBlockForDevnet = async (): Promise => { await fetch(new URL('/create_block', process.env.TEST_RPC_URL), { method: 'POST' }); }; +export async function waitNextBlock(provider: RpcProvider, delay: number) { + const initBlock = await provider.getBlockNumber(); + createBlockForDevnet(); + let isNewBlock: boolean = false; + while (!isNewBlock) { + // eslint-disable-next-line no-await-in-loop + const currentBlock = await provider.getBlockNumber(); + if (currentBlock !== initBlock) { + isNewBlock = true; + } else { + // eslint-disable-next-line no-await-in-loop + await wait(delay); + } + } +} + const describeIf = (condition: boolean) => (condition ? describe : describe.skip); export const describeIfRpc = describeIf(process.env.IS_RPC === 'true'); export const describeIfNotDevnet = describeIf(process.env.IS_DEVNET === 'false'); export const describeIfDevnet = describeIf(process.env.IS_DEVNET === 'true'); export const describeIfTestnet = describeIf(process.env.IS_TESTNET === 'true'); - export const erc20ClassHash = '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a'; export const wrongClassHash = '0x000000000000000000000000000000000000000000000000000000000000000'; +export const devnetETHtokenAddress = + '0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7'; diff --git a/__tests__/config/helpers/strategyResolver.ts b/__tests__/config/helpers/strategyResolver.ts index c30155cb3..d729a130e 100644 --- a/__tests__/config/helpers/strategyResolver.ts +++ b/__tests__/config/helpers/strategyResolver.ts @@ -2,7 +2,7 @@ import accountResolver from './accountResolver'; import { GS_DEFAULT_TEST_PROVIDER_URL, LOCAL_DEVNET_NOT_RUNNING_MESSAGE } from '../constants'; import { setIfNullish } from './env'; -import { BaseUrl } from '../../../src/constants'; +import { RpcProvider } from '../../../src'; class StrategyResolver { private isDevnet = false; @@ -14,7 +14,12 @@ class StrategyResolver { } get isTestnet() { - return process.env.TEST_RPC_URL?.includes(BaseUrl.SN_SEPOLIA); + const provider = new RpcProvider({ nodeUrl: process.env.TEST_RPC_URL }); + const isTestnetSepolia = provider + .getTransactionByHash('0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819') // one random existing Sepolia transaction hash + .then(() => true) + .catch(() => false); + return isTestnetSepolia; } get hasAllAccountEnvs() { @@ -47,7 +52,7 @@ class StrategyResolver { setIfNullish('IS_DEVNET', this.isRpcDevnet); } - resolveRpc(): void { + async resolveRpc(): Promise { const hasRpcUrl = !!process.env.TEST_RPC_URL; this.isRpcNode = hasRpcUrl || this.isDevnet; @@ -57,7 +62,7 @@ class StrategyResolver { } setIfNullish('IS_RPC', this.isRpcNode); - setIfNullish('IS_TESTNET', this.isTestnet); + setIfNullish('IS_TESTNET', await this.isTestnet); console.log('Detected RPC'); } @@ -94,10 +99,10 @@ class StrategyResolver { } } - private useProvidedSetup(): void { + private async useProvidedSetup(): Promise { setIfNullish('IS_DEVNET', false); setIfNullish('IS_RPC', !!process.env.TEST_RPC_URL); - setIfNullish('IS_TESTNET', this.isTestnet); + setIfNullish('IS_TESTNET', await this.isTestnet); this.logConfigInfo(); @@ -110,7 +115,7 @@ class StrategyResolver { this.verifyAccountData(); if (this.hasAllAccountEnvs) { - this.useProvidedSetup(); + await this.useProvidedSetup(); return; } @@ -118,7 +123,7 @@ class StrategyResolver { console.log('Basic test parameters are missing, Auto Setup Started'); await this.detectDevnet(); - this.resolveRpc(); + await this.resolveRpc(); await accountResolver.execute(this.isDevnet); this.verifyAccountData(true); diff --git a/__tests__/rpcProvider.test.ts b/__tests__/rpcProvider.test.ts index 6aa109f3d..18d4f421e 100644 --- a/__tests__/rpcProvider.test.ts +++ b/__tests__/rpcProvider.test.ts @@ -11,6 +11,7 @@ import { ReceiptTx, RpcProvider, TransactionExecutionStatus, + cairo, stark, waitForTransactionOptions, } from '../src'; @@ -29,6 +30,8 @@ import { describeIfDevnet, getTestAccount, getTestProvider, + waitNextBlock, + devnetETHtokenAddress, } from './config/fixtures'; import { initializeMatcher } from './config/schema'; @@ -115,20 +118,15 @@ describeIfRpc('RPCProvider', () => { estimateSpy.mockRestore(); }); - describe('Test Estimate message fee', () => { + describeIfDevnet('Test Estimate message fee Cairo 0', () => { + // declaration of Cairo 0 contract is no more authorized in Sepolia Testnet let l1l2ContractCairo0Address: string; - let l1l2ContractCairo1Address: string; beforeAll(async () => { const { deploy } = await account.declareAndDeploy({ contract: compiledL1L2, }); l1l2ContractCairo0Address = deploy.contract_address; - const { deploy: deploy2 } = await account.declareAndDeploy({ - contract: compiledC1v2, - casm: compiledC1v2Casm, - }); - l1l2ContractCairo1Address = deploy2.contract_address; }); test('estimate message fee Cairo 0', async () => { @@ -147,6 +145,19 @@ describeIfRpc('RPCProvider', () => { }) ); }); + }); + + describe('Test Estimate message fee Cairo 1', () => { + let l1l2ContractCairo1Address: string; + + beforeAll(async () => { + const { deploy: deploy2 } = await account.declareAndDeploy({ + contract: compiledC1v2, + casm: compiledC1v2Casm, + }); + l1l2ContractCairo1Address = deploy2.contract_address; + await waitNextBlock(provider as RpcProvider, 5000); // in Sepolia Testnet, needs pending block validation before interacting + }); test('estimate message fee Cairo 1', async () => { const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165'; // not coded in 20 bytes @@ -230,6 +241,16 @@ describeIfRpc('RPCProvider', () => { let latestBlock: Block; beforeAll(async () => { + // add a Tx to be sure to have at least one Tx in the last block + const { transaction_hash } = await account.execute({ + contractAddress: devnetETHtokenAddress, + entrypoint: 'transfer', + calldata: { + recipient: account.address, + amount: cairo.uint256(1n * 10n ** 4n), + }, + }); + await account.waitForTransaction(transaction_hash); latestBlock = await provider.getBlock('latest'); }); @@ -408,3 +429,37 @@ describeIfRpc('RPCProvider', () => { }); }); }); + +describeIfNotDevnet('waitForBlock', () => { + // As Devnet-rs isn't generating automatically blocks at a periodic time, it's excluded of this test. + const providerStandard = new RpcProvider({ nodeUrl: process.env.TEST_RPC_URL }); + const providerFastTimeOut = new RpcProvider({ nodeUrl: process.env.TEST_RPC_URL, retries: 1 }); + let block: number; + beforeEach(async () => { + block = await providerStandard.getBlockNumber(); + }); + + test('waitForBlock timeOut', async () => { + await expect(providerFastTimeOut.waitForBlock(10 ** 20, 1)).rejects.toThrow(/timed-out/); + }); + + test('waitForBlock in the past', async () => { + const start = new Date().getTime(); + await providerStandard.waitForBlock(block); + const end = new Date().getTime(); + expect(end - start).toBeLessThan(1000); // quick answer expected + }); + + test('waitForBlock latest', async () => { + const start = new Date().getTime(); + await providerStandard.waitForBlock('latest'); + const end = new Date().getTime(); + expect(end - start).toBeLessThan(100); // nearly immediate answer expected + }); + + // NOTA : this test can have a duration up to block interval. + test('waitForBlock pending', async () => { + await providerStandard.waitForBlock('pending'); + expect(true).toBe(true); // answer without timeout Error (blocks have to be spaced with 16 minutes maximum : 200 retries * 5000ms) + }); +}); diff --git a/__tests__/utils/ellipticalCurve.test.ts b/__tests__/utils/ellipticalCurve.test.ts index 92cb348a0..034ea6439 100644 --- a/__tests__/utils/ellipticalCurve.test.ts +++ b/__tests__/utils/ellipticalCurve.test.ts @@ -53,21 +53,21 @@ test('hashMessage()', () => { BigInt(constants.TRANSACTION_VERSION.V1), calldata, maxFee, - StarknetChainId.SN_GOERLI, + StarknetChainId.SN_SEPOLIA, nonce ); expect(hashMsg).toMatchInlineSnapshot( - `"0x6d1706bd3d1ba7c517be2a2a335996f63d4738e2f182144d078a1dd9997062e"` + `"0xa006ce6da518722c1af8bdb1d8a42cee638102c670bb1a55f063bff10506d4"` ); const { r, s } = ec.starkCurve.sign(hashMsg, privateKey); expect(r.toString()).toMatchInlineSnapshot( - `"1427981024487605678086498726488552139932400435436186597196374630267616399345"` + `"384207128292005766686294801921397180350977625816434242436096267488258549139"` ); expect(s.toString()).toMatchInlineSnapshot( - `"1853664302719670721837677288395394946745467311923401353018029119631574115563"` + `"2521602681140573534692734854765316415611209530542226558354401890884906162365"` ); }); diff --git a/__tests__/utils/ethSigner.test.ts b/__tests__/utils/ethSigner.test.ts index a4b39652d..37d4a684d 100644 --- a/__tests__/utils/ethSigner.test.ts +++ b/__tests__/utils/ethSigner.test.ts @@ -9,9 +9,11 @@ import { cairo, encode, eth, + extractContractHashes, hash, num, stark, + type DeclareContractPayload, } from '../../src'; import { validateAndParseEthAddress } from '../../src/utils/eth'; import { ETransactionVersion } from '../../src/types/api'; @@ -25,6 +27,8 @@ import { compiledEthCasm, compiledEthPubk, compiledEthPubkCasm, + describeIfDevnet, + devnetETHtokenAddress, getTestAccount, getTestProvider, } from '../config/fixtures'; @@ -93,11 +97,10 @@ describe('Ethereum signer', () => { }); }); - describe('ETH account tx V2', () => { + describeIfDevnet('ETH account tx V2', () => { + // devnet only because estimateFee in Sepolia v0.13.1 are producing widely different numbers. const provider = new Provider(getTestProvider()); const account = getTestAccount(provider); - const devnetETHtokenAddress = - '0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7'; let ethAccount: Account; beforeAll(async () => { const { transaction_hash: declTH, class_hash: decClassHash } = await account.declareIfNot({ @@ -107,7 +110,7 @@ describe('Ethereum signer', () => { if (declTH) { await provider.waitForTransaction(declTH); } - const privateKeyETH = '0x45397ee6ca34cb49060f1c303c6cb7ee2d6123e617601ef3e31ccf7bf5bef1f9'; + const privateKeyETH = eth.ethRandomPrivateKey(); const ethSigner = new EthSigner(privateKeyETH); const ethFullPublicKey = await ethSigner.getPubKey(); const pubKeyETHx = cairo.uint256( @@ -125,28 +128,28 @@ describe('Ethereum signer', () => { 0 ); + ethAccount = new Account(provider, contractETHAccountAddress, ethSigner); + const deployPayload = { + classHash: decClassHash, + constructorCalldata: accountETHconstructorCalldata, + addressSalt: salt, + }; + const { suggestedMaxFee: feeDeploy } = + await ethAccount.estimateAccountDeployFee(deployPayload); // fund account with ETH const { transaction_hash } = await account.execute({ contractAddress: devnetETHtokenAddress, entrypoint: 'transfer', calldata: { recipient: contractETHAccountAddress, - amount: cairo.uint256(5 * 10 ** 17), + amount: cairo.uint256(3n * 10n ** 16n), }, }); await account.waitForTransaction(transaction_hash); - ethAccount = new Account(provider, contractETHAccountAddress, ethSigner); - const deployPayload = { - classHash: decClassHash, - constructorCalldata: accountETHconstructorCalldata, - addressSalt: salt, - }; - const { suggestedMaxFee: feeDeploy } = - await ethAccount.estimateAccountDeployFee(deployPayload); const { transaction_hash: txH2, contract_address } = await ethAccount.deployAccount( deployPayload, - { maxFee: stark.estimatedFeeToMaxFee(feeDeploy, 100) } + { maxFee: stark.estimatedFeeToMaxFee(feeDeploy, 300) } ); await provider.waitForTransaction(txH2); expect(contract_address).toBe(contractETHAccountAddress); @@ -156,11 +159,10 @@ describe('Ethereum signer', () => { const ethContract2 = new Contract(compiledErc20.abi, devnetETHtokenAddress, ethAccount); const respTransfer = await ethContract2.transfer( account.address, - cairo.uint256(2 * 10 ** 16), + cairo.uint256(1 * 10 ** 4), { maxFee: 1 * 10 ** 16 } ); const txR = await provider.waitForTransaction(respTransfer.transaction_hash); - if (txR.isSuccess()) { expect(txR.execution_status).toBe('SUCCEEDED'); } else { @@ -185,7 +187,8 @@ describe('Ethereum signer', () => { }); }); - describe('ETH account tx V3', () => { + describeIfDevnet('ETH account tx V3', () => { + // devnet only because estimateFee in Sepolia v0.13.1 are producing widely different numbers. const provider = new Provider(getTestProvider()); const account = getTestAccount(provider); const devnetSTRKtokenAddress = @@ -199,7 +202,7 @@ describe('Ethereum signer', () => { if (declTH) { await provider.waitForTransaction(declTH); } - const privateKeyETH = '0x525bc68475c0955fae83869beec0996114d4bb27b28b781ed2a20ef23121b8de'; + const privateKeyETH = eth.ethRandomPrivateKey(); const ethSigner = new EthSigner(privateKeyETH); const ethFullPublicKey = await ethSigner.getPubKey(); const pubKeyETHx = cairo.uint256( @@ -218,17 +221,6 @@ describe('Ethereum signer', () => { 0 ); - // fund account with STRK - const { transaction_hash } = await account.execute({ - contractAddress: devnetSTRKtokenAddress, - entrypoint: 'transfer', - calldata: { - recipient: contractETHAccountAddress, - amount: cairo.uint256(5 * 10 ** 17), - }, - }); - await account.waitForTransaction(transaction_hash); - ethAccount = new Account( provider, contractETHAccountAddress, @@ -241,6 +233,16 @@ describe('Ethereum signer', () => { addressSalt: salt, constructorCalldata: accountETHconstructorCalldata, }); + // fund account with STRK + const { transaction_hash } = await account.execute({ + contractAddress: devnetSTRKtokenAddress, + entrypoint: 'transfer', + calldata: { + recipient: contractETHAccountAddress, + amount: cairo.uint256(30n * 10n ** 16n), // 0.3 STRK + }, + }); + await account.waitForTransaction(transaction_hash); const { transaction_hash: txH2, contract_address } = await ethAccount.deployAccount( { classHash: decClassHash, @@ -253,7 +255,7 @@ describe('Ethereum signer', () => { l1_gas: { max_amount: num.toHex(BigInt(feeEstimation.resourceBounds.l1_gas.max_amount) * 2n), max_price_per_unit: num.toHex( - BigInt(feeEstimation.resourceBounds.l1_gas.max_price_per_unit) * 2n + BigInt(feeEstimation.resourceBounds.l1_gas.max_price_per_unit) ), }, }, @@ -264,22 +266,18 @@ describe('Ethereum signer', () => { }); test('ETH account transaction V3', async () => { - const ethContract2 = new Contract(compiledErc20.abi, devnetSTRKtokenAddress, ethAccount); - const txCallData = ethContract2.populate('transfer', [ + const strkContract2 = new Contract(compiledErc20.abi, devnetSTRKtokenAddress, ethAccount); + const txCallData = strkContract2.populate('transfer', [ account.address, - cairo.uint256(1 * 10 ** 15), + cairo.uint256(1 * 10 ** 4), ]); const feeTransfer = await ethAccount.estimateInvokeFee(txCallData); const respTransfer = await ethAccount.execute(txCallData, undefined, { resourceBounds: { l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' }, l1_gas: { - max_amount: num.toHex( - stark.estimatedFeeToMaxFee(feeTransfer.resourceBounds.l1_gas.max_amount, 150) - ), - max_price_per_unit: num.toHex( - stark.estimatedFeeToMaxFee(feeTransfer.resourceBounds.l1_gas.max_price_per_unit, 150) - ), + max_amount: num.toHex(BigInt(feeTransfer.resourceBounds.l1_gas.max_amount) * 3n), + max_price_per_unit: num.toHex(feeTransfer.resourceBounds.l1_gas.max_price_per_unit), }, }, }); @@ -295,30 +293,48 @@ describe('Ethereum signer', () => { test('ETH account declaration V3', async () => { const accountTestSierra = compiledDummy2Eth; const accountTestCasm = compiledDummy2EthCasm; - const feeDeclare = await ethAccount.estimateDeclareFee({ + const payload: DeclareContractPayload = { contract: accountTestSierra, casm: accountTestCasm, - }); - const { transaction_hash: declTH2, class_hash: decClassHash2 } = - await ethAccount.declareIfNot( - { contract: accountTestSierra, casm: accountTestCasm }, + }; + const declareContractPayload = extractContractHashes(payload); + try { + await provider.getClassByHash(declareContractPayload.classHash); + expect(true).toBeTruthy(); // test skipped if class already declared + } catch { + const feeDeclare = await ethAccount.estimateDeclareFee(payload); + const { transaction_hash: declTH2, class_hash: decClassHash2 } = await ethAccount.declare( + payload, { resourceBounds: { l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' }, l1_gas: { max_amount: num.toHex(BigInt(feeDeclare.resourceBounds.l1_gas.max_amount) * 2n), max_price_per_unit: num.toHex( - BigInt(feeDeclare.resourceBounds.l1_gas.max_price_per_unit) * 2n + BigInt(feeDeclare.resourceBounds.l1_gas.max_price_per_unit) ), }, }, } ); - if (declTH2) { await provider.waitForTransaction(declTH2); + expect(decClassHash2).toBe( + '0x5d574bd1467f1ca5178c118be7cdb3e74718c37bae90ab686a9b8536ca24436' + ); } - expect(decClassHash2).toBe( - '0x5d574bd1467f1ca5178c118be7cdb3e74718c37bae90ab686a9b8536ca24436' + }); + }); + describe('Ethereum address', () => { + test('Eth address format', async () => { + const ethAddr = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165'; // not a valid 20 bytes ETh address + expect(validateAndParseEthAddress(ethAddr)).toBe( + '0x008359e4b0152ed5a731162d3c7b0d8d56edb165' + ); + expect(validateAndParseEthAddress(BigInt(ethAddr))).toBe( + '0x008359e4b0152ed5a731162d3c7b0d8d56edb165' + ); + expect(validateAndParseEthAddress(BigInt(ethAddr).toString(10))).toBe( + '0x008359e4b0152ed5a731162d3c7b0d8d56edb165' ); }); }); diff --git a/__tests__/utils/starknetId.test.ts b/__tests__/utils/starknetId.test.ts index bdd080620..43e8727cd 100644 --- a/__tests__/utils/starknetId.test.ts +++ b/__tests__/utils/starknetId.test.ts @@ -40,8 +40,8 @@ describe('Should tets StarknetId utils', () => { }); test('Should test getStarknetIdContract', () => { - expect(getStarknetIdContract(StarknetChainId.SN_GOERLI)).toBe( - '0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce' + expect(getStarknetIdContract(StarknetChainId.SN_SEPOLIA)).toBe( + '0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7' ); expect(getStarknetIdContract(StarknetChainId.SN_MAIN)).toBe( diff --git a/__tests__/utils/transactionHash.test.ts b/__tests__/utils/transactionHash.test.ts index 9d2cd5c99..52add1758 100644 --- a/__tests__/utils/transactionHash.test.ts +++ b/__tests__/utils/transactionHash.test.ts @@ -11,9 +11,9 @@ describe('TxV2 Hash Tests', () => { '0x64', [], '0x0', - constants.StarknetChainId.SN_GOERLI + constants.StarknetChainId.SN_SEPOLIA ); - expect(result).toBe('0x7d260744de9d8c55e7675a34512d1951a7b262c79e685d26599edd2948de959'); + expect(result).toBe('0x63ba2bc7f3a3912597e221d5fad8eb0783e0684a428b47fa4737faf66f46dfb'); }); }); }); @@ -93,7 +93,7 @@ describe('TxV3 Hash Tests', () => { '0x276faadb842bfcbba834f3af948386a2eb694f7006e118ad6c80305791d3247', '0x613816405e6334ab420e53d4b38a0451cb2ebca2755171315958c87d303cf6', ], - constants.StarknetChainId.SN_GOERLI, + constants.StarknetChainId.SN_SEPOLIA, '0x8a9', [], 0, @@ -106,7 +106,7 @@ describe('TxV3 Hash Tests', () => { [] ); - expect(result).toBe('0x41906f1c314cca5f43170ea75d3b1904196a10101190d2b12a41cc61cfd17c'); + expect(result).toBe('0x6d0e3ff991d62a10189a0ea11685d26b7efdb5baa9fa0d0a4edd1711185f671'); }); test('calculateDeployAccountTransactionHash Demo', () => { @@ -138,7 +138,7 @@ describe('TxV3 Hash Tests', () => { ['0x5cd65f3d7daea6c63939d659b8473ea0c5cd81576035a4d34e52fb06840196c'], '0x0', '0x3', - constants.StarknetChainId.SN_GOERLI, + constants.StarknetChainId.SN_SEPOLIA, '0x0', types.RPC.EDAMode.L1, types.RPC.EDAMode.L1, @@ -150,7 +150,7 @@ describe('TxV3 Hash Tests', () => { [] ); - expect(result).toBe('0x29fd7881f14380842414cdfdd8d6c0b1f2174f8916edcfeb1ede1eb26ac3ef0'); + expect(result).toBe('0x3018236df5779c1f28caba0e64febcb78f5bc69aa3538be54f4e27def9de1b3'); }); test('calculateDeclareTransactionHash Demo', () => { @@ -181,7 +181,7 @@ describe('TxV3 Hash Tests', () => { '0x1add56d64bebf8140f3b8a38bdf102b7874437f0c861ab4ca7526ec33b4d0f8', '0x2fab82e4aef1d8664874e1f194951856d48463c3e6bf9a8c68e234a629a6f50', '0x3', - constants.StarknetChainId.SN_GOERLI, + constants.StarknetChainId.SN_SEPOLIA, '0x1', [], types.RPC.EDAMode.L1, @@ -194,6 +194,6 @@ describe('TxV3 Hash Tests', () => { [] ); - expect(result).toBe('0x41d1f5206ef58a443e7d3d1ca073171ec25fa75313394318fc83a074a6631c3'); + expect(result).toBe('0x61bfaf480ac824971ad1bdc316fa821f58afd6b47e037242ef265d0aaea7c78'); }); }); diff --git a/package-lock.json b/package-lock.json index d09dd21f6..fafabd76c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@scure/starknet": "~1.0.0", "abi-wan-kanabi": "^2.2.2", "fetch-cookie": "^3.0.0", + "get-starknet-core": "^4.0.0-next.3", "isomorphic-fetch": "^3.0.0", "lossless-json": "^4.0.1", "pako": "^2.0.4", @@ -9053,6 +9054,11 @@ "node": ">=8.0.0" } }, + "node_modules/get-starknet-core": { + "version": "4.0.0-next.3", + "resolved": "https://registry.npmjs.org/get-starknet-core/-/get-starknet-core-4.0.0-next.3.tgz", + "integrity": "sha512-/9q0UpsshYHZyEMcd+XD7CVrnwQ50WfXhy0TNocyHQzn+/qxQIBn25ZYJ+DEzwLPoUtrajMYI4L6DMKu1CJ+ig==" + }, "node_modules/get-stream": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-7.0.1.tgz", diff --git a/package.json b/package.json index 0c67828f1..6ddac578c 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,7 @@ "@scure/starknet": "~1.0.0", "abi-wan-kanabi": "^2.2.2", "fetch-cookie": "^3.0.0", + "get-starknet-core": "^4.0.0-next.3", "isomorphic-fetch": "^3.0.0", "lossless-json": "^4.0.1", "pako": "^2.0.4", diff --git a/src/constants.ts b/src/constants.ts index a13e0c925..0b2d9ef85 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -30,19 +30,16 @@ export const RANGE_U128 = range(ZERO, 2n ** 128n - 1n); export enum BaseUrl { SN_MAIN = 'https://alpha-mainnet.starknet.io', - SN_GOERLI = 'https://alpha4.starknet.io', SN_SEPOLIA = 'https://alpha-sepolia.starknet.io', } export enum NetworkName { SN_MAIN = 'SN_MAIN', - SN_GOERLI = 'SN_GOERLI', SN_SEPOLIA = 'SN_SEPOLIA', } export enum StarknetChainId { SN_MAIN = '0x534e5f4d41494e', // encodeShortString('SN_MAIN'), - SN_GOERLI = '0x534e5f474f45524c49', // encodeShortString('SN_GOERLI') SN_SEPOLIA = '0x534e5f5345504f4c4941', // encodeShortString('SN_SEPOLIA') } @@ -68,10 +65,6 @@ export const UDC = { export const RPC_DEFAULT_VERSION = 'v0_7'; export const RPC_NODES = { - SN_GOERLI: [ - `https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`, - `https://free-rpc.nethermind.io/goerli-juno/${RPC_DEFAULT_VERSION}`, - ], SN_MAIN: [ `https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`, `https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`, diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts index 66ee958e9..27427ab24 100644 --- a/src/provider/rpc.ts +++ b/src/provider/rpc.ts @@ -30,6 +30,8 @@ import { getAbiContractVersion } from '../utils/calldata/cairo'; import { isSierra } from '../utils/contract'; import { RPCResponseParser } from '../utils/responseParser/rpc'; import { GetTransactionReceiptResponse, ReceiptTx } from '../utils/transactionReceipt'; +import { wait } from '../utils/provider'; +import { toHex } from '../utils/num'; import { LibraryError } from './errors'; import { ProviderInterface } from './interface'; @@ -101,6 +103,47 @@ export class RpcProvider implements ProviderInterface { return this.channel.getBlockWithTxs(blockIdentifier); } + /** + * Pause the execution of the script until a specified block is created. + * @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'. + * Use of 'latest" or of a block already created will generate no pause. + * @param {number} [retryInterval] number of milliseconds between 2 requests to the node + * @example + * ```typescript + * await myProvider.waitForBlock(); + * // wait the creation of the pending block + * ``` + */ + public async waitForBlock( + blockIdentifier: BlockIdentifier = 'pending', + retryInterval: number = 5000 + ) { + if (blockIdentifier === BlockTag.latest) return; + const currentBlock = await this.getBlockNumber(); + const targetBlock = + blockIdentifier === BlockTag.pending + ? currentBlock + 1 + : Number(toHex(blockIdentifier as BigNumberish)); + if (targetBlock <= currentBlock) return; + const { retries } = this.channel; + let retriesCount = retries; + let isTargetBlock: boolean = false; + while (!isTargetBlock) { + // eslint-disable-next-line no-await-in-loop + const currBlock = await this.getBlockNumber(); + if (currBlock === targetBlock) { + isTargetBlock = true; + } else { + // eslint-disable-next-line no-await-in-loop + await wait(retryInterval); + } + retriesCount -= 1; + if (retriesCount <= 0) { + throw new Error(`waitForBlock() timed-out after ${retries} tries.`); + } + } + } + public async getL1GasPrice(blockIdentifier?: BlockIdentifier) { return this.channel .getBlockWithTxHashes(blockIdentifier) diff --git a/src/utils/num.ts b/src/utils/num.ts index 544cb3bab..5ada05f38 100644 --- a/src/utils/num.ts +++ b/src/utils/num.ts @@ -10,6 +10,17 @@ export type { BigNumberish }; /** * Test if string is hex-string * @param hex hex-string + * @returns {boolean} True if the input string is a hexadecimal string, false otherwise + * @example + * ```typescript + * const hexString1 = "0x2fd23d9182193775423497fc0c472e156c57c69e4089a1967fb288a2d84e914"; + * const result1 = isHex(hexString1); + * // result1 = true + * + * const hexString2 = "2fd23d9182193775423497fc0c472e156c57c69e4089a1967fb288a2d84e914"; + * const result2 = isHex(hexString2); + * // result2 = false + * ``` */ export function isHex(hex: string): boolean { return /^0x[0-9a-f]*$/i.test(hex); @@ -77,6 +88,20 @@ export const cleanHex = (hex: string) => hex.toLowerCase().replace(/^(0x)0+/, '$ * Asserts input is equal to or greater then lowerBound and lower then upperBound. * * The `inputName` parameter is used in the assertion message. + * @param input Value to check + * @param lowerBound Lower bound value + * @param upperBound Upper bound value + * @param inputName Name of the input for error message + * @Throws Error if input is out of range + * @example + * ```typescript + * const input1:BigNumberish = 10; + * assertInRange(input1, 5, 20, 'value') + * + * const input2: BigNumberish = 25; + * assertInRange(input2, 5, 20, 'value'); + * // Throws Error: Message not signable, invalid value length. + * ``` */ export function assertInRange( input: BigNumberish, @@ -119,6 +144,14 @@ export const isStringWholeNumber = (value: string) => /^\d+$/.test(value); /** * Convert string to decimal string * @returns format: decimal string + * @example + * ```typescript + * const result = getDecimalString("0x1a"); + * // result = "26" + * + * const result2 = getDecimalString("Hello"); + * // Throws Error: "Hello need to be hex-string or whole-number-string" + * ``` */ export function getDecimalString(value: string) { if (isHex(value)) { @@ -133,6 +166,14 @@ export function getDecimalString(value: string) { /** * Convert string to hexadecimal string * @returns format: hex-string + * @example + * ```typescript + * const result = getHexString("123"); + * // result = "0x7b" + * + * const result2 = getHexString("Hello"); + * // Throws Error: Hello need to be hex-string or whole-number-string + * ``` */ export function getHexString(value: string) { if (isHex(value)) { @@ -154,6 +195,16 @@ export function getHexStringArray(value: Array) { /** * Convert boolean to "0" or "1" + * @param value The boolean value to be converted. + * @returns {boolean} Returns true if the value is a number, otherwise returns false. + * @example + * ```typescript + * const result = toCairoBool(true); + * // result ="1" + * + * const result2 = toCairoBool(false); + * // result2 = "0" + * ``` */ export const toCairoBool = (value: boolean): string => (+value).toString(); @@ -186,6 +237,15 @@ export function addPercent(number: BigNumberish, percent: number) { * Check if a value is a number. * * @param {unknown} value - The value to check. + * @returns {boolean} Returns true if the value is a number, otherwise returns false. + * @example + * ```typescript + * const result = isNumber(123); + * // result = true + * + * const result2 = isNumber("123"); + * // result2 = false + * ``` * @return {boolean} Returns true if the value is a number, otherwise returns false. */ export function isNumber(value: unknown): value is number { @@ -196,6 +256,15 @@ export function isNumber(value: unknown): value is number { * Checks if a given value is of boolean type. * * @param {unknown} value - The value to check. + * @returns {boolean} - True if the value is of boolean type, false otherwise. + * @example + * ```typescript + * const result = isBoolean(true); + * // result = true + * + * const result2 = isBoolean(false); + * // result2 = false + * ``` * @return {boolean} - True if the value is of boolean type, false otherwise. */ export function isBoolean(value: unknown): value is boolean { diff --git a/src/utils/selector.ts b/src/utils/selector.ts index 1a137a62b..43ed3a515 100644 --- a/src/utils/selector.ts +++ b/src/utils/selector.ts @@ -63,6 +63,17 @@ export function getSelectorFromName(funcName: string) { * * @param value hex-string | dec-string | ascii-string * @returns format: hex-string + * @example + * ```typescript + * const selector: string = getSelector("myFunction"); + * // selector = "0x7e44bafo" + * + * const selector1: string = getSelector("0x123abc"); + * // selector1 = "0x123abc" + * + * const selector2: string = getSelector("123456"); + * // selector2 = "0x1e240" + * ``` */ export function getSelector(value: string) { if (isHex(value)) { diff --git a/src/utils/starknetId.ts b/src/utils/starknetId.ts index ad643b486..f9ed7376c 100644 --- a/src/utils/starknetId.ts +++ b/src/utils/starknetId.ts @@ -116,7 +116,6 @@ export function useEncoded(decoded: string): bigint { export const enum StarknetIdContract { MAINNET = '0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678', - TESTNET = '0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce', TESTNET_SEPOLIA = '0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7', } @@ -132,9 +131,6 @@ export function getStarknetIdContract(chainId: StarknetChainId): string { case StarknetChainId.SN_MAIN: return StarknetIdContract.MAINNET; - case StarknetChainId.SN_GOERLI: - return StarknetIdContract.TESTNET; - case StarknetChainId.SN_SEPOLIA: return StarknetIdContract.TESTNET_SEPOLIA; @@ -145,7 +141,6 @@ export function getStarknetIdContract(chainId: StarknetChainId): string { export const enum StarknetIdIdentityContract { MAINNET = '0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af', - TESTNET = '0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d', TESTNET_SEPOLIA = '0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90', } @@ -163,9 +158,6 @@ export function getStarknetIdIdentityContract(chainId: StarknetChainId): string case StarknetChainId.SN_MAIN: return StarknetIdIdentityContract.MAINNET; - case StarknetChainId.SN_GOERLI: - return StarknetIdIdentityContract.TESTNET; - case StarknetChainId.SN_SEPOLIA: return StarknetIdIdentityContract.TESTNET_SEPOLIA; @@ -189,9 +181,6 @@ export function getStarknetIdMulticallContract(chainId: StarknetChainId): string case StarknetChainId.SN_MAIN: return StarknetIdMulticallContract; - case StarknetChainId.SN_GOERLI: - return StarknetIdMulticallContract; - case StarknetChainId.SN_SEPOLIA: return StarknetIdMulticallContract; @@ -202,7 +191,6 @@ export function getStarknetIdMulticallContract(chainId: StarknetChainId): string export const enum StarknetIdVerifierContract { MAINNET = '0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf', - TESTNET = '0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11', TESTNET_SEPOLIA = '0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184', } @@ -218,9 +206,6 @@ export function getStarknetIdVerifierContract(chainId: StarknetChainId): string case StarknetChainId.SN_MAIN: return StarknetIdVerifierContract.MAINNET; - case StarknetChainId.SN_GOERLI: - return StarknetIdVerifierContract.TESTNET; - case StarknetChainId.SN_SEPOLIA: return StarknetIdVerifierContract.TESTNET_SEPOLIA; @@ -231,7 +216,6 @@ export function getStarknetIdVerifierContract(chainId: StarknetChainId): string export const enum StarknetIdPfpContract { MAINNET = '0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7', - TESTNET = '0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698', TESTNET_SEPOLIA = '0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2', } @@ -247,9 +231,6 @@ export function getStarknetIdPfpContract(chainId: StarknetChainId): string { case StarknetChainId.SN_MAIN: return StarknetIdPfpContract.MAINNET; - case StarknetChainId.SN_GOERLI: - return StarknetIdPfpContract.TESTNET; - case StarknetChainId.SN_SEPOLIA: return StarknetIdPfpContract.TESTNET_SEPOLIA; @@ -262,7 +243,6 @@ export function getStarknetIdPfpContract(chainId: StarknetChainId): string { export const enum StarknetIdPopContract { MAINNET = '0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4', - TESTNET = '0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106', TESTNET_SEPOLIA = '0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49', } @@ -278,9 +258,6 @@ export function getStarknetIdPopContract(chainId: StarknetChainId): string { case StarknetChainId.SN_MAIN: return StarknetIdPopContract.MAINNET; - case StarknetChainId.SN_GOERLI: - return StarknetIdPopContract.TESTNET; - case StarknetChainId.SN_SEPOLIA: return StarknetIdPopContract.TESTNET_SEPOLIA;