File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,20 @@ export const getSimulationComputeUnits = async (
43
43
lookupTables : Array < AddressLookupTableAccount > | [ ] ,
44
44
commitment : Commitment = "confirmed" ,
45
45
) : Promise < number | null > => {
46
- const testInstructions = [
47
- // Set an arbitrarily high number in simulation
48
- // so we can be sure the transaction will succeed
49
- // and get the real compute units used
50
- ComputeBudgetProgram . setComputeUnitLimit ( { units : 1_400_000 } ) ,
51
- ...instructions ,
52
- ] ;
46
+ const hasComputeInstructions = instructions . some (
47
+ ( ix : TransactionInstruction ) =>
48
+ ix . programId . equals ( ComputeBudgetProgram . programId ) ,
49
+ ) ;
50
+
51
+ const testInstructions = hasComputeInstructions
52
+ ? instructions
53
+ : [
54
+ // Set an arbitrarily high number in simulation
55
+ // so we can be sure the transaction will succeed
56
+ // and get the real compute units used
57
+ ComputeBudgetProgram . setComputeUnitLimit ( { units : 1_400_000 } ) ,
58
+ ...instructions ,
59
+ ] ;
53
60
54
61
const testTransaction = new VersionedTransaction (
55
62
new TransactionMessage ( {
You can’t perform that action at this time.
0 commit comments