carbon-js-sdk 0.3.17-beta.1 → 0.3.18
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 -5
- package/lib/CarbonSDK.js +4 -24
- package/lib/constant/ibc.d.ts +4 -1
- package/lib/constant/ibc.js +203 -43
- package/lib/constant/network.d.ts +0 -6
- package/lib/constant/network.js +1 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -2
- package/lib/provider/index.d.ts +0 -1
- package/lib/provider/index.js +1 -3
- package/lib/provider/keplr/KeplrStore.d.ts +3 -9
- package/lib/provider/keplr/KeplrStore.js +18 -69
- package/lib/util/blockchain.d.ts +7 -1
- package/lib/util/blockchain.js +25 -1
- package/lib/util/ibc.js +6 -0
- package/lib/wallet/CarbonWallet.d.ts +0 -3
- package/lib/wallet/CarbonWallet.js +0 -6
- package/package.json +4 -8
- package/lib/clients/CarbonTendermintClient.d.ts +0 -117
- package/lib/clients/CarbonTendermintClient.js +0 -376
- package/lib/codec/cdp/vault.d.ts +0 -44
- package/lib/codec/cdp/vault.js +0 -235
- package/lib/codec/cosmos/base/store/v1beta1/snapshot.d.ts +0 -45
- package/lib/codec/cosmos/base/store/v1beta1/snapshot.js +0 -246
- package/lib/wallet/CarbonTendermintClient.js +0 -376
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as clients from "./clients";
|
|
|
6
6
|
import N3Client from "./clients/N3Client";
|
|
7
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
|
-
import { CosmosLedger, Keplr
|
|
9
|
+
import { CosmosLedger, Keplr } from "./provider";
|
|
10
10
|
import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts } from "./wallet";
|
|
11
11
|
export { CarbonTx } from "./util";
|
|
12
12
|
export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
|
|
@@ -14,7 +14,6 @@ export { DenomPrefix } from "./constant";
|
|
|
14
14
|
export interface CarbonSDKOpts {
|
|
15
15
|
network: Network;
|
|
16
16
|
tmClient: Tendermint34Client;
|
|
17
|
-
chainId?: string;
|
|
18
17
|
token?: TokenClient;
|
|
19
18
|
config?: Partial<NetworkConfig>;
|
|
20
19
|
defaultTimeoutBlocks?: number;
|
|
@@ -70,7 +69,6 @@ declare class CarbonSDK {
|
|
|
70
69
|
bsc: ETHClient;
|
|
71
70
|
zil: ZILClient;
|
|
72
71
|
n3: N3Client;
|
|
73
|
-
chainId: string;
|
|
74
72
|
constructor(opts: CarbonSDKOpts);
|
|
75
73
|
static instance(opts?: CarbonSDKInitOpts): Promise<CarbonSDK>;
|
|
76
74
|
static instanceWithWallet(wallet: CarbonWallet, sdkOpts?: CarbonSDKInitOpts): Promise<ConnectedCarbonSDK>;
|
|
@@ -79,7 +77,6 @@ declare class CarbonSDK {
|
|
|
79
77
|
static instanceWithSigner(signer: CarbonSigner, publicKeyBase64: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
80
78
|
static instanceWithLedger(ledger: CosmosLedger, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
81
79
|
static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
82
|
-
static instanceWithLeap(leap: Leap, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
83
80
|
static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
84
81
|
initialize(): Promise<CarbonSDK>;
|
|
85
82
|
clone(): CarbonSDK;
|
|
@@ -91,7 +88,6 @@ declare class CarbonSDK {
|
|
|
91
88
|
connectWithSigner(signer: CarbonSigner, publicKeyBase64: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
92
89
|
connectWithLedger(ledger: CosmosLedger, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
93
90
|
connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
94
|
-
connectWithLeap(leap: Leap, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
95
91
|
connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
|
|
96
92
|
getConfig(): NetworkConfig;
|
|
97
93
|
getTokenClient(): TokenClient;
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -60,16 +60,15 @@ const DEFAULT_SDK_INIT_OPTS = {
|
|
|
60
60
|
*/
|
|
61
61
|
class CarbonSDK {
|
|
62
62
|
constructor(opts) {
|
|
63
|
-
var _a, _b, _c
|
|
63
|
+
var _a, _b, _c;
|
|
64
64
|
this.network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
|
|
65
65
|
this.configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
|
|
66
66
|
this.networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[this.network], this.configOverride);
|
|
67
67
|
this.tmClient = opts.tmClient;
|
|
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];
|
|
69
68
|
this.query = new clients_1.CarbonQueryClient(opts.tmClient);
|
|
70
69
|
this.insights = new clients_1.InsightsQueryClient(this.networkConfig);
|
|
71
70
|
this.hydrogen = new clients_1.HydrogenClient(this.networkConfig);
|
|
72
|
-
this.token = (
|
|
71
|
+
this.token = (_c = opts.token) !== null && _c !== void 0 ? _c : clients_1.TokenClient.instance(this.query, this);
|
|
73
72
|
this.admin = new modules_1.AdminModule(this);
|
|
74
73
|
this.order = new modules_1.OrderModule(this);
|
|
75
74
|
this.lp = new modules_1.LiquidityPoolModule(this);
|
|
@@ -112,15 +111,14 @@ class CarbonSDK {
|
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
113
|
static instance(opts = DEFAULT_SDK_INIT_OPTS) {
|
|
115
|
-
var _a, _b, _c
|
|
114
|
+
var _a, _b, _c;
|
|
116
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
116
|
const network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
|
|
118
117
|
const configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
|
|
119
118
|
const networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[network], configOverride);
|
|
120
119
|
const tmClient = (_c = opts.tmClient) !== null && _c !== void 0 ? _c : util_1.GenericUtils.modifyTmClient(yield tendermint_rpc_1.Tendermint34Client.connect(networkConfig.tmRpcUrl));
|
|
121
120
|
const defaultTimeoutBlocks = opts.defaultTimeoutBlocks;
|
|
122
|
-
const
|
|
123
|
-
const sdk = new CarbonSDK({ network, config: configOverride, tmClient, defaultTimeoutBlocks, chainId });
|
|
121
|
+
const sdk = new CarbonSDK({ network, config: configOverride, tmClient, defaultTimeoutBlocks });
|
|
124
122
|
if (opts.wallet) {
|
|
125
123
|
yield sdk.connect(opts.wallet);
|
|
126
124
|
}
|
|
@@ -166,12 +164,6 @@ class CarbonSDK {
|
|
|
166
164
|
return sdk.connectWithKeplr(keplr, walletOpts);
|
|
167
165
|
});
|
|
168
166
|
}
|
|
169
|
-
static instanceWithLeap(leap, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
const sdk = yield CarbonSDK.instance(sdkOpts);
|
|
172
|
-
return sdk.connectWithLeap(leap, walletOpts);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
167
|
static instanceViewOnly(bech32Address, sdkOpts = DEFAULT_SDK_INIT_OPTS, walletOpts) {
|
|
176
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
169
|
const sdk = yield CarbonSDK.instance(sdkOpts);
|
|
@@ -180,8 +172,6 @@ class CarbonSDK {
|
|
|
180
172
|
}
|
|
181
173
|
initialize() {
|
|
182
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
const chainId = yield this.query.chain.getChainId();
|
|
184
|
-
this.chainId = chainId;
|
|
185
175
|
yield this.token.initialize();
|
|
186
176
|
if (this.wallet) {
|
|
187
177
|
yield this.wallet.initialize(this.query);
|
|
@@ -197,7 +187,6 @@ class CarbonSDK {
|
|
|
197
187
|
network: this.network,
|
|
198
188
|
config: this.configOverride,
|
|
199
189
|
tmClient: this.tmClient,
|
|
200
|
-
chainId: this.chainId,
|
|
201
190
|
};
|
|
202
191
|
}
|
|
203
192
|
connect(wallet) {
|
|
@@ -260,15 +249,6 @@ class CarbonSDK {
|
|
|
260
249
|
return this.connect(wallet);
|
|
261
250
|
});
|
|
262
251
|
}
|
|
263
|
-
connectWithLeap(leap, opts) {
|
|
264
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
const chainId = this.chainId;
|
|
266
|
-
const leapKey = yield leap.getKey(chainId);
|
|
267
|
-
yield leap.enable(chainId);
|
|
268
|
-
const wallet = wallet_1.CarbonWallet.withLeap(leap, chainId, leapKey, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
|
269
|
-
return this.connect(wallet);
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
252
|
connectViewOnly(bech32Address, opts) {
|
|
273
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
274
254
|
const wallet = wallet_1.CarbonWallet.withAddress(bech32Address, Object.assign(Object.assign({}, opts), { network: this.network, config: this.configOverride }));
|
package/lib/constant/ibc.d.ts
CHANGED
|
@@ -51,7 +51,10 @@ export declare enum ChainIds {
|
|
|
51
51
|
Carbon = "carbon-1",
|
|
52
52
|
Axelar = "axelar-dojo-1",
|
|
53
53
|
Stride = "stride-1",
|
|
54
|
-
Kujira = "kaiyo-1"
|
|
54
|
+
Kujira = "kaiyo-1",
|
|
55
|
+
Terra2 = "phoenix-1",
|
|
56
|
+
Quicksilver = "quicksilver-1",
|
|
57
|
+
StafiHub = "stafihub-1"
|
|
55
58
|
}
|
|
56
59
|
export declare const swthIbcWhitelist: string[];
|
|
57
60
|
export declare const ibcWhitelist: string[];
|