diff --git a/src/async.test.ts b/src/async.test.ts index f0431914..395a054e 100644 --- a/src/async.test.ts +++ b/src/async.test.ts @@ -1,5 +1,14 @@ import { expect, test } from "bun:test"; import { getCoderByCoinNameAsync, getCoderByCoinTypeAsync } from "./async.js"; +import { + evmCoinNameToTypeMap, + nonEvmCoinNameToTypeMap, +} from "./consts/coinNameToTypeMap.js"; +import { + evmCoinTypeToNameMap, + nonEvmCoinTypeToNameMap, +} from "./consts/coinTypeToNameMap.js"; +import { coinTypeToEvmChainId } from "./utils/evm.js"; test("coin name", async () => { const coder = await getCoderByCoinNameAsync("btc"); @@ -26,3 +35,46 @@ test("evm coin type", async () => { expect(coder.name).toBe("op"); expect(coder.evmChainId).toBe(10); }); + +const nonEvmCoinNames = Object.keys(nonEvmCoinNameToTypeMap); +const evmCoinNames = Object.keys(evmCoinNameToTypeMap); + +test.each(nonEvmCoinNames)( + 'getCoderByCoinNameAsync("%s")', + async (coinName) => { + const coder = await getCoderByCoinNameAsync(coinName); + expect(coder.name).toBe(coinName); + expect(coder.coinType).toBe(nonEvmCoinNameToTypeMap[coinName]); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); + } +); + +test.each(evmCoinNames)('getCoderByCoinNameAsync("%s")', async (coinName) => { + const coder = await getCoderByCoinNameAsync(coinName); + expect(coder.name).toBe(coinName); + expect(coder.coinType).toBe(evmCoinNameToTypeMap[coinName]); + expect(coder.evmChainId).toBe(coinTypeToEvmChainId(coder.coinType)); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); + +const nonEvmCoinTypes = Object.values(nonEvmCoinNameToTypeMap); +const evmCoinTypes = Object.values(evmCoinNameToTypeMap); + +test.each(nonEvmCoinTypes)("getCoderByCoinTypeAsync(%d)", async (coinType) => { + const coder = await getCoderByCoinTypeAsync(coinType); + expect(coder.name).toBe(nonEvmCoinTypeToNameMap[coinType][0]); + expect(coder.coinType).toBe(coinType); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); + +test.each(evmCoinTypes)("getCoderByCoinTypeAsync(%d)", async (coinType) => { + const coder = await getCoderByCoinTypeAsync(coinType); + expect(coder.name).toBe(evmCoinTypeToNameMap[coinType][0]); + expect(coder.coinType).toBe(coinType); + expect(coder.evmChainId).toBe(coinTypeToEvmChainId(coinType)); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); diff --git a/src/coders.test.ts b/src/coders.test.ts new file mode 100644 index 00000000..0c74f476 --- /dev/null +++ b/src/coders.test.ts @@ -0,0 +1,15 @@ +import { expect, test } from "bun:test"; +import * as coders from "./coders.js"; +import { nonEvmCoinNameToTypeMap } from "./consts/coinNameToTypeMap.js"; + +const coinNames = Object.keys(nonEvmCoinNameToTypeMap); + +const capitalise = (s: string) => s[0].toUpperCase() + s.slice(1); + +test.each(coinNames)("coders.ts exports - %s", (coinName) => { + const coderSuffix = `${capitalise(coinName)}Address`; + const encoder = coders[`encode${coderSuffix}`]; + const decoder = coders[`decode${coderSuffix}`]; + expect(encoder).toBeFunction(); + expect(decoder).toBeFunction(); +}); diff --git a/src/coders.ts b/src/coders.ts index 53edd5f7..7de36ffe 100644 --- a/src/coders.ts +++ b/src/coders.ts @@ -54,6 +54,7 @@ export { decodeFilAddress, encodeFilAddress } from "./coin/fil.js"; export { decodeFioAddress, encodeFioAddress } from "./coin/fio.js"; export { decodeFiroAddress, encodeFiroAddress } from "./coin/firo.js"; export { decodeFlowAddress, encodeFlowAddress } from "./coin/flow.js"; +export { decodeFluxAddress, encodeFluxAddress } from "./coin/flux.js"; export { decodeFtmLegacyAddress, encodeFtmLegacyAddress, @@ -107,8 +108,8 @@ export { } from "./coin/poaLegacy.js"; export { decodePpcAddress, encodePpcAddress } from "./coin/ppc.js"; export { decodeQtumAddress, encodeQtumAddress } from "./coin/qtum.js"; +export { decodeRbtcAddress, encodeRbtcAddress } from "./coin/rbtc.js"; export { decodeRddAddress, encodeRddAddress } from "./coin/rdd.js"; -export { decodeRskAddress, encodeRskAddress } from "./coin/rsk.js"; export { decodeRuneAddress, encodeRuneAddress } from "./coin/rune.js"; export { decodeRvnAddress, encodeRvnAddress } from "./coin/rvn.js"; export { decodeScAddress, encodeScAddress } from "./coin/sc.js"; @@ -137,6 +138,10 @@ export { export { decodeVetAddress, encodeVetAddress } from "./coin/vet.js"; export { decodeViaAddress, encodeViaAddress } from "./coin/via.js"; export { decodeVlxAddress, encodeVlxAddress } from "./coin/vlx.js"; +export { + decodeVlxLegacyAddress, + encodeVlxLegacyAddress, +} from "./coin/vlxLegacy.js"; export { decodeVsysAddress, encodeVsysAddress } from "./coin/vsys.js"; export { decodeWanAddress, encodeWanAddress } from "./coin/wan.js"; export { decodeWavesAddress, encodeWavesAddress } from "./coin/waves.js"; @@ -150,6 +155,5 @@ export { decodeXrpAddress, encodeXrpAddress } from "./coin/xrp.js"; export { decodeXtzAddress, encodeXtzAddress } from "./coin/xtz.js"; export { decodeXvgAddress, encodeXvgAddress } from "./coin/xvg.js"; export { decodeZecAddress, encodeZecAddress } from "./coin/zec.js"; -export { decodeZelAddress, encodeZelAddress } from "./coin/zel.js"; export { decodeZenAddress, encodeZenAddress } from "./coin/zen.js"; export { decodeZilAddress, encodeZilAddress } from "./coin/zil.js"; diff --git a/src/coin/abbc.ts b/src/coin/abbc.ts index 340faa10..d5cf1f99 100644 --- a/src/coin/abbc.ts +++ b/src/coin/abbc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "abbc"; @@ -14,4 +14,4 @@ export const abbc = { coinType, encode: encodeAbbcAddress, decode: decodeAbbcAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ada.ts b/src/coin/ada.ts index a88c1e17..1bbb5ca5 100644 --- a/src/coin/ada.ts +++ b/src/coin/ada.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; import { byronDecode, byronEncode } from "../utils/byron.js"; @@ -30,4 +30,4 @@ export const ada = { coinType, encode: encodeAdaAddress, decode: decodeAdaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ae.ts b/src/coin/ae.ts index b0343c25..e1a2d871 100644 --- a/src/coin/ae.ts +++ b/src/coin/ae.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "ae"; @@ -20,4 +20,4 @@ export const ae = { coinType, encode: encodeAeAddress, decode: decodeAeAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/aib.ts b/src/coin/aib.ts index 7152e123..b58ef940 100644 --- a/src/coin/aib.ts +++ b/src/coin/aib.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const aib = { coinType, encode: encodeAibAddress, decode: decodeAibAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/aion.ts b/src/coin/aion.ts index 54281d83..fbdd3da4 100644 --- a/src/coin/aion.ts +++ b/src/coin/aion.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToHex, hexWithoutPrefixToBytes } from "../utils/bytes.js"; const name = "aion"; @@ -22,4 +22,4 @@ export const aion = { coinType, encode: encodeAionAddress, decode: decodeAionAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/algo.ts b/src/coin/algo.ts index 60affdba..f13627b1 100644 --- a/src/coin/algo.ts +++ b/src/coin/algo.ts @@ -1,6 +1,6 @@ import { sha512_256 } from "@noble/hashes/sha512"; import { utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base32UnpaddedDecode, base32UnpaddedEncode } from "../utils/base32.js"; const name = "algo"; @@ -25,4 +25,4 @@ export const algo = { coinType, encode: encodeAlgoAddress, decode: decodeAlgoAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ar.ts b/src/coin/ar.ts index 510e7c24..6342c6db 100644 --- a/src/coin/ar.ts +++ b/src/coin/ar.ts @@ -1,5 +1,5 @@ import { base64urlnopad } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "ar"; const coinType = 472; @@ -12,4 +12,4 @@ export const ar = { coinType, encode: encodeArAddress, decode: decodeArAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ardr.ts b/src/coin/ardr.ts index fbdc491a..d299fcc1 100644 --- a/src/coin/ardr.ts +++ b/src/coin/ardr.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "ardr"; const coinType = 16754; @@ -87,4 +87,4 @@ export const ardr = { coinType, encode: encodeArdrAddress, decode: decodeArdrAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ark.ts b/src/coin/ark.ts index b0bb6aec..ab158d06 100644 --- a/src/coin/ark.ts +++ b/src/coin/ark.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "ark"; @@ -16,4 +16,4 @@ export const ark = { coinType, encode: encodeArkAddress, decode: decodeArkAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/atom.ts b/src/coin/atom.ts index 17602956..f738a332 100644 --- a/src/coin/atom.ts +++ b/src/coin/atom.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "atom"; @@ -12,4 +12,4 @@ export const atom = { coinType, encode: encodeAtomAddress, decode: decodeAtomAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/avax.ts b/src/coin/avax.ts index 230eaff1..cad170a3 100644 --- a/src/coin/avax.ts +++ b/src/coin/avax.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "avax"; @@ -26,4 +26,4 @@ export const avax = { coinType, encode: encodeAvaxAddress, decode: decodeAvaxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bcd.ts b/src/coin/bcd.ts index 18f2ff5e..4964b5da 100644 --- a/src/coin/bcd.ts +++ b/src/coin/bcd.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const bcd = { coinType, encode: encodeBcdAddress, decode: decodeBcdAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bch.ts b/src/coin/bch.ts index 7af83a8e..c2836fd8 100644 --- a/src/coin/bch.ts +++ b/src/coin/bch.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder } from "../utils/base58.js"; import { decodeBchAddressToTypeAndHash, @@ -63,4 +63,4 @@ export const bch = { coinType, encode: encodeBchAddress, decode: decodeBchAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bcn.ts b/src/coin/bcn.ts index 81de7503..49bfae30 100644 --- a/src/coin/bcn.ts +++ b/src/coin/bcn.ts @@ -2,7 +2,7 @@ import { equalBytes } from "@noble/curves/abstract/utils"; import { keccak_256 } from "@noble/hashes/sha3"; import { concatBytes } from "@noble/hashes/utils"; import { utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { decodeXmrAddress, encodeXmrAddress } from "./xmr.js"; const name = "bcn"; @@ -34,4 +34,4 @@ export const bcn = { coinType, encode: encodeBcnAddress, decode: decodeBcnAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bdx.ts b/src/coin/bdx.ts index 94f2b675..1043083c 100644 --- a/src/coin/bdx.ts +++ b/src/coin/bdx.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { decodeXmrAddress, encodeXmrAddress } from "./xmr.js"; const name = "bdx"; @@ -12,4 +12,4 @@ export const bdx = { coinType, encode: encodeBdxAddress, decode: decodeBdxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bnb.ts b/src/coin/bnb.ts index 710b6303..8932162d 100644 --- a/src/coin/bnb.ts +++ b/src/coin/bnb.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "bnb"; @@ -14,4 +14,4 @@ export const bnb = { coinType, encode: encodeBnbAddress, decode: decodeBnbAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bps.ts b/src/coin/bps.ts index cc1e31b0..42597f82 100644 --- a/src/coin/bps.ts +++ b/src/coin/bps.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const bps = { coinType, encode: encodeBpsAddress, decode: decodeBpsAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bsv.ts b/src/coin/bsv.ts index 397f411a..67f52a45 100644 --- a/src/coin/bsv.ts +++ b/src/coin/bsv.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "bsv"; @@ -23,4 +23,4 @@ export const bsv = { coinType, encode: encodeBsvAddress, decode: decodeBsvAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/btc.ts b/src/coin/btc.ts index c5015a6e..56a2864b 100644 --- a/src/coin/btc.ts +++ b/src/coin/btc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const btc = { coinType, encode: encodeBtcAddress, decode: decodeBtcAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/btg.ts b/src/coin/btg.ts index 1ab509fe..8f439132 100644 --- a/src/coin/btg.ts +++ b/src/coin/btg.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const btg = { coinType, encode: encodeBtgAddress, decode: decodeBtgAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/btm.ts b/src/coin/btm.ts index 7dfb0d77..7ebbdf9f 100644 --- a/src/coin/btm.ts +++ b/src/coin/btm.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32SegwitDecoder, createBech32SegwitEncoder, @@ -17,4 +17,4 @@ export const btm = { coinType, encode: encodeBtmAddress, decode: decodeBtmAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/bts.ts b/src/coin/bts.ts index 1b57ac4d..0cbbc1e3 100644 --- a/src/coin/bts.ts +++ b/src/coin/bts.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "bts"; @@ -14,4 +14,4 @@ export const bts = { coinType, encode: encodeBtsAddress, decode: decodeBtsAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/cca.ts b/src/coin/cca.ts index 98a7cb1d..9bd89e5b 100644 --- a/src/coin/cca.ts +++ b/src/coin/cca.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const cca = { coinType, encode: encodeCcaAddress, decode: decodeCcaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ccxx.ts b/src/coin/ccxx.ts index 831e3e19..9eea44b2 100644 --- a/src/coin/ccxx.ts +++ b/src/coin/ccxx.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const ccxx = { coinType, encode: encodeCcxxAddress, decode: decodeCcxxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/celoLegacy.ts b/src/coin/celoLegacy.ts index f021d262..8b47be63 100644 --- a/src/coin/celoLegacy.ts +++ b/src/coin/celoLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const celoLegacy = { coinType, encode: encodeCeloLegacyAddress, decode: decodeCeloLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ckb.ts b/src/coin/ckb.ts index 7eb49eab..6ac4790c 100644 --- a/src/coin/ckb.ts +++ b/src/coin/ckb.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "ckb"; @@ -14,4 +14,4 @@ export const ckb = { coinType, encode: encodeCkbAddress, decode: decodeCkbAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/cloLegacy.ts b/src/coin/cloLegacy.ts index a76a41b6..b327b0c3 100644 --- a/src/coin/cloLegacy.ts +++ b/src/coin/cloLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const cloLegacy = { coinType, encode: encodeCloLegacyAddress, decode: decodeCloLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/dash.ts b/src/coin/dash.ts index c6e608d4..3aa84c80 100644 --- a/src/coin/dash.ts +++ b/src/coin/dash.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const dash = { coinType, encode: encodeDashAddress, decode: decodeDashAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/dcr.ts b/src/coin/dcr.ts index 3aaf59cf..54502a28 100644 --- a/src/coin/dcr.ts +++ b/src/coin/dcr.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -15,4 +15,4 @@ export const dcr = { coinType, encode: encodeDcrAddress, decode: decodeDcrAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/dgb.ts b/src/coin/dgb.ts index 3fd8a40f..d355eb2f 100644 --- a/src/coin/dgb.ts +++ b/src/coin/dgb.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const dgb = { coinType, encode: encodeDgbAddress, decode: decodeDgbAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/divi.ts b/src/coin/divi.ts index ad9903bc..0daa216f 100644 --- a/src/coin/divi.ts +++ b/src/coin/divi.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const divi = { coinType, encode: encodeDiviAddress, decode: decodeDiviAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/doge.ts b/src/coin/doge.ts index e9b3cc46..4ef845b9 100644 --- a/src/coin/doge.ts +++ b/src/coin/doge.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const doge = { coinType, encode: encodeDogeAddress, decode: decodeDogeAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/dot.ts b/src/coin/dot.ts index c07c6566..8611d4c1 100644 --- a/src/coin/dot.ts +++ b/src/coin/dot.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createDotAddressDecoder, createDotAddressEncoder, @@ -17,4 +17,4 @@ export const dot = { coinType, encode: encodeDotAddress, decode: decodeDotAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/egld.ts b/src/coin/egld.ts index 6b2bd3d1..ce525d7c 100644 --- a/src/coin/egld.ts +++ b/src/coin/egld.ts @@ -1,8 +1,8 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "egld"; -const coinType = 120; +const coinType = 508; export const encodeEgldAddress = createBech32Encoder("erd"); export const decodeEgldAddress = createBech32Decoder("erd"); @@ -12,4 +12,4 @@ export const egld = { coinType, encode: encodeEgldAddress, decode: decodeEgldAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ela.ts b/src/coin/ela.ts index 88b13c79..801670c0 100644 --- a/src/coin/ela.ts +++ b/src/coin/ela.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -15,4 +15,4 @@ export const ela = { coinType, encode: encodeElaAddress, decode: decodeElaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/eos.ts b/src/coin/eos.ts index e5caea9c..8169698a 100644 --- a/src/coin/eos.ts +++ b/src/coin/eos.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "eos"; @@ -14,4 +14,4 @@ export const eos = { coinType, encode: encodeEosAddress, decode: decodeEosAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/etcLegacy.ts b/src/coin/etcLegacy.ts index a972d7d8..c19fcc48 100644 --- a/src/coin/etcLegacy.ts +++ b/src/coin/etcLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const etcLegacy = { coinType, encode: encodeEtcLegacyAddress, decode: decodeEtcLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/eth.ts b/src/coin/eth.ts index f9990feb..0d04356f 100644 --- a/src/coin/eth.ts +++ b/src/coin/eth.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const eth = { coinType, encode: encodeEthAddress, decode: decodeEthAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/etn.ts b/src/coin/etn.ts index 5560a6df..f9852d5a 100644 --- a/src/coin/etn.ts +++ b/src/coin/etn.ts @@ -1,7 +1,7 @@ import { keccak_256 } from "@noble/hashes/sha3"; import { concatBytes } from "@noble/hashes/utils"; import { utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { decodeXmrAddress, encodeXmrAddress } from "./xmr.js"; const name = "etn"; @@ -31,4 +31,4 @@ export const etn = { coinType, encode: encodeEtnAddress, decode: decodeEtnAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ewtLegacy.ts b/src/coin/ewtLegacy.ts index f196ac57..6fb49feb 100644 --- a/src/coin/ewtLegacy.ts +++ b/src/coin/ewtLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const ewtLegacy = { coinType, encode: encodeEwtLegacyAddress, decode: decodeEwtLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/fil.ts b/src/coin/fil.ts index 499653c2..431d437d 100644 --- a/src/coin/fil.ts +++ b/src/coin/fil.ts @@ -1,7 +1,7 @@ import { equalBytes } from "@noble/curves/abstract/utils"; import { blake2b } from "@noble/hashes/blake2b"; import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base32UnpaddedDecode, base32UnpaddedEncode } from "../utils/base32.js"; import { decodeLeb128, encodeLeb128 } from "../utils/leb128.js"; @@ -69,4 +69,4 @@ export const fil = { coinType, encode: encodeFilAddress, decode: decodeFilAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/fio.ts b/src/coin/fio.ts index f740f20b..b8b19d18 100644 --- a/src/coin/fio.ts +++ b/src/coin/fio.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "fio"; @@ -14,4 +14,4 @@ export const fio = { coinType, encode: encodeFioAddress, decode: decodeFioAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/firo.ts b/src/coin/firo.ts index 9613bec7..2108a83a 100644 --- a/src/coin/firo.ts +++ b/src/coin/firo.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const firo = { coinType, encode: encodeFiroAddress, decode: decodeFiroAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/flow.ts b/src/coin/flow.ts index 169d0c7d..1fede0ca 100644 --- a/src/coin/flow.ts +++ b/src/coin/flow.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToHex, hexWithoutPrefixToBytes } from "../utils/bytes.js"; import { validateFlowAddress } from "../utils/flow.js"; @@ -30,4 +30,4 @@ export const flow = { coinType, encode: encodeFlowAddress, decode: decodeFlowAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/zel.test.ts b/src/coin/flux.test.ts similarity index 71% rename from src/coin/zel.test.ts rename to src/coin/flux.test.ts index 4262708b..392369fc 100644 --- a/src/coin/zel.test.ts +++ b/src/coin/flux.test.ts @@ -1,6 +1,6 @@ import { hexToBytes } from "@noble/hashes/utils"; import { describe, expect, test } from "bun:test"; -import { decodeZelAddress, encodeZelAddress } from "./zel.js"; +import { decodeFluxAddress, encodeFluxAddress } from "./flux.js"; describe.each([ { @@ -13,9 +13,9 @@ describe.each([ }, ])("zel address", ({ text, hex }) => { test(`encode: ${text}`, () => { - expect(encodeZelAddress(hexToBytes(hex))).toEqual(text); + expect(encodeFluxAddress(hexToBytes(hex))).toEqual(text); }); test(`decode: ${text}`, () => { - expect(decodeZelAddress(text)).toEqual(hexToBytes(hex)); + expect(decodeFluxAddress(text)).toEqual(hexToBytes(hex)); }); }); diff --git a/src/coin/zel.ts b/src/coin/flux.ts similarity index 53% rename from src/coin/zel.ts rename to src/coin/flux.ts index 636c4cc9..98a6ab45 100644 --- a/src/coin/zel.ts +++ b/src/coin/flux.ts @@ -1,27 +1,27 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createZcashDecoder, createZcashEncoder } from "../utils/zcash.js"; -const name = "zel"; +const name = "flux"; const coinType = 19167; const hrp = "za"; const p2pkhVersions = [new Uint8Array([0x1c, 0xb8])]; const p2shVersions = [new Uint8Array([0x1c, 0xbd])]; -export const encodeZelAddress = createZcashEncoder({ +export const encodeFluxAddress = createZcashEncoder({ hrp, p2pkhVersions, p2shVersions, }); -export const decodeZelAddress = createZcashDecoder({ +export const decodeFluxAddress = createZcashDecoder({ hrp, p2pkhVersions, p2shVersions, }); -export const zel = { +export const flux = { name, coinType, - encode: encodeZelAddress, - decode: decodeZelAddress, -} as const satisfies Coin; + encode: encodeFluxAddress, + decode: decodeFluxAddress, +} as const satisfies CheckedCoin; diff --git a/src/coin/ftmLegacy.ts b/src/coin/ftmLegacy.ts index fc87499a..bd3d04ed 100644 --- a/src/coin/ftmLegacy.ts +++ b/src/coin/ftmLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const ftmLegacy = { coinType, encode: encodeFtmLegacyAddress, decode: decodeFtmLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/gnoLegacy.ts b/src/coin/gnoLegacy.ts index 04180269..43789cdb 100644 --- a/src/coin/gnoLegacy.ts +++ b/src/coin/gnoLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const gnoLegacy = { coinType, encode: encodeGnoLegacyAddress, decode: decodeGnoLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/goLegacy.ts b/src/coin/goLegacy.ts index 8d4b0737..148d7ceb 100644 --- a/src/coin/goLegacy.ts +++ b/src/coin/goLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const goLegacy = { coinType, encode: encodeGoLegacyAddress, decode: decodeGoLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/grin.ts b/src/coin/grin.ts index e7deddb0..0a81d0a5 100644 --- a/src/coin/grin.ts +++ b/src/coin/grin.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "grin"; @@ -14,4 +14,4 @@ export const grin = { coinType, encode: encodeGrinAddress, decode: decodeGrinAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/gxc.ts b/src/coin/gxc.ts index a439b2a9..e47e19b9 100644 --- a/src/coin/gxc.ts +++ b/src/coin/gxc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "gxc"; @@ -14,4 +14,4 @@ export const gxc = { coinType, encode: encodeGxcAddress, decode: decodeGxcAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/hbar.ts b/src/coin/hbar.ts index a5123edb..46ccc91d 100644 --- a/src/coin/hbar.ts +++ b/src/coin/hbar.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "hbar"; const coinType = 3030; @@ -36,4 +36,4 @@ export const hbar = { coinType, encode: encodeHbarAddress, decode: decodeHbarAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/hive.ts b/src/coin/hive.ts index f68e7a57..608e833c 100644 --- a/src/coin/hive.ts +++ b/src/coin/hive.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "hive"; @@ -14,4 +14,4 @@ export const hive = { coinType, encode: encodeHiveAddress, decode: decodeHiveAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/hns.ts b/src/coin/hns.ts index 619f9b1d..11715a02 100644 --- a/src/coin/hns.ts +++ b/src/coin/hns.ts @@ -1,5 +1,5 @@ import { bech32 } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "hns"; const coinType = 5353; @@ -31,4 +31,4 @@ export const hns = { coinType, encode: encodeHnsAddress, decode: decodeHnsAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/hnt.ts b/src/coin/hnt.ts index 5adab41f..cb1b03e5 100644 --- a/src/coin/hnt.ts +++ b/src/coin/hnt.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "hnt"; @@ -23,4 +23,4 @@ export const hnt = { coinType, encode: encodeHntAddress, decode: decodeHntAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/icx.ts b/src/coin/icx.ts index bc161269..e28cb08e 100644 --- a/src/coin/icx.ts +++ b/src/coin/icx.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToHexWithoutPrefix, hexWithoutPrefixToBytes, @@ -31,4 +31,4 @@ export const icx = { coinType, encode: encodeIcxAddress, decode: decodeIcxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/iost.ts b/src/coin/iost.ts index f8ae7810..43f33e51 100644 --- a/src/coin/iost.ts +++ b/src/coin/iost.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -15,4 +15,4 @@ export const iost = { coinType, encode: encodeIostAddress, decode: decodeIostAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/iota.ts b/src/coin/iota.ts index 8d03361c..eb0a2cb5 100644 --- a/src/coin/iota.ts +++ b/src/coin/iota.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "iota"; @@ -24,4 +24,4 @@ export const iota = { coinType, encode: encodeIotaAddress, decode: decodeIotaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/iotx.ts b/src/coin/iotx.ts index 890ccbd0..6b3394f1 100644 --- a/src/coin/iotx.ts +++ b/src/coin/iotx.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "iotx"; @@ -14,4 +14,4 @@ export const iotx = { coinType, encode: encodeIotxAddress, decode: decodeIotxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/iris.ts b/src/coin/iris.ts index 1743e858..d51f8fff 100644 --- a/src/coin/iris.ts +++ b/src/coin/iris.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "iris"; @@ -14,4 +14,4 @@ export const iris = { coinType, encode: encodeIrisAddress, decode: decodeIrisAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/kava.ts b/src/coin/kava.ts index da599fdc..b9f828ae 100644 --- a/src/coin/kava.ts +++ b/src/coin/kava.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "kava"; @@ -14,4 +14,4 @@ export const kava = { coinType, encode: encodeKavaAddress, decode: decodeKavaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/kmd.ts b/src/coin/kmd.ts index b65c62de..333f6478 100644 --- a/src/coin/kmd.ts +++ b/src/coin/kmd.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const kmd = { coinType, encode: encodeKmdAddress, decode: decodeKmdAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ksm.ts b/src/coin/ksm.ts index d32224c9..67d74aba 100644 --- a/src/coin/ksm.ts +++ b/src/coin/ksm.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createDotAddressDecoder, createDotAddressEncoder, @@ -17,4 +17,4 @@ export const ksm = { coinType, encode: encodeKsmAddress, decode: decodeKsmAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/lcc.ts b/src/coin/lcc.ts index 1d838bd7..a170db70 100644 --- a/src/coin/lcc.ts +++ b/src/coin/lcc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const lcc = { coinType, encode: encodeLccAddress, decode: decodeLccAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/lrg.ts b/src/coin/lrg.ts index f2c43c3b..2c8d90d7 100644 --- a/src/coin/lrg.ts +++ b/src/coin/lrg.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const lrg = { coinType, encode: encodeLrgAddress, decode: decodeLrgAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/lsk.ts b/src/coin/lsk.ts index d518d5bf..0116ea7b 100644 --- a/src/coin/lsk.ts +++ b/src/coin/lsk.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base10ToBytes, bytesToBase10 } from "../utils/bytes.js"; const name = "lsk"; @@ -22,4 +22,4 @@ export const lsk = { coinType, encode: encodeLskAddress, decode: decodeLskAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ltc.ts b/src/coin/ltc.ts index fda6404b..514f41f6 100644 --- a/src/coin/ltc.ts +++ b/src/coin/ltc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const ltc = { coinType, encode: encodeLtcAddress, decode: decodeLtcAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/luna.ts b/src/coin/luna.ts index 52de9de5..4ce1333f 100644 --- a/src/coin/luna.ts +++ b/src/coin/luna.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "luna"; @@ -14,4 +14,4 @@ export const luna = { coinType, encode: encodeLunaAddress, decode: decodeLunaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/mona.ts b/src/coin/mona.ts index ad952783..8dccd1cc 100644 --- a/src/coin/mona.ts +++ b/src/coin/mona.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const mona = { coinType, encode: encodeMonaAddress, decode: decodeMonaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/mrx.ts b/src/coin/mrx.ts index 669fc469..9d8b66b4 100644 --- a/src/coin/mrx.ts +++ b/src/coin/mrx.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "mrx"; @@ -12,4 +12,4 @@ export const mrx = { coinType, encode: encodeMrxAddress, decode: decodeMrxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nano.ts b/src/coin/nano.ts index 7c2a0bb5..1cbcaadf 100644 --- a/src/coin/nano.ts +++ b/src/coin/nano.ts @@ -1,6 +1,6 @@ import { blake2b } from "@noble/hashes/blake2b"; import { utils, type Coder } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "nano"; const coinType = 165; @@ -69,4 +69,4 @@ export const nano = { coinType, encode: encodeNanoAddress, decode: decodeNanoAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nas.ts b/src/coin/nas.ts index b4a862b0..5d5539ec 100644 --- a/src/coin/nas.ts +++ b/src/coin/nas.ts @@ -1,6 +1,6 @@ import { sha3_256 } from "@noble/hashes/sha3"; import { utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -33,4 +33,4 @@ export const nas = { coinType, encode: encodeNasAddress, decode: decodeNasAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/near.ts b/src/coin/near.ts index 54578b0f..69890f7f 100644 --- a/src/coin/near.ts +++ b/src/coin/near.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToString, stringToBytes } from "../utils/bytes.js"; import { validateNearAddress } from "../utils/near.js"; @@ -22,4 +22,4 @@ export const near = { coinType, encode: encodeNearAddress, decode: decodeNearAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/neo.ts b/src/coin/neo.ts index 3a5c701a..7483eed3 100644 --- a/src/coin/neo.ts +++ b/src/coin/neo.ts @@ -1,8 +1,8 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "neo"; -const coinType = 239; +const coinType = 888; export const encodeNeoAddress = base58CheckEncode; export const decodeNeoAddress = base58CheckDecode; @@ -12,4 +12,4 @@ export const neo = { coinType, encode: encodeNeoAddress, decode: decodeNeoAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nim.ts b/src/coin/nim.ts index 0aa746ff..213e8f60 100644 --- a/src/coin/nim.ts +++ b/src/coin/nim.ts @@ -1,5 +1,5 @@ import { utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "nim"; const coinType = 242; @@ -63,4 +63,4 @@ export const nim = { coinType, encode: encodeNimAddress, decode: decodeNimAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nmc.ts b/src/coin/nmc.ts index f34f2a80..2f989525 100644 --- a/src/coin/nmc.ts +++ b/src/coin/nmc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "nmc"; @@ -12,4 +12,4 @@ export const nmc = { coinType, encode: encodeNmcAddress, decode: decodeNmcAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nostr.ts b/src/coin/nostr.ts index 4d2133cb..5102aace 100644 --- a/src/coin/nostr.ts +++ b/src/coin/nostr.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "nostr"; @@ -14,4 +14,4 @@ export const nostr = { coinType, encode: encodeNostrAddress, decode: decodeNostrAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nrgLegacy.ts b/src/coin/nrgLegacy.ts index cdc87470..fae9134c 100644 --- a/src/coin/nrgLegacy.ts +++ b/src/coin/nrgLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const nrgLegacy = { coinType, encode: encodeNrgLegacyAddress, decode: decodeNrgLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/nuls.ts b/src/coin/nuls.ts index 669573d9..ba3bbaf1 100644 --- a/src/coin/nuls.ts +++ b/src/coin/nuls.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -77,4 +77,4 @@ export const nuls = { coinType, encode: encodeNulsAddress, decode: decodeNulsAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/one.ts b/src/coin/one.ts index 97f8d177..6d2be923 100644 --- a/src/coin/one.ts +++ b/src/coin/one.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "one"; @@ -14,4 +14,4 @@ export const one = { coinType, encode: encodeOneAddress, decode: decodeOneAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ont.ts b/src/coin/ont.ts index ea771216..ef064f2b 100644 --- a/src/coin/ont.ts +++ b/src/coin/ont.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "ont"; @@ -23,4 +23,4 @@ export const ont = { coinType, encode: encodeOntAddress, decode: decodeOntAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/poaLegacy.ts b/src/coin/poaLegacy.ts index 90e839d5..0be872ae 100644 --- a/src/coin/poaLegacy.ts +++ b/src/coin/poaLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const poaLegacy = { coinType, encode: encodePoaLegacyAddress, decode: decodePoaLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ppc.ts b/src/coin/ppc.ts index ba5aa136..64f333e2 100644 --- a/src/coin/ppc.ts +++ b/src/coin/ppc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const ppc = { coinType, encode: encodePpcAddress, decode: decodePpcAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/qtum.ts b/src/coin/qtum.ts index 15a8f1a7..6d0f48e5 100644 --- a/src/coin/qtum.ts +++ b/src/coin/qtum.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "qtum"; @@ -12,4 +12,4 @@ export const qtum = { coinType, encode: encodeQtumAddress, decode: decodeQtumAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/rsk.test.ts b/src/coin/rbtc.test.ts similarity index 65% rename from src/coin/rsk.test.ts rename to src/coin/rbtc.test.ts index 307ba77b..4230c448 100644 --- a/src/coin/rsk.test.ts +++ b/src/coin/rbtc.test.ts @@ -1,6 +1,6 @@ import { hexToBytes } from "@noble/hashes/utils"; import { describe, expect, test } from "bun:test"; -import { decodeRskAddress, encodeRskAddress } from "./rsk.js"; +import { decodeRbtcAddress, encodeRbtcAddress } from "./rbtc.js"; describe.each([ { @@ -9,9 +9,9 @@ describe.each([ }, ])("rsk address", ({ text, hex }) => { test(`encode: ${text}`, () => { - expect(encodeRskAddress(hexToBytes(hex))).toEqual(text); + expect(encodeRbtcAddress(hexToBytes(hex))).toEqual(text); }); test(`decode: ${text}`, () => { - expect(decodeRskAddress(text)).toEqual(hexToBytes(hex)); + expect(decodeRbtcAddress(text)).toEqual(hexToBytes(hex)); }); }); diff --git a/src/coin/rbtc.ts b/src/coin/rbtc.ts new file mode 100644 index 00000000..cf4dad1b --- /dev/null +++ b/src/coin/rbtc.ts @@ -0,0 +1,20 @@ +import type { CheckedCoin } from "../types.js"; +import { + createHexChecksummedDecoder, + createHexChecksummedEncoder, +} from "../utils/hex.js"; + +const name = "rbtc"; +const coinType = 137; + +const chainId = 30; + +export const encodeRbtcAddress = createHexChecksummedEncoder(chainId); +export const decodeRbtcAddress = createHexChecksummedDecoder(chainId); + +export const rbtc = { + name, + coinType, + encode: encodeRbtcAddress, + decode: decodeRbtcAddress, +} as const satisfies CheckedCoin; diff --git a/src/coin/rdd.ts b/src/coin/rdd.ts index b21321da..5dd5a154 100644 --- a/src/coin/rdd.ts +++ b/src/coin/rdd.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const rdd = { coinType, encode: encodeRddAddress, decode: decodeRddAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/rsk.ts b/src/coin/rsk.ts deleted file mode 100644 index 7dc7cbeb..00000000 --- a/src/coin/rsk.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Coin } from "../types.js"; -import { - createHexChecksummedDecoder, - createHexChecksummedEncoder, -} from "../utils/hex.js"; - -const name = "rsk"; -const coinType = 137; - -const chainId = 30; - -export const encodeRskAddress = createHexChecksummedEncoder(chainId); -export const decodeRskAddress = createHexChecksummedDecoder(chainId); - -export const rsk = { - name, - coinType, - encode: encodeRskAddress, - decode: decodeRskAddress, -} as const satisfies Coin; diff --git a/src/coin/rune.ts b/src/coin/rune.ts index 4049e1a9..96902ffa 100644 --- a/src/coin/rune.ts +++ b/src/coin/rune.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "rune"; @@ -14,4 +14,4 @@ export const rune = { coinType, encode: encodeRuneAddress, decode: decodeRuneAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/rvn.ts b/src/coin/rvn.ts index 8da3d95d..b211a000 100644 --- a/src/coin/rvn.ts +++ b/src/coin/rvn.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const rvn = { coinType, encode: encodeRvnAddress, decode: decodeRvnAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/sc.ts b/src/coin/sc.ts index dd4686ae..d1b60ce9 100644 --- a/src/coin/sc.ts +++ b/src/coin/sc.ts @@ -1,7 +1,7 @@ import { equalBytes } from "@noble/curves/abstract/utils"; import { blake2b } from "@noble/hashes/blake2b"; import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToHexWithoutPrefix, hexWithoutPrefixToBytes, @@ -39,4 +39,4 @@ export const sc = { coinType, encode: encodeScAddress, decode: decodeScAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/sero.ts b/src/coin/sero.ts index 5a377a65..585e8752 100644 --- a/src/coin/sero.ts +++ b/src/coin/sero.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -19,4 +19,4 @@ export const sero = { coinType, encode: encodeSeroAddress, decode: decodeSeroAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/sol.ts b/src/coin/sol.ts index c91b2203..af4e2a8f 100644 --- a/src/coin/sol.ts +++ b/src/coin/sol.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -15,4 +15,4 @@ export const sol = { coinType, encode: encodeSolAddress, decode: decodeSolAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/srm.ts b/src/coin/srm.ts index 97d03878..511d3c73 100644 --- a/src/coin/srm.ts +++ b/src/coin/srm.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -15,4 +15,4 @@ export const srm = { coinType, encode: encodeSrmAddress, decode: decodeSrmAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/steem.ts b/src/coin/steem.ts index 5fee222f..2b3a801c 100644 --- a/src/coin/steem.ts +++ b/src/coin/steem.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createEosDecoder, createEosEncoder } from "../utils/eosio.js"; const name = "steem"; @@ -14,4 +14,4 @@ export const steem = { coinType, encode: encodeSteemAddress, decode: decodeSteemAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/strat.ts b/src/coin/strat.ts index 697540e6..06ad67da 100644 --- a/src/coin/strat.ts +++ b/src/coin/strat.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const strat = { coinType, encode: encodeStratAddress, decode: decodeStratAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/strk.ts b/src/coin/strk.ts index d3b35479..4a8f2003 100644 --- a/src/coin/strk.ts +++ b/src/coin/strk.ts @@ -1,5 +1,5 @@ import { keccak_256 } from "@noble/hashes/sha3"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToHexWithoutPrefix, hexToBytes, @@ -47,4 +47,4 @@ export const strk = { coinType, encode: encodeStrkAddress, decode: decodeStrkAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/stx.ts b/src/coin/stx.ts index 99e0a7f1..207f754b 100644 --- a/src/coin/stx.ts +++ b/src/coin/stx.ts @@ -2,7 +2,7 @@ import { equalBytes } from "@noble/curves/abstract/utils"; import { sha256 } from "@noble/hashes/sha256"; import { concatBytes } from "@noble/hashes/utils"; import { utils, type Coder } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base32CrockfordNormalise } from "../utils/base32.js"; const name = "stx"; @@ -104,4 +104,4 @@ export const stx = { coinType, encode: encodeStxAddress, decode: decodeStxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/sys.ts b/src/coin/sys.ts index fe8cda06..a1ebbf3a 100644 --- a/src/coin/sys.ts +++ b/src/coin/sys.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBitcoinDecoder, createBitcoinEncoder, @@ -27,4 +27,4 @@ export const sys = { coinType, encode: encodeSysAddress, decode: decodeSysAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/tfuel.ts b/src/coin/tfuel.ts index 9a6b5ca2..56d64367 100644 --- a/src/coin/tfuel.ts +++ b/src/coin/tfuel.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const tfuel = { coinType, encode: encodeTfuelAddress, decode: decodeTfuelAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/thetaLegacy.ts b/src/coin/thetaLegacy.ts index 76ac15c7..2e6b1192 100644 --- a/src/coin/thetaLegacy.ts +++ b/src/coin/thetaLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const thetaLegacy = { coinType, encode: encodeThetaLegacyAddress, decode: decodeThetaLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/tomoLegacy.ts b/src/coin/tomoLegacy.ts index d51bcef1..4beee9fc 100644 --- a/src/coin/tomoLegacy.ts +++ b/src/coin/tomoLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const tomoLegacy = { coinType, encode: encodeTomoLegacyAddress, decode: decodeTomoLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/trx.ts b/src/coin/trx.ts index 5d9f19e1..98e5cd7c 100644 --- a/src/coin/trx.ts +++ b/src/coin/trx.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "trx"; @@ -12,4 +12,4 @@ export const trx = { coinType, encode: encodeTrxAddress, decode: decodeTrxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/ttLegacy.ts b/src/coin/ttLegacy.ts index 2cfb8ba5..776f337a 100644 --- a/src/coin/ttLegacy.ts +++ b/src/coin/ttLegacy.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, @@ -15,4 +15,4 @@ export const ttLegacy = { coinType, encode: encodeTtLegacyAddress, decode: decodeTtLegacyAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/vet.ts b/src/coin/vet.ts index 6d4e4b4c..97652d58 100644 --- a/src/coin/vet.ts +++ b/src/coin/vet.ts @@ -1,11 +1,11 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createHexChecksummedDecoder, createHexChecksummedEncoder, } from "../utils/hex.js"; const name = "vet"; -const coinType = 703; +const coinType = 818; export const encodeVetAddress = createHexChecksummedEncoder(); export const decodeVetAddress = createHexChecksummedDecoder(); @@ -15,4 +15,4 @@ export const vet = { coinType, encode: encodeVetAddress, decode: decodeVetAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/via.ts b/src/coin/via.ts index 1de7df2d..2c1a4d6b 100644 --- a/src/coin/via.ts +++ b/src/coin/via.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const via = { coinType, encode: encodeViaAddress, decode: decodeViaAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/vlx.ts b/src/coin/vlx.ts index 3fe2cfba..0e964cd4 100644 --- a/src/coin/vlx.ts +++ b/src/coin/vlx.ts @@ -1,11 +1,11 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, } from "../utils/base58.js"; const name = "vlx"; -const coinType = 574; +const coinType = 5655640; export const encodeVlxAddress = base58UncheckedEncode; export const decodeVlxAddress = base58UncheckedDecode; @@ -15,4 +15,4 @@ export const vlx = { coinType, encode: encodeVlxAddress, decode: decodeVlxAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/vlxLegacy.test.ts b/src/coin/vlxLegacy.test.ts new file mode 100644 index 00000000..9f85145b --- /dev/null +++ b/src/coin/vlxLegacy.test.ts @@ -0,0 +1,17 @@ +import { hexToBytes } from "@noble/hashes/utils"; +import { describe, expect, test } from "bun:test"; +import { decodeVlxAddress, encodeVlxAddress } from "./vlx.js"; + +describe.each([ + { + text: "VDTHiswjSTkLFbfh2S5XFsqkLzC11HoBD6", + hex: "461ea68e5e13c72abf1bd2f0bcae4650521712cdb76276f0d5", + }, +])("vlx address", ({ text, hex }) => { + test(`encode: ${text}`, () => { + expect(encodeVlxAddress(hexToBytes(hex))).toEqual(text); + }); + test(`decode: ${text}`, () => { + expect(decodeVlxAddress(text)).toEqual(hexToBytes(hex)); + }); +}); diff --git a/src/coin/vlxLegacy.ts b/src/coin/vlxLegacy.ts new file mode 100644 index 00000000..77efbdf7 --- /dev/null +++ b/src/coin/vlxLegacy.ts @@ -0,0 +1,18 @@ +import type { CheckedCoin } from "../types.js"; +import { + base58UncheckedDecode, + base58UncheckedEncode, +} from "../utils/base58.js"; + +const name = "vlxLegacy"; +const coinType = 574; + +export const encodeVlxLegacyAddress = base58UncheckedEncode; +export const decodeVlxLegacyAddress = base58UncheckedDecode; + +export const vlxLegacy = { + name, + coinType, + encode: encodeVlxLegacyAddress, + decode: decodeVlxLegacyAddress, +} as const satisfies CheckedCoin; diff --git a/src/coin/vsys.ts b/src/coin/vsys.ts index ba288717..232f74d9 100644 --- a/src/coin/vsys.ts +++ b/src/coin/vsys.ts @@ -1,7 +1,7 @@ import { equalBytes } from "@noble/curves/abstract/utils"; import { blake2b } from "@noble/hashes/blake2b"; import { keccak_256 } from "@noble/hashes/sha3"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -41,4 +41,4 @@ export const vsys = { coinType, encode: encodeVsysAddress, decode: decodeVsysAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/wan.ts b/src/coin/wan.ts index 83b1c631..57b70a71 100644 --- a/src/coin/wan.ts +++ b/src/coin/wan.ts @@ -1,5 +1,5 @@ import { keccak_256 } from "@noble/hashes/sha3"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { bytesToHexWithoutPrefix, hexToBytes, @@ -51,4 +51,4 @@ export const wan = { coinType, encode: encodeWanAddress, decode: decodeWanAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/waves.ts b/src/coin/waves.ts index 4c5206c1..fbb66c83 100644 --- a/src/coin/waves.ts +++ b/src/coin/waves.ts @@ -1,7 +1,7 @@ import { blake2b } from "@noble/hashes/blake2b"; import { keccak_256 } from "@noble/hashes/sha3"; import { utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58UncheckedDecode, base58UncheckedEncode, @@ -34,4 +34,4 @@ export const waves = { coinType, encode: encodeWavesAddress, decode: decodeWavesAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/wicc.ts b/src/coin/wicc.ts index ed030316..55dfd8db 100644 --- a/src/coin/wicc.ts +++ b/src/coin/wicc.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const wicc = { coinType, encode: encodeWiccAddress, decode: decodeWiccAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xch.ts b/src/coin/xch.ts index 508f8c2e..cca13e0d 100644 --- a/src/coin/xch.ts +++ b/src/coin/xch.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32mDecoder, createBech32mEncoder } from "../utils/bech32.js"; const name = "xch"; @@ -15,4 +15,4 @@ export const xch = { coinType, encode: encodeXchAddress, decode: decodeXchAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xem.ts b/src/coin/xem.ts index 7e312a23..5e9cb0df 100644 --- a/src/coin/xem.ts +++ b/src/coin/xem.ts @@ -1,5 +1,5 @@ import { keccak_256 } from "@noble/hashes/sha3"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base32Decode, base32Encode } from "../utils/base32.js"; import { bytesToHexWithoutPrefix } from "../utils/bytes.js"; @@ -30,4 +30,4 @@ export const xem = { coinType, encode: encodeXemAddress, decode: decodeXemAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xhv.ts b/src/coin/xhv.ts index fc36e45b..96893265 100644 --- a/src/coin/xhv.ts +++ b/src/coin/xhv.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { decodeXmrAddress, encodeXmrAddress } from "./xmr.js"; const name = "xhv"; @@ -12,4 +12,4 @@ export const xhv = { coinType, encode: encodeXhvAddress, decode: decodeXhvAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xlm.ts b/src/coin/xlm.ts index 5782549f..d878e0cb 100644 --- a/src/coin/xlm.ts +++ b/src/coin/xlm.ts @@ -1,6 +1,6 @@ import { equalBytes } from "@noble/curves/abstract/utils"; import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base32Decode, base32Encode } from "../utils/base32.js"; import { hexWithoutPrefixToBytes } from "../utils/bytes.js"; @@ -59,4 +59,4 @@ export const xlm = { coinType, encode: encodeXlmAddress, decode: decodeXlmAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xmr.ts b/src/coin/xmr.ts index b204692c..c1ec42c0 100644 --- a/src/coin/xmr.ts +++ b/src/coin/xmr.ts @@ -1,5 +1,5 @@ import { base58xmr } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "xmr"; const coinType = 128; @@ -12,4 +12,4 @@ export const xmr = { coinType, encode: encodeXmrAddress, decode: decodeXmrAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xrp.ts b/src/coin/xrp.ts index a025598e..e0f8b548 100644 --- a/src/coin/xrp.ts +++ b/src/coin/xrp.ts @@ -1,6 +1,6 @@ import { sha256 } from "@noble/hashes/sha256"; import { base58xrp, utils } from "@scure/base"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; const name = "xrp"; const coinType = 144; @@ -18,4 +18,4 @@ export const xrp = { coinType, encode: encodeXrpAddress, decode: decodeXrpAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xtz.ts b/src/coin/xtz.ts index 1d4871af..46dd85d2 100644 --- a/src/coin/xtz.ts +++ b/src/coin/xtz.ts @@ -1,5 +1,5 @@ import { concatBytes } from "@noble/hashes/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "xtz"; @@ -55,4 +55,4 @@ export const xtz = { coinType, encode: encodeXtzAddress, decode: decodeXtzAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/xvg.ts b/src/coin/xvg.ts index b57690c5..96fa3527 100644 --- a/src/coin/xvg.ts +++ b/src/coin/xvg.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBase58VersionedDecoder, createBase58VersionedEncoder, @@ -24,4 +24,4 @@ export const xvg = { coinType, encode: encodeXvgAddress, decode: decodeXvgAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/zec.ts b/src/coin/zec.ts index 7fa9f991..91b4c8c1 100644 --- a/src/coin/zec.ts +++ b/src/coin/zec.ts @@ -1,4 +1,4 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createZcashDecoder, createZcashEncoder } from "../utils/zcash.js"; const name = "zec"; @@ -24,4 +24,4 @@ export const zec = { coinType, encode: encodeZecAddress, decode: decodeZecAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/zen.ts b/src/coin/zen.ts index 4d283d59..f770c0b4 100644 --- a/src/coin/zen.ts +++ b/src/coin/zen.ts @@ -1,5 +1,5 @@ import { equalBytes } from "@noble/curves/abstract/utils"; -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { base58CheckDecode, base58CheckEncode } from "../utils/base58.js"; const name = "zen"; @@ -35,4 +35,4 @@ export const zen = { coinType, encode: encodeZenAddress, decode: decodeZenAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coin/zil.ts b/src/coin/zil.ts index 8c1123c6..09ee5edc 100644 --- a/src/coin/zil.ts +++ b/src/coin/zil.ts @@ -1,8 +1,8 @@ -import type { Coin } from "../types.js"; +import type { CheckedCoin } from "../types.js"; import { createBech32Decoder, createBech32Encoder } from "../utils/bech32.js"; const name = "zil"; -const coinType = 119; +const coinType = 313; export const encodeZilAddress = createBech32Encoder("zil"); export const decodeZilAddress = createBech32Decoder("zil"); @@ -12,4 +12,4 @@ export const zil = { coinType, encode: encodeZilAddress, decode: decodeZilAddress, -} as const satisfies Coin; +} as const satisfies CheckedCoin; diff --git a/src/coins.test.ts b/src/coins.test.ts new file mode 100644 index 00000000..9bb14e08 --- /dev/null +++ b/src/coins.test.ts @@ -0,0 +1,14 @@ +import { expect, test } from "bun:test"; +import * as coins from "./coins.js"; +import { nonEvmCoinNameToTypeMap } from "./consts/coinNameToTypeMap.js"; + +const coinNames = Object.keys(nonEvmCoinNameToTypeMap); + +test.each(coinNames)("coins.ts export - %s", (coinName) => { + const obj = coins[coinName]; + expect(obj).toBeObject(); + expect(obj.name).toBe(coinName); + expect(obj.coinType).toBe(nonEvmCoinNameToTypeMap[coinName]); + expect(obj.encode).toBeFunction(); + expect(obj.decode).toBeFunction(); +}); diff --git a/src/coins.ts b/src/coins.ts index e3d59f65..a17852aa 100644 --- a/src/coins.ts +++ b/src/coins.ts @@ -42,6 +42,7 @@ export { fil } from "./coin/fil.js"; export { fio } from "./coin/fio.js"; export { firo } from "./coin/firo.js"; export { flow } from "./coin/flow.js"; +export { flux } from "./coin/flux.js"; export { ftmLegacy } from "./coin/ftmLegacy.js"; export { gnoLegacy } from "./coin/gnoLegacy.js"; export { goLegacy } from "./coin/goLegacy.js"; @@ -80,8 +81,8 @@ export { ont } from "./coin/ont.js"; export { poaLegacy } from "./coin/poaLegacy.js"; export { ppc } from "./coin/ppc.js"; export { qtum } from "./coin/qtum.js"; +export { rbtc } from "./coin/rbtc.js"; export { rdd } from "./coin/rdd.js"; -export { rsk } from "./coin/rsk.js"; export { rune } from "./coin/rune.js"; export { rvn } from "./coin/rvn.js"; export { sc } from "./coin/sc.js"; @@ -101,6 +102,7 @@ export { ttLegacy } from "./coin/ttLegacy.js"; export { vet } from "./coin/vet.js"; export { via } from "./coin/via.js"; export { vlx } from "./coin/vlx.js"; +export { vlxLegacy } from "./coin/vlxLegacy.js"; export { vsys } from "./coin/vsys.js"; export { wan } from "./coin/wan.js"; export { waves } from "./coin/waves.js"; @@ -114,6 +116,5 @@ export { xrp } from "./coin/xrp.js"; export { xtz } from "./coin/xtz.js"; export { xvg } from "./coin/xvg.js"; export { zec } from "./coin/zec.js"; -export { zel } from "./coin/zel.js"; export { zen } from "./coin/zen.js"; export { zil } from "./coin/zil.js"; diff --git a/src/index.test.ts b/src/index.test.ts index a8dbc891..297c7038 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,16 +1,29 @@ import { expect, test } from "bun:test"; +import { + evmCoinNameToTypeMap, + nonEvmCoinNameToTypeMap, +} from "./consts/coinNameToTypeMap.js"; +import { + evmCoinTypeToNameMap, + nonEvmCoinTypeToNameMap, +} from "./consts/coinTypeToNameMap.js"; import { getCoderByCoinName, getCoderByCoinType } from "./index.js"; +import { coinTypeToEvmChainId } from "./utils/evm.js"; test("coin name", () => { const coder = getCoderByCoinName("btc"); expect(coder.coinType).toBe(0); expect(coder.name).toBe("btc"); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); }); test("coin type", () => { const coder = getCoderByCoinType(0); expect(coder.coinType).toBe(0); expect(coder.name).toBe("btc"); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); }); test("evm coin name", () => { @@ -18,6 +31,8 @@ test("evm coin name", () => { expect(coder.coinType).toBe(2147483658); expect(coder.name).toBe("op"); expect(coder.evmChainId).toBe(10); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); }); test("evm coin type", () => { @@ -25,4 +40,46 @@ test("evm coin type", () => { expect(coder.coinType).toBe(2147483658); expect(coder.name).toBe("op"); expect(coder.evmChainId).toBe(10); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); + +const nonEvmCoinNames = Object.keys(nonEvmCoinNameToTypeMap); +const evmCoinNames = Object.keys(evmCoinNameToTypeMap); + +test.each(nonEvmCoinNames)('getCoderByCoinName("%s")', (coinName) => { + const coder = getCoderByCoinName(coinName); + expect(coder.name).toBe(coinName); + expect(coder.coinType).toBe(nonEvmCoinNameToTypeMap[coinName]); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); + +test.each(evmCoinNames)('getCoderByCoinName("%s")', (coinName) => { + const coder = getCoderByCoinName(coinName); + expect(coder.name).toBe(coinName); + expect(coder.coinType).toBe(evmCoinNameToTypeMap[coinName]); + expect(coder.evmChainId).toBe(coinTypeToEvmChainId(coder.coinType)); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); + +const nonEvmCoinTypes = Object.values(nonEvmCoinNameToTypeMap); +const evmCoinTypes = Object.values(evmCoinNameToTypeMap); + +test.each(nonEvmCoinTypes)("getCoderByCoinType(%d)", (coinType) => { + const coder = getCoderByCoinType(coinType); + expect(coder.name).toBe(nonEvmCoinTypeToNameMap[coinType][0]); + expect(coder.coinType).toBe(coinType); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); +}); + +test.each(evmCoinTypes)("getCoderByCoinType(%d)", (coinType) => { + const coder = getCoderByCoinType(coinType); + expect(coder.name).toBe(evmCoinTypeToNameMap[coinType][0]); + expect(coder.coinType).toBe(coinType); + expect(coder.evmChainId).toBe(coinTypeToEvmChainId(coinType)); + expect(coder.encode).toBeFunction(); + expect(coder.decode).toBeFunction(); });