diff --git a/src/account/default.ts b/src/account/default.ts index 425b98385..4284d297b 100644 --- a/src/account/default.ts +++ b/src/account/default.ts @@ -23,7 +23,6 @@ import { EstimateFee, EstimateFeeAction, EstimateFeeBulk, - EstimateFeeDetails, EstimateFeeResponse, Invocation, Invocations, @@ -38,6 +37,7 @@ import { TransactionType, TypedData, UniversalDeployerContractPayload, + UniversalDetails, } from '../types'; import { ETransactionVersion, ETransactionVersion3, ResourceBounds } from '../types/api'; import { CallData } from '../utils/calldata'; @@ -127,14 +127,14 @@ export class Account extends Provider implements AccountInterface { public async estimateFee( calls: AllowArray, - estimateFeeDetails: EstimateFeeDetails = {} + estimateFeeDetails: UniversalDetails = {} ): Promise { return this.estimateInvokeFee(calls, estimateFeeDetails); } public async estimateInvokeFee( calls: AllowArray, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const { nonce: providedNonce, blockIdentifier, version: providedVersion } = details; @@ -172,31 +172,28 @@ export class Account extends Provider implements AccountInterface { } public async estimateDeclareFee( - { contract, classHash: providedClassHash, casm, compiledClassHash }: DeclareContractPayload, - details: EstimateFeeDetails = {} + payload: DeclareContractPayload, + details: UniversalDetails = {} ): Promise { const { blockIdentifier, nonce: providedNonce, version: providedVersion } = details; const nonce = toBigInt(providedNonce ?? (await this.getNonce())); const version = toTransactionVersion( - !isSierra(contract) + !isSierra(payload.contract) ? ETransactionVersion.F1 : this.getPreferredVersion(ETransactionVersion.F2, ETransactionVersion.F3), toFeeVersion(providedVersion) ); const chainId = await this.getChainId(); - const declareContractTransaction = await this.buildDeclarePayload( - { classHash: providedClassHash, contract, casm, compiledClassHash }, - { - ...v3Details(details), - nonce, - chainId, - version, - walletAddress: this.address, - maxFee: ZERO, - cairoVersion: undefined, // unused parameter - } - ); + const declareContractTransaction = await this.buildDeclarePayload(payload, { + ...v3Details(details), + nonce, + chainId, + version, + walletAddress: this.address, + maxFee: ZERO, + cairoVersion: undefined, // unused parameter + }); const estimateFeeResponse = await super.getDeclareEstimateFee( declareContractTransaction, @@ -217,9 +214,9 @@ export class Account extends Provider implements AccountInterface { classHash, addressSalt = 0, constructorCalldata = [], - contractAddress: providedContractAddress, + contractAddress, }: DeployAccountContractPayload, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const { blockIdentifier, version: providedVersion } = details; const version = toTransactionVersion( @@ -230,7 +227,7 @@ export class Account extends Provider implements AccountInterface { const chainId = await this.getChainId(); const payload = await this.buildAccountDeployPayload( - { classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress }, + { classHash, addressSalt, constructorCalldata, contractAddress }, { ...v3Details(details), nonce, @@ -258,15 +255,15 @@ export class Account extends Provider implements AccountInterface { public async estimateDeployFee( payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], - transactionsDetail: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const calls = this.buildUDCContractPayload(payload); - return this.estimateInvokeFee(calls, transactionsDetail); + return this.estimateInvokeFee(calls, details); } public async estimateFeeBulk( invocations: Invocations, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const { nonce, blockIdentifier } = details; const accountInvocations = await this.accountInvocationsFactory(invocations, { @@ -293,25 +290,35 @@ export class Account extends Provider implements AccountInterface { }); } - public async buildInvocation( - call: Array, - details: InvocationsSignerDetails - ): Promise { - const calldata = getExecuteCalldata(call, await this.getCairoVersion()); - const signature = await this.signer.signTransaction(call, details); - - return { + public async simulateTransaction( + invocations: Invocations, + details: SimulateTransactionDetails = {} + ): Promise { + const { nonce, blockIdentifier, skipValidate, skipExecute, version } = details; + const accountInvocations = await this.accountInvocationsFactory(invocations, { ...v3Details(details), - contractAddress: this.address, - calldata, - signature, - }; + versions: [ + ETransactionVersion.V1, // non-sierra + toTransactionVersion( + this.getPreferredVersion(ETransactionVersion.V2, ETransactionVersion.V3), + version + ), + ], + nonce, + blockIdentifier, + }); + + return super.getSimulateTransaction(accountInvocations, { + blockIdentifier, + skipValidate, + skipExecute, + }); } public async execute( calls: AllowArray, abis: Abi[] | undefined = undefined, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const transactions = Array.isArray(calls) ? calls : [calls]; const nonce = toBigInt(details.nonce ?? (await this.getNonce())); @@ -366,7 +373,7 @@ export class Account extends Provider implements AccountInterface { */ public async declareIfNot( payload: DeclareContractPayload, - transactionsDetail: EstimateFeeDetails = {} + transactionsDetail: UniversalDetails = {} ): Promise { const declareContractPayload = extractContractHashes(payload); try { @@ -382,7 +389,7 @@ export class Account extends Provider implements AccountInterface { public async declare( payload: DeclareContractPayload, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const declareContractPayload = extractContractHashes(payload); const { nonce, version: providedVersion } = details; @@ -426,7 +433,7 @@ export class Account extends Provider implements AccountInterface { public async deploy( payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const params = [].concat(payload as []).map((it) => { const { @@ -472,7 +479,7 @@ export class Account extends Provider implements AccountInterface { public async deployContract( payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const deployTx = await this.deploy(payload, details); const txReceipt = await this.waitForTransaction(deployTx.transaction_hash); @@ -481,7 +488,7 @@ export class Account extends Provider implements AccountInterface { public async declareAndDeploy( payload: DeclareAndDeployContractPayload, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const { constructorCalldata, salt, unique } = payload; let declare = await this.declareIfNot(payload, details); @@ -505,7 +512,7 @@ export class Account extends Provider implements AccountInterface { addressSalt = 0, contractAddress: providedContractAddress, }: DeployAccountContractPayload, - details: EstimateFeeDetails = {} + details: UniversalDetails = {} ): Promise { const version = toTransactionVersion( this.getPreferredVersion(ETransactionVersion.V1, ETransactionVersion.V3), @@ -558,29 +565,6 @@ export class Account extends Provider implements AccountInterface { ); } - private async getUniversalSuggestedFee( - version: ETransactionVersion, - { type, payload }: EstimateFeeAction, - details: EstimateFeeDetails - ) { - let maxFee: BigNumberish = 0; - let resourceBounds: ResourceBounds = estimateFeeToBounds(ZERO); - if (version === ETransactionVersion.V3) { - resourceBounds = - details.resourceBounds ?? - (await this.getSuggestedFee({ type, payload } as any, details)).resourceBounds; - } else { - maxFee = - details.maxFee ?? - (await this.getSuggestedFee({ type, payload } as any, details)).suggestedMaxFee; - } - - return { - maxFee, - resourceBounds, - }; - } - public async signMessage(typedData: TypedData): Promise { return this.signer.signMessage(typedData, this.address); } @@ -610,7 +594,34 @@ export class Account extends Provider implements AccountInterface { return this.verifyMessageHash(hash, signature); } - public async getSuggestedFee({ type, payload }: EstimateFeeAction, details: EstimateFeeDetails) { + /* + * Support methods + */ + + private async getUniversalSuggestedFee( + version: ETransactionVersion, + { type, payload }: EstimateFeeAction, + details: UniversalDetails + ) { + let maxFee: BigNumberish = 0; + let resourceBounds: ResourceBounds = estimateFeeToBounds(ZERO); + if (version === ETransactionVersion.V3) { + resourceBounds = + details.resourceBounds ?? + (await this.getSuggestedFee({ type, payload } as any, details)).resourceBounds; + } else { + maxFee = + details.maxFee ?? + (await this.getSuggestedFee({ type, payload } as any, details)).suggestedMaxFee; + } + + return { + maxFee, + resourceBounds, + }; + } + + public async getSuggestedFee({ type, payload }: EstimateFeeAction, details: UniversalDetails) { let feeEstimate: EstimateFee; switch (type) { @@ -642,9 +653,21 @@ export class Account extends Provider implements AccountInterface { return feeEstimate; } - /** - * will be renamed to buildDeclareContractTransaction - */ + public async buildInvocation( + call: Array, + details: InvocationsSignerDetails + ): Promise { + const calldata = getExecuteCalldata(call, await this.getCairoVersion()); + const signature = await this.signer.signTransaction(call, details); + + return { + ...v3Details(details), + contractAddress: this.address, + calldata, + signature, + }; + } + public async buildDeclarePayload( payload: DeclareContractPayload, details: InvocationsSignerDetails @@ -733,31 +756,6 @@ export class Account extends Provider implements AccountInterface { return calls; } - public async simulateTransaction( - invocations: Invocations, - details: SimulateTransactionDetails = {} - ): Promise { - const { nonce, blockIdentifier, skipValidate, skipExecute, version } = details; - const accountInvocations = await this.accountInvocationsFactory(invocations, { - ...v3Details(details), - versions: [ - ETransactionVersion.V1, // non-sierra - toTransactionVersion( - this.getPreferredVersion(ETransactionVersion.V2, ETransactionVersion.V3), - version - ), - ], - nonce, - blockIdentifier, - }); - - return super.getSimulateTransaction(accountInvocations, { - blockIdentifier, - skipValidate, - skipExecute, - }); - } - public async accountInvocationsFactory( invocations: Invocations, details: AccountInvocationsFactoryDetails diff --git a/src/account/interface.ts b/src/account/interface.ts index 1bf93e3f6..3db5f9e62 100644 --- a/src/account/interface.ts +++ b/src/account/interface.ts @@ -44,7 +44,18 @@ export abstract class AccountInterface extends ProviderInterface { * @param calls the invocation object containing: * - contractAddress - the address of the contract * - entrypoint - the entrypoint of the contract - * - calldata - (defaults to []) the calldata + * - calldata? - (defaults to []) the calldata + * + * @param estimateFeeDetails - + * - blockIdentifier? + * - nonce? = 0 + * - skipValidate? - default true + * - tip? - prioritize order of transactions in the mempool. + * - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) + * - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) + * - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei * * @returns response from estimate_fee */ @@ -58,7 +69,20 @@ export abstract class AccountInterface extends ProviderInterface { * * @param contractPayload the payload object containing: * - contract - the compiled contract to be declared - * - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli. + * - casm? - compiled cairo assembly. Cairo1(casm or compiledClassHash are required) + * - classHash? - the class hash of the compiled contract. Precalculate for faster execution. + * - compiledClassHash?: class hash of the cairo assembly. Cairo1(casm or compiledClassHash are required) + * + * @param estimateFeeDetails - + * - blockIdentifier? + * - nonce? = 0 + * - skipValidate? - default true + * - tip? - prioritize order of transactions in the mempool. + * - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) + * - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) + * - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei * * @returns response from estimate_fee */ @@ -71,11 +95,21 @@ export abstract class AccountInterface extends ProviderInterface { * Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet * * @param contractPayload - - * - contract - the compiled contract to be deployed - * - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli. + * - classHash - the class hash of the compiled contract. + * - constructorCalldata? - constructor data; + * - contractAddress? - future account contract address. Precalculate for faster execution. + * - addressSalt? - salt used for calculation of the contractAddress. Required if contractAddress is provided. + * * @param estimateFeeDetails - - * - optional blockIdentifier - * - constant nonce = 0 + * - blockIdentifier? + * - nonce? = 0 + * - skipValidate? - default true + * - tip? - prioritize order of transactions in the mempool. + * - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) + * - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei + * * @returns response from estimate_fee */ public abstract estimateAccountDeployFee( @@ -87,20 +121,26 @@ export abstract class AccountInterface extends ProviderInterface { * Estimate Fee for executing a UDC DEPLOY transaction on starknet * This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC) - * @param deployContractPayload containing + * @param deployContractPayload array or singular * - classHash: computed class hash of compiled contract * - salt: address salt * - unique: bool if true ensure unique salt - * - calldata: constructor calldata + * - constructorCalldata: constructor calldata * - * @param transactionsDetail Invocation Details containing: - * - optional nonce - * - optional version - * - optional maxFee + * @param estimateFeeDetails - + * - blockIdentifier? + * - nonce? + * - skipValidate? - default true + * - tip? - prioritize order of transactions in the mempool. + * - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) + * - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) + * - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei */ public abstract estimateDeployFee( deployContractPayload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], - transactionsDetail?: InvocationsDetails + estimateFeeDetails?: EstimateFeeDetails ): Promise; /** @@ -111,6 +151,17 @@ export abstract class AccountInterface extends ProviderInterface { * - type - the type of transaction : 'DECLARE' | (multi)'DEPLOY' | (multi)'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT' * - payload - the payload of the transaction * + * @param estimateFeeDetails - + * - blockIdentifier? + * - nonce? + * - skipValidate? - default true + * - tip? - prioritize order of transactions in the mempool. + * - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) + * - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) + * - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) + * - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei + * * @returns response from estimate_fee */ public abstract estimateFeeBulk( @@ -118,6 +169,32 @@ export abstract class AccountInterface extends ProviderInterface { details?: EstimateFeeDetails ): Promise; + /** + * Gets Suggested Max Fee based on the transaction type + * + * @param {EstimateFeeAction} estimateFeeAction + * @param {EstimateFeeDetails} details + * @returns EstimateFee (...response, resourceBounds, suggestedMaxFee) + */ + public abstract getSuggestedFee( + estimateFeeAction: EstimateFeeAction, + details: EstimateFeeDetails + ): Promise; + + /** + * Simulates an array of transaction and returns an array of transaction trace and estimated fee. + * + * @param invocations Invocations containing: + * - type - transaction type: DECLARE, (multi)DEPLOY, DEPLOY_ACCOUNT, (multi)INVOKE_FUNCTION + * @param details SimulateTransactionDetails + * + * @returns response from simulate_transaction + */ + public abstract simulateTransaction( + invocations: Invocations, + details?: SimulateTransactionDetails + ): Promise; + /** * Invoke execute function in account contract * @@ -138,16 +215,14 @@ export abstract class AccountInterface extends ProviderInterface { /** * Declares a given compiled contract (json) to starknet - * + * * @param contractPayload transaction payload to be deployed containing: - - contract: compiled contract code - - (optional) classHash: computed class hash of compiled contract. Pre-compute it for faster execution. - - (required for Cairo1 without compiledClassHash) casm: CompiledContract | string; - - (optional for Cairo1 with casm) compiledClassHash: compiled class hash from casm. Pre-compute it for faster execution. - * @param transactionsDetail Invocation Details containing: - - optional nonce - - optional version - - optional maxFee + * - contract: compiled contract code + * - (optional) classHash: computed class hash of compiled contract. Pre-compute it for faster execution. + * - (required for Cairo1 without compiledClassHash) casm: CompiledContract | string; + * - (optional for Cairo1 with casm) compiledClassHash: compiled class hash from casm. Pre-compute it for faster execution. + * @param transactionsDetail - InvocationsDetails + * * @returns a confirmation of sending a transaction on the starknet contract */ public abstract declare( @@ -164,17 +239,15 @@ export abstract class AccountInterface extends ProviderInterface { * - [constructorCalldata] contract constructor calldata * - [salt=pseudorandom] deploy address salt * - [unique=true] ensure unique salt - * @param details - - * - [nonce=getNonce] - * - [version=transactionVersion] - * - [maxFee=getSuggestedFee] + * @param details - InvocationsDetails + * * @returns * - contract_address[] * - transaction_hash */ public abstract deploy( payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], - details?: InvocationsDetails | undefined + details?: InvocationsDetails ): Promise; /** @@ -186,10 +259,8 @@ export abstract class AccountInterface extends ProviderInterface { * - [constructorCalldata] contract constructor calldata * - [salt=pseudorandom] deploy address salt * - [unique=true] ensure unique salt - * @param details - - * - [nonce=getNonce] - * - [version=transactionVersion] - * - [maxFee=getSuggestedFee] + * @param details - InvocationsDetails + * * @returns * - contract_address * - transaction_hash @@ -203,7 +274,7 @@ export abstract class AccountInterface extends ProviderInterface { */ public abstract deployContract( payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[], - details?: InvocationsDetails | undefined + details?: InvocationsDetails ): Promise; /** @@ -219,10 +290,8 @@ export abstract class AccountInterface extends ProviderInterface { * - [constructorCalldata] contract constructor calldata * - [salt=pseudorandom] deploy address salt * - [unique=true] ensure unique salt - * @param details - * - [nonce=getNonce] - * - [version=transactionVersion] - * - [maxFee=getSuggestedFee] + * @param details - InvocationsDetails + * * @returns * - declare * - transaction_hash @@ -239,21 +308,19 @@ export abstract class AccountInterface extends ProviderInterface { */ public abstract declareAndDeploy( payload: DeclareAndDeployContractPayload, - details?: InvocationsDetails | undefined + details?: InvocationsDetails ): Promise; /** * Deploy the account on Starknet - * + * * @param contractPayload transaction payload to be deployed containing: - - classHash: computed class hash of compiled contract - - optional constructor calldata - - optional address salt - - optional contractAddress - * @param transactionsDetail Invocation Details containing: - - constant nonce = 0 - - optional version - - optional maxFee + * - classHash: computed class hash of compiled contract + * - optional constructor calldata + * - optional address salt + * - optional contractAddress + * @param transactionsDetail - InvocationsDetails + * * @returns a confirmation of sending a transaction on the starknet contract */ public abstract deployAccount( @@ -309,30 +376,4 @@ export abstract class AccountInterface extends ProviderInterface { * @returns nonce of the account */ public abstract getNonce(blockIdentifier?: BlockIdentifier): Promise; - - /** - * Gets Suggested Max Fee based on the transaction type - * - * @param {EstimateFeeAction} estimateFeeAction - * @param {EstimateFeeDetails} details - * @returns suggestedMaxFee - */ - public abstract getSuggestedFee( - estimateFeeAction: EstimateFeeAction, - details: EstimateFeeDetails - ): Promise; - - /** - * Simulates an array of transaction and returns an array of transaction trace and estimated fee. - * - * @param invocations Invocations containing: - * - type - transaction type: DECLARE, (multi)DEPLOY, DEPLOY_ACCOUNT, (multi)INVOKE_FUNCTION - * @param details SimulateTransactionDetails - * - * @returns response from simulate_transaction - */ - public abstract simulateTransaction( - invocations: Invocations, - details?: SimulateTransactionDetails - ): Promise; } diff --git a/src/types/account.ts b/src/types/account.ts index 3b0e5a735..2c9950a14 100644 --- a/src/types/account.ts +++ b/src/types/account.ts @@ -16,20 +16,22 @@ export type AccountInvocationsFactoryDetails = { blockIdentifier?: BlockIdentifier; } & Partial; -export interface EstimateFeeDetails { +export interface UniversalDetails { nonce?: BigNumberish; blockIdentifier?: BlockIdentifier; - maxFee?: BigNumberish; // TODO: max_fee is added to match InvocationsDetails + maxFee?: BigNumberish; // ignored on estimate tip?: BigNumberish; paymasterData?: BigNumberish[]; accountDeploymentData?: BigNumberish[]; nonceDataAvailabilityMode?: EDataAvailabilityMode; feeDataAvailabilityMode?: EDataAvailabilityMode; - version?: BigNumberish; // TODO: this is BigNumberish for interoperability with InvocationsDetails - resourceBounds?: ResourceBounds; // TODO: required for non estimate and for estimate is 00 - skipValidate?: boolean; // TODO: Specific only to estimatFee methods + version?: BigNumberish; + resourceBounds?: ResourceBounds; // ignored on estimate + skipValidate?: boolean; // ignored on non-estimate } +export interface EstimateFeeDetails extends UniversalDetails {} + export interface DeployContractResponse { contract_address: string; transaction_hash: string; diff --git a/src/types/api/rpcspec_0_6/methods.ts b/src/types/api/rpcspec_0_6/methods.ts index 96a51252f..471b681f8 100644 --- a/src/types/api/rpcspec_0_6/methods.ts +++ b/src/types/api/rpcspec_0_6/methods.ts @@ -177,7 +177,7 @@ type ReadMethods = { starknet_estimateFee: { params: { request: BROADCASTED_TXN[]; - simulation_flags?: [SIMULATION_FLAG_FOR_ESTIMATE_FEE] | []; // TODO: Check this is like this is spec (0.5 can't be, 0.6 must be) + simulation_flags?: [SIMULATION_FLAG_FOR_ESTIMATE_FEE] | []; // Diverged from spec (0.5 can't be, 0.6 must be) block_id: BLOCK_ID; }; result: FeeEstimate[]; @@ -191,7 +191,7 @@ type ReadMethods = { block_id: BLOCK_ID; }; result: FeeEstimate; - errors: Errors.CONTRACT_NOT_FOUND | Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND; + errors: Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND; }; // Get the most recent accepted block number diff --git a/src/types/lib/index.ts b/src/types/lib/index.ts index 99d05b5d4..2b85b9a9a 100644 --- a/src/types/lib/index.ts +++ b/src/types/lib/index.ts @@ -99,7 +99,7 @@ export type DeclareContractTransaction = { export type CallDetails = { contractAddress: string; calldata?: RawArgs | Calldata; - entrypoint?: string; // TODO: check if required + entrypoint?: string; }; export type Invocation = CallDetails & { signature?: Signature }; @@ -113,7 +113,7 @@ export type InvocationsDetails = { nonce?: BigNumberish; maxFee?: BigNumberish; version?: BigNumberish; -}; +} & Partial; export type V3TransactionDetails = { nonce: BigNumberish; diff --git a/src/utils/stark.ts b/src/utils/stark.ts index a0dbf6744..52b722d38 100644 --- a/src/utils/stark.ts +++ b/src/utils/stark.ts @@ -6,10 +6,10 @@ import { ArraySignatureType, BigNumberish, CompressedProgram, - EstimateFeeDetails, EstimateFeeResponse, Program, Signature, + UniversalDetails, } from '../types'; import { EDAMode, EDataAvailabilityMode, ETransactionVersion, ResourceBounds } from '../types/api'; import { addHexPrefix, arrayBufferToString, atobUniversal, btoaUniversal } from './encode'; @@ -169,7 +169,7 @@ export function toFeeVersion(providedVersion?: BigNumberish) { * Rerturn provided or default v3 tx details * @param details EstimateFeeDetails */ -export function v3Details(details: EstimateFeeDetails) { +export function v3Details(details: UniversalDetails) { return { tip: details.tip || 0, paymasterData: details.paymasterData || [],