From b83b09463ad5ae831047ff5f68357a5c471dd9c6 Mon Sep 17 00:00:00 2001 From: Gautam2305 Date: Tue, 23 Dec 2025 15:07:27 +0530 Subject: [PATCH] fix(sdk-coin-vet): fix mainnet addresses Ticket: SC-4678 --- modules/sdk-coin-vet/src/lib/constants.ts | 5 +-- modules/sdk-coin-vet/src/lib/utils.ts | 43 +------------------ .../transactionBuilder/claimRewardsBuilder.ts | 10 ++++- .../delegateClauseTxnBuilder.ts | 12 +++--- .../stakeClauseTransactionBuilder.ts | 8 ++-- 5 files changed, 23 insertions(+), 55 deletions(-) diff --git a/modules/sdk-coin-vet/src/lib/constants.ts b/modules/sdk-coin-vet/src/lib/constants.ts index 93cf48a8ca..d83579cc88 100644 --- a/modules/sdk-coin-vet/src/lib/constants.ts +++ b/modules/sdk-coin-vet/src/lib/constants.ts @@ -15,11 +15,10 @@ export const CLAIM_BASE_REWARDS_METHOD_ID = '0x858d50e8'; // claimVetGeneratedVt export const CLAIM_STAKING_REWARDS_METHOD_ID = '0x0962ef79'; // claimRewards(uint256) export const STARGATE_NFT_ADDRESS = '0x1856c533ac2d94340aaa8544d35a5c1d4a21dee7'; -export const STARGATE_DELEGATION_ADDRESS = '0x4cb1c9ef05b529c093371264fab2c93cc6cddb0e'; -export const STARGATE_DELEGATION_ADDRESS_TESTNET = '0x7240e3bc0d26431512d5b67dbd26d199205bffe8'; - export const STARGATE_NFT_ADDRESS_TESTNET = '0x887d9102f0003f1724d8fd5d4fe95a11572fcd77'; + export const STARGATE_CONTRACT_ADDRESS_TESTNET = '0x1e02b2953adefec225cf0ec49805b1146a4429c1'; +export const STARGATE_CONTRACT_ADDRESS = '0x03c557be98123fdb6fad325328ac6eb77de7248c'; export const VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET = '0x00000000000000000000000000005374616B6572'; export const VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_MAINNET = '0x00000000000000000000000000005374616B6572'; diff --git a/modules/sdk-coin-vet/src/lib/utils.ts b/modules/sdk-coin-vet/src/lib/utils.ts index cf6c2cdf35..cd3bcfc4e8 100644 --- a/modules/sdk-coin-vet/src/lib/utils.ts +++ b/modules/sdk-coin-vet/src/lib/utils.ts @@ -22,10 +22,9 @@ import { CLAIM_STAKING_REWARDS_METHOD_ID, STARGATE_NFT_ADDRESS, STARGATE_NFT_ADDRESS_TESTNET, - STARGATE_DELEGATION_ADDRESS, DELEGATE_CLAUSE_METHOD_ID, STARGATE_CONTRACT_ADDRESS_TESTNET, - STARGATE_DELEGATION_ADDRESS_TESTNET, + STARGATE_CONTRACT_ADDRESS, VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_MAINNET, VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET, ADD_VALIDATION_METHOD_ID, @@ -325,16 +324,6 @@ export class Utils implements BaseUtils { } } - /** - * Get the network-appropriate stargate contract address - * @param {CoinConfig} coinConfig - The coin configuration object - * @returns {string} The delegation contract address for the network - */ - getDefaultDelegationAddress(coinConfig: Readonly): string { - const isTestnet = coinConfig.network.type === 'testnet'; - return isTestnet ? STARGATE_CONTRACT_ADDRESS_TESTNET : STARGATE_DELEGATION_ADDRESS; - } - /** * Get the network-appropriate staking contract address * @param {CoinConfig} coinConfig - The coin configuration object @@ -342,7 +331,7 @@ export class Utils implements BaseUtils { */ getDefaultStakingAddress(coinConfig: Readonly): string { const isTestnet = coinConfig.network.type === 'testnet'; - return isTestnet ? STARGATE_CONTRACT_ADDRESS_TESTNET : STARGATE_NFT_ADDRESS; + return isTestnet ? STARGATE_CONTRACT_ADDRESS_TESTNET : STARGATE_CONTRACT_ADDRESS; } /** @@ -357,19 +346,6 @@ export class Utils implements BaseUtils { : VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_MAINNET; } - /** - * Check if an address is a valid delegation contract address for any network - * @param {string} address - The address to check - * @returns {boolean} True if the address is a delegation contract address - */ - isDelegationContractAddress(address: string): boolean { - const lowerAddress = address.toLowerCase(); - return ( - lowerAddress === STARGATE_DELEGATION_ADDRESS.toLowerCase() || - lowerAddress === STARGATE_DELEGATION_ADDRESS_TESTNET.toLowerCase() - ); - } - /** * Check if an address is a valid NFT contract address for any network * @param {string} address - The address to check @@ -411,21 +387,6 @@ export class Utils implements BaseUtils { ); } } - - /** - * Validate that a contract address matches the expected stargate contract for the network - * @param {string} address - The contract address to validate - * @param {CoinConfig} coinConfig - The coin configuration object - * @throws {Error} If the address doesn't match the expected delegation contract address - */ - validateDelegationContractAddress(address: string, coinConfig: Readonly): void { - const expectedAddress = this.getDefaultDelegationAddress(coinConfig); - if (address.toLowerCase() !== expectedAddress.toLowerCase()) { - throw new Error( - `Invalid delegation contract address. Expected ${expectedAddress} for ${coinConfig.network.type}, got ${address}` - ); - } - } } const utils = new Utils(); diff --git a/modules/sdk-coin-vet/test/transactionBuilder/claimRewardsBuilder.ts b/modules/sdk-coin-vet/test/transactionBuilder/claimRewardsBuilder.ts index 037d84d660..4054907f8c 100644 --- a/modules/sdk-coin-vet/test/transactionBuilder/claimRewardsBuilder.ts +++ b/modules/sdk-coin-vet/test/transactionBuilder/claimRewardsBuilder.ts @@ -152,8 +152,16 @@ describe('VET Claim Rewards Transaction', function () { }); it('should throw error when staking contract address is missing', async function () { - const txBuilder = createBasicTxBuilder(); + const txBuilder = factory.getClaimRewardsBuilder(); txBuilder.tokenId(tokenId); + txBuilder.sender('0x9378c12BD7502A11F770a5C1F223c959B2805dA9'); + txBuilder.chainTag(0x27); + txBuilder.blockRef('0x0000000000000000'); + txBuilder.expiration(64); + txBuilder.gas(100000); + txBuilder.gasPriceCoef(0); + txBuilder.nonce('12345'); + // Intentionally not setting stakingContractAddress await txBuilder.build().should.be.rejectedWith('Staking contract address is required'); }); diff --git a/modules/sdk-coin-vet/test/transactionBuilder/delegateClauseTxnBuilder.ts b/modules/sdk-coin-vet/test/transactionBuilder/delegateClauseTxnBuilder.ts index 703ac21751..7d46aecfd1 100644 --- a/modules/sdk-coin-vet/test/transactionBuilder/delegateClauseTxnBuilder.ts +++ b/modules/sdk-coin-vet/test/transactionBuilder/delegateClauseTxnBuilder.ts @@ -155,19 +155,19 @@ describe('VET Delegation Transaction', function () { }); it('should build a signed tx and validate its toJson', async function () { - const tokenIdForDelegateTxn = '15662'; + const tokenIdForDelegateTxn = '15685'; const txBuilder = factory.from(testData.DELEGATION_TRANSACTION); const tx = txBuilder.transaction as DelegateClauseTransaction; const toJson = tx.toJson(); - toJson.id.should.equal('0xc47792a421d90cb52a4aedbd9abe96f779a8ad68e508680ac3cc135428c3f4c5'); + toJson.id.should.equal('0x841fd66a1d7feff7ab3d432720a659697197e6c67da1aeb9ce9d93b131e46ab7'); toJson.stakingContractAddress?.should.equal('0x1e02b2953adefec225cf0ec49805b1146a4429c1'); - toJson.nonce.should.equal('887557'); - toJson.gas.should.equal(287920); + toJson.nonce.should.equal('0xf341b4c6b5ff5294'); + toJson.gas.should.equal(242796); toJson.gasPriceCoef.should.equal(128); - toJson.expiration.should.equal(64); + toJson.expiration.should.equal(400); toJson.chainTag.should.equal(39); toJson.tokenId?.should.equal(tokenIdForDelegateTxn); - toJson.validatorAddress?.should.equal('0x00563ec3cafbbe7e60b04b3190e6eca66579706d'); + toJson.validatorAddress?.should.equal('0x00000021cbe0de65ea10f7658effeea70727154a'); }); }); diff --git a/modules/sdk-coin-vet/test/transactionBuilder/stakeClauseTransactionBuilder.ts b/modules/sdk-coin-vet/test/transactionBuilder/stakeClauseTransactionBuilder.ts index a02f9e8f40..c938167fc7 100644 --- a/modules/sdk-coin-vet/test/transactionBuilder/stakeClauseTransactionBuilder.ts +++ b/modules/sdk-coin-vet/test/transactionBuilder/stakeClauseTransactionBuilder.ts @@ -240,13 +240,13 @@ describe('VET Staking Transaction', function () { const txBuilder = factory.from(testData.STAKE_CLAUSE_TRANSACTION); const tx = txBuilder.transaction as StakeClauseTransaction; const toJson = tx.toJson(); - toJson.id.should.equal('0x7148f62b42ecfdcb7ee62ac0654514e4b5f65f2fe5fdee79d4d29f56ab1722eb'); + toJson.id.should.equal('0xe003dbe6db08e71b962aa97ba5cb9e69810f52db41d31111fe39654281c6227c'); toJson.stakingContractAddress?.should.equal('0x1e02b2953adefec225cf0ec49805b1146a4429c1'); toJson.amountToStake?.should.equal(amountToStake); - toJson.nonce.should.equal('996363'); - toJson.gas.should.equal(406410); + toJson.nonce.should.equal('0xf536788f0c121df3'); + toJson.gas.should.equal(338631); toJson.gasPriceCoef.should.equal(128); - toJson.expiration.should.equal(64); + toJson.expiration.should.equal(400); toJson.chainTag.should.equal(39); toJson.levelId?.should.equal(8); });