diff --git a/src/account/default.ts b/src/account/default.ts index af633b667..3798cc7fb 100644 --- a/src/account/default.ts +++ b/src/account/default.ts @@ -1,12 +1,10 @@ -import assert from 'minimalistic-assert'; - import { compileCalldata } from '../contract'; import { Provider } from '../provider'; import { Signer, SignerInterface } from '../signer'; import { Abi, AddTransactionResponse, - Invocation, + ExecuteInvocation, InvocationsDetails, KeyPair, Signature, @@ -44,7 +42,7 @@ export class Account extends Provider implements AccountInterface { * @returns a confirmation of invoking a function on the starknet contract */ public async execute( - transactions: Invocation | Invocation[], + transactions: ExecuteInvocation | ExecuteInvocation[], abis: Abi[] = [], transactionsDetail: InvocationsDetails = {} ): Promise { @@ -60,11 +58,6 @@ export class Account extends Provider implements AccountInterface { } = Array.isArray(transactions) ? transactions[0] : transactions; const { nonce } = transactionsDetail; - assert( - !invocation.signature, - "Adding signatures to an account transaction currently isn't supported" - ); - const nonceBn = toBN(nonce ?? (await this.getNonce())); const calldataDecimal = bigNumberishArrayToDecimalStringArray(calldata); @@ -83,18 +76,17 @@ export class Account extends Provider implements AccountInterface { const entrypointSelector = getSelectorFromName(entrypoint); - return super.fetchEndpoint('add_transaction', undefined, { - type: 'INVOKE_FUNCTION', - entry_point_selector: getSelectorFromName('execute'), - calldata: bigNumberishArrayToDecimalStringArray([ + return super.invokeFunction({ + contractAddress: this.address, + entrypoint: 'execute', + calldata: [ contractAddress, entrypointSelector, calldataDecimal.length.toString(), ...calldataDecimal, nonceBn.toString(), - ]), - contract_address: this.address, - signature: bigNumberishArrayToDecimalStringArray(signature), + ], + signature, }); } diff --git a/src/account/interface.ts b/src/account/interface.ts index 6da700e17..050a64c13 100644 --- a/src/account/interface.ts +++ b/src/account/interface.ts @@ -3,7 +3,7 @@ import { Abi, AddTransactionResponse, DeployContractPayload, - Invocation, + ExecuteInvocation, InvocationsDetails, Signature, } from '../types'; @@ -41,7 +41,7 @@ export abstract class AccountInterface extends ProviderInterface { * @returns response from addTransaction */ public abstract execute( - transactions: Invocation | Invocation[], + transactions: ExecuteInvocation | ExecuteInvocation[], abis?: Abi[], transactionsDetail?: InvocationsDetails ): Promise; diff --git a/src/provider/interface.ts b/src/provider/interface.ts index c6268a38e..54c3bd6a0 100644 --- a/src/provider/interface.ts +++ b/src/provider/interface.ts @@ -1,5 +1,4 @@ import type { - Abi, AddTransactionResponse, Call, CallContractResponse, @@ -120,13 +119,9 @@ export abstract class ProviderInterface { * - compiled contract code * - constructor calldata * - address salt - * @param abi the abi of the contract * @returns a confirmation of sending a transaction on the starknet contract */ - public abstract deployContract( - payload: DeployContractPayload, - abi?: Abi - ): Promise; + public abstract deployContract(payload: DeployContractPayload): Promise; /** * Invokes a function on starknet @@ -140,10 +135,7 @@ export abstract class ProviderInterface { * * @returns response from addTransaction */ - public abstract invokeFunction( - invocation: Invocation, - abi?: Abi - ): Promise; + public abstract invokeFunction(invocation: Invocation): Promise; public abstract waitForTx(txHash: BigNumberish, retryInterval?: number): Promise; } diff --git a/src/types/lib.ts b/src/types/lib.ts index e77af2b86..aa0daa341 100644 --- a/src/types/lib.ts +++ b/src/types/lib.ts @@ -19,6 +19,8 @@ export type Invocation = { signature?: Signature; }; +export type ExecuteInvocation = Omit; + export type InvocationsDetails = { nonce?: BigNumberish; };