@@ -52,6 +52,10 @@ const QUERY_VERSION_THREE: Felt = Felt::from_raw([
52
52
] ) ;
53
53
54
54
impl < ' a , A > DeclarationV2 < ' a , A > {
55
+ /// Constructs a new [`DeclarationV2`].
56
+ ///
57
+ /// Users would typically use [`declare_v2`](fn.declare_v2) on an [`Account`] instead of
58
+ /// directly calling this method.
55
59
pub const fn new (
56
60
contract_class : Arc < FlattenedSierraClass > ,
57
61
compiled_class_hash : Felt ,
@@ -67,20 +71,25 @@ impl<'a, A> DeclarationV2<'a, A> {
67
71
}
68
72
}
69
73
74
+ /// Returns a new [`DeclarationV2`] with the `nonce`.
70
75
pub fn nonce ( self , nonce : Felt ) -> Self {
71
76
Self {
72
77
nonce : Some ( nonce) ,
73
78
..self
74
79
}
75
80
}
76
81
82
+ /// Returns a new [`DeclarationV2`] with the `max_fee`.
77
83
pub fn max_fee ( self , max_fee : Felt ) -> Self {
78
84
Self {
79
85
max_fee : Some ( max_fee) ,
80
86
..self
81
87
}
82
88
}
83
89
90
+ /// Returns a new [`DeclarationV2`] with the fee estimate multiplier. The multiplier is used
91
+ /// when transaction fee is not manually specified and must be fetched from a [`Provider`]
92
+ /// instead.
84
93
pub fn fee_estimate_multiplier ( self , fee_estimate_multiplier : f64 ) -> Self {
85
94
Self {
86
95
fee_estimate_multiplier,
@@ -110,6 +119,7 @@ impl<'a, A> DeclarationV2<'a, A>
110
119
where
111
120
A : ConnectedAccount + Sync ,
112
121
{
122
+ /// Estimates transaction fees from a [`Provider`].
113
123
pub async fn estimate_fee ( & self ) -> Result < FeeEstimate , AccountError < A :: SignError > > {
114
124
// Resolves nonce
115
125
let nonce = match self . nonce {
@@ -124,6 +134,8 @@ where
124
134
self . estimate_fee_with_nonce ( nonce) . await
125
135
}
126
136
137
+ /// Simulates the transaction from a [`Provider`]. Transaction validation and fee transfer can
138
+ /// be skipped.
127
139
pub async fn simulate (
128
140
& self ,
129
141
skip_validate : bool ,
@@ -143,6 +155,7 @@ where
143
155
. await
144
156
}
145
157
158
+ /// Signs and broadcasts the transaction to the network.
146
159
pub async fn send ( & self ) -> Result < DeclareTransactionResult , AccountError < A :: SignError > > {
147
160
self . prepare ( ) . await ?. send ( ) . await
148
161
}
@@ -275,6 +288,10 @@ where
275
288
}
276
289
277
290
impl < ' a , A > DeclarationV3 < ' a , A > {
291
+ /// Constructs a new [`DeclarationV3`].
292
+ ///
293
+ /// Users would typically use [`declare_v3`](fn.declare_v3) on an [`Account`] instead of
294
+ /// directly calling this method.
278
295
pub const fn new (
279
296
contract_class : Arc < FlattenedSierraClass > ,
280
297
compiled_class_hash : Felt ,
@@ -292,34 +309,43 @@ impl<'a, A> DeclarationV3<'a, A> {
292
309
}
293
310
}
294
311
312
+ /// Returns a new [`DeclarationV3`] with the `nonce`.
295
313
pub fn nonce ( self , nonce : Felt ) -> Self {
296
314
Self {
297
315
nonce : Some ( nonce) ,
298
316
..self
299
317
}
300
318
}
301
319
320
+ /// Returns a new [`DeclarationV3`] with the `gas`.
302
321
pub fn gas ( self , gas : u64 ) -> Self {
303
322
Self {
304
323
gas : Some ( gas) ,
305
324
..self
306
325
}
307
326
}
308
327
328
+ /// Returns a new [`DeclarationV3`] with the `gas_price`.
309
329
pub fn gas_price ( self , gas_price : u128 ) -> Self {
310
330
Self {
311
331
gas_price : Some ( gas_price) ,
312
332
..self
313
333
}
314
334
}
315
335
336
+ /// Returns a new [`DeclarationV3`] with the gas amount estimate multiplier. The multiplier is
337
+ /// used when the gas amount is not manually specified and must be fetched from a [`Provider`]
338
+ /// instead.
316
339
pub fn gas_estimate_multiplier ( self , gas_estimate_multiplier : f64 ) -> Self {
317
340
Self {
318
341
gas_estimate_multiplier,
319
342
..self
320
343
}
321
344
}
322
345
346
+ /// Returns a new [`DeclarationV3`] with the gas price estimate multiplier. The multiplier is
347
+ /// used when the gas price is not manually specified and must be fetched from a [`Provider`]
348
+ /// instead.
323
349
pub fn gas_price_estimate_multiplier ( self , gas_price_estimate_multiplier : f64 ) -> Self {
324
350
Self {
325
351
gas_price_estimate_multiplier,
@@ -351,6 +377,7 @@ impl<'a, A> DeclarationV3<'a, A>
351
377
where
352
378
A : ConnectedAccount + Sync ,
353
379
{
380
+ /// Estimates transaction fees from a [`Provider`].
354
381
pub async fn estimate_fee ( & self ) -> Result < FeeEstimate , AccountError < A :: SignError > > {
355
382
// Resolves nonce
356
383
let nonce = match self . nonce {
@@ -365,6 +392,8 @@ where
365
392
self . estimate_fee_with_nonce ( nonce) . await
366
393
}
367
394
395
+ /// Simulates the transaction from a [`Provider`]. Transaction validation and fee transfer can
396
+ /// be skipped.
368
397
pub async fn simulate (
369
398
& self ,
370
399
skip_validate : bool ,
@@ -384,6 +413,7 @@ where
384
413
. await
385
414
}
386
415
416
+ /// Signs and broadcasts the transaction to the network.
387
417
pub async fn send ( & self ) -> Result < DeclareTransactionResult , AccountError < A :: SignError > > {
388
418
self . prepare ( ) . await ?. send ( ) . await
389
419
}
@@ -570,6 +600,10 @@ where
570
600
}
571
601
572
602
impl < ' a , A > LegacyDeclaration < ' a , A > {
603
+ /// Constructs a new [`LegacyDeclaration`].
604
+ ///
605
+ /// Users would typically use [`declare_legacy`](fn.declare_legacy) on an [`Account`] instead of
606
+ /// directly calling this method.
573
607
pub const fn new ( contract_class : Arc < LegacyContractClass > , account : & ' a A ) -> Self {
574
608
Self {
575
609
account,
@@ -580,20 +614,25 @@ impl<'a, A> LegacyDeclaration<'a, A> {
580
614
}
581
615
}
582
616
617
+ /// Returns a new [`LegacyDeclaration`] with the `nonce`.
583
618
pub fn nonce ( self , nonce : Felt ) -> Self {
584
619
Self {
585
620
nonce : Some ( nonce) ,
586
621
..self
587
622
}
588
623
}
589
624
625
+ /// Returns a new [`LegacyDeclaration`] with the `max_fee`.
590
626
pub fn max_fee ( self , max_fee : Felt ) -> Self {
591
627
Self {
592
628
max_fee : Some ( max_fee) ,
593
629
..self
594
630
}
595
631
}
596
632
633
+ /// Returns a new [`LegacyDeclaration`] with the fee estimate multiplier. The multiplier is used
634
+ /// when transaction fee is not manually specified and must be fetched from a [`Provider`]
635
+ /// instead.
597
636
pub fn fee_estimate_multiplier ( self , fee_estimate_multiplier : f64 ) -> Self {
598
637
Self {
599
638
fee_estimate_multiplier,
@@ -623,6 +662,7 @@ impl<'a, A> LegacyDeclaration<'a, A>
623
662
where
624
663
A : ConnectedAccount + Sync ,
625
664
{
665
+ /// Estimates transaction fees from a [`Provider`].
626
666
pub async fn estimate_fee ( & self ) -> Result < FeeEstimate , AccountError < A :: SignError > > {
627
667
// Resolves nonce
628
668
let nonce = match self . nonce {
@@ -637,6 +677,8 @@ where
637
677
self . estimate_fee_with_nonce ( nonce) . await
638
678
}
639
679
680
+ /// Simulates the transaction from a [`Provider`]. Transaction validation and fee transfer can
681
+ /// be skipped.
640
682
pub async fn simulate (
641
683
& self ,
642
684
skip_validate : bool ,
@@ -656,6 +698,7 @@ where
656
698
. await
657
699
}
658
700
701
+ /// Signs and broadcasts the transaction to the network.
659
702
pub async fn send ( & self ) -> Result < DeclareTransactionResult , AccountError < A :: SignError > > {
660
703
self . prepare ( ) . await ?. send ( ) . await
661
704
}
@@ -787,6 +830,7 @@ where
787
830
}
788
831
789
832
impl RawDeclarationV2 {
833
+ /// Calculates transaction hash given `chain_id`, `address`, and `query_only`.
790
834
pub fn transaction_hash ( & self , chain_id : Felt , address : Felt , query_only : bool ) -> Felt {
791
835
compute_hash_on_elements ( & [
792
836
PREFIX_DECLARE ,
@@ -805,24 +849,29 @@ impl RawDeclarationV2 {
805
849
] )
806
850
}
807
851
852
+ /// Gets a reference to the flattened Sierra (Cairo 1) class being declared.
808
853
pub fn contract_class ( & self ) -> & FlattenedSierraClass {
809
854
& self . contract_class
810
855
}
811
856
857
+ /// Gets the CASM class hash corresponding to the Sierra class being declared.
812
858
pub const fn compiled_class_hash ( & self ) -> Felt {
813
859
self . compiled_class_hash
814
860
}
815
861
862
+ /// Gets the `nonce` of the declaration request.
816
863
pub const fn nonce ( & self ) -> Felt {
817
864
self . nonce
818
865
}
819
866
867
+ /// Gets the `max_fee` of the declaration request.
820
868
pub const fn max_fee ( & self ) -> Felt {
821
869
self . max_fee
822
870
}
823
871
}
824
872
825
873
impl RawDeclarationV3 {
874
+ /// Calculates transaction hash given `chain_id`, `address`, and `query_only`.
826
875
pub fn transaction_hash ( & self , chain_id : Felt , address : Felt , query_only : bool ) -> Felt {
827
876
let mut hasher = PoseidonHasher :: new ( ) ;
828
877
@@ -876,28 +925,34 @@ impl RawDeclarationV3 {
876
925
hasher. finalize ( )
877
926
}
878
927
928
+ /// Gets a reference to the flattened Sierra (Cairo 1) class being declared.
879
929
pub fn contract_class ( & self ) -> & FlattenedSierraClass {
880
930
& self . contract_class
881
931
}
882
932
933
+ /// Gets the CASM class hash corresponding to the Sierra class being declared.
883
934
pub const fn compiled_class_hash ( & self ) -> Felt {
884
935
self . compiled_class_hash
885
936
}
886
937
938
+ /// Gets the `nonce` of the declaration request.
887
939
pub const fn nonce ( & self ) -> Felt {
888
940
self . nonce
889
941
}
890
942
943
+ /// Gets the `gas` of the declaration request.
891
944
pub const fn gas ( & self ) -> u64 {
892
945
self . gas
893
946
}
894
947
948
+ /// Gets the `gas_price` of the declaration request.
895
949
pub const fn gas_price ( & self ) -> u128 {
896
950
self . gas_price
897
951
}
898
952
}
899
953
900
954
impl RawLegacyDeclaration {
955
+ /// Calculates transaction hash given `chain_id`, `address`, and `query_only`.
901
956
pub fn transaction_hash (
902
957
& self ,
903
958
chain_id : Felt ,
@@ -920,14 +975,17 @@ impl RawLegacyDeclaration {
920
975
] ) )
921
976
}
922
977
978
+ /// Gets a reference to the legacy (Cairo 0) class being declared.
923
979
pub fn contract_class ( & self ) -> & LegacyContractClass {
924
980
& self . contract_class
925
981
}
926
982
983
+ /// Gets the `nonce` of the declaration request.
927
984
pub const fn nonce ( & self ) -> Felt {
928
985
self . nonce
929
986
}
930
987
988
+ /// Gets the `max_fee` of the declaration request.
931
989
pub const fn max_fee ( & self ) -> Felt {
932
990
self . max_fee
933
991
}
@@ -949,6 +1007,7 @@ impl<'a, A> PreparedDeclarationV2<'a, A>
949
1007
where
950
1008
A : ConnectedAccount ,
951
1009
{
1010
+ /// Signs and broadcasts the transaction to the network.
952
1011
pub async fn send ( & self ) -> Result < DeclareTransactionResult , AccountError < A :: SignError > > {
953
1012
let tx_request = self . get_declare_request ( false , false ) . await ?;
954
1013
self . account
@@ -998,6 +1057,7 @@ impl<'a, A> PreparedDeclarationV3<'a, A>
998
1057
where
999
1058
A : ConnectedAccount ,
1000
1059
{
1060
+ /// Signs and broadcasts the transaction to the network.
1001
1061
pub async fn send ( & self ) -> Result < DeclareTransactionResult , AccountError < A :: SignError > > {
1002
1062
let tx_request = self . get_declare_request ( false , false ) . await ?;
1003
1063
self . account
@@ -1066,6 +1126,7 @@ impl<'a, A> PreparedLegacyDeclaration<'a, A>
1066
1126
where
1067
1127
A : ConnectedAccount ,
1068
1128
{
1129
+ /// Signs and broadcasts the transaction to the network.
1069
1130
pub async fn send ( & self ) -> Result < DeclareTransactionResult , AccountError < A :: SignError > > {
1070
1131
let tx_request = self . get_declare_request ( false , false ) . await ?;
1071
1132
self . account
0 commit comments