Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-core",
"version": "15.2.0",
"version": "15.2.1",
"description": "MultiversX SDK for JavaScript and TypeScript",
"author": "MultiversX",
"homepage": "https://multiversx.com",
Expand Down
56 changes: 28 additions & 28 deletions src/core/baseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,11 @@ export type BaseControllerInput = {
};

export class BaseController {
private gasLimitEstimator?: IGasLimitEstimator;
readonly gasLimitEstimator?: IGasLimitEstimator;
constructor(options?: { gasLimitEstimator?: IGasLimitEstimator }) {
this.gasLimitEstimator = options?.gasLimitEstimator;
}

protected async setTransactionGasOptions(
transaction: Transaction,
options: { gasLimit?: bigint; gasPrice?: bigint },
) {
if (options.gasPrice) {
transaction.gasPrice = options.gasPrice;
}

if (options.gasLimit) {
transaction.gasLimit = options.gasLimit;
return;
} else {
this.addExtraGasLimitIfRequired(transaction);
}

if (this.gasLimitEstimator) {
transaction.gasLimit = await this.gasLimitEstimator.estimateGasLimit({ transaction });
}
}

protected addExtraGasLimitIfRequired(transaction: Transaction): void {
if (transaction.guardian && !transaction.guardian.isEmpty()) {
transaction.gasLimit += BigInt(EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS);
Expand All @@ -47,13 +27,6 @@ export class BaseController {
}
}

protected setVersionAndOptionsForGuardian(transaction: Transaction): void {
if (transaction.guardian && !transaction.guardian.isEmpty()) {
const txComputer = new TransactionComputer();
txComputer.applyGuardian(transaction, transaction.guardian);
}
}

protected async setupAndSignTransaction(
transaction: Transaction,
options: BaseControllerInput,
Expand All @@ -67,4 +40,31 @@ export class BaseController {
await this.setTransactionGasOptions(transaction, options);
transaction.signature = await sender.signTransaction(transaction);
}

protected setVersionAndOptionsForGuardian(transaction: Transaction): void {
if (transaction.guardian && !transaction.guardian.isEmpty()) {
const txComputer = new TransactionComputer();
txComputer.applyGuardian(transaction, transaction.guardian);
}
}

protected async setTransactionGasOptions(
transaction: Transaction,
options: { gasLimit?: bigint; gasPrice?: bigint },
) {
if (options.gasPrice) {
transaction.gasPrice = options.gasPrice;
}

if (options.gasLimit) {
transaction.gasLimit = options.gasLimit;
return;
}

this.addExtraGasLimitIfRequired(transaction);

if (this.gasLimitEstimator) {
transaction.gasLimit = await this.gasLimitEstimator.estimateGasLimit({ transaction });
}
}
}
2 changes: 1 addition & 1 deletion src/transfers/transfersController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("test transfers controller", function () {
grace = await Account.newFromPem(path.join(walletsPath, "grace.pem"));
});

it("should send relayed with ho native balance", async function () {
it("should send relayed with no native balance", async function () {
sender.nonce = await entrypoint.recallAccountNonce(sender.address);
const token = new Token({ identifier: "USDC-350c4e" });
const transfer = new TokenTransfer({ token: token, amount: 7n });
Expand Down
Loading