@@ -11,7 +11,7 @@ import {
1111} from './utils' ;
1212import { BaseCoin as CoinConfig , SolCoin } from '@bitgo/statics' ;
1313import assert from 'assert' ;
14- import { AtaInit , TokenAssociateRecipient , TokenTransfer , Transfer } from './iface' ;
14+ import { AtaInit , TokenAssociateRecipient , TokenTransfer , Transfer , SetPriorityFee } from './iface' ;
1515import { InstructionBuilderTypes } from './constants' ;
1616import _ from 'lodash' ;
1717
@@ -167,8 +167,20 @@ export class TransferBuilderV2 extends TransactionBuilder {
167167 } ;
168168 } )
169169 ) ;
170- // order is important, createAtaInstructions must be before sendInstructions
171- this . _instructionsData = [ ...createAtaInstructions , ...sendInstructions ] ;
170+
171+ let addPriorityFeeInstruction : SetPriorityFee ;
172+ // If there are createAtaInstructions, then token is involved and we need to add a priority fee instruction
173+ if ( createAtaInstructions . length !== 0 ) {
174+ addPriorityFeeInstruction = {
175+ type : InstructionBuilderTypes . SetPriorityFee ,
176+ params : { } ,
177+ } ;
178+ this . _instructionsData = [ addPriorityFeeInstruction , ...createAtaInstructions , ...sendInstructions ] ;
179+ } else {
180+ // order is important, createAtaInstructions must be before sendInstructions
181+ this . _instructionsData = [ ...createAtaInstructions , ...sendInstructions ] ;
182+ }
183+
172184 return await super . buildImplementation ( ) ;
173185 }
174186}
0 commit comments