1
+ import { config } from '../global/config' ;
1
2
import {
2
3
OutsideExecutionCallerAny ,
3
4
SNIP9_V1_INTERFACE_ID ,
@@ -6,7 +7,13 @@ import {
6
7
UDC ,
7
8
ZERO ,
8
9
} from '../global/constants' ;
10
+ import { logger } from '../global/logger' ;
9
11
import { LibraryError , Provider , ProviderInterface } from '../provider' ;
12
+ import {
13
+ ETransactionVersion ,
14
+ ETransactionVersion3 ,
15
+ ResourceBounds ,
16
+ } from '../provider/types/spec.type' ;
10
17
import { Signer , SignerInterface } from '../signer' ;
11
18
import {
12
19
AccountInvocations ,
@@ -27,7 +34,6 @@ import {
27
34
DeployContractUDCResponse ,
28
35
DeployTransactionReceiptResponse ,
29
36
EstimateFee ,
30
- UniversalSuggestedFee ,
31
37
EstimateFeeAction ,
32
38
EstimateFeeBulk ,
33
39
Invocation ,
@@ -44,12 +50,8 @@ import {
44
50
TypedData ,
45
51
UniversalDeployerContractPayload ,
46
52
UniversalDetails ,
53
+ UniversalSuggestedFee ,
47
54
} from '../types' ;
48
- import {
49
- ETransactionVersion ,
50
- ETransactionVersion3 ,
51
- ResourceBounds ,
52
- } from '../provider/types/spec.type' ;
53
55
import {
54
56
OutsideExecutionVersion ,
55
57
type OutsideExecution ,
@@ -60,7 +62,6 @@ import { CallData } from '../utils/calldata';
60
62
import { extractContractHashes , isSierra } from '../utils/contract' ;
61
63
import { parseUDCEvent } from '../utils/events' ;
62
64
import { calculateContractAddressFromHash } from '../utils/hash' ;
63
- import { isUndefined , isString } from '../utils/typed' ;
64
65
import { isHex , toBigInt , toCairoBool , toHex } from '../utils/num' ;
65
66
import {
66
67
buildExecuteFromOutsideCall ,
@@ -79,10 +80,9 @@ import {
79
80
ZEROFee ,
80
81
} from '../utils/stark' ;
81
82
import { buildUDCCall , getExecuteCalldata } from '../utils/transaction' ;
83
+ import { isString , isUndefined } from '../utils/typed' ;
82
84
import { getMessageHash } from '../utils/typedData' ;
83
85
import { AccountInterface } from './interface' ;
84
- import { config } from '../global/config' ;
85
- import { logger } from '../global/logger' ;
86
86
87
87
export class Account extends Provider implements AccountInterface {
88
88
public signer : SignerInterface ;
@@ -188,7 +188,7 @@ export class Account extends Provider implements AccountInterface {
188
188
const chainId = await this . getChainId ( ) ;
189
189
190
190
const signerDetails : InvocationsSignerDetails = {
191
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
191
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
192
192
walletAddress : this . address ,
193
193
nonce,
194
194
maxFee : ZERO ,
@@ -201,7 +201,7 @@ export class Account extends Provider implements AccountInterface {
201
201
const invocation = await this . buildInvocation ( transactions , signerDetails ) ;
202
202
return super . getInvokeEstimateFee (
203
203
{ ...invocation } ,
204
- { ...v3Details ( details , await this . channel . getSpecVersion ( ) ) , version, nonce } ,
204
+ { ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) , version, nonce } ,
205
205
blockIdentifier ,
206
206
details . skipValidate
207
207
) ;
@@ -227,7 +227,7 @@ export class Account extends Provider implements AccountInterface {
227
227
const chainId = await this . getChainId ( ) ;
228
228
229
229
const declareContractTransaction = await this . buildDeclarePayload ( payload , {
230
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
230
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
231
231
nonce,
232
232
chainId,
233
233
version,
@@ -239,7 +239,7 @@ export class Account extends Provider implements AccountInterface {
239
239
240
240
return super . getDeclareEstimateFee (
241
241
declareContractTransaction ,
242
- { ...v3Details ( details , await this . channel . getSpecVersion ( ) ) , version, nonce } ,
242
+ { ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) , version, nonce } ,
243
243
blockIdentifier ,
244
244
details . skipValidate
245
245
) ;
@@ -265,7 +265,7 @@ export class Account extends Provider implements AccountInterface {
265
265
const payload = await this . buildAccountDeployPayload (
266
266
{ classHash, addressSalt, constructorCalldata, contractAddress } ,
267
267
{
268
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
268
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
269
269
nonce,
270
270
chainId,
271
271
version,
@@ -278,7 +278,7 @@ export class Account extends Provider implements AccountInterface {
278
278
279
279
return super . getDeployAccountEstimateFee (
280
280
{ ...payload } ,
281
- { ...v3Details ( details , await this . channel . getSpecVersion ( ) ) , version, nonce } ,
281
+ { ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) , version, nonce } ,
282
282
blockIdentifier ,
283
283
details . skipValidate
284
284
) ;
@@ -299,7 +299,7 @@ export class Account extends Provider implements AccountInterface {
299
299
if ( ! invocations . length ) throw TypeError ( 'Invocations should be non-empty array' ) ;
300
300
const { nonce, blockIdentifier, version, skipValidate } = details ;
301
301
const accountInvocations = await this . accountInvocationsFactory ( invocations , {
302
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
302
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
303
303
versions : [
304
304
ETransactionVersion . F1 , // non-sierra
305
305
toTransactionVersion (
@@ -325,7 +325,7 @@ export class Account extends Provider implements AccountInterface {
325
325
if ( ! invocations . length ) throw TypeError ( 'Invocations should be non-empty array' ) ;
326
326
const { nonce, blockIdentifier, skipValidate = true , skipExecute, version } = details ;
327
327
const accountInvocations = await this . accountInvocationsFactory ( invocations , {
328
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
328
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
329
329
versions : [
330
330
ETransactionVersion . V1 , // non-sierra
331
331
toTransactionVersion (
@@ -368,7 +368,7 @@ export class Account extends Provider implements AccountInterface {
368
368
const chainId = await this . getChainId ( ) ;
369
369
370
370
const signerDetails : InvocationsSignerDetails = {
371
- ...v3Details ( transactionsDetail , await this . channel . getSpecVersion ( ) ) ,
371
+ ...v3Details ( transactionsDetail , await this . channel . setupSpecVersion ( ) ) ,
372
372
resourceBounds : estimate . resourceBounds ,
373
373
walletAddress : this . address ,
374
374
nonce,
@@ -385,7 +385,7 @@ export class Account extends Provider implements AccountInterface {
385
385
return this . invokeFunction (
386
386
{ contractAddress : this . address , calldata, signature } ,
387
387
{
388
- ...v3Details ( transactionsDetail , await this . channel . getSpecVersion ( ) ) ,
388
+ ...v3Details ( transactionsDetail , await this . channel . setupSpecVersion ( ) ) ,
389
389
resourceBounds : estimate . resourceBounds ,
390
390
nonce,
391
391
maxFee : estimate . maxFee ,
@@ -442,7 +442,7 @@ export class Account extends Provider implements AccountInterface {
442
442
) ;
443
443
444
444
const declareDetails : InvocationsSignerDetails = {
445
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
445
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
446
446
resourceBounds : estimate . resourceBounds ,
447
447
maxFee : estimate . maxFee ,
448
448
nonce : toBigInt ( nonce ?? ( await this . getNonce ( ) ) ) ,
@@ -537,7 +537,7 @@ export class Account extends Provider implements AccountInterface {
537
537
) ;
538
538
539
539
const signature = await this . signer . signDeployAccountTransaction ( {
540
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
540
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
541
541
classHash,
542
542
constructorCalldata : compiledCalldata ,
543
543
contractAddress,
@@ -552,7 +552,7 @@ export class Account extends Provider implements AccountInterface {
552
552
return this . deployAccountContract (
553
553
{ classHash, addressSalt, constructorCalldata, signature } ,
554
554
{
555
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
555
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
556
556
nonce,
557
557
resourceBounds : estimate . resourceBounds ,
558
558
maxFee : estimate . maxFee ,
@@ -741,7 +741,7 @@ export class Account extends Provider implements AccountInterface {
741
741
let resourceBounds : ResourceBounds = estimateFeeToBounds (
742
742
ZERO ,
743
743
undefined ,
744
- await this . channel . getSpecVersion ( )
744
+ await this . channel . setupSpecVersion ( )
745
745
) ;
746
746
747
747
if ( version === ETransactionVersion . V3 ) {
@@ -778,7 +778,7 @@ export class Account extends Provider implements AccountInterface {
778
778
return this . estimateDeployFee ( payload , details ) ;
779
779
780
780
default :
781
- return ZEROFee ( await this . channel . getSpecVersion ( ) ) ;
781
+ return ZEROFee ( await this . channel . setupSpecVersion ( ) ) ;
782
782
}
783
783
}
784
784
@@ -790,7 +790,7 @@ export class Account extends Provider implements AccountInterface {
790
790
const signature = ! details . skipValidate ? await this . signer . signTransaction ( call , details ) : [ ] ;
791
791
792
792
return {
793
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
793
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
794
794
contractAddress : this . address ,
795
795
calldata,
796
796
signature,
@@ -814,7 +814,7 @@ export class Account extends Provider implements AccountInterface {
814
814
const signature = ! details . skipValidate
815
815
? await this . signer . signDeclareTransaction ( {
816
816
...details ,
817
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
817
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
818
818
classHash,
819
819
compiledClassHash : compiledClassHash as string , // TODO: TS, cast because optional for v2 and required for v3, thrown if not present
820
820
senderAddress : details . walletAddress ,
@@ -846,7 +846,7 @@ export class Account extends Provider implements AccountInterface {
846
846
const signature = ! details . skipValidate
847
847
? await this . signer . signDeployAccountTransaction ( {
848
848
...details ,
849
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
849
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
850
850
classHash,
851
851
contractAddress,
852
852
addressSalt,
@@ -855,7 +855,7 @@ export class Account extends Provider implements AccountInterface {
855
855
: [ ] ;
856
856
857
857
return {
858
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
858
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
859
859
classHash,
860
860
addressSalt,
861
861
constructorCalldata : compiledCalldata ,
@@ -910,7 +910,7 @@ export class Account extends Provider implements AccountInterface {
910
910
( [ ] as Invocations ) . concat ( invocations ) . map ( async ( transaction , index : number ) => {
911
911
const txPayload : any = 'payload' in transaction ? transaction . payload : transaction ;
912
912
const signerDetails = {
913
- ...v3Details ( details , await this . channel . getSpecVersion ( ) ) ,
913
+ ...v3Details ( details , await this . channel . setupSpecVersion ( ) ) ,
914
914
walletAddress : this . address ,
915
915
nonce : toBigInt ( Number ( safeNonce ) + index ) ,
916
916
maxFee : ZERO ,
0 commit comments