@pioneer-platform/pioneer-caip 9.2.7 → 9.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/data.d.ts +3 -39
- package/lib/data.js +45 -56
- package/package.json +2 -2
package/lib/data.d.ts
CHANGED
@@ -45,6 +45,7 @@ export declare enum Chain {
|
|
45
45
|
}
|
46
46
|
export declare const ChainToCaip: Record<string, string>;
|
47
47
|
export declare const ChainToNetworkId: Record<string, string>;
|
48
|
+
export declare const NetworkIdToChain: Record<string, string>;
|
48
49
|
export declare function getChainEnumValue(chainStr: string): Chain | undefined;
|
49
50
|
export declare const shortListSymbolToCoinGeckoPlatformId: {
|
50
51
|
ARB: string;
|
@@ -107,42 +108,5 @@ export declare const shortListNameToCaip: {
|
|
107
108
|
};
|
108
109
|
declare let tokenToCaip: (token: any) => any;
|
109
110
|
declare let thorchainToCaip: (chain: string, symbol: string, ticker: string, type: string) => string;
|
110
|
-
|
111
|
-
export
|
112
|
-
"eip155:1/slip44:60": {
|
113
|
-
name: string;
|
114
|
-
type: string;
|
115
|
-
caip: string;
|
116
|
-
tags: string[];
|
117
|
-
blockchain: string;
|
118
|
-
symbol: string;
|
119
|
-
decimals: number;
|
120
|
-
image: string;
|
121
|
-
description: string;
|
122
|
-
website: string;
|
123
|
-
explorer: string;
|
124
|
-
rank: number;
|
125
|
-
};
|
126
|
-
};
|
127
|
-
export declare const primaryAssets: {
|
128
|
-
"eip155:1/slip44:60": {
|
129
|
-
blockchain: string;
|
130
|
-
caip: string;
|
131
|
-
chainId: number;
|
132
|
-
description: string;
|
133
|
-
explorer: string;
|
134
|
-
faucets: never[];
|
135
|
-
feeAssetCaip: string;
|
136
|
-
feeAssetName: string;
|
137
|
-
feeAssetRank: number;
|
138
|
-
feeAssetSymbol: string;
|
139
|
-
image: string;
|
140
|
-
isCharted: boolean;
|
141
|
-
name: string;
|
142
|
-
network: string;
|
143
|
-
service: null;
|
144
|
-
symbol: string;
|
145
|
-
tags: (string | number | null)[];
|
146
|
-
type: string;
|
147
|
-
};
|
148
|
-
};
|
111
|
+
declare let caipToThorchain: (caip: string, ticker: string) => string | null;
|
112
|
+
export { thorchainToCaip, tokenToCaip, caipToThorchain };
|
package/lib/data.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.caipToThorchain = exports.tokenToCaip = exports.thorchainToCaip = exports.shortListNameToCaip = exports.shortListSymbolToCaip = exports.shortListSymbolToCoinGeckoPlatformId = exports.getChainEnumValue = exports.NetworkIdToChain = exports.ChainToNetworkId = exports.ChainToCaip = exports.Chain = exports.evmCaips = void 0;
|
4
4
|
exports.evmCaips = {
|
5
5
|
ethereum: 'eip155:1/slip44:60',
|
6
6
|
base: 'eip155:8453/slip44:60',
|
@@ -95,6 +95,12 @@ exports.ChainToNetworkId = {
|
|
95
95
|
'THOR': 'cosmos:thorchain-mainnet-v1',
|
96
96
|
'ZEC': 'bip122:0000000000196a45',
|
97
97
|
};
|
98
|
+
exports.NetworkIdToChain = Object.entries(exports.ChainToNetworkId)
|
99
|
+
.reduce(function (acc, _a) {
|
100
|
+
var key = _a[0], value = _a[1];
|
101
|
+
acc[value] = key;
|
102
|
+
return acc;
|
103
|
+
}, {});
|
98
104
|
function getChainEnumValue(chainStr) {
|
99
105
|
switch (chainStr) {
|
100
106
|
case 'ARB':
|
@@ -291,7 +297,7 @@ var thorchainToCaip = function (chain, symbol, ticker, type) {
|
|
291
297
|
//if token
|
292
298
|
if (symbol.indexOf("-") > -1) {
|
293
299
|
var contract = symbol.split("-")[1];
|
294
|
-
caip = "".concat(networkId, "
|
300
|
+
caip = "".concat(networkId, "/erc20:").concat(contract);
|
295
301
|
}
|
296
302
|
else {
|
297
303
|
console.error({ chain: chain, symbol: symbol, ticker: ticker, type: type });
|
@@ -306,60 +312,43 @@ var thorchainToCaip = function (chain, symbol, ticker, type) {
|
|
306
312
|
}
|
307
313
|
};
|
308
314
|
exports.thorchainToCaip = thorchainToCaip;
|
309
|
-
//
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
315
|
+
//NOTE THIS IS IMPOSSIBLE to do well!
|
316
|
+
// Caips do NOT include the token tickers!
|
317
|
+
var caipToThorchain = function (caip, ticker) {
|
318
|
+
try {
|
319
|
+
var networkId = caip.split('/')[0]; // Splitting off the network ID from the CAIP
|
320
|
+
console.log("networkId: ", networkId);
|
321
|
+
if (!networkId)
|
322
|
+
throw Error("Invalid CAIP!");
|
323
|
+
var chain = exports.NetworkIdToChain[networkId];
|
324
|
+
if (!chain) {
|
325
|
+
console.error("No matching chain symbol found for network ID", networkId);
|
326
|
+
return null;
|
327
|
+
}
|
328
|
+
// Handling contract tokens
|
329
|
+
if (caip.includes('erc20')) {
|
330
|
+
if (!ticker) {
|
331
|
+
console.error("Ticker is undefined for ERC20 token");
|
332
|
+
return null;
|
333
|
+
}
|
334
|
+
var parts = caip.split('/');
|
335
|
+
var contractPart = parts[1];
|
336
|
+
var contractAddress = contractPart.split(':')[1];
|
337
|
+
if (!contractAddress) {
|
338
|
+
console.error("Contract address is undefined for ERC20 token");
|
339
|
+
return null;
|
340
|
+
}
|
341
|
+
// Use the ticker as is without converting to uppercase
|
342
|
+
return "".concat(chain, ".").concat(ticker, "-").concat(contractAddress.toUpperCase());
|
343
|
+
}
|
344
|
+
else {
|
345
|
+
// Handling native tokens
|
346
|
+
return chain + "." + chain;
|
347
|
+
}
|
331
348
|
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
blockchain: 'ethereum',
|
336
|
-
caip: 'eip155:1/slip44:60',
|
337
|
-
chainId: 1,
|
338
|
-
description: 'more info here: https://ethereum.org This is a EVM network with chainId: 1 Follows EIP:155',
|
339
|
-
explorer: 'https://ethereum.org',
|
340
|
-
faucets: [],
|
341
|
-
feeAssetCaip: 'eip155:1/slip44:60',
|
342
|
-
feeAssetName: 'ethereum',
|
343
|
-
feeAssetRank: 2,
|
344
|
-
feeAssetSymbol: 'ETH',
|
345
|
-
image: 'https://pioneers.dev/coins/ethereum-mainnet.png',
|
346
|
-
isCharted: false,
|
347
|
-
name: 'ethereum',
|
348
|
-
network: 'ETH',
|
349
|
-
service: null,
|
350
|
-
symbol: 'ETH',
|
351
|
-
tags: [
|
352
|
-
'KeepKeySupport',
|
353
|
-
'DappSupport',
|
354
|
-
'WalletConnectSupport',
|
355
|
-
'EVM',
|
356
|
-
'EIP:155',
|
357
|
-
'ethereum',
|
358
|
-
'Ether',
|
359
|
-
'ETH',
|
360
|
-
1,
|
361
|
-
null
|
362
|
-
],
|
363
|
-
type: 'EVM'
|
349
|
+
catch (e) {
|
350
|
+
console.error("Error processing network ID to THORChain", e);
|
351
|
+
return null;
|
364
352
|
}
|
365
353
|
};
|
354
|
+
exports.caipToThorchain = caipToThorchain;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pioneer-platform/pioneer-caip",
|
3
|
-
"version": "9.2.
|
3
|
+
"version": "9.2.9",
|
4
4
|
"main": "./lib/index.js",
|
5
5
|
"types": "./lib/main.d.ts",
|
6
6
|
"_moduleAliases": {
|
@@ -9,7 +9,7 @@
|
|
9
9
|
"scripts": {
|
10
10
|
"npm": "npm i",
|
11
11
|
"build": "tsc -p .",
|
12
|
-
"test": "npm run build && node __tests__/
|
12
|
+
"test": "npm run build && node __tests__/tests-common.js",
|
13
13
|
"build:watch": "npm run build && onchange 'src/**/*.ts' -- npm run build",
|
14
14
|
"prepublish": "npm run build"
|
15
15
|
},
|