Skip to content

Commit 621bdad

Browse files
authored
Merge pull request #890 from starknet-io/v6/v3-transactions
V6/v3 transactions
2 parents da2db6f + ab50471 commit 621bdad

File tree

8 files changed

+314
-308
lines changed

8 files changed

+314
-308
lines changed

src/account/default.ts

Lines changed: 172 additions & 215 deletions
Large diffs are not rendered by default.

src/account/interface.ts

Lines changed: 113 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,18 @@ export abstract class AccountInterface extends ProviderInterface {
4444
* @param calls the invocation object containing:
4545
* - contractAddress - the address of the contract
4646
* - entrypoint - the entrypoint of the contract
47-
* - calldata - (defaults to []) the calldata
47+
* - calldata? - (defaults to []) the calldata
48+
*
49+
* @param estimateFeeDetails -
50+
* - blockIdentifier?
51+
* - nonce? = 0
52+
* - skipValidate? - default true
53+
* - tip? - prioritize order of transactions in the mempool.
54+
* - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction)
55+
* - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337)
56+
* - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
57+
* - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
58+
* - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei
4859
*
4960
* @returns response from estimate_fee
5061
*/
@@ -58,7 +69,20 @@ export abstract class AccountInterface extends ProviderInterface {
5869
*
5970
* @param contractPayload the payload object containing:
6071
* - contract - the compiled contract to be declared
61-
* - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
72+
* - casm? - compiled cairo assembly. Cairo1(casm or compiledClassHash are required)
73+
* - classHash? - the class hash of the compiled contract. Precalculate for faster execution.
74+
* - compiledClassHash?: class hash of the cairo assembly. Cairo1(casm or compiledClassHash are required)
75+
*
76+
* @param estimateFeeDetails -
77+
* - blockIdentifier?
78+
* - nonce? = 0
79+
* - skipValidate? - default true
80+
* - tip? - prioritize order of transactions in the mempool.
81+
* - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction)
82+
* - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337)
83+
* - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
84+
* - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
85+
* - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei
6286
*
6387
* @returns response from estimate_fee
6488
*/
@@ -71,11 +95,21 @@ export abstract class AccountInterface extends ProviderInterface {
7195
* Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
7296
*
7397
* @param contractPayload -
74-
* - contract - the compiled contract to be deployed
75-
* - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
98+
* - classHash - the class hash of the compiled contract.
99+
* - constructorCalldata? - constructor data;
100+
* - contractAddress? - future account contract address. Precalculate for faster execution.
101+
* - addressSalt? - salt used for calculation of the contractAddress. Required if contractAddress is provided.
102+
*
76103
* @param estimateFeeDetails -
77-
* - optional blockIdentifier
78-
* - constant nonce = 0
104+
* - blockIdentifier?
105+
* - nonce? = 0
106+
* - skipValidate? - default true
107+
* - tip? - prioritize order of transactions in the mempool.
108+
* - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337)
109+
* - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
110+
* - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
111+
* - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei
112+
*
79113
* @returns response from estimate_fee
80114
*/
81115
public abstract estimateAccountDeployFee(
@@ -87,20 +121,26 @@ export abstract class AccountInterface extends ProviderInterface {
87121
* Estimate Fee for executing a UDC DEPLOY transaction on starknet
88122
* This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
89123
90-
* @param deployContractPayload containing
124+
* @param deployContractPayload array or singular
91125
* - classHash: computed class hash of compiled contract
92126
* - salt: address salt
93127
* - unique: bool if true ensure unique salt
94-
* - calldata: constructor calldata
128+
* - constructorCalldata: constructor calldata
95129
*
96-
* @param transactionsDetail Invocation Details containing:
97-
* - optional nonce
98-
* - optional version
99-
* - optional maxFee
130+
* @param estimateFeeDetails -
131+
* - blockIdentifier?
132+
* - nonce?
133+
* - skipValidate? - default true
134+
* - tip? - prioritize order of transactions in the mempool.
135+
* - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction)
136+
* - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337)
137+
* - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
138+
* - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
139+
* - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei
100140
*/
101141
public abstract estimateDeployFee(
102142
deployContractPayload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[],
103-
transactionsDetail?: InvocationsDetails
143+
estimateFeeDetails?: EstimateFeeDetails
104144
): Promise<EstimateFeeResponse>;
105145

