carbon-js-sdk 0.4.3 → 0.4.4
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/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +1 -1
- package/lib/clients/ZILClient.js +17 -17
- 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/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 +16 -0
- package/lib/modules/ibc.js +23 -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/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +1 -1
- 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/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- 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.js +3 -3
- 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
|
@@ -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]) {
|
|
@@ -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) {
|
|
@@ -281,7 +281,7 @@ class WSConnector {
|
|
|
281
281
|
if (!channelHandler) {
|
|
282
282
|
this.debugLog(`handler not found for channel: ${message.channel}`);
|
|
283
283
|
try {
|
|
284
|
-
const params = channel_1.parseChannelId(message.channel);
|
|
284
|
+
const params = (0, channel_1.parseChannelId)(message.channel);
|
|
285
285
|
this.unsubscribe({ channel: params.channel });
|
|
286
286
|
}
|
|
287
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
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { TxRaw } from "../../codec/cosmos/tx/v1beta1/tx";
|
|
2
|
-
import { Network } from "../../constant";
|
|
3
|
-
import { StdFee, StdSignDoc } from "@cosmjs/amino";
|
|
4
|
-
import { EncodeObject, Registry } from "@cosmjs/proto-signing";
|
|
5
|
-
import { Blockchain } from "../blockchain";
|
|
6
|
-
declare type SupportedBlockchains = Blockchain.Canto | Blockchain.Evmos;
|
|
7
|
-
declare namespace EvmIbcHelper {
|
|
8
|
-
interface TypedDomain {
|
|
9
|
-
name: string;
|
|
10
|
-
version: string;
|
|
11
|
-
chainId: number;
|
|
12
|
-
verifyingContract: string;
|
|
13
|
-
salt: string;
|
|
14
|
-
}
|
|
15
|
-
interface TypedDataV4 {
|
|
16
|
-
types: object;
|
|
17
|
-
primaryType: string;
|
|
18
|
-
message: StdSignDoc;
|
|
19
|
-
domain: TypedDomain;
|
|
20
|
-
}
|
|
21
|
-
interface SignFee extends StdFee {
|
|
22
|
-
feePayer: string;
|
|
23
|
-
}
|
|
24
|
-
interface SignDoc extends StdSignDoc {
|
|
25
|
-
fee: SignFee;
|
|
26
|
-
}
|
|
27
|
-
const TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
|
|
28
|
-
const DEFAULT_EIP712_TYPES: {
|
|
29
|
-
EIP712Domain: {
|
|
30
|
-
name: string;
|
|
31
|
-
type: string;
|
|
32
|
-
}[];
|
|
33
|
-
Tx: {
|
|
34
|
-
name: string;
|
|
35
|
-
type: string;
|
|
36
|
-
}[];
|
|
37
|
-
Fee: {
|
|
38
|
-
name: string;
|
|
39
|
-
type: string;
|
|
40
|
-
}[];
|
|
41
|
-
Coin: {
|
|
42
|
-
name: string;
|
|
43
|
-
type: string;
|
|
44
|
-
}[];
|
|
45
|
-
Msg: {
|
|
46
|
-
name: string;
|
|
47
|
-
type: string;
|
|
48
|
-
}[];
|
|
49
|
-
};
|
|
50
|
-
const getEvmChainId: (blockchain: SupportedBlockchains, network?: Network) => 7700 | 9001;
|
|
51
|
-
const getIbcTransferTypes: () => {
|
|
52
|
-
MsgValue: {
|
|
53
|
-
name: string;
|
|
54
|
-
type: string;
|
|
55
|
-
}[];
|
|
56
|
-
TypeToken: {
|
|
57
|
-
name: string;
|
|
58
|
-
type: string;
|
|
59
|
-
}[];
|
|
60
|
-
TypeTimeoutHeight: {
|
|
61
|
-
name: string;
|
|
62
|
-
type: string;
|
|
63
|
-
}[];
|
|
64
|
-
EIP712Domain: {
|
|
65
|
-
name: string;
|
|
66
|
-
type: string;
|
|
67
|
-
}[];
|
|
68
|
-
Tx: {
|
|
69
|
-
name: string;
|
|
70
|
-
type: string;
|
|
71
|
-
}[];
|
|
72
|
-
Fee: {
|
|
73
|
-
name: string;
|
|
74
|
-
type: string;
|
|
75
|
-
}[];
|
|
76
|
-
Coin: {
|
|
77
|
-
name: string;
|
|
78
|
-
type: string;
|
|
79
|
-
}[];
|
|
80
|
-
Msg: {
|
|
81
|
-
name: string;
|
|
82
|
-
type: string;
|
|
83
|
-
}[];
|
|
84
|
-
};
|
|
85
|
-
const getCosmosWeb3Domain: (blockchain: SupportedBlockchains) => {
|
|
86
|
-
name: string;
|
|
87
|
-
version: string;
|
|
88
|
-
chainId: number;
|
|
89
|
-
verifyingContract: string;
|
|
90
|
-
salt: string;
|
|
91
|
-
};
|
|
92
|
-
const getSignatureExtension: (blockchain: SupportedBlockchains, address: string, signature: Uint8Array) => EncodeObject;
|
|
93
|
-
const getEIP712TypedData: (blockchain: SupportedBlockchains, tx: EvmIbcHelper.SignDoc, types?: object, domain?: EvmIbcHelper.TypedDomain, primaryType?: string) => TypedDataV4;
|
|
94
|
-
const makeSignedTx: (blockchain: SupportedBlockchains, msgs: EncodeObject[], tx: EvmIbcHelper.SignDoc, address: string, publicKey: Uint8Array, signature: Uint8Array, registry: Registry) => TxRaw;
|
|
95
|
-
const registerEthermintCodec: (registry: Registry) => void;
|
|
96
|
-
}
|
|
97
|
-
export default EvmIbcHelper;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tx_1 = require("../../codec/cosmos/tx/v1beta1/tx");
|
|
4
|
-
const constant_1 = require("../../constant");
|
|
5
|
-
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
6
|
-
const signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
|
|
7
|
-
const blockchain_1 = require("../blockchain");
|
|
8
|
-
const keys_1 = require("./keys");
|
|
9
|
-
const web3_1 = require("./web3");
|
|
10
|
-
const _DEFAULT_EIP712_TYPES = {
|
|
11
|
-
EIP712Domain: [
|
|
12
|
-
{ name: 'name', type: 'string' },
|
|
13
|
-
{ name: 'version', type: 'string' },
|
|
14
|
-
{ name: 'chainId', type: 'uint256' },
|
|
15
|
-
{ name: 'verifyingContract', type: 'string' },
|
|
16
|
-
{ name: 'salt', type: 'string' },
|
|
17
|
-
],
|
|
18
|
-
Tx: [
|
|
19
|
-
{ name: 'account_number', type: 'string' },
|
|
20
|
-
{ name: 'chain_id', type: 'string' },
|
|
21
|
-
{ name: 'fee', type: 'Fee' },
|
|
22
|
-
{ name: 'memo', type: 'string' },
|
|
23
|
-
{ name: 'msgs', type: 'Msg[]' },
|
|
24
|
-
{ name: 'sequence', type: 'string' },
|
|
25
|
-
],
|
|
26
|
-
Fee: [
|
|
27
|
-
{ name: 'feePayer', type: 'string' },
|
|
28
|
-
{ name: 'amount', type: 'Coin[]' },
|
|
29
|
-
{ name: 'gas', type: 'string' },
|
|
30
|
-
],
|
|
31
|
-
Coin: [
|
|
32
|
-
{ name: 'denom', type: 'string' },
|
|
33
|
-
{ name: 'amount', type: 'string' },
|
|
34
|
-
],
|
|
35
|
-
Msg: [
|
|
36
|
-
{ name: 'type', type: 'string' },
|
|
37
|
-
{ name: 'value', type: 'MsgValue' },
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
var EvmIbcHelper;
|
|
41
|
-
(function (EvmIbcHelper) {
|
|
42
|
-
;
|
|
43
|
-
EvmIbcHelper.TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
|
|
44
|
-
EvmIbcHelper.DEFAULT_EIP712_TYPES = _DEFAULT_EIP712_TYPES;
|
|
45
|
-
EvmIbcHelper.getEvmChainId = (blockchain, network = constant_1.Network.MainNet) => {
|
|
46
|
-
switch (network) {
|
|
47
|
-
case constant_1.Network.MainNet:
|
|
48
|
-
switch (blockchain) {
|
|
49
|
-
case blockchain_1.Blockchain.Canto:
|
|
50
|
-
return 7700;
|
|
51
|
-
case blockchain_1.Blockchain.Evmos:
|
|
52
|
-
return 9001;
|
|
53
|
-
default:
|
|
54
|
-
throw new Error("network not supported");
|
|
55
|
-
}
|
|
56
|
-
default:
|
|
57
|
-
throw new Error("network not supported");
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
EvmIbcHelper.getIbcTransferTypes = () => {
|
|
61
|
-
return Object.assign(Object.assign({}, EvmIbcHelper.DEFAULT_EIP712_TYPES), { MsgValue: [
|
|
62
|
-
{ name: 'source_port', type: 'string' },
|
|
63
|
-
{ name: 'source_channel', type: 'string' },
|
|
64
|
-
{ name: 'token', type: 'TypeToken' },
|
|
65
|
-
{ name: 'sender', type: 'string' },
|
|
66
|
-
{ name: 'receiver', type: 'string' },
|
|
67
|
-
{ name: 'timeout_height', type: 'TypeTimeoutHeight' },
|
|
68
|
-
{ name: 'timeout_timestamp', type: 'uint64' },
|
|
69
|
-
], TypeToken: [
|
|
70
|
-
{ name: 'denom', type: 'string' },
|
|
71
|
-
{ name: 'amount', type: 'string' },
|
|
72
|
-
], TypeTimeoutHeight: [
|
|
73
|
-
{ name: 'revision_number', type: 'uint64' },
|
|
74
|
-
{ name: 'revision_height', type: 'uint64' },
|
|
75
|
-
] });
|
|
76
|
-
};
|
|
77
|
-
EvmIbcHelper.getCosmosWeb3Domain = (blockchain) => {
|
|
78
|
-
return {
|
|
79
|
-
name: "Cosmos Web3",
|
|
80
|
-
version: "1.0.0",
|
|
81
|
-
chainId: EvmIbcHelper.getEvmChainId(blockchain),
|
|
82
|
-
verifyingContract: "cosmos",
|
|
83
|
-
salt: "0",
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
EvmIbcHelper.getSignatureExtension = (blockchain, address, signature) => {
|
|
87
|
-
return {
|
|
88
|
-
typeUrl: "/ethermint.types.v1.ExtensionOptionsWeb3Tx",
|
|
89
|
-
value: web3_1.ExtensionOptionsWeb3Tx.encode(web3_1.ExtensionOptionsWeb3Tx.fromPartial({
|
|
90
|
-
typedDataChainId: EvmIbcHelper.getEvmChainId(blockchain),
|
|
91
|
-
feePayer: address,
|
|
92
|
-
feePayerSig: signature,
|
|
93
|
-
})).finish(),
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
EvmIbcHelper.getEIP712TypedData = (blockchain, tx, types = EvmIbcHelper.getIbcTransferTypes(), domain = EvmIbcHelper.getCosmosWeb3Domain(blockchain), primaryType = "Tx") => {
|
|
97
|
-
const typedData = {
|
|
98
|
-
types,
|
|
99
|
-
primaryType,
|
|
100
|
-
domain,
|
|
101
|
-
message: tx,
|
|
102
|
-
};
|
|
103
|
-
return typedData;
|
|
104
|
-
};
|
|
105
|
-
EvmIbcHelper.makeSignedTx = (blockchain, msgs, tx, address, publicKey, signature, registry) => {
|
|
106
|
-
EvmIbcHelper.registerEthermintCodec(registry);
|
|
107
|
-
const pubkey = registry.encodeAsAny({
|
|
108
|
-
typeUrl: '/ethermint.crypto.v1.ethsecp256k1.PubKey',
|
|
109
|
-
value: keys_1.PubKey.fromPartial({
|
|
110
|
-
key: publicKey,
|
|
111
|
-
}),
|
|
112
|
-
});
|
|
113
|
-
const signatureExtension = EvmIbcHelper.getSignatureExtension(blockchain, address, signature);
|
|
114
|
-
const txBodyBytes = registry.encodeTxBody({
|
|
115
|
-
extensionOptions: [signatureExtension],
|
|
116
|
-
messages: msgs,
|
|
117
|
-
memo: tx.memo,
|
|
118
|
-
});
|
|
119
|
-
const txRaw = tx_1.TxRaw.fromPartial({
|
|
120
|
-
authInfoBytes: proto_signing_1.makeAuthInfoBytes([{
|
|
121
|
-
pubkey,
|
|
122
|
-
sequence: parseInt(tx.sequence),
|
|
123
|
-
}], tx.fee.amount, parseInt(tx.fee.gas), signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON),
|
|
124
|
-
bodyBytes: txBodyBytes,
|
|
125
|
-
signatures: [new Uint8Array()],
|
|
126
|
-
});
|
|
127
|
-
return txRaw;
|
|
128
|
-
};
|
|
129
|
-
EvmIbcHelper.registerEthermintCodec = (registry) => {
|
|
130
|
-
registry.register('/ethermint.types.v1.ExtensionOptionsWeb3Tx', web3_1.ExtensionOptionsWeb3Tx);
|
|
131
|
-
registry.register('/ethermint.crypto.v1.ethsecp256k1.PubKey', keys_1.PubKey);
|
|
132
|
-
};
|
|
133
|
-
})(EvmIbcHelper || (EvmIbcHelper = {}));
|
|
134
|
-
exports.default = EvmIbcHelper;
|
|
@@ -1,12 +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.EvmIbcHelper = exports.ExtensionOptionsWeb3Tx = exports.PubKey = void 0;
|
|
7
|
-
var keys_1 = require("./keys");
|
|
8
|
-
Object.defineProperty(exports, "PubKey", { enumerable: true, get: function () { return keys_1.PubKey; } });
|
|
9
|
-
var web3_1 = require("./web3");
|
|
10
|
-
Object.defineProperty(exports, "ExtensionOptionsWeb3Tx", { enumerable: true, get: function () { return web3_1.ExtensionOptionsWeb3Tx; } });
|
|
11
|
-
var evm_ibc_1 = require("./evm-ibc");
|
|
12
|
-
Object.defineProperty(exports, "EvmIbcHelper", { enumerable: true, get: function () { return __importDefault(evm_ibc_1).default; } });
|