From fa4c8b78c19137a743bf6272942206218cabb435 Mon Sep 17 00:00:00 2001 From: miketout Date: Mon, 20 Dec 2021 12:24:43 -0800 Subject: [PATCH 1/4] Add Verus chain and types --- src/chains.ts | 19 ++++++++++++++++++- src/common.ts | 9 ++++++++- src/types.ts | 3 ++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/chains.ts b/src/chains.ts index cc8173d03..d3ac68d9c 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -14,7 +14,9 @@ import { with0x, isValidTerraAddress, isValidTerraTx, - getRSKChainID + getRSKChainID, + isValidVerusAddress, + isValidVerusTx } from './common' const chains: { [key in ChainId]: Chain } = { @@ -186,6 +188,21 @@ const chains: { [key in ChainId]: Chain } = { formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), formatTransactionHash: (hash: string) => toLowerCaseWithout0x(hash) + }, + [ChainId.Verus]: { + name: 'Verus', + code: 'VRSC', + nativeAsset: 'VRSC', + fees: { + unit: 'satoshi' + }, + safeConfirmations: 20, + // ~30 blocks wait period + txFailureTimeout: 1600000, // in ms + 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 f9a419c42..d8c521f76 100644 --- a/src/common.ts +++ b/src/common.ts @@ -6,7 +6,6 @@ const BASE58_LENGTH = 32 export const isValidHex = (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) => { @@ -60,6 +59,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 isValidHex(tx) +} + 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 662bb2153..59edd666d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -26,7 +26,8 @@ export enum ChainId { Arbitrum = 'arbitrum', Solana = 'solana', Fuse = 'fuse', - Terra = 'terra' + Terra = 'terra', + Verus = 'vrsc' } export interface Asset { From e9ba0a37fefeb04f72f0543394e2956987cbceec Mon Sep 17 00:00:00 2001 From: miketout Date: Mon, 20 Dec 2021 13:48:46 -0800 Subject: [PATCH 2/4] A little more validation on txid --- src/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.ts b/src/common.ts index d8c521f76..be4e727ab 100644 --- a/src/common.ts +++ b/src/common.ts @@ -64,7 +64,7 @@ export const isValidVerusAddress = (address: string): boolean => { } export const isValidVerusTx = (tx: string): boolean => { - return isValidHex(tx) + return isValidHex(tx) && tx.length === 64 } export const getRSKChainID = (network: string) => { From b752474a984fff90a5c19c7a633a6d60fb6a4775 Mon Sep 17 00:00:00 2001 From: Monkins1010 Date: Thu, 12 Dec 2024 21:03:16 +0000 Subject: [PATCH 3/4] fix hex check --- src/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.ts b/src/common.ts index e96acc857..6e18e24e8 100644 --- a/src/common.ts +++ b/src/common.ts @@ -65,7 +65,7 @@ export const isValidVerusAddress = (address: string): boolean => { } export const isValidVerusTx = (tx: string): boolean => { - return isValidHex(tx) && tx.length === 64 + return isValidHexWith0xPrefix(tx) && tx.length === 64 } export const getRSKChainID = (network: string) => { From 6099112df9444ae66673e185d85a79c1356f3b0d Mon Sep 17 00:00:00 2001 From: Chris <34682781+monkins1010@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:31:33 +0000 Subject: [PATCH 4/4] Add missing keys --- src/chains.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chains.ts b/src/chains.ts index f0f7ecb67..5817b587f 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -248,8 +248,11 @@ const chains: { [key in ChainId]: Chain } = { unit: 'satoshi' }, safeConfirmations: 20, - // ~30 blocks wait period + // ~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),