carbon-js-sdk 0.2.13 → 0.2.14
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/codec/cdp/asset_params.d.ts +0 -11
- package/lib/codec/cdp/asset_params.js +1 -69
- package/lib/codec/coin/query.d.ts +0 -3
- package/lib/codec/coin/query.js +0 -6
- package/lib/codec/coin/token.d.ts +11 -0
- package/lib/codec/coin/token.js +65 -1
- package/lib/codec/cosmos/authz/v1beta1/authz.d.ts +19 -0
- package/lib/codec/cosmos/authz/v1beta1/authz.js +89 -1
- package/lib/codec/cosmos/authz/v1beta1/genesis.d.ts +1 -15
- package/lib/codec/cosmos/authz/v1beta1/genesis.js +7 -120
- package/lib/codec/cosmos/authz/v1beta1/query.d.ts +69 -1
- package/lib/codec/cosmos/authz/v1beta1/query.js +273 -1
- package/lib/codec/cosmos/bank/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/bank/v1beta1/export.js +3 -1
- package/lib/codec/cosmos/bank/v1beta1/query.d.ts +40 -0
- package/lib/codec/cosmos/bank/v1beta1/query.js +137 -1
- package/lib/codec/cosmos/base/snapshots/v1beta1/snapshot.d.ts +64 -0
- package/lib/codec/cosmos/base/snapshots/v1beta1/snapshot.js +343 -1
- package/lib/codec/cosmos/feegrant/v1beta1/query.d.ts +33 -0
- package/lib/codec/cosmos/feegrant/v1beta1/query.js +137 -1
- package/lib/codec/cosmos/tx/signing/v1beta1/signing.d.ts +13 -0
- package/lib/codec/cosmos/tx/signing/v1beta1/signing.js +18 -0
- package/lib/codec/cosmos/tx/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/tx/v1beta1/export.js +3 -1
- package/lib/codec/cosmos/tx/v1beta1/service.d.ts +50 -2
- package/lib/codec/cosmos/tx/v1beta1/service.js +176 -1
- package/lib/codec/index.d.ts +1 -6
- package/lib/codec/index.js +334 -347
- package/lib/codec/market/genesis.d.ts +1 -0
- package/lib/codec/market/genesis.js +19 -1
- package/lib/codec/misc/trade.d.ts +1 -0
- package/lib/codec/misc/trade.js +17 -0
- package/lib/util/tx.d.ts +0 -4
- package/lib/wallet/CarbonSigningClient.js +27 -2
- package/lib/websocket/models.d.ts +37 -21
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ export interface GenesisState {
|
|
|
12
12
|
/** params defines all the paramaters of the module. */
|
|
13
13
|
params?: Params;
|
|
14
14
|
controlledParams?: ControlledParams;
|
|
15
|
+
marketNameSequence: Long;
|
|
15
16
|
}
|
|
16
17
|
export declare const GenesisState: {
|
|
17
18
|
encode(message: GenesisState, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -9,7 +9,7 @@ const long_1 = __importDefault(require("long"));
|
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
10
|
const market_1 = require("../market/market");
|
|
11
11
|
exports.protobufPackage = "Switcheo.carbon.market";
|
|
12
|
-
const baseGenesisState = {};
|
|
12
|
+
const baseGenesisState = { marketNameSequence: long_1.default.ZERO };
|
|
13
13
|
exports.GenesisState = {
|
|
14
14
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
15
15
|
for (const v of message.markets) {
|
|
@@ -21,6 +21,9 @@ exports.GenesisState = {
|
|
|
21
21
|
if (message.controlledParams !== undefined) {
|
|
22
22
|
market_1.ControlledParams.encode(message.controlledParams, writer.uint32(26).fork()).ldelim();
|
|
23
23
|
}
|
|
24
|
+
if (!message.marketNameSequence.isZero()) {
|
|
25
|
+
writer.uint32(32).int64(message.marketNameSequence);
|
|
26
|
+
}
|
|
24
27
|
return writer;
|
|
25
28
|
},
|
|
26
29
|
decode(input, length) {
|
|
@@ -40,6 +43,9 @@ exports.GenesisState = {
|
|
|
40
43
|
case 3:
|
|
41
44
|
message.controlledParams = market_1.ControlledParams.decode(reader, reader.uint32());
|
|
42
45
|
break;
|
|
46
|
+
case 4:
|
|
47
|
+
message.marketNameSequence = reader.int64();
|
|
48
|
+
break;
|
|
43
49
|
default:
|
|
44
50
|
reader.skipType(tag & 7);
|
|
45
51
|
break;
|
|
@@ -59,6 +65,11 @@ exports.GenesisState = {
|
|
|
59
65
|
object.controlledParams !== undefined && object.controlledParams !== null
|
|
60
66
|
? market_1.ControlledParams.fromJSON(object.controlledParams)
|
|
61
67
|
: undefined;
|
|
68
|
+
message.marketNameSequence =
|
|
69
|
+
object.marketNameSequence !== undefined &&
|
|
70
|
+
object.marketNameSequence !== null
|
|
71
|
+
? long_1.default.fromString(object.marketNameSequence)
|
|
72
|
+
: long_1.default.ZERO;
|
|
62
73
|
return message;
|
|
63
74
|
},
|
|
64
75
|
toJSON(message) {
|
|
@@ -75,6 +86,8 @@ exports.GenesisState = {
|
|
|
75
86
|
(obj.controlledParams = message.controlledParams
|
|
76
87
|
? market_1.ControlledParams.toJSON(message.controlledParams)
|
|
77
88
|
: undefined);
|
|
89
|
+
message.marketNameSequence !== undefined &&
|
|
90
|
+
(obj.marketNameSequence = (message.marketNameSequence || long_1.default.ZERO).toString());
|
|
78
91
|
return obj;
|
|
79
92
|
},
|
|
80
93
|
fromPartial(object) {
|
|
@@ -89,6 +102,11 @@ exports.GenesisState = {
|
|
|
89
102
|
object.controlledParams !== undefined && object.controlledParams !== null
|
|
90
103
|
? market_1.ControlledParams.fromPartial(object.controlledParams)
|
|
91
104
|
: undefined;
|
|
105
|
+
message.marketNameSequence =
|
|
106
|
+
object.marketNameSequence !== undefined &&
|
|
107
|
+
object.marketNameSequence !== null
|
|
108
|
+
? long_1.default.fromValue(object.marketNameSequence)
|
|
109
|
+
: long_1.default.ZERO;
|
|
92
110
|
return message;
|
|
93
111
|
},
|
|
94
112
|
};
|
package/lib/codec/misc/trade.js
CHANGED
|
@@ -19,6 +19,7 @@ const baseAccountTrade = {
|
|
|
19
19
|
feeDenom: "",
|
|
20
20
|
address: "",
|
|
21
21
|
blockHeight: long_1.default.ZERO,
|
|
22
|
+
tradeId: long_1.default.UZERO,
|
|
22
23
|
};
|
|
23
24
|
exports.AccountTrade = {
|
|
24
25
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -52,6 +53,9 @@ exports.AccountTrade = {
|
|
|
52
53
|
if (message.blockCreatedAt !== undefined) {
|
|
53
54
|
timestamp_1.Timestamp.encode(toTimestamp(message.blockCreatedAt), writer.uint32(82).fork()).ldelim();
|
|
54
55
|
}
|
|
56
|
+
if (!message.tradeId.isZero()) {
|
|
57
|
+
writer.uint32(88).uint64(message.tradeId);
|
|
58
|
+
}
|
|
55
59
|
return writer;
|
|
56
60
|
},
|
|
57
61
|
decode(input, length) {
|
|
@@ -91,6 +95,9 @@ exports.AccountTrade = {
|
|
|
91
95
|
case 10:
|
|
92
96
|
message.blockCreatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
93
97
|
break;
|
|
98
|
+
case 11:
|
|
99
|
+
message.tradeId = reader.uint64();
|
|
100
|
+
break;
|
|
94
101
|
default:
|
|
95
102
|
reader.skipType(tag & 7);
|
|
96
103
|
break;
|
|
@@ -140,6 +147,10 @@ exports.AccountTrade = {
|
|
|
140
147
|
object.blockCreatedAt !== undefined && object.blockCreatedAt !== null
|
|
141
148
|
? fromJsonTimestamp(object.blockCreatedAt)
|
|
142
149
|
: undefined;
|
|
150
|
+
message.tradeId =
|
|
151
|
+
object.tradeId !== undefined && object.tradeId !== null
|
|
152
|
+
? long_1.default.fromString(object.tradeId)
|
|
153
|
+
: long_1.default.UZERO;
|
|
143
154
|
return message;
|
|
144
155
|
},
|
|
145
156
|
toJSON(message) {
|
|
@@ -156,6 +167,8 @@ exports.AccountTrade = {
|
|
|
156
167
|
(obj.blockHeight = (message.blockHeight || long_1.default.ZERO).toString());
|
|
157
168
|
message.blockCreatedAt !== undefined &&
|
|
158
169
|
(obj.blockCreatedAt = message.blockCreatedAt.toISOString());
|
|
170
|
+
message.tradeId !== undefined &&
|
|
171
|
+
(obj.tradeId = (message.tradeId || long_1.default.UZERO).toString());
|
|
159
172
|
return obj;
|
|
160
173
|
},
|
|
161
174
|
fromPartial(object) {
|
|
@@ -174,6 +187,10 @@ exports.AccountTrade = {
|
|
|
174
187
|
? long_1.default.fromValue(object.blockHeight)
|
|
175
188
|
: long_1.default.ZERO;
|
|
176
189
|
message.blockCreatedAt = (_j = object.blockCreatedAt) !== null && _j !== void 0 ? _j : undefined;
|
|
190
|
+
message.tradeId =
|
|
191
|
+
object.tradeId !== undefined && object.tradeId !== null
|
|
192
|
+
? long_1.default.fromValue(object.tradeId)
|
|
193
|
+
: long_1.default.UZERO;
|
|
177
194
|
return message;
|
|
178
195
|
},
|
|
179
196
|
};
|
package/lib/util/tx.d.ts
CHANGED
|
@@ -85,10 +85,6 @@ export declare const Types: {
|
|
|
85
85
|
SetMinGasPriceProposal: string;
|
|
86
86
|
RemoveMsgGasCostProposal: string;
|
|
87
87
|
RemoveMinGasPriceProposal: string;
|
|
88
|
-
MsgEnableSend: string;
|
|
89
|
-
MsgEnableSendResponse: string;
|
|
90
|
-
MsgDisableSend: string;
|
|
91
|
-
MsgDisableSendResponse: string;
|
|
92
88
|
MsgCreate: string;
|
|
93
89
|
MsgCreateResponse: string;
|
|
94
90
|
MsgBind: string;
|
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CarbonSigningClient = exports.makeSignDocAmino = void 0;
|
|
16
16
|
const codec_1 = require("../codec");
|
|
17
|
-
const signing_1 = require("../codec/cosmos/tx/signing/v1beta1/signing");
|
|
18
17
|
const tx_1 = require("../codec/cosmos/tx/v1beta1/tx");
|
|
19
18
|
const amino_1 = require("@cosmjs/amino");
|
|
20
19
|
const encoding_1 = require("@cosmjs/encoding");
|
|
@@ -23,6 +22,32 @@ const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
|
23
22
|
const stargate_1 = require("@cosmjs/stargate");
|
|
24
23
|
const long_1 = __importDefault(require("long"));
|
|
25
24
|
const provider_1 = require("../provider");
|
|
25
|
+
// Added SignMode enum from cosmjs-types to resolve build error
|
|
26
|
+
var SignMode;
|
|
27
|
+
(function (SignMode) {
|
|
28
|
+
/**
|
|
29
|
+
* SIGN_MODE_UNSPECIFIED - SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be
|
|
30
|
+
* rejected
|
|
31
|
+
*/
|
|
32
|
+
SignMode[SignMode["SIGN_MODE_UNSPECIFIED"] = 0] = "SIGN_MODE_UNSPECIFIED";
|
|
33
|
+
/**
|
|
34
|
+
* SIGN_MODE_DIRECT - SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is
|
|
35
|
+
* verified with raw bytes from Tx
|
|
36
|
+
*/
|
|
37
|
+
SignMode[SignMode["SIGN_MODE_DIRECT"] = 1] = "SIGN_MODE_DIRECT";
|
|
38
|
+
/**
|
|
39
|
+
* SIGN_MODE_TEXTUAL - SIGN_MODE_TEXTUAL is a future signing mode that will verify some
|
|
40
|
+
* human-readable textual representation on top of the binary representation
|
|
41
|
+
* from SIGN_MODE_DIRECT
|
|
42
|
+
*/
|
|
43
|
+
SignMode[SignMode["SIGN_MODE_TEXTUAL"] = 2] = "SIGN_MODE_TEXTUAL";
|
|
44
|
+
/**
|
|
45
|
+
* SIGN_MODE_LEGACY_AMINO_JSON - SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
|
|
46
|
+
* Amino JSON and will be removed in the future
|
|
47
|
+
*/
|
|
48
|
+
SignMode[SignMode["SIGN_MODE_LEGACY_AMINO_JSON"] = 127] = "SIGN_MODE_LEGACY_AMINO_JSON";
|
|
49
|
+
SignMode[SignMode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
50
|
+
})(SignMode || (SignMode = {}));
|
|
26
51
|
function makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight = 0) {
|
|
27
52
|
const timeoutHeightStr = typeof timeoutHeight === "number" ? timeoutHeight.toString(10) : timeoutHeight;
|
|
28
53
|
return {
|
|
@@ -101,7 +126,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
101
126
|
throw new Error("Failed to retrieve account from signer");
|
|
102
127
|
}
|
|
103
128
|
const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
|
|
104
|
-
const signMode =
|
|
129
|
+
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
105
130
|
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
|
106
131
|
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight !== null && timeoutHeight !== void 0 ? timeoutHeight : 0);
|
|
107
132
|
const { signature, signed } = yield signer.signAmino(signerAddress, signDoc);
|
|
@@ -2,6 +2,7 @@ export interface RecentTrade {
|
|
|
2
2
|
block_created_at: string;
|
|
3
3
|
block_height: number;
|
|
4
4
|
id: number;
|
|
5
|
+
liquidation?: string;
|
|
5
6
|
maker_address: string;
|
|
6
7
|
maker_fee_amount: string;
|
|
7
8
|
maker_fee_denom: string;
|
|
@@ -19,18 +20,19 @@ export interface RecentTrade {
|
|
|
19
20
|
export interface HistoryOrder {
|
|
20
21
|
address: string;
|
|
21
22
|
allocated_margin: string;
|
|
23
|
+
avg_filled_price: string;
|
|
22
24
|
available: string;
|
|
23
25
|
block_created_at: string;
|
|
24
26
|
block_height: number;
|
|
25
27
|
filled: string;
|
|
26
28
|
id: string;
|
|
27
29
|
initiator: string;
|
|
28
|
-
is_liquidation
|
|
29
|
-
is_post_only
|
|
30
|
-
is_reduce_only
|
|
30
|
+
is_liquidation?: boolean;
|
|
31
|
+
is_post_only?: boolean;
|
|
32
|
+
is_reduce_only?: boolean;
|
|
31
33
|
market: string;
|
|
32
|
-
order_id: string;
|
|
33
34
|
order_type: string;
|
|
35
|
+
pool_id?: number;
|
|
34
36
|
price: string;
|
|
35
37
|
quantity: string;
|
|
36
38
|
side: string;
|
|
@@ -39,47 +41,52 @@ export interface HistoryOrder {
|
|
|
39
41
|
time_in_force: string;
|
|
40
42
|
trigger_type: string;
|
|
41
43
|
triggered_block_height: number;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
referral_address?: string;
|
|
45
|
+
referral_commission?: number;
|
|
46
|
+
referral_kickback?: number;
|
|
44
47
|
}
|
|
45
48
|
export interface BaseHistoryOrder {
|
|
46
49
|
allocated_margin_amount: string;
|
|
47
50
|
allocated_margin_denom: string;
|
|
51
|
+
last_updated_block_height: number;
|
|
48
52
|
order: HistoryOrder;
|
|
53
|
+
username?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface BaseHistoryOrderEvent extends BaseHistoryOrder {
|
|
56
|
+
type?: string;
|
|
49
57
|
}
|
|
50
58
|
export interface Candlestick {
|
|
51
|
-
time:
|
|
59
|
+
time: string;
|
|
52
60
|
close: string;
|
|
61
|
+
market: string;
|
|
53
62
|
open: string;
|
|
54
63
|
high: string;
|
|
55
64
|
low: string;
|
|
56
65
|
volume: string;
|
|
57
66
|
quote_volume: string;
|
|
67
|
+
resolution: number;
|
|
58
68
|
}
|
|
59
69
|
export interface AccountTrade {
|
|
60
70
|
address: string;
|
|
61
|
-
base_precision: number;
|
|
62
71
|
block_created_at: string;
|
|
63
|
-
block_height:
|
|
72
|
+
block_height: number;
|
|
64
73
|
fee_amount: string;
|
|
65
74
|
fee_denom: string;
|
|
66
|
-
fee_precision: number;
|
|
67
|
-
id: number;
|
|
68
75
|
market: string;
|
|
69
76
|
order_id: string;
|
|
70
77
|
price: string;
|
|
71
78
|
quantity: string;
|
|
72
|
-
quote_precision: number;
|
|
73
79
|
side: string;
|
|
80
|
+
trade_id: number;
|
|
74
81
|
}
|
|
75
82
|
export interface Position {
|
|
76
83
|
market: string;
|
|
77
84
|
address: string;
|
|
78
85
|
trade_id: string;
|
|
79
86
|
side: string;
|
|
80
|
-
opened_block_height:
|
|
81
|
-
updated_block_height:
|
|
82
|
-
closed_block_height
|
|
87
|
+
opened_block_height: number;
|
|
88
|
+
updated_block_height: number;
|
|
89
|
+
closed_block_height?: number;
|
|
83
90
|
realized_pnl: string;
|
|
84
91
|
max_lots: string;
|
|
85
92
|
total_fee_amount: string;
|
|
@@ -89,7 +96,7 @@ export interface Position {
|
|
|
89
96
|
allocated_margin: string;
|
|
90
97
|
lots: string;
|
|
91
98
|
opened_at: string;
|
|
92
|
-
closed_at
|
|
99
|
+
closed_at?: string;
|
|
93
100
|
}
|
|
94
101
|
export interface MarketStat {
|
|
95
102
|
day_high: string;
|
|
@@ -103,18 +110,22 @@ export interface MarketStat {
|
|
|
103
110
|
last_price: string;
|
|
104
111
|
market: string;
|
|
105
112
|
market_type: string;
|
|
106
|
-
premium_rate
|
|
107
|
-
last_funding_at
|
|
108
|
-
open_interest
|
|
113
|
+
premium_rate: string;
|
|
114
|
+
last_funding_at: string;
|
|
115
|
+
open_interest: string;
|
|
109
116
|
}
|
|
110
117
|
export interface PriceLevel {
|
|
111
118
|
price: string;
|
|
112
119
|
quantity: string;
|
|
120
|
+
market?: string;
|
|
121
|
+
side?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface PriceLevelEvent extends PriceLevel {
|
|
124
|
+
type?: string;
|
|
113
125
|
}
|
|
114
126
|
export interface Leverage {
|
|
115
|
-
market
|
|
127
|
+
market?: string;
|
|
116
128
|
leverage: string;
|
|
117
|
-
originator?: string;
|
|
118
129
|
}
|
|
119
130
|
export interface Pool {
|
|
120
131
|
pool: {
|
|
@@ -141,6 +152,11 @@ export interface Commitment {
|
|
|
141
152
|
amount: string;
|
|
142
153
|
start_time: string;
|
|
143
154
|
end_time: string;
|
|
155
|
+
duration?: number;
|
|
156
|
+
is_locked: boolean;
|
|
144
157
|
commitment_power: string;
|
|
145
158
|
boost_factor: string;
|
|
146
159
|
}
|
|
160
|
+
export interface CommitmentEvent extends Commitment {
|
|
161
|
+
Type?: string;
|
|
162
|
+
}
|