coreum-js 2.18.11 → 2.20.0
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/dist/main/client/index.d.ts +34 -1
- package/dist/main/client/index.js +162 -0
- package/dist/main/coreum/dex/v1/cosmos/cosmos-sdk/proto/cosmos/msg/v1/msg.d.ts +1 -0
- package/dist/main/coreum/dex/v1/cosmos/cosmos-sdk/proto/cosmos/msg/v1/msg.js +10 -0
- package/dist/main/coreum/dex/v1/event.js +8 -28
- package/dist/main/coreum/dex/v1/genesis.d.ts +2 -1
- package/dist/main/coreum/dex/v1/genesis.js +57 -14
- package/dist/main/coreum/dex/v1/order.d.ts +3 -23
- package/dist/main/coreum/dex/v1/order.js +27 -205
- package/dist/main/coreum/dex/v1/params.d.ts +5 -3
- package/dist/main/coreum/dex/v1/params.js +25 -7
- package/dist/main/coreum/dex/v1/query.d.ts +2 -2
- package/dist/main/coreum/dex/v1/query.js +48 -48
- package/dist/main/coreum/dex/v1/tx.d.ts +1 -1
- package/dist/main/coreum/dex/v1/tx.js +31 -45
- package/dist/module/client/index.d.ts +34 -1
- package/dist/module/client/index.js +162 -0
- package/dist/module/coreum/dex/v1/cosmos/cosmos-sdk/proto/cosmos/msg/v1/msg.d.ts +1 -0
- package/dist/module/coreum/dex/v1/cosmos/cosmos-sdk/proto/cosmos/msg/v1/msg.js +7 -0
- package/dist/module/coreum/dex/v1/event.js +8 -28
- package/dist/module/coreum/dex/v1/genesis.d.ts +2 -1
- package/dist/module/coreum/dex/v1/genesis.js +51 -8
- package/dist/module/coreum/dex/v1/order.d.ts +3 -23
- package/dist/module/coreum/dex/v1/order.js +14 -192
- package/dist/module/coreum/dex/v1/params.d.ts +5 -3
- package/dist/module/coreum/dex/v1/params.js +23 -5
- package/dist/module/coreum/dex/v1/query.d.ts +2 -2
- package/dist/module/coreum/dex/v1/query.js +13 -13
- package/dist/module/coreum/dex/v1/tx.d.ts +1 -1
- package/dist/module/coreum/dex/v1/tx.js +17 -31
- package/package.json +3 -2
- package/tests/README.md +59 -0
- package/tests/client/calculateGas.test.ts +372 -0
|
@@ -9,9 +9,16 @@ import { COREUM_CONFIG } from "../types/coreum";
|
|
|
9
9
|
import { QueryClientImpl as FeeModelClient } from "../coreum/feemodel/v1/query";
|
|
10
10
|
import { Registry, } from "@cosmjs/proto-signing";
|
|
11
11
|
import { Tendermint37Client, WebsocketClient } from "@cosmjs/tendermint-rpc";
|
|
12
|
+
import { TxRaw } from "../cosmos";
|
|
13
|
+
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
|
|
14
|
+
import { ServiceClientImpl as TxServiceClient } from "cosmjs-types/cosmos/tx/v1beta1/service";
|
|
15
|
+
import { PubKey } from "cosmjs-types/cosmos/crypto/secp256k1/keys";
|
|
16
|
+
import { TxBody as TxBodyProto, AuthInfo as AuthInfoProto } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
12
17
|
import { ExtensionWallets } from "../types";
|
|
13
18
|
import { generateWalletFromMnemonic, generateMultisigFromPubkeys, } from "../utils";
|
|
14
19
|
import { GasPrice, QueryClient, StargateClient, calculateFee, createProtobufRpcClient, decodeCosmosSdkDecFromProto, defaultRegistryTypes, setupAuthExtension, setupFeegrantExtension, setupIbcExtension, setupMintExtension, setupStakingExtension, setupTxExtension, } from "@cosmjs/stargate";
|
|
20
|
+
import { toBech32 } from "@cosmjs/encoding";
|
|
21
|
+
import { sha256, ripemd160 } from "@cosmjs/crypto";
|
|
15
22
|
import { setupBankExtension, setupGovExtension, setupDistributionExtension, } from "../cosmos/extensions";
|
|
16
23
|
import EventEmitter from "eventemitter3";
|
|
17
24
|
import { parseSubscriptionEvents } from "../utils/event";
|
|
@@ -196,6 +203,73 @@ export class Client {
|
|
|
196
203
|
fee: calculateFee(total_gas_wanted, gasPrice),
|
|
197
204
|
};
|
|
198
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Calculates gas by simulating the transaction with a dummy signer.
|
|
208
|
+
* Similar to Go's CalculateGas function - works without a signing client.
|
|
209
|
+
*
|
|
210
|
+
* @param msgs Messages to simulate
|
|
211
|
+
* @param options Optional configuration
|
|
212
|
+
* @param options.fromAddress Address to simulate from (optional, uses dummy if not provided)
|
|
213
|
+
* @param options.gasAdjustment Multiplier for gas (default: 1.2)
|
|
214
|
+
* @returns The estimated gas amount
|
|
215
|
+
*/
|
|
216
|
+
async calculateGas(msgs, options) {
|
|
217
|
+
if (!this._queryClient) {
|
|
218
|
+
throw new Error("Query client not initialized. Call connect() first.");
|
|
219
|
+
}
|
|
220
|
+
const { fromAddress, gasAdjustment = 1.2 } = options || {};
|
|
221
|
+
// Use provided address or generate a valid dummy bech32 address
|
|
222
|
+
let simAddress;
|
|
223
|
+
if (fromAddress) {
|
|
224
|
+
simAddress = fromAddress;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Generate a valid bech32 address from a dummy hash
|
|
228
|
+
// This creates a valid address format that the RPC will accept
|
|
229
|
+
const dummyHash = sha256(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
|
|
230
|
+
const addressBytes = dummyHash.slice(0, 20); // Use first 20 bytes for address
|
|
231
|
+
simAddress = toBech32(this.config.chain_bech32_prefix, addressBytes);
|
|
232
|
+
}
|
|
233
|
+
// Get account info if address is provided and client is available
|
|
234
|
+
let accountNumber = 0;
|
|
235
|
+
let sequence = 0;
|
|
236
|
+
if (fromAddress && this._client) {
|
|
237
|
+
try {
|
|
238
|
+
const account = await this._client.getAccount(fromAddress);
|
|
239
|
+
accountNumber = account.accountNumber;
|
|
240
|
+
sequence = account.sequence;
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
// If account doesn't exist, use defaults (0, 0)
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// Build transaction for simulation
|
|
247
|
+
// Note: We'll derive the address from the dummy pubkey in _buildTxForSimulation
|
|
248
|
+
// to ensure the fee payer address matches the signer
|
|
249
|
+
const txBytes = await this._buildTxForSimulation(msgs, simAddress, // This will be overridden by derived address if not provided
|
|
250
|
+
accountNumber, sequence);
|
|
251
|
+
// Use tx service client to simulate
|
|
252
|
+
const rpcClient = createProtobufRpcClient(this._queryClient);
|
|
253
|
+
const txService = new TxServiceClient(rpcClient);
|
|
254
|
+
const simulateResponse = await txService.Simulate({
|
|
255
|
+
txBytes: txBytes,
|
|
256
|
+
});
|
|
257
|
+
if (!simulateResponse.gasInfo) {
|
|
258
|
+
throw new Error("Simulation failed: no gas info returned");
|
|
259
|
+
}
|
|
260
|
+
const gasUsed = Number(simulateResponse.gasInfo.gasUsed || 0);
|
|
261
|
+
const adjustedGas = Math.ceil(gasUsed * gasAdjustment);
|
|
262
|
+
return adjustedGas;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Gets the current gas price without transaction simulation.
|
|
266
|
+
* Equivalent to Go's GetGasPrice function.
|
|
267
|
+
*
|
|
268
|
+
* @returns GasPrice object
|
|
269
|
+
*/
|
|
270
|
+
async getGasPrice() {
|
|
271
|
+
return await this._getGasPrice();
|
|
272
|
+
}
|
|
199
273
|
/**
|
|
200
274
|
*
|
|
201
275
|
* @param transaction Transaction to be submitted
|
|
@@ -379,6 +453,94 @@ export class Client {
|
|
|
379
453
|
}
|
|
380
454
|
return GasPrice.fromString(`${gasPrice}${minGasPriceRes.minGasPrice?.denom || ""}`);
|
|
381
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* Builds a transaction for simulation with a dummy signer.
|
|
458
|
+
* Similar to Go's BuildTxForSimulation function.
|
|
459
|
+
*
|
|
460
|
+
* @private
|
|
461
|
+
* @param msgs Messages to simulate
|
|
462
|
+
* @param fromAddress Address to simulate from
|
|
463
|
+
* @param accountNumber Account number
|
|
464
|
+
* @param sequence Sequence number
|
|
465
|
+
* @returns Encoded transaction bytes ready for simulation
|
|
466
|
+
*/
|
|
467
|
+
async _buildTxForSimulation(msgs, fromAddress, accountNumber = 0, sequence = 0) {
|
|
468
|
+
if (!this._queryClient) {
|
|
469
|
+
throw new Error("Query client not initialized. Call connect() first.");
|
|
470
|
+
}
|
|
471
|
+
const registry = Client.getRegistry();
|
|
472
|
+
// Create dummy public key (33 bytes for secp256k1 compressed pubkey)
|
|
473
|
+
const dummyPubKeyBytes = new Uint8Array(33).fill(0);
|
|
474
|
+
dummyPubKeyBytes[0] = 0x02; // Set compression flag
|
|
475
|
+
const dummyPubKey = {
|
|
476
|
+
key: dummyPubKeyBytes,
|
|
477
|
+
};
|
|
478
|
+
// Derive address from the dummy pubkey to ensure consistency
|
|
479
|
+
// Cosmos SDK derives addresses as: RIPEMD160(SHA256(pubkey))
|
|
480
|
+
const pubkeyHash = sha256(dummyPubKeyBytes);
|
|
481
|
+
const addressBytes = ripemd160(pubkeyHash).slice(0, 20);
|
|
482
|
+
const derivedAddress = toBech32(this.config.chain_bech32_prefix, addressBytes);
|
|
483
|
+
// Use derived address to ensure fee payer matches signer
|
|
484
|
+
// This is important for simulation - the RPC expects consistency
|
|
485
|
+
const finalAddress = fromAddress || derivedAddress;
|
|
486
|
+
// Create dummy signer info
|
|
487
|
+
const signerInfo = {
|
|
488
|
+
publicKey: {
|
|
489
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
490
|
+
value: PubKey.encode(dummyPubKey).finish(),
|
|
491
|
+
},
|
|
492
|
+
modeInfo: {
|
|
493
|
+
single: {
|
|
494
|
+
mode: SignMode.SIGN_MODE_DIRECT,
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
sequence: BigInt(sequence),
|
|
498
|
+
};
|
|
499
|
+
// Create dummy fee
|
|
500
|
+
// Leave payer empty for simulation - RPC will use the first signer as payer
|
|
501
|
+
const fee = {
|
|
502
|
+
amount: [],
|
|
503
|
+
gasLimit: BigInt(0),
|
|
504
|
+
payer: "",
|
|
505
|
+
granter: "",
|
|
506
|
+
};
|
|
507
|
+
// Create auth info
|
|
508
|
+
const authInfo = {
|
|
509
|
+
signerInfos: [signerInfo],
|
|
510
|
+
fee: fee,
|
|
511
|
+
};
|
|
512
|
+
// Build the transaction body
|
|
513
|
+
const body = {
|
|
514
|
+
messages: msgs.map((msg) => {
|
|
515
|
+
// EncodeObject.value is already a Uint8Array, but we need to encode
|
|
516
|
+
// the message object itself using the registry
|
|
517
|
+
const encoded = registry.encode(msg);
|
|
518
|
+
return {
|
|
519
|
+
typeUrl: msg.typeUrl,
|
|
520
|
+
value: encoded,
|
|
521
|
+
};
|
|
522
|
+
}),
|
|
523
|
+
memo: "",
|
|
524
|
+
timeoutHeight: BigInt(0),
|
|
525
|
+
extensionOptions: [],
|
|
526
|
+
nonCriticalExtensionOptions: [],
|
|
527
|
+
};
|
|
528
|
+
// Encode body and auth info using protobuf encoders
|
|
529
|
+
const bodyBytes = TxBodyProto.encode(body).finish();
|
|
530
|
+
const authInfoBytes = AuthInfoProto.encode(authInfo).finish();
|
|
531
|
+
// Create dummy signature (64 bytes for secp256k1 signature)
|
|
532
|
+
const dummySignature = new Uint8Array(64).fill(0);
|
|
533
|
+
// Create TxRaw
|
|
534
|
+
const txRaw = {
|
|
535
|
+
bodyBytes: bodyBytes,
|
|
536
|
+
authInfoBytes: authInfoBytes,
|
|
537
|
+
signatures: [dummySignature],
|
|
538
|
+
};
|
|
539
|
+
// Serialize TxRaw to bytes for simulation
|
|
540
|
+
// TxRaw is already in the correct format, we just need to encode it
|
|
541
|
+
const txBytes = TxRaw.encode(txRaw).finish();
|
|
542
|
+
return txBytes;
|
|
543
|
+
}
|
|
382
544
|
_isSigningClientInit() {
|
|
383
545
|
if (!this._client || !isSigningClient(this._client))
|
|
384
546
|
throw new Error("Signing Client is not initialized");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const protobufPackage = "cosmos.msg.v1";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.
|
|
4
|
-
// protoc
|
|
3
|
+
// protoc-gen-ts_proto v2.7.0
|
|
4
|
+
// protoc v6.32.0
|
|
5
5
|
// source: coreum-protos/dex/event.proto
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
@@ -166,12 +166,8 @@ export const EventOrderReduced = {
|
|
|
166
166
|
creator: isSet(object.creator) ? globalThis.String(object.creator) : "",
|
|
167
167
|
id: isSet(object.id) ? globalThis.String(object.id) : "",
|
|
168
168
|
sequence: isSet(object.sequence) ? globalThis.Number(object.sequence) : 0,
|
|
169
|
-
sentCoin: isSet(object.sentCoin)
|
|
170
|
-
|
|
171
|
-
: "",
|
|
172
|
-
receivedCoin: isSet(object.receivedCoin)
|
|
173
|
-
? globalThis.String(object.receivedCoin)
|
|
174
|
-
: "",
|
|
169
|
+
sentCoin: isSet(object.sentCoin) ? globalThis.String(object.sentCoin) : "",
|
|
170
|
+
receivedCoin: isSet(object.receivedCoin) ? globalThis.String(object.receivedCoin) : "",
|
|
175
171
|
};
|
|
176
172
|
},
|
|
177
173
|
toJSON(message) {
|
|
@@ -207,13 +203,7 @@ export const EventOrderReduced = {
|
|
|
207
203
|
},
|
|
208
204
|
};
|
|
209
205
|
function createBaseEventOrderCreated() {
|
|
210
|
-
return {
|
|
211
|
-
creator: "",
|
|
212
|
-
id: "",
|
|
213
|
-
sequence: 0,
|
|
214
|
-
remainingBaseQuantity: "",
|
|
215
|
-
remainingSpendableBalance: "",
|
|
216
|
-
};
|
|
206
|
+
return { creator: "", id: "", sequence: 0, remainingBaseQuantity: "", remainingSpendableBalance: "" };
|
|
217
207
|
}
|
|
218
208
|
export const EventOrderCreated = {
|
|
219
209
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -289,9 +279,7 @@ export const EventOrderCreated = {
|
|
|
289
279
|
creator: isSet(object.creator) ? globalThis.String(object.creator) : "",
|
|
290
280
|
id: isSet(object.id) ? globalThis.String(object.id) : "",
|
|
291
281
|
sequence: isSet(object.sequence) ? globalThis.Number(object.sequence) : 0,
|
|
292
|
-
remainingBaseQuantity: isSet(object.remainingBaseQuantity)
|
|
293
|
-
? globalThis.String(object.remainingBaseQuantity)
|
|
294
|
-
: "",
|
|
282
|
+
remainingBaseQuantity: isSet(object.remainingBaseQuantity) ? globalThis.String(object.remainingBaseQuantity) : "",
|
|
295
283
|
remainingSpendableBalance: isSet(object.remainingSpendableBalance)
|
|
296
284
|
? globalThis.String(object.remainingSpendableBalance)
|
|
297
285
|
: "",
|
|
@@ -330,13 +318,7 @@ export const EventOrderCreated = {
|
|
|
330
318
|
},
|
|
331
319
|
};
|
|
332
320
|
function createBaseEventOrderClosed() {
|
|
333
|
-
return {
|
|
334
|
-
creator: "",
|
|
335
|
-
id: "",
|
|
336
|
-
sequence: 0,
|
|
337
|
-
remainingBaseQuantity: "",
|
|
338
|
-
remainingSpendableBalance: "",
|
|
339
|
-
};
|
|
321
|
+
return { creator: "", id: "", sequence: 0, remainingBaseQuantity: "", remainingSpendableBalance: "" };
|
|
340
322
|
}
|
|
341
323
|
export const EventOrderClosed = {
|
|
342
324
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -412,9 +394,7 @@ export const EventOrderClosed = {
|
|
|
412
394
|
creator: isSet(object.creator) ? globalThis.String(object.creator) : "",
|
|
413
395
|
id: isSet(object.id) ? globalThis.String(object.id) : "",
|
|
414
396
|
sequence: isSet(object.sequence) ? globalThis.Number(object.sequence) : 0,
|
|
415
|
-
remainingBaseQuantity: isSet(object.remainingBaseQuantity)
|
|
416
|
-
? globalThis.String(object.remainingBaseQuantity)
|
|
417
|
-
: "",
|
|
397
|
+
remainingBaseQuantity: isSet(object.remainingBaseQuantity) ? globalThis.String(object.remainingBaseQuantity) : "",
|
|
418
398
|
remainingSpendableBalance: isSet(object.remainingSpendableBalance)
|
|
419
399
|
? globalThis.String(object.remainingSpendableBalance)
|
|
420
400
|
: "",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from "
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
2
|
import { Order, OrderBookData } from "./order";
|
|
3
3
|
import { Params } from "./params";
|
|
4
4
|
export declare const protobufPackage = "coreum.dex.v1";
|
|
@@ -11,6 +11,7 @@ export interface GenesisState {
|
|
|
11
11
|
/** order_sequence is current order sequence; */
|
|
12
12
|
orderSequence: number;
|
|
13
13
|
accountsDenomsOrdersCounts: AccountDenomOrdersCount[];
|
|
14
|
+
reservedOrderIds: Uint8Array[];
|
|
14
15
|
}
|
|
15
16
|
/** OrderBookDataWithID is a order book data with it's corresponding ID. */
|
|
16
17
|
export interface OrderBookDataWithID {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.
|
|
4
|
-
// protoc
|
|
3
|
+
// protoc-gen-ts_proto v2.7.0
|
|
4
|
+
// protoc v6.32.0
|
|
5
5
|
// source: coreum-protos/dex/genesis.proto
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
8
|
import { Order, OrderBookData } from "./order";
|
|
9
9
|
import { Params } from "./params";
|
|
10
10
|
export const protobufPackage = "coreum.dex.v1";
|
|
@@ -15,24 +15,28 @@ function createBaseGenesisState() {
|
|
|
15
15
|
orders: [],
|
|
16
16
|
orderSequence: 0,
|
|
17
17
|
accountsDenomsOrdersCounts: [],
|
|
18
|
+
reservedOrderIds: [],
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export const GenesisState = {
|
|
21
22
|
encode(message, writer = new BinaryWriter()) {
|
|
22
23
|
if (message.params !== undefined) {
|
|
23
|
-
Params.encode(message.params, writer.uint32(10).fork()).
|
|
24
|
+
Params.encode(message.params, writer.uint32(10).fork()).join();
|
|
24
25
|
}
|
|
25
26
|
for (const v of message.orderBooks) {
|
|
26
|
-
OrderBookDataWithID.encode(v, writer.uint32(18).fork()).
|
|
27
|
+
OrderBookDataWithID.encode(v, writer.uint32(18).fork()).join();
|
|
27
28
|
}
|
|
28
29
|
for (const v of message.orders) {
|
|
29
|
-
Order.encode(v, writer.uint32(26).fork()).
|
|
30
|
+
Order.encode(v, writer.uint32(26).fork()).join();
|
|
30
31
|
}
|
|
31
32
|
if (message.orderSequence !== 0) {
|
|
32
33
|
writer.uint32(32).uint64(message.orderSequence);
|
|
33
34
|
}
|
|
34
35
|
for (const v of message.accountsDenomsOrdersCounts) {
|
|
35
|
-
AccountDenomOrdersCount.encode(v, writer.uint32(42).fork()).
|
|
36
|
+
AccountDenomOrdersCount.encode(v, writer.uint32(42).fork()).join();
|
|
37
|
+
}
|
|
38
|
+
for (const v of message.reservedOrderIds) {
|
|
39
|
+
writer.uint32(50).bytes(v);
|
|
36
40
|
}
|
|
37
41
|
return writer;
|
|
38
42
|
},
|
|
@@ -78,6 +82,13 @@ export const GenesisState = {
|
|
|
78
82
|
message.accountsDenomsOrdersCounts.push(AccountDenomOrdersCount.decode(reader, reader.uint32()));
|
|
79
83
|
continue;
|
|
80
84
|
}
|
|
85
|
+
case 6: {
|
|
86
|
+
if (tag !== 50) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
message.reservedOrderIds.push(reader.bytes());
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
if ((tag & 7) === 4 || tag === 0) {
|
|
83
94
|
break;
|
|
@@ -101,6 +112,9 @@ export const GenesisState = {
|
|
|
101
112
|
accountsDenomsOrdersCounts: globalThis.Array.isArray(object?.accountsDenomsOrdersCounts)
|
|
102
113
|
? object.accountsDenomsOrdersCounts.map((e) => AccountDenomOrdersCount.fromJSON(e))
|
|
103
114
|
: [],
|
|
115
|
+
reservedOrderIds: globalThis.Array.isArray(object?.reservedOrderIds)
|
|
116
|
+
? object.reservedOrderIds.map((e) => bytesFromBase64(e))
|
|
117
|
+
: [],
|
|
104
118
|
};
|
|
105
119
|
},
|
|
106
120
|
toJSON(message) {
|
|
@@ -120,6 +134,9 @@ export const GenesisState = {
|
|
|
120
134
|
if (message.accountsDenomsOrdersCounts?.length) {
|
|
121
135
|
obj.accountsDenomsOrdersCounts = message.accountsDenomsOrdersCounts.map((e) => AccountDenomOrdersCount.toJSON(e));
|
|
122
136
|
}
|
|
137
|
+
if (message.reservedOrderIds?.length) {
|
|
138
|
+
obj.reservedOrderIds = message.reservedOrderIds.map((e) => base64FromBytes(e));
|
|
139
|
+
}
|
|
123
140
|
return obj;
|
|
124
141
|
},
|
|
125
142
|
create(base) {
|
|
@@ -137,6 +154,7 @@ export const GenesisState = {
|
|
|
137
154
|
message.orderSequence = object.orderSequence ?? 0;
|
|
138
155
|
message.accountsDenomsOrdersCounts =
|
|
139
156
|
object.accountsDenomsOrdersCounts?.map((e) => AccountDenomOrdersCount.fromPartial(e)) || [];
|
|
157
|
+
message.reservedOrderIds = object.reservedOrderIds?.map((e) => e) || [];
|
|
140
158
|
return message;
|
|
141
159
|
},
|
|
142
160
|
};
|
|
@@ -149,7 +167,7 @@ export const OrderBookDataWithID = {
|
|
|
149
167
|
writer.uint32(8).uint32(message.id);
|
|
150
168
|
}
|
|
151
169
|
if (message.data !== undefined) {
|
|
152
|
-
OrderBookData.encode(message.data, writer.uint32(18).fork()).
|
|
170
|
+
OrderBookData.encode(message.data, writer.uint32(18).fork()).join();
|
|
153
171
|
}
|
|
154
172
|
return writer;
|
|
155
173
|
},
|
|
@@ -300,6 +318,31 @@ export const AccountDenomOrdersCount = {
|
|
|
300
318
|
return message;
|
|
301
319
|
},
|
|
302
320
|
};
|
|
321
|
+
function bytesFromBase64(b64) {
|
|
322
|
+
if (globalThis.Buffer) {
|
|
323
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
const bin = globalThis.atob(b64);
|
|
327
|
+
const arr = new Uint8Array(bin.length);
|
|
328
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
329
|
+
arr[i] = bin.charCodeAt(i);
|
|
330
|
+
}
|
|
331
|
+
return arr;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function base64FromBytes(arr) {
|
|
335
|
+
if (globalThis.Buffer) {
|
|
336
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
const bin = [];
|
|
340
|
+
arr.forEach((byte) => {
|
|
341
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
342
|
+
});
|
|
343
|
+
return globalThis.btoa(bin.join(""));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
303
346
|
function longToNumber(int64) {
|
|
304
347
|
const num = globalThis.Number(int64.toString());
|
|
305
348
|
if (num > globalThis.Number.MAX_SAFE_INTEGER) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from "
|
|
2
|
-
import { Coin } from "
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import { Coin } from "./cosmos/cosmos-sdk/proto/cosmos/base/v1beta1/coin";
|
|
3
3
|
export declare const protobufPackage = "coreum.dex.v1";
|
|
4
4
|
/** Side is order side. */
|
|
5
5
|
export declare enum Side {
|
|
@@ -45,7 +45,7 @@ export declare function timeInForceToJSON(object: TimeInForce): string;
|
|
|
45
45
|
/** GoodTil is a good til order settings. */
|
|
46
46
|
export interface GoodTil {
|
|
47
47
|
/** good_til_block_height means that order remains active until a specific blockchain block height is reached. */
|
|
48
|
-
goodTilBlockHeight: number
|
|
48
|
+
goodTilBlockHeight: number;
|
|
49
49
|
/** good_til_block_time means that order remains active until a specific blockchain block time is reached. */
|
|
50
50
|
goodTilBlockTime: Date | undefined;
|
|
51
51
|
}
|
|
@@ -114,25 +114,6 @@ export interface OrderBookData {
|
|
|
114
114
|
/** quote_denom is quote order book denom */
|
|
115
115
|
quoteDenom: string;
|
|
116
116
|
}
|
|
117
|
-
/** OrderBookRecord is a single order book record, it combines both key and value from the store. */
|
|
118
|
-
export interface OrderBookRecord {
|
|
119
|
-
/** order_book_id is order book ID. */
|
|
120
|
-
orderBookId: number;
|
|
121
|
-
/** side is order side. */
|
|
122
|
-
side: Side;
|
|
123
|
-
/** price is order book record price. */
|
|
124
|
-
price: string;
|
|
125
|
-
/** order_sequence is order sequence. */
|
|
126
|
-
orderSequence: number;
|
|
127
|
-
/** order ID provided by the creator. */
|
|
128
|
-
orderId: string;
|
|
129
|
-
/** account_number is account number which corresponds the order creator. */
|
|
130
|
-
accountNumber: number;
|
|
131
|
-
/** remaining_base_quantity - is remaining quantity of base denom which user wants to sell or buy. */
|
|
132
|
-
remainingBaseQuantity: string;
|
|
133
|
-
/** remaining_spendable_balance - is balance up to which user wants to spend to execute the order. */
|
|
134
|
-
remainingSpendableBalance: string;
|
|
135
|
-
}
|
|
136
117
|
/** OrderBookRecordData is a single order book record used for the store. */
|
|
137
118
|
export interface OrderBookRecordData {
|
|
138
119
|
/** order ID provided by the creator. */
|
|
@@ -149,7 +130,6 @@ export declare const CancelGoodTil: MessageFns<CancelGoodTil>;
|
|
|
149
130
|
export declare const Order: MessageFns<Order>;
|
|
150
131
|
export declare const OrderData: MessageFns<OrderData>;
|
|
151
132
|
export declare const OrderBookData: MessageFns<OrderBookData>;
|
|
152
|
-
export declare const OrderBookRecord: MessageFns<OrderBookRecord>;
|
|
153
133
|
export declare const OrderBookRecordData: MessageFns<OrderBookRecordData>;
|
|
154
134
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
155
135
|
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|