@shapeshiftoss/caip 1.11.2 → 1.12.0
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/dist/adapters/coincap/utils.js +4 -5
- package/dist/adapters/coingecko/utils.js +4 -5
- package/dist/caip19/caip19.d.ts +9 -2
- package/dist/caip19/caip19.js +71 -12
- package/dist/caip2/caip2.d.ts +1 -2
- package/dist/caip2/caip2.js +63 -52
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ const types_1 = require("@shapeshiftoss/types");
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const caip2_1 = require("../../caip2/caip2");
|
|
11
|
-
const caip19_1 = require("
|
|
11
|
+
const caip19_1 = require("../../caip19/caip19");
|
|
12
12
|
const writeFiles = async (data) => {
|
|
13
13
|
const path = './src/adapters/coincap/generated/';
|
|
14
14
|
const file = '/adapter.json';
|
|
@@ -24,7 +24,7 @@ const parseEthData = (data) => {
|
|
|
24
24
|
const chain = types_1.ChainTypes.Ethereum;
|
|
25
25
|
const network = types_1.NetworkTypes.MAINNET;
|
|
26
26
|
const contractType = types_1.ContractTypes.ERC20;
|
|
27
|
-
|
|
27
|
+
return ethCoins.reduce((acc, { id, explorer }) => {
|
|
28
28
|
let tokenId;
|
|
29
29
|
if (id !== 'ethereum' && explorer) {
|
|
30
30
|
tokenId = explorer.replace('https://etherscan.io/token/', '').split('#')[0].split('?')[0];
|
|
@@ -33,7 +33,6 @@ const parseEthData = (data) => {
|
|
|
33
33
|
acc[caip19] = id;
|
|
34
34
|
return acc;
|
|
35
35
|
}, {});
|
|
36
|
-
return result;
|
|
37
36
|
};
|
|
38
37
|
exports.parseEthData = parseEthData;
|
|
39
38
|
const makeBtcData = () => {
|
|
@@ -51,7 +50,7 @@ const makeCosmosHubData = () => {
|
|
|
51
50
|
};
|
|
52
51
|
exports.makeCosmosHubData = makeCosmosHubData;
|
|
53
52
|
const makeOsmosisData = () => {
|
|
54
|
-
const chain = types_1.ChainTypes.
|
|
53
|
+
const chain = types_1.ChainTypes.Osmosis;
|
|
55
54
|
const network = types_1.NetworkTypes.OSMOSIS_MAINNET;
|
|
56
55
|
const caip19 = (0, caip19_1.toCAIP19)({ chain, network });
|
|
57
56
|
return { [caip19]: 'osmosis' };
|
|
@@ -65,7 +64,7 @@ const parseData = (d) => {
|
|
|
65
64
|
network: types_1.NetworkTypes.COSMOSHUB_MAINNET
|
|
66
65
|
});
|
|
67
66
|
const osmosisMainnet = (0, caip2_1.toCAIP2)({
|
|
68
|
-
chain: types_1.ChainTypes.
|
|
67
|
+
chain: types_1.ChainTypes.Osmosis,
|
|
69
68
|
network: types_1.NetworkTypes.OSMOSIS_MAINNET
|
|
70
69
|
});
|
|
71
70
|
return {
|
|
@@ -8,7 +8,7 @@ const types_1 = require("@shapeshiftoss/types");
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const caip2_1 = require("../../caip2/caip2");
|
|
11
|
-
const caip19_1 = require("
|
|
11
|
+
const caip19_1 = require("../../caip19/caip19");
|
|
12
12
|
const writeFiles = async (data) => {
|
|
13
13
|
const path = './src/adapters/coingecko/generated/';
|
|
14
14
|
const file = '/adapter.json';
|
|
@@ -24,13 +24,12 @@ const parseEthData = (data) => {
|
|
|
24
24
|
const chain = types_1.ChainTypes.Ethereum;
|
|
25
25
|
const network = types_1.NetworkTypes.MAINNET;
|
|
26
26
|
const contractType = types_1.ContractTypes.ERC20;
|
|
27
|
-
|
|
27
|
+
return ethCoins.reduce((acc, { id, platforms }) => {
|
|
28
28
|
const tokenId = platforms === null || platforms === void 0 ? void 0 : platforms.ethereum;
|
|
29
29
|
const caip19 = (0, caip19_1.toCAIP19)({ chain, network, ...(tokenId ? { contractType, tokenId } : {}) });
|
|
30
30
|
acc[caip19] = id;
|
|
31
31
|
return acc;
|
|
32
32
|
}, {});
|
|
33
|
-
return result;
|
|
34
33
|
};
|
|
35
34
|
exports.parseEthData = parseEthData;
|
|
36
35
|
const makeBtcData = () => {
|
|
@@ -48,7 +47,7 @@ const makeCosmosHubData = () => {
|
|
|
48
47
|
};
|
|
49
48
|
exports.makeCosmosHubData = makeCosmosHubData;
|
|
50
49
|
const makeOsmosisData = () => {
|
|
51
|
-
const chain = types_1.ChainTypes.
|
|
50
|
+
const chain = types_1.ChainTypes.Osmosis;
|
|
52
51
|
const network = types_1.NetworkTypes.OSMOSIS_MAINNET;
|
|
53
52
|
const caip19 = (0, caip19_1.toCAIP19)({ chain, network });
|
|
54
53
|
return { [caip19]: 'osmosis' };
|
|
@@ -62,7 +61,7 @@ const parseData = (d) => {
|
|
|
62
61
|
network: types_1.NetworkTypes.COSMOSHUB_MAINNET
|
|
63
62
|
});
|
|
64
63
|
const osmosisMainnet = (0, caip2_1.toCAIP2)({
|
|
65
|
-
chain: types_1.ChainTypes.
|
|
64
|
+
chain: types_1.ChainTypes.Osmosis,
|
|
66
65
|
network: types_1.NetworkTypes.OSMOSIS_MAINNET
|
|
67
66
|
});
|
|
68
67
|
return {
|
package/dist/caip19/caip19.d.ts
CHANGED
|
@@ -5,18 +5,23 @@ export declare enum AssetNamespace {
|
|
|
5
5
|
CW721 = "cw721",
|
|
6
6
|
ERC20 = "erc20",
|
|
7
7
|
ERC721 = "erc721",
|
|
8
|
-
Slip44 = "slip44"
|
|
8
|
+
Slip44 = "slip44",
|
|
9
|
+
NATIVE = "native",
|
|
10
|
+
IBC = "ibc"
|
|
9
11
|
}
|
|
10
12
|
export declare enum AssetReference {
|
|
11
13
|
Bitcoin = 0,
|
|
12
14
|
Ethereum = 60,
|
|
13
|
-
Cosmos = 118
|
|
15
|
+
Cosmos = 118,
|
|
16
|
+
Osmosis = 118
|
|
14
17
|
}
|
|
15
18
|
declare type ToCAIP19Args = {
|
|
16
19
|
chain: ChainTypes;
|
|
17
20
|
network: NetworkTypes;
|
|
18
21
|
contractType?: ContractTypes;
|
|
19
22
|
tokenId?: string;
|
|
23
|
+
assetNamespace?: AssetNamespace;
|
|
24
|
+
assetReference?: string;
|
|
20
25
|
};
|
|
21
26
|
declare type ToCAIP19 = (args: ToCAIP19Args) => string;
|
|
22
27
|
export declare const toCAIP19: ToCAIP19;
|
|
@@ -25,6 +30,8 @@ declare type FromCAIP19Return = {
|
|
|
25
30
|
network: NetworkTypes;
|
|
26
31
|
contractType?: ContractTypes;
|
|
27
32
|
tokenId?: string;
|
|
33
|
+
assetNamespace?: AssetNamespace;
|
|
34
|
+
assetReference?: string;
|
|
28
35
|
};
|
|
29
36
|
declare type FromCAIP19 = (caip19: string) => FromCAIP19Return;
|
|
30
37
|
export declare const fromCAIP19: FromCAIP19;
|
package/dist/caip19/caip19.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.fromCAIP19 = exports.toCAIP19 = exports.AssetReference = exports.AssetNamespace = void 0;
|
|
5
5
|
const types_1 = require("@shapeshiftoss/types");
|
|
6
|
-
const caip2_1 = require("
|
|
6
|
+
const caip2_1 = require("../caip2/caip2");
|
|
7
7
|
var AssetNamespace;
|
|
8
8
|
(function (AssetNamespace) {
|
|
9
9
|
AssetNamespace["CW20"] = "cw20";
|
|
@@ -11,20 +11,36 @@ var AssetNamespace;
|
|
|
11
11
|
AssetNamespace["ERC20"] = "erc20";
|
|
12
12
|
AssetNamespace["ERC721"] = "erc721";
|
|
13
13
|
AssetNamespace["Slip44"] = "slip44";
|
|
14
|
+
AssetNamespace["NATIVE"] = "native";
|
|
15
|
+
AssetNamespace["IBC"] = "ibc";
|
|
14
16
|
})(AssetNamespace = exports.AssetNamespace || (exports.AssetNamespace = {}));
|
|
15
17
|
var AssetReference;
|
|
16
18
|
(function (AssetReference) {
|
|
17
19
|
AssetReference[AssetReference["Bitcoin"] = 0] = "Bitcoin";
|
|
18
20
|
AssetReference[AssetReference["Ethereum"] = 60] = "Ethereum";
|
|
19
21
|
AssetReference[AssetReference["Cosmos"] = 118] = "Cosmos";
|
|
22
|
+
AssetReference[AssetReference["Osmosis"] = 118] = "Osmosis";
|
|
20
23
|
})(AssetReference = exports.AssetReference || (exports.AssetReference = {}));
|
|
21
|
-
const toCAIP19 = ({ chain, network, contractType, tokenId }) => {
|
|
24
|
+
const toCAIP19 = ({ chain, network, contractType, tokenId, assetNamespace, assetReference }) => {
|
|
22
25
|
const caip2 = (0, caip2_1.toCAIP2)({ chain, network });
|
|
23
26
|
switch (chain) {
|
|
24
27
|
// TODO: There is no chain-level fungible token standard in Cosmos SDK, but CosmWasm chains have CW20/CW721
|
|
25
28
|
// This should be implemented when we want to support tokens for Cosmos SDK chains
|
|
26
|
-
case types_1.ChainTypes.Cosmos:
|
|
27
|
-
|
|
29
|
+
case types_1.ChainTypes.Cosmos:
|
|
30
|
+
case types_1.ChainTypes.Osmosis: {
|
|
31
|
+
if (!assetNamespace || !assetReference) {
|
|
32
|
+
return `${caip2}/${AssetNamespace.Slip44}:${AssetReference.Cosmos}`;
|
|
33
|
+
}
|
|
34
|
+
switch (assetNamespace) {
|
|
35
|
+
case AssetNamespace.CW20:
|
|
36
|
+
case AssetNamespace.CW721:
|
|
37
|
+
case AssetNamespace.IBC:
|
|
38
|
+
case AssetNamespace.NATIVE:
|
|
39
|
+
return `${caip2}/${assetNamespace}:${assetReference}`;
|
|
40
|
+
default: {
|
|
41
|
+
throw new Error(`Could not construct CAIP19 chain: ${chain}, network: ${network}, assetNamespace: ${assetNamespace}, assetReference: ${assetReference}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
28
44
|
}
|
|
29
45
|
case types_1.ChainTypes.Ethereum: {
|
|
30
46
|
tokenId = tokenId === null || tokenId === void 0 ? void 0 : tokenId.toLowerCase();
|
|
@@ -65,6 +81,9 @@ const toCAIP19 = ({ chain, network, contractType, tokenId }) => {
|
|
|
65
81
|
case types_1.ChainTypes.Bitcoin: {
|
|
66
82
|
return `${caip2}/${AssetNamespace.Slip44}:${AssetReference.Bitcoin}`;
|
|
67
83
|
}
|
|
84
|
+
default: {
|
|
85
|
+
throw new Error(`Chain type not supported: ${chain}`);
|
|
86
|
+
}
|
|
68
87
|
}
|
|
69
88
|
};
|
|
70
89
|
exports.toCAIP19 = toCAIP19;
|
|
@@ -87,18 +106,13 @@ const fromCAIP19 = (caip19) => {
|
|
|
87
106
|
case AssetReference.Bitcoin: {
|
|
88
107
|
return { chain, network };
|
|
89
108
|
}
|
|
90
|
-
case AssetReference.Ethereum:
|
|
91
109
|
default: {
|
|
92
110
|
throw new Error(`fromCAIP19: invalid asset reference ${reference} on chain ${chain}`);
|
|
93
111
|
}
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
|
-
case AssetNamespace.ERC20:
|
|
97
|
-
case AssetNamespace.ERC721:
|
|
98
|
-
case AssetNamespace.CW20:
|
|
99
|
-
case AssetNamespace.CW721:
|
|
100
114
|
default: {
|
|
101
|
-
throw new Error(`fromCAIP19: invalid asset
|
|
115
|
+
throw new Error(`fromCAIP19: invalid asset namespace ${namespace} on chain ${chain}`);
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
118
|
}
|
|
@@ -109,7 +123,6 @@ const fromCAIP19 = (caip19) => {
|
|
|
109
123
|
case AssetReference.Ethereum: {
|
|
110
124
|
return { chain, network };
|
|
111
125
|
}
|
|
112
|
-
case AssetReference.Bitcoin:
|
|
113
126
|
default: {
|
|
114
127
|
throw new Error(`fromCAIP19: invalid asset reference ${reference} on chain ${chain}`);
|
|
115
128
|
}
|
|
@@ -125,10 +138,56 @@ const fromCAIP19 = (caip19) => {
|
|
|
125
138
|
const tokenId = referenceString.toLowerCase();
|
|
126
139
|
return { chain, network, contractType, tokenId };
|
|
127
140
|
}
|
|
141
|
+
default: {
|
|
142
|
+
throw new Error(`fromCAIP19: invalid asset namespace ${namespace} on chain ${chain}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
case types_1.ChainTypes.Osmosis:
|
|
147
|
+
case types_1.ChainTypes.Cosmos: {
|
|
148
|
+
switch (namespace) {
|
|
149
|
+
case AssetNamespace.Slip44: {
|
|
150
|
+
switch (reference) {
|
|
151
|
+
case AssetReference.Cosmos: {
|
|
152
|
+
return { chain, network };
|
|
153
|
+
}
|
|
154
|
+
case AssetReference.Ethereum:
|
|
155
|
+
case AssetReference.Bitcoin:
|
|
156
|
+
default: {
|
|
157
|
+
throw new Error(`fromCAIP19: invalid asset namespace ${namespace} on chain ${chain}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
128
161
|
case AssetNamespace.CW20:
|
|
162
|
+
return {
|
|
163
|
+
chain,
|
|
164
|
+
network,
|
|
165
|
+
assetNamespace: AssetNamespace.CW20,
|
|
166
|
+
assetReference: referenceString
|
|
167
|
+
};
|
|
129
168
|
case AssetNamespace.CW721:
|
|
169
|
+
return {
|
|
170
|
+
chain,
|
|
171
|
+
network,
|
|
172
|
+
assetNamespace: AssetNamespace.CW721,
|
|
173
|
+
assetReference: referenceString
|
|
174
|
+
};
|
|
175
|
+
case AssetNamespace.IBC:
|
|
176
|
+
return {
|
|
177
|
+
chain,
|
|
178
|
+
network,
|
|
179
|
+
assetNamespace: AssetNamespace.IBC,
|
|
180
|
+
assetReference: referenceString
|
|
181
|
+
};
|
|
182
|
+
case AssetNamespace.NATIVE:
|
|
183
|
+
return {
|
|
184
|
+
chain,
|
|
185
|
+
network,
|
|
186
|
+
assetNamespace: AssetNamespace.NATIVE,
|
|
187
|
+
assetReference: referenceString
|
|
188
|
+
};
|
|
130
189
|
default: {
|
|
131
|
-
throw new Error(`fromCAIP19: invalid asset
|
|
190
|
+
throw new Error(`fromCAIP19: invalid asset namespace ${namespace} on chain ${chain}`);
|
|
132
191
|
}
|
|
133
192
|
}
|
|
134
193
|
}
|
package/dist/caip2/caip2.d.ts
CHANGED
|
@@ -20,8 +20,7 @@ declare type ToCAIP2Args = {
|
|
|
20
20
|
chain: ChainTypes;
|
|
21
21
|
network: NetworkTypes;
|
|
22
22
|
};
|
|
23
|
-
declare
|
|
24
|
-
export declare const toCAIP2: ToCAIP2;
|
|
23
|
+
export declare const toCAIP2: (args: ToCAIP2Args) => string;
|
|
25
24
|
declare type FromCAIP2Return = {
|
|
26
25
|
chain: ChainTypes;
|
|
27
26
|
network: NetworkTypes;
|
package/dist/caip2/caip2.js
CHANGED
|
@@ -24,72 +24,85 @@ var ChainReference;
|
|
|
24
24
|
ChainReference["OsmosisMainnet"] = "osmosis-1";
|
|
25
25
|
ChainReference["OsmosisTestnet"] = "osmo-testnet-1";
|
|
26
26
|
})(ChainReference = exports.ChainReference || (exports.ChainReference = {}));
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
27
|
+
const shapeShiftToCAIP2 = Object.freeze({
|
|
28
|
+
[types_1.ChainTypes.Ethereum]: {
|
|
29
|
+
namespace: ChainNamespace.Ethereum,
|
|
30
|
+
reference: {
|
|
31
|
+
[types_1.NetworkTypes.MAINNET]: ChainReference.EthereumMainnet,
|
|
32
|
+
[types_1.NetworkTypes.ETH_ROPSTEN]: ChainReference.EthereumRopsten,
|
|
33
|
+
[types_1.NetworkTypes.ETH_RINKEBY]: ChainReference.EthereumRinkeby
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
[types_1.ChainTypes.Bitcoin]: {
|
|
37
|
+
namespace: ChainNamespace.Bitcoin,
|
|
38
|
+
reference: {
|
|
39
|
+
[types_1.NetworkTypes.MAINNET]: ChainReference.BitcoinMainnet,
|
|
40
|
+
[types_1.NetworkTypes.TESTNET]: ChainReference.BitcoinTestnet
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[types_1.ChainTypes.Cosmos]: {
|
|
44
|
+
namespace: ChainNamespace.Cosmos,
|
|
45
|
+
reference: {
|
|
46
|
+
[types_1.NetworkTypes.COSMOSHUB_MAINNET]: ChainReference.CosmosHubMainnet,
|
|
47
|
+
[types_1.NetworkTypes.COSMOSHUB_VEGA]: ChainReference.CosmosHubVega
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[types_1.ChainTypes.Osmosis]: {
|
|
51
|
+
namespace: ChainNamespace.Cosmos,
|
|
52
|
+
reference: {
|
|
53
|
+
[types_1.NetworkTypes.OSMOSIS_MAINNET]: ChainReference.OsmosisMainnet,
|
|
54
|
+
[types_1.NetworkTypes.OSMOSIS_TESTNET]: ChainReference.OsmosisTestnet
|
|
52
55
|
}
|
|
53
|
-
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const toCAIP2 = (args) => {
|
|
59
|
+
const { chain, network } = args;
|
|
54
60
|
const namespace = shapeShiftToCAIP2[chain].namespace;
|
|
55
61
|
switch (chain) {
|
|
56
|
-
case types_1.ChainTypes.
|
|
62
|
+
case types_1.ChainTypes.Ethereum: {
|
|
57
63
|
const referenceMap = shapeShiftToCAIP2[chain].reference;
|
|
58
64
|
switch (network) {
|
|
59
|
-
case types_1.NetworkTypes.
|
|
60
|
-
case types_1.NetworkTypes.
|
|
61
|
-
case types_1.NetworkTypes.
|
|
62
|
-
case types_1.NetworkTypes.OSMOSIS_TESTNET: {
|
|
65
|
+
case types_1.NetworkTypes.MAINNET:
|
|
66
|
+
case types_1.NetworkTypes.ETH_ROPSTEN:
|
|
67
|
+
case types_1.NetworkTypes.ETH_RINKEBY: {
|
|
63
68
|
const reference = referenceMap[network];
|
|
64
|
-
|
|
65
|
-
return caip2;
|
|
69
|
+
return `${namespace}:${reference}`;
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
break;
|
|
69
73
|
}
|
|
70
|
-
case types_1.ChainTypes.
|
|
74
|
+
case types_1.ChainTypes.Bitcoin: {
|
|
71
75
|
const referenceMap = shapeShiftToCAIP2[chain].reference;
|
|
72
76
|
switch (network) {
|
|
73
77
|
case types_1.NetworkTypes.MAINNET:
|
|
74
|
-
case types_1.NetworkTypes.
|
|
75
|
-
case types_1.NetworkTypes.ETH_RINKEBY: {
|
|
78
|
+
case types_1.NetworkTypes.TESTNET: {
|
|
76
79
|
const reference = referenceMap[network];
|
|
77
|
-
|
|
78
|
-
return caip2;
|
|
80
|
+
return `${namespace}:${reference}`;
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
break;
|
|
82
84
|
}
|
|
83
|
-
case types_1.ChainTypes.
|
|
85
|
+
case types_1.ChainTypes.Cosmos: {
|
|
84
86
|
const referenceMap = shapeShiftToCAIP2[chain].reference;
|
|
85
87
|
switch (network) {
|
|
86
|
-
case types_1.NetworkTypes.
|
|
87
|
-
case types_1.NetworkTypes.
|
|
88
|
+
case types_1.NetworkTypes.COSMOSHUB_MAINNET:
|
|
89
|
+
case types_1.NetworkTypes.COSMOSHUB_VEGA: {
|
|
90
|
+
const reference = referenceMap[network];
|
|
91
|
+
return `${namespace}:${reference}`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case types_1.ChainTypes.Osmosis: {
|
|
97
|
+
const referenceMap = shapeShiftToCAIP2[chain].reference;
|
|
98
|
+
switch (network) {
|
|
99
|
+
case types_1.NetworkTypes.OSMOSIS_MAINNET:
|
|
100
|
+
case types_1.NetworkTypes.OSMOSIS_TESTNET: {
|
|
88
101
|
const reference = referenceMap[network];
|
|
89
|
-
|
|
90
|
-
return caip2;
|
|
102
|
+
return `${namespace}:${reference}`;
|
|
91
103
|
}
|
|
92
104
|
}
|
|
105
|
+
break;
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
throw new Error(`toCAIP2: unsupported ${chain} network: ${network}`);
|
|
@@ -102,23 +115,18 @@ const fromCAIP2 = (caip2) => {
|
|
|
102
115
|
}
|
|
103
116
|
switch (c) {
|
|
104
117
|
case ChainNamespace.Cosmos: {
|
|
105
|
-
const chain = types_1.ChainTypes.Cosmos;
|
|
106
118
|
switch (n) {
|
|
107
119
|
case ChainReference.CosmosHubMainnet: {
|
|
108
|
-
|
|
109
|
-
return { chain, network };
|
|
120
|
+
return { chain: types_1.ChainTypes.Cosmos, network: types_1.NetworkTypes.COSMOSHUB_MAINNET };
|
|
110
121
|
}
|
|
111
122
|
case ChainReference.CosmosHubVega: {
|
|
112
|
-
|
|
113
|
-
return { chain, network };
|
|
123
|
+
return { chain: types_1.ChainTypes.Cosmos, network: types_1.NetworkTypes.COSMOSHUB_VEGA };
|
|
114
124
|
}
|
|
115
125
|
case ChainReference.OsmosisMainnet: {
|
|
116
|
-
|
|
117
|
-
return { chain, network };
|
|
126
|
+
return { chain: types_1.ChainTypes.Osmosis, network: types_1.NetworkTypes.OSMOSIS_MAINNET };
|
|
118
127
|
}
|
|
119
128
|
case ChainReference.OsmosisTestnet: {
|
|
120
|
-
|
|
121
|
-
return { chain, network };
|
|
129
|
+
return { chain: types_1.ChainTypes.Osmosis, network: types_1.NetworkTypes.OSMOSIS_TESTNET };
|
|
122
130
|
}
|
|
123
131
|
default: {
|
|
124
132
|
throw new Error(`fromCAIP19: unsupported ${c} network: ${n}`);
|
|
@@ -175,6 +183,8 @@ const isCAIP2 = (caip2) => {
|
|
|
175
183
|
switch (n) {
|
|
176
184
|
case ChainReference.CosmosHubMainnet:
|
|
177
185
|
case ChainReference.CosmosHubVega:
|
|
186
|
+
case ChainReference.OsmosisMainnet:
|
|
187
|
+
case ChainReference.OsmosisTestnet:
|
|
178
188
|
return true;
|
|
179
189
|
}
|
|
180
190
|
break;
|
|
@@ -194,6 +204,7 @@ const isCAIP2 = (caip2) => {
|
|
|
194
204
|
case ChainReference.BitcoinTestnet:
|
|
195
205
|
return true;
|
|
196
206
|
}
|
|
207
|
+
break;
|
|
197
208
|
}
|
|
198
209
|
}
|
|
199
210
|
throw new Error(`isCAIP2: invalid caip2 ${caip2}`);
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import * as caip19 from './caip19/caip19';
|
|
|
5
5
|
export { adapters, caip2, caip19, caip10 };
|
|
6
6
|
export { CAIP2 } from './caip2/caip2';
|
|
7
7
|
export { CAIP10 } from './caip10/caip10';
|
|
8
|
-
export { CAIP19 } from './caip19/caip19';
|
|
8
|
+
export { AssetNamespace, CAIP19 } from './caip19/caip19';
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.caip10 = exports.caip19 = exports.caip2 = exports.adapters = void 0;
|
|
22
|
+
exports.AssetNamespace = exports.caip10 = exports.caip19 = exports.caip2 = exports.adapters = void 0;
|
|
23
23
|
const adapters = __importStar(require("./adapters"));
|
|
24
24
|
exports.adapters = adapters;
|
|
25
25
|
const caip2 = __importStar(require("./caip2/caip2"));
|
|
@@ -28,3 +28,5 @@ const caip10 = __importStar(require("./caip10/caip10"));
|
|
|
28
28
|
exports.caip10 = caip10;
|
|
29
29
|
const caip19 = __importStar(require("./caip19/caip19"));
|
|
30
30
|
exports.caip19 = caip19;
|
|
31
|
+
var caip19_1 = require("./caip19/caip19");
|
|
32
|
+
Object.defineProperty(exports, "AssetNamespace", { enumerable: true, get: function () { return caip19_1.AssetNamespace; } });
|