From da2ffe8cb5c43447b78d3f5748136148ecdb0449 Mon Sep 17 00:00:00 2001 From: danielailie Date: Wed, 5 Mar 2025 17:05:34 +0200 Subject: [PATCH] Add extra gas in case we have relayer and guardian --- src/accountManagement/accountController.ts | 9 +++-- src/core/baseController.ts | 14 ++++++++ src/core/constants.ts | 2 ++ src/core/index.ts | 1 + src/delegation/delegationController.ts | 24 +++++++++++-- src/smartContracts/smartContractController.ts | 8 +++-- .../tokenManagementController.ts | 35 +++++++++++++++++-- src/transfers/transfersControllers.ts | 8 +++-- 8 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 src/core/baseController.ts diff --git a/src/accountManagement/accountController.ts b/src/accountManagement/accountController.ts index e4cb9c455..00599fba4 100644 --- a/src/accountManagement/accountController.ts +++ b/src/accountManagement/accountController.ts @@ -1,16 +1,17 @@ import { IAccount } from "../accounts/interfaces"; -import { Address } from "../core"; +import { Address, BaseController } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionComputer } from "../core/transactionComputer"; import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig"; import { AccountTransactionsFactory } from "./accountTransactionsFactory"; import { SaveKeyValueInput, SetGuardianInput } from "./resources"; -export class AccountController { +export class AccountController extends BaseController { private factory: AccountTransactionsFactory; private txComputer: TransactionComputer; constructor(options: { chainID: string }) { + super(); this.factory = new AccountTransactionsFactory({ config: new TransactionsFactoryConfig(options), }); @@ -27,6 +28,7 @@ export class AccountController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -42,6 +44,7 @@ export class AccountController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -55,6 +58,7 @@ export class AccountController { const transaction = this.factory.createTransactionForGuardingAccount(sender.address); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -70,6 +74,7 @@ export class AccountController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; diff --git a/src/core/baseController.ts b/src/core/baseController.ts new file mode 100644 index 000000000..43db3b191 --- /dev/null +++ b/src/core/baseController.ts @@ -0,0 +1,14 @@ +import { Transaction } from "../core/transaction"; +import { EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS, EXTRA_GAS_LIMIT_FOR_RELAYED_TRANSACTIONS } from "./constants"; + +export class BaseController { + addExtraGasLimitIfRequired(transaction: Transaction): void { + if (transaction.guardian && !transaction.guardian.isEmpty()) { + transaction.gasLimit += BigInt(EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS); + } + + if (transaction.relayer && !transaction.relayer.isEmpty()) { + transaction.gasLimit += BigInt(EXTRA_GAS_LIMIT_FOR_RELAYED_TRANSACTIONS); + } + } +} diff --git a/src/core/constants.ts b/src/core/constants.ts index d62de0fa7..765ed156c 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -26,3 +26,5 @@ export const SDK_JS_SIGNER = "sdk-js"; export const UNKNOWN_SIGNER = "unknown"; export const EGLD_IDENTIFIER_FOR_MULTI_ESDTNFT_TRANSFER = "EGLD-000000"; +export const EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS = 50_000; +export const EXTRA_GAS_LIMIT_FOR_RELAYED_TRANSACTIONS = 50_000; diff --git a/src/core/index.ts b/src/core/index.ts index ce95f33f4..72d825d07 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -2,6 +2,7 @@ require("./globals"); export * from "./address"; export * from "./asyncTimer"; +export * from "./baseController"; export * from "./config"; export * from "./errors"; export * from "./interface"; diff --git a/src/delegation/delegationController.ts b/src/delegation/delegationController.ts index f0c0f0f3e..1392d3986 100644 --- a/src/delegation/delegationController.ts +++ b/src/delegation/delegationController.ts @@ -1,5 +1,5 @@ import { IAccount } from "../accounts/interfaces"; -import { Address } from "../core"; +import { Address, BaseController } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionComputer } from "../core/transactionComputer"; import { TransactionOnNetwork } from "../core/transactionOnNetwork"; @@ -10,13 +10,14 @@ import { DelegationTransactionsFactory } from "./delegationTransactionsFactory"; import { DelegationTransactionsOutcomeParser } from "./delegationTransactionsOutcomeParser"; import * as resources from "./resources"; -export class DelegationController { +export class DelegationController extends BaseController { private transactionAwaiter: TransactionWatcher; private factory: DelegationTransactionsFactory; private parser: DelegationTransactionsOutcomeParser; private txComputer: TransactionComputer; constructor(options: { chainID: string; networkProvider: INetworkProvider }) { + super(); this.transactionAwaiter = new TransactionWatcher(options.networkProvider); this.factory = new DelegationTransactionsFactory({ config: new TransactionsFactoryConfig({ chainID: options.chainID }), @@ -35,6 +36,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -59,6 +61,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -74,6 +77,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -89,6 +93,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -104,6 +109,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -119,6 +125,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -134,6 +141,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -149,6 +157,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -164,6 +173,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -179,6 +189,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -194,6 +205,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -212,6 +224,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -230,6 +243,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -245,6 +259,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -260,6 +275,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -275,6 +291,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -290,6 +307,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -305,6 +323,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -321,6 +340,7 @@ export class DelegationController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; diff --git a/src/smartContracts/smartContractController.ts b/src/smartContracts/smartContractController.ts index fd370f410..e36551243 100644 --- a/src/smartContracts/smartContractController.ts +++ b/src/smartContracts/smartContractController.ts @@ -1,6 +1,6 @@ import { Abi, ArgSerializer, isTyped, NativeSerializer } from "../abi"; import { IAccount } from "../accounts/interfaces"; -import { Address } from "../core"; +import { Address, BaseController } from "../core"; import { Err, ErrSmartContractQuery } from "../core/errors"; import { SmartContractQuery, SmartContractQueryInput, SmartContractQueryResponse } from "../core/smartContractQuery"; import { Transaction } from "../core/transaction"; @@ -13,7 +13,7 @@ import { SmartContractTransactionsOutcomeParser } from "../transactionsOutcomePa import * as resources from "./resources"; import { SmartContractTransactionsFactory } from "./smartContractTransactionsFactory"; -export class SmartContractController { +export class SmartContractController extends BaseController { private factory: SmartContractTransactionsFactory; private parser: SmartContractTransactionsOutcomeParser; private transactionWatcher: TransactionWatcher; @@ -22,6 +22,7 @@ export class SmartContractController { private abi?: Abi; constructor(options: { chainID: string; networkProvider: INetworkProvider; abi?: Abi }) { + super(); this.factory = new SmartContractTransactionsFactory({ config: new TransactionsFactoryConfig({ chainID: options.chainID }), abi: options.abi, @@ -43,6 +44,7 @@ export class SmartContractController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -67,6 +69,7 @@ export class SmartContractController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -82,6 +85,7 @@ export class SmartContractController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; diff --git a/src/tokenManagement/tokenManagementController.ts b/src/tokenManagement/tokenManagementController.ts index e63821477..da006224f 100644 --- a/src/tokenManagement/tokenManagementController.ts +++ b/src/tokenManagement/tokenManagementController.ts @@ -1,5 +1,5 @@ import { IAccount } from "../accounts/interfaces"; -import { Address } from "../core"; +import { Address, BaseController } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionComputer } from "../core/transactionComputer"; import { TransactionOnNetwork } from "../core/transactionOnNetwork"; @@ -10,13 +10,14 @@ import { TokenManagementTransactionsOutcomeParser } from "../transactionsOutcome import * as resources from "./resources"; import { TokenManagementTransactionsFactory } from "./tokenManagementTransactionsFactory"; -export class TokenManagementController { +export class TokenManagementController extends BaseController { private factory: TokenManagementTransactionsFactory; private transactionAwaiter: TransactionWatcher; private txComputer: TransactionComputer; private parser: TokenManagementTransactionsOutcomeParser; constructor(options: { chainID: string; networkProvider: INetworkProvider }) { + super(); this.factory = new TokenManagementTransactionsFactory({ config: new TransactionsFactoryConfig({ chainID: options.chainID }), }); @@ -35,6 +36,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -59,6 +61,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -83,6 +86,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -107,6 +111,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -131,6 +136,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -155,6 +161,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -179,6 +186,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -203,6 +211,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -230,6 +239,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -257,6 +267,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -281,6 +292,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -305,6 +317,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -329,6 +342,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -353,6 +367,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -377,6 +392,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -401,6 +417,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -425,6 +442,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -449,6 +467,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -473,6 +492,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -497,6 +517,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -521,6 +542,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -545,6 +567,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -569,6 +592,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -593,6 +617,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -617,6 +642,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -641,6 +667,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -665,6 +692,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -689,6 +717,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -709,6 +738,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -733,6 +763,7 @@ export class TokenManagementController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; diff --git a/src/transfers/transfersControllers.ts b/src/transfers/transfersControllers.ts index 55f5d446d..f06f68bef 100644 --- a/src/transfers/transfersControllers.ts +++ b/src/transfers/transfersControllers.ts @@ -1,16 +1,17 @@ import { IAccount } from "../accounts/interfaces"; -import { Address } from "../core"; +import { Address, BaseController } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionComputer } from "../core/transactionComputer"; import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig"; import * as resources from "./resources"; import { TransferTransactionsFactory } from "./transferTransactionsFactory"; -export class TransfersController { +export class TransfersController extends BaseController { private factory: TransferTransactionsFactory; private txComputer: TransactionComputer; constructor(options: { chainID: string }) { + super(); this.factory = new TransferTransactionsFactory({ config: new TransactionsFactoryConfig(options) }); this.txComputer = new TransactionComputer(); } @@ -25,6 +26,7 @@ export class TransfersController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -40,6 +42,7 @@ export class TransfersController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction; @@ -55,6 +58,7 @@ export class TransfersController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; + this.addExtraGasLimitIfRequired(transaction); transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction)); return transaction;