@pioneer-platform/pioneer-caip 9.2.6 → 9.2.8
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 +2 -39
- package/lib/data.js +33 -55
- package/package.json +1 -1
package/lib/data.d.ts
CHANGED
@@ -107,42 +107,5 @@ export declare const shortListNameToCaip: {
|
|
107
107
|
};
|
108
108
|
declare let tokenToCaip: (token: any) => any;
|
109
109
|
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
|
-
};
|
110
|
+
declare let caipToThorchain: (caip: string, ticker: string) => string | null;
|
111
|
+
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.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',
|
@@ -226,12 +226,14 @@ var tokenToCaip = function (token) {
|
|
226
226
|
}
|
227
227
|
else {
|
228
228
|
type = 'native';
|
229
|
+
ticker = symbol;
|
229
230
|
}
|
230
231
|
var caip = thorchainToCaip(chain, symbol, ticker, type);
|
231
232
|
token.networkId = exports.ChainToNetworkId[chain];
|
232
233
|
token.caip = caip;
|
233
234
|
token.symbol = symbol;
|
234
235
|
token.ticker = ticker;
|
236
|
+
token.type = type;
|
235
237
|
// Get pubkey for chain
|
236
238
|
return token;
|
237
239
|
}
|
@@ -304,60 +306,36 @@ var thorchainToCaip = function (chain, symbol, ticker, type) {
|
|
304
306
|
}
|
305
307
|
};
|
306
308
|
exports.thorchainToCaip = thorchainToCaip;
|
307
|
-
//
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
'
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
309
|
+
//NOTE THIS IS IMPOSSIBLE to do well!
|
310
|
+
// Caips do NOT include the token tickers!
|
311
|
+
var caipToThorchain = function (caip, ticker) {
|
312
|
+
try {
|
313
|
+
var parts = caip.split(':');
|
314
|
+
var networkId = parts[0];
|
315
|
+
var chainId = parts[1];
|
316
|
+
var contractType = parts.length > 2 ? parts[2] : null;
|
317
|
+
var contractAddress = parts.length > 3 ? parts[3] : null;
|
318
|
+
var thorChainSymbol = void 0;
|
319
|
+
for (var _i = 0, _a = Object.entries(exports.ChainToNetworkId); _i < _a.length; _i++) {
|
320
|
+
var _b = _a[_i], symbol = _b[0], thorChainNetworkId = _b[1];
|
321
|
+
var thorChainId = thorChainNetworkId.split(':')[1];
|
322
|
+
if (thorChainId === chainId) {
|
323
|
+
thorChainSymbol = symbol;
|
324
|
+
break;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
if (!thorChainSymbol) {
|
328
|
+
console.error("No matching THORChain symbol found for network ID", networkId);
|
329
|
+
return null;
|
330
|
+
}
|
331
|
+
if (contractType && contractAddress) {
|
332
|
+
return "".concat(thorChainSymbol, ".").concat(ticker, "-").concat(contractAddress.toUpperCase());
|
333
|
+
}
|
334
|
+
return thorChainSymbol;
|
329
335
|
}
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
blockchain: 'ethereum',
|
334
|
-
caip: 'eip155:1/slip44:60',
|
335
|
-
chainId: 1,
|
336
|
-
description: 'more info here: https://ethereum.org This is a EVM network with chainId: 1 Follows EIP:155',
|
337
|
-
explorer: 'https://ethereum.org',
|
338
|
-
faucets: [],
|
339
|
-
feeAssetCaip: 'eip155:1/slip44:60',
|
340
|
-
feeAssetName: 'ethereum',
|
341
|
-
feeAssetRank: 2,
|
342
|
-
feeAssetSymbol: 'ETH',
|
343
|
-
image: 'https://pioneers.dev/coins/ethereum-mainnet.png',
|
344
|
-
isCharted: false,
|
345
|
-
name: 'ethereum',
|
346
|
-
network: 'ETH',
|
347
|
-
service: null,
|
348
|
-
symbol: 'ETH',
|
349
|
-
tags: [
|
350
|
-
'KeepKeySupport',
|
351
|
-
'DappSupport',
|
352
|
-
'WalletConnectSupport',
|
353
|
-
'EVM',
|
354
|
-
'EIP:155',
|
355
|
-
'ethereum',
|
356
|
-
'Ether',
|
357
|
-
'ETH',
|
358
|
-
1,
|
359
|
-
null
|
360
|
-
],
|
361
|
-
type: 'EVM'
|
336
|
+
catch (e) {
|
337
|
+
console.error("Error processing CAIP to THORChain", e);
|
338
|
+
return null;
|
362
339
|
}
|
363
340
|
};
|
341
|
+
exports.caipToThorchain = caipToThorchain;
|