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
|
@@ -1,12 +1,12 @@
|
|
|
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/order.proto
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "
|
|
8
|
-
import { Coin } from "
|
|
9
|
-
import { Timestamp } from "
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
|
+
import { Coin } from "./cosmos/cosmos-sdk/proto/cosmos/base/v1beta1/coin";
|
|
9
|
+
import { Timestamp } from "./google/protobuf/timestamp";
|
|
10
10
|
export const protobufPackage = "coreum.dex.v1";
|
|
11
11
|
/** Side is order side. */
|
|
12
12
|
export var Side;
|
|
@@ -150,7 +150,7 @@ export const GoodTil = {
|
|
|
150
150
|
writer.uint32(8).uint64(message.goodTilBlockHeight);
|
|
151
151
|
}
|
|
152
152
|
if (message.goodTilBlockTime !== undefined) {
|
|
153
|
-
Timestamp.encode(toTimestamp(message.goodTilBlockTime), writer.uint32(18).fork()).
|
|
153
|
+
Timestamp.encode(toTimestamp(message.goodTilBlockTime), writer.uint32(18).fork()).join();
|
|
154
154
|
}
|
|
155
155
|
return writer;
|
|
156
156
|
},
|
|
@@ -337,13 +337,13 @@ export const Order = {
|
|
|
337
337
|
writer.uint32(90).string(message.remainingSpendableBalance);
|
|
338
338
|
}
|
|
339
339
|
if (message.goodTil !== undefined) {
|
|
340
|
-
GoodTil.encode(message.goodTil, writer.uint32(98).fork()).
|
|
340
|
+
GoodTil.encode(message.goodTil, writer.uint32(98).fork()).join();
|
|
341
341
|
}
|
|
342
342
|
if (message.timeInForce !== 0) {
|
|
343
343
|
writer.uint32(104).int32(message.timeInForce);
|
|
344
344
|
}
|
|
345
345
|
if (message.reserve !== undefined) {
|
|
346
|
-
Coin.encode(message.reserve, writer.uint32(114).fork()).
|
|
346
|
+
Coin.encode(message.reserve, writer.uint32(114).fork()).join();
|
|
347
347
|
}
|
|
348
348
|
return writer;
|
|
349
349
|
},
|
|
@@ -597,10 +597,10 @@ export const OrderData = {
|
|
|
597
597
|
writer.uint32(40).int32(message.side);
|
|
598
598
|
}
|
|
599
599
|
if (message.goodTil !== undefined) {
|
|
600
|
-
GoodTil.encode(message.goodTil, writer.uint32(50).fork()).
|
|
600
|
+
GoodTil.encode(message.goodTil, writer.uint32(50).fork()).join();
|
|
601
601
|
}
|
|
602
602
|
if (message.reserve !== undefined) {
|
|
603
|
-
Coin.encode(message.reserve, writer.uint32(58).fork()).
|
|
603
|
+
Coin.encode(message.reserve, writer.uint32(58).fork()).join();
|
|
604
604
|
}
|
|
605
605
|
return writer;
|
|
606
606
|
},
|
|
@@ -805,183 +805,6 @@ export const OrderBookData = {
|
|
|
805
805
|
return message;
|
|
806
806
|
},
|
|
807
807
|
};
|
|
808
|
-
function createBaseOrderBookRecord() {
|
|
809
|
-
return {
|
|
810
|
-
orderBookId: 0,
|
|
811
|
-
side: 0,
|
|
812
|
-
price: "",
|
|
813
|
-
orderSequence: 0,
|
|
814
|
-
orderId: "",
|
|
815
|
-
accountNumber: 0,
|
|
816
|
-
remainingBaseQuantity: "",
|
|
817
|
-
remainingSpendableBalance: "",
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
export const OrderBookRecord = {
|
|
821
|
-
encode(message, writer = new BinaryWriter()) {
|
|
822
|
-
if (message.orderBookId !== 0) {
|
|
823
|
-
writer.uint32(8).uint32(message.orderBookId);
|
|
824
|
-
}
|
|
825
|
-
if (message.side !== 0) {
|
|
826
|
-
writer.uint32(16).int32(message.side);
|
|
827
|
-
}
|
|
828
|
-
if (message.price !== "") {
|
|
829
|
-
writer.uint32(26).string(message.price);
|
|
830
|
-
}
|
|
831
|
-
if (message.orderSequence !== 0) {
|
|
832
|
-
writer.uint32(32).uint64(message.orderSequence);
|
|
833
|
-
}
|
|
834
|
-
if (message.orderId !== "") {
|
|
835
|
-
writer.uint32(42).string(message.orderId);
|
|
836
|
-
}
|
|
837
|
-
if (message.accountNumber !== 0) {
|
|
838
|
-
writer.uint32(48).uint64(message.accountNumber);
|
|
839
|
-
}
|
|
840
|
-
if (message.remainingBaseQuantity !== "") {
|
|
841
|
-
writer.uint32(58).string(message.remainingBaseQuantity);
|
|
842
|
-
}
|
|
843
|
-
if (message.remainingSpendableBalance !== "") {
|
|
844
|
-
writer.uint32(66).string(message.remainingSpendableBalance);
|
|
845
|
-
}
|
|
846
|
-
return writer;
|
|
847
|
-
},
|
|
848
|
-
decode(input, length) {
|
|
849
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
850
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
851
|
-
const message = createBaseOrderBookRecord();
|
|
852
|
-
while (reader.pos < end) {
|
|
853
|
-
const tag = reader.uint32();
|
|
854
|
-
switch (tag >>> 3) {
|
|
855
|
-
case 1: {
|
|
856
|
-
if (tag !== 8) {
|
|
857
|
-
break;
|
|
858
|
-
}
|
|
859
|
-
message.orderBookId = reader.uint32();
|
|
860
|
-
continue;
|
|
861
|
-
}
|
|
862
|
-
case 2: {
|
|
863
|
-
if (tag !== 16) {
|
|
864
|
-
break;
|
|
865
|
-
}
|
|
866
|
-
message.side = reader.int32();
|
|
867
|
-
continue;
|
|
868
|
-
}
|
|
869
|
-
case 3: {
|
|
870
|
-
if (tag !== 26) {
|
|
871
|
-
break;
|
|
872
|
-
}
|
|
873
|
-
message.price = reader.string();
|
|
874
|
-
continue;
|
|
875
|
-
}
|
|
876
|
-
case 4: {
|
|
877
|
-
if (tag !== 32) {
|
|
878
|
-
break;
|
|
879
|
-
}
|
|
880
|
-
message.orderSequence = longToNumber(reader.uint64());
|
|
881
|
-
continue;
|
|
882
|
-
}
|
|
883
|
-
case 5: {
|
|
884
|
-
if (tag !== 42) {
|
|
885
|
-
break;
|
|
886
|
-
}
|
|
887
|
-
message.orderId = reader.string();
|
|
888
|
-
continue;
|
|
889
|
-
}
|
|
890
|
-
case 6: {
|
|
891
|
-
if (tag !== 48) {
|
|
892
|
-
break;
|
|
893
|
-
}
|
|
894
|
-
message.accountNumber = longToNumber(reader.uint64());
|
|
895
|
-
continue;
|
|
896
|
-
}
|
|
897
|
-
case 7: {
|
|
898
|
-
if (tag !== 58) {
|
|
899
|
-
break;
|
|
900
|
-
}
|
|
901
|
-
message.remainingBaseQuantity = reader.string();
|
|
902
|
-
continue;
|
|
903
|
-
}
|
|
904
|
-
case 8: {
|
|
905
|
-
if (tag !== 66) {
|
|
906
|
-
break;
|
|
907
|
-
}
|
|
908
|
-
message.remainingSpendableBalance = reader.string();
|
|
909
|
-
continue;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
913
|
-
break;
|
|
914
|
-
}
|
|
915
|
-
reader.skip(tag & 7);
|
|
916
|
-
}
|
|
917
|
-
return message;
|
|
918
|
-
},
|
|
919
|
-
fromJSON(object) {
|
|
920
|
-
return {
|
|
921
|
-
orderBookId: isSet(object.orderBookId)
|
|
922
|
-
? globalThis.Number(object.orderBookId)
|
|
923
|
-
: 0,
|
|
924
|
-
side: isSet(object.side) ? sideFromJSON(object.side) : 0,
|
|
925
|
-
price: isSet(object.price) ? globalThis.String(object.price) : "",
|
|
926
|
-
orderSequence: isSet(object.orderSequence)
|
|
927
|
-
? globalThis.Number(object.orderSequence)
|
|
928
|
-
: 0,
|
|
929
|
-
orderId: isSet(object.orderId) ? globalThis.String(object.orderId) : "",
|
|
930
|
-
accountNumber: isSet(object.accountNumber)
|
|
931
|
-
? globalThis.Number(object.accountNumber)
|
|
932
|
-
: 0,
|
|
933
|
-
remainingBaseQuantity: isSet(object.remainingBaseQuantity)
|
|
934
|
-
? globalThis.String(object.remainingBaseQuantity)
|
|
935
|
-
: "",
|
|
936
|
-
remainingSpendableBalance: isSet(object.remainingSpendableBalance)
|
|
937
|
-
? globalThis.String(object.remainingSpendableBalance)
|
|
938
|
-
: "",
|
|
939
|
-
};
|
|
940
|
-
},
|
|
941
|
-
toJSON(message) {
|
|
942
|
-
const obj = {};
|
|
943
|
-
if (message.orderBookId !== 0) {
|
|
944
|
-
obj.orderBookId = Math.round(message.orderBookId);
|
|
945
|
-
}
|
|
946
|
-
if (message.side !== 0) {
|
|
947
|
-
obj.side = sideToJSON(message.side);
|
|
948
|
-
}
|
|
949
|
-
if (message.price !== "") {
|
|
950
|
-
obj.price = message.price;
|
|
951
|
-
}
|
|
952
|
-
if (message.orderSequence !== 0) {
|
|
953
|
-
obj.orderSequence = Math.round(message.orderSequence);
|
|
954
|
-
}
|
|
955
|
-
if (message.orderId !== "") {
|
|
956
|
-
obj.orderId = message.orderId;
|
|
957
|
-
}
|
|
958
|
-
if (message.accountNumber !== 0) {
|
|
959
|
-
obj.accountNumber = Math.round(message.accountNumber);
|
|
960
|
-
}
|
|
961
|
-
if (message.remainingBaseQuantity !== "") {
|
|
962
|
-
obj.remainingBaseQuantity = message.remainingBaseQuantity;
|
|
963
|
-
}
|
|
964
|
-
if (message.remainingSpendableBalance !== "") {
|
|
965
|
-
obj.remainingSpendableBalance = message.remainingSpendableBalance;
|
|
966
|
-
}
|
|
967
|
-
return obj;
|
|
968
|
-
},
|
|
969
|
-
create(base) {
|
|
970
|
-
return OrderBookRecord.fromPartial(base ?? {});
|
|
971
|
-
},
|
|
972
|
-
fromPartial(object) {
|
|
973
|
-
const message = createBaseOrderBookRecord();
|
|
974
|
-
message.orderBookId = object.orderBookId ?? 0;
|
|
975
|
-
message.side = object.side ?? 0;
|
|
976
|
-
message.price = object.price ?? "";
|
|
977
|
-
message.orderSequence = object.orderSequence ?? 0;
|
|
978
|
-
message.orderId = object.orderId ?? "";
|
|
979
|
-
message.accountNumber = object.accountNumber ?? 0;
|
|
980
|
-
message.remainingBaseQuantity = object.remainingBaseQuantity ?? "";
|
|
981
|
-
message.remainingSpendableBalance = object.remainingSpendableBalance ?? "";
|
|
982
|
-
return message;
|
|
983
|
-
},
|
|
984
|
-
};
|
|
985
808
|
function createBaseOrderBookRecordData() {
|
|
986
809
|
return {
|
|
987
810
|
orderId: "",
|
|
@@ -1094,13 +917,12 @@ export const OrderBookRecordData = {
|
|
|
1094
917
|
function toTimestamp(date) {
|
|
1095
918
|
const seconds = Math.trunc(date.getTime() / 1_000);
|
|
1096
919
|
const nanos = (date.getTime() % 1_000) * 1_000_000;
|
|
1097
|
-
return { seconds
|
|
920
|
+
return { seconds, nanos };
|
|
1098
921
|
}
|
|
1099
922
|
function fromTimestamp(t) {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
return new Date(Number(millis));
|
|
923
|
+
let millis = (t.seconds || 0) * 1_000;
|
|
924
|
+
millis += (t.nanos || 0) / 1_000_000;
|
|
925
|
+
return new globalThis.Date(millis);
|
|
1104
926
|
}
|
|
1105
927
|
function fromJsonTimestamp(o) {
|
|
1106
928
|
if (o instanceof globalThis.Date) {
|
|
@@ -1,12 +1,14 @@
|
|
|
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
|
/** Params keeps gov manageable parameters. */
|
|
5
5
|
export interface Params {
|
|
6
6
|
/** default_unified_ref_amount is the default approximate amount you need to buy 1USD, used to for tokens without custom value */
|
|
7
7
|
defaultUnifiedRefAmount: string;
|
|
8
|
-
/** price_tick_exponent is the exponent used
|
|
8
|
+
/** price_tick_exponent is the exponent used in price tick calculation formula */
|
|
9
9
|
priceTickExponent: number;
|
|
10
|
+
/** quantity_step_exponent is the exponent used in quantity step calculation formula */
|
|
11
|
+
quantityStepExponent: number;
|
|
10
12
|
/** max_orders_per_denom is the maximum number of orders per denom the user can have */
|
|
11
13
|
maxOrdersPerDenom: number;
|
|
12
14
|
/** order_reserve is the reserve required to save the order in the order book */
|
|
@@ -1,16 +1,17 @@
|
|
|
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/params.proto
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "
|
|
8
|
-
import { Coin } from "
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
|
+
import { Coin } from "./cosmos/cosmos-sdk/proto/cosmos/base/v1beta1/coin";
|
|
9
9
|
export const protobufPackage = "coreum.dex.v1";
|
|
10
10
|
function createBaseParams() {
|
|
11
11
|
return {
|
|
12
12
|
defaultUnifiedRefAmount: "",
|
|
13
13
|
priceTickExponent: 0,
|
|
14
|
+
quantityStepExponent: 0,
|
|
14
15
|
maxOrdersPerDenom: 0,
|
|
15
16
|
orderReserve: undefined,
|
|
16
17
|
};
|
|
@@ -23,11 +24,14 @@ export const Params = {
|
|
|
23
24
|
if (message.priceTickExponent !== 0) {
|
|
24
25
|
writer.uint32(16).int32(message.priceTickExponent);
|
|
25
26
|
}
|
|
27
|
+
if (message.quantityStepExponent !== 0) {
|
|
28
|
+
writer.uint32(40).int32(message.quantityStepExponent);
|
|
29
|
+
}
|
|
26
30
|
if (message.maxOrdersPerDenom !== 0) {
|
|
27
31
|
writer.uint32(24).uint64(message.maxOrdersPerDenom);
|
|
28
32
|
}
|
|
29
33
|
if (message.orderReserve !== undefined) {
|
|
30
|
-
Coin.encode(message.orderReserve, writer.uint32(34).fork()).
|
|
34
|
+
Coin.encode(message.orderReserve, writer.uint32(34).fork()).join();
|
|
31
35
|
}
|
|
32
36
|
return writer;
|
|
33
37
|
},
|
|
@@ -52,6 +56,13 @@ export const Params = {
|
|
|
52
56
|
message.priceTickExponent = reader.int32();
|
|
53
57
|
continue;
|
|
54
58
|
}
|
|
59
|
+
case 5: {
|
|
60
|
+
if (tag !== 40) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
message.quantityStepExponent = reader.int32();
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
55
66
|
case 3: {
|
|
56
67
|
if (tag !== 24) {
|
|
57
68
|
break;
|
|
@@ -82,6 +93,9 @@ export const Params = {
|
|
|
82
93
|
priceTickExponent: isSet(object.priceTickExponent)
|
|
83
94
|
? globalThis.Number(object.priceTickExponent)
|
|
84
95
|
: 0,
|
|
96
|
+
quantityStepExponent: isSet(object.quantityStepExponent)
|
|
97
|
+
? globalThis.Number(object.quantityStepExponent)
|
|
98
|
+
: 0,
|
|
85
99
|
maxOrdersPerDenom: isSet(object.maxOrdersPerDenom)
|
|
86
100
|
? globalThis.Number(object.maxOrdersPerDenom)
|
|
87
101
|
: 0,
|
|
@@ -98,6 +112,9 @@ export const Params = {
|
|
|
98
112
|
if (message.priceTickExponent !== 0) {
|
|
99
113
|
obj.priceTickExponent = Math.round(message.priceTickExponent);
|
|
100
114
|
}
|
|
115
|
+
if (message.quantityStepExponent !== 0) {
|
|
116
|
+
obj.quantityStepExponent = Math.round(message.quantityStepExponent);
|
|
117
|
+
}
|
|
101
118
|
if (message.maxOrdersPerDenom !== 0) {
|
|
102
119
|
obj.maxOrdersPerDenom = Math.round(message.maxOrdersPerDenom);
|
|
103
120
|
}
|
|
@@ -113,6 +130,7 @@ export const Params = {
|
|
|
113
130
|
const message = createBaseParams();
|
|
114
131
|
message.defaultUnifiedRefAmount = object.defaultUnifiedRefAmount ?? "";
|
|
115
132
|
message.priceTickExponent = object.priceTickExponent ?? 0;
|
|
133
|
+
message.quantityStepExponent = object.quantityStepExponent ?? 0;
|
|
116
134
|
message.maxOrdersPerDenom = object.maxOrdersPerDenom ?? 0;
|
|
117
135
|
message.orderReserve =
|
|
118
136
|
object.orderReserve !== undefined && object.orderReserve !== null
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from "
|
|
2
|
-
import { PageRequest, PageResponse } from "
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import { PageRequest, PageResponse } from "./cosmos/cosmos-sdk/proto/cosmos/base/query/v1beta1/pagination";
|
|
3
3
|
import { Order, OrderBookData, Side } from "./order";
|
|
4
4
|
import { Params } from "./params";
|
|
5
5
|
export declare const protobufPackage = "coreum.dex.v1";
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// protoc v6.32.0
|
|
5
5
|
// source: coreum-protos/dex/query.proto
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "
|
|
8
|
-
import { PageRequest, PageResponse, } from "
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
|
+
import { PageRequest, PageResponse, } from "./cosmos/cosmos-sdk/proto/cosmos/base/query/v1beta1/pagination";
|
|
9
9
|
import { Order, OrderBookData, sideFromJSON, sideToJSON } from "./order";
|
|
10
10
|
import { Params } from "./params";
|
|
11
11
|
export const protobufPackage = "coreum.dex.v1";
|
|
@@ -52,7 +52,7 @@ function createBaseQueryParamsResponse() {
|
|
|
52
52
|
export const QueryParamsResponse = {
|
|
53
53
|
encode(message, writer = new BinaryWriter()) {
|
|
54
54
|
if (message.params !== undefined) {
|
|
55
|
-
Params.encode(message.params, writer.uint32(10).fork()).
|
|
55
|
+
Params.encode(message.params, writer.uint32(10).fork()).join();
|
|
56
56
|
}
|
|
57
57
|
return writer;
|
|
58
58
|
},
|
|
@@ -176,7 +176,7 @@ function createBaseQueryOrderResponse() {
|
|
|
176
176
|
export const QueryOrderResponse = {
|
|
177
177
|
encode(message, writer = new BinaryWriter()) {
|
|
178
178
|
if (message.order !== undefined) {
|
|
179
|
-
Order.encode(message.order, writer.uint32(10).fork()).
|
|
179
|
+
Order.encode(message.order, writer.uint32(10).fork()).join();
|
|
180
180
|
}
|
|
181
181
|
return writer;
|
|
182
182
|
},
|
|
@@ -235,7 +235,7 @@ export const QueryOrdersRequest = {
|
|
|
235
235
|
writer.uint32(10).string(message.creator);
|
|
236
236
|
}
|
|
237
237
|
if (message.pagination !== undefined) {
|
|
238
|
-
PageRequest.encode(message.pagination, writer.uint32(18).fork()).
|
|
238
|
+
PageRequest.encode(message.pagination, writer.uint32(18).fork()).join();
|
|
239
239
|
}
|
|
240
240
|
return writer;
|
|
241
241
|
},
|
|
@@ -305,10 +305,10 @@ function createBaseQueryOrdersResponse() {
|
|
|
305
305
|
export const QueryOrdersResponse = {
|
|
306
306
|
encode(message, writer = new BinaryWriter()) {
|
|
307
307
|
for (const v of message.orders) {
|
|
308
|
-
Order.encode(v, writer.uint32(10).fork()).
|
|
308
|
+
Order.encode(v, writer.uint32(10).fork()).join();
|
|
309
309
|
}
|
|
310
310
|
if (message.pagination !== undefined) {
|
|
311
|
-
PageResponse.encode(message.pagination, writer.uint32(18).fork()).
|
|
311
|
+
PageResponse.encode(message.pagination, writer.uint32(18).fork()).join();
|
|
312
312
|
}
|
|
313
313
|
return writer;
|
|
314
314
|
},
|
|
@@ -380,7 +380,7 @@ function createBaseQueryOrderBooksRequest() {
|
|
|
380
380
|
export const QueryOrderBooksRequest = {
|
|
381
381
|
encode(message, writer = new BinaryWriter()) {
|
|
382
382
|
if (message.pagination !== undefined) {
|
|
383
|
-
PageRequest.encode(message.pagination, writer.uint32(10).fork()).
|
|
383
|
+
PageRequest.encode(message.pagination, writer.uint32(10).fork()).join();
|
|
384
384
|
}
|
|
385
385
|
return writer;
|
|
386
386
|
},
|
|
@@ -438,10 +438,10 @@ function createBaseQueryOrderBooksResponse() {
|
|
|
438
438
|
export const QueryOrderBooksResponse = {
|
|
439
439
|
encode(message, writer = new BinaryWriter()) {
|
|
440
440
|
for (const v of message.orderBooks) {
|
|
441
|
-
OrderBookData.encode(v, writer.uint32(10).fork()).
|
|
441
|
+
OrderBookData.encode(v, writer.uint32(10).fork()).join();
|
|
442
442
|
}
|
|
443
443
|
if (message.pagination !== undefined) {
|
|
444
|
-
PageResponse.encode(message.pagination, writer.uint32(18).fork()).
|
|
444
|
+
PageResponse.encode(message.pagination, writer.uint32(18).fork()).join();
|
|
445
445
|
}
|
|
446
446
|
return writer;
|
|
447
447
|
},
|
|
@@ -708,7 +708,7 @@ export const QueryOrderBookOrdersRequest = {
|
|
|
708
708
|
writer.uint32(24).int32(message.side);
|
|
709
709
|
}
|
|
710
710
|
if (message.pagination !== undefined) {
|
|
711
|
-
PageRequest.encode(message.pagination, writer.uint32(34).fork()).
|
|
711
|
+
PageRequest.encode(message.pagination, writer.uint32(34).fork()).join();
|
|
712
712
|
}
|
|
713
713
|
return writer;
|
|
714
714
|
},
|
|
@@ -806,10 +806,10 @@ function createBaseQueryOrderBookOrdersResponse() {
|
|
|
806
806
|
export const QueryOrderBookOrdersResponse = {
|
|
807
807
|
encode(message, writer = new BinaryWriter()) {
|
|
808
808
|
for (const v of message.orders) {
|
|
809
|
-
Order.encode(v, writer.uint32(10).fork()).
|
|
809
|
+
Order.encode(v, writer.uint32(10).fork()).join();
|
|
810
810
|
}
|
|
811
811
|
if (message.pagination !== undefined) {
|
|
812
|
-
PageResponse.encode(message.pagination, writer.uint32(18).fork()).
|
|
812
|
+
PageResponse.encode(message.pagination, writer.uint32(18).fork()).join();
|
|
813
813
|
}
|
|
814
814
|
return writer;
|
|
815
815
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from "
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
2
|
import { GoodTil, OrderType, Side, TimeInForce } from "./order";
|
|
3
3
|
import { Params } from "./params";
|
|
4
4
|
export declare const protobufPackage = "coreum.dex.v1";
|
|
@@ -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/tx.proto
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
8
|
import { GoodTil, orderTypeFromJSON, orderTypeToJSON, sideFromJSON, sideToJSON, timeInForceFromJSON, timeInForceToJSON, } from "./order";
|
|
9
9
|
import { Params } from "./params";
|
|
10
10
|
export const protobufPackage = "coreum.dex.v1";
|
|
@@ -17,7 +17,7 @@ export const MsgUpdateParams = {
|
|
|
17
17
|
writer.uint32(10).string(message.authority);
|
|
18
18
|
}
|
|
19
19
|
if (message.params !== undefined) {
|
|
20
|
-
Params.encode(message.params, writer.uint32(18).fork()).
|
|
20
|
+
Params.encode(message.params, writer.uint32(18).fork()).join();
|
|
21
21
|
}
|
|
22
22
|
return writer;
|
|
23
23
|
},
|
|
@@ -52,9 +52,7 @@ export const MsgUpdateParams = {
|
|
|
52
52
|
},
|
|
53
53
|
fromJSON(object) {
|
|
54
54
|
return {
|
|
55
|
-
authority: isSet(object.authority)
|
|
56
|
-
? globalThis.String(object.authority)
|
|
57
|
-
: "",
|
|
55
|
+
authority: isSet(object.authority) ? globalThis.String(object.authority) : "",
|
|
58
56
|
params: isSet(object.params) ? Params.fromJSON(object.params) : undefined,
|
|
59
57
|
};
|
|
60
58
|
},
|
|
@@ -74,10 +72,9 @@ export const MsgUpdateParams = {
|
|
|
74
72
|
fromPartial(object) {
|
|
75
73
|
const message = createBaseMsgUpdateParams();
|
|
76
74
|
message.authority = object.authority ?? "";
|
|
77
|
-
message.params =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: undefined;
|
|
75
|
+
message.params = (object.params !== undefined && object.params !== null)
|
|
76
|
+
? Params.fromPartial(object.params)
|
|
77
|
+
: undefined;
|
|
81
78
|
return message;
|
|
82
79
|
},
|
|
83
80
|
};
|
|
@@ -122,7 +119,7 @@ export const MsgPlaceOrder = {
|
|
|
122
119
|
writer.uint32(64).int32(message.side);
|
|
123
120
|
}
|
|
124
121
|
if (message.goodTil !== undefined) {
|
|
125
|
-
GoodTil.encode(message.goodTil, writer.uint32(74).fork()).
|
|
122
|
+
GoodTil.encode(message.goodTil, writer.uint32(74).fork()).join();
|
|
126
123
|
}
|
|
127
124
|
if (message.timeInForce !== 0) {
|
|
128
125
|
writer.uint32(80).int32(message.timeInForce);
|
|
@@ -219,23 +216,13 @@ export const MsgPlaceOrder = {
|
|
|
219
216
|
sender: isSet(object.sender) ? globalThis.String(object.sender) : "",
|
|
220
217
|
type: isSet(object.type) ? orderTypeFromJSON(object.type) : 0,
|
|
221
218
|
id: isSet(object.id) ? globalThis.String(object.id) : "",
|
|
222
|
-
baseDenom: isSet(object.baseDenom)
|
|
223
|
-
|
|
224
|
-
: "",
|
|
225
|
-
quoteDenom: isSet(object.quoteDenom)
|
|
226
|
-
? globalThis.String(object.quoteDenom)
|
|
227
|
-
: "",
|
|
219
|
+
baseDenom: isSet(object.baseDenom) ? globalThis.String(object.baseDenom) : "",
|
|
220
|
+
quoteDenom: isSet(object.quoteDenom) ? globalThis.String(object.quoteDenom) : "",
|
|
228
221
|
price: isSet(object.price) ? globalThis.String(object.price) : "",
|
|
229
|
-
quantity: isSet(object.quantity)
|
|
230
|
-
? globalThis.String(object.quantity)
|
|
231
|
-
: "",
|
|
222
|
+
quantity: isSet(object.quantity) ? globalThis.String(object.quantity) : "",
|
|
232
223
|
side: isSet(object.side) ? sideFromJSON(object.side) : 0,
|
|
233
|
-
goodTil: isSet(object.goodTil)
|
|
234
|
-
|
|
235
|
-
: undefined,
|
|
236
|
-
timeInForce: isSet(object.timeInForce)
|
|
237
|
-
? timeInForceFromJSON(object.timeInForce)
|
|
238
|
-
: 0,
|
|
224
|
+
goodTil: isSet(object.goodTil) ? GoodTil.fromJSON(object.goodTil) : undefined,
|
|
225
|
+
timeInForce: isSet(object.timeInForce) ? timeInForceFromJSON(object.timeInForce) : 0,
|
|
239
226
|
};
|
|
240
227
|
},
|
|
241
228
|
toJSON(message) {
|
|
@@ -285,10 +272,9 @@ export const MsgPlaceOrder = {
|
|
|
285
272
|
message.price = object.price ?? "";
|
|
286
273
|
message.quantity = object.quantity ?? "";
|
|
287
274
|
message.side = object.side ?? 0;
|
|
288
|
-
message.goodTil =
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
: undefined;
|
|
275
|
+
message.goodTil = (object.goodTil !== undefined && object.goodTil !== null)
|
|
276
|
+
? GoodTil.fromPartial(object.goodTil)
|
|
277
|
+
: undefined;
|
|
292
278
|
message.timeInForce = object.timeInForce ?? 0;
|
|
293
279
|
return message;
|
|
294
280
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coreum-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
4
4
|
"description": "JS/TS Library to to easily make use of the Coreum Blockchain",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rm -rf ./dist && npm run build:main && npm run build:module",
|
|
14
|
-
"test": "ts-node test.ts",
|
|
14
|
+
"test": "npx ts-node tests/client/calculateGas.test.ts",
|
|
15
|
+
"test:all": "npx ts-node tests/**/*.test.ts",
|
|
15
16
|
"build:main": "npx tsc -p tsconfig.json",
|
|
16
17
|
"build:module": "npx tsc -p tsconfig.module.json",
|
|
17
18
|
"generate:docs": "npx typedoc --plugin typedoc-plugin-missing-exports --plugin typedoc-plugin-markdown src/index.ts && rm ./docs/README.md"
|
package/tests/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Tests
|
|
2
|
+
|
|
3
|
+
This directory contains tests for the coreum-js package.
|
|
4
|
+
|
|
5
|
+
## Test Structure
|
|
6
|
+
|
|
7
|
+
- `client/` - Tests for the Client class
|
|
8
|
+
- `calculateGas.test.ts` - Tests for `calculateGas` and `getGasPrice` functions
|
|
9
|
+
|
|
10
|
+
## Running Tests
|
|
11
|
+
|
|
12
|
+
### Using ts-node (recommended)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx ts-node tests/client/calculateGas.test.ts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Using npm test
|
|
19
|
+
|
|
20
|
+
Update `package.json` to add a test script:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "npx ts-node tests/client/calculateGas.test.ts",
|
|
26
|
+
"test:all": "npx ts-node tests/**/*.test.ts"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then run:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm test
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Test Framework
|
|
38
|
+
|
|
39
|
+
The tests are written to work without external test frameworks, using a simple test runner. However, you can easily migrate to Jest, Mocha, or another framework if desired.
|
|
40
|
+
|
|
41
|
+
## Excluded from Build
|
|
42
|
+
|
|
43
|
+
Tests are automatically excluded from the build process:
|
|
44
|
+
- `tsconfig.json` excludes `tests/**/*` and `**/*.test.ts`
|
|
45
|
+
- `tsconfig.module.json` excludes `tests/**/*` and `**/*.test.ts`
|
|
46
|
+
- Only files in `src/` are included in the build
|
|
47
|
+
|
|
48
|
+
## Writing New Tests
|
|
49
|
+
|
|
50
|
+
1. Create test files with `.test.ts` extension
|
|
51
|
+
2. Place them in the `tests/` directory
|
|
52
|
+
3. Use the test utilities from existing test files as a template
|
|
53
|
+
4. Tests will automatically be excluded from builds
|
|
54
|
+
|
|
55
|
+
## Notes
|
|
56
|
+
|
|
57
|
+
- Some tests require a live RPC connection to the blockchain
|
|
58
|
+
- Tests that require RPC will be skipped if the connection is unavailable
|
|
59
|
+
- Mock implementations can be added for unit testing without RPC
|