carbon-js-sdk 0.4.27 → 0.4.28-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CarbonSDK.d.ts +12 -1
- package/lib/CarbonSDK.js +30 -2
- package/lib/clients/CarbonQueryClient.d.ts +13 -0
- package/lib/clients/CarbonQueryClient.js +59 -46
- package/lib/codec/bank/query.d.ts +14 -1
- package/lib/codec/bank/query.js +148 -29
- package/lib/codec/broker/amm.d.ts +35 -7
- package/lib/codec/broker/amm.js +185 -6
- package/lib/codec/broker/genesis.d.ts +2 -2
- package/lib/codec/broker/genesis.js +9 -9
- package/lib/codec/cosmos/group/v1/query.d.ts +41 -0
- package/lib/codec/cosmos/group/v1/query.js +124 -1
- package/lib/codec/cosmos/vesting/v1beta1/tx.d.ts +2 -0
- package/lib/codec/cosmos/vesting/v1beta1/vesting.d.ts +3 -0
- package/lib/codec/index.d.ts +53 -4
- package/lib/codec/index.js +24902 -812
- package/lib/codec/market/genesis.d.ts +3 -0
- package/lib/codec/market/genesis.js +33 -2
- package/lib/codec/market/market.d.ts +8 -0
- package/lib/codec/market/query.d.ts +93 -0
- package/lib/codec/market/query.js +420 -1
- package/lib/codec/market/tx.d.ts +100 -3
- package/lib/codec/market/tx.js +553 -7
- 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 +9 -1
- package/lib/constant/network.js +19 -5
- package/lib/constant/walletProvider.d.ts +3 -1
- package/lib/constant/walletProvider.js +3 -0
- package/lib/modules/cdp.d.ts +1 -1
- package/lib/modules/cdp.js +56 -43
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +4 -0
- package/lib/modules/market.d.ts +34 -0
- package/lib/modules/market.js +73 -1
- package/lib/provider/amino/AminoTypesMap.js +5 -1
- package/lib/provider/amino/types/gov.js +20 -0
- package/lib/provider/amino/types/index.d.ts +3 -0
- package/lib/provider/amino/types/index.js +7 -1
- package/lib/provider/amino/types/liquidityPool.js +3 -0
- package/lib/provider/amino/types/market.js +38 -0
- package/lib/provider/amino/types/oracle.js +6 -0
- package/lib/provider/keplr/KeplrAccount.d.ts +2 -0
- package/lib/provider/keplr/KeplrAccount.js +38 -0
- package/lib/provider/leap/LeapAccount.js +4 -0
- package/lib/provider/ledger/ledger.d.ts +1 -0
- package/lib/provider/ledger/ledger.js +10 -0
- package/lib/provider/metamask/MetaMask.d.ts +27 -2
- package/lib/provider/metamask/MetaMask.js +317 -12
- package/lib/provider/metamask/legacy-accounts.d.ts +4 -0
- package/lib/provider/metamask/legacy-accounts.js +2171 -8
- package/lib/provider/o3/O3Wallet.js +3 -0
- package/lib/util/address.d.ts +5 -1
- package/lib/util/address.js +11 -0
- package/lib/util/blockchain.d.ts +4 -5
- package/lib/util/blockchain.js +9 -3
- package/lib/util/tx.d.ts +39 -0
- package/lib/wallet/CarbonSigner.d.ts +21 -4
- package/lib/wallet/CarbonSigner.js +20 -1
- package/lib/wallet/CarbonSigningClient.d.ts +1 -0
- package/lib/wallet/CarbonSigningClient.js +52 -4
- package/lib/wallet/CarbonWallet.d.ts +38 -2
- package/lib/wallet/CarbonWallet.js +200 -21
- package/package.json +2 -1
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -4,10 +4,12 @@ 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, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
|
|
7
|
+
import { AdminModule, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule, EvmModule, FeemarketModule, EvmMergeModule, PerpsLiquidityModule } 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";
|
|
11
13
|
export { CarbonTx } from "./util";
|
|
12
14
|
export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
|
|
13
15
|
export { DenomPrefix } from "./constant";
|
|
@@ -15,6 +17,7 @@ export interface CarbonSDKOpts {
|
|
|
15
17
|
network: Network;
|
|
16
18
|
tmClient: Tendermint34Client;
|
|
17
19
|
chainId?: string;
|
|
20
|
+
evmChainId?: string;
|
|
18
21
|
token?: TokenClient;
|
|
19
22
|
config?: Partial<NetworkConfig>;
|
|
20
23
|
defaultTimeoutBlocks?: number;
|
|
@@ -41,6 +44,7 @@ declare class CarbonSDK {
|
|
|
41
44
|
readonly query: CarbonQueryClient;
|
|
42
45
|
insights: InsightsQueryClient;
|
|
43
46
|
hydrogen: HydrogenClient;
|
|
47
|
+
evmJsonRpc: ethers.providers.JsonRpcProvider;
|
|
44
48
|
wallet?: CarbonWallet;
|
|
45
49
|
network: Network;
|
|
46
50
|
configOverride: Partial<NetworkConfig>;
|
|
@@ -51,6 +55,7 @@ declare class CarbonSDK {
|
|
|
51
55
|
alliance: AllianceModule;
|
|
52
56
|
order: OrderModule;
|
|
53
57
|
lp: LiquidityPoolModule;
|
|
58
|
+
plp: PerpsLiquidityModule;
|
|
54
59
|
subaccount: SubAccountModule;
|
|
55
60
|
profile: ProfileModule;
|
|
56
61
|
cdp: CDPModule;
|
|
@@ -66,6 +71,9 @@ declare class CarbonSDK {
|
|
|
66
71
|
fee: FeeModule;
|
|
67
72
|
ibc: IBCModule;
|
|
68
73
|
xchain: XChainModule;
|
|
74
|
+
evm: EvmModule;
|
|
75
|
+
evmmerge: EvmMergeModule;
|
|
76
|
+
feemarket: FeemarketModule;
|
|
69
77
|
neo: NEOClient;
|
|
70
78
|
eth: ETHClient;
|
|
71
79
|
bsc: ETHClient;
|
|
@@ -75,6 +83,7 @@ declare class CarbonSDK {
|
|
|
75
83
|
zil: ZILClient;
|
|
76
84
|
n3: N3Client;
|
|
77
85
|
chainId: string;
|
|
86
|
+
evmChainId: string;
|
|
78
87
|
constructor(opts: CarbonSDKOpts);
|
|
79
88
|
static instance(opts?: CarbonSDKInitOpts): Promise<CarbonSDK>;
|
|
80
89
|
static instanceWithWallet(wallet: CarbonWallet, sdkOpts?: CarbonSDKInitOpts): Promise<ConnectedCarbonSDK>;
|
|
@@ -84,6 +93,7 @@ declare class CarbonSDK {
|
|
|
84
93
|
static instanceWithLedger(ledger: CosmosLedger, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
85
94
|
static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
86
95
|
static instanceWithLeap(leap: LeapExtended, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
96
|
+
static instanceWithMetamask(metamask: MetaMask, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
87
97
|
static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
88
98
|
initialize(): Promise<CarbonSDK>;
|
|
89
99
|
clone(): CarbonSDK;
|
|
@@ -96,6 +106,7 @@ declare class CarbonSDK {
|
|
|
96
106
|
connectWithLedger(ledger: CosmosLedger, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
97
107
|
connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
98
108
|
connectWithLeap(leap: LeapExtended, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
109
|
+
connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
99
110
|
connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
100
111
|
getConfig(): NetworkConfig;
|
|
101
112
|
getTokenClient(): TokenClient;
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -43,6 +43,7 @@ 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");
|
|
46
47
|
var util_2 = require("./util");
|
|
47
48
|
Object.defineProperty(exports, "CarbonTx", { enumerable: true, get: function () { return util_2.CarbonTx; } });
|
|
48
49
|
var wallet_2 = require("./wallet");
|
|
@@ -60,20 +61,24 @@ const DEFAULT_SDK_INIT_OPTS = {
|
|
|
60
61
|
*/
|
|
61
62
|
class CarbonSDK {
|
|
62
63
|
constructor(opts) {
|
|
63
|
-
var _a, _b, _c, _d, _e;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
64
65
|
this.network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
|
|
65
66
|
this.configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
|
|
66
67
|
this.networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[this.network], this.configOverride);
|
|
67
68
|
this.tmClient = opts.tmClient;
|
|
68
69
|
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];
|
|
69
71
|
this.query = new clients_1.CarbonQueryClient(opts.tmClient);
|
|
70
72
|
this.insights = new clients_1.InsightsQueryClient(this.networkConfig);
|
|
71
|
-
this.token = (
|
|
73
|
+
this.token = (_g = opts.token) !== null && _g !== void 0 ? _g : clients_1.TokenClient.instance(this.query, this);
|
|
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);
|
|
72
76
|
this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
|
|
73
77
|
this.admin = new modules_1.AdminModule(this);
|
|
74
78
|
this.alliance = new modules_1.AllianceModule(this);
|
|
75
79
|
this.order = new modules_1.OrderModule(this);
|
|
76
80
|
this.lp = new modules_1.LiquidityPoolModule(this);
|
|
81
|
+
this.plp = new modules_1.PerpsLiquidityModule(this);
|
|
77
82
|
this.subaccount = new modules_1.SubAccountModule(this);
|
|
78
83
|
this.profile = new modules_1.ProfileModule(this);
|
|
79
84
|
this.cdp = new modules_1.CDPModule(this);
|
|
@@ -89,6 +94,9 @@ class CarbonSDK {
|
|
|
89
94
|
this.fee = new modules_1.FeeModule(this);
|
|
90
95
|
this.ibc = new modules_1.IBCModule(this);
|
|
91
96
|
this.xchain = new modules_1.XChainModule(this);
|
|
97
|
+
this.evm = new modules_1.EvmModule(this);
|
|
98
|
+
this.evmmerge = new modules_1.EvmMergeModule(this);
|
|
99
|
+
this.feemarket = new modules_1.FeemarketModule(this);
|
|
92
100
|
this.neo = clients_1.NEOClient.instance({
|
|
93
101
|
configProvider: this,
|
|
94
102
|
blockchain: blockchain_1.Blockchain.Neo,
|
|
@@ -188,6 +196,12 @@ class CarbonSDK {
|
|
|
188
196
|
return sdk.connectWithLeap(leap, walletOpts);
|
|
189
197
|
});
|
|
190
198
|
}
|
|
199
|
+
static instanceWithMetamask(metamask, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const sdk = yield CarbonSDK.instance(sdkOpts);
|
|
202
|
+
return sdk.connectWithMetamask(metamask, walletOpts);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
191
205
|
static instanceViewOnly(bech32Address, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
|
|
192
206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
193
207
|
const sdk = yield CarbonSDK.instance(sdkOpts);
|
|
@@ -291,6 +305,20 @@ class CarbonSDK {
|
|
|
291
305
|
return this.connect(wallet);
|
|
292
306
|
});
|
|
293
307
|
}
|
|
308
|
+
connectWithMetamask(metamask, opts) {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
const evmChainId = this.evmChainId;
|
|
311
|
+
const addressOptions = {
|
|
312
|
+
network: this.networkConfig.network,
|
|
313
|
+
bech32Prefix: this.networkConfig.Bech32Prefix
|
|
314
|
+
};
|
|
315
|
+
const address = yield metamask.defaultAccount();
|
|
316
|
+
const publicKeyHex = yield metamask.getPublicKey(address);
|
|
317
|
+
const publicKeyBase64 = Buffer.from(publicKeyHex, 'hex').toString('base64');
|
|
318
|
+
const wallet = wallet_1.CarbonWallet.withMetamask(metamask, evmChainId, publicKeyBase64, addressOptions, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
319
|
+
return this.connect(wallet);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
294
322
|
connectViewOnly(bech32Address, opts) {
|
|
295
323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
296
324
|
const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
@@ -14,6 +14,10 @@ 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";
|
|
17
21
|
import { QueryClientImpl as FeeQueryClient } from "../codec/fee/query";
|
|
18
22
|
import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/query";
|
|
19
23
|
import { QueryClientImpl as IBCInterchainControlQueryClient } from "../codec/ibc/applications/interchain_accounts/controller/v1/query";
|
|
@@ -27,6 +31,7 @@ import { QueryClientImpl as InsuranceQueryClient } from "../codec/insurance/quer
|
|
|
27
31
|
import { QueryClientImpl as LeverageQueryClient } from "../codec/leverage/query";
|
|
28
32
|
import { QueryClientImpl as LiquidationQueryClient } from "../codec/liquidation/query";
|
|
29
33
|
import { QueryClientImpl as LiquidityPoolQueryClient } from "../codec/liquiditypool/query";
|
|
34
|
+
import { QueryClientImpl as PerpLiquidityPoolQueryClient } from "../codec/perpsliquidity/query";
|
|
30
35
|
import { QueryClientImpl as MarketQueryClient } from "../codec/market/query";
|
|
31
36
|
import { QueryClientImpl as MarketStatsQueryClient } from "../codec/marketstats/query";
|
|
32
37
|
import { QueryClientImpl as MiscQueryClient } from "../codec/misc/query";
|
|
@@ -47,6 +52,10 @@ export interface IBCClientGroup {
|
|
|
47
52
|
connection: IBCConnectionQueryClient;
|
|
48
53
|
channel: IBCChannelQueryClient;
|
|
49
54
|
}
|
|
55
|
+
export interface EthermintClientGroup {
|
|
56
|
+
evm: EthermintEVMQueryClient;
|
|
57
|
+
feeMarket: EthermintFeeMarketQueryClient;
|
|
58
|
+
}
|
|
50
59
|
declare class CarbonQueryClient {
|
|
51
60
|
private readonly tmClient;
|
|
52
61
|
adl: ADLQueryClient;
|
|
@@ -60,6 +69,7 @@ declare class CarbonQueryClient {
|
|
|
60
69
|
leverage: LeverageQueryClient;
|
|
61
70
|
liquidation: LiquidationQueryClient;
|
|
62
71
|
liquiditypool: LiquidityPoolQueryClient;
|
|
72
|
+
perpetualpool: PerpLiquidityPoolQueryClient;
|
|
63
73
|
market: MarketQueryClient;
|
|
64
74
|
marketstats: MarketStatsQueryClient;
|
|
65
75
|
misc: MiscQueryClient;
|
|
@@ -84,6 +94,9 @@ declare class CarbonQueryClient {
|
|
|
84
94
|
alliance: AllianceClient;
|
|
85
95
|
chain: BlockchainClient;
|
|
86
96
|
ibc: IBCClientGroup;
|
|
97
|
+
ethermint: EthermintClientGroup;
|
|
98
|
+
evmmerge: EvmMergeQueryClient;
|
|
99
|
+
evmbank: EvmBankQueryClient;
|
|
87
100
|
private baseClient;
|
|
88
101
|
constructor(tmClient: Tendermint34Client);
|
|
89
102
|
getProtobufRpcClient(): import("@cosmjs/stargate").ProtobufRpcClient;
|
|
@@ -19,29 +19,34 @@ 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/
|
|
22
|
+
const query_17 = require("../codec/ethermint/evm/v1/query");
|
|
23
|
+
const query_18 = require("../codec/evmmerge/query");
|
|
24
|
+
const query_19 = require("../codec/evmbank/query");
|
|
25
|
+
const query_20 = require("../codec/ethermint/feemarket/v1/query");
|
|
26
|
+
const query_21 = require("../codec/fee/query");
|
|
27
|
+
const query_22 = require("../codec/headersync/query");
|
|
28
|
+
const query_23 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
|
|
29
|
+
const query_24 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
|
|
30
|
+
const query_25 = require("../codec/ibc/applications/transfer/v1/query");
|
|
31
|
+
const query_26 = require("../codec/ibc/core/client/v1/query");
|
|
32
|
+
const query_27 = require("../codec/ibc/core/connection/v1/query");
|
|
33
|
+
const query_28 = require("../codec/ibc/core/channel/v1/query");
|
|
34
|
+
const query_29 = require("../codec/inflation/query");
|
|
35
|
+
const query_30 = require("../codec/insurance/query");
|
|
36
|
+
const query_31 = require("../codec/leverage/query");
|
|
37
|
+
const query_32 = require("../codec/liquidation/query");
|
|
38
|
+
const query_33 = require("../codec/liquiditypool/query");
|
|
39
|
+
const query_34 = require("../codec/perpsliquidity/query");
|
|
40
|
+
const query_35 = require("../codec/market/query");
|
|
41
|
+
const query_36 = require("../codec/marketstats/query");
|
|
42
|
+
const query_37 = require("../codec/misc/query");
|
|
43
|
+
const query_38 = require("../codec/oracle/query");
|
|
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");
|
|
49
|
+
const query_44 = require("../codec/alliance/query");
|
|
45
50
|
const stargate_1 = require("@cosmjs/stargate");
|
|
46
51
|
const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
|
|
47
52
|
class CarbonQueryClient {
|
|
@@ -51,27 +56,30 @@ class CarbonQueryClient {
|
|
|
51
56
|
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
52
57
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
53
58
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
54
|
-
this.alliance = new
|
|
59
|
+
this.alliance = new query_44.QueryClientImpl(rpcClient);
|
|
55
60
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
56
61
|
this.broker = new query_3.QueryClientImpl(rpcClient);
|
|
57
62
|
this.coin = new query_5.QueryClientImpl(rpcClient);
|
|
58
63
|
this.cdp = new query_4.QueryClientImpl(rpcClient);
|
|
59
|
-
this.fee = new
|
|
60
|
-
this.inflation = new
|
|
61
|
-
this.insurance = new
|
|
62
|
-
this.leverage = new
|
|
63
|
-
this.liquidation = new
|
|
64
|
-
this.liquiditypool = new
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
64
|
+
this.fee = new query_21.QueryClientImpl(rpcClient);
|
|
65
|
+
this.inflation = new query_29.QueryClientImpl(rpcClient);
|
|
66
|
+
this.insurance = new query_30.QueryClientImpl(rpcClient);
|
|
67
|
+
this.leverage = new query_31.QueryClientImpl(rpcClient);
|
|
68
|
+
this.liquidation = new query_32.QueryClientImpl(rpcClient);
|
|
69
|
+
this.liquiditypool = new query_33.QueryClientImpl(rpcClient);
|
|
70
|
+
this.perpetualpool = new query_34.QueryClientImpl(rpcClient);
|
|
71
|
+
this.market = new query_35.QueryClientImpl(rpcClient);
|
|
72
|
+
this.marketstats = new query_36.QueryClientImpl(rpcClient);
|
|
73
|
+
this.misc = new query_37.QueryClientImpl(rpcClient);
|
|
74
|
+
this.oracle = new query_38.QueryClientImpl(rpcClient);
|
|
75
|
+
this.order = new query_39.QueryClientImpl(rpcClient);
|
|
76
|
+
this.position = new query_40.QueryClientImpl(rpcClient);
|
|
77
|
+
this.pricing = new query_41.QueryClientImpl(rpcClient);
|
|
78
|
+
this.profile = new query_42.QueryClientImpl(rpcClient);
|
|
79
|
+
this.subaccount = new query_43.QueryClientImpl(rpcClient);
|
|
80
|
+
this.headersync = new query_22.QueryClientImpl(rpcClient);
|
|
81
|
+
this.evmmerge = new query_18.QueryClientImpl(rpcClient);
|
|
82
|
+
this.evmbank = new query_19.QueryClientImpl(rpcClient);
|
|
75
83
|
this.auth = new query_6.QueryClientImpl(rpcClient);
|
|
76
84
|
this.bank = new query_7.QueryClientImpl(rpcClient);
|
|
77
85
|
this.distribution = new query_9.QueryClientImpl(rpcClient);
|
|
@@ -83,13 +91,18 @@ class CarbonQueryClient {
|
|
|
83
91
|
this.staking = new query_15.QueryClientImpl(rpcClient);
|
|
84
92
|
this.upgrade = new query_16.QueryClientImpl(rpcClient);
|
|
85
93
|
this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
|
|
94
|
+
this.alliance = new query_44.QueryClientImpl(rpcClient);
|
|
86
95
|
this.ibc = {
|
|
87
|
-
controller: new
|
|
88
|
-
host: new
|
|
89
|
-
transfer: new
|
|
90
|
-
client: new
|
|
91
|
-
connection: new
|
|
92
|
-
channel: new
|
|
96
|
+
controller: new query_23.QueryClientImpl(rpcClient),
|
|
97
|
+
host: new query_24.QueryClientImpl(rpcClient),
|
|
98
|
+
transfer: new query_25.QueryClientImpl(rpcClient),
|
|
99
|
+
client: new query_26.QueryClientImpl(rpcClient),
|
|
100
|
+
connection: new query_27.QueryClientImpl(rpcClient),
|
|
101
|
+
channel: new query_28.QueryClientImpl(rpcClient),
|
|
102
|
+
};
|
|
103
|
+
this.ethermint = {
|
|
104
|
+
evm: new query_17.QueryClientImpl(rpcClient),
|
|
105
|
+
feeMarket: new query_20.QueryClientImpl(rpcClient),
|
|
93
106
|
};
|
|
94
107
|
}
|
|
95
108
|
getProtobufRpcClient() {
|
|
@@ -5,9 +5,15 @@ 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 {
|
|
8
15
|
denom: string;
|
|
9
16
|
amount: string;
|
|
10
|
-
transactionHash: string;
|
|
11
17
|
}
|
|
12
18
|
export interface QueryInternalTransfersRequest {
|
|
13
19
|
address: string;
|
|
@@ -27,6 +33,13 @@ export declare const InternalTransfer: {
|
|
|
27
33
|
toJSON(message: InternalTransfer): unknown;
|
|
28
34
|
fromPartial(object: DeepPartial<InternalTransfer>): InternalTransfer;
|
|
29
35
|
};
|
|
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
|
+
};
|
|
30
43
|
export declare const QueryInternalTransfersRequest: {
|
|
31
44
|
encode(message: QueryInternalTransfersRequest, writer?: _m0.Writer): _m0.Writer;
|
|
32
45
|
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryInternalTransfersRequest;
|
package/lib/codec/bank/query.js
CHANGED
|
@@ -3,18 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.QueryClientImpl = exports.QueryInternalTransfersResponse = exports.QueryInternalTransfersRequest = exports.InternalTransfer = exports.protobufPackage = void 0;
|
|
6
|
+
exports.QueryClientImpl = exports.QueryInternalTransfersResponse = exports.QueryInternalTransfersRequest = exports.Coin = exports.InternalTransfer = exports.protobufPackage = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
10
|
const pagination_1 = require("../cosmos/base/query/v1beta1/pagination");
|
|
11
|
+
const timestamp_1 = require("../google/protobuf/timestamp");
|
|
11
12
|
exports.protobufPackage = "Switcheo.carbon.bank";
|
|
12
13
|
const baseInternalTransfer = {
|
|
13
14
|
sender: "",
|
|
14
15
|
receiver: "",
|
|
15
|
-
denom: "",
|
|
16
|
-
amount: "",
|
|
17
16
|
transactionHash: "",
|
|
17
|
+
transactionMemo: "",
|
|
18
|
+
transactionBlockHeight: long_1.default.UZERO,
|
|
18
19
|
};
|
|
19
20
|
exports.InternalTransfer = {
|
|
20
21
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -24,21 +25,28 @@ exports.InternalTransfer = {
|
|
|
24
25
|
if (message.receiver !== "") {
|
|
25
26
|
writer.uint32(18).string(message.receiver);
|
|
26
27
|
}
|
|
27
|
-
if (message.denom !== "") {
|
|
28
|
-
writer.uint32(26).string(message.denom);
|
|
29
|
-
}
|
|
30
|
-
if (message.amount !== "") {
|
|
31
|
-
writer.uint32(34).string(message.amount);
|
|
32
|
-
}
|
|
33
28
|
if (message.transactionHash !== "") {
|
|
34
29
|
writer.uint32(42).string(message.transactionHash);
|
|
35
30
|
}
|
|
31
|
+
for (const v of message.coins) {
|
|
32
|
+
exports.Coin.encode(v, writer.uint32(50).fork()).ldelim();
|
|
33
|
+
}
|
|
34
|
+
if (message.transactionMemo !== "") {
|
|
35
|
+
writer.uint32(58).string(message.transactionMemo);
|
|
36
|
+
}
|
|
37
|
+
if (!message.transactionBlockHeight.isZero()) {
|
|
38
|
+
writer.uint32(64).uint64(message.transactionBlockHeight);
|
|
39
|
+
}
|
|
40
|
+
if (message.transactionBlockTime !== undefined) {
|
|
41
|
+
timestamp_1.Timestamp.encode(toTimestamp(message.transactionBlockTime), writer.uint32(74).fork()).ldelim();
|
|
42
|
+
}
|
|
36
43
|
return writer;
|
|
37
44
|
},
|
|
38
45
|
decode(input, length) {
|
|
39
46
|
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
40
47
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
41
48
|
const message = Object.assign({}, baseInternalTransfer);
|
|
49
|
+
message.coins = [];
|
|
42
50
|
while (reader.pos < end) {
|
|
43
51
|
const tag = reader.uint32();
|
|
44
52
|
switch (tag >>> 3) {
|
|
@@ -48,15 +56,21 @@ exports.InternalTransfer = {
|
|
|
48
56
|
case 2:
|
|
49
57
|
message.receiver = reader.string();
|
|
50
58
|
break;
|
|
51
|
-
case 3:
|
|
52
|
-
message.denom = reader.string();
|
|
53
|
-
break;
|
|
54
|
-
case 4:
|
|
55
|
-
message.amount = reader.string();
|
|
56
|
-
break;
|
|
57
59
|
case 5:
|
|
58
60
|
message.transactionHash = reader.string();
|
|
59
61
|
break;
|
|
62
|
+
case 6:
|
|
63
|
+
message.coins.push(exports.Coin.decode(reader, reader.uint32()));
|
|
64
|
+
break;
|
|
65
|
+
case 7:
|
|
66
|
+
message.transactionMemo = reader.string();
|
|
67
|
+
break;
|
|
68
|
+
case 8:
|
|
69
|
+
message.transactionBlockHeight = reader.uint64();
|
|
70
|
+
break;
|
|
71
|
+
case 9:
|
|
72
|
+
message.transactionBlockTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
73
|
+
break;
|
|
60
74
|
default:
|
|
61
75
|
reader.skipType(tag & 7);
|
|
62
76
|
break;
|
|
@@ -65,6 +79,7 @@ exports.InternalTransfer = {
|
|
|
65
79
|
return message;
|
|
66
80
|
},
|
|
67
81
|
fromJSON(object) {
|
|
82
|
+
var _a;
|
|
68
83
|
const message = Object.assign({}, baseInternalTransfer);
|
|
69
84
|
message.sender =
|
|
70
85
|
object.sender !== undefined && object.sender !== null
|
|
@@ -74,38 +89,118 @@ exports.InternalTransfer = {
|
|
|
74
89
|
object.receiver !== undefined && object.receiver !== null
|
|
75
90
|
? String(object.receiver)
|
|
76
91
|
: "";
|
|
77
|
-
message.denom =
|
|
78
|
-
object.denom !== undefined && object.denom !== null
|
|
79
|
-
? String(object.denom)
|
|
80
|
-
: "";
|
|
81
|
-
message.amount =
|
|
82
|
-
object.amount !== undefined && object.amount !== null
|
|
83
|
-
? String(object.amount)
|
|
84
|
-
: "";
|
|
85
92
|
message.transactionHash =
|
|
86
93
|
object.transactionHash !== undefined && object.transactionHash !== null
|
|
87
94
|
? String(object.transactionHash)
|
|
88
95
|
: "";
|
|
96
|
+
message.coins = ((_a = object.coins) !== null && _a !== void 0 ? _a : []).map((e) => exports.Coin.fromJSON(e));
|
|
97
|
+
message.transactionMemo =
|
|
98
|
+
object.transactionMemo !== undefined && object.transactionMemo !== null
|
|
99
|
+
? String(object.transactionMemo)
|
|
100
|
+
: "";
|
|
101
|
+
message.transactionBlockHeight =
|
|
102
|
+
object.transactionBlockHeight !== undefined &&
|
|
103
|
+
object.transactionBlockHeight !== null
|
|
104
|
+
? long_1.default.fromString(object.transactionBlockHeight)
|
|
105
|
+
: long_1.default.UZERO;
|
|
106
|
+
message.transactionBlockTime =
|
|
107
|
+
object.transactionBlockTime !== undefined &&
|
|
108
|
+
object.transactionBlockTime !== null
|
|
109
|
+
? fromJsonTimestamp(object.transactionBlockTime)
|
|
110
|
+
: undefined;
|
|
89
111
|
return message;
|
|
90
112
|
},
|
|
91
113
|
toJSON(message) {
|
|
92
114
|
const obj = {};
|
|
93
115
|
message.sender !== undefined && (obj.sender = message.sender);
|
|
94
116
|
message.receiver !== undefined && (obj.receiver = message.receiver);
|
|
95
|
-
message.denom !== undefined && (obj.denom = message.denom);
|
|
96
|
-
message.amount !== undefined && (obj.amount = message.amount);
|
|
97
117
|
message.transactionHash !== undefined &&
|
|
98
118
|
(obj.transactionHash = message.transactionHash);
|
|
119
|
+
if (message.coins) {
|
|
120
|
+
obj.coins = message.coins.map((e) => (e ? exports.Coin.toJSON(e) : undefined));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
obj.coins = [];
|
|
124
|
+
}
|
|
125
|
+
message.transactionMemo !== undefined &&
|
|
126
|
+
(obj.transactionMemo = message.transactionMemo);
|
|
127
|
+
message.transactionBlockHeight !== undefined &&
|
|
128
|
+
(obj.transactionBlockHeight = (message.transactionBlockHeight || long_1.default.UZERO).toString());
|
|
129
|
+
message.transactionBlockTime !== undefined &&
|
|
130
|
+
(obj.transactionBlockTime = message.transactionBlockTime.toISOString());
|
|
99
131
|
return obj;
|
|
100
132
|
},
|
|
101
133
|
fromPartial(object) {
|
|
102
|
-
var _a, _b, _c, _d, _e;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
103
135
|
const message = Object.assign({}, baseInternalTransfer);
|
|
104
136
|
message.sender = (_a = object.sender) !== null && _a !== void 0 ? _a : "";
|
|
105
137
|
message.receiver = (_b = object.receiver) !== null && _b !== void 0 ? _b : "";
|
|
106
|
-
message.
|
|
107
|
-
message.
|
|
108
|
-
message.
|
|
138
|
+
message.transactionHash = (_c = object.transactionHash) !== null && _c !== void 0 ? _c : "";
|
|
139
|
+
message.coins = ((_d = object.coins) !== null && _d !== void 0 ? _d : []).map((e) => exports.Coin.fromPartial(e));
|
|
140
|
+
message.transactionMemo = (_e = object.transactionMemo) !== null && _e !== void 0 ? _e : "";
|
|
141
|
+
message.transactionBlockHeight =
|
|
142
|
+
object.transactionBlockHeight !== undefined &&
|
|
143
|
+
object.transactionBlockHeight !== null
|
|
144
|
+
? long_1.default.fromValue(object.transactionBlockHeight)
|
|
145
|
+
: long_1.default.UZERO;
|
|
146
|
+
message.transactionBlockTime = (_f = object.transactionBlockTime) !== null && _f !== void 0 ? _f : undefined;
|
|
147
|
+
return message;
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const baseCoin = { denom: "", amount: "" };
|
|
151
|
+
exports.Coin = {
|
|
152
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
153
|
+
if (message.denom !== "") {
|
|
154
|
+
writer.uint32(10).string(message.denom);
|
|
155
|
+
}
|
|
156
|
+
if (message.amount !== "") {
|
|
157
|
+
writer.uint32(18).string(message.amount);
|
|
158
|
+
}
|
|
159
|
+
return writer;
|
|
160
|
+
},
|
|
161
|
+
decode(input, length) {
|
|
162
|
+
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
163
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
164
|
+
const message = Object.assign({}, baseCoin);
|
|
165
|
+
while (reader.pos < end) {
|
|
166
|
+
const tag = reader.uint32();
|
|
167
|
+
switch (tag >>> 3) {
|
|
168
|
+
case 1:
|
|
169
|
+
message.denom = reader.string();
|
|
170
|
+
break;
|
|
171
|
+
case 2:
|
|
172
|
+
message.amount = reader.string();
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
reader.skipType(tag & 7);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return message;
|
|
180
|
+
},
|
|
181
|
+
fromJSON(object) {
|
|
182
|
+
const message = Object.assign({}, baseCoin);
|
|
183
|
+
message.denom =
|
|
184
|
+
object.denom !== undefined && object.denom !== null
|
|
185
|
+
? String(object.denom)
|
|
186
|
+
: "";
|
|
187
|
+
message.amount =
|
|
188
|
+
object.amount !== undefined && object.amount !== null
|
|
189
|
+
? String(object.amount)
|
|
190
|
+
: "";
|
|
191
|
+
return message;
|
|
192
|
+
},
|
|
193
|
+
toJSON(message) {
|
|
194
|
+
const obj = {};
|
|
195
|
+
message.denom !== undefined && (obj.denom = message.denom);
|
|
196
|
+
message.amount !== undefined && (obj.amount = message.amount);
|
|
197
|
+
return obj;
|
|
198
|
+
},
|
|
199
|
+
fromPartial(object) {
|
|
200
|
+
var _a, _b;
|
|
201
|
+
const message = Object.assign({}, baseCoin);
|
|
202
|
+
message.denom = (_a = object.denom) !== null && _a !== void 0 ? _a : "";
|
|
203
|
+
message.amount = (_b = object.amount) !== null && _b !== void 0 ? _b : "";
|
|
109
204
|
return message;
|
|
110
205
|
},
|
|
111
206
|
};
|
|
@@ -292,6 +387,30 @@ class QueryClientImpl {
|
|
|
292
387
|
}
|
|
293
388
|
}
|
|
294
389
|
exports.QueryClientImpl = QueryClientImpl;
|
|
390
|
+
function toTimestamp(date) {
|
|
391
|
+
const seconds = numberToLong(date.getTime() / 1000);
|
|
392
|
+
const nanos = (date.getTime() % 1000) * 1000000;
|
|
393
|
+
return { seconds, nanos };
|
|
394
|
+
}
|
|
395
|
+
function fromTimestamp(t) {
|
|
396
|
+
let millis = t.seconds.toNumber() * 1000;
|
|
397
|
+
millis += t.nanos / 1000000;
|
|
398
|
+
return new Date(millis);
|
|
399
|
+
}
|
|
400
|
+
function fromJsonTimestamp(o) {
|
|
401
|
+
if (o instanceof Date) {
|
|
402
|
+
return o;
|
|
403
|
+
}
|
|
404
|
+
else if (typeof o === "string") {
|
|
405
|
+
return new Date(o);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function numberToLong(number) {
|
|
412
|
+
return long_1.default.fromNumber(number);
|
|
413
|
+
}
|
|
295
414
|
if (minimal_1.default.util.Long !== long_1.default) {
|
|
296
415
|
minimal_1.default.util.Long = long_1.default;
|
|
297
416
|
minimal_1.default.configure();
|