Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/sdk-coin-polyx/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ export const POLYX_ADDRESS_FORMAT = 12;
* Tpolyx testnet address format
*/
export const TPOLYX_ADDRESS_FORMAT = 42;

/**
* Regex pattern for validating Polymesh DID (Decentralized Identifier)
* DIDs are 32-byte hex strings (0x prefix + 64 hex characters)
*/
export const POLYX_DID_REGEX = /^0x[a-fA-F0-9]{64}$/;
10 changes: 10 additions & 0 deletions modules/sdk-coin-polyx/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ export { BatchStakingBuilder as BatchBuilder } from './batchStakingBuilder';
export { BatchUnstakingBuilder } from './batchUnstakingBuilder';
export { UnbondBuilder } from './unbondBuilder';
export { WithdrawUnbondedBuilder } from './withdrawUnbondedBuilder';
import polyxUtils from './utils';
export { Utils, default as utils } from './utils';
export * from './iface';

export { BondArgs, NominateArgs, BatchCallObject, BatchArgs } from './iface';

/**
* Checks if a string is a valid Polymesh DID (Decentralized Identifier)
* DIDs are 32-byte hex strings (0x prefix + 64 hex characters)
*
* @param {string} did - The string to validate
* @returns {boolean} true if valid DID format, false otherwise
*/
export const isValidDid = (did: string): boolean => polyxUtils.isValidDid(did);
12 changes: 12 additions & 0 deletions modules/sdk-coin-polyx/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NetworkType } from '@bitgo/statics';
import { TypeRegistry } from '@substrate/txwrapper-core/lib/types';
import { mainnetMaterial, testnetMaterial } from '../resources';
import { BatchCallObject } from './iface';
import { POLYX_DID_REGEX } from './constants';

export class Utils extends SubstrateUtils {
/**
Expand All @@ -17,6 +18,17 @@ export class Utils extends SubstrateUtils {
return isMainnet ? 12 : 42;
}

/**
* Checks if a string is a valid Polymesh DID (Decentralized Identifier)
* DIDs are 32-byte hex strings (0x prefix + 64 hex characters)
*
* @param {string} did - The string to validate
* @returns {boolean} true if valid DID format, false otherwise
*/
isValidDid(did: string): boolean {
return POLYX_DID_REGEX.test(did);
}

getMaterial(networkType: NetworkType): Interface.Material {
return (networkType === NetworkType.MAINNET ? mainnetMaterial : testnetMaterial) as unknown as Interface.Material;
}
Expand Down
1 change: 1 addition & 0 deletions modules/statics/src/coinFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ export const POLYX_FEATURES = [
CoinFeature.STAKING,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_TSS,
CoinFeature.ALTERNATIVE_ADDRESS_IDENTIFIER,
];

export const POLYX_TOKEN_FEATURES = [
Expand Down
Loading