diff --git a/src/chains.ts b/src/chains.ts index 48e84c49b..5817b587f 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -15,7 +15,9 @@ import { isValidTerraAddress, isValidTerraTx, getRSKChainID, - isValidHexWith0xPrefix + isValidHexWith0xPrefix, + isValidVerusAddress, + isValidVerusTx } from './common' const chains: { [key in ChainId]: Chain } = { @@ -237,6 +239,24 @@ const chains: { [key in ChainId]: Chain } = { formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), formatTransactionHash: (hash: string) => hash + }, + [ChainId.Verus]: { + name: 'Verus', + code: 'VRSC', + nativeAsset: 'VRSC', + fees: { + unit: 'satoshi' + }, + safeConfirmations: 20, + // ~20 blocks wait period + txFailureTimeout: 1600000, // in ms + evmCompatible: false, + hasTokens: false, + supportCustomFees: false, + isValidAddress: (address) => isValidVerusAddress(address), + formatAddress: (address) => address, + isValidTransactionHash: (hash: string) => isValidVerusTx(hash), + formatTransactionHash: (hash: string) => toLowerCaseWithout0x(hash) } } diff --git a/src/common.ts b/src/common.ts index d623126fa..6e18e24e8 100644 --- a/src/common.ts +++ b/src/common.ts @@ -7,7 +7,6 @@ export const isValidHexWith0xPrefix = (hash: string) => /^(0x)?([A-Fa-f0-9]{64}) export const isValidHexWithout0xPrefix = (hash: string) => /^([A-Fa-f0-9]{64})$/.test(hash) export const toLowerCaseWithout0x = (hash: string) => hash.toLowerCase().replace(/0x/g, '') export const with0x = (hash: string) => (hash.startsWith('0x') ? hash : '0x' + hash) - export const isValidNearAddress = (address: string) => address.endsWith('.near') || /^[0-9a-fA-F]{64}$/.test(address) export const isValidNearTx = (hash: string) => { @@ -61,6 +60,14 @@ export const isValidTerraTx = (tx: string): boolean => { return typeof tx === 'string' && tx.length === 64 } +export const isValidVerusAddress = (address: string): boolean => { + return base58.decode(address).length === 21 +} + +export const isValidVerusTx = (tx: string): boolean => { + return isValidHexWith0xPrefix(tx) && tx.length === 64 +} + export const getRSKChainID = (network: string) => { if (network == 'mainnet') return 30 if (network == 'testnet') return 31 diff --git a/src/types.ts b/src/types.ts index f39ca3b8a..10567b3b2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -35,7 +35,8 @@ export enum ChainId { Solana = 'solana', Fuse = 'fuse', Terra = 'terra', - Avalanche = 'avalanche' + Avalanche = 'avalanche', + Verus = 'vrsc' } export interface Asset {