106146
/**
@@ -111,13 +151,50 @@ export abstract class AccountInterface extends ProviderInterface {
111151
* - type - the type of transaction : 'DECLARE' | (multi)'DEPLOY' | (multi)'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT'
112152
* - payload - the payload of the transaction
113153
*
154+
* @param estimateFeeDetails -
155+
* - blockIdentifier?
156+
* - nonce?
157+
* - skipValidate? - default true
158+
* - tip? - prioritize order of transactions in the mempool.
159+
* - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction)
160+
* - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337)
161+
* - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
162+
* - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition)
163+
* - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei
164+
*
114165
* @returns response from estimate_fee
115166
*/
116167
public abstract estimateFeeBulk(
117168
invocations: Invocations,
118169
details?: EstimateFeeDetails
119170
): Promise<EstimateFeeResponseBulk>;
120171

172+
/**
173+
* Gets Suggested Max Fee based on the transaction type
174+
*
175+
* @param {EstimateFeeAction} estimateFeeAction
176+
* @param {EstimateFeeDetails} details
177+
* @returns EstimateFee (...response, resourceBounds, suggestedMaxFee)
178+
*/
179+
public abstract getSuggestedFee(
180+
estimateFeeAction: EstimateFeeAction,
181+
details: EstimateFeeDetails
182+
): Promise<EstimateFee>;
183+
184+
/**
185+
* Simulates an array of transaction and returns an array of transaction trace and estimated fee.
186+
*
187+
* @param invocations Invocations containing:
188+
* - type - transaction type: DECLARE, (multi)DEPLOY, DEPLOY_ACCOUNT, (multi)INVOKE_FUNCTION
189+
* @param details SimulateTransactionDetails
190+
*
191+
* @returns response from simulate_transaction
192+
*/
193+
public abstract simulateTransaction(
194+
invocations: Invocations,
195+
details?: SimulateTransactionDetails
196+
): Promise<SimulateTransactionResponse>;
197+
121198
/**
122199
* Invoke execute function in account contract
123200
*
@@ -138,16 +215,14 @@ export abstract class AccountInterface extends ProviderInterface {
138215

139216
/**
140217
* Declares a given compiled contract (json) to starknet
141-
*
218+
*
142219
* @param contractPayload transaction payload to be deployed containing:
143-
- contract: compiled contract code
144-
- (optional) classHash: computed class hash of compiled contract. Pre-compute it for faster execution.
145-
- (required for Cairo1 without compiledClassHash) casm: CompiledContract | string;
146-
- (optional for Cairo1 with casm) compiledClassHash: compiled class hash from casm. Pre-compute it for faster execution.
147-
* @param transactionsDetail Invocation Details containing:
148-
- optional nonce
149-
- optional version
150-
- optional maxFee
220+
* - contract: compiled contract code
221+
* - (optional) classHash: computed class hash of compiled contract. Pre-compute it for faster execution.
222+
* - (required for Cairo1 without compiledClassHash) casm: CompiledContract | string;
223+
* - (optional for Cairo1 with casm) compiledClassHash: compiled class hash from casm. Pre-compute it for faster execution.
224+
* @param transactionsDetail - InvocationsDetails
225+
*
151226
* @returns a confirmation of sending a transaction on the starknet contract
152227
*/
153228
public abstract declare(
@@ -164,17 +239,15 @@ export abstract class AccountInterface extends ProviderInterface {
164239
* - [constructorCalldata] contract constructor calldata
165240
* - [salt=pseudorandom] deploy address salt
166241
* - [unique=true] ensure unique salt
167-
* @param details -
168-
* - [nonce=getNonce]
169-
* - [version=transactionVersion]
170-
* - [maxFee=getSuggestedFee]
242+
* @param details - InvocationsDetails
243+
*
171244
* @returns
172245
* - contract_address[]
173246
* - transaction_hash
174247
*/
175248
public abstract deploy(
176249
payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[],
177-
details?: InvocationsDetails | undefined
250+
details?: InvocationsDetails
178251
): Promise<MultiDeployContractResponse>;
179252

180253
/**
@@ -186,10 +259,8 @@ export abstract class AccountInterface extends ProviderInterface {
186259
* - [constructorCalldata] contract constructor calldata
187260
* - [salt=pseudorandom] deploy address salt
188261
* - [unique=true] ensure unique salt
189-
* @param details -
190-
* - [nonce=getNonce]
191-
* - [version=transactionVersion]
192-
* - [maxFee=getSuggestedFee]
262+
* @param details - InvocationsDetails
263+
*
193264
* @returns
194265
* - contract_address
195266
* - transaction_hash
@@ -203,7 +274,7 @@ export abstract class AccountInterface extends ProviderInterface {
203274
*/
204275
public abstract deployContract(
205276
payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[],
206-
details?: InvocationsDetails | undefined
277+
details?: InvocationsDetails
207278
): Promise<DeployContractUDCResponse>;
208279

209280
/**
@@ -219,10 +290,8 @@ export abstract class AccountInterface extends ProviderInterface {
219290
* - [constructorCalldata] contract constructor calldata
220291
* - [salt=pseudorandom] deploy address salt
221292
* - [unique=true] ensure unique salt
222-
* @param details
223-
* - [nonce=getNonce]
224-
* - [version=transactionVersion]
225-
* - [maxFee=getSuggestedFee]
293+
* @param details - InvocationsDetails
294+
*
226295
* @returns
227296
* - declare
228297
* - transaction_hash
@@ -239,21 +308,19 @@ export abstract class AccountInterface extends ProviderInterface {
239308
*/
240309
public abstract declareAndDeploy(
241310
payload: DeclareAndDeployContractPayload,
242-
details?: InvocationsDetails | undefined
311+
details?: InvocationsDetails
243312
): Promise<DeclareDeployUDCResponse>;
244313

245314
/**
246315
* Deploy the account on Starknet
247-
*
316+
*
248317
* @param contractPayload transaction payload to be deployed containing:
249-
- classHash: computed class hash of compiled contract
250-
- optional constructor calldata
251-
- optional address salt
252-
- optional contractAddress
253-
* @param transactionsDetail Invocation Details containing:
254-
- constant nonce = 0
255-
- optional version
256-
- optional maxFee
318+
* - classHash: computed class hash of compiled contract
319+
* - optional constructor calldata
320+
* - optional address salt
321+
* - optional contractAddress
322+
* @param transactionsDetail - InvocationsDetails
323+
*
257324
* @returns a confirmation of sending a transaction on the starknet contract
258325
*/
259326
public abstract deployAccount(
@@ -309,30 +376,4 @@ export abstract class AccountInterface extends ProviderInterface {
309376
* @returns nonce of the account
310377
*/
311378
public abstract getNonce(blockIdentifier?: BlockIdentifier): Promise<Nonce>;
312-
313-
/**
314-
* Gets Suggested Max Fee based on the transaction type
315-
*
316-
* @param {EstimateFeeAction} estimateFeeAction
317-
* @param {EstimateFeeDetails} details
318-
* @returns suggestedMaxFee
319-
*/
320-
public abstract getSuggestedFee(
321-
estimateFeeAction: EstimateFeeAction,
322-
details: EstimateFeeDetails
323-
): Promise<EstimateFee>;
324-
325-
/**
326-
* Simulates an array of transaction and returns an array of transaction trace and estimated fee.
327-
*
328-
* @param invocations Invocations containing:
329-
* - type - transaction type: DECLARE, (multi)DEPLOY, DEPLOY_ACCOUNT, (multi)INVOKE_FUNCTION
330-
* @param details SimulateTransactionDetails
331-
*
332-
* @returns response from simulate_transaction
333-
*/
334-
public abstract simulateTransaction(
335-
invocations: Invocations,
336-
details?: SimulateTransactionDetails
337-
): Promise<SimulateTransactionResponse>;
338379
}

src/types/account.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ export type AccountInvocationsFactoryDetails = {
1616
blockIdentifier?: BlockIdentifier;
1717
} & Partial<V3TransactionDetails>;
1818

19-
export interface EstimateFeeDetails {
19+
export interface UniversalDetails {
2020
nonce?: BigNumberish;
2121
blockIdentifier?: BlockIdentifier;
22-
maxFee?: BigNumberish; // TODO: max_fee is added to match InvocationsDetails
22+
maxFee?: BigNumberish; // ignored on estimate
2323
tip?: BigNumberish;
2424
paymasterData?: BigNumberish[];
2525
accountDeploymentData?: BigNumberish[];
2626
nonceDataAvailabilityMode?: EDataAvailabilityMode;
2727
feeDataAvailabilityMode?: EDataAvailabilityMode;
28-
version?: BigNumberish; // TODO: this is BigNumberish for interoperability with InvocationsDetails
29-
resourceBounds?: ResourceBounds; // TODO: required for non estimate and for estimate is 00
30-
skipValidate?: boolean; // TODO: Specific only to estimatFee methods
28+
version?: BigNumberish;
29+
resourceBounds?: ResourceBounds; // ignored on estimate
30+
skipValidate?: boolean; // ignored on non-estimate
3131
}
3232

33+
export interface EstimateFeeDetails extends UniversalDetails {}
34+
3335
export interface DeployContractResponse {
3436
contract_address: string;
3537
transaction_hash: string;

src/types/api/rpcspec_0_6/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export interface INSUFFICIENT_ACCOUNT_BALANCE {
111111
export interface VALIDATION_FAILURE {
112112
code: 55;
113113
message: 'Account validation failed';
114+
data: string;
114115
}
115116

116117
export interface COMPILATION_FAILED {

src/types/api/rpcspec_0_6/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* version 0.6.0-rc2
2+
* version 0.6.0
33
*/
44

55
export { Methods } from './methods';

src/types/api/rpcspec_0_6/methods.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ type ReadMethods = {
177177
starknet_estimateFee: {
178178
params: {
179179
request: BROADCASTED_TXN[];
180-
simulation_flags?: [SIMULATION_FLAG_FOR_ESTIMATE_FEE] | []; // TODO: Check this is like this is spec (0.5 can't be, 0.6 must be)
180+
simulation_flags?: [SIMULATION_FLAG_FOR_ESTIMATE_FEE] | []; // Diverged from spec (0.5 can't be, 0.6 must be)
181181
block_id: BLOCK_ID;
182182
};
183183
result: FeeEstimate[];
@@ -191,7 +191,7 @@ type ReadMethods = {
191191
block_id: BLOCK_ID;
192192
};
193193
result: FeeEstimate;
194-
errors: Errors.CONTRACT_NOT_FOUND | Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND;
194+
errors: Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND;
195195
};
196196

197197
// Get the most recent accepted block number

src/types/lib/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export type DeclareContractTransaction = {
9999
export type CallDetails = {
100100
contractAddress: string;
101101
calldata?: RawArgs | Calldata;
102-
entrypoint?: string; // TODO: check if required
102+
entrypoint?: string;
103103
};
104104

105105
export type Invocation = CallDetails & { signature?: Signature };
@@ -113,7 +113,7 @@ export type InvocationsDetails = {
113113
nonce?: BigNumberish;
114114
maxFee?: BigNumberish;
115115
version?: BigNumberish;
116-
};
116+
} & Partial<V3TransactionDetails>;
117117

118118
export type V3TransactionDetails = {
119119
nonce: BigNumberish;

0 commit comments

Comments
 (0)