chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
154 lines (153 loc) • 6.22 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NETWORKS_INFO = void 0;
exports.createNetworkCollection = createNetworkCollection;
const UtxoNetworkDescriptor_1 = require("./UtxoNetworkDescriptor");
const BchNetworkDescriptor_1 = require("./BchNetworkDescriptor");
const EvmNetworkDescriptor_1 = require("./EvmNetworkDescriptor");
const EvmRpcNetworkDescriptor_1 = require("./EvmRpcNetworkDescriptor");
// ---------------------------------------------------------------------------
// Static network data
// ---------------------------------------------------------------------------
/** @internal */
exports.NETWORKS_INFO = {
bitcoin: {
name: 'Bitcoin',
symbol: 'BTC',
type: 'utxo',
decimals: 8,
isTestnet: false,
hasOwnToken: true,
nativeToken: { symbol: 'BTC', name: 'Bitcoin' },
networkParams: { bech32: 'bc', pubKeyHash: 0x00, scriptHash: 0x05, wif: 0x80 },
defaultAddressType: 'segwit',
addressTypes: {
segwit: { derivationPath: "m/84'/0'/0'/0" },
taproot: { derivationPath: "m/86'/0'/0'/0" },
legacy: { derivationPath: "m/44'/0'/0'/0" },
},
},
litecoin: {
name: 'Litecoin',
symbol: 'LTC',
type: 'utxo',
decimals: 8,
isTestnet: false,
hasOwnToken: true,
nativeToken: { symbol: 'LTC', name: 'Litecoin' },
networkParams: { bech32: 'ltc', pubKeyHash: 0x30, scriptHash: 0x32, wif: 0xb0 },
defaultAddressType: 'segwit',
addressTypes: {
segwit: { derivationPath: "m/84'/2'/0'/0" },
taproot: { derivationPath: "m/86'/2'/0'/0" },
legacy: { derivationPath: "m/44'/2'/0'/0" },
},
},
dogecoin: {
name: 'Dogecoin',
symbol: 'DOGE',
type: 'utxo',
decimals: 8,
isTestnet: false,
hasOwnToken: true,
nativeToken: { symbol: 'DOGE', name: 'Dogecoin' },
networkParams: { bech32: 'doge', pubKeyHash: 0x1e, scriptHash: 0x16, wif: 0x9e },
defaultAddressType: 'legacy',
addressTypes: {
legacy: { derivationPath: "m/44'/3'/0'/0" },
},
},
bitcoincash: {
name: 'Bitcoin Cash',
symbol: 'BCH',
type: 'utxo',
decimals: 8,
isTestnet: false,
hasOwnToken: true,
nativeToken: { symbol: 'BCH', name: 'Bitcoin Cash' },
networkParams: { bech32: 'bc', pubKeyHash: 0x00, scriptHash: 0x05, wif: 0x80 },
defaultAddressType: 'cashaddr',
addressTypes: {
cashaddr: { derivationPath: "m/44'/145'/0'/0" },
legacy: { derivationPath: "m/44'/145'/0'/0" },
},
},
bitcointestnet: {
name: 'Bitcoin Testnet',
symbol: 'tBTC',
type: 'utxo',
decimals: 8,
isTestnet: true,
hasOwnToken: false,
nativeToken: { symbol: 'tBTC', name: 'Bitcoin Testnet' },
networkParams: { bech32: 'tb', pubKeyHash: 0x6f, scriptHash: 0xc4, wif: 0xef },
defaultAddressType: 'segwit',
addressTypes: {
segwit: { derivationPath: "m/84'/1'/0'/0" },
taproot: { derivationPath: "m/86'/1'/0'/0" },
legacy: { derivationPath: "m/44'/1'/0'/0" },
},
},
ethereum: {
name: 'Ethereum',
symbol: 'ETH',
type: 'evm',
decimals: 18,
isTestnet: false,
hasOwnToken: true,
nativeToken: { symbol: 'ETH', name: 'Ether' },
chainId: 1,
defaultAddressType: 'eoa',
addressTypes: {
eoa: { derivationPath: "m/44'/60'/0'/0" },
},
},
avalanche: {
name: 'Avalanche',
symbol: 'AVAX',
type: 'evm',
decimals: 18,
isTestnet: false,
hasOwnToken: true,
nativeToken: { symbol: 'AVAX', name: 'Avalanche' },
chainId: 43114,
defaultAddressType: 'eoa',
addressTypes: {
eoa: { derivationPath: "m/44'/60'/0'/0" },
},
},
};
/** @internal Builds the {@link NetworkCollection} for a {@link ChainGate} instance. */
function createNetworkCollection(marketsCache, apiKey) {
const bitcoin = new UtxoNetworkDescriptor_1.UtxoNetworkDescriptor('bitcoin', exports.NETWORKS_INFO.bitcoin, marketsCache, apiKey);
const litecoin = new UtxoNetworkDescriptor_1.UtxoNetworkDescriptor('litecoin', exports.NETWORKS_INFO.litecoin, marketsCache, apiKey);
const dogecoin = new UtxoNetworkDescriptor_1.UtxoNetworkDescriptor('dogecoin', exports.NETWORKS_INFO.dogecoin, marketsCache, apiKey);
const bitcoincash = new BchNetworkDescriptor_1.BchNetworkDescriptor(exports.NETWORKS_INFO.bitcoincash, marketsCache, apiKey);
const bitcointestnet = new UtxoNetworkDescriptor_1.UtxoNetworkDescriptor('bitcointestnet', exports.NETWORKS_INFO.bitcointestnet, marketsCache, apiKey);
const ethereum = new EvmNetworkDescriptor_1.EvmNetworkDescriptor('ethereum', exports.NETWORKS_INFO.ethereum, marketsCache, apiKey);
const avalanche = new EvmNetworkDescriptor_1.EvmNetworkDescriptor('avalanche', exports.NETWORKS_INFO.avalanche, marketsCache, apiKey);
const all = [
bitcoin,
litecoin,
dogecoin,
bitcoincash,
bitcointestnet,
ethereum,
avalanche,
];
const evmRpc = (config) => {
return new EvmRpcNetworkDescriptor_1.EvmRpcNetworkDescriptor(config, marketsCache);
};
const collection = all;
Object.defineProperties(collection, {
bitcoin: { value: bitcoin, writable: false, enumerable: false },
litecoin: { value: litecoin, writable: false, enumerable: false },
dogecoin: { value: dogecoin, writable: false, enumerable: false },
bitcoincash: { value: bitcoincash, writable: false, enumerable: false },
bitcointestnet: { value: bitcointestnet, writable: false, enumerable: false },
ethereum: { value: ethereum, writable: false, enumerable: false },
avalanche: { value: avalanche, writable: false, enumerable: false },
evmRpc: { value: evmRpc, writable: false, enumerable: false },
});
return Object.freeze(collection);
}