Skip to content

Commit b83b094

Browse files
committed
fix(sdk-coin-vet): fix mainnet addresses
Ticket: SC-4678
1 parent d6a558a commit b83b094

File tree

5 files changed

+23
-55
lines changed

5 files changed

+23
-55
lines changed

modules/sdk-coin-vet/src/lib/constants.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ export const CLAIM_BASE_REWARDS_METHOD_ID = '0x858d50e8'; // claimVetGeneratedVt
1515
export const CLAIM_STAKING_REWARDS_METHOD_ID = '0x0962ef79'; // claimRewards(uint256)
1616

1717
export const STARGATE_NFT_ADDRESS = '0x1856c533ac2d94340aaa8544d35a5c1d4a21dee7';
18-
export const STARGATE_DELEGATION_ADDRESS = '0x4cb1c9ef05b529c093371264fab2c93cc6cddb0e';
19-
export const STARGATE_DELEGATION_ADDRESS_TESTNET = '0x7240e3bc0d26431512d5b67dbd26d199205bffe8';
20-
2118
export const STARGATE_NFT_ADDRESS_TESTNET = '0x887d9102f0003f1724d8fd5d4fe95a11572fcd77';
19+
2220
export const STARGATE_CONTRACT_ADDRESS_TESTNET = '0x1e02b2953adefec225cf0ec49805b1146a4429c1';
21+
export const STARGATE_CONTRACT_ADDRESS = '0x03c557be98123fdb6fad325328ac6eb77de7248c';
2322

2423
export const VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET = '0x00000000000000000000000000005374616B6572';
2524
export const VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_MAINNET = '0x00000000000000000000000000005374616B6572';

modules/sdk-coin-vet/src/lib/utils.ts

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ import {
2222
CLAIM_STAKING_REWARDS_METHOD_ID,
2323
STARGATE_NFT_ADDRESS,
2424
STARGATE_NFT_ADDRESS_TESTNET,
25-
STARGATE_DELEGATION_ADDRESS,
2625
DELEGATE_CLAUSE_METHOD_ID,
2726
STARGATE_CONTRACT_ADDRESS_TESTNET,
28-
STARGATE_DELEGATION_ADDRESS_TESTNET,
27+
STARGATE_CONTRACT_ADDRESS,
2928
VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_MAINNET,
3029
VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET,
3130
ADD_VALIDATION_METHOD_ID,
@@ -325,24 +324,14 @@ export class Utils implements BaseUtils {
325324
}
326325
}
327326

328-
/**
329-
* Get the network-appropriate stargate contract address
330-
* @param {CoinConfig} coinConfig - The coin configuration object
331-
* @returns {string} The delegation contract address for the network
332-
*/
333-
getDefaultDelegationAddress(coinConfig: Readonly<CoinConfig>): string {
334-
const isTestnet = coinConfig.network.type === 'testnet';
335-
return isTestnet ? STARGATE_CONTRACT_ADDRESS_TESTNET : STARGATE_DELEGATION_ADDRESS;
336-
}
337-
338327
/**
339328
* Get the network-appropriate staking contract address
340329
* @param {CoinConfig} coinConfig - The coin configuration object
341330
* @returns {string} The staking contract address for the network
342331
*/
343332
getDefaultStakingAddress(coinConfig: Readonly<CoinConfig>): string {
344333
const isTestnet = coinConfig.network.type === 'testnet';
345-
return isTestnet ? STARGATE_CONTRACT_ADDRESS_TESTNET : STARGATE_NFT_ADDRESS;
334+
return isTestnet ? STARGATE_CONTRACT_ADDRESS_TESTNET : STARGATE_CONTRACT_ADDRESS;
346335
}
347336

348337
/**
@@ -357,19 +346,6 @@ export class Utils implements BaseUtils {
357346
: VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_MAINNET;
358347
}
359348

360-
/**
361-
* Check if an address is a valid delegation contract address for any network
362-
* @param {string} address - The address to check
363-
* @returns {boolean} True if the address is a delegation contract address
364-
*/
365-
isDelegationContractAddress(address: string): boolean {
366-
const lowerAddress = address.toLowerCase();
367-
return (
368-
lowerAddress === STARGATE_DELEGATION_ADDRESS.toLowerCase() ||
369-
lowerAddress === STARGATE_DELEGATION_ADDRESS_TESTNET.toLowerCase()
370-
);
371-
}
372-
373349
/**
374350
* Check if an address is a valid NFT contract address for any network
375351
* @param {string} address - The address to check
@@ -411,21 +387,6 @@ export class Utils implements BaseUtils {
411387
);
412388
}
413389
}
414-
415-
/**
416-
* Validate that a contract address matches the expected stargate contract for the network
417-
* @param {string} address - The contract address to validate
418-
* @param {CoinConfig} coinConfig - The coin configuration object
419-
* @throws {Error} If the address doesn't match the expected delegation contract address
420-
*/
421-
validateDelegationContractAddress(address: string, coinConfig: Readonly<CoinConfig>): void {
422-
const expectedAddress = this.getDefaultDelegationAddress(coinConfig);
423-
if (address.toLowerCase() !== expectedAddress.toLowerCase()) {
424-
throw new Error(
425-
`Invalid delegation contract address. Expected ${expectedAddress} for ${coinConfig.network.type}, got ${address}`
426-
);
427-
}
428-
}
429390
}
430391

