@@ -78,6 +78,43 @@ func init() {
78
78
setNN (MainnetConfig )
79
79
}
80
80
81
+ // PollPeriod is an option to PollForTransactions
82
+ type PollPeriod time.Duration
83
+
84
+ // PollTimeout is an option to PollForTransactions
85
+ type PollTimeout time.Duration
86
+
87
+ // EstimateGasUnitPrice estimates the gas unit price for a transaction
88
+ type EstimateGasUnitPrice bool
89
+
90
+ // EstimateMaxGasAmount estimates the max gas amount for a transaction
91
+ type EstimateMaxGasAmount bool
92
+
93
+ // EstimatePrioritizedGasUnitPrice estimates the prioritized gas unit price for a transaction
94
+ type EstimatePrioritizedGasUnitPrice bool
95
+
96
+ // MaxGasAmount will set the max gas amount in gas units for a transaction
97
+ type MaxGasAmount uint64
98
+
99
+ // GasUnitPrice will set the gas unit price in octas (1/10^8 APT) for a transaction
100
+ type GasUnitPrice uint64
101
+
102
+ // ExpirationSeconds will set the number of seconds from the current time to expire a transaction
103
+ type ExpirationSeconds uint64
104
+
105
+ // FeePayer will set the fee payer for a transaction
106
+ type FeePayer * AccountAddress
107
+
108
+ // AdditionalSigners will set the additional signers for a transaction
109
+ type AdditionalSigners []AccountAddress
110
+
111
+ // SequenceNumber will set the sequence number for a transaction
112
+ type SequenceNumber uint64
113
+
114
+ // ChainIdOption will set the chain ID for a transaction
115
+ // TODO: This one may want to be removed / renamed?
116
+ type ChainIdOption uint8
117
+
81
118
// AptosClient is an interface for all functionality on the Client.
82
119
// It is a combination of [AptosRpcClient], [AptosIndexerClient], and [AptosFaucetClient] for the purposes
83
120
// of mocking and convenience.
@@ -137,6 +174,12 @@ type AptosRpcClient interface {
137
174
// AccountResourcesBCS fetches account resources as raw Move struct BCS blobs in AccountResourceRecord.Data []byte
138
175
AccountResourcesBCS (address AccountAddress , ledgerVersion ... uint64 ) (resources []AccountResourceRecord , err error )
139
176
177
+ // AccountModule fetches a single account module's bytecode and ABI from on-chain state.
178
+ AccountModule (address AccountAddress , moduleName string , ledgerVersion ... uint64 ) (data * api.MoveBytecode , err error )
179
+
180
+ // EntryFunctionWithArgs generates an EntryFunction from on-chain Module ABI, and converts simple inputs to BCS encoded ones.
181
+ EntryFunctionWithArgs (moduleAddress AccountAddress , moduleName string , functionName string , typeArgs []any , args []any ) (entry * EntryFunction , err error )
182
+
140
183
// BlockByHeight fetches a block by height
141
184
//
142
185
// block, _ := client.BlockByHeight(1, false)
@@ -172,6 +215,10 @@ type AptosRpcClient interface {
172
215
// }
173
216
TransactionByHash (txnHash string ) (data * api.Transaction , err error )
174
217
218
+ // WaitTransactionByHash waits for a transaction to be confirmed by its hash.
219
+ // This function allows you to monitor the status of a transaction until it is finalized.
220
+ WaitTransactionByHash (txnHash string ) (data * api.Transaction , err error )
221
+
175
222
// TransactionByVersion gets info on a transaction from its LedgerVersion. It must have been
176
223
// committed to have a ledger version
177
224
//
@@ -185,6 +232,11 @@ type AptosRpcClient interface {
185
232
// }
186
233
TransactionByVersion (version uint64 ) (data * api.CommittedTransaction , err error )
187
234
235
+ // PollForTransaction waits up to 10 seconds for a transaction to be done, polling at 10Hz
236
+ // Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
237
+ // Not just a degenerate case of PollForTransactions, it may return additional information for the single transaction polled.
238
+ PollForTransaction (hash string , options ... any ) (* api.UserTransaction , error )
239
+
188
240
// PollForTransactions Waits up to 10 seconds for transactions to be done, polling at 10Hz
189
241
// Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
190
242
//
@@ -609,6 +661,11 @@ func (client *Client) TransactionByHash(txnHash string) (data *api.Transaction,
609
661
return client .nodeClient .TransactionByHash (txnHash )
610
662
}
611
663
664
+ // WaitTransactionByHash waits for a transaction to complete and returns it's data when finished.
665
+ func (client * Client ) WaitTransactionByHash (txnHash string ) (data * api.Transaction , err error ) {
666
+ return client .nodeClient .WaitTransactionByHash (txnHash )
667
+ }
668
+
612
669
// TransactionByVersion gets info on a transaction from its LedgerVersion. It must have been
613
670
// committed to have a ledger version
614
671
//
@@ -624,6 +681,11 @@ func (client *Client) TransactionByVersion(version uint64) (data *api.CommittedT
624
681
return client .nodeClient .TransactionByVersion (version )
625
682
}
626
683
684
+ // PollForTransaction Waits up to 10 seconds for as single transaction to be done, polling at 10Hz
685
+ func (client * Client ) PollForTransaction (hash string , options ... any ) (* api.UserTransaction , error ) {
686
+ return client .nodeClient .PollForTransaction (hash , options ... )
687
+ }
688
+
627
689
// PollForTransactions Waits up to 10 seconds for transactions to be done, polling at 10Hz
628
690
// Accepts options PollPeriod and PollTimeout which should wrap time.Duration values.
629
691
//
0 commit comments