carbon-js-sdk 0.4.2 → 0.4.3-dev.1
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/CarbonSDK.js +1 -1
- package/lib/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.d.ts +11 -4
- package/lib/clients/ETHClient.js +32 -18
- package/lib/clients/HydrogenClient.d.ts +16 -7
- package/lib/clients/HydrogenClient.js +56 -10
- package/lib/clients/NEOClient.d.ts +1 -1
- package/lib/clients/NEOClient.js +15 -10
- package/lib/clients/TokenClient.d.ts +29 -5
- package/lib/clients/TokenClient.js +258 -53
- package/lib/clients/ZILClient.d.ts +1 -1
- package/lib/clients/ZILClient.js +25 -20
- package/lib/codec/cosmos/gov/v1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1/tx.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/group/v1/events.js +2 -2
- package/lib/codec/cosmos/group/v1/tx.js +4 -4
- package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
- package/lib/constant/generic.js +1 -1
- package/lib/constant/ibc.d.ts +7 -0
- package/lib/constant/ibc.js +4 -1
- package/lib/constant/network.d.ts +2 -0
- package/lib/constant/network.js +5 -1
- package/lib/hydrogen/transfer.d.ts +5 -5
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/gov.js +12 -12
- package/lib/modules/ibc.d.ts +5 -1
- package/lib/modules/ibc.js +78 -0
- package/lib/modules/liquiditypool.js +1 -1
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
- package/lib/provider/amino/types/admin.js +27 -27
- package/lib/provider/amino/types/bank.js +1 -1
- package/lib/provider/amino/types/broker.js +1 -1
- package/lib/provider/amino/types/cdp.js +22 -22
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/gov.js +4 -4
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -7
- package/lib/provider/amino/types/market.js +1 -1
- package/lib/provider/amino/types/oracle.js +1 -1
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/position.js +1 -1
- package/lib/provider/amino/types/profile.js +1 -1
- package/lib/provider/amino/types/staking.js +4 -4
- package/lib/provider/amino/types/subaccount.js +3 -3
- package/lib/provider/amino/utils.js +11 -11
- package/lib/provider/keplr/KeplrStore.d.ts +1 -1
- package/lib/provider/keplr/KeplrStore.js +2 -5
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.d.ts +5 -5
- package/lib/provider/metamask/MetaMask.js +37 -37
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +13 -13
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.d.ts +26 -0
- package/lib/util/blockchain.js +160 -1
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/ibc.d.ts +4 -3
- package/lib/util/ibc.js +20 -1
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +8 -8
- package/lib/wallet/CarbonWallet.js +6 -6
- package/lib/websocket/connector.d.ts +2 -1
- package/lib/websocket/connector.js +7 -9
- package/package.json +1 -1
- package/lib/clients/EvmIbcClient.d.ts +0 -86
- package/lib/clients/EvmIbcClient.js +0 -90
- package/lib/codec/broker/incoming_pool_swap.d.ts +0 -23
- package/lib/codec/broker/incoming_pool_swap.js +0 -136
- package/lib/util/ethermint/evm-ibc.d.ts +0 -97
- package/lib/util/ethermint/evm-ibc.js +0 -134
- package/lib/util/ethermint/index.d.ts +0 -3
- package/lib/util/ethermint/index.js +0 -12
- package/lib/util/ethermint/keys.d.ts +0 -39
- package/lib/util/ethermint/keys.js +0 -138
- package/lib/util/ethermint/web3.d.ts +0 -36
- package/lib/util/ethermint/web3.js +0 -124
package/lib/util/ibc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCw20Token = exports.calculateMaxFee = exports.parseChainId = exports.BlockchainMap = exports.getIbcChainFromBlockchain = exports.ChainIdBlockchainMap = exports.totalAssetObj = exports.EmbedChainInfos = exports.makeIBCMinimalDenom = void 0;
|
|
3
|
+
exports.isCw20Token = exports.calculateMaxFee = exports.parseChainId = exports.BlockchainMap = exports.getIbcChainFromBlockchain = exports.ChainIdBlockchainMap = exports.ChainIdBlockchainMapV2 = exports.totalAssetObj = exports.EmbedChainInfos = exports.makeIBCMinimalDenom = void 0;
|
|
4
4
|
const constant_1 = require("../constant");
|
|
5
5
|
const provider_1 = require("../provider");
|
|
6
6
|
const crypto_1 = require("@keplr-wallet/crypto");
|
|
@@ -46,6 +46,25 @@ exports.totalAssetObj = Object.values(exports.EmbedChainInfos).reduce((prev, cha
|
|
|
46
46
|
newAssetObj[chainInfo.chainId] = assetsObj;
|
|
47
47
|
return newAssetObj;
|
|
48
48
|
}, {});
|
|
49
|
+
exports.ChainIdBlockchainMapV2 = {
|
|
50
|
+
[constant_1.ChainIds.Osmosis]: "Osmosis",
|
|
51
|
+
[constant_1.ChainIds.Terra]: "Terra",
|
|
52
|
+
[constant_1.ChainIds.CosmosHub]: "Cosmos Hub",
|
|
53
|
+
[constant_1.ChainIds.Juno]: "Juno",
|
|
54
|
+
[constant_1.ChainIds.Evmos]: "Evmos",
|
|
55
|
+
[constant_1.ChainIds.Axelar]: "Axelar",
|
|
56
|
+
[constant_1.ChainIds.Stride]: "Stride",
|
|
57
|
+
[constant_1.ChainIds.Kujira]: "Kujira",
|
|
58
|
+
[constant_1.ChainIds.Terra2]: "Terra (CW20)",
|
|
59
|
+
[constant_1.ChainIds.Quicksilver]: "Quicksilver",
|
|
60
|
+
[constant_1.ChainIds.Comdex]: "Comdex",
|
|
61
|
+
[constant_1.ChainIds.StafiHub]: "Stafihub",
|
|
62
|
+
[constant_1.ChainIds.Persistence]: "Persistence Core",
|
|
63
|
+
[constant_1.ChainIds.Stargaze]: "Stargaze",
|
|
64
|
+
[constant_1.ChainIds.Canto]: "Canto",
|
|
65
|
+
[constant_1.ChainIds.OmniFlixHub]: "Omniflix Hub",
|
|
66
|
+
[constant_1.ChainIds.Agoric]: "Agoric",
|
|
67
|
+
};
|
|
49
68
|
exports.ChainIdBlockchainMap = {
|
|
50
69
|
[constant_1.ChainIds.Osmosis]: blockchain_1.Blockchain.Osmosis,
|
|
51
70
|
[constant_1.ChainIds.Terra]: blockchain_1.Blockchain.Terra,
|
package/lib/util/number.js
CHANGED
|
@@ -18,26 +18,26 @@ const parseBN = (input, defaultValue) => {
|
|
|
18
18
|
};
|
|
19
19
|
exports.parseBN = parseBN;
|
|
20
20
|
const bnOrZero = (input, defaultValue = exports.BN_ZERO) => {
|
|
21
|
-
return exports.parseBN(input, defaultValue);
|
|
21
|
+
return (0, exports.parseBN)(input, defaultValue);
|
|
22
22
|
};
|
|
23
23
|
exports.bnOrZero = bnOrZero;
|
|
24
24
|
const toHuman = (value, decimals) => {
|
|
25
25
|
if (value === undefined || value === null)
|
|
26
26
|
return undefined;
|
|
27
|
-
const valueBN = exports.bnOrZero(value);
|
|
27
|
+
const valueBN = (0, exports.bnOrZero)(value);
|
|
28
28
|
if (!decimals)
|
|
29
29
|
return valueBN; // decimals = 0 or nullish
|
|
30
|
-
const decimalsBN = exports.bnOrZero(decimals);
|
|
30
|
+
const decimalsBN = (0, exports.bnOrZero)(decimals);
|
|
31
31
|
return valueBN.shiftedBy(decimalsBN.negated().toNumber());
|
|
32
32
|
};
|
|
33
33
|
exports.toHuman = toHuman;
|
|
34
34
|
const toUnitless = (value, decimals) => {
|
|
35
35
|
if (value === undefined || value === null)
|
|
36
36
|
return undefined;
|
|
37
|
-
const valueBN = exports.bnOrZero(value);
|
|
37
|
+
const valueBN = (0, exports.bnOrZero)(value);
|
|
38
38
|
if (!decimals)
|
|
39
39
|
return valueBN; // decimals = 0 or nullish
|
|
40
|
-
const decimalsBN = exports.bnOrZero(decimals);
|
|
40
|
+
const decimalsBN = (0, exports.bnOrZero)(decimals);
|
|
41
41
|
return valueBN.shiftedBy(decimalsBN.toNumber());
|
|
42
42
|
};
|
|
43
43
|
exports.toUnitless = toUnitless;
|
|
@@ -106,9 +106,9 @@ class CarbonLedgerSigner {
|
|
|
106
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
107
|
const account = yield this.retrieveAccount();
|
|
108
108
|
const { pubkey } = account;
|
|
109
|
-
const msg = JSON.stringify(generic_1.sortObject(doc));
|
|
109
|
+
const msg = JSON.stringify((0, generic_1.sortObject)(doc));
|
|
110
110
|
const signBytes = yield this.ledger.sign(msg);
|
|
111
|
-
const signature = amino_1.encodeSecp256k1Signature(pubkey, signBytes);
|
|
111
|
+
const signature = (0, amino_1.encodeSecp256k1Signature)(pubkey, signBytes);
|
|
112
112
|
return {
|
|
113
113
|
signed: doc,
|
|
114
114
|
signature,
|
|
@@ -87,7 +87,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
87
87
|
*/
|
|
88
88
|
sign(signerAddress, messages, fee, memo, signerData) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
return proto_signing_1.isOfflineDirectSigner(this.signer)
|
|
90
|
+
return (0, proto_signing_1.isOfflineDirectSigner)(this.signer)
|
|
91
91
|
? this.signDirect(signerAddress, messages, fee, memo, signerData)
|
|
92
92
|
: this.signAmino(signerAddress, messages, fee, memo, signerData);
|
|
93
93
|
});
|
|
@@ -99,7 +99,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
99
99
|
if (!accountFromSigner) {
|
|
100
100
|
throw new Error("Failed to retrieve account from signer");
|
|
101
101
|
}
|
|
102
|
-
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
102
|
+
const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
|
|
103
103
|
const txBodyEncodeObject = {
|
|
104
104
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
105
105
|
value: Object.assign({ messages: messages, memo: memo }, (timeoutHeight && {
|
|
@@ -108,13 +108,13 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
108
108
|
};
|
|
109
109
|
const txBodyBytes = this.registry.encode(txBodyEncodeObject);
|
|
110
110
|
const gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
|
|
111
|
-
const authInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit);
|
|
112
|
-
const signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
111
|
+
const authInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence }], fee.amount, gasLimit);
|
|
112
|
+
const signDoc = (0, proto_signing_1.makeSignDoc)(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
113
113
|
const { signature, signed } = yield signer.signDirect(signerAddress, signDoc);
|
|
114
114
|
return tx_1.TxRaw.fromPartial({
|
|
115
115
|
bodyBytes: signed.bodyBytes,
|
|
116
116
|
authInfoBytes: signed.authInfoBytes,
|
|
117
|
-
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
117
|
+
signatures: [(0, encoding_1.fromBase64)(signature.signature)],
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -125,7 +125,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
125
125
|
if (!accountFromSigner) {
|
|
126
126
|
throw new Error("Failed to retrieve account from signer");
|
|
127
127
|
}
|
|
128
|
-
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
128
|
+
const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
|
|
129
129
|
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
130
130
|
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
|
131
131
|
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight !== null && timeoutHeight !== void 0 ? timeoutHeight : 0);
|
|
@@ -140,11 +140,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
140
140
|
const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
|
|
141
141
|
const signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
|
|
142
142
|
const signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
|
|
143
|
-
const signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signMode);
|
|
143
|
+
const signedAuthInfoBytes = (0, proto_signing_1.makeAuthInfoBytes)([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signMode);
|
|
144
144
|
return tx_1.TxRaw.fromPartial({
|
|
145
145
|
bodyBytes: signedTxBodyBytes,
|
|
146
146
|
authInfoBytes: signedAuthInfoBytes,
|
|
147
|
-
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
147
|
+
signatures: [(0, encoding_1.fromBase64)(signature.signature)],
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
}
|
|
@@ -150,7 +150,7 @@ class CarbonWallet {
|
|
|
150
150
|
const signerData = Object.assign({ accountNumber: this.accountInfo.accountNumber, chainId: this.getChainId(), sequence }, explicitSignerData);
|
|
151
151
|
const fee = (_a = opts === null || opts === void 0 ? void 0 : opts.fee) !== null && _a !== void 0 ? _a : this.estimateTxFee(messages, feeDenom);
|
|
152
152
|
const txRaw = yield signingClient.sign(signerAddress, messages, fee, memo, signerData);
|
|
153
|
-
signature = amino_1.encodeSecp256k1Signature(account.pubkey, txRaw.signatures[0]);
|
|
153
|
+
signature = (0, amino_1.encodeSecp256k1Signature)(account.pubkey, txRaw.signatures[0]);
|
|
154
154
|
return txRaw;
|
|
155
155
|
}
|
|
156
156
|
finally {
|
|
@@ -168,7 +168,7 @@ class CarbonWallet {
|
|
|
168
168
|
const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
|
|
169
169
|
const carbonClient = this.getSigningClient();
|
|
170
170
|
const response = yield carbonClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
|
|
171
|
-
if (stargate_1.isDeliverTxFailure(response)) {
|
|
171
|
+
if ((0, stargate_1.isDeliverTxFailure)(response)) {
|
|
172
172
|
// tx failed
|
|
173
173
|
throw new tx_1.CarbonTxError(`[${response.code}] ${response.rawLog}`, response);
|
|
174
174
|
}
|
|
@@ -207,9 +207,9 @@ class CarbonWallet {
|
|
|
207
207
|
try {
|
|
208
208
|
if (!this.accountInfo || this.sequenceInvalidated)
|
|
209
209
|
yield this.reloadAccountSequence();
|
|
210
|
-
const heightResponse = yield fetch_1.fetch(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
|
|
210
|
+
const heightResponse = yield (0, fetch_1.fetch)(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
|
|
211
211
|
const heightRes = yield heightResponse.json();
|
|
212
|
-
const height = number_1.bnOrZero((_a = heightRes.result) === null || _a === void 0 ? void 0 : _a.last_height);
|
|
212
|
+
const height = (0, number_1.bnOrZero)((_a = heightRes.result) === null || _a === void 0 ? void 0 : _a.last_height);
|
|
213
213
|
const timeoutHeight = height.isZero() ? undefined : height.toNumber() + this.defaultTimeoutBlocks;
|
|
214
214
|
const sequence = this.accountInfo.sequence;
|
|
215
215
|
this.accountInfo = Object.assign(Object.assign({}, this.accountInfo), { sequence: sequence + 1 });
|
|
@@ -343,12 +343,12 @@ class CarbonWallet {
|
|
|
343
343
|
const queryClient = this.getQueryClient();
|
|
344
344
|
const { msgGasCosts } = yield queryClient.fee.MsgGasCostAll({});
|
|
345
345
|
this.txGasCosts = msgGasCosts.reduce((result, item) => {
|
|
346
|
-
result[item.msgType] = number_1.bnOrZero(item.gasCost);
|
|
346
|
+
result[item.msgType] = (0, number_1.bnOrZero)(item.gasCost);
|
|
347
347
|
return result;
|
|
348
348
|
}, {});
|
|
349
349
|
const { minGasPrices } = yield queryClient.fee.MinGasPriceAll({});
|
|
350
350
|
this.txGasPrices = minGasPrices.reduce((result, item) => {
|
|
351
|
-
result[item.denom] = number_1.bnOrZero(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
|
|
351
|
+
result[item.denom] = (0, number_1.bnOrZero)(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
|
|
352
352
|
return result;
|
|
353
353
|
}, {});
|
|
354
354
|
if (!this.txGasPrices[this.defaultFeeDenom]) {
|
|
@@ -150,12 +150,13 @@ export declare class WSConnector {
|
|
|
150
150
|
* options: subscribe, unsubscribe, get_recent_trades, get_candlesticks, get_open_orders,
|
|
151
151
|
* get_account_trades, get_market_stats, get_leverages, get_open_positions, get_closed_positions
|
|
152
152
|
* @param {any} params - parameters based on the specified method
|
|
153
|
+
* @param {any} extras - additional args to be sent in the request
|
|
153
154
|
*
|
|
154
155
|
* @returns {Promise<WSResult<T>>} - a Promise resolving to the response from the endpoint
|
|
155
156
|
*
|
|
156
157
|
* @see WSConnector documentation for usage example
|
|
157
158
|
*/
|
|
158
|
-
request<T = unknown>(method: string, params: any): Promise<WSResult<T> | undefined>;
|
|
159
|
+
request<T = unknown>(method: string, params: any, extras?: any): Promise<WSResult<T> | undefined>;
|
|
159
160
|
/**
|
|
160
161
|
* Sends a message to the web socket
|
|
161
162
|
* @param {string | Buffer} data - the message sent to the web socket
|
|
@@ -171,7 +171,7 @@ class WSConnector {
|
|
|
171
171
|
params = [params]; // eslint-disable-line no-param-reassign
|
|
172
172
|
}
|
|
173
173
|
for (const param of params) {
|
|
174
|
-
const channelId = channel_1.generateChannelId(param);
|
|
174
|
+
const channelId = (0, channel_1.generateChannelId)(param);
|
|
175
175
|
const shouldSubscribe = this.channelHandlers[channelId] === undefined;
|
|
176
176
|
this.channelHandlers[channelId] = handler;
|
|
177
177
|
if (shouldSubscribe) {
|
|
@@ -193,7 +193,7 @@ class WSConnector {
|
|
|
193
193
|
}
|
|
194
194
|
const channelIds = [];
|
|
195
195
|
for (const param of params) {
|
|
196
|
-
const channelId = channel_1.generateChannelId(param);
|
|
196
|
+
const channelId = (0, channel_1.generateChannelId)(param);
|
|
197
197
|
const shouldUnsubscribe = this.channelHandlers[channelId] !== undefined;
|
|
198
198
|
delete this.channelHandlers[channelId];
|
|
199
199
|
if (shouldUnsubscribe) {
|
|
@@ -224,19 +224,17 @@ class WSConnector {
|
|
|
224
224
|
* options: subscribe, unsubscribe, get_recent_trades, get_candlesticks, get_open_orders,
|
|
225
225
|
* get_account_trades, get_market_stats, get_leverages, get_open_positions, get_closed_positions
|
|
226
226
|
* @param {any} params - parameters based on the specified method
|
|
227
|
+
* @param {any} extras - additional args to be sent in the request
|
|
227
228
|
*
|
|
228
229
|
* @returns {Promise<WSResult<T>>} - a Promise resolving to the response from the endpoint
|
|
229
230
|
*
|
|
230
231
|
* @see WSConnector documentation for usage example
|
|
231
232
|
*/
|
|
232
|
-
request(method, params) {
|
|
233
|
+
request(method, params, extras = {}) {
|
|
233
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
234
235
|
const requestId = `r${++this.requestIdCounter}`;
|
|
235
|
-
this.sendMessage(JSON.stringify({
|
|
236
|
-
|
|
237
|
-
method,
|
|
238
|
-
params,
|
|
239
|
-
}));
|
|
236
|
+
this.sendMessage(JSON.stringify(Object.assign({ id: requestId, method,
|
|
237
|
+
params }, extras)));
|
|
240
238
|
return new Promise((resolve, reject) => {
|
|
241
239
|
this.requestHandlers[requestId] = { requestId, resolve, reject };
|
|
242
240
|
});
|
|
@@ -283,7 +281,7 @@ class WSConnector {
|
|
|
283
281
|
if (!channelHandler) {
|
|
284
282
|
this.debugLog(`handler not found for channel: ${message.channel}`);
|
|
285
283
|
try {
|
|
286
|
-
const params = channel_1.parseChannelId(message.channel);
|
|
284
|
+
const params = (0, channel_1.parseChannelId)(message.channel);
|
|
287
285
|
this.unsubscribe({ channel: params.channel });
|
|
288
286
|
}
|
|
289
287
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Network } from "../constant";
|
|
2
|
-
import { StdSignDoc } from "@cosmjs/amino";
|
|
3
|
-
import { BlockchainUtils } from "../util";
|
|
4
|
-
declare type SupportedBlockchains = BlockchainUtils.Blockchain.Canto | BlockchainUtils.Blockchain.Evmos;
|
|
5
|
-
declare namespace EvmIbcClient {
|
|
6
|
-
interface TypedDomain {
|
|
7
|
-
name: string;
|
|
8
|
-
version: string;
|
|
9
|
-
chainId: number;
|
|
10
|
-
verifyingContract: string;
|
|
11
|
-
salt: string;
|
|
12
|
-
}
|
|
13
|
-
interface TypedDataV4 {
|
|
14
|
-
types: object;
|
|
15
|
-
primaryType: string;
|
|
16
|
-
message: StdSignDoc;
|
|
17
|
-
domain: TypedDomain;
|
|
18
|
-
}
|
|
19
|
-
const TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
|
|
20
|
-
const DEFAULT_EIP712_TYPES: {
|
|
21
|
-
EIP712Domain: {
|
|
22
|
-
name: string;
|
|
23
|
-
type: string;
|
|
24
|
-
}[];
|
|
25
|
-
Tx: {
|
|
26
|
-
name: string;
|
|
27
|
-
type: string;
|
|
28
|
-
}[];
|
|
29
|
-
Fee: {
|
|
30
|
-
name: string;
|
|
31
|
-
type: string;
|
|
32
|
-
}[];
|
|
33
|
-
Coin: {
|
|
34
|
-
name: string;
|
|
35
|
-
type: string;
|
|
36
|
-
}[];
|
|
37
|
-
Msg: {
|
|
38
|
-
name: string;
|
|
39
|
-
type: string;
|
|
40
|
-
}[];
|
|
41
|
-
};
|
|
42
|
-
const getEvmChainId: (blockchain: SupportedBlockchains, network?: Network) => 7700 | 9001;
|
|
43
|
-
const getIbcTransferTypes: () => {
|
|
44
|
-
MsgValue: {
|
|
45
|
-
name: string;
|
|
46
|
-
type: string;
|
|
47
|
-
}[];
|
|
48
|
-
TypeToken: {
|
|
49
|
-
name: string;
|
|
50
|
-
type: string;
|
|
51
|
-
}[];
|
|
52
|
-
TypeTimeoutHeight: {
|
|
53
|
-
name: string;
|
|
54
|
-
type: string;
|
|
55
|
-
}[];
|
|
56
|
-
EIP712Domain: {
|
|
57
|
-
name: string;
|
|
58
|
-
type: string;
|
|
59
|
-
}[];
|
|
60
|
-
Tx: {
|
|
61
|
-
name: string;
|
|
62
|
-
type: string;
|
|
63
|
-
}[];
|
|
64
|
-
Fee: {
|
|
65
|
-
name: string;
|
|
66
|
-
type: string;
|
|
67
|
-
}[];
|
|
68
|
-
Coin: {
|
|
69
|
-
name: string;
|
|
70
|
-
type: string;
|
|
71
|
-
}[];
|
|
72
|
-
Msg: {
|
|
73
|
-
name: string;
|
|
74
|
-
type: string;
|
|
75
|
-
}[];
|
|
76
|
-
};
|
|
77
|
-
const getCosmosWeb3Domain: (blockchain: SupportedBlockchains) => {
|
|
78
|
-
name: string;
|
|
79
|
-
version: string;
|
|
80
|
-
chainId: number;
|
|
81
|
-
verifyingContract: string;
|
|
82
|
-
salt: string;
|
|
83
|
-
};
|
|
84
|
-
const getEIP712TypedData: (tx: StdSignDoc, blockchain: SupportedBlockchains, types?: object, domain?: EvmIbcClient.TypedDomain, primaryType?: string) => TypedDataV4;
|
|
85
|
-
}
|
|
86
|
-
export default EvmIbcClient;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constant_1 = require("../constant");
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const _DEFAULT_EIP712_TYPES = {
|
|
6
|
-
EIP712Domain: [
|
|
7
|
-
{ name: 'name', type: 'string' },
|
|
8
|
-
{ name: 'version', type: 'string' },
|
|
9
|
-
{ name: 'chainId', type: 'uint256' },
|
|
10
|
-
{ name: 'verifyingContract', type: 'string' },
|
|
11
|
-
{ name: 'salt', type: 'string' },
|
|
12
|
-
],
|
|
13
|
-
Tx: [
|
|
14
|
-
{ name: 'account_number', type: 'string' },
|
|
15
|
-
{ name: 'chain_id', type: 'string' },
|
|
16
|
-
{ name: 'fee', type: 'Fee' },
|
|
17
|
-
{ name: 'memo', type: 'string' },
|
|
18
|
-
{ name: 'msgs', type: 'Msg[]' },
|
|
19
|
-
{ name: 'sequence', type: 'string' },
|
|
20
|
-
],
|
|
21
|
-
Fee: [
|
|
22
|
-
{ name: 'feePayer', type: 'string' },
|
|
23
|
-
{ name: 'amount', type: 'Coin[]' },
|
|
24
|
-
{ name: 'gas', type: 'string' },
|
|
25
|
-
],
|
|
26
|
-
Coin: [
|
|
27
|
-
{ name: 'denom', type: 'string' },
|
|
28
|
-
{ name: 'amount', type: 'string' },
|
|
29
|
-
],
|
|
30
|
-
Msg: [
|
|
31
|
-
{ name: 'type', type: 'string' },
|
|
32
|
-
{ name: 'value', type: 'MsgValue' },
|
|
33
|
-
],
|
|
34
|
-
};
|
|
35
|
-
var EvmIbcClient;
|
|
36
|
-
(function (EvmIbcClient) {
|
|
37
|
-
EvmIbcClient.TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
|
|
38
|
-
EvmIbcClient.DEFAULT_EIP712_TYPES = _DEFAULT_EIP712_TYPES;
|
|
39
|
-
EvmIbcClient.getEvmChainId = (blockchain, network = constant_1.Network.MainNet) => {
|
|
40
|
-
switch (network) {
|
|
41
|
-
case constant_1.Network.MainNet:
|
|
42
|
-
switch (blockchain) {
|
|
43
|
-
case util_1.BlockchainUtils.Blockchain.Canto:
|
|
44
|
-
return 7700;
|
|
45
|
-
case util_1.BlockchainUtils.Blockchain.Evmos:
|
|
46
|
-
return 9001;
|
|
47
|
-
default:
|
|
48
|
-
throw new Error("network not supported");
|
|
49
|
-
}
|
|
50
|
-
default:
|
|
51
|
-
throw new Error("network not supported");
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
EvmIbcClient.getIbcTransferTypes = () => {
|
|
55
|
-
return Object.assign(Object.assign({}, EvmIbcClient.DEFAULT_EIP712_TYPES), { MsgValue: [
|
|
56
|
-
{ name: 'source_port', type: 'string' },
|
|
57
|
-
{ name: 'source_channel', type: 'string' },
|
|
58
|
-
{ name: 'token', type: 'TypeToken' },
|
|
59
|
-
{ name: 'sender', type: 'string' },
|
|
60
|
-
{ name: 'receiver', type: 'string' },
|
|
61
|
-
{ name: 'timeout_height', type: 'TypeTimeoutHeight' },
|
|
62
|
-
{ name: 'timeout_timestamp', type: 'uint64' },
|
|
63
|
-
], TypeToken: [
|
|
64
|
-
{ name: 'denom', type: 'string' },
|
|
65
|
-
{ name: 'amount', type: 'string' },
|
|
66
|
-
], TypeTimeoutHeight: [
|
|
67
|
-
{ name: 'revision_number', type: 'uint64' },
|
|
68
|
-
{ name: 'revision_height', type: 'uint64' },
|
|
69
|
-
] });
|
|
70
|
-
};
|
|
71
|
-
EvmIbcClient.getCosmosWeb3Domain = (blockchain) => {
|
|
72
|
-
return {
|
|
73
|
-
name: "Cosmos Web3",
|
|
74
|
-
version: "1.0.0",
|
|
75
|
-
chainId: EvmIbcClient.getEvmChainId(blockchain),
|
|
76
|
-
verifyingContract: "cosmos",
|
|
77
|
-
salt: "0",
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
EvmIbcClient.getEIP712TypedData = (tx, blockchain, types = EvmIbcClient.getIbcTransferTypes(), domain = EvmIbcClient.getCosmosWeb3Domain(blockchain), primaryType = "Tx") => {
|
|
81
|
-
const typedData = {
|
|
82
|
-
types,
|
|
83
|
-
primaryType,
|
|
84
|
-
domain,
|
|
85
|
-
message: tx,
|
|
86
|
-
};
|
|
87
|
-
return typedData;
|
|
88
|
-
};
|
|
89
|
-
})(EvmIbcClient || (EvmIbcClient = {}));
|
|
90
|
-
exports.default = EvmIbcClient;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Long from "long";
|
|
2
|
-
import _m0 from "protobufjs/minimal";
|
|
3
|
-
export declare const protobufPackage = "Switcheo.carbon.broker";
|
|
4
|
-
export interface IncomingPoolSwap {
|
|
5
|
-
poolId: Long;
|
|
6
|
-
market: string;
|
|
7
|
-
tokenATotalInput: string;
|
|
8
|
-
tokenATotalExpectedOutput: string;
|
|
9
|
-
tokenBTotalInput: string;
|
|
10
|
-
tokenBTotalExpectedOutput: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const IncomingPoolSwap: {
|
|
13
|
-
encode(message: IncomingPoolSwap, writer?: _m0.Writer): _m0.Writer;
|
|
14
|
-
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): IncomingPoolSwap;
|
|
15
|
-
fromJSON(object: any): IncomingPoolSwap;
|
|
16
|
-
toJSON(message: IncomingPoolSwap): unknown;
|
|
17
|
-
fromPartial(object: DeepPartial<IncomingPoolSwap>): IncomingPoolSwap;
|
|
18
|
-
};
|
|
19
|
-
declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
20
|
-
export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
21
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
22
|
-
} : Partial<T>;
|
|
23
|
-
export {};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IncomingPoolSwap = exports.protobufPackage = void 0;
|
|
7
|
-
/* eslint-disable */
|
|
8
|
-
const long_1 = __importDefault(require("long"));
|
|
9
|
-
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
-
exports.protobufPackage = "Switcheo.carbon.broker";
|
|
11
|
-
const baseIncomingPoolSwap = {
|
|
12
|
-
poolId: long_1.default.UZERO,
|
|
13
|
-
market: "",
|
|
14
|
-
tokenATotalInput: "",
|
|
15
|
-
tokenATotalExpectedOutput: "",
|
|
16
|
-
tokenBTotalInput: "",
|
|
17
|
-
tokenBTotalExpectedOutput: "",
|
|
18
|
-
};
|
|
19
|
-
exports.IncomingPoolSwap = {
|
|
20
|
-
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
21
|
-
if (!message.poolId.isZero()) {
|
|
22
|
-
writer.uint32(8).uint64(message.poolId);
|
|
23
|
-
}
|
|
24
|
-
if (message.market !== "") {
|
|
25
|
-
writer.uint32(18).string(message.market);
|
|
26
|
-
}
|
|
27
|
-
if (message.tokenATotalInput !== "") {
|
|
28
|
-
writer.uint32(26).string(message.tokenATotalInput);
|
|
29
|
-
}
|
|
30
|
-
if (message.tokenATotalExpectedOutput !== "") {
|
|
31
|
-
writer.uint32(34).string(message.tokenATotalExpectedOutput);
|
|
32
|
-
}
|
|
33
|
-
if (message.tokenBTotalInput !== "") {
|
|
34
|
-
writer.uint32(42).string(message.tokenBTotalInput);
|
|
35
|
-
}
|
|
36
|
-
if (message.tokenBTotalExpectedOutput !== "") {
|
|
37
|
-
writer.uint32(50).string(message.tokenBTotalExpectedOutput);
|
|
38
|
-
}
|
|
39
|
-
return writer;
|
|
40
|
-
},
|
|
41
|
-
decode(input, length) {
|
|
42
|
-
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
43
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
44
|
-
const message = Object.assign({}, baseIncomingPoolSwap);
|
|
45
|
-
while (reader.pos < end) {
|
|
46
|
-
const tag = reader.uint32();
|
|
47
|
-
switch (tag >>> 3) {
|
|
48
|
-
case 1:
|
|
49
|
-
message.poolId = reader.uint64();
|
|
50
|
-
break;
|
|
51
|
-
case 2:
|
|
52
|
-
message.market = reader.string();
|
|
53
|
-
break;
|
|
54
|
-
case 3:
|
|
55
|
-
message.tokenATotalInput = reader.string();
|
|
56
|
-
break;
|
|
57
|
-
case 4:
|
|
58
|
-
message.tokenATotalExpectedOutput = reader.string();
|
|
59
|
-
break;
|
|
60
|
-
case 5:
|
|
61
|
-
message.tokenBTotalInput = reader.string();
|
|
62
|
-
break;
|
|
63
|
-
case 6:
|
|
64
|
-
message.tokenBTotalExpectedOutput = reader.string();
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
reader.skipType(tag & 7);
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return message;
|
|
72
|
-
},
|
|
73
|
-
fromJSON(object) {
|
|
74
|
-
const message = Object.assign({}, baseIncomingPoolSwap);
|
|
75
|
-
message.poolId =
|
|
76
|
-
object.poolId !== undefined && object.poolId !== null
|
|
77
|
-
? long_1.default.fromString(object.poolId)
|
|
78
|
-
: long_1.default.UZERO;
|
|
79
|
-
message.market =
|
|
80
|
-
object.market !== undefined && object.market !== null
|
|
81
|
-
? String(object.market)
|
|
82
|
-
: "";
|
|
83
|
-
message.tokenATotalInput =
|
|
84
|
-
object.tokenATotalInput !== undefined && object.tokenATotalInput !== null
|
|
85
|
-
? String(object.tokenATotalInput)
|
|
86
|
-
: "";
|
|
87
|
-
message.tokenATotalExpectedOutput =
|
|
88
|
-
object.tokenATotalExpectedOutput !== undefined &&
|
|
89
|
-
object.tokenATotalExpectedOutput !== null
|
|
90
|
-
? String(object.tokenATotalExpectedOutput)
|
|
91
|
-
: "";
|
|
92
|
-
message.tokenBTotalInput =
|
|
93
|
-
object.tokenBTotalInput !== undefined && object.tokenBTotalInput !== null
|
|
94
|
-
? String(object.tokenBTotalInput)
|
|
95
|
-
: "";
|
|
96
|
-
message.tokenBTotalExpectedOutput =
|
|
97
|
-
object.tokenBTotalExpectedOutput !== undefined &&
|
|
98
|
-
object.tokenBTotalExpectedOutput !== null
|
|
99
|
-
? String(object.tokenBTotalExpectedOutput)
|
|
100
|
-
: "";
|
|
101
|
-
return message;
|
|
102
|
-
},
|
|
103
|
-
toJSON(message) {
|
|
104
|
-
const obj = {};
|
|
105
|
-
message.poolId !== undefined &&
|
|
106
|
-
(obj.poolId = (message.poolId || long_1.default.UZERO).toString());
|
|
107
|
-
message.market !== undefined && (obj.market = message.market);
|
|
108
|
-
message.tokenATotalInput !== undefined &&
|
|
109
|
-
(obj.tokenATotalInput = message.tokenATotalInput);
|
|
110
|
-
message.tokenATotalExpectedOutput !== undefined &&
|
|
111
|
-
(obj.tokenATotalExpectedOutput = message.tokenATotalExpectedOutput);
|
|
112
|
-
message.tokenBTotalInput !== undefined &&
|
|
113
|
-
(obj.tokenBTotalInput = message.tokenBTotalInput);
|
|
114
|
-
message.tokenBTotalExpectedOutput !== undefined &&
|
|
115
|
-
(obj.tokenBTotalExpectedOutput = message.tokenBTotalExpectedOutput);
|
|
116
|
-
return obj;
|
|
117
|
-
},
|
|
118
|
-
fromPartial(object) {
|
|
119
|
-
var _a, _b, _c, _d, _e;
|
|
120
|
-
const message = Object.assign({}, baseIncomingPoolSwap);
|
|
121
|
-
message.poolId =
|
|
122
|
-
object.poolId !== undefined && object.poolId !== null
|
|
123
|
-
? long_1.default.fromValue(object.poolId)
|
|
124
|
-
: long_1.default.UZERO;
|
|
125
|
-
message.market = (_a = object.market) !== null && _a !== void 0 ? _a : "";
|
|
126
|
-
message.tokenATotalInput = (_b = object.tokenATotalInput) !== null && _b !== void 0 ? _b : "";
|
|
127
|
-
message.tokenATotalExpectedOutput = (_c = object.tokenATotalExpectedOutput) !== null && _c !== void 0 ? _c : "";
|
|
128
|
-
message.tokenBTotalInput = (_d = object.tokenBTotalInput) !== null && _d !== void 0 ? _d : "";
|
|
129
|
-
message.tokenBTotalExpectedOutput = (_e = object.tokenBTotalExpectedOutput) !== null && _e !== void 0 ? _e : "";
|
|
130
|
-
return message;
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
if (minimal_1.default.util.Long !== long_1.default) {
|
|
134
|
-
minimal_1.default.util.Long = long_1.default;
|
|
135
|
-
minimal_1.default.configure();
|
|
136
|
-
}
|