431392
const utils = new Utils();

modules/sdk-coin-vet/test/transactionBuilder/claimRewardsBuilder.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,16 @@ describe('VET Claim Rewards Transaction', function () {
152152
});
153153

154154
it('should throw error when staking contract address is missing', async function () {
155-
const txBuilder = createBasicTxBuilder();
155+
const txBuilder = factory.getClaimRewardsBuilder();
156156
txBuilder.tokenId(tokenId);
157+
txBuilder.sender('0x9378c12BD7502A11F770a5C1F223c959B2805dA9');
158+
txBuilder.chainTag(0x27);
159+
txBuilder.blockRef('0x0000000000000000');
160+
txBuilder.expiration(64);
161+
txBuilder.gas(100000);
162+
txBuilder.gasPriceCoef(0);
163+
txBuilder.nonce('12345');
164+
// Intentionally not setting stakingContractAddress
157165

158166
await txBuilder.build().should.be.rejectedWith('Staking contract address is required');
159167
});

modules/sdk-coin-vet/test/transactionBuilder/delegateClauseTxnBuilder.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,19 @@ describe('VET Delegation Transaction', function () {
155155
});
156156

157157
it('should build a signed tx and validate its toJson', async function () {
158-
const tokenIdForDelegateTxn = '15662';
158+
const tokenIdForDelegateTxn = '15685';
159159
const txBuilder = factory.from(testData.DELEGATION_TRANSACTION);
160160
const tx = txBuilder.transaction as DelegateClauseTransaction;
161161
const toJson = tx.toJson();
162-
toJson.id.should.equal('0xc47792a421d90cb52a4aedbd9abe96f779a8ad68e508680ac3cc135428c3f4c5');
162+
toJson.id.should.equal('0x841fd66a1d7feff7ab3d432720a659697197e6c67da1aeb9ce9d93b131e46ab7');
163163
toJson.stakingContractAddress?.should.equal('0x1e02b2953adefec225cf0ec49805b1146a4429c1');
164-
toJson.nonce.should.equal('887557');
165-
toJson.gas.should.equal(287920);
164+
toJson.nonce.should.equal('0xf341b4c6b5ff5294');
165+
toJson.gas.should.equal(242796);
166166
toJson.gasPriceCoef.should.equal(128);
167-
toJson.expiration.should.equal(64);
167+
toJson.expiration.should.equal(400);
168168
toJson.chainTag.should.equal(39);
169169
toJson.tokenId?.should.equal(tokenIdForDelegateTxn);
170-
toJson.validatorAddress?.should.equal('0x00563ec3cafbbe7e60b04b3190e6eca66579706d');
170+
toJson.validatorAddress?.should.equal('0x00000021cbe0de65ea10f7658effeea70727154a');
171171
});
172172
});
173173

modules/sdk-coin-vet/test/transactionBuilder/stakeClauseTransactionBuilder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ describe('VET Staking Transaction', function () {
240240
const txBuilder = factory.from(testData.STAKE_CLAUSE_TRANSACTION);
241241
const tx = txBuilder.transaction as StakeClauseTransaction;
242242
const toJson = tx.toJson();
243-
toJson.id.should.equal('0x7148f62b42ecfdcb7ee62ac0654514e4b5f65f2fe5fdee79d4d29f56ab1722eb');
243+
toJson.id.should.equal('0xe003dbe6db08e71b962aa97ba5cb9e69810f52db41d31111fe39654281c6227c');
244244
toJson.stakingContractAddress?.should.equal('0x1e02b2953adefec225cf0ec49805b1146a4429c1');
245245
toJson.amountToStake?.should.equal(amountToStake);
246-
toJson.nonce.should.equal('996363');
247-
toJson.gas.should.equal(406410);
246+
toJson.nonce.should.equal('0xf536788f0c121df3');
247+
toJson.gas.should.equal(338631);
248248
toJson.gasPriceCoef.should.equal(128);
249-
toJson.expiration.should.equal(64);
249+
toJson.expiration.should.equal(400);
250250
toJson.chainTag.should.equal(39);
251251
toJson.levelId?.should.equal(8);
252252
});

0 commit comments

Comments
 (0)