@@ -10,7 +10,9 @@ import {
1010import { BaseCoin as CoinConfig } from '@bitgo/statics' ;
1111import {
1212 AccountAddress ,
13+ AccountAuthenticator ,
1314 AccountAuthenticatorEd25519 ,
15+ AccountAuthenticatorNoAccountAuthenticator ,
1416 DEFAULT_MAX_GAS_AMOUNT ,
1517 Ed25519PublicKey ,
1618 Ed25519Signature ,
@@ -44,6 +46,7 @@ export abstract class Transaction extends BaseTransaction {
4446 protected _expirationTime : number ;
4547 protected _feePayerAddress : string ;
4648 protected _assetId : string ;
49+ protected _isSimulateTxn : boolean ;
4750
4851 static EMPTY_PUBLIC_KEY = Buffer . alloc ( 32 ) ;
4952 static EMPTY_SIGNATURE = Buffer . alloc ( 64 ) ;
@@ -57,6 +60,7 @@ export abstract class Transaction extends BaseTransaction {
5760 this . _sequenceNumber = 0 ;
5861 this . _sender = AccountAddress . ZERO . toString ( ) ;
5962 this . _assetId = AccountAddress . ZERO . toString ( ) ;
63+ this . _isSimulateTxn = false ;
6064 this . _senderSignature = {
6165 publicKey : {
6266 pub : Hex . fromHexInput ( Transaction . EMPTY_PUBLIC_KEY ) . toString ( ) ,
@@ -150,6 +154,14 @@ export abstract class Transaction extends BaseTransaction {
150154 this . _assetId = value ;
151155 }
152156
157+ get isSimulateTxn ( ) : boolean {
158+ return this . _isSimulateTxn ;
159+ }
160+
161+ set isSimulateTxn ( value : boolean ) {
162+ this . _isSimulateTxn = value ;
163+ }
164+
153165 protected abstract buildRawTransaction ( ) : void ;
154166
155167 protected abstract parseTransactionPayload ( payload : TransactionPayload ) : void ;
@@ -196,17 +208,22 @@ export abstract class Transaction extends BaseTransaction {
196208 }
197209
198210 serialize ( ) : string {
199- const senderPublicKeyBuffer = utils . getBufferFromHexString ( this . _senderSignature . publicKey . pub ) ;
200- const senderPublicKey = new Ed25519PublicKey ( senderPublicKeyBuffer ) ;
201-
202- const senderSignature = new Ed25519Signature ( this . _senderSignature . signature ) ;
203- const senderAuthenticator = new AccountAuthenticatorEd25519 ( senderPublicKey , senderSignature ) ;
204-
205- const feePayerPublicKeyBuffer = utils . getBufferFromHexString ( this . _feePayerSignature . publicKey . pub ) ;
206- const feePayerPublicKey = new Ed25519PublicKey ( feePayerPublicKeyBuffer ) ;
207-
208- const feePayerSignature = new Ed25519Signature ( this . _feePayerSignature . signature ) ;
209- const feePayerAuthenticator = new AccountAuthenticatorEd25519 ( feePayerPublicKey , feePayerSignature ) ;
211+ let senderAuthenticator : AccountAuthenticator ;
212+ let feePayerAuthenticator : AccountAuthenticator ;
213+ if ( this . isSimulateTxn ) {
214+ senderAuthenticator = new AccountAuthenticatorNoAccountAuthenticator ( ) ;
215+ feePayerAuthenticator = new AccountAuthenticatorNoAccountAuthenticator ( ) ;
216+ } else {
217+ const senderPublicKeyBuffer = utils . getBufferFromHexString ( this . _senderSignature . publicKey . pub ) ;
218+ const senderPublicKey = new Ed25519PublicKey ( senderPublicKeyBuffer ) ;
219+ const senderSignature = new Ed25519Signature ( this . _senderSignature . signature ) ;
220+ senderAuthenticator = new AccountAuthenticatorEd25519 ( senderPublicKey , senderSignature ) ;
221+
222+ const feePayerPublicKeyBuffer = utils . getBufferFromHexString ( this . _feePayerSignature . publicKey . pub ) ;
223+ const feePayerPublicKey = new Ed25519PublicKey ( feePayerPublicKeyBuffer ) ;
224+ const feePayerSignature = new Ed25519Signature ( this . _feePayerSignature . signature ) ;
225+ feePayerAuthenticator = new AccountAuthenticatorEd25519 ( feePayerPublicKey , feePayerSignature ) ;
226+ }
210227
211228 const txnAuthenticator = new TransactionAuthenticatorFeePayer ( senderAuthenticator , [ ] , [ ] , {
212229 address : AccountAddress . fromString ( this . _feePayerAddress ) ,
0 commit comments