@pioneer-platform/pioneer-caip 9.2.9 → 9.2.10
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 +19 -1
- package/lib/data.js +55 -1
- package/package.json +1 -1
package/lib/data.d.ts
CHANGED
@@ -106,7 +106,25 @@ export declare const shortListNameToCaip: {
|
|
106
106
|
eos: string;
|
107
107
|
fio: string;
|
108
108
|
};
|
109
|
+
export declare const shortListRangoNameToNetworkId: {
|
110
|
+
COSMOS: string;
|
111
|
+
OSMOSIS: string;
|
112
|
+
AVAX_CCHAIN: string;
|
113
|
+
ETH: string;
|
114
|
+
THOR: string;
|
115
|
+
BCH: string;
|
116
|
+
LTC: string;
|
117
|
+
DASH: string;
|
118
|
+
DGB: string;
|
119
|
+
DOGE: string;
|
120
|
+
};
|
121
|
+
export declare const NetworkIdToRangoName: (networkId: string) => string | null;
|
109
122
|
declare let tokenToCaip: (token: any) => any;
|
110
123
|
declare let thorchainToCaip: (chain: string, symbol: string, ticker: string, type: string) => string;
|
111
124
|
declare let caipToThorchain: (caip: string, ticker: string) => string | null;
|
112
|
-
|
125
|
+
declare let caipToRango: (caip: string, ticker: string) => {
|
126
|
+
blockchain: string;
|
127
|
+
symbol: string;
|
128
|
+
address: any;
|
129
|
+
} | null;
|
130
|
+
export { thorchainToCaip, tokenToCaip, caipToThorchain, caipToRango };
|
package/lib/data.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
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;
|
3
|
+
exports.caipToRango = exports.caipToThorchain = exports.tokenToCaip = exports.thorchainToCaip = exports.NetworkIdToRangoName = exports.shortListRangoNameToNetworkId = 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',
|
@@ -211,6 +211,36 @@ exports.shortListNameToCaip = {
|
|
211
211
|
eos: 'eip155:1:/erc20:0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0',
|
212
212
|
fio: 'placeholder:caip:fio:native:fio-protocol'
|
213
213
|
};
|
214
|
+
exports.shortListRangoNameToNetworkId = {
|
215
|
+
COSMOS: 'cosmos:cosmoshub-4',
|
216
|
+
OSMOSIS: 'cosmos:osmosis-1',
|
217
|
+
AVAX_CCHAIN: 'eip155:43114',
|
218
|
+
ETH: 'eip155:1',
|
219
|
+
THOR: 'cosmos:thorchain-mainnet-v1',
|
220
|
+
BCH: 'bip122:000000000000000000651ef99cb9fcbe',
|
221
|
+
LTC: 'bip122:12a765e31ffd4059bada1e25190f6e98',
|
222
|
+
DASH: 'bip122:000007d91d1254d60e2dd1ae58038307',
|
223
|
+
DGB: 'bip122:digibytes-hash',
|
224
|
+
DOGE: 'bip122:00000000001a91e3dace36e2be3bf030'
|
225
|
+
};
|
226
|
+
var NetworkIdToRangoName = function (networkId) {
|
227
|
+
try {
|
228
|
+
// Inverting the mapping to find the Rango name based on networkId
|
229
|
+
for (var _i = 0, _a = Object.entries(exports.shortListRangoNameToNetworkId); _i < _a.length; _i++) {
|
230
|
+
var _b = _a[_i], rangoName = _b[0], rangoNetworkId = _b[1];
|
231
|
+
if (rangoNetworkId === networkId) {
|
232
|
+
return rangoName;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
console.error('Rango name not found for networkId:', networkId);
|
236
|
+
return null;
|
237
|
+
}
|
238
|
+
catch (e) {
|
239
|
+
console.error("Error processing networkId to Rango Name", e);
|
240
|
+
return null;
|
241
|
+
}
|
242
|
+
};
|
243
|
+
exports.NetworkIdToRangoName = NetworkIdToRangoName;
|
214
244
|
var tokenToCaip = function (token) {
|
215
245
|
try {
|
216
246
|
// Handle identifiers with an extra period
|
@@ -352,3 +382,27 @@ var caipToThorchain = function (caip, ticker) {
|
|
352
382
|
}
|
353
383
|
};
|
354
384
|
exports.caipToThorchain = caipToThorchain;
|
385
|
+
var caipToRango = function (caip, ticker) {
|
386
|
+
try {
|
387
|
+
var _a = caip.split('/'), networkId = _a[0], tokenInfo = _a[1];
|
388
|
+
var rangoName = (0, exports.NetworkIdToRangoName)(networkId); // Get the Rango name from the network ID
|
389
|
+
// Extracting the symbol and address
|
390
|
+
var symbol = ticker;
|
391
|
+
var address = null;
|
392
|
+
// For ERC20 tokens, the contract address is included in the CAIP
|
393
|
+
if (tokenInfo && tokenInfo.startsWith('erc20:')) {
|
394
|
+
address = tokenInfo.split(':')[1];
|
395
|
+
}
|
396
|
+
// Check if the Rango name is found
|
397
|
+
if (!rangoName) {
|
398
|
+
console.error('Rango name not found for networkId:', networkId);
|
399
|
+
return null;
|
400
|
+
}
|
401
|
+
return { blockchain: rangoName, symbol: symbol, address: address };
|
402
|
+
}
|
403
|
+
catch (e) {
|
404
|
+
console.error("Error processing CAIP to Rango", e);
|
405
|
+
return null;
|
406
|
+
}
|
407
|
+
};
|
408
|
+
exports.caipToRango = caipToRango;
|