@pioneer-platform/pioneer-caip 9.2.4 → 9.2.6
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 -1
- package/lib/data.js +31 -2
- package/package.json +1 -1
package/lib/data.d.ts
CHANGED
@@ -105,8 +105,9 @@ export declare const shortListNameToCaip: {
|
|
105
105
|
eos: string;
|
106
106
|
fio: string;
|
107
107
|
};
|
108
|
+
declare let tokenToCaip: (token: any) => any;
|
108
109
|
declare let thorchainToCaip: (chain: string, symbol: string, ticker: string, type: string) => string;
|
109
|
-
export { thorchainToCaip };
|
110
|
+
export { thorchainToCaip, tokenToCaip };
|
110
111
|
export declare const primaryBlockchains: {
|
111
112
|
"eip155:1/slip44:60": {
|
112
113
|
name: string;
|
package/lib/data.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.primaryAssets = exports.primaryBlockchains = exports.thorchainToCaip = exports.shortListNameToCaip = exports.shortListSymbolToCaip = exports.shortListSymbolToCoinGeckoPlatformId = exports.getChainEnumValue = exports.ChainToNetworkId = exports.ChainToCaip = exports.Chain = exports.evmCaips = void 0;
|
3
|
+
exports.primaryAssets = exports.primaryBlockchains = 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',
|
@@ -205,12 +205,41 @@ exports.shortListNameToCaip = {
|
|
205
205
|
eos: 'eip155:1:/erc20:0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0',
|
206
206
|
fio: 'placeholder:caip:fio:native:fio-protocol'
|
207
207
|
};
|
208
|
-
var
|
208
|
+
var tokenToCaip = function (token) {
|
209
209
|
try {
|
210
|
+
// Handle identifiers with an extra period
|
211
|
+
var parts = token.identifier.split('.');
|
212
|
+
var chain = void 0, symbol = void 0;
|
213
|
+
if (parts.length >= 2) {
|
214
|
+
chain = parts[0];
|
215
|
+
symbol = parts.slice(1).join('.'); // Re-join the remaining parts excluding the first
|
216
|
+
}
|
217
|
+
else {
|
218
|
+
// Fallback to the original method if there's only one or no period
|
219
|
+
chain = token.identifier.split('.')[0];
|
220
|
+
symbol = token.identifier.split('.')[1];
|
221
|
+
}
|
222
|
+
var type = void 0, ticker = void 0;
|
223
|
+
if (token.address) {
|
224
|
+
ticker = symbol.split('-')[0];
|
225
|
+
type = 'token';
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
type = 'native';
|
229
|
+
}
|
230
|
+
var caip = thorchainToCaip(chain, symbol, ticker, type);
|
231
|
+
token.networkId = exports.ChainToNetworkId[chain];
|
232
|
+
token.caip = caip;
|
233
|
+
token.symbol = symbol;
|
234
|
+
token.ticker = ticker;
|
235
|
+
// Get pubkey for chain
|
236
|
+
return token;
|
210
237
|
}
|
211
238
|
catch (e) {
|
239
|
+
console.error(e);
|
212
240
|
}
|
213
241
|
};
|
242
|
+
exports.tokenToCaip = tokenToCaip;
|
214
243
|
var thorchainToCaip = function (chain, symbol, ticker, type) {
|
215
244
|
try {
|
216
245
|
var caip
|