Skip to content

Commit 0c9373d

Browse files
authored
Merge pull request #6315 from BitGo/WIN-5750
fix(sdk-coin-polyx): add address format for polyx and tpolyx
2 parents a5d912c + 7748439 commit 0c9373d

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Address format constants for Polyx networks
3+
*/
4+
5+
/**
6+
* Polyx mainnet address format
7+
*/
8+
export const POLYX_ADDRESS_FORMAT = 12;
9+
10+
/**
11+
* Tpolyx testnet address format
12+
*/
13+
export const TPOLYX_ADDRESS_FORMAT = 42;

modules/sdk-coin-polyx/src/polyx.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
33
import { SubstrateCoin } from '@bitgo/abstract-substrate';
44
import { BatchStakingBuilder } from './lib/batchStakingBuilder';
55
import { BondExtraBuilder } from './lib/bondExtraBuilder';
6+
import { POLYX_ADDRESS_FORMAT } from './lib/constants';
67

78
export class Polyx extends SubstrateCoin {
89
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
@@ -47,4 +48,14 @@ export class Polyx extends SubstrateCoin {
4748
bondExtra(): BondExtraBuilder {
4849
return this.getBuilder().getBondExtraBuilder();
4950
}
51+
52+
/**
53+
* Retrieves the address format for Polyx.
54+
*
55+
* @returns {number} The address format as a number for Polyx.
56+
* @override
57+
*/
58+
protected getAddressFormat(): number {
59+
return POLYX_ADDRESS_FORMAT;
60+
}
5061
}

modules/sdk-coin-polyx/src/tpolyx.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core';
22
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
33
import { Polyx } from './polyx';
4+
import { TPOLYX_ADDRESS_FORMAT } from './lib/constants';
45

56
export class Tpolyx extends Polyx {
67
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
@@ -31,4 +32,14 @@ export class Tpolyx extends Polyx {
3132
public getFullName(): string {
3233
return 'Testnet Polymesh';
3334
}
35+
36+
/**
37+
* Retrieves the address format for Testnet Polyx.
38+
*
39+
* @returns {number} The address format as a number for Testnet Polyx.
40+
* @override
41+
*/
42+
protected getAddressFormat(): number {
43+
return TPOLYX_ADDRESS_FORMAT;
44+
}
3445
}

modules/sdk-coin-polyx/test/unit/polyx.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'should';
22
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
33
import { BitGoAPI } from '@bitgo/sdk-api';
44
import { Polyx, Tpolyx } from '../../src';
5+
import { POLYX_ADDRESS_FORMAT, TPOLYX_ADDRESS_FORMAT } from '../../src/lib/constants';
56

67
describe('Polyx:', function () {
78
let bitgo: TestBitGoAPI;
@@ -12,4 +13,12 @@ describe('Polyx:', function () {
1213
bitgo.safeRegister('tpolyx', Tpolyx.createInstance);
1314
bitgo.initializeTestVars();
1415
});
16+
17+
describe('Address Format Constants', function () {
18+
it('should have the correct address format constants', function () {
19+
// Verify the constants are defined correctly
20+
POLYX_ADDRESS_FORMAT.should.equal(12);
21+
TPOLYX_ADDRESS_FORMAT.should.equal(42);
22+
});
23+
});
1524
});

0 commit comments

Comments
 (0)