Skip to content

Commit

Permalink
Merge pull request #109 from GenesysGo/tracy/undefined-compute-units-…
Browse files Browse the repository at this point in the history
…check

Undefined compute units check
  • Loading branch information
tracy-codes authored Jun 8, 2024
2 parents 1b5c54d + 3dff183 commit 6ad8762
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shadow-drive/sdk",
"version": "5.1.0",
"version": "5.1.1",
"description": "Interfaces for GenesysGo ShadowDrive",
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
14 changes: 9 additions & 5 deletions src/methods/add-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ export default async function addStorage(
),
this.connection,
]);
txn.add(
web3.ComputeBudgetProgram.setComputeUnitLimit({
units: immutableUnits,
})
);
if (typeof immutableUnits !== "undefined") {
txn.add(
web3.ComputeBudgetProgram.setComputeUnitLimit({
units: immutableUnits,
})
);
}
txn.add(immutableComputePriceIx);
txn.add(increaseImmutableStorageIx);
break;
Expand Down Expand Up @@ -141,6 +143,8 @@ export default async function addStorage(
),
this.connection,
]);
if (typeof units !== "undefined") {
}
txn.add(
web3.ComputeBudgetProgram.setComputeUnitLimit({ units })
);
Expand Down
4 changes: 3 additions & 1 deletion src/methods/cancel-storage-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default async function cancelDeleteStorageAccount(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);

txn.add(unmarkDeleteAccountIx2);
Expand Down
4 changes: 3 additions & 1 deletion src/methods/claim-stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export default async function claimStake(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);
txn.add(claimStakeIx2);
let blockInfo = await this.connection.getLatestBlockhash();
Expand Down
4 changes: 3 additions & 1 deletion src/methods/create-storage-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export default async function createStorageAccount(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== undefined) {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);
txn.add(initializeAccountIx2);

Expand Down
4 changes: 3 additions & 1 deletion src/methods/delete-storage-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default async function deleteStorageAccount(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);

txn.add(reqDeleteAccountIx2);
Expand Down
4 changes: 3 additions & 1 deletion src/methods/make-storage-immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export default async function makeStorageImmutable(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);

txn.add(makeImmutableIx2);
Expand Down
4 changes: 3 additions & 1 deletion src/methods/reduce-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default async function reduceStorage(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);
txn.add(decreaseStorageIx2);

Expand Down
4 changes: 3 additions & 1 deletion src/methods/refresh-stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export default async function refreshStake(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);

txn.add(refreshStakeIx2);
Expand Down
4 changes: 3 additions & 1 deletion src/methods/top-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export default async function topUp(
),
this.connection,
]);
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
if (typeof units !== "undefined") {
txn.add(web3.ComputeBudgetProgram.setComputeUnitLimit({ units }));
}
txn.add(computePriceIx);

txn.add(transferInstruction);
Expand Down

0 comments on commit 6ad8762

Please sign in to comment.