From c8a38e5349e5c5ebe3bb0665a4fb18cd02811626 Mon Sep 17 00:00:00 2001 From: Toni Tabak Date: Wed, 14 Dec 2022 12:57:14 +0100 Subject: [PATCH] fix: nonce should be fixed for deploy account to 0 --- src/account/default.ts | 2 +- src/account/interface.ts | 2 +- src/provider/rpc.ts | 15 ++++----------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/account/default.ts b/src/account/default.ts index 2bc02b090..5d797309f 100644 --- a/src/account/default.ts +++ b/src/account/default.ts @@ -400,7 +400,7 @@ export class Account extends Provider implements AccountInterface { }: DeployAccountContractPayload, transactionsDetail: InvocationsDetails = {} ): Promise { - const nonce = toBN(transactionsDetail.nonce ?? (await this.getNonce())); + const nonce = '0x0'; const version = toBN(transactionVersion); const chainId = await this.getChainId(); diff --git a/src/account/interface.ts b/src/account/interface.ts index c5e46927c..3ba4bc6f4 100644 --- a/src/account/interface.ts +++ b/src/account/interface.ts @@ -236,7 +236,7 @@ export abstract class AccountInterface extends ProviderInterface { - optional address salt - optional contractAddress * @param transactionsDetail Invocation Details containing: - - optional nonce + - constant nonce = 0 - optional version - optional maxFee * @returns a confirmation of sending a transaction on the starknet contract diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts index a7a0e7926..faaeecb3f 100644 --- a/src/provider/rpc.ts +++ b/src/provider/rpc.ts @@ -84,22 +84,15 @@ export class RpcProvider implements ProviderInterface { } } - protected deviationHandler(method: string, { error, result }: any): any { - // for non-existing address Sequencer return '0x0' rpc return error. - if (method === 'starknet_getNonce' && error.code === 20) return '0x0'; - - this.errorHandler(error); - return result; - } - protected async fetchEndpoint( method: T, params?: RPC.Methods[T]['params'] ): Promise { try { - const rawResponse = await this.fetch(method, params); - const response = await rawResponse.json(); - return this.deviationHandler(method, response) as RPC.Methods[T]['result']; + const rawResult = await this.fetch(method, params); + const { error, result } = await rawResult.json(); + this.errorHandler(error); + return result as RPC.Methods[T]['result']; } catch (error: any) { this.errorHandler(error?.response?.data); throw error;