carbon-js-sdk 0.2.16-dev.4 → 0.2.17
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 -13
- package/lib/CarbonSDK.js +2 -31
- package/lib/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.d.ts +1 -1
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/N3Client.js +2 -3
- package/lib/clients/NEOClient.d.ts +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.d.ts +0 -5
- package/lib/clients/TokenClient.js +10 -38
- package/lib/clients/ZILClient.d.ts +1 -1
- package/lib/clients/ZILClient.js +16 -16
- package/lib/codec/book/genesis.d.ts +1 -1
- package/lib/codec/book/genesis.js +1 -1
- package/lib/codec/book/query.d.ts +1 -1
- package/lib/codec/book/query.js +1 -1
- package/lib/codec/broker/genesis.d.ts +1 -1
- package/lib/codec/broker/genesis.js +1 -1
- package/lib/codec/broker/query.d.ts +3 -3
- package/lib/codec/broker/query.js +3 -3
- package/lib/codec/btcx/denom_cross_chain_info.d.ts +1 -1
- package/lib/codec/btcx/denom_cross_chain_info.js +1 -1
- package/lib/codec/btcx/query.d.ts +1 -1
- package/lib/codec/btcx/query.js +1 -1
- package/lib/codec/ccm/genesis.d.ts +1 -1
- package/lib/codec/ccm/genesis.js +1 -1
- package/lib/codec/cdp/event.d.ts +22 -389
- package/lib/codec/cdp/event.js +83 -2494
- package/lib/codec/cdp/genesis.d.ts +4 -97
- package/lib/codec/cdp/genesis.js +23 -648
- package/lib/codec/cdp/query.d.ts +89 -439
- package/lib/codec/cdp/query.js +173 -1991
- package/lib/codec/cdp/tx.d.ts +96 -760
- package/lib/codec/cdp/tx.js +235 -3645
- package/lib/codec/coin/event.d.ts +1 -1
- package/lib/codec/coin/event.js +1 -1
- package/lib/codec/coin/genesis.d.ts +2 -2
- package/lib/codec/coin/genesis.js +2 -2
- package/lib/codec/coin/proposal.d.ts +1 -1
- package/lib/codec/coin/proposal.js +1 -1
- package/lib/codec/coin/query.d.ts +2 -2
- package/lib/codec/coin/query.js +2 -2
- package/lib/codec/coin/tx.d.ts +1 -1
- package/lib/codec/coin/tx.js +1 -1
- package/lib/codec/cosmos/auth/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/auth/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/auth/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/auth/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/authz/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/authz/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/authz/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/authz/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/authz/v1beta1/tx.d.ts +1 -1
- package/lib/codec/cosmos/authz/v1beta1/tx.js +1 -1
- package/lib/codec/cosmos/bank/v1beta1/authz.d.ts +1 -1
- package/lib/codec/cosmos/bank/v1beta1/authz.js +1 -1
- package/lib/codec/cosmos/bank/v1beta1/bank.d.ts +1 -1
- package/lib/codec/cosmos/bank/v1beta1/bank.js +1 -1
- package/lib/codec/cosmos/bank/v1beta1/genesis.d.ts +2 -2
- package/lib/codec/cosmos/bank/v1beta1/genesis.js +2 -2
- package/lib/codec/cosmos/bank/v1beta1/query.d.ts +3 -3
- package/lib/codec/cosmos/bank/v1beta1/query.js +3 -3
- package/lib/codec/cosmos/bank/v1beta1/tx.d.ts +2 -2
- package/lib/codec/cosmos/bank/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/base/tendermint/v1beta1/query.d.ts +1 -1
- package/lib/codec/cosmos/base/tendermint/v1beta1/query.js +1 -1
- package/lib/codec/cosmos/capability/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/capability/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/crisis/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/crisis/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/distribution/v1beta1/distribution.d.ts +1 -1
- package/lib/codec/cosmos/distribution/v1beta1/distribution.js +1 -1
- package/lib/codec/cosmos/distribution/v1beta1/genesis.d.ts +2 -2
- package/lib/codec/cosmos/distribution/v1beta1/genesis.js +2 -2
- package/lib/codec/cosmos/distribution/v1beta1/query.d.ts +3 -3
- package/lib/codec/cosmos/distribution/v1beta1/query.js +3 -3
- package/lib/codec/cosmos/distribution/v1beta1/tx.d.ts +1 -1
- package/lib/codec/cosmos/distribution/v1beta1/tx.js +1 -1
- package/lib/codec/cosmos/evidence/v1beta1/query.d.ts +1 -1
- package/lib/codec/cosmos/evidence/v1beta1/query.js +1 -1
- package/lib/codec/cosmos/feegrant/v1beta1/feegrant.d.ts +1 -1
- package/lib/codec/cosmos/feegrant/v1beta1/feegrant.js +1 -1
- package/lib/codec/cosmos/feegrant/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/feegrant/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/feegrant/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/feegrant/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/gov/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/gov/v1beta1/gov.d.ts +1 -1
- package/lib/codec/cosmos/gov/v1beta1/gov.js +1 -1
- package/lib/codec/cosmos/gov/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/gov/v1beta1/query.js +4 -4
- package/lib/codec/cosmos/gov/v1beta1/tx.d.ts +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +4 -4
- package/lib/codec/cosmos/mint/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/mint/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/mint/v1beta1/query.d.ts +1 -1
- package/lib/codec/cosmos/mint/v1beta1/query.js +1 -1
- package/lib/codec/cosmos/params/v1beta1/query.d.ts +1 -1
- package/lib/codec/cosmos/params/v1beta1/query.js +1 -1
- package/lib/codec/cosmos/slashing/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/slashing/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/slashing/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/slashing/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/staking/v1beta1/authz.d.ts +1 -1
- package/lib/codec/cosmos/staking/v1beta1/authz.js +1 -1
- package/lib/codec/cosmos/staking/v1beta1/genesis.d.ts +1 -1
- package/lib/codec/cosmos/staking/v1beta1/genesis.js +1 -1
- package/lib/codec/cosmos/staking/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/staking/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/staking/v1beta1/staking.d.ts +1 -1
- package/lib/codec/cosmos/staking/v1beta1/staking.js +1 -1
- package/lib/codec/cosmos/staking/v1beta1/tx.d.ts +2 -2
- package/lib/codec/cosmos/staking/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/tx/signing/v1beta1/signing.d.ts +1 -1
- package/lib/codec/cosmos/tx/signing/v1beta1/signing.js +1 -1
- package/lib/codec/cosmos/tx/v1beta1/service.d.ts +3 -3
- package/lib/codec/cosmos/tx/v1beta1/service.js +3 -3
- package/lib/codec/cosmos/tx/v1beta1/tx.d.ts +3 -3
- package/lib/codec/cosmos/tx/v1beta1/tx.js +5 -5
- package/lib/codec/cosmos/upgrade/v1beta1/query.d.ts +1 -1
- package/lib/codec/cosmos/upgrade/v1beta1/query.js +1 -1
- package/lib/codec/cosmos/vesting/v1beta1/tx.d.ts +1 -1
- package/lib/codec/cosmos/vesting/v1beta1/tx.js +1 -1
- package/lib/codec/cosmos/vesting/v1beta1/vesting.d.ts +2 -2
- package/lib/codec/cosmos/vesting/v1beta1/vesting.js +2 -2
- package/lib/codec/fee/genesis.d.ts +1 -1
- package/lib/codec/fee/genesis.js +1 -1
- package/lib/codec/fee/proposal.d.ts +1 -1
- package/lib/codec/fee/proposal.js +1 -1
- package/lib/codec/fee/query.d.ts +1 -1
- package/lib/codec/fee/query.js +1 -1
- package/lib/codec/fee/tx.d.ts +1 -1
- package/lib/codec/fee/tx.js +1 -1
- package/lib/codec/headersync/genesis.d.ts +1 -1
- package/lib/codec/headersync/genesis.js +1 -1
- package/lib/codec/headersync/query.d.ts +1 -1
- package/lib/codec/headersync/query.js +1 -1
- package/lib/codec/index.d.ts +18 -89
- package/lib/codec/index.js +180 -463
- package/lib/codec/inflation/genesis.d.ts +1 -1
- package/lib/codec/inflation/genesis.js +1 -1
- package/lib/codec/inflation/query.d.ts +1 -1
- package/lib/codec/inflation/query.js +1 -1
- package/lib/codec/insurance/genesis.d.ts +1 -1
- package/lib/codec/insurance/genesis.js +1 -1
- package/lib/codec/leverage/genesis.d.ts +1 -1
- package/lib/codec/leverage/genesis.js +1 -1
- package/lib/codec/leverage/query.d.ts +1 -1
- package/lib/codec/leverage/query.js +1 -1
- package/lib/codec/liquidation/genesis.d.ts +1 -1
- package/lib/codec/liquidation/genesis.js +1 -1
- package/lib/codec/liquidation/query.d.ts +1 -1
- package/lib/codec/liquidation/query.js +1 -1
- package/lib/codec/liquidation/quote_changes.d.ts +1 -1
- package/lib/codec/liquidation/quote_changes.js +1 -1
- package/lib/codec/liquiditypool/event.d.ts +2 -2
- package/lib/codec/liquiditypool/event.js +2 -2
- package/lib/codec/liquiditypool/genesis.d.ts +2 -2
- package/lib/codec/liquiditypool/genesis.js +2 -2
- package/lib/codec/liquiditypool/liquiditypool.d.ts +0 -3
- package/lib/codec/liquiditypool/liquiditypool.js +1 -44
- package/lib/codec/liquiditypool/proposal.d.ts +1 -1
- package/lib/codec/liquiditypool/proposal.js +1 -1
- package/lib/codec/liquiditypool/query.d.ts +2 -39
- package/lib/codec/liquiditypool/query.js +3 -195
- package/lib/codec/liquiditypool/tx.d.ts +1 -3
- package/lib/codec/liquiditypool/tx.js +1 -35
- package/lib/codec/lockproxy/genesis.d.ts +1 -1
- package/lib/codec/lockproxy/genesis.js +1 -1
- package/lib/codec/lockproxy/query.d.ts +1 -1
- package/lib/codec/lockproxy/query.js +1 -1
- package/lib/codec/market/event.d.ts +1 -1
- package/lib/codec/market/event.js +1 -1
- package/lib/codec/market/genesis.d.ts +1 -1
- package/lib/codec/market/genesis.js +1 -1
- package/lib/codec/market/proposal.d.ts +1 -1
- package/lib/codec/market/proposal.js +1 -1
- package/lib/codec/market/query.d.ts +1 -1
- package/lib/codec/market/query.js +1 -1
- package/lib/codec/market/tx.d.ts +1 -1
- package/lib/codec/market/tx.js +1 -1
- package/lib/codec/marketstats/genesis.d.ts +1 -1
- package/lib/codec/marketstats/genesis.js +1 -1
- package/lib/codec/marketstats/query.d.ts +2 -2
- package/lib/codec/marketstats/query.js +2 -2
- package/lib/codec/misc/message.d.ts +1 -1
- package/lib/codec/misc/message.js +1 -1
- package/lib/codec/misc/query.d.ts +3 -3
- package/lib/codec/misc/query.js +3 -3
- package/lib/codec/misc/transaction.d.ts +1 -1
- package/lib/codec/misc/transaction.js +1 -1
- package/lib/codec/oracle/event.d.ts +1 -1
- package/lib/codec/oracle/event.js +1 -1
- package/lib/codec/oracle/genesis.d.ts +1 -4
- package/lib/codec/oracle/genesis.js +3 -34
- package/lib/codec/oracle/proposal.d.ts +1 -1
- package/lib/codec/oracle/proposal.js +1 -1
- package/lib/codec/oracle/query.d.ts +2 -2
- package/lib/codec/oracle/query.js +2 -2
- package/lib/codec/order/event.d.ts +1 -1
- package/lib/codec/order/event.js +1 -1
- package/lib/codec/order/genesis.d.ts +1 -1
- package/lib/codec/order/genesis.js +1 -1
- package/lib/codec/order/query.d.ts +1 -1
- package/lib/codec/order/query.js +1 -1
- package/lib/codec/position/event.d.ts +1 -1
- package/lib/codec/position/event.js +1 -1
- package/lib/codec/position/genesis.d.ts +1 -1
- package/lib/codec/position/genesis.js +1 -1
- package/lib/codec/position/query.d.ts +1 -1
- package/lib/codec/position/query.js +1 -1
- package/lib/codec/pricing/event.d.ts +1 -56
- package/lib/codec/pricing/event.js +2 -298
- package/lib/codec/pricing/genesis.d.ts +1 -2
- package/lib/codec/pricing/genesis.js +5 -20
- package/lib/codec/pricing/pricing.d.ts +0 -14
- package/lib/codec/pricing/pricing.js +1 -103
- package/lib/codec/pricing/query.d.ts +1 -68
- package/lib/codec/pricing/query.js +2 -321
- package/lib/codec/pricing/tx.d.ts +0 -96
- package/lib/codec/pricing/tx.js +1 -399
- package/lib/codec/profile/event.d.ts +1 -1
- package/lib/codec/profile/event.js +1 -1
- package/lib/codec/profile/genesis.d.ts +1 -1
- package/lib/codec/profile/genesis.js +1 -1
- package/lib/codec/profile/query.d.ts +1 -1
- package/lib/codec/profile/query.js +1 -1
- package/lib/codec/subaccount/genesis.d.ts +1 -1
- package/lib/codec/subaccount/genesis.js +1 -1
- package/lib/codec/subaccount/query.d.ts +1 -1
- package/lib/codec/subaccount/query.js +1 -1
- package/lib/codec/tendermint/abci/types.d.ts +4 -4
- package/lib/codec/tendermint/abci/types.js +4 -4
- package/lib/codec/tendermint/types/block.d.ts +2 -2
- package/lib/codec/tendermint/types/block.js +2 -2
- package/lib/codec/tendermint/types/evidence.d.ts +2 -2
- package/lib/codec/tendermint/types/evidence.js +2 -2
- package/lib/codec/tendermint/types/types.d.ts +3 -3
- package/lib/codec/tendermint/types/types.js +3 -3
- package/lib/codec/tendermint/types/validator.d.ts +1 -1
- package/lib/codec/tendermint/types/validator.js +1 -1
- package/lib/constant/generic.js +1 -1
- package/lib/constant/token.d.ts +0 -4
- package/lib/constant/token.js +1 -5
- package/lib/modules/admin.d.ts +7 -114
- package/lib/modules/admin.js +53 -275
- package/lib/modules/cdp.d.ts +13 -152
- package/lib/modules/cdp.js +20 -800
- package/lib/modules/gov.js +14 -14
- package/lib/modules/liquiditypool.d.ts +0 -3
- package/lib/modules/liquiditypool.js +1 -3
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
- package/lib/provider/amino/types/admin.js +26 -91
- 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 +24 -135
- package/lib/provider/amino/types/coin.js +2 -2
- package/lib/provider/amino/types/gov.js +4 -4
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -9
- package/lib/provider/amino/types/market.js +1 -1
- package/lib/provider/amino/types/oracle.js +1 -1
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/position.js +1 -1
- package/lib/provider/amino/types/profile.js +1 -1
- package/lib/provider/amino/types/staking.js +4 -4
- package/lib/provider/amino/types/subaccount.js +3 -3
- package/lib/provider/amino/utils.js +11 -11
- package/lib/provider/keplr/KeplrStore.js +1 -1
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +1 -1
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.d.ts +0 -1
- package/lib/util/address.js +13 -21
- package/lib/util/api.js +4 -4
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/number.d.ts +0 -1
- package/lib/util/number.js +6 -7
- package/lib/util/tx.d.ts +10 -74
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +8 -8
- package/lib/wallet/CarbonWallet.js +7 -6
- package/lib/websocket/channel.js +21 -115
- package/lib/websocket/connector.js +3 -3
- package/lib/websocket/models.d.ts +0 -156
- package/lib/websocket/types.d.ts +3 -87
- package/lib/websocket/types.js +0 -31
- package/package.json +1 -1
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { Network, Network as _Network, NetworkConfig } from "./constant";
|
|
3
3
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
4
4
|
import { CarbonQueryClient, ETHClient, HydrogenClient, InsightsQueryClient, NEOClient, TokenClient, ZILClient } from "./clients";
|
|
5
|
-
import * as clients from "./clients";
|
|
6
5
|
import N3Client from "./clients/N3Client";
|
|
7
6
|
import { AdminModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
|
|
8
7
|
import { StakingModule } from "./modules/staking";
|
|
@@ -10,7 +9,6 @@ import { CosmosLedger, Keplr } from "./provider";
|
|
|
10
9
|
import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts } from "./wallet";
|
|
11
10
|
export { CarbonTx } from "./util";
|
|
12
11
|
export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
|
|
13
|
-
export { DenomPrefix } from "./constant";
|
|
14
12
|
export interface CarbonSDKOpts {
|
|
15
13
|
network: Network;
|
|
16
14
|
tmClient: Tendermint34Client;
|
|
@@ -33,10 +31,7 @@ export interface CarbonSDKInitOpts {
|
|
|
33
31
|
*/
|
|
34
32
|
declare class CarbonSDK {
|
|
35
33
|
static DEFAULT_NETWORK: Network;
|
|
36
|
-
static
|
|
37
|
-
LPToken: string;
|
|
38
|
-
CDPToken: string;
|
|
39
|
-
};
|
|
34
|
+
static TokenClient: typeof TokenClient;
|
|
40
35
|
readonly query: CarbonQueryClient;
|
|
41
36
|
insights: InsightsQueryClient;
|
|
42
37
|
hydrogen: HydrogenClient;
|
|
@@ -103,12 +98,5 @@ export declare class ConnectedCarbonSDK extends CarbonSDK {
|
|
|
103
98
|
}
|
|
104
99
|
declare namespace CarbonSDK {
|
|
105
100
|
export import Network = _Network;
|
|
106
|
-
export import CarbonQueryClient = clients.CarbonQueryClient;
|
|
107
|
-
export import ETHClient = clients.ETHClient;
|
|
108
|
-
export import HydrogenClient = clients.HydrogenClient;
|
|
109
|
-
export import InsightsQueryClient = clients.InsightsQueryClient;
|
|
110
|
-
export import NEOClient = clients.NEOClient;
|
|
111
|
-
export import TokenClient = clients.TokenClient;
|
|
112
|
-
export import ZILClient = clients.ZILClient;
|
|
113
101
|
}
|
|
114
102
|
export default CarbonSDK;
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,12 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.ConnectedCarbonSDK = exports.
|
|
15
|
+
exports.ConnectedCarbonSDK = exports.CarbonWallet = exports.CarbonSignerTypes = exports.CarbonTx = void 0;
|
|
35
16
|
const constant_1 = require("./constant");
|
|
36
17
|
const util_1 = require("./util");
|
|
37
18
|
const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
38
19
|
const clients_1 = require("./clients");
|
|
39
|
-
const clients = __importStar(require("./clients"));
|
|
40
20
|
const N3Client_1 = __importDefault(require("./clients/N3Client"));
|
|
41
21
|
const modules_1 = require("./modules");
|
|
42
22
|
const staking_1 = require("./modules/staking");
|
|
@@ -48,8 +28,6 @@ Object.defineProperty(exports, "CarbonTx", { enumerable: true, get: function ()
|
|
|
48
28
|
var wallet_2 = require("./wallet");
|
|
49
29
|
Object.defineProperty(exports, "CarbonSignerTypes", { enumerable: true, get: function () { return wallet_2.CarbonSignerTypes; } });
|
|
50
30
|
Object.defineProperty(exports, "CarbonWallet", { enumerable: true, get: function () { return wallet_2.CarbonWallet; } });
|
|
51
|
-
var constant_2 = require("./constant");
|
|
52
|
-
Object.defineProperty(exports, "DenomPrefix", { enumerable: true, get: function () { return constant_2.DenomPrefix; } });
|
|
53
31
|
const DEFAULT_SDK_INIT_OPTS = {
|
|
54
32
|
network: constant_1.DEFAULT_NETWORK,
|
|
55
33
|
};
|
|
@@ -275,7 +253,7 @@ class CarbonSDK {
|
|
|
275
253
|
}
|
|
276
254
|
}
|
|
277
255
|
CarbonSDK.DEFAULT_NETWORK = constant_1.DEFAULT_NETWORK;
|
|
278
|
-
CarbonSDK.
|
|
256
|
+
CarbonSDK.TokenClient = clients_1.TokenClient;
|
|
279
257
|
CarbonSDK.parseNetwork = util_1.NetworkUtils.parseNetwork;
|
|
280
258
|
class ConnectedCarbonSDK extends CarbonSDK {
|
|
281
259
|
constructor(wallet, opts) {
|
|
@@ -289,12 +267,5 @@ class ConnectedCarbonSDK extends CarbonSDK {
|
|
|
289
267
|
exports.ConnectedCarbonSDK = ConnectedCarbonSDK;
|
|
290
268
|
(function (CarbonSDK) {
|
|
291
269
|
CarbonSDK.Network = constant_1.Network;
|
|
292
|
-
CarbonSDK.CarbonQueryClient = clients.CarbonQueryClient;
|
|
293
|
-
CarbonSDK.ETHClient = clients.ETHClient;
|
|
294
|
-
CarbonSDK.HydrogenClient = clients.HydrogenClient;
|
|
295
|
-
CarbonSDK.InsightsQueryClient = clients.InsightsQueryClient;
|
|
296
|
-
CarbonSDK.NEOClient = clients.NEOClient;
|
|
297
|
-
CarbonSDK.TokenClient = clients.TokenClient;
|
|
298
|
-
CarbonSDK.ZILClient = clients.ZILClient;
|
|
299
270
|
})(CarbonSDK || (CarbonSDK = {}));
|
|
300
271
|
exports.default = CarbonSDK;
|
|
@@ -44,7 +44,7 @@ class CarbonQueryClient {
|
|
|
44
44
|
constructor(tmClient) {
|
|
45
45
|
this.tmClient = tmClient;
|
|
46
46
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
47
|
-
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
47
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
48
48
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
49
49
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
50
50
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
@@ -85,7 +85,7 @@ class CarbonQueryClient {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
getProtobufRpcClient() {
|
|
88
|
-
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
88
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
exports.default = CarbonQueryClient;
|
|
@@ -55,7 +55,7 @@ export declare class ETHClient {
|
|
|
55
55
|
eth: string;
|
|
56
56
|
};
|
|
57
57
|
private constructor();
|
|
58
|
-
static instance(opts: ETHClientOpts):
|
|
58
|
+
static instance(opts: ETHClientOpts): ETHClient;
|
|
59
59
|
getExternalBalances(api: CarbonSDK, address: string, whitelistDenoms?: string[]): Promise<TokensWithExternalBalance[]>;
|
|
60
60
|
approveERC20(params: ApproveERC20Params): Promise<EthersTransactionResponse>;
|
|
61
61
|
checkAllowanceERC20(token: Models.Token, owner: string, spender: string): Promise<BigNumber>;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -40,13 +40,13 @@ class ETHClient {
|
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
const tokenQueryResults = yield api.token.getAllTokens();
|
|
42
42
|
const lockProxyAddress = this.getLockProxyAddress().toLowerCase();
|
|
43
|
-
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
|
|
43
|
+
const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
|
|
44
44
|
token.tokenAddress.length == 40 &&
|
|
45
|
-
token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
|
|
45
|
+
token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
|
|
46
46
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
47
|
-
this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress)));
|
|
47
|
+
this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress)));
|
|
48
48
|
const assetIds = tokens.map((token) => {
|
|
49
|
-
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
49
|
+
return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
|
|
50
50
|
});
|
|
51
51
|
const provider = this.getProvider();
|
|
52
52
|
const contractAddress = this.getBalanceReaderAddress();
|
|
@@ -95,14 +95,14 @@ class ETHClient {
|
|
|
95
95
|
throw new Error("Invalid recovery address");
|
|
96
96
|
}
|
|
97
97
|
const fromTokenId = fromToken.id;
|
|
98
|
-
const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
98
|
+
const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
99
99
|
const toTokenDenom = toToken.denom;
|
|
100
100
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
|
|
101
101
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
102
102
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
103
103
|
const nonce = yield rpcProvider.getTransactionCount(fromAddress);
|
|
104
104
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
105
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
105
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
106
106
|
const tokenCreator = fromToken.creator;
|
|
107
107
|
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, CarbonSDK_1.default.Network.MainNet);
|
|
108
108
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
@@ -137,9 +137,9 @@ class ETHClient {
|
|
|
137
137
|
throw new Error("Minimum gas required: 150,000");
|
|
138
138
|
}
|
|
139
139
|
const networkConfig = this.getNetworkConfig();
|
|
140
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
141
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
142
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
140
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
141
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
142
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
143
143
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
144
144
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
145
145
|
const contractAddress = this.getLockProxyAddress();
|
|
@@ -190,16 +190,16 @@ class ETHClient {
|
|
|
190
190
|
return "insufficient balance";
|
|
191
191
|
}
|
|
192
192
|
const networkConfig = this.getNetworkConfig();
|
|
193
|
-
const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
|
|
194
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
195
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
193
|
+
const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
|
|
194
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
195
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
196
196
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
|
|
197
197
|
const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
|
|
198
198
|
const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
|
|
199
199
|
// logger("sendDeposit message", message)
|
|
200
200
|
let signatureResult;
|
|
201
201
|
const { address, signature } = yield getSignatureCallback(message);
|
|
202
|
-
const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
|
|
202
|
+
const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
|
|
203
203
|
const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
|
|
204
204
|
// logger("sign result", address, signature)
|
|
205
205
|
signatureResult = {
|
|
@@ -238,7 +238,7 @@ class ETHClient {
|
|
|
238
238
|
if (!feeInfo.deposit_fee) {
|
|
239
239
|
throw new Error("unsupported token");
|
|
240
240
|
}
|
|
241
|
-
if (blockchain_1.blockchainForChainId(token.chainId.toNumber()) !== this.blockchain) {
|
|
241
|
+
if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) !== this.blockchain) {
|
|
242
242
|
throw new Error("unsupported token");
|
|
243
243
|
}
|
|
244
244
|
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
@@ -304,7 +304,7 @@ class ETHClient {
|
|
|
304
304
|
getTargetProxyHash(token) {
|
|
305
305
|
const networkConfig = this.getNetworkConfig();
|
|
306
306
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
307
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
307
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
308
308
|
return addressHex;
|
|
309
309
|
}
|
|
310
310
|
getProvider() {
|
|
@@ -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
|
const formatCrossChainTransfer = (value) => {
|
|
35
35
|
var _a, _b;
|
package/lib/clients/N3Client.js
CHANGED
|
@@ -65,10 +65,9 @@ class N3Client {
|
|
|
65
65
|
continue;
|
|
66
66
|
if (whitelistDenoms && !whitelistDenoms.includes(token.denom))
|
|
67
67
|
continue;
|
|
68
|
-
|
|
69
|
-
if (!balances[tokenScriptHash])
|
|
68
|
+
if (!balances[token.tokenAddress])
|
|
70
69
|
continue;
|
|
71
|
-
tokensWithBalance.push(Object.assign(Object.assign({}, token), { externalBalance: balances[
|
|
70
|
+
tokensWithBalance.push(Object.assign(Object.assign({}, token), { externalBalance: balances[token.tokenAddress] }));
|
|
72
71
|
}
|
|
73
72
|
return tokensWithBalance;
|
|
74
73
|
});
|
|
@@ -34,7 +34,7 @@ export declare class NEOClient {
|
|
|
34
34
|
neo: string;
|
|
35
35
|
};
|
|
36
36
|
private constructor();
|
|
37
|
-
static instance(opts: NEOClientOpts):
|
|
37
|
+
static instance(opts: NEOClientOpts): NEOClient;
|
|
38
38
|
static parseHexNum(hex: string, exp?: number): string;
|
|
39
39
|
getExternalBalances(sdk: CarbonSDK, address: string, url: string, whitelistDenoms?: string[]): Promise<TokensWithExternalBalance[]>;
|
|
40
40
|
lockDeposit(token: TokensWithExternalBalance, feeAmountInput: string, swthAddress: string, neoPrivateKey: string): Promise<false | import("@cityofzion/neon-api/lib/funcs/types").DoInvokeConfig>;
|
package/lib/clients/NEOClient.js
CHANGED
|
@@ -37,8 +37,8 @@ const util_1 = require("../util");
|
|
|
37
37
|
const address_1 = require("../util/address");
|
|
38
38
|
const blockchain_1 = require("../util/blockchain");
|
|
39
39
|
const generic_1 = require("../util/generic");
|
|
40
|
-
const Neon = __importStar(require("@cityofzion/neon-core"));
|
|
41
40
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
41
|
+
const Neon = __importStar(require("@cityofzion/neon-core"));
|
|
42
42
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
43
43
|
const ethers_1 = require("ethers");
|
|
44
44
|
const lodash_1 = require("lodash");
|
|
@@ -63,13 +63,13 @@ class NEOClient {
|
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
64
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
65
65
|
const account = new Neon.wallet.Account(address);
|
|
66
|
-
const tokens = tokenQueryResults.filter(token => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
|
|
66
|
+
const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
|
|
67
67
|
token.tokenAddress.length == 40 &&
|
|
68
68
|
token.bridgeAddress.length == 40);
|
|
69
69
|
const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
|
|
70
70
|
// NOTE: fetching of tokens is chunked in sets of 15 as we may hit
|
|
71
71
|
// the gas limit on the RPC node and error out otherwise
|
|
72
|
-
const promises = lodash_1.chunk(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const promises = (0, lodash_1.chunk)(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
var _a, _b, _c;
|
|
74
74
|
let acc = {};
|
|
75
75
|
for (const token of partition) {
|
|
@@ -110,7 +110,7 @@ class NEOClient {
|
|
|
110
110
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
111
111
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
112
112
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
|
|
113
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
113
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
114
114
|
const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
|
|
115
115
|
const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
|
|
116
116
|
const feeAddress = networkConfig.feeAddress;
|
|
@@ -157,7 +157,7 @@ class NEOClient {
|
|
|
157
157
|
const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
|
|
158
158
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
159
159
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
160
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
160
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
161
161
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
162
162
|
if (amount.lt(feeAmount)) {
|
|
163
163
|
throw new Error("Invalid amount");
|
|
@@ -193,7 +193,7 @@ class NEOClient {
|
|
|
193
193
|
const fromAddress = ledger.scriptHash;
|
|
194
194
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
195
195
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
196
|
-
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
196
|
+
const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
|
|
197
197
|
const feeAddress = networkConfig.feeAddress;
|
|
198
198
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
199
199
|
if (amount.lt(feeAmount)) {
|
|
@@ -313,7 +313,7 @@ class NEOClient {
|
|
|
313
313
|
getTargetProxyHash(token) {
|
|
314
314
|
const networkConfig = this.getNetworkConfig();
|
|
315
315
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
316
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
316
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
317
317
|
return addressHex;
|
|
318
318
|
}
|
|
319
319
|
getNetworkConfig() {
|
|
@@ -11,7 +11,6 @@ declare class TokenClient {
|
|
|
11
11
|
readonly tokens: TypeUtils.SimpleMap<Token>;
|
|
12
12
|
readonly wrapperMap: TypeUtils.SimpleMap<string>;
|
|
13
13
|
readonly poolTokens: TypeUtils.SimpleMap<Token>;
|
|
14
|
-
readonly cdpTokens: TypeUtils.SimpleMap<Token>;
|
|
15
14
|
readonly symbols: TypeUtils.SimpleMap<string>;
|
|
16
15
|
readonly usdValues: TypeUtils.SimpleMap<BigNumber>;
|
|
17
16
|
readonly commonAssetNames: TypeUtils.SimpleMap<string>;
|
|
@@ -35,7 +34,6 @@ declare class TokenClient {
|
|
|
35
34
|
getTokenDesc(denom: string): string;
|
|
36
35
|
static isPoolTokenNew(denom: string): boolean;
|
|
37
36
|
static isPoolTokenLegacy(denom: string): boolean;
|
|
38
|
-
static isCdpToken(denom: string): boolean;
|
|
39
37
|
static isPoolToken(denom: string): boolean;
|
|
40
38
|
static isIBCDenom(denom: string): boolean;
|
|
41
39
|
isWrappedToken(denom?: string): boolean;
|
|
@@ -44,14 +42,11 @@ declare class TokenClient {
|
|
|
44
42
|
getWrappedToken(denom: string, blockchain?: BlockchainUtils.Blockchain): Token | null;
|
|
45
43
|
getSourceToken(denom: string): Token | null;
|
|
46
44
|
getNativeToken(): Token | undefined;
|
|
47
|
-
getNativeStablecoin(): Token | undefined;
|
|
48
45
|
isNativeToken(denom: string): boolean;
|
|
49
|
-
isNativeStablecoin(denom: string): boolean;
|
|
50
46
|
getDepositTokenFor(tokenDenom: string, chain: BlockchainUtils.Blockchain): Token | undefined;
|
|
51
47
|
getAllTokens(): Promise<Token[]>;
|
|
52
48
|
reloadTokens(): Promise<TypeUtils.SimpleMap<Token>>;
|
|
53
49
|
getCarbonIbcTokens(): Token[];
|
|
54
|
-
getCdpUnderlyingToken(cdpDenom: string): Token | undefined;
|
|
55
50
|
reloadWrapperMap(): Promise<TypeUtils.SimpleMap<string>>;
|
|
56
51
|
reloadDenomGeckoMap(): Promise<void>;
|
|
57
52
|
reloadUSDValues(denoms?: string[]): Promise<TypeUtils.SimpleMap<BigNumber>>;
|
|
@@ -32,8 +32,6 @@ const SYMBOL_OVERRIDE = {
|
|
|
32
32
|
AVA1: 'AVA',
|
|
33
33
|
TSWTH: 'tSWTH',
|
|
34
34
|
};
|
|
35
|
-
const regexCdpDenom = RegExp(`^${constant_1.DenomPrefix.CDPToken}/`, "i");
|
|
36
|
-
const regexLPDenom = RegExp(`^${constant_1.DenomPrefix.LPToken}/(\\d+)$`, "i");
|
|
37
35
|
class TokenClient {
|
|
38
36
|
constructor(query, configProvider) {
|
|
39
37
|
this.query = query;
|
|
@@ -41,7 +39,6 @@ class TokenClient {
|
|
|
41
39
|
this.tokens = {};
|
|
42
40
|
this.wrapperMap = {};
|
|
43
41
|
this.poolTokens = {};
|
|
44
|
-
this.cdpTokens = {};
|
|
45
42
|
this.symbols = {};
|
|
46
43
|
this.usdValues = {};
|
|
47
44
|
this.commonAssetNames = constant_1.CommonAssetName;
|
|
@@ -75,16 +72,16 @@ class TokenClient {
|
|
|
75
72
|
return (_a = this.commonAssetNames[denom]) !== null && _a !== void 0 ? _a : denom;
|
|
76
73
|
}
|
|
77
74
|
getDecimals(denom) {
|
|
78
|
-
var _a, _b
|
|
79
|
-
return (
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return (_b = ((_a = this.tokens[denom]) !== null && _a !== void 0 ? _a : this.poolTokens[denom])) === null || _b === void 0 ? void 0 : _b.decimals.toNumber();
|
|
80
77
|
}
|
|
81
78
|
getBlockchain(denom) {
|
|
82
79
|
var _a, _b, _c;
|
|
83
80
|
// chainId defaults to 3 so that blockchain will be undefined
|
|
84
81
|
let chainId = (_c = (_b = (_a = this.tokens[denom]) === null || _a === void 0 ? void 0 : _a.chainId) === null || _b === void 0 ? void 0 : _b.toNumber()) !== null && _c !== void 0 ? _c : 3;
|
|
85
|
-
if (this.isNativeToken(denom) ||
|
|
86
|
-
// native
|
|
87
|
-
// pool
|
|
82
|
+
if (this.isNativeToken(denom) || TokenClient.isPoolToken(denom)) {
|
|
83
|
+
// native denom "swth" should be native.
|
|
84
|
+
// pool tokens are on the Native blockchain, hence 0
|
|
88
85
|
chainId = 0;
|
|
89
86
|
}
|
|
90
87
|
if (TokenClient.isIBCDenom(denom)) {
|
|
@@ -94,12 +91,9 @@ class TokenClient {
|
|
|
94
91
|
return blockchain;
|
|
95
92
|
}
|
|
96
93
|
getSymbol(denom) {
|
|
97
|
-
var _a
|
|
98
|
-
if (TokenClient.isCdpToken(denom)) {
|
|
99
|
-
return (_a = this.symbols[denom]) !== null && _a !== void 0 ? _a : denom;
|
|
100
|
-
}
|
|
94
|
+
var _a;
|
|
101
95
|
const commonDenom = this.getCommonDenom(denom);
|
|
102
|
-
return (
|
|
96
|
+
return (_a = this.symbols[commonDenom]) !== null && _a !== void 0 ? _a : commonDenom.toUpperCase();
|
|
103
97
|
}
|
|
104
98
|
getUSDValue(denom) {
|
|
105
99
|
return this.usdValues[denom];
|
|
@@ -161,7 +155,7 @@ class TokenClient {
|
|
|
161
155
|
return symbol;
|
|
162
156
|
}
|
|
163
157
|
getTokenDesc(denom) {
|
|
164
|
-
var _a, _b
|
|
158
|
+
var _a, _b;
|
|
165
159
|
if (typeof denom !== 'string')
|
|
166
160
|
return '';
|
|
167
161
|
denom = denom.toLowerCase();
|
|
@@ -178,20 +172,14 @@ class TokenClient {
|
|
|
178
172
|
const symbolB = this.getTokenName(denomB);
|
|
179
173
|
return `${weightA}% ${symbolA} / ${weightB}% ${symbolB}`;
|
|
180
174
|
}
|
|
181
|
-
|
|
182
|
-
return (_b = (_a = this.cdpTokens[denom]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : this.getSymbol(denom);
|
|
183
|
-
}
|
|
184
|
-
return (_d = (_c = this.tokens[denom]) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : this.getSymbol(denom);
|
|
175
|
+
return (_b = (_a = this.tokens[denom]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : this.getSymbol(denom);
|
|
185
176
|
}
|
|
186
177
|
static isPoolTokenNew(denom) {
|
|
187
|
-
return denom.match(
|
|
178
|
+
return denom.match(/^clpt\/(\d+)$/i) !== null;
|
|
188
179
|
}
|
|
189
180
|
static isPoolTokenLegacy(denom) {
|
|
190
181
|
return denom.match(/^([a-z\d.-]+)-(\d+)-([a-z\d.-]+)-(\d+)-lp\d+$/i) !== null;
|
|
191
182
|
}
|
|
192
|
-
static isCdpToken(denom) {
|
|
193
|
-
return denom.match(regexCdpDenom) !== null;
|
|
194
|
-
}
|
|
195
183
|
static isPoolToken(denom) {
|
|
196
184
|
return this.isPoolTokenNew(denom) || this.isPoolTokenLegacy(denom);
|
|
197
185
|
}
|
|
@@ -264,15 +252,9 @@ class TokenClient {
|
|
|
264
252
|
getNativeToken() {
|
|
265
253
|
return this.tokenForId("swth");
|
|
266
254
|
}
|
|
267
|
-
getNativeStablecoin() {
|
|
268
|
-
return this.tokenForId("usc");
|
|
269
|
-
}
|
|
270
255
|
isNativeToken(denom) {
|
|
271
256
|
return denom === "swth";
|
|
272
257
|
}
|
|
273
|
-
isNativeStablecoin(denom) {
|
|
274
|
-
return denom === "usc";
|
|
275
|
-
}
|
|
276
258
|
getDepositTokenFor(tokenDenom, chain) {
|
|
277
259
|
const token = this.tokenForDenom(tokenDenom);
|
|
278
260
|
if (!token) {
|
|
@@ -318,10 +300,6 @@ class TokenClient {
|
|
|
318
300
|
if (TokenClient.isPoolToken(token.denom)) {
|
|
319
301
|
this.poolTokens[token.denom] = token;
|
|
320
302
|
}
|
|
321
|
-
else if (TokenClient.isCdpToken(token.denom)) {
|
|
322
|
-
this.cdpTokens[token.denom] = token;
|
|
323
|
-
this.symbols[token.denom] = token.symbol;
|
|
324
|
-
}
|
|
325
303
|
else {
|
|
326
304
|
if (this.isNativeToken(token.denom)) {
|
|
327
305
|
// Change token name to Carbon
|
|
@@ -378,12 +356,6 @@ class TokenClient {
|
|
|
378
356
|
});
|
|
379
357
|
return swthTokens;
|
|
380
358
|
}
|
|
381
|
-
getCdpUnderlyingToken(cdpDenom) {
|
|
382
|
-
if (!this.cdpTokens[cdpDenom])
|
|
383
|
-
throw new Error("not a CDP denom");
|
|
384
|
-
const tokenDenom = cdpDenom.replace(regexCdpDenom, "");
|
|
385
|
-
return this.tokenForDenom(tokenDenom);
|
|
386
|
-
}
|
|
387
359
|
reloadWrapperMap() {
|
|
388
360
|
var _a;
|
|
389
361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -76,7 +76,7 @@ export declare class ZILClient {
|
|
|
76
76
|
};
|
|
77
77
|
private walletProvider?;
|
|
78
78
|
private constructor();
|
|
79
|
-
static instance(opts: ZILClientOpts):
|
|
79
|
+
static instance(opts: ZILClientOpts): ZILClient;
|
|
80
80
|
getExternalBalances(sdk: CarbonSDK, address: string, whitelistDenoms?: string[]): Promise<TokensWithExternalBalance[]>;
|
|
81
81
|
formatWithdrawalAddress(bech32Address: string): Promise<string>;
|
|
82
82
|
private callContract;
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -74,10 +74,10 @@ class ZILClient {
|
|
|
74
74
|
getExternalBalances(sdk, address, whitelistDenoms) {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
76
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
77
|
-
const tokens = tokenQueryResults.filter(token => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
|
|
77
|
+
const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
|
|
78
78
|
token.tokenAddress.length == 40 &&
|
|
79
79
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)));
|
|
80
|
-
const requests = tokens.map(token => token.tokenAddress === zeroAddress ? exports.balanceBatchRequest(address.replace(/^0x/i, "")) : exports.tokenBalanceBatchRequest(token.tokenAddress, address));
|
|
80
|
+
const requests = tokens.map(token => token.tokenAddress === zeroAddress ? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, "")) : (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
|
|
81
81
|
const response = yield fetch(this.getProviderUrl(), {
|
|
82
82
|
method: "post",
|
|
83
83
|
headers: { "content-type": "application/json" },
|
|
@@ -102,7 +102,7 @@ class ZILClient {
|
|
|
102
102
|
// if (!isValidAddress) {
|
|
103
103
|
// throw new Error("invalid address")
|
|
104
104
|
// }
|
|
105
|
-
return zilliqa_1.fromBech32Address(bech32Address).toLowerCase().substr(2);
|
|
105
|
+
return (0, zilliqa_1.fromBech32Address)(bech32Address).toLowerCase().substr(2);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
// see examplesV2/zil_client.ts on how to confirm the transactions
|
|
@@ -148,7 +148,7 @@ class ZILClient {
|
|
|
148
148
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
149
149
|
}
|
|
150
150
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
151
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
151
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
|
|
152
152
|
if (balanceAndNonceResp.error !== undefined) {
|
|
153
153
|
throw new Error(balanceAndNonceResp.error.message);
|
|
154
154
|
}
|
|
@@ -166,7 +166,7 @@ class ZILClient {
|
|
|
166
166
|
vname: 'spender',
|
|
167
167
|
type: 'ByStr20',
|
|
168
168
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
169
|
-
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : generic_1.appendHexPrefix(token.bridgeAddress),
|
|
169
|
+
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
vname: 'amount',
|
|
@@ -184,7 +184,7 @@ class ZILClient {
|
|
|
184
184
|
}
|
|
185
185
|
checkAllowanceZRC2(token, owner, spender) {
|
|
186
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const contractAddress = generic_1.appendHexPrefix(token.tokenAddress);
|
|
187
|
+
const contractAddress = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
188
188
|
const zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
189
189
|
const resp = yield zilliqa.blockchain.getSmartContractSubState(contractAddress, "allowances", [owner, spender]);
|
|
190
190
|
if (resp.error !== undefined) {
|
|
@@ -204,13 +204,13 @@ class ZILClient {
|
|
|
204
204
|
throw new Error("Invalid recovery address");
|
|
205
205
|
}
|
|
206
206
|
const fromTokenId = fromToken.id;
|
|
207
|
-
const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
207
|
+
const fromTokenAddr = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
|
|
208
208
|
const toTokenDenom = toToken.denom;
|
|
209
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(fromToken));
|
|
209
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
|
|
210
210
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
|
|
211
211
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
212
212
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
213
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
213
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
214
214
|
const contractAddress = this.getBridgeEntranceAddr();
|
|
215
215
|
let zilliqa;
|
|
216
216
|
if (typeof signer === 'string') {
|
|
@@ -225,7 +225,7 @@ class ZILClient {
|
|
|
225
225
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
226
226
|
}
|
|
227
227
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
228
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(fromAddress));
|
|
228
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(fromAddress));
|
|
229
229
|
if (balanceAndNonceResp.error !== undefined) {
|
|
230
230
|
throw new Error(balanceAndNonceResp.error.message);
|
|
231
231
|
}
|
|
@@ -302,13 +302,13 @@ class ZILClient {
|
|
|
302
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
303
303
|
const { address, amount, token, gasPrice, gasLimit, zilAddress, signer } = params;
|
|
304
304
|
const networkConfig = this.getNetworkConfig();
|
|
305
|
-
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
306
|
-
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
307
|
-
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
305
|
+
const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
|
|
306
|
+
const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
|
|
307
|
+
const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
|
|
308
308
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
309
309
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
310
310
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
311
|
-
const contractAddress = generic_1.appendHexPrefix(token.bridgeAddress);
|
|
311
|
+
const contractAddress = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
|
|
312
312
|
let zilliqa;
|
|
313
313
|
if (typeof signer === 'string') {
|
|
314
314
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
@@ -322,7 +322,7 @@ class ZILClient {
|
|
|
322
322
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
323
323
|
}
|
|
324
324
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
325
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
325
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
|
|
326
326
|
if (balanceAndNonceResp.error !== undefined) {
|
|
327
327
|
throw new Error(balanceAndNonceResp.error.message);
|
|
328
328
|
}
|
|
@@ -407,7 +407,7 @@ class ZILClient {
|
|
|
407
407
|
getTargetProxyHash(token) {
|
|
408
408
|
const networkConfig = this.getNetworkConfig();
|
|
409
409
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
410
|
-
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
410
|
+
const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
411
411
|
return addressHex;
|
|
412
412
|
}
|
|
413
413
|
getNetworkConfig() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Long from "long";
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
|
-
import { OrderBook, StopBook } from "
|
|
3
|
+
import { OrderBook, StopBook } from "../book/book";
|
|
4
4
|
export declare const protobufPackage = "Switcheo.carbon.book";
|
|
5
5
|
/** GenesisState defines the book module's genesis state. */
|
|
6
6
|
export interface GenesisState {
|
|
@@ -7,7 +7,7 @@ exports.GenesisState = 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
|
-
const book_1 = require("
|
|
10
|
+
const book_1 = require("../book/book");
|
|
11
11
|
exports.protobufPackage = "Switcheo.carbon.book";
|
|
12
12
|
const baseGenesisState = {};
|
|
13
13
|
exports.GenesisState = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Long from "long";
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
|
-
import { OrderBook } from "
|
|
3
|
+
import { OrderBook } from "../book/book";
|
|
4
4
|
import { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination";
|
|
5
5
|
export declare const protobufPackage = "Switcheo.carbon.book";
|
|
6
6
|
/** this line is used by starport scaffolding # 3 */
|
package/lib/codec/book/query.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.QueryClientImpl = exports.QueryAllBookResponse = exports.QueryAllBookReq
|
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
-
const book_1 = require("
|
|
10
|
+
const book_1 = require("../book/book");
|
|
11
11
|
const pagination_1 = require("../cosmos/base/query/v1beta1/pagination");
|
|
12
12
|
exports.protobufPackage = "Switcheo.carbon.book";
|
|
13
13
|
const baseQueryGetBookRequest = { market: "" };
|