diff --git a/src/accountManagement/accountController.ts b/src/accountManagement/accountController.ts index 8e28ea85..f34ddeb4 100644 --- a/src/accountManagement/accountController.ts +++ b/src/accountManagement/accountController.ts @@ -1,5 +1,5 @@ import { IAccount } from "../accounts/interfaces"; -import { Address, BaseController } from "../core"; +import { Address, BaseController, BaseControllerInput } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig"; import { AccountTransactionsFactory } from "./accountTransactionsFactory"; @@ -18,14 +18,14 @@ export class AccountController extends BaseController { async createTransactionForSavingKeyValue( sender: IAccount, nonce: bigint, - options: SaveKeyValueInput & { guardian?: Address; relayer?: Address }, + options: SaveKeyValueInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSavingKeyValue(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -34,14 +34,14 @@ export class AccountController extends BaseController { async createTransactionForSettingGuardian( sender: IAccount, nonce: bigint, - options: SetGuardianInput & { guardian?: Address; relayer?: Address }, + options: SetGuardianInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingGuardian(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -50,12 +50,12 @@ export class AccountController extends BaseController { async createTransactionForGuardingAccount( sender: IAccount, nonce: bigint, - options: { relayer?: Address }, + options: { relayer?: Address; gasPrice?: bigint; gasLimit?: bigint }, ): Promise { const transaction = this.factory.createTransactionForGuardingAccount(sender.address); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -64,14 +64,14 @@ export class AccountController extends BaseController { async createTransactionForUnguardingAccount( sender: IAccount, nonce: bigint, - options: { guardian: Address; relayer?: Address }, + options: BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnguardingAccount(sender.address); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; diff --git a/src/core/baseController.ts b/src/core/baseController.ts index 43db3b19..56fc8cdf 100644 --- a/src/core/baseController.ts +++ b/src/core/baseController.ts @@ -1,8 +1,27 @@ -import { Transaction } from "../core/transaction"; +import { Address } from "./address"; import { EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS, EXTRA_GAS_LIMIT_FOR_RELAYED_TRANSACTIONS } from "./constants"; +import { Transaction } from "./transaction"; + +export type BaseControllerInput = { + guardian?: Address; + relayer?: Address; + gasPrice?: bigint; + gasLimit?: bigint; +}; export class BaseController { - addExtraGasLimitIfRequired(transaction: Transaction): void { + protected setTransactionGasOptions(transaction: Transaction, options: { gasLimit?: bigint; gasPrice?: bigint }) { + if (options.gasLimit) { + transaction.gasLimit = options.gasLimit; + } else { + this.addExtraGasLimitIfRequired(transaction); + } + if (options.gasPrice) { + transaction.gasPrice = options.gasPrice; + } + } + + protected addExtraGasLimitIfRequired(transaction: Transaction): void { if (transaction.guardian && !transaction.guardian.isEmpty()) { transaction.gasLimit += BigInt(EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS); } diff --git a/src/delegation/delegationController.ts b/src/delegation/delegationController.ts index d40559d8..ecba3f98 100644 --- a/src/delegation/delegationController.ts +++ b/src/delegation/delegationController.ts @@ -1,5 +1,5 @@ import { IAccount } from "../accounts/interfaces"; -import { Address, BaseController } from "../core"; +import { Address, BaseController, BaseControllerInput } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionOnNetwork } from "../core/transactionOnNetwork"; import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig"; @@ -26,14 +26,14 @@ export class DelegationController extends BaseController { async createTransactionForNewDelegationContract( sender: IAccount, nonce: bigint, - options: resources.NewDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.NewDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForNewDelegationContract(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -51,14 +51,14 @@ export class DelegationController extends BaseController { async createTransactionForAddingNodes( sender: IAccount, nonce: bigint, - options: resources.AddNodesInput & { guardian?: Address; relayer?: Address }, + options: resources.AddNodesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForAddingNodes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -67,14 +67,14 @@ export class DelegationController extends BaseController { async createTransactionForRemovingNodes( sender: IAccount, nonce: bigint, - options: resources.ManageNodesInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageNodesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForRemovingNodes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -83,14 +83,14 @@ export class DelegationController extends BaseController { async createTransactionForStakingNodes( sender: IAccount, nonce: bigint, - options: resources.ManageNodesInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageNodesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForStakingNodes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -99,14 +99,14 @@ export class DelegationController extends BaseController { async createTransactionForUnbondingNodes( sender: IAccount, nonce: bigint, - options: resources.ManageNodesInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageNodesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnbondingNodes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -115,14 +115,14 @@ export class DelegationController extends BaseController { async createTransactionForUnstakingNodes( sender: IAccount, nonce: bigint, - options: resources.ManageNodesInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageNodesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnstakingNodes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -131,14 +131,14 @@ export class DelegationController extends BaseController { async createTransactionForUnjailingNodes( sender: IAccount, nonce: bigint, - options: resources.UnjailingNodesInput & { guardian?: Address; relayer?: Address }, + options: resources.UnjailingNodesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnjailingNodes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -147,14 +147,14 @@ export class DelegationController extends BaseController { async createTransactionForChangingServiceFee( sender: IAccount, nonce: bigint, - options: resources.ChangeServiceFee & { guardian?: Address; relayer?: Address }, + options: resources.ChangeServiceFee & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForChangingServiceFee(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -163,14 +163,14 @@ export class DelegationController extends BaseController { async createTransactionForModifyingDelegationCap( sender: IAccount, nonce: bigint, - options: resources.ModifyDelegationCapInput & { guardian?: Address; relayer?: Address }, + options: resources.ModifyDelegationCapInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForModifyingDelegationCap(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -179,14 +179,14 @@ export class DelegationController extends BaseController { async createTransactionForSettingAutomaticActivation( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingAutomaticActivation(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -195,14 +195,14 @@ export class DelegationController extends BaseController { async createTransactionForUnsettingAutomaticActivation( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingAutomaticActivation(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -211,7 +211,7 @@ export class DelegationController extends BaseController { async createTransactionForSettingCapCheckOnRedelegateRewards( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingCapCheckOnRedelegateRewards( sender.address, @@ -221,7 +221,7 @@ export class DelegationController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -230,7 +230,7 @@ export class DelegationController extends BaseController { async createTransactionForUnsettingCapCheckOnRedelegateRewards( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingCapCheckOnRedelegateRewards( sender.address, @@ -240,7 +240,7 @@ export class DelegationController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -249,14 +249,14 @@ export class DelegationController extends BaseController { async createTransactionForSettingMetadata( sender: IAccount, nonce: bigint, - options: resources.SetContractMetadataInput & { guardian?: Address; relayer?: Address }, + options: resources.SetContractMetadataInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingMetadata(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -265,14 +265,14 @@ export class DelegationController extends BaseController { async createTransactionForDelegating( sender: IAccount, nonce: bigint, - options: resources.DelegateActionsInput & { guardian?: Address; relayer?: Address }, + options: resources.DelegateActionsInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForDelegating(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -281,14 +281,14 @@ export class DelegationController extends BaseController { async createTransactionForClaimingRewards( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForClaimingRewards(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -297,14 +297,14 @@ export class DelegationController extends BaseController { async createTransactionForRedelegatingRewards( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForRedelegatingRewards(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -313,14 +313,14 @@ export class DelegationController extends BaseController { async createTransactionForUndelegating( sender: IAccount, nonce: bigint, - options: resources.DelegateActionsInput & { guardian?: Address; relayer?: Address }, + options: resources.DelegateActionsInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUndelegating(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -329,7 +329,7 @@ export class DelegationController extends BaseController { async createTransactionForWithdrawing( sender: IAccount, nonce: bigint, - options: resources.ManageDelegationContractInput & { guardian?: Address; relayer?: Address }, + options: resources.ManageDelegationContractInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForWithdrawing(sender.address, options); @@ -337,7 +337,7 @@ export class DelegationController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; diff --git a/src/entrypoints/entrypoints.spec.ts b/src/entrypoints/entrypoints.spec.ts index e06d617e..5febc135 100644 --- a/src/entrypoints/entrypoints.spec.ts +++ b/src/entrypoints/entrypoints.spec.ts @@ -31,6 +31,31 @@ describe("TestEntrypoint", function () { ); }); + it("native transfer with gas options", async () => { + const controller = entrypoint.createTransfersController(); + const filePath = path.join("src", "testdata", "testwallets", "alice.pem"); + const sender = await Account.newFromPem(filePath); + sender.nonce = 77777n; + + const gasLimit = BigInt(50000); + const gasPrice = BigInt(1000); + + const transaction = await controller.createTransactionForTransfer( + sender, + BigInt(sender.getNonceThenIncrement().valueOf()), + { + receiver: sender.address, + nativeAmount: BigInt(0), + data: Buffer.from("hello"), + gasLimit: gasLimit, + gasPrice: gasPrice, + }, + ); + + assert.equal(transaction.gasLimit, gasLimit, "Gas limit should be set correctly"); + assert.equal(transaction.gasPrice, gasPrice, "Gas price should be set correctly"); + }); + it("native transfer with guardian and relayer", async () => { const controller = entrypoint.createTransfersController(); const filePath = path.join("src", "testdata", "testwallets"); diff --git a/src/smartContracts/smartContractController.ts b/src/smartContracts/smartContractController.ts index a9cb9649..c5810c81 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, BaseController } from "../core"; +import { Address, BaseController, BaseControllerInput } from "../core"; import { Err, ErrSmartContractQuery } from "../core/errors"; import { SmartContractQuery, SmartContractQueryInput, SmartContractQueryResponse } from "../core/smartContractQuery"; import { Transaction } from "../core/transaction"; @@ -34,14 +34,14 @@ export class SmartContractController extends BaseController { async createTransactionForDeploy( sender: IAccount, nonce: bigint, - options: resources.ContractDeployInput & { guardian?: Address; relayer?: Address }, + options: resources.ContractDeployInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForDeploy(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -59,14 +59,14 @@ export class SmartContractController extends BaseController { async createTransactionForUpgrade( sender: IAccount, nonce: bigint, - options: resources.ContractUpgradeInput & { guardian?: Address; relayer?: Address }, + options: resources.ContractUpgradeInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUpgrade(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -75,14 +75,14 @@ export class SmartContractController extends BaseController { async createTransactionForExecute( sender: IAccount, nonce: bigint, - options: resources.ContractExecuteInput & { guardian?: Address; relayer?: Address }, + options: resources.ContractExecuteInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForExecute(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; diff --git a/src/tokenManagement/tokenManagementController.ts b/src/tokenManagement/tokenManagementController.ts index b77cf706..947e84e6 100644 --- a/src/tokenManagement/tokenManagementController.ts +++ b/src/tokenManagement/tokenManagementController.ts @@ -1,5 +1,5 @@ import { IAccount } from "../accounts/interfaces"; -import { Address, BaseController } from "../core"; +import { Address, BaseController, BaseControllerInput } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionOnNetwork } from "../core/transactionOnNetwork"; import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig"; @@ -26,14 +26,14 @@ export class TokenManagementController extends BaseController { async createTransactionForIssuingFungible( sender: IAccount, nonce: bigint, - options: resources.IssueFungibleInput & { guardian?: Address; relayer?: Address }, + options: resources.IssueFungibleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForIssuingFungible(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -51,14 +51,14 @@ export class TokenManagementController extends BaseController { async createTransactionForIssuingSemiFungible( sender: IAccount, nonce: bigint, - options: resources.IssueSemiFungibleInput & { guardian?: Address; relayer?: Address }, + options: resources.IssueSemiFungibleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForIssuingSemiFungible(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -76,14 +76,14 @@ export class TokenManagementController extends BaseController { async createTransactionForIssuingNonFungible( sender: IAccount, nonce: bigint, - options: resources.IssueNonFungibleInput & { guardian?: Address; relayer?: Address }, + options: resources.IssueNonFungibleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForIssuingNonFungible(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -101,14 +101,14 @@ export class TokenManagementController extends BaseController { async createTransactionForRegisteringMetaEsdt( sender: IAccount, nonce: bigint, - options: resources.RegisterMetaESDTInput & { guardian?: Address; relayer?: Address }, + options: resources.RegisterMetaESDTInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForRegisteringMetaESDT(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -126,14 +126,14 @@ export class TokenManagementController extends BaseController { async createTransactionForRegisteringAndSettingRoles( sender: IAccount, nonce: bigint, - options: resources.RegisterRolesInput & { guardian?: Address; relayer?: Address }, + options: resources.RegisterRolesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForRegisteringAndSettingRoles(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -151,14 +151,14 @@ export class TokenManagementController extends BaseController { async createTransactionForSetBurnRoleGlobally( sender: IAccount, nonce: bigint, - options: resources.BurnRoleGloballyInput & { guardian?: Address; relayer?: Address }, + options: resources.BurnRoleGloballyInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingBurnRoleGlobally(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -176,14 +176,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUnsettingBurnRoleGlobally( sender: IAccount, nonce: bigint, - options: resources.BurnRoleGloballyInput & { guardian?: Address; relayer?: Address }, + options: resources.BurnRoleGloballyInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingBurnRoleGlobally(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -201,14 +201,14 @@ export class TokenManagementController extends BaseController { async createTransactionForSettingSpecialRoleOnFungibleToken( sender: IAccount, nonce: bigint, - options: resources.FungibleSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.FungibleSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingSpecialRoleOnFungibleToken(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -226,7 +226,7 @@ export class TokenManagementController extends BaseController { async createTransactionForUnsettingSpecialRoleOnFungibleToken( sender: IAccount, nonce: bigint, - options: resources.UnsetFungibleSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.UnsetFungibleSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingSpecialRoleOnFungibleToken( sender.address, @@ -236,7 +236,7 @@ export class TokenManagementController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -245,7 +245,7 @@ export class TokenManagementController extends BaseController { async createTransactionForSettingSpecialRoleOnSemiFungibleToken( sender: IAccount, nonce: bigint, - options: resources.SemiFungibleSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.SemiFungibleSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingSpecialRoleOnSemiFungibleToken( sender.address, @@ -255,7 +255,7 @@ export class TokenManagementController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -273,7 +273,7 @@ export class TokenManagementController extends BaseController { async createTransactionForUnsettingSpecialRoleOnSemiFungibleToken( sender: IAccount, nonce: bigint, - options: resources.UnsetSemiFungibleSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.UnsetSemiFungibleSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingSpecialRoleOnSemiFungibleToken( sender.address, @@ -283,7 +283,7 @@ export class TokenManagementController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -292,14 +292,14 @@ export class TokenManagementController extends BaseController { async createTransactionForSettingSpecialRoleOnMetaESDT( sender: IAccount, nonce: bigint, - options: resources.SemiFungibleSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.SemiFungibleSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingSpecialRoleOnMetaESDT(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -317,14 +317,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUnsettingSpecialRoleOnMetaESDT( sender: IAccount, nonce: bigint, - options: resources.UnsetSemiFungibleSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.UnsetSemiFungibleSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingSpecialRoleOnMetaESDT(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -333,7 +333,7 @@ export class TokenManagementController extends BaseController { async createTransactionForSettingSpecialRoleOnNonFungibleToken( sender: IAccount, nonce: bigint, - options: resources.SpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.SpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingSpecialRoleOnNonFungibleToken( sender.address, @@ -343,7 +343,7 @@ export class TokenManagementController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -361,7 +361,7 @@ export class TokenManagementController extends BaseController { async createTransactionForUnsettingSpecialRoleOnNonFungibleToken( sender: IAccount, nonce: bigint, - options: resources.UnsetSpecialRoleInput & { guardian?: Address; relayer?: Address }, + options: resources.UnsetSpecialRoleInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnsettingSpecialRoleOnNonFungibleToken( sender.address, @@ -371,7 +371,7 @@ export class TokenManagementController extends BaseController { transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -380,14 +380,14 @@ export class TokenManagementController extends BaseController { async createTransactionForCreatingNft( sender: IAccount, nonce: bigint, - options: resources.MintInput & { guardian?: Address; relayer?: Address }, + options: resources.MintInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForCreatingNFT(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -405,14 +405,14 @@ export class TokenManagementController extends BaseController { async createTransactionForPausing( sender: IAccount, nonce: bigint, - options: resources.PausingInput & { guardian?: Address; relayer?: Address }, + options: resources.PausingInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForPausing(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -430,14 +430,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUnpausing( sender: IAccount, nonce: bigint, - options: resources.PausingInput & { guardian?: Address; relayer?: Address }, + options: resources.PausingInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnpausing(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -455,14 +455,14 @@ export class TokenManagementController extends BaseController { async createTransactionForFreezing( sender: IAccount, nonce: bigint, - options: resources.ManagementInput & { guardian?: Address; relayer?: Address }, + options: resources.ManagementInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForFreezing(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -480,14 +480,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUnFreezing( sender: IAccount, nonce: bigint, - options: resources.ManagementInput & { guardian?: Address; relayer?: Address }, + options: resources.ManagementInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUnfreezing(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -505,14 +505,14 @@ export class TokenManagementController extends BaseController { async createTransactionForWiping( sender: IAccount, nonce: bigint, - options: resources.ManagementInput & { guardian?: Address; relayer?: Address }, + options: resources.ManagementInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForWiping(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -530,14 +530,14 @@ export class TokenManagementController extends BaseController { async createTransactionForLocaMinting( sender: IAccount, nonce: bigint, - options: resources.LocalMintInput & { guardian?: Address; relayer?: Address }, + options: resources.LocalMintInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForLocalMint(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -555,14 +555,14 @@ export class TokenManagementController extends BaseController { async createTransactionForLocalBurning( sender: IAccount, nonce: bigint, - options: resources.LocalBurnInput & { guardian?: Address; relayer?: Address }, + options: resources.LocalBurnInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForLocalBurning(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -580,14 +580,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUpdatingAttributes( sender: IAccount, nonce: bigint, - options: resources.UpdateAttributesInput & { guardian?: Address; relayer?: Address }, + options: resources.UpdateAttributesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUpdatingAttributes(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -605,14 +605,14 @@ export class TokenManagementController extends BaseController { async createTransactionForAddingQuantity( sender: IAccount, nonce: bigint, - options: resources.UpdateQuantityInput & { guardian?: Address; relayer?: Address }, + options: resources.UpdateQuantityInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForAddingQuantity(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -630,14 +630,14 @@ export class TokenManagementController extends BaseController { async createTransactionForBurningQuantity( sender: IAccount, nonce: bigint, - options: resources.UpdateQuantityInput & { guardian?: Address; relayer?: Address }, + options: resources.UpdateQuantityInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForBurningQuantity(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -655,14 +655,14 @@ export class TokenManagementController extends BaseController { async createTransactionForModifyingRoyalties( sender: IAccount, nonce: bigint, - options: resources.ModifyRoyaltiesInput & { guardian?: Address; relayer?: Address }, + options: resources.ModifyRoyaltiesInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForModifyingRoyalties(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -680,14 +680,14 @@ export class TokenManagementController extends BaseController { async createTransactionForSettingNewUris( sender: IAccount, nonce: bigint, - options: resources.SetNewUriInput & { guardian?: Address; relayer?: Address }, + options: resources.SetNewUriInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForSettingNewUris(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -705,14 +705,14 @@ export class TokenManagementController extends BaseController { async createTransactionForModifyingCreator( sender: IAccount, nonce: bigint, - options: resources.SetNewUriInput & { guardian?: Address; relayer?: Address }, + options: resources.SetNewUriInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForModifyingCreator(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -730,14 +730,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUpdatingMetadata( sender: IAccount, nonce: bigint, - options: resources.SetNewUriInput & { guardian?: Address; relayer?: Address }, + options: resources.SetNewUriInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForModifyingCreator(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -755,14 +755,14 @@ export class TokenManagementController extends BaseController { async createTransactionForMetadataRecreate( sender: IAccount, nonce: bigint, - options: resources.SetNewUriInput & { guardian?: Address; relayer?: Address }, + options: resources.SetNewUriInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForMetadataRecreate(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -780,14 +780,14 @@ export class TokenManagementController extends BaseController { async createTransactionForChangingTokenToDynamic( sender: IAccount, nonce: bigint, - options: resources.SetNewUriInput & { guardian?: Address; relayer?: Address }, + options: resources.SetNewUriInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForChangingTokenToDynamic(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -805,14 +805,14 @@ export class TokenManagementController extends BaseController { async createTransactionForUpdatingTokenId( sender: IAccount, nonce: bigint, - options: resources.UpdateTokenIDInput & { guardian?: Address; relayer?: Address }, + options: resources.UpdateTokenIDInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForUpdatingTokenId(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -826,14 +826,14 @@ export class TokenManagementController extends BaseController { async createTransactionForRegisteringDynamicToken( sender: IAccount, nonce: bigint, - options: resources.RegisteringDynamicTokenInput & { guardian?: Address; relayer?: Address }, + options: resources.RegisteringDynamicTokenInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForRegisteringDynamicToken(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -851,14 +851,14 @@ export class TokenManagementController extends BaseController { async createTransactionForRegisteringDynamicTokenAndSettingRoles( sender: IAccount, nonce: bigint, - options: resources.RegisteringDynamicTokenInput & { guardian?: Address; relayer?: Address }, + options: resources.RegisteringDynamicTokenInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForRegisteringDynamicAndSettingRoles(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; diff --git a/src/transfers/transfersControllers.ts b/src/transfers/transfersControllers.ts index 099be124..6c323d38 100644 --- a/src/transfers/transfersControllers.ts +++ b/src/transfers/transfersControllers.ts @@ -1,5 +1,5 @@ import { IAccount } from "../accounts/interfaces"; -import { Address, BaseController } from "../core"; +import { Address, BaseController, BaseControllerInput } from "../core"; import { Transaction } from "../core/transaction"; import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig"; import * as resources from "./resources"; @@ -16,14 +16,14 @@ export class TransfersController extends BaseController { async createTransactionForNativeTokenTransfer( sender: IAccount, nonce: bigint, - options: resources.NativeTokenTransferInput & { guardian?: Address; relayer?: Address }, + options: resources.NativeTokenTransferInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForNativeTokenTransfer(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -32,14 +32,14 @@ export class TransfersController extends BaseController { async createTransactionForEsdtTokenTransfer( sender: IAccount, nonce: bigint, - options: resources.CustomTokenTransferInput & { guardian?: Address; relayer?: Address }, + options: resources.CustomTokenTransferInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForESDTTokenTransfer(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction; @@ -48,14 +48,14 @@ export class TransfersController extends BaseController { async createTransactionForTransfer( sender: IAccount, nonce: bigint, - options: resources.CreateTransferTransactionInput & { guardian?: Address; relayer?: Address }, + options: resources.CreateTransferTransactionInput & BaseControllerInput, ): Promise { const transaction = this.factory.createTransactionForTransfer(sender.address, options); transaction.guardian = options.guardian ?? Address.empty(); transaction.relayer = options.relayer ?? Address.empty(); transaction.nonce = nonce; - this.addExtraGasLimitIfRequired(transaction); + this.setTransactionGasOptions(transaction, options); transaction.signature = await sender.signTransaction(transaction); return transaction;