carbon-js-sdk 0.4.21-beta.1 → 0.4.22
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.d.ts +1 -12
- package/lib/CarbonSDK.js +2 -30
- package/lib/clients/CarbonQueryClient.d.ts +0 -13
- package/lib/clients/CarbonQueryClient.js +46 -58
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/EvmIbcClient.d.ts +86 -0
- package/lib/clients/EvmIbcClient.js +90 -0
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +4 -4
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/broker/amm.d.ts +7 -35
- package/lib/codec/broker/amm.js +6 -185
- package/lib/codec/broker/genesis.d.ts +2 -2
- package/lib/codec/broker/genesis.js +9 -9
- package/lib/codec/broker/incoming_pool_swap.d.ts +23 -0
- package/lib/codec/broker/incoming_pool_swap.js +136 -0
- 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/query.d.ts +0 -41
- package/lib/codec/cosmos/group/v1/query.js +1 -124
- package/lib/codec/cosmos/group/v1/tx.js +4 -4
- package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
- package/lib/codec/cosmos/vesting/v1beta1/tx.d.ts +0 -2
- package/lib/codec/cosmos/vesting/v1beta1/vesting.d.ts +0 -3
- package/lib/codec/index.d.ts +3 -41
- package/lib/codec/index.js +479 -23535
- package/lib/codec/market/genesis.d.ts +0 -3
- package/lib/codec/market/genesis.js +2 -33
- package/lib/codec/market/market.d.ts +0 -8
- package/lib/codec/market/query.d.ts +0 -93
- package/lib/codec/market/query.js +1 -420
- package/lib/codec/market/tx.d.ts +3 -100
- package/lib/codec/market/tx.js +7 -553
- package/lib/codec/tendermint/abci/types.d.ts +1 -1
- package/lib/codec/tendermint/crypto/keys.d.ts +1 -1
- package/lib/codec/tendermint/types/types.d.ts +1 -1
- package/lib/constant/generic.js +1 -1
- package/lib/constant/network.d.ts +1 -9
- package/lib/constant/network.js +5 -19
- package/lib/constant/walletProvider.d.ts +1 -3
- package/lib/constant/walletProvider.js +0 -3
- package/lib/modules/cdp.d.ts +1 -1
- package/lib/modules/cdp.js +85 -98
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/gov.js +12 -12
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +0 -4
- 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/AminoTypesMap.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 +25 -25
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/gov.js +4 -24
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/index.d.ts +0 -3
- package/lib/provider/amino/types/index.js +1 -7
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -25
- package/lib/provider/amino/types/market.js +2 -2
- package/lib/provider/amino/types/oracle.js +1 -7
- 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/KeplrAccount.d.ts +0 -2
- package/lib/provider/keplr/KeplrAccount.js +0 -38
- package/lib/provider/leap/LeapAccount.js +0 -4
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.d.ts +1 -25
- package/lib/provider/metamask/MetaMask.js +8 -310
- package/lib/provider/o3/O3Wallet.js +2 -5
- package/lib/util/address.d.ts +1 -5
- package/lib/util/address.js +13 -24
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.d.ts +5 -4
- package/lib/util/blockchain.js +3 -9
- package/lib/util/ethermint/evm-ibc.d.ts +97 -0
- package/lib/util/ethermint/evm-ibc.js +134 -0
- package/lib/util/ethermint/index.d.ts +3 -0
- package/lib/util/ethermint/index.js +12 -0
- package/lib/util/ethermint/keys.d.ts +39 -0
- package/lib/util/ethermint/keys.js +138 -0
- package/lib/util/ethermint/web3.d.ts +36 -0
- package/lib/util/ethermint/web3.js +124 -0
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/number.js +5 -5
- package/lib/util/tx.d.ts +0 -30
- package/lib/wallet/CarbonSigner.d.ts +4 -21
- package/lib/wallet/CarbonSigner.js +3 -22
- package/lib/wallet/CarbonSigningClient.d.ts +0 -1
- package/lib/wallet/CarbonSigningClient.js +10 -58
- package/lib/wallet/CarbonWallet.d.ts +2 -14
- package/lib/wallet/CarbonWallet.js +22 -147
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -2
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +0 -1
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +0 -6
- package/lib/codec/ethermint/evm/v1/export.d.ts +0 -5
- package/lib/codec/ethermint/evm/v1/export.js +0 -53
- package/lib/codec/ethermint/feemarket/v1/export.d.ts +0 -4
- package/lib/codec/ethermint/feemarket/v1/export.js +0 -18
- package/lib/codec/ethermint/types/v1/export.d.ts +0 -4
- package/lib/codec/ethermint/types/v1/export.js +0 -11
- package/lib/codec/ethermint-models.d.ts +0 -4
- package/lib/codec/ethermint-models.js +0 -26
- package/lib/codec/market/fee.d.ts +0 -123
- package/lib/codec/market/fee.js +0 -334
- package/lib/codec/perpsliquidity/event.d.ts +0 -102
- package/lib/codec/perpsliquidity/event.js +0 -581
- package/lib/codec/perpsliquidity/genesis.d.ts +0 -35
- package/lib/codec/perpsliquidity/genesis.js +0 -162
- package/lib/codec/perpsliquidity/params.d.ts +0 -24
- package/lib/codec/perpsliquidity/params.js +0 -103
- package/lib/codec/perpsliquidity/pool.d.ts +0 -137
- package/lib/codec/perpsliquidity/pool.js +0 -747
- package/lib/codec/perpsliquidity/query.d.ts +0 -194
- package/lib/codec/perpsliquidity/query.js +0 -876
- package/lib/codec/perpsliquidity/tx.d.ts +0 -199
- package/lib/codec/perpsliquidity/tx.js +0 -940
- package/lib/constant/eip712.d.ts +0 -46
- package/lib/constant/eip712.js +0 -106
- package/lib/modules/evm.d.ts +0 -46
- package/lib/modules/evm.js +0 -127
- package/lib/modules/evmmerge.d.ts +0 -12
- package/lib/modules/evmmerge.js +0 -35
- package/lib/modules/feemarket.d.ts +0 -20
- package/lib/modules/feemarket.js +0 -45
- package/lib/modules/vault.d.ts +0 -56
- package/lib/modules/vault.js +0 -128
- package/lib/provider/amino/types/evm.d.ts +0 -4
- package/lib/provider/amino/types/evm.js +0 -40
- package/lib/provider/amino/types/evmmerge.d.ts +0 -4
- package/lib/provider/amino/types/evmmerge.js +0 -34
- package/lib/provider/amino/types/feemarket.d.ts +0 -4
- package/lib/provider/amino/types/feemarket.js +0 -34
- package/lib/provider/metamask/legacy-accounts.d.ts +0 -6
- package/lib/provider/metamask/legacy-accounts.js +0 -44
- package/lib/util/eip712.d.ts +0 -10
- package/lib/util/eip712.js +0 -195
- package/lib/util/ethermint.d.ts +0 -8
- package/lib/util/ethermint.js +0 -68
- package/lib/util/legacyEIP712.d.ts +0 -20
- package/lib/util/legacyEIP712.js +0 -98
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -4,12 +4,10 @@ import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
|
4
4
|
import { CarbonQueryClient, ETHClient, HydrogenClient, InsightsQueryClient, NEOClient, TokenClient, ZILClient } from "./clients";
|
|
5
5
|
import * as clients from "./clients";
|
|
6
6
|
import N3Client from "./clients/N3Client";
|
|
7
|
-
import { AdminModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule
|
|
7
|
+
import { AdminModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
|
|
8
8
|
import { StakingModule } from "./modules/staking";
|
|
9
9
|
import { CosmosLedger, Keplr, LeapExtended } from "./provider";
|
|
10
10
|
import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts } from "./wallet";
|
|
11
|
-
import { MetaMask } from "./provider/metamask/MetaMask";
|
|
12
|
-
import { ethers } from "ethers";
|
|
13
11
|
export { CarbonTx } from "./util";
|
|
14
12
|
export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
|
|
15
13
|
export { DenomPrefix } from "./constant";
|
|
@@ -17,7 +15,6 @@ export interface CarbonSDKOpts {
|
|
|
17
15
|
network: Network;
|
|
18
16
|
tmClient: Tendermint34Client;
|
|
19
17
|
chainId?: string;
|
|
20
|
-
evmChainId?: string;
|
|
21
18
|
token?: TokenClient;
|
|
22
19
|
config?: Partial<NetworkConfig>;
|
|
23
20
|
defaultTimeoutBlocks?: number;
|
|
@@ -44,7 +41,6 @@ declare class CarbonSDK {
|
|
|
44
41
|
readonly query: CarbonQueryClient;
|
|
45
42
|
insights: InsightsQueryClient;
|
|
46
43
|
hydrogen: HydrogenClient;
|
|
47
|
-
evmJsonRpc: ethers.providers.JsonRpcProvider;
|
|
48
44
|
wallet?: CarbonWallet;
|
|
49
45
|
network: Network;
|
|
50
46
|
configOverride: Partial<NetworkConfig>;
|
|
@@ -54,7 +50,6 @@ declare class CarbonSDK {
|
|
|
54
50
|
admin: AdminModule;
|
|
55
51
|
order: OrderModule;
|
|
56
52
|
lp: LiquidityPoolModule;
|
|
57
|
-
vault: VaultModule;
|
|
58
53
|
subaccount: SubAccountModule;
|
|
59
54
|
profile: ProfileModule;
|
|
60
55
|
cdp: CDPModule;
|
|
@@ -70,9 +65,6 @@ declare class CarbonSDK {
|
|
|
70
65
|
fee: FeeModule;
|
|
71
66
|
ibc: IBCModule;
|
|
72
67
|
xchain: XChainModule;
|
|
73
|
-
evm: EvmModule;
|
|
74
|
-
evmmerge: EvmMergeModule;
|
|
75
|
-
feemarket: FeemarketModule;
|
|
76
68
|
neo: NEOClient;
|
|
77
69
|
eth: ETHClient;
|
|
78
70
|
bsc: ETHClient;
|
|
@@ -82,7 +74,6 @@ declare class CarbonSDK {
|
|
|
82
74
|
zil: ZILClient;
|
|
83
75
|
n3: N3Client;
|
|
84
76
|
chainId: string;
|
|
85
|
-
evmChainId: string;
|
|
86
77
|
constructor(opts: CarbonSDKOpts);
|
|
87
78
|
static instance(opts?: CarbonSDKInitOpts): Promise<CarbonSDK>;
|
|
88
79
|
static instanceWithWallet(wallet: CarbonWallet, sdkOpts?: CarbonSDKInitOpts): Promise<ConnectedCarbonSDK>;
|
|
@@ -92,7 +83,6 @@ declare class CarbonSDK {
|
|
|
92
83
|
static instanceWithLedger(ledger: CosmosLedger, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
93
84
|
static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
94
85
|
static instanceWithLeap(leap: LeapExtended, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
95
|
-
static instanceWithMetamask(metamask: MetaMask, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
96
86
|
static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
97
87
|
initialize(): Promise<CarbonSDK>;
|
|
98
88
|
clone(): CarbonSDK;
|
|
@@ -105,7 +95,6 @@ declare class CarbonSDK {
|
|
|
105
95
|
connectWithLedger(ledger: CosmosLedger, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
106
96
|
connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
107
97
|
connectWithLeap(leap: LeapExtended, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
108
|
-
connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
109
98
|
connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
110
99
|
getConfig(): NetworkConfig;
|
|
111
100
|
getTokenClient(): TokenClient;
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -43,7 +43,6 @@ const staking_1 = require("./modules/staking");
|
|
|
43
43
|
const provider_1 = require("./provider");
|
|
44
44
|
const blockchain_1 = require("./util/blockchain");
|
|
45
45
|
const wallet_1 = require("./wallet");
|
|
46
|
-
const ethers_1 = require("ethers");
|
|
47
46
|
var util_2 = require("./util");
|
|
48
47
|
Object.defineProperty(exports, "CarbonTx", { enumerable: true, get: function () { return util_2.CarbonTx; } });
|
|
49
48
|
var wallet_2 = require("./wallet");
|
|
@@ -61,23 +60,19 @@ const DEFAULT_SDK_INIT_OPTS = {
|
|
|
61
60
|
*/
|
|
62
61
|
class CarbonSDK {
|
|
63
62
|
constructor(opts) {
|
|
64
|
-
var _a, _b, _c, _d, _e
|
|
63
|
+
var _a, _b, _c, _d, _e;
|
|
65
64
|
this.network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
|
|
66
65
|
this.configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
|
|
67
66
|
this.networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[this.network], this.configOverride);
|
|
68
67
|
this.tmClient = opts.tmClient;
|
|
69
68
|
this.chainId = (_d = (_c = opts.chainId) !== null && _c !== void 0 ? _c : constant_1.CarbonChainIDs[this.network]) !== null && _d !== void 0 ? _d : constant_1.CarbonChainIDs[constant_1.Network.MainNet];
|
|
70
|
-
this.evmChainId = (_f = (_e = opts.evmChainId) !== null && _e !== void 0 ? _e : constant_1.CarbonEvmChainIDs[this.network]) !== null && _f !== void 0 ? _f : constant_1.CarbonEvmChainIDs[constant_1.Network.MainNet];
|
|
71
69
|
this.query = new clients_1.CarbonQueryClient(opts.tmClient);
|
|
72
70
|
this.insights = new clients_1.InsightsQueryClient(this.networkConfig);
|
|
73
|
-
this.token = (
|
|
74
|
-
this.hydrogen = new clients_1.HydrogenClient(this.networkConfig, this.token);
|
|
75
|
-
this.evmJsonRpc = new ethers_1.ethers.providers.JsonRpcProvider(constant_1.NetworkConfigs[this.network].evmJsonRpcUrl);
|
|
71
|
+
this.token = (_e = opts.token) !== null && _e !== void 0 ? _e : clients_1.TokenClient.instance(this.query, this);
|
|
76
72
|
this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
|
|
77
73
|
this.admin = new modules_1.AdminModule(this);
|
|
78
74
|
this.order = new modules_1.OrderModule(this);
|
|
79
75
|
this.lp = new modules_1.LiquidityPoolModule(this);
|
|
80
|
-
this.vault = new modules_1.VaultModule(this);
|
|
81
76
|
this.subaccount = new modules_1.SubAccountModule(this);
|
|
82
77
|
this.profile = new modules_1.ProfileModule(this);
|
|
83
78
|
this.cdp = new modules_1.CDPModule(this);
|
|
@@ -93,9 +88,6 @@ class CarbonSDK {
|
|
|
93
88
|
this.fee = new modules_1.FeeModule(this);
|
|
94
89
|
this.ibc = new modules_1.IBCModule(this);
|
|
95
90
|
this.xchain = new modules_1.XChainModule(this);
|
|
96
|
-
this.evm = new modules_1.EvmModule(this);
|
|
97
|
-
this.evmmerge = new modules_1.EvmMergeModule(this);
|
|
98
|
-
this.feemarket = new modules_1.FeemarketModule(this);
|
|
99
91
|
this.neo = clients_1.NEOClient.instance({
|
|
100
92
|
configProvider: this,
|
|
101
93
|
blockchain: blockchain_1.Blockchain.Neo,
|
|
@@ -195,12 +187,6 @@ class CarbonSDK {
|
|
|
195
187
|
return sdk.connectWithLeap(leap, walletOpts);
|
|
196
188
|
});
|
|
197
189
|
}
|
|
198
|
-
static instanceWithMetamask(metamask, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
|
|
199
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const sdk = yield CarbonSDK.instance(sdkOpts);
|
|
201
|
-
return sdk.connectWithMetamask(metamask, walletOpts);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
190
|
static instanceViewOnly(bech32Address, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
|
|
205
191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
192
|
const sdk = yield CarbonSDK.instance(sdkOpts);
|
|
@@ -304,20 +290,6 @@ class CarbonSDK {
|
|
|
304
290
|
return this.connect(wallet);
|
|
305
291
|
});
|
|
306
292
|
}
|
|
307
|
-
connectWithMetamask(metamask, opts) {
|
|
308
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
const evmChainId = this.evmChainId;
|
|
310
|
-
const addressOptions = {
|
|
311
|
-
network: this.networkConfig.network,
|
|
312
|
-
bech32Prefix: this.networkConfig.Bech32Prefix
|
|
313
|
-
};
|
|
314
|
-
const address = yield metamask.defaultAccount();
|
|
315
|
-
const publicKeyHex = yield metamask.getPublicKey(address);
|
|
316
|
-
const publicKeyBase64 = Buffer.from(publicKeyHex, 'hex').toString('base64');
|
|
317
|
-
const wallet = wallet_1.CarbonWallet.withMetamask(metamask, evmChainId, publicKeyBase64, addressOptions, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
318
|
-
return this.connect(wallet);
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
293
|
connectViewOnly(bech32Address, opts) {
|
|
322
294
|
return __awaiter(this, void 0, void 0, function* () {
|
|
323
295
|
const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
@@ -14,10 +14,6 @@ import { QueryClientImpl as ParamsQueryClient } from "../codec/cosmos/params/v1b
|
|
|
14
14
|
import { QueryClientImpl as SlashingQueryClient } from "../codec/cosmos/slashing/v1beta1/query";
|
|
15
15
|
import { QueryClientImpl as StakingQueryClient } from "../codec/cosmos/staking/v1beta1/query";
|
|
16
16
|
import { QueryClientImpl as UpgradeQueryClient } from "../codec/cosmos/upgrade/v1beta1/query";
|
|
17
|
-
import { QueryClientImpl as EthermintEVMQueryClient } from "../codec/ethermint/evm/v1/query";
|
|
18
|
-
import { QueryClientImpl as EvmMergeQueryClient } from "../codec/evmmerge/query";
|
|
19
|
-
import { QueryClientImpl as EvmBankQueryClient } from "../codec/evmbank/query";
|
|
20
|
-
import { QueryClientImpl as EthermintFeeMarketQueryClient } from "../codec/ethermint/feemarket/v1/query";
|
|
21
17
|
import { QueryClientImpl as FeeQueryClient } from "../codec/fee/query";
|
|
22
18
|
import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/query";
|
|
23
19
|
import { QueryClientImpl as IBCInterchainControlQueryClient } from "../codec/ibc/applications/interchain_accounts/controller/v1/query";
|
|
@@ -31,7 +27,6 @@ import { QueryClientImpl as InsuranceQueryClient } from "../codec/insurance/quer
|
|
|
31
27
|
import { QueryClientImpl as LeverageQueryClient } from "../codec/leverage/query";
|
|
32
28
|
import { QueryClientImpl as LiquidationQueryClient } from "../codec/liquidation/query";
|
|
33
29
|
import { QueryClientImpl as LiquidityPoolQueryClient } from "../codec/liquiditypool/query";
|
|
34
|
-
import { QueryClientImpl as PerpLiquidityPoolQueryClient } from "../codec/perpsliquidity/query";
|
|
35
30
|
import { QueryClientImpl as MarketQueryClient } from "../codec/market/query";
|
|
36
31
|
import { QueryClientImpl as MarketStatsQueryClient } from "../codec/marketstats/query";
|
|
37
32
|
import { QueryClientImpl as MiscQueryClient } from "../codec/misc/query";
|
|
@@ -51,10 +46,6 @@ export interface IBCClientGroup {
|
|
|
51
46
|
connection: IBCConnectionQueryClient;
|
|
52
47
|
channel: IBCChannelQueryClient;
|
|
53
48
|
}
|
|
54
|
-
export interface EthermintClientGroup {
|
|
55
|
-
evm: EthermintEVMQueryClient;
|
|
56
|
-
feeMarket: EthermintFeeMarketQueryClient;
|
|
57
|
-
}
|
|
58
49
|
declare class CarbonQueryClient {
|
|
59
50
|
private readonly tmClient;
|
|
60
51
|
adl: ADLQueryClient;
|
|
@@ -68,7 +59,6 @@ declare class CarbonQueryClient {
|
|
|
68
59
|
leverage: LeverageQueryClient;
|
|
69
60
|
liquidation: LiquidationQueryClient;
|
|
70
61
|
liquiditypool: LiquidityPoolQueryClient;
|
|
71
|
-
perpetualpool: PerpLiquidityPoolQueryClient;
|
|
72
62
|
market: MarketQueryClient;
|
|
73
63
|
marketstats: MarketStatsQueryClient;
|
|
74
64
|
misc: MiscQueryClient;
|
|
@@ -92,9 +82,6 @@ declare class CarbonQueryClient {
|
|
|
92
82
|
cosmosTm: CosmosTmClient;
|
|
93
83
|
chain: BlockchainClient;
|
|
94
84
|
ibc: IBCClientGroup;
|
|
95
|
-
ethermint: EthermintClientGroup;
|
|
96
|
-
evmmerge: EvmMergeQueryClient;
|
|
97
|
-
evmbank: EvmBankQueryClient;
|
|
98
85
|
private baseClient;
|
|
99
86
|
constructor(tmClient: Tendermint34Client);
|
|
100
87
|
getProtobufRpcClient(): import("@cosmjs/stargate").ProtobufRpcClient;
|
|
@@ -19,65 +19,57 @@ const query_13 = require("../codec/cosmos/params/v1beta1/query");
|
|
|
19
19
|
const query_14 = require("../codec/cosmos/slashing/v1beta1/query");
|
|
20
20
|
const query_15 = require("../codec/cosmos/staking/v1beta1/query");
|
|
21
21
|
const query_16 = require("../codec/cosmos/upgrade/v1beta1/query");
|
|
22
|
-
const query_17 = require("../codec/
|
|
23
|
-
const query_18 = require("../codec/
|
|
24
|
-
const query_19 = require("../codec/
|
|
25
|
-
const query_20 = require("../codec/
|
|
26
|
-
const query_21 = require("../codec/
|
|
27
|
-
const query_22 = require("../codec/
|
|
28
|
-
const query_23 = require("../codec/ibc/
|
|
29
|
-
const query_24 = require("../codec/ibc/
|
|
30
|
-
const query_25 = require("../codec/
|
|
31
|
-
const query_26 = require("../codec/
|
|
32
|
-
const query_27 = require("../codec/
|
|
33
|
-
const query_28 = require("../codec/
|
|
34
|
-
const query_29 = require("../codec/
|
|
35
|
-
const query_30 = require("../codec/
|
|
36
|
-
const query_31 = require("../codec/
|
|
37
|
-
const query_32 = require("../codec/
|
|
38
|
-
const query_33 = require("../codec/
|
|
39
|
-
const query_34 = require("../codec/
|
|
40
|
-
const query_35 = require("../codec/
|
|
41
|
-
const query_36 = require("../codec/
|
|
42
|
-
const query_37 = require("../codec/
|
|
43
|
-
const query_38 = require("../codec/
|
|
44
|
-
const query_39 = require("../codec/order/query");
|
|
45
|
-
const query_40 = require("../codec/position/query");
|
|
46
|
-
const query_41 = require("../codec/pricing/query");
|
|
47
|
-
const query_42 = require("../codec/profile/query");
|
|
48
|
-
const query_43 = require("../codec/subaccount/query");
|
|
22
|
+
const query_17 = require("../codec/fee/query");
|
|
23
|
+
const query_18 = require("../codec/headersync/query");
|
|
24
|
+
const query_19 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
|
|
25
|
+
const query_20 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
|
|
26
|
+
const query_21 = require("../codec/ibc/applications/transfer/v1/query");
|
|
27
|
+
const query_22 = require("../codec/ibc/core/client/v1/query");
|
|
28
|
+
const query_23 = require("../codec/ibc/core/connection/v1/query");
|
|
29
|
+
const query_24 = require("../codec/ibc/core/channel/v1/query");
|
|
30
|
+
const query_25 = require("../codec/inflation/query");
|
|
31
|
+
const query_26 = require("../codec/insurance/query");
|
|
32
|
+
const query_27 = require("../codec/leverage/query");
|
|
33
|
+
const query_28 = require("../codec/liquidation/query");
|
|
34
|
+
const query_29 = require("../codec/liquiditypool/query");
|
|
35
|
+
const query_30 = require("../codec/market/query");
|
|
36
|
+
const query_31 = require("../codec/marketstats/query");
|
|
37
|
+
const query_32 = require("../codec/misc/query");
|
|
38
|
+
const query_33 = require("../codec/oracle/query");
|
|
39
|
+
const query_34 = require("../codec/order/query");
|
|
40
|
+
const query_35 = require("../codec/position/query");
|
|
41
|
+
const query_36 = require("../codec/pricing/query");
|
|
42
|
+
const query_37 = require("../codec/profile/query");
|
|
43
|
+
const query_38 = require("../codec/subaccount/query");
|
|
49
44
|
const stargate_1 = require("@cosmjs/stargate");
|
|
50
45
|
const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
|
|
51
46
|
class CarbonQueryClient {
|
|
52
47
|
constructor(tmClient) {
|
|
53
48
|
this.tmClient = tmClient;
|
|
54
49
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
55
|
-
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
50
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
56
51
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
57
52
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
58
53
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
59
54
|
this.broker = new query_3.QueryClientImpl(rpcClient);
|
|
60
55
|
this.coin = new query_5.QueryClientImpl(rpcClient);
|
|
61
56
|
this.cdp = new query_4.QueryClientImpl(rpcClient);
|
|
62
|
-
this.fee = new
|
|
63
|
-
this.inflation = new
|
|
64
|
-
this.insurance = new
|
|
65
|
-
this.leverage = new
|
|
66
|
-
this.liquidation = new
|
|
67
|
-
this.liquiditypool = new
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this.headersync = new query_22.QueryClientImpl(rpcClient);
|
|
79
|
-
this.evmmerge = new query_18.QueryClientImpl(rpcClient);
|
|
80
|
-
this.evmbank = new query_19.QueryClientImpl(rpcClient);
|
|
57
|
+
this.fee = new query_17.QueryClientImpl(rpcClient);
|
|
58
|
+
this.inflation = new query_25.QueryClientImpl(rpcClient);
|
|
59
|
+
this.insurance = new query_26.QueryClientImpl(rpcClient);
|
|
60
|
+
this.leverage = new query_27.QueryClientImpl(rpcClient);
|
|
61
|
+
this.liquidation = new query_28.QueryClientImpl(rpcClient);
|
|
62
|
+
this.liquiditypool = new query_29.QueryClientImpl(rpcClient);
|
|
63
|
+
this.market = new query_30.QueryClientImpl(rpcClient);
|
|
64
|
+
this.marketstats = new query_31.QueryClientImpl(rpcClient);
|
|
65
|
+
this.misc = new query_32.QueryClientImpl(rpcClient);
|
|
66
|
+
this.oracle = new query_33.QueryClientImpl(rpcClient);
|
|
67
|
+
this.order = new query_34.QueryClientImpl(rpcClient);
|
|
68
|
+
this.position = new query_35.QueryClientImpl(rpcClient);
|
|
69
|
+
this.pricing = new query_36.QueryClientImpl(rpcClient);
|
|
70
|
+
this.profile = new query_37.QueryClientImpl(rpcClient);
|
|
71
|
+
this.subaccount = new query_38.QueryClientImpl(rpcClient);
|
|
72
|
+
this.headersync = new query_18.QueryClientImpl(rpcClient);
|
|
81
73
|
this.auth = new query_6.QueryClientImpl(rpcClient);
|
|
82
74
|
this.bank = new query_7.QueryClientImpl(rpcClient);
|
|
83
75
|
this.distribution = new query_9.QueryClientImpl(rpcClient);
|
|
@@ -90,20 +82,16 @@ class CarbonQueryClient {
|
|
|
90
82
|
this.upgrade = new query_16.QueryClientImpl(rpcClient);
|
|
91
83
|
this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
|
|
92
84
|
this.ibc = {
|
|
93
|
-
controller: new
|
|
94
|
-
host: new
|
|
95
|
-
transfer: new
|
|
96
|
-
client: new
|
|
97
|
-
connection: new
|
|
98
|
-
channel: new
|
|
99
|
-
};
|
|
100
|
-
this.ethermint = {
|
|
101
|
-
evm: new query_17.QueryClientImpl(rpcClient),
|
|
102
|
-
feeMarket: new query_20.QueryClientImpl(rpcClient),
|
|
85
|
+
controller: new query_19.QueryClientImpl(rpcClient),
|
|
86
|
+
host: new query_20.QueryClientImpl(rpcClient),
|
|
87
|
+
transfer: new query_21.QueryClientImpl(rpcClient),
|
|
88
|
+
client: new query_22.QueryClientImpl(rpcClient),
|
|
89
|
+
connection: new query_23.QueryClientImpl(rpcClient),
|
|
90
|
+
channel: new query_24.QueryClientImpl(rpcClient),
|
|
103
91
|
};
|
|
104
92
|
}
|
|
105
93
|
getProtobufRpcClient() {
|
|
106
|
-
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
94
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
107
95
|
}
|
|
108
96
|
}
|
|
109
97
|
exports.default = CarbonQueryClient;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -44,15 +44,15 @@ class ETHClient {
|
|
|
44
44
|
?
|
|
45
45
|
this.tokenClient.getBlockchainV2(token.denom) == ETHClient.BLOCKCHAINV2_MAPPING[this.blockchain]
|
|
46
46
|
:
|
|
47
|
-
blockchain_1.blockchainForChainId(token.chainId.toNumber(), api.network) == this.blockchain;
|
|
47
|
+
(0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), api.network) == this.blockchain;
|
|
48
48
|
return isCorrectBlockchain &&
|
|
49
49
|
token.tokenAddress.length == 40 &&
|
|
50
|
-
token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
|
|
50
|
+
token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
|
|
51
51
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
52
|
-
this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
52
|
+
this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
53
53
|
});
|
|
54
54
|
const assetIds = tokens.map((token) => {
|
|
55
|
-
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
55
|
+
return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
56
56
|
});
|
|
57
57
|
const provider = this.getProvider();
|
|
58
58
|
const contractAddress = this.getBalanceReaderAddress();
|
|
@@ -99,14 +99,14 @@ class ETHClient {
|
|
|
99
99
|
}
|
|
100
100
|
const carbonNetwork = networkConfig.network;
|
|
101
101
|
const fromTokenId = fromToken.id;
|
|
102
|
-
const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
102
|
+
const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
103
103
|
const toTokenDenom = toToken.denom;
|
|
104
104
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
105
105
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
106
106
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
107
107
|
const nonce = yield this.getTxNonce(fromAddress, params.nonce, rpcProvider);
|
|
108
108
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
109
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
109
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
110
110
|
const tokenCreator = fromToken.creator;
|
|
111
111
|
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, carbonNetwork);
|
|
112
112
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
@@ -135,9 +135,9 @@ class ETHClient {
|
|
|
135
135
|
throw new Error("Minimum gas required: 150,000");
|
|
136
136
|
}
|
|
137
137
|
const networkConfig = this.getNetworkConfig();
|
|
138
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
139
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
140
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
138
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
139
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
140
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
141
141
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
142
142
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
143
143
|
const contractAddress = this.getLockProxyAddress();
|
|
@@ -188,16 +188,16 @@ class ETHClient {
|
|
|
188
188
|
return "insufficient balance";
|
|
189
189
|
}
|
|
190
190
|
const networkConfig = this.getNetworkConfig();
|
|
191
|
-
const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
|
|
192
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
193
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
191
|
+
const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
|
|
192
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
193
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
194
194
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
|
|
195
195
|
const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
|
|
196
196
|
const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
|
|
197
197
|
// logger("sendDeposit message", message)
|
|
198
198
|
let signatureResult;
|
|
199
199
|
const { address, signature } = yield getSignatureCallback(message);
|
|
200
|
-
const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
|
|
200
|
+
const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
|
|
201
201
|
const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
|
|
202
202
|
// logger("sign result", address, signature)
|
|
203
203
|
signatureResult = {
|
|
@@ -236,7 +236,7 @@ class ETHClient {
|
|
|
236
236
|
if (!feeInfo.deposit_fee) {
|
|
237
237
|
throw new Error("unsupported token");
|
|
238
238
|
}
|
|
239
|
-
if (blockchain_1.blockchainForChainId(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
239
|
+
if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
240
240
|
throw new Error("unsupported token");
|
|
241
241
|
}
|
|
242
242
|
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
@@ -302,7 +302,7 @@ class ETHClient {
|
|
|
302
302
|
getTargetProxyHash(token) {
|
|
303
303
|
const networkConfig = this.getNetworkConfig();
|
|
304
304
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
305
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
305
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
306
306
|
return addressHex;
|
|
307
307
|
}
|
|
308
308
|
getProvider() {
|
|
@@ -0,0 +1,86 @@
|
|
|
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;
|
|
@@ -0,0 +1,90 @@
|
|
|
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;
|
|
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
|
|
|
29
29
|
const formatDateField = (value) => {
|
|
30
30
|
if (typeof value !== "string")
|
|
31
31
|
return null;
|
|
32
|
-
return dayjs_1.default(value);
|
|
32
|
+
return (0, dayjs_1.default)(value);
|
|
33
33
|
};
|
|
34
34
|
// temporary function to parse okt/okc blockchain
|
|
35
35
|
// to remove when automatic deposit/withdraw feature is deployed
|