From b3b970162feee0c21bcf71cc6c4b8bf6dc1b1209 Mon Sep 17 00:00:00 2001 From: Rishabh Singh Date: Tue, 29 Jul 2025 12:51:07 +0530 Subject: [PATCH 1/2] chore: update types for gas values --- src/token-registry-functions/transfer.ts | 8 ++++---- src/token-registry-functions/types.ts | 2 +- src/token-registry-functions/utils.ts | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/token-registry-functions/transfer.ts b/src/token-registry-functions/transfer.ts index c0dc9a9..835543c 100644 --- a/src/token-registry-functions/transfer.ts +++ b/src/token-registry-functions/transfer.ts @@ -62,7 +62,7 @@ const transferHolder = async ( if (!titleEscrowAddress) throw new Error('Token registry address is required'); if (!signer.provider) throw new Error('Provider is required'); - const { holderAddress, remarks } = params; + const { newHolderAddress, remarks } = params; // Connect V5 contract by default // let titleEscrowContract: v5Contracts.TitleEscrow | v4Contracts.TitleEscrow = @@ -121,7 +121,7 @@ const transferHolder = async ( // Check callStatic (dry run) try { const isV6 = isV6EthersProvider(signer.provider); - const args = isV5TT ? [holderAddress, encryptedRemarks] : [holderAddress]; + const args = isV5TT ? [newHolderAddress, encryptedRemarks] : [newHolderAddress]; if (isV6) { await (titleEscrowContract as ContractV6).transferHolder.staticCall(...args); @@ -137,9 +137,9 @@ const transferHolder = async ( const txOptions = await getTxOptions(signer, chainId, maxFeePerGas, maxPriorityFeePerGas); // Send the actual transaction if (isV5TT) { - return await titleEscrowContract.transferHolder(holderAddress, encryptedRemarks, txOptions); + return await titleEscrowContract.transferHolder(newHolderAddress, encryptedRemarks, txOptions); } else if (isV4TT) { - return await titleEscrowContract.transferHolder(holderAddress, txOptions); + return await titleEscrowContract.transferHolder(newHolderAddress, txOptions); } }; diff --git a/src/token-registry-functions/types.ts b/src/token-registry-functions/types.ts index 3af157f..f13beaa 100644 --- a/src/token-registry-functions/types.ts +++ b/src/token-registry-functions/types.ts @@ -65,7 +65,7 @@ export type OwnerOfTokenOptions = { }; export interface TransferHolderParams { - holderAddress: string; + newHolderAddress: string; remarks?: string; } export interface TransferBeneficiaryParams { diff --git a/src/token-registry-functions/utils.ts b/src/token-registry-functions/utils.ts index bbfc666..88e8213 100644 --- a/src/token-registry-functions/utils.ts +++ b/src/token-registry-functions/utils.ts @@ -2,14 +2,14 @@ import { isV6EthersProvider } from '../utils/ethers'; import { GasValue } from './types'; import { CHAIN_ID, SUPPORTED_CHAINS } from '@tradetrust-tt/tradetrust-utils'; import { Signer } from 'ethers'; -import { Signer as SignerV6 } from 'ethersV6'; +import { Signer as SignerV6, BigNumberish } from 'ethersV6'; const getTxOptions = async ( signer: SignerV6 | Signer, chainId: CHAIN_ID, maxFeePerGas: GasValue, maxPriorityFeePerGas: GasValue, -) => { +): Promise<{ maxFeePerGas?: GasValue; maxPriorityFeePerGas?: GasValue }> => { // If gas values are missing, query gas station if available if (!maxFeePerGas || !maxPriorityFeePerGas) { chainId = chainId ?? ((await getChainIdSafe(signer)) as unknown as CHAIN_ID); @@ -21,7 +21,19 @@ const getTxOptions = async ( maxPriorityFeePerGas = gasFees?.maxPriorityFeePerGas ?? 0; } } - return maxFeePerGas && maxPriorityFeePerGas ? { maxFeePerGas, maxPriorityFeePerGas } : {}; + if (maxFeePerGas && maxPriorityFeePerGas) { + if (isV6EthersProvider(signer.provider)) { + // For ethers v6, cast gas values as BigNumberish + return { + maxFeePerGas: maxFeePerGas as BigNumberish, + maxPriorityFeePerGas: maxPriorityFeePerGas as BigNumberish, + }; + } else { + // For ethers v5, return as is + return { maxFeePerGas, maxPriorityFeePerGas }; + } + } + return {}; }; // 🔍 Handles both Ethers v5 and v6 signer types From f34e3dc3cc8cc95e180ac78354ef833e46194aac Mon Sep 17 00:00:00 2001 From: Rishabh Singh Date: Tue, 29 Jul 2025 12:53:59 +0530 Subject: [PATCH 2/2] fix: update tests --- src/__tests__/token-registry-functions/transfers.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/token-registry-functions/transfers.test.ts b/src/__tests__/token-registry-functions/transfers.test.ts index 86d9faa..9ac9faa 100644 --- a/src/__tests__/token-registry-functions/transfers.test.ts +++ b/src/__tests__/token-registry-functions/transfers.test.ts @@ -88,12 +88,12 @@ describe.each(providers)('Transfers', async ({ Provider, ethersVersion, titleEsc describe(`transfer holder with TR Version ${titleEscrowVersion} and ethers version ${ethersVersion}`, () => { const params = isV5TT ? { - holderAddress: '0xholder', + newHolderAddress: '0xholder', remarks: '0xencrypted_remarks', tokenId: 1, } : { - holderAddress: '0xholder', + newHolderAddress: '0xholder', tokenId: 1, }; const txHash = isV5TT ? 'v5_transfer_holder_tx_hash' : 'v4_transfer_holder_tx_hash';