carbon-js-sdk 0.4.25-beta.1 → 0.4.26
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 +2 -13
- package/lib/clients/CarbonQueryClient.js +46 -56
- package/lib/clients/EvmIbcClient.d.ts +86 -0
- package/lib/clients/EvmIbcClient.js +90 -0
- package/lib/codec/bank/query.d.ts +1 -14
- package/lib/codec/bank/query.js +29 -148
- 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/group/v1/query.d.ts +0 -41
- package/lib/codec/cosmos/group/v1/query.js +1 -124
- 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 +4 -53
- package/lib/codec/index.js +812 -24902
- 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/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 +43 -56
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +0 -4
- package/lib/modules/market.d.ts +0 -34
- package/lib/modules/market.js +1 -73
- package/lib/provider/amino/AminoTypesMap.js +1 -5
- package/lib/provider/amino/types/gov.js +0 -20
- package/lib/provider/amino/types/index.d.ts +0 -3
- package/lib/provider/amino/types/index.js +1 -7
- package/lib/provider/amino/types/liquidityPool.js +0 -3
- package/lib/provider/amino/types/market.js +0 -38
- package/lib/provider/amino/types/oracle.js +0 -6
- 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/metamask/MetaMask.d.ts +1 -25
- package/lib/provider/metamask/MetaMask.js +7 -309
- package/lib/provider/o3/O3Wallet.js +0 -3
- package/lib/util/address.d.ts +1 -5
- package/lib/util/address.js +0 -11
- 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/ethermint.js +1 -1
- package/lib/util/tx.d.ts +0 -38
- package/lib/wallet/CarbonSigner.d.ts +4 -21
- package/lib/wallet/CarbonSigner.js +1 -20
- package/lib/wallet/CarbonSigningClient.d.ts +0 -1
- package/lib/wallet/CarbonSigningClient.js +4 -52
- package/lib/wallet/CarbonWallet.d.ts +2 -14
- package/lib/wallet/CarbonWallet.js +16 -141
- package/package.json +1 -2
- package/lib/modules/vault.d.ts +0 -56
- package/lib/modules/vault.js +0 -128
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
|
-
perpsliquidity: PerpsLiquidityModule;
|
|
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.perpsliquidity = new modules_1.PerpsLiquidityModule(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";
|
|
@@ -41,6 +36,7 @@ import { QueryClientImpl as PositionQueryClient } from "../codec/position/query"
|
|
|
41
36
|
import { QueryClientImpl as PricingQueryClient } from "../codec/pricing/query";
|
|
42
37
|
import { QueryClientImpl as ProfileQueryClient } from "../codec/profile/query";
|
|
43
38
|
import { QueryClientImpl as SubaccountQueryClient } from "../codec/subaccount/query";
|
|
39
|
+
import { QueryClientImpl as AlliancesClient } from "../codec/alliance/query";
|
|
44
40
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
45
41
|
import BlockchainClient from "./BlockchainClient";
|
|
46
42
|
export interface IBCClientGroup {
|
|
@@ -51,10 +47,6 @@ export interface IBCClientGroup {
|
|
|
51
47
|
connection: IBCConnectionQueryClient;
|
|
52
48
|
channel: IBCChannelQueryClient;
|
|
53
49
|
}
|
|
54
|
-
export interface EthermintClientGroup {
|
|
55
|
-
evm: EthermintEVMQueryClient;
|
|
56
|
-
feeMarket: EthermintFeeMarketQueryClient;
|
|
57
|
-
}
|
|
58
50
|
declare class CarbonQueryClient {
|
|
59
51
|
private readonly tmClient;
|
|
60
52
|
adl: ADLQueryClient;
|
|
@@ -68,7 +60,6 @@ declare class CarbonQueryClient {
|
|
|
68
60
|
leverage: LeverageQueryClient;
|
|
69
61
|
liquidation: LiquidationQueryClient;
|
|
70
62
|
liquiditypool: LiquidityPoolQueryClient;
|
|
71
|
-
perpetualpool: PerpLiquidityPoolQueryClient;
|
|
72
63
|
market: MarketQueryClient;
|
|
73
64
|
marketstats: MarketStatsQueryClient;
|
|
74
65
|
misc: MiscQueryClient;
|
|
@@ -90,11 +81,9 @@ declare class CarbonQueryClient {
|
|
|
90
81
|
staking: StakingQueryClient;
|
|
91
82
|
upgrade: UpgradeQueryClient;
|
|
92
83
|
cosmosTm: CosmosTmClient;
|
|
84
|
+
alliances: AlliancesClient;
|
|
93
85
|
chain: BlockchainClient;
|
|
94
86
|
ibc: IBCClientGroup;
|
|
95
|
-
ethermint: EthermintClientGroup;
|
|
96
|
-
evmmerge: EvmMergeQueryClient;
|
|
97
|
-
evmbank: EvmBankQueryClient;
|
|
98
87
|
private baseClient;
|
|
99
88
|
constructor(tmClient: Tendermint34Client);
|
|
100
89
|
getProtobufRpcClient(): import("@cosmjs/stargate").ProtobufRpcClient;
|
|
@@ -19,33 +19,29 @@ 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/
|
|
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");
|
|
44
|
+
const query_39 = require("../codec/alliance/query");
|
|
49
45
|
const stargate_1 = require("@cosmjs/stargate");
|
|
50
46
|
const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
|
|
51
47
|
class CarbonQueryClient {
|
|
@@ -59,25 +55,22 @@ class CarbonQueryClient {
|
|
|
59
55
|
this.broker = new query_3.QueryClientImpl(rpcClient);
|
|
60
56
|
this.coin = new query_5.QueryClientImpl(rpcClient);
|
|
61
57
|
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);
|
|
58
|
+
this.fee = new query_17.QueryClientImpl(rpcClient);
|
|
59
|
+
this.inflation = new query_25.QueryClientImpl(rpcClient);
|
|
60
|
+
this.insurance = new query_26.QueryClientImpl(rpcClient);
|
|
61
|
+
this.leverage = new query_27.QueryClientImpl(rpcClient);
|
|
62
|
+
this.liquidation = new query_28.QueryClientImpl(rpcClient);
|
|
63
|
+
this.liquiditypool = new query_29.QueryClientImpl(rpcClient);
|
|
64
|
+
this.market = new query_30.QueryClientImpl(rpcClient);
|
|
65
|
+
this.marketstats = new query_31.QueryClientImpl(rpcClient);
|
|
66
|
+
this.misc = new query_32.QueryClientImpl(rpcClient);
|
|
67
|
+
this.oracle = new query_33.QueryClientImpl(rpcClient);
|
|
68
|
+
this.order = new query_34.QueryClientImpl(rpcClient);
|
|
69
|
+
this.position = new query_35.QueryClientImpl(rpcClient);
|
|
70
|
+
this.pricing = new query_36.QueryClientImpl(rpcClient);
|
|
71
|
+
this.profile = new query_37.QueryClientImpl(rpcClient);
|
|
72
|
+
this.subaccount = new query_38.QueryClientImpl(rpcClient);
|
|
73
|
+
this.headersync = new query_18.QueryClientImpl(rpcClient);
|
|
81
74
|
this.auth = new query_6.QueryClientImpl(rpcClient);
|
|
82
75
|
this.bank = new query_7.QueryClientImpl(rpcClient);
|
|
83
76
|
this.distribution = new query_9.QueryClientImpl(rpcClient);
|
|
@@ -89,17 +82,14 @@ class CarbonQueryClient {
|
|
|
89
82
|
this.staking = new query_15.QueryClientImpl(rpcClient);
|
|
90
83
|
this.upgrade = new query_16.QueryClientImpl(rpcClient);
|
|
91
84
|
this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
|
|
85
|
+
this.alliances = new query_39.QueryClientImpl(rpcClient);
|
|
92
86
|
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),
|
|
87
|
+
controller: new query_19.QueryClientImpl(rpcClient),
|
|
88
|
+
host: new query_20.QueryClientImpl(rpcClient),
|
|
89
|
+
transfer: new query_21.QueryClientImpl(rpcClient),
|
|
90
|
+
client: new query_22.QueryClientImpl(rpcClient),
|
|
91
|
+
connection: new query_23.QueryClientImpl(rpcClient),
|
|
92
|
+
channel: new query_24.QueryClientImpl(rpcClient),
|
|
103
93
|
};
|
|
104
94
|
}
|
|
105
95
|
getProtobufRpcClient() {
|
|
@@ -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;
|
|
@@ -5,15 +5,9 @@ export declare const protobufPackage = "Switcheo.carbon.bank";
|
|
|
5
5
|
export interface InternalTransfer {
|
|
6
6
|
sender: string;
|
|
7
7
|
receiver: string;
|
|
8
|
-
transactionHash: string;
|
|
9
|
-
coins: Coin[];
|
|
10
|
-
transactionMemo: string;
|
|
11
|
-
transactionBlockHeight: Long;
|
|
12
|
-
transactionBlockTime?: Date;
|
|
13
|
-
}
|
|
14
|
-
export interface Coin {
|
|
15
8
|
denom: string;
|
|
16
9
|
amount: string;
|
|
10
|
+
transactionHash: string;
|
|
17
11
|
}
|
|
18
12
|
export interface QueryInternalTransfersRequest {
|
|
19
13
|
address: string;
|
|
@@ -33,13 +27,6 @@ export declare const InternalTransfer: {
|
|
|
33
27
|
toJSON(message: InternalTransfer): unknown;
|
|
34
28
|
fromPartial(object: DeepPartial<InternalTransfer>): InternalTransfer;
|
|
35
29
|
};
|
|
36
|
-
export declare const Coin: {
|
|
37
|
-
encode(message: Coin, writer?: _m0.Writer): _m0.Writer;
|
|
38
|
-
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Coin;
|
|
39
|
-
fromJSON(object: any): Coin;
|
|
40
|
-
toJSON(message: Coin): unknown;
|
|
41
|
-
fromPartial(object: DeepPartial<Coin>): Coin;
|
|
42
|
-
};
|
|
43
30
|
export declare const QueryInternalTransfersRequest: {
|
|
44
31
|
encode(message: QueryInternalTransfersRequest, writer?: _m0.Writer): _m0.Writer;
|
|
45
32
|
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryInternalTransfersRequest;
|