carbon-js-sdk 0.5.6 → 0.6.0-rc1
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 +6 -5
- package/lib/CarbonSDK.js +15 -10
- package/lib/clients/CarbonQueryClient.d.ts +16 -4
- package/lib/clients/CarbonQueryClient.js +15 -6
- package/lib/clients/GrpcQueryClient.d.ts +9 -0
- package/lib/clients/GrpcQueryClient.js +36 -0
- package/lib/clients/index.d.ts +2 -0
- package/lib/clients/index.js +5 -1
- package/lib/constant/network.d.ts +5 -2
- package/lib/constant/network.js +8 -0
- package/lib/constant/node.d.ts +3 -3
- package/lib/constant/token.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +5 -5
- package/lib/provider/metamask/MetaMask.d.ts +1 -1
- package/lib/util/legacyEIP712.d.ts +3 -3
- package/lib/util/legacyEIP712.js +2 -2
- package/lib/util/network.d.ts +1 -1
- package/lib/util/network.js +6 -6
- package/lib/util/type.d.ts +1 -1
- package/lib/util/type.js +1 -1
- package/package.json +2 -1
- package/lib/clients/EvmIbcClient.d.ts +0 -86
- package/lib/clients/EvmIbcClient.js +0 -90
- package/lib/codec/broker/incoming_pool_swap.d.ts +0 -23
- package/lib/codec/broker/incoming_pool_swap.js +0 -136
- package/lib/codec/crisis/genesis.d.ts +0 -18
- package/lib/codec/crisis/genesis.js +0 -46
- package/lib/codec/crisis/query.d.ts +0 -43
- package/lib/codec/crisis/query.js +0 -103
- package/lib/codec/crisis/tx.d.ts +0 -12
- package/lib/codec/crisis/tx.js +0 -20
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.d.ts +0 -76
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.js +0 -424
- package/lib/codec/market/legacy.d.ts +0 -62
- package/lib/codec/market/legacy.js +0 -630
- package/lib/codec/perpsliquidity/event.d.ts +0 -103
- package/lib/codec/perpsliquidity/event.js +0 -596
- package/lib/codec/perpsliquidity/genesis.d.ts +0 -35
- package/lib/codec/perpsliquidity/genesis.js +0 -162
- package/lib/codec/perpsliquidity/params.d.ts +0 -22
- package/lib/codec/perpsliquidity/params.js +0 -86
- package/lib/codec/perpsliquidity/pool.d.ts +0 -155
- package/lib/codec/perpsliquidity/pool.js +0 -871
- package/lib/codec/perpsliquidity/query.d.ts +0 -194
- package/lib/codec/perpsliquidity/query.js +0 -876
- package/lib/codec/perpsliquidity/tx.d.ts +0 -202
- package/lib/codec/perpsliquidity/tx.js +0 -970
- package/lib/codec/query/pagination.d.ts +0 -29
- package/lib/codec/query/pagination.js +0 -126
- package/lib/modules/erc20.d.ts +0 -26
- package/lib/modules/erc20.js +0 -79
- package/lib/modules/perpsliquidity.d.ts +0 -48
- package/lib/modules/perpsliquidity.js +0 -117
- package/lib/provider/amino/types/alliance.d.ts +0 -4
- package/lib/provider/amino/types/alliance.js +0 -56
- package/lib/provider/amino/types/erc20.d.ts +0 -4
- package/lib/provider/amino/types/erc20.js +0 -40
- package/lib/provider/amino/types/perpsliquidity.d.ts +0 -4
- package/lib/provider/amino/types/perpsliquidity.js +0 -73
- package/lib/util/ethermint/evm-ibc.d.ts +0 -97
- package/lib/util/ethermint/evm-ibc.js +0 -134
- package/lib/util/ethermint/index.d.ts +0 -3
- package/lib/util/ethermint/index.js +0 -12
- package/lib/util/ethermint/keys.d.ts +0 -39
- package/lib/util/ethermint/keys.js +0 -138
- package/lib/util/ethermint/web3.d.ts +0 -36
- package/lib/util/ethermint/web3.js +0 -124
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Network, Network as _Network
|
|
2
|
+
import { Network, NetworkConfig, Network as _Network } from "./constant";
|
|
3
3
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
4
|
-
import { CarbonQueryClient, ETHClient, HydrogenClient, InsightsQueryClient, NEOClient, TokenClient, ZILClient } from "./clients";
|
|
5
4
|
import * as clients from "./clients";
|
|
6
|
-
import N3Client from "./clients
|
|
7
|
-
import { AdminModule, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule
|
|
5
|
+
import { CarbonQueryClient, ETHClient, GrpcQueryClient, HydrogenClient, InsightsQueryClient, N3Client, NEOClient, TokenClient, ZILClient } from "./clients";
|
|
6
|
+
import { AdminModule, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, EvmMergeModule, EvmModule, FeeModule, FeemarketModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
|
|
8
7
|
import { StakingModule } from "./modules/staking";
|
|
9
8
|
import { CosmosLedger, Keplr, LeapExtended } from "./provider";
|
|
10
|
-
import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts, MetaMaskWalletOpts } from "./wallet";
|
|
11
9
|
import { MetaMask } from "./provider/metamask/MetaMask";
|
|
10
|
+
import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts, MetaMaskWalletOpts } from "./wallet";
|
|
12
11
|
export { CarbonTx } from "./util";
|
|
13
12
|
export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
|
|
14
13
|
export { DenomPrefix } from "./constant";
|
|
15
14
|
export interface CarbonSDKOpts {
|
|
16
15
|
network: Network;
|
|
17
16
|
tmClient: Tendermint34Client;
|
|
17
|
+
grpcQueryClient?: GrpcQueryClient;
|
|
18
18
|
chainId?: string;
|
|
19
19
|
evmChainId?: string;
|
|
20
20
|
token?: TokenClient;
|
|
21
21
|
config?: Partial<NetworkConfig>;
|
|
22
|
+
useTmAbciQuery?: boolean;
|
|
22
23
|
defaultTimeoutBlocks?: number;
|
|
23
24
|
}
|
|
24
25
|
export interface CarbonSDKInitOpts {
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -27,17 +27,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
31
|
exports.ConnectedCarbonSDK = exports.DenomPrefix = exports.CarbonWallet = exports.CarbonSignerTypes = exports.CarbonTx = void 0;
|
|
35
32
|
const constant_1 = require("./constant");
|
|
36
33
|
const util_1 = require("./util");
|
|
37
34
|
const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
38
|
-
const
|
|
35
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
39
36
|
const clients = __importStar(require("./clients"));
|
|
40
|
-
const
|
|
37
|
+
const clients_1 = require("./clients");
|
|
41
38
|
const modules_1 = require("./modules");
|
|
42
39
|
const staking_1 = require("./modules/staking");
|
|
43
40
|
const provider_1 = require("./provider");
|
|
@@ -60,16 +57,24 @@ const DEFAULT_SDK_INIT_OPTS = {
|
|
|
60
57
|
*/
|
|
61
58
|
class CarbonSDK {
|
|
62
59
|
constructor(opts) {
|
|
63
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64
61
|
this.network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
|
|
65
62
|
this.configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
|
|
66
63
|
this.networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[this.network], this.configOverride);
|
|
67
64
|
this.tmClient = opts.tmClient;
|
|
68
65
|
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
66
|
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];
|
|
70
|
-
|
|
67
|
+
let grpcClient;
|
|
68
|
+
if (opts.useTmAbciQuery !== true && this.networkConfig.grpcUrl) {
|
|
69
|
+
const c = this.networkConfig.grpcInsecure ? grpc_js_1.credentials.createInsecure() : grpc_js_1.credentials.createSsl();
|
|
70
|
+
grpcClient = (_g = opts.grpcQueryClient) !== null && _g !== void 0 ? _g : new clients_1.GrpcQueryClient(this.networkConfig.grpcUrl, c);
|
|
71
|
+
}
|
|
72
|
+
this.query = new clients_1.CarbonQueryClient({
|
|
73
|
+
tmClient: this.tmClient,
|
|
74
|
+
grpcClient,
|
|
75
|
+
});
|
|
71
76
|
this.insights = new clients_1.InsightsQueryClient(this.networkConfig);
|
|
72
|
-
this.token = (
|
|
77
|
+
this.token = (_h = opts.token) !== null && _h !== void 0 ? _h : clients_1.TokenClient.instance(this.query, this);
|
|
73
78
|
this.hydrogen = new clients_1.HydrogenClient(this.networkConfig, this.token);
|
|
74
79
|
this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
|
|
75
80
|
this.admin = new modules_1.AdminModule(this);
|
|
@@ -98,7 +103,7 @@ class CarbonSDK {
|
|
|
98
103
|
configProvider: this,
|
|
99
104
|
blockchain: blockchain_1.Blockchain.Neo,
|
|
100
105
|
});
|
|
101
|
-
this.n3 =
|
|
106
|
+
this.n3 = clients_1.N3Client.instance({
|
|
102
107
|
configProvider: this,
|
|
103
108
|
blockchain: blockchain_1.Blockchain.Neo3,
|
|
104
109
|
});
|
|
@@ -138,7 +143,7 @@ class CarbonSDK {
|
|
|
138
143
|
const network = (_a = opts.network) !== null && _a !== void 0 ? _a : constant_1.DEFAULT_NETWORK;
|
|
139
144
|
const configOverride = (_b = opts.config) !== null && _b !== void 0 ? _b : {};
|
|
140
145
|
const networkConfig = util_1.GenericUtils.overrideConfig(constant_1.NetworkConfigs[network], configOverride);
|
|
141
|
-
const batchQueryClient = new
|
|
146
|
+
const batchQueryClient = new clients_1.BatchQueryClient(networkConfig.tmRpcUrl);
|
|
142
147
|
const tmClient = (_c = opts.tmClient) !== null && _c !== void 0 ? _c : util_1.GenericUtils.modifyTmClient(yield tendermint_rpc_1.Tendermint34Client.create(batchQueryClient));
|
|
143
148
|
const defaultTimeoutBlocks = opts.defaultTimeoutBlocks;
|
|
144
149
|
const chainId = (_d = (yield tmClient.status())) === null || _d === void 0 ? void 0 : _d.nodeInfo.network;
|
|
@@ -42,8 +42,10 @@ import { QueryClientImpl as PricingQueryClient } from "../codec/pricing/query";
|
|
|
42
42
|
import { QueryClientImpl as ProfileQueryClient } from "../codec/profile/query";
|
|
43
43
|
import { QueryClientImpl as SubaccountQueryClient } from "../codec/subaccount/query";
|
|
44
44
|
import { QueryClientImpl as AllianceClient } from "../codec/alliance/query";
|
|
45
|
+
import { ProtobufRpcClient } from "@cosmjs/stargate";
|
|
45
46
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
46
47
|
import BlockchainClient from "./BlockchainClient";
|
|
48
|
+
import GrpcQueryClient from "./GrpcQueryClient";
|
|
47
49
|
export interface IBCClientGroup {
|
|
48
50
|
controller: IBCInterchainControlQueryClient;
|
|
49
51
|
host: IBCInterchainHostQueryClient;
|
|
@@ -56,8 +58,17 @@ export interface EthermintClientGroup {
|
|
|
56
58
|
evm: EthermintEVMQueryClient;
|
|
57
59
|
feeMarket: EthermintFeeMarketQueryClient;
|
|
58
60
|
}
|
|
61
|
+
export interface CarbonQueryClientOpts {
|
|
62
|
+
/**
|
|
63
|
+
* Used to create an RPC client through Tendermint ABCI.
|
|
64
|
+
*/
|
|
65
|
+
tmClient: Tendermint34Client;
|
|
66
|
+
/**
|
|
67
|
+
* Used for querying through GRPC instead of Tendermint ABCI.
|
|
68
|
+
*/
|
|
69
|
+
grpcClient?: GrpcQueryClient;
|
|
70
|
+
}
|
|
59
71
|
declare class CarbonQueryClient {
|
|
60
|
-
private readonly tmClient;
|
|
61
72
|
adl: ADLQueryClient;
|
|
62
73
|
book: BookQueryClient;
|
|
63
74
|
broker: BrokerQueryClient;
|
|
@@ -97,8 +108,9 @@ declare class CarbonQueryClient {
|
|
|
97
108
|
ethermint: EthermintClientGroup;
|
|
98
109
|
evmmerge: EvmMergeQueryClient;
|
|
99
110
|
evmbank: EvmBankQueryClient;
|
|
100
|
-
private
|
|
101
|
-
constructor(
|
|
102
|
-
|
|
111
|
+
private rpcClient;
|
|
112
|
+
constructor(opts: CarbonQueryClientOpts);
|
|
113
|
+
private parseRpcClient;
|
|
114
|
+
getProtobufRpcClient(): ProtobufRpcClient;
|
|
103
115
|
}
|
|
104
116
|
export default CarbonQueryClient;
|
|
@@ -50,11 +50,20 @@ const query_44 = require("../codec/alliance/query");
|
|
|
50
50
|
const stargate_1 = require("@cosmjs/stargate");
|
|
51
51
|
const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
|
|
52
52
|
class CarbonQueryClient {
|
|
53
|
-
constructor(
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
constructor(opts) {
|
|
54
|
+
this.parseRpcClient = (opts) => {
|
|
55
|
+
if (opts.grpcClient) {
|
|
56
|
+
return opts.grpcClient;
|
|
57
|
+
}
|
|
58
|
+
else if (opts.tmClient) {
|
|
59
|
+
const tmQueryClient = new stargate_1.QueryClient(opts.tmClient);
|
|
60
|
+
return stargate_1.createProtobufRpcClient(tmQueryClient);
|
|
61
|
+
}
|
|
62
|
+
throw new Error("invalid initialization, no valid query client found");
|
|
63
|
+
};
|
|
64
|
+
const rpcClient = this.parseRpcClient(opts);
|
|
65
|
+
this.rpcClient = rpcClient;
|
|
66
|
+
this.chain = BlockchainClient_1.default.connectWithTm(opts.tmClient);
|
|
58
67
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
59
68
|
this.alliance = new query_44.QueryClientImpl(rpcClient);
|
|
60
69
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
@@ -106,7 +115,7 @@ class CarbonQueryClient {
|
|
|
106
115
|
};
|
|
107
116
|
}
|
|
108
117
|
getProtobufRpcClient() {
|
|
109
|
-
return
|
|
118
|
+
return this.rpcClient;
|
|
110
119
|
}
|
|
111
120
|
}
|
|
112
121
|
exports.default = CarbonQueryClient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ChannelCredentials, Client } from "@grpc/grpc-js";
|
|
3
|
+
declare class GrpcQueryClient extends Client {
|
|
4
|
+
constructor(url: string, creds?: ChannelCredentials);
|
|
5
|
+
serializeRequest: (value: Uint8Array) => Buffer;
|
|
6
|
+
deserializeResponse: (buffer: Buffer) => Buffer;
|
|
7
|
+
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
8
|
+
}
|
|
9
|
+
export default GrpcQueryClient;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
13
|
+
class GrpcQueryClient extends grpc_js_1.Client {
|
|
14
|
+
constructor(url, creds = grpc_js_1.credentials.createSsl()) {
|
|
15
|
+
super(url, creds);
|
|
16
|
+
this.serializeRequest = (value) => {
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
this.deserializeResponse = (buffer) => {
|
|
20
|
+
return buffer;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
request(service, method, data) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
this.makeUnaryRequest(`/${service}/${method}`, this.serializeRequest, this.deserializeResponse, data, (err, value) => {
|
|
27
|
+
if (err)
|
|
28
|
+
reject(err);
|
|
29
|
+
else
|
|
30
|
+
resolve(value !== null && value !== void 0 ? value : new Uint8Array());
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = GrpcQueryClient;
|
package/lib/clients/index.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ export { default as BatchQueryClient } from "./BatchQueryClient";
|
|
|
2
2
|
export { default as BlockchainClient } from "./BlockchainClient";
|
|
3
3
|
export { default as CarbonQueryClient } from "./CarbonQueryClient";
|
|
4
4
|
export { default as ETHClient } from "./ETHClient";
|
|
5
|
+
export { default as GrpcQueryClient } from "./GrpcQueryClient";
|
|
5
6
|
export { default as HydrogenClient } from "./HydrogenClient";
|
|
6
7
|
export { default as InsightsQueryClient } from "./InsightsQueryClient";
|
|
8
|
+
export { default as N3Client } from "./N3Client";
|
|
7
9
|
export { default as NEOClient } from "./NEOClient";
|
|
8
10
|
export { default as TokenClient } from "./TokenClient";
|
|
9
11
|
export { default as ZILClient } from "./ZILClient";
|
package/lib/clients/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.ZILClient = exports.TokenClient = exports.NEOClient = exports.InsightsQueryClient = exports.HydrogenClient = exports.ETHClient = exports.CarbonQueryClient = exports.BlockchainClient = exports.BatchQueryClient = void 0;
|
|
6
|
+
exports.ZILClient = exports.TokenClient = exports.NEOClient = exports.N3Client = exports.InsightsQueryClient = exports.HydrogenClient = exports.GrpcQueryClient = exports.ETHClient = exports.CarbonQueryClient = exports.BlockchainClient = exports.BatchQueryClient = void 0;
|
|
7
7
|
var BatchQueryClient_1 = require("./BatchQueryClient");
|
|
8
8
|
Object.defineProperty(exports, "BatchQueryClient", { enumerable: true, get: function () { return __importDefault(BatchQueryClient_1).default; } });
|
|
9
9
|
var BlockchainClient_1 = require("./BlockchainClient");
|
|
@@ -12,10 +12,14 @@ var CarbonQueryClient_1 = require("./CarbonQueryClient");
|
|
|
12
12
|
Object.defineProperty(exports, "CarbonQueryClient", { enumerable: true, get: function () { return __importDefault(CarbonQueryClient_1).default; } });
|
|
13
13
|
var ETHClient_1 = require("./ETHClient");
|
|
14
14
|
Object.defineProperty(exports, "ETHClient", { enumerable: true, get: function () { return __importDefault(ETHClient_1).default; } });
|
|
15
|
+
var GrpcQueryClient_1 = require("./GrpcQueryClient");
|
|
16
|
+
Object.defineProperty(exports, "GrpcQueryClient", { enumerable: true, get: function () { return __importDefault(GrpcQueryClient_1).default; } });
|
|
15
17
|
var HydrogenClient_1 = require("./HydrogenClient");
|
|
16
18
|
Object.defineProperty(exports, "HydrogenClient", { enumerable: true, get: function () { return __importDefault(HydrogenClient_1).default; } });
|
|
17
19
|
var InsightsQueryClient_1 = require("./InsightsQueryClient");
|
|
18
20
|
Object.defineProperty(exports, "InsightsQueryClient", { enumerable: true, get: function () { return __importDefault(InsightsQueryClient_1).default; } });
|
|
21
|
+
var N3Client_1 = require("./N3Client");
|
|
22
|
+
Object.defineProperty(exports, "N3Client", { enumerable: true, get: function () { return __importDefault(N3Client_1).default; } });
|
|
19
23
|
var NEOClient_1 = require("./NEOClient");
|
|
20
24
|
Object.defineProperty(exports, "NEOClient", { enumerable: true, get: function () { return __importDefault(NEOClient_1).default; } });
|
|
21
25
|
var TokenClient_1 = require("./TokenClient");
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SimpleMap } from "../util/type";
|
|
2
1
|
export declare enum Network {
|
|
3
2
|
MainNet = "mainnet",
|
|
4
3
|
TestNet = "testnet",
|
|
@@ -45,6 +44,8 @@ export interface NetworkConfig {
|
|
|
45
44
|
tmRpcUrl: string;
|
|
46
45
|
tmWsUrl: string;
|
|
47
46
|
restUrl: string;
|
|
47
|
+
grpcUrl: string;
|
|
48
|
+
grpcInsecure: boolean;
|
|
48
49
|
evmJsonRpcUrl: string;
|
|
49
50
|
evmWsUrl: string;
|
|
50
51
|
insightsUrl: string;
|
|
@@ -73,4 +74,6 @@ export interface NetworkConfigProvider {
|
|
|
73
74
|
export declare const NetworkConfigs: {
|
|
74
75
|
[key in Network]: NetworkConfig;
|
|
75
76
|
};
|
|
76
|
-
export declare const publicRpcNodes:
|
|
77
|
+
export declare const publicRpcNodes: {
|
|
78
|
+
[index: string]: string;
|
|
79
|
+
};
|
package/lib/constant/network.js
CHANGED
|
@@ -28,6 +28,8 @@ exports.NetworkConfigs = {
|
|
|
28
28
|
tmRpcUrl: "https://tm-api.carbon.network/",
|
|
29
29
|
tmWsUrl: "wss://tm-api.carbon.network/",
|
|
30
30
|
restUrl: "https://api.carbon.network",
|
|
31
|
+
grpcUrl: "grpc.carbon.network",
|
|
32
|
+
grpcInsecure: false,
|
|
31
33
|
evmJsonRpcUrl: "https://evm-api.carbon.network/",
|
|
32
34
|
evmWsUrl: "wss://evm-ws.carbon.network/",
|
|
33
35
|
insightsUrl: "https://api-insights.carbon.network",
|
|
@@ -105,6 +107,8 @@ exports.NetworkConfigs = {
|
|
|
105
107
|
tmRpcUrl: "https://test-tm-api.carbon.network",
|
|
106
108
|
tmWsUrl: "wss://test-tm-api.carbon.network",
|
|
107
109
|
restUrl: "https://test-api.carbon.network",
|
|
110
|
+
grpcUrl: "test-grpc.carbon.network",
|
|
111
|
+
grpcInsecure: false,
|
|
108
112
|
evmJsonRpcUrl: "https://test-evm-api.carbon.network/",
|
|
109
113
|
evmWsUrl: "wss://test-evm-ws.carbon.network/",
|
|
110
114
|
insightsUrl: "https://test-api-insights.carbon.network",
|
|
@@ -182,6 +186,8 @@ exports.NetworkConfigs = {
|
|
|
182
186
|
tmRpcUrl: "https://dev-tm-api.carbon.network",
|
|
183
187
|
tmWsUrl: "wss://dev-tm-api.carbon.network",
|
|
184
188
|
restUrl: "https://dev-api.carbon.network",
|
|
189
|
+
grpcUrl: "dev-grpc.carbon.network",
|
|
190
|
+
grpcInsecure: false,
|
|
185
191
|
evmJsonRpcUrl: "https://dev-evm-api.carbon.network/",
|
|
186
192
|
evmWsUrl: "wss://dev-evm-ws.carbon.network/",
|
|
187
193
|
insightsUrl: "https://dev-api-insights.carbon.network",
|
|
@@ -259,6 +265,8 @@ exports.NetworkConfigs = {
|
|
|
259
265
|
tmRpcUrl: "http://localhost:26657",
|
|
260
266
|
tmWsUrl: "ws://localhost:26657",
|
|
261
267
|
restUrl: "http://localhost:1317",
|
|
268
|
+
grpcUrl: "localhost:9090",
|
|
269
|
+
grpcInsecure: true,
|
|
262
270
|
evmJsonRpcUrl: "http://localhost:8545/",
|
|
263
271
|
evmWsUrl: "ws://localhost:8546/",
|
|
264
272
|
insightsUrl: "http://localhost:8181",
|
package/lib/constant/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
declare type NodeNet =
|
|
1
|
+
import { NodeItem } from "../insights/node";
|
|
2
|
+
import { SimpleMap } from "../util/type";
|
|
3
|
+
declare type NodeNet = SimpleMap<NodeItem[]>;
|
|
4
4
|
export declare const nodesByNet: NodeNet;
|
|
5
5
|
export {};
|
package/lib/constant/token.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from "./CarbonSDK";
|
|
2
2
|
export * from "./modules";
|
|
3
3
|
export * as Models from "./codec";
|
|
4
|
+
export { ProviderAgent } from "./constant";
|
|
4
5
|
export * from "./util";
|
|
5
6
|
export { Blockchain } from "./util/blockchain";
|
|
6
7
|
export * from "./websocket";
|
|
7
8
|
export { AminoTypesMap, CoinPretty, SDKProvider, KeplrAccount, KeplrWindow, CosmosLedger, Keplr, ChainInfo, EVMChain, MetaMaskChangeNetworkParam, CallContractArgs, MetaMaskSyncResult, MetaMask, EthLedgerAccount, EthLedgerSigner, NeoLedgerAccount, Zilpay, ZilPayChangeNetworkParam, O3Types, O3Wallet, LeapAccount, Leap, Key, getSigningCosmosClientOptions, AssetList, Chain, LeapExtended, } from "./provider";
|
|
8
|
-
export { default as CarbonSDK } from "./CarbonSDK";
|
|
9
|
-
export { ProviderAgent } from "./constant";
|
|
10
9
|
export * as Insights from "./insights";
|
|
11
10
|
export * as Hydrogen from "./hydrogen";
|
|
12
11
|
export { CarbonSigner, DirectCarbonSigner, AminoCarbonSigner, CarbonLedgerSigner, CarbonPrivateKeySigner, CarbonNonSigner } from "./wallet";
|
|
12
|
+
export { default as CarbonSDK } from "./CarbonSDK";
|
package/lib/index.js
CHANGED
|
@@ -25,10 +25,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.CarbonNonSigner = exports.CarbonPrivateKeySigner = exports.CarbonLedgerSigner = exports.Hydrogen = exports.Insights = exports.
|
|
28
|
+
exports.CarbonSDK = exports.CarbonNonSigner = exports.CarbonPrivateKeySigner = exports.CarbonLedgerSigner = exports.Hydrogen = exports.Insights = exports.getSigningCosmosClientOptions = exports.LeapAccount = exports.O3Wallet = exports.O3Types = exports.Zilpay = exports.NeoLedgerAccount = exports.EthLedgerSigner = exports.EthLedgerAccount = exports.MetaMask = exports.CosmosLedger = exports.KeplrAccount = exports.CoinPretty = exports.AminoTypesMap = exports.Blockchain = exports.ProviderAgent = exports.Models = void 0;
|
|
29
29
|
__exportStar(require("./CarbonSDK"), exports);
|
|
30
30
|
__exportStar(require("./modules"), exports);
|
|
31
31
|
exports.Models = __importStar(require("./codec"));
|
|
32
|
+
var constant_1 = require("./constant");
|
|
33
|
+
Object.defineProperty(exports, "ProviderAgent", { enumerable: true, get: function () { return constant_1.ProviderAgent; } });
|
|
32
34
|
__exportStar(require("./util"), exports);
|
|
33
35
|
var blockchain_1 = require("./util/blockchain");
|
|
34
36
|
Object.defineProperty(exports, "Blockchain", { enumerable: true, get: function () { return blockchain_1.Blockchain; } });
|
|
@@ -47,13 +49,11 @@ Object.defineProperty(exports, "O3Types", { enumerable: true, get: function () {
|
|
|
47
49
|
Object.defineProperty(exports, "O3Wallet", { enumerable: true, get: function () { return provider_1.O3Wallet; } });
|
|
48
50
|
Object.defineProperty(exports, "LeapAccount", { enumerable: true, get: function () { return provider_1.LeapAccount; } });
|
|
49
51
|
Object.defineProperty(exports, "getSigningCosmosClientOptions", { enumerable: true, get: function () { return provider_1.getSigningCosmosClientOptions; } });
|
|
50
|
-
var CarbonSDK_1 = require("./CarbonSDK");
|
|
51
|
-
Object.defineProperty(exports, "CarbonSDK", { enumerable: true, get: function () { return __importDefault(CarbonSDK_1).default; } });
|
|
52
|
-
var constant_1 = require("./constant");
|
|
53
|
-
Object.defineProperty(exports, "ProviderAgent", { enumerable: true, get: function () { return constant_1.ProviderAgent; } });
|
|
54
52
|
exports.Insights = __importStar(require("./insights"));
|
|
55
53
|
exports.Hydrogen = __importStar(require("./hydrogen"));
|
|
56
54
|
var wallet_1 = require("./wallet");
|
|
57
55
|
Object.defineProperty(exports, "CarbonLedgerSigner", { enumerable: true, get: function () { return wallet_1.CarbonLedgerSigner; } });
|
|
58
56
|
Object.defineProperty(exports, "CarbonPrivateKeySigner", { enumerable: true, get: function () { return wallet_1.CarbonPrivateKeySigner; } });
|
|
59
57
|
Object.defineProperty(exports, "CarbonNonSigner", { enumerable: true, get: function () { return wallet_1.CarbonNonSigner; } });
|
|
58
|
+
var CarbonSDK_1 = require("./CarbonSDK");
|
|
59
|
+
Object.defineProperty(exports, "CarbonSDK", { enumerable: true, get: function () { return __importDefault(CarbonSDK_1).default; } });
|
|
@@ -56,7 +56,7 @@ export declare class MetaMask {
|
|
|
56
56
|
static createMetamaskSigner(metamask: MetaMask, evmChainId: string, pubKeyBase64: string, addressOptions: SWTHAddressOptions): CarbonSigner;
|
|
57
57
|
static getNetworkParams(network: Network, blockchain?: EVMChain): MetaMaskChangeNetworkParam;
|
|
58
58
|
static getCarbonEvmNetworkParams(network: Network): MetaMaskChangeNetworkParam;
|
|
59
|
-
static getRequiredChainId(network: Network, blockchain?: BlockchainV2): 1 | 5 | 66 | 56 |
|
|
59
|
+
static getRequiredChainId(network: Network, blockchain?: BlockchainV2): 1 | 5 | 66 | 56 | 42161 | 137 | 97 | 421611 | 80001 | 65;
|
|
60
60
|
constructor(network: Network, legacyEip712SignMode?: boolean);
|
|
61
61
|
private checkProvider;
|
|
62
62
|
getBlockchain(): BlockchainV2;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StdSignDoc } from "@cosmjs/amino/build";
|
|
2
|
-
import { TypedDataDomain, TypedDataField } from "@ethersproject/abstract-signer";
|
|
3
|
-
import { TypeUtils } from ".";
|
|
4
2
|
import { Coin } from "@cosmjs/proto-signing";
|
|
3
|
+
import { TypedDataDomain, TypedDataField } from "@ethersproject/abstract-signer";
|
|
4
|
+
import { SimpleMap } from "./type";
|
|
5
5
|
export interface LegacyEIP712Tx {
|
|
6
|
-
readonly types:
|
|
6
|
+
readonly types: SimpleMap<TypedDataField[]>;
|
|
7
7
|
readonly primaryType: string;
|
|
8
8
|
readonly domain: TypedDataDomain;
|
|
9
9
|
readonly message: LegacyEIP712StdSignDoc;
|
package/lib/util/legacyEIP712.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.legacyConstructEIP712Tx = void 0;
|
|
7
|
-
const eip712_1 = require("../constant/eip712");
|
|
8
|
-
const ethermint_1 = require("../util/ethermint");
|
|
9
7
|
const codec_1 = require("../codec");
|
|
8
|
+
const eip712_1 = require("../constant/eip712");
|
|
10
9
|
const AminoTypesMap_1 = __importDefault(require("../provider/amino/AminoTypesMap"));
|
|
10
|
+
const ethermint_1 = require("../util/ethermint");
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
function getTypes(msgTypeUrl, aminoMsgValue) {
|
|
13
13
|
return Object.assign(Object.assign({}, eip712_1.LEGACY_DEFAULT_EIP712_TYPES), getMsgValueType(msgTypeUrl, aminoMsgValue, "MsgValue"));
|
package/lib/util/network.d.ts
CHANGED
package/lib/util/network.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseNetwork = void 0;
|
|
4
|
-
const
|
|
4
|
+
const network_1 = require("../constant/network");
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param network
|
|
8
8
|
* @param defaultNetwork
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
|
-
const parseNetwork = (network, defaultNetwork =
|
|
11
|
+
const parseNetwork = (network, defaultNetwork = network_1.DEFAULT_NETWORK) => {
|
|
12
12
|
var _a;
|
|
13
13
|
switch ((_a = network === null || network === void 0 ? void 0 : network.toLowerCase) === null || _a === void 0 ? void 0 : _a.call(network)) {
|
|
14
14
|
case "main":
|
|
15
15
|
case "mainnet":
|
|
16
|
-
return
|
|
16
|
+
return network_1.Network.MainNet;
|
|
17
17
|
case "test":
|
|
18
18
|
case "testnet":
|
|
19
|
-
return
|
|
19
|
+
return network_1.Network.TestNet;
|
|
20
20
|
case "dev":
|
|
21
21
|
case "devnet":
|
|
22
|
-
return
|
|
22
|
+
return network_1.Network.DevNet;
|
|
23
23
|
case "local":
|
|
24
24
|
case "localhost":
|
|
25
|
-
return
|
|
25
|
+
return network_1.Network.LocalHost;
|
|
26
26
|
}
|
|
27
27
|
return defaultNetwork;
|
|
28
28
|
};
|
package/lib/util/type.d.ts
CHANGED
package/lib/util/type.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isDurationType = exports.camelToSnake = exports.snakeToCamel = void 0;
|
|
7
|
-
const
|
|
7
|
+
const network_1 = require("../constant/network");
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
/**
|
|
10
10
|
* converts snakecase strings to camelcase
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-js-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-rc1",
|
|
4
4
|
"description": "TypeScript SDK for Carbon blockchain",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@cityofzion/neon-js": "^4.9.0",
|
|
43
43
|
"@cosmjs/stargate": "~0.29.5",
|
|
44
44
|
"@cosmos-kit/leap": "^0.13.14",
|
|
45
|
+
"@grpc/grpc-js": "^1.8.18",
|
|
45
46
|
"@keplr-wallet/stores": "^0.11.64",
|
|
46
47
|
"@keplr-wallet/types": "^0.11.64",
|
|
47
48
|
"@ledgerhq/cryptoassets": "^6.31.0",
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Network } from "../constant";
|
|
2
|
-
import { StdSignDoc } from "@cosmjs/amino";
|
|
3
|
-
import { BlockchainUtils } from "../util";
|
|
4
|
-
declare type SupportedBlockchains = BlockchainUtils.Blockchain.Canto | BlockchainUtils.Blockchain.Evmos;
|
|
5
|
-
declare namespace EvmIbcClient {
|
|
6
|
-
interface TypedDomain {
|
|
7
|
-
name: string;
|
|
8
|
-
version: string;
|
|
9
|
-
chainId: number;
|
|
10
|
-
verifyingContract: string;
|
|
11
|
-
salt: string;
|
|
12
|
-
}
|
|
13
|
-
interface TypedDataV4 {
|
|
14
|
-
types: object;
|
|
15
|
-
primaryType: string;
|
|
16
|
-
message: StdSignDoc;
|
|
17
|
-
domain: TypedDomain;
|
|
18
|
-
}
|
|
19
|
-
const TYPED_DATA_REQUEST_METHOD = "eth_signTypedData_v4";
|
|
20
|
-
const DEFAULT_EIP712_TYPES: {
|
|
21
|
-
EIP712Domain: {
|
|
22
|
-
name: string;
|
|
23
|
-
type: string;
|
|
24
|
-
}[];
|
|
25
|
-
Tx: {
|
|
26
|
-
name: string;
|
|
27
|
-
type: string;
|
|
28
|
-
}[];
|
|
29
|
-
Fee: {
|
|
30
|
-
name: string;
|
|
31
|
-
type: string;
|
|
32
|
-
}[];
|
|
33
|
-
Coin: {
|
|
34
|
-
name: string;
|
|
35
|
-
type: string;
|
|
36
|
-
}[];
|
|
37
|
-
Msg: {
|
|
38
|
-
name: string;
|
|
39
|
-
type: string;
|
|
40
|
-
}[];
|
|
41
|
-
};
|
|
42
|
-
const getEvmChainId: (blockchain: SupportedBlockchains, network?: Network) => 7700 | 9001;
|
|
43
|
-
const getIbcTransferTypes: () => {
|
|
44
|
-
MsgValue: {
|
|
45
|
-
name: string;
|
|
46
|
-
type: string;
|
|
47
|
-
}[];
|
|
48
|
-
TypeToken: {
|
|
49
|
-
name: string;
|
|
50
|
-
type: string;
|
|
51
|
-
}[];
|
|
52
|
-
TypeTimeoutHeight: {
|
|
53
|
-
name: string;
|
|
54
|
-
type: string;
|
|
55
|
-
}[];
|
|
56
|
-
EIP712Domain: {
|
|
57
|
-
name: string;
|
|
58
|
-
type: string;
|
|
59
|
-
}[];
|
|
60
|
-
Tx: {
|
|
61
|
-
name: string;
|
|
62
|
-
type: string;
|
|
63
|
-
}[];
|
|
64
|
-
Fee: {
|
|
65
|
-
name: string;
|
|
66
|
-
type: string;
|
|
67
|
-
}[];
|
|
68
|
-
Coin: {
|
|
69
|
-
name: string;
|
|
70
|
-
type: string;
|
|
71
|
-
}[];
|
|
72
|
-
Msg: {
|
|
73
|
-
name: string;
|
|
74
|
-
type: string;
|
|
75
|
-
}[];
|
|
76
|
-
};
|
|
77
|
-
const getCosmosWeb3Domain: (blockchain: SupportedBlockchains) => {
|
|
78
|
-
name: string;
|
|
79
|
-
version: string;
|
|
80
|
-
chainId: number;
|
|
81
|
-
verifyingContract: string;
|
|
82
|
-
salt: string;
|
|
83
|
-
};
|
|
84
|
-
const getEIP712TypedData: (tx: StdSignDoc, blockchain: SupportedBlockchains, types?: object, domain?: EvmIbcClient.TypedDomain, primaryType?: string) => TypedDataV4;
|
|
85
|
-
}
|
|
86
|
-
export default EvmIbcClient;
|