Skip to content

Commit d16f638

Browse files
committed
fix(sdk-coin-vet): add prefix for validator address
Ticket: SC-4444
1 parent 7c3fc05 commit d16f638

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class Utils implements BaseUtils {
194194

195195
return {
196196
tokenId: String(decoded[0]),
197-
validator: String(decoded[1]),
197+
validator: addHexPrefix(decoded[1].toString()).toLowerCase(),
198198
};
199199
} catch (error) {
200200
throw new Error(`Failed to decode delegation data: ${error.message}`);

modules/sdk-coin-vet/test/resources/vet.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,8 @@ export const SERIALIZED_SIGNED_FLUSH_TOKEN_TX =
215215

216216
export const VALID_NFT_CONTRACT_DATA =
217217
'0x23b872dd0000000000000000000000007ca00e3bc8a836026c2917c6c7c6d049e52099dd000000000000000000000000e59f1cea4e0fef511e3d0f4eec44adf19c4cbeec00000000000000000000000000000000000000000000000000000000000004d2';
218+
219+
export const DELEGATE_CLAUSE_DATA =
220+
'0x08bbb8240000000000000000000000000000000000000000000000000000000000003d45000000000000000000000000ae99cb89767a09d53e589a40cb4016974aba4b94';
221+
export const DELEGATE_TOKEN_ID = '15685';
222+
export const DELEGATE_VALIDATOR = '0xae99cb89767a09d53e589a40cb4016974aba4b94';

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DELEGATE_CLAUSE_METHOD_ID, STARGATE_CONTRACT_ADDRESS_TESTNET } from '..
55
import EthereumAbi from 'ethereumjs-abi';
66
import * as testData from '../resources/vet';
77
import { BN } from 'ethereumjs-util';
8+
import utils from '../../src/lib/utils';
89

910
describe('VET Delegation Transaction', function () {
1011
const factory = new TransactionBuilderFactory(coins.get('tvet'));
@@ -169,4 +170,15 @@ describe('VET Delegation Transaction', function () {
169170
toJson.validatorAddress?.should.equal('00563ec3cafbbe7e60b04b3190e6eca66579706d');
170171
});
171172
});
173+
174+
describe('decodeDelegateClauseData', function () {
175+
it('should correctly decode delegate transaction data with proper address formatting', function () {
176+
const decodedData = utils.decodeDelegateClauseData(testData.DELEGATE_CLAUSE_DATA);
177+
178+
decodedData.tokenId.should.equal(testData.DELEGATE_TOKEN_ID);
179+
decodedData.validator.should.equal(testData.DELEGATE_VALIDATOR);
180+
decodedData.validator.should.startWith('0x');
181+
decodedData.validator.should.equal(decodedData.validator.toLowerCase());
182+
});
183+
});
172184
});

0 commit comments

Comments
 (0)