ault-sdk-ts 0.0.2-alpha.23 → 0.0.2-alpha.25
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/README.md +32 -7
- package/dist/agent/sign-and-broadcast.d.ts +10 -3
- package/dist/agent/tx/clob.d.ts +1 -1
- package/dist/agent/tx-executor.d.ts +9 -1
- package/dist/client.d.ts +2 -7
- package/dist/core/clob-gas.d.ts +22 -0
- package/dist/core/clob-responses.d.ts +19 -0
- package/dist/core/errors.d.ts +13 -0
- package/dist/core/network.d.ts +3 -2
- package/dist/eip712/sign-and-broadcast.d.ts +19 -4
- package/dist/high-level/tx-executor.d.ts +9 -1
- package/dist/high-level/types.d.ts +146 -62
- package/dist/high-level-client.d.ts +1 -1
- package/dist/index.cjs +878 -269
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +875 -267
- package/dist/index.js.map +1 -1
- package/dist/proto/tx-decode.d.ts +18 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -98,6 +98,7 @@ __export(index_exports, {
|
|
|
98
98
|
ManifestUrlsSchema: () => ManifestUrlsSchema,
|
|
99
99
|
MarketId: () => MarketId,
|
|
100
100
|
MarketType: () => MarketType,
|
|
101
|
+
MissingMsgResponseError: () => MissingMsgResponseError,
|
|
101
102
|
NETWORKS: () => NETWORKS,
|
|
102
103
|
NetworkError: () => NetworkError,
|
|
103
104
|
OrderId: () => OrderId,
|
|
@@ -438,6 +439,16 @@ var TxConfirmationUnavailableError = class extends TxError {
|
|
|
438
439
|
this.name = "TxConfirmationUnavailableError";
|
|
439
440
|
}
|
|
440
441
|
};
|
|
442
|
+
var MissingMsgResponseError = class extends Error {
|
|
443
|
+
constructor(typeUrl, txHash) {
|
|
444
|
+
super(
|
|
445
|
+
`Transaction committed but the expected msg response ${typeUrl} was missing` + (txHash ? ` (txHash ${txHash}); re-query by hash to recover it.` : ".")
|
|
446
|
+
);
|
|
447
|
+
this.name = "MissingMsgResponseError";
|
|
448
|
+
this.typeUrl = typeUrl;
|
|
449
|
+
this.txHash = txHash;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
441
452
|
function formatTxErrorMessage(params) {
|
|
442
453
|
const head = `Transaction ${params.txHash} failed (code ${params.code})`;
|
|
443
454
|
return params.rawLog ? `${head}: ${params.rawLog}` : `${head}.`;
|
|
@@ -715,7 +726,7 @@ var GAS_CONSTANTS = {
|
|
|
715
726
|
APPROVE_BUILDER: 81e3,
|
|
716
727
|
REVOKE_BUILDER: 57e3,
|
|
717
728
|
SET_REFERRAL_CODE: 76e3,
|
|
718
|
-
SET_REFERRAL:
|
|
729
|
+
SET_REFERRAL: 8e4,
|
|
719
730
|
// CLOB module — mirror the chain's x/clob MinGasLimit* (agent_msg.go) exactly:
|
|
720
731
|
// the agent ante enforces MinGasLimit ≤ gas ≤ MinGasLimit×1.2, so any drift
|
|
721
732
|
// makes the SDK over- or under-shoot that window.
|
|
@@ -724,7 +735,10 @@ var GAS_CONSTANTS = {
|
|
|
724
735
|
SCALE_ORDER_BASE: 115e3,
|
|
725
736
|
SCALE_ORDER_PER_SUB: 13e3,
|
|
726
737
|
CANCEL_ORDER_BASE: 5e4,
|
|
727
|
-
CANCEL_ORDER_PER_ID:
|
|
738
|
+
CANCEL_ORDER_PER_ID: 13e3,
|
|
739
|
+
// MsgModifyOrders is gas-per-order with no base (chain MinGasPerModifyOrder).
|
|
740
|
+
// Mirrored for parity; no high-level/agent method consumes it yet.
|
|
741
|
+
MODIFY_ORDER_PER_ID: 113e3,
|
|
728
742
|
// Accountx module
|
|
729
743
|
OPEN_ACCOUNT: 96e3,
|
|
730
744
|
// Staking module (cosmos-sdk standard, NOT fee-free — user pays gas).
|
|
@@ -15546,6 +15560,74 @@ var MsgPlaceLimitOrder = {
|
|
|
15546
15560
|
return message;
|
|
15547
15561
|
}
|
|
15548
15562
|
};
|
|
15563
|
+
function createBaseMsgPlaceLimitOrderResponse() {
|
|
15564
|
+
return { orderId: new Uint8Array(0), escrowedAmount: void 0 };
|
|
15565
|
+
}
|
|
15566
|
+
var MsgPlaceLimitOrderResponse = {
|
|
15567
|
+
encode(message, writer = new import_wire37.BinaryWriter()) {
|
|
15568
|
+
if (message.orderId.length !== 0) {
|
|
15569
|
+
writer.uint32(10).bytes(message.orderId);
|
|
15570
|
+
}
|
|
15571
|
+
if (message.escrowedAmount !== void 0) {
|
|
15572
|
+
Coin.encode(message.escrowedAmount, writer.uint32(18).fork()).join();
|
|
15573
|
+
}
|
|
15574
|
+
return writer;
|
|
15575
|
+
},
|
|
15576
|
+
decode(input, length) {
|
|
15577
|
+
const reader = input instanceof import_wire37.BinaryReader ? input : new import_wire37.BinaryReader(input);
|
|
15578
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15579
|
+
const message = createBaseMsgPlaceLimitOrderResponse();
|
|
15580
|
+
while (reader.pos < end) {
|
|
15581
|
+
const tag = reader.uint32();
|
|
15582
|
+
switch (tag >>> 3) {
|
|
15583
|
+
case 1: {
|
|
15584
|
+
if (tag !== 10) {
|
|
15585
|
+
break;
|
|
15586
|
+
}
|
|
15587
|
+
message.orderId = reader.bytes();
|
|
15588
|
+
continue;
|
|
15589
|
+
}
|
|
15590
|
+
case 2: {
|
|
15591
|
+
if (tag !== 18) {
|
|
15592
|
+
break;
|
|
15593
|
+
}
|
|
15594
|
+
message.escrowedAmount = Coin.decode(reader, reader.uint32());
|
|
15595
|
+
continue;
|
|
15596
|
+
}
|
|
15597
|
+
}
|
|
15598
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15599
|
+
break;
|
|
15600
|
+
}
|
|
15601
|
+
reader.skip(tag & 7);
|
|
15602
|
+
}
|
|
15603
|
+
return message;
|
|
15604
|
+
},
|
|
15605
|
+
fromJSON(object2) {
|
|
15606
|
+
return {
|
|
15607
|
+
orderId: isSet35(object2.orderId) ? bytesFromBase648(object2.orderId) : isSet35(object2.order_id) ? bytesFromBase648(object2.order_id) : new Uint8Array(0),
|
|
15608
|
+
escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0
|
|
15609
|
+
};
|
|
15610
|
+
},
|
|
15611
|
+
toJSON(message) {
|
|
15612
|
+
const obj = {};
|
|
15613
|
+
if (message.orderId.length !== 0) {
|
|
15614
|
+
obj.orderId = base64FromBytes8(message.orderId);
|
|
15615
|
+
}
|
|
15616
|
+
if (message.escrowedAmount !== void 0) {
|
|
15617
|
+
obj.escrowedAmount = Coin.toJSON(message.escrowedAmount);
|
|
15618
|
+
}
|
|
15619
|
+
return obj;
|
|
15620
|
+
},
|
|
15621
|
+
create(base) {
|
|
15622
|
+
return MsgPlaceLimitOrderResponse.fromPartial(base ?? {});
|
|
15623
|
+
},
|
|
15624
|
+
fromPartial(object2) {
|
|
15625
|
+
const message = createBaseMsgPlaceLimitOrderResponse();
|
|
15626
|
+
message.orderId = object2.orderId ?? new Uint8Array(0);
|
|
15627
|
+
message.escrowedAmount = object2.escrowedAmount !== void 0 && object2.escrowedAmount !== null ? Coin.fromPartial(object2.escrowedAmount) : void 0;
|
|
15628
|
+
return message;
|
|
15629
|
+
}
|
|
15630
|
+
};
|
|
15549
15631
|
function createBaseMsgPlaceMarketOrder() {
|
|
15550
15632
|
return {
|
|
15551
15633
|
sender: "",
|
|
@@ -15713,6 +15795,74 @@ var MsgPlaceMarketOrder = {
|
|
|
15713
15795
|
return message;
|
|
15714
15796
|
}
|
|
15715
15797
|
};
|
|
15798
|
+
function createBaseMsgPlaceMarketOrderResponse() {
|
|
15799
|
+
return { orderId: new Uint8Array(0), escrowedAmount: void 0 };
|
|
15800
|
+
}
|
|
15801
|
+
var MsgPlaceMarketOrderResponse = {
|
|
15802
|
+
encode(message, writer = new import_wire37.BinaryWriter()) {
|
|
15803
|
+
if (message.orderId.length !== 0) {
|
|
15804
|
+
writer.uint32(10).bytes(message.orderId);
|
|
15805
|
+
}
|
|
15806
|
+
if (message.escrowedAmount !== void 0) {
|
|
15807
|
+
Coin.encode(message.escrowedAmount, writer.uint32(18).fork()).join();
|
|
15808
|
+
}
|
|
15809
|
+
return writer;
|
|
15810
|
+
},
|
|
15811
|
+
decode(input, length) {
|
|
15812
|
+
const reader = input instanceof import_wire37.BinaryReader ? input : new import_wire37.BinaryReader(input);
|
|
15813
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15814
|
+
const message = createBaseMsgPlaceMarketOrderResponse();
|
|
15815
|
+
while (reader.pos < end) {
|
|
15816
|
+
const tag = reader.uint32();
|
|
15817
|
+
switch (tag >>> 3) {
|
|
15818
|
+
case 1: {
|
|
15819
|
+
if (tag !== 10) {
|
|
15820
|
+
break;
|
|
15821
|
+
}
|
|
15822
|
+
message.orderId = reader.bytes();
|
|
15823
|
+
continue;
|
|
15824
|
+
}
|
|
15825
|
+
case 2: {
|
|
15826
|
+
if (tag !== 18) {
|
|
15827
|
+
break;
|
|
15828
|
+
}
|
|
15829
|
+
message.escrowedAmount = Coin.decode(reader, reader.uint32());
|
|
15830
|
+
continue;
|
|
15831
|
+
}
|
|
15832
|
+
}
|
|
15833
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15834
|
+
break;
|
|
15835
|
+
}
|
|
15836
|
+
reader.skip(tag & 7);
|
|
15837
|
+
}
|
|
15838
|
+
return message;
|
|
15839
|
+
},
|
|
15840
|
+
fromJSON(object2) {
|
|
15841
|
+
return {
|
|
15842
|
+
orderId: isSet35(object2.orderId) ? bytesFromBase648(object2.orderId) : isSet35(object2.order_id) ? bytesFromBase648(object2.order_id) : new Uint8Array(0),
|
|
15843
|
+
escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0
|
|
15844
|
+
};
|
|
15845
|
+
},
|
|
15846
|
+
toJSON(message) {
|
|
15847
|
+
const obj = {};
|
|
15848
|
+
if (message.orderId.length !== 0) {
|
|
15849
|
+
obj.orderId = base64FromBytes8(message.orderId);
|
|
15850
|
+
}
|
|
15851
|
+
if (message.escrowedAmount !== void 0) {
|
|
15852
|
+
obj.escrowedAmount = Coin.toJSON(message.escrowedAmount);
|
|
15853
|
+
}
|
|
15854
|
+
return obj;
|
|
15855
|
+
},
|
|
15856
|
+
create(base) {
|
|
15857
|
+
return MsgPlaceMarketOrderResponse.fromPartial(base ?? {});
|
|
15858
|
+
},
|
|
15859
|
+
fromPartial(object2) {
|
|
15860
|
+
const message = createBaseMsgPlaceMarketOrderResponse();
|
|
15861
|
+
message.orderId = object2.orderId ?? new Uint8Array(0);
|
|
15862
|
+
message.escrowedAmount = object2.escrowedAmount !== void 0 && object2.escrowedAmount !== null ? Coin.fromPartial(object2.escrowedAmount) : void 0;
|
|
15863
|
+
return message;
|
|
15864
|
+
}
|
|
15865
|
+
};
|
|
15716
15866
|
function createBaseMsgCancelOrders() {
|
|
15717
15867
|
return { sender: "", orderIds: [] };
|
|
15718
15868
|
}
|
|
@@ -15781,6 +15931,74 @@ var MsgCancelOrders = {
|
|
|
15781
15931
|
return message;
|
|
15782
15932
|
}
|
|
15783
15933
|
};
|
|
15934
|
+
function createBaseMsgCancelOrdersResponse() {
|
|
15935
|
+
return { succeeded: [], failed: [] };
|
|
15936
|
+
}
|
|
15937
|
+
var MsgCancelOrdersResponse = {
|
|
15938
|
+
encode(message, writer = new import_wire37.BinaryWriter()) {
|
|
15939
|
+
for (const v of message.succeeded) {
|
|
15940
|
+
writer.uint32(10).bytes(v);
|
|
15941
|
+
}
|
|
15942
|
+
for (const v of message.failed) {
|
|
15943
|
+
writer.uint32(18).bytes(v);
|
|
15944
|
+
}
|
|
15945
|
+
return writer;
|
|
15946
|
+
},
|
|
15947
|
+
decode(input, length) {
|
|
15948
|
+
const reader = input instanceof import_wire37.BinaryReader ? input : new import_wire37.BinaryReader(input);
|
|
15949
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
15950
|
+
const message = createBaseMsgCancelOrdersResponse();
|
|
15951
|
+
while (reader.pos < end) {
|
|
15952
|
+
const tag = reader.uint32();
|
|
15953
|
+
switch (tag >>> 3) {
|
|
15954
|
+
case 1: {
|
|
15955
|
+
if (tag !== 10) {
|
|
15956
|
+
break;
|
|
15957
|
+
}
|
|
15958
|
+
message.succeeded.push(reader.bytes());
|
|
15959
|
+
continue;
|
|
15960
|
+
}
|
|
15961
|
+
case 2: {
|
|
15962
|
+
if (tag !== 18) {
|
|
15963
|
+
break;
|
|
15964
|
+
}
|
|
15965
|
+
message.failed.push(reader.bytes());
|
|
15966
|
+
continue;
|
|
15967
|
+
}
|
|
15968
|
+
}
|
|
15969
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
15970
|
+
break;
|
|
15971
|
+
}
|
|
15972
|
+
reader.skip(tag & 7);
|
|
15973
|
+
}
|
|
15974
|
+
return message;
|
|
15975
|
+
},
|
|
15976
|
+
fromJSON(object2) {
|
|
15977
|
+
return {
|
|
15978
|
+
succeeded: globalThis.Array.isArray(object2?.succeeded) ? object2.succeeded.map((e) => bytesFromBase648(e)) : [],
|
|
15979
|
+
failed: globalThis.Array.isArray(object2?.failed) ? object2.failed.map((e) => bytesFromBase648(e)) : []
|
|
15980
|
+
};
|
|
15981
|
+
},
|
|
15982
|
+
toJSON(message) {
|
|
15983
|
+
const obj = {};
|
|
15984
|
+
if (message.succeeded?.length) {
|
|
15985
|
+
obj.succeeded = message.succeeded.map((e) => base64FromBytes8(e));
|
|
15986
|
+
}
|
|
15987
|
+
if (message.failed?.length) {
|
|
15988
|
+
obj.failed = message.failed.map((e) => base64FromBytes8(e));
|
|
15989
|
+
}
|
|
15990
|
+
return obj;
|
|
15991
|
+
},
|
|
15992
|
+
create(base) {
|
|
15993
|
+
return MsgCancelOrdersResponse.fromPartial(base ?? {});
|
|
15994
|
+
},
|
|
15995
|
+
fromPartial(object2) {
|
|
15996
|
+
const message = createBaseMsgCancelOrdersResponse();
|
|
15997
|
+
message.succeeded = object2.succeeded?.map((e) => e) || [];
|
|
15998
|
+
message.failed = object2.failed?.map((e) => e) || [];
|
|
15999
|
+
return message;
|
|
16000
|
+
}
|
|
16001
|
+
};
|
|
15784
16002
|
function createBaseMsgModifyOrders() {
|
|
15785
16003
|
return { sender: "", orders: [] };
|
|
15786
16004
|
}
|
|
@@ -16156,23 +16374,23 @@ var MsgPlaceScaleOrder = {
|
|
|
16156
16374
|
return message;
|
|
16157
16375
|
}
|
|
16158
16376
|
};
|
|
16159
|
-
function
|
|
16160
|
-
return {
|
|
16377
|
+
function createBaseMsgPlaceScaleOrderResponse() {
|
|
16378
|
+
return { orders: [], escrowedAmount: void 0 };
|
|
16161
16379
|
}
|
|
16162
|
-
var
|
|
16380
|
+
var MsgPlaceScaleOrderResponse = {
|
|
16163
16381
|
encode(message, writer = new import_wire37.BinaryWriter()) {
|
|
16164
|
-
|
|
16165
|
-
writer.uint32(10).
|
|
16382
|
+
for (const v of message.orders) {
|
|
16383
|
+
ScaleOrderResult.encode(v, writer.uint32(10).fork()).join();
|
|
16166
16384
|
}
|
|
16167
|
-
if (message.
|
|
16168
|
-
|
|
16385
|
+
if (message.escrowedAmount !== void 0) {
|
|
16386
|
+
Coin.encode(message.escrowedAmount, writer.uint32(18).fork()).join();
|
|
16169
16387
|
}
|
|
16170
16388
|
return writer;
|
|
16171
16389
|
},
|
|
16172
16390
|
decode(input, length) {
|
|
16173
16391
|
const reader = input instanceof import_wire37.BinaryReader ? input : new import_wire37.BinaryReader(input);
|
|
16174
16392
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
16175
|
-
const message =
|
|
16393
|
+
const message = createBaseMsgPlaceScaleOrderResponse();
|
|
16176
16394
|
while (reader.pos < end) {
|
|
16177
16395
|
const tag = reader.uint32();
|
|
16178
16396
|
switch (tag >>> 3) {
|
|
@@ -16180,14 +16398,14 @@ var MsgUpdateParams3 = {
|
|
|
16180
16398
|
if (tag !== 10) {
|
|
16181
16399
|
break;
|
|
16182
16400
|
}
|
|
16183
|
-
message.
|
|
16401
|
+
message.orders.push(ScaleOrderResult.decode(reader, reader.uint32()));
|
|
16184
16402
|
continue;
|
|
16185
16403
|
}
|
|
16186
16404
|
case 2: {
|
|
16187
16405
|
if (tag !== 18) {
|
|
16188
16406
|
break;
|
|
16189
16407
|
}
|
|
16190
|
-
message.
|
|
16408
|
+
message.escrowedAmount = Coin.decode(reader, reader.uint32());
|
|
16191
16409
|
continue;
|
|
16192
16410
|
}
|
|
16193
16411
|
}
|
|
@@ -16200,101 +16418,50 @@ var MsgUpdateParams3 = {
|
|
|
16200
16418
|
},
|
|
16201
16419
|
fromJSON(object2) {
|
|
16202
16420
|
return {
|
|
16203
|
-
|
|
16204
|
-
|
|
16421
|
+
orders: globalThis.Array.isArray(object2?.orders) ? object2.orders.map((e) => ScaleOrderResult.fromJSON(e)) : [],
|
|
16422
|
+
escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0
|
|
16205
16423
|
};
|
|
16206
16424
|
},
|
|
16207
16425
|
toJSON(message) {
|
|
16208
16426
|
const obj = {};
|
|
16209
|
-
if (message.
|
|
16210
|
-
obj.
|
|
16427
|
+
if (message.orders?.length) {
|
|
16428
|
+
obj.orders = message.orders.map((e) => ScaleOrderResult.toJSON(e));
|
|
16211
16429
|
}
|
|
16212
|
-
if (message.
|
|
16213
|
-
obj.
|
|
16430
|
+
if (message.escrowedAmount !== void 0) {
|
|
16431
|
+
obj.escrowedAmount = Coin.toJSON(message.escrowedAmount);
|
|
16214
16432
|
}
|
|
16215
16433
|
return obj;
|
|
16216
16434
|
},
|
|
16217
16435
|
create(base) {
|
|
16218
|
-
return
|
|
16436
|
+
return MsgPlaceScaleOrderResponse.fromPartial(base ?? {});
|
|
16219
16437
|
},
|
|
16220
16438
|
fromPartial(object2) {
|
|
16221
|
-
const message =
|
|
16222
|
-
message.
|
|
16223
|
-
message.
|
|
16439
|
+
const message = createBaseMsgPlaceScaleOrderResponse();
|
|
16440
|
+
message.orders = object2.orders?.map((e) => ScaleOrderResult.fromPartial(e)) || [];
|
|
16441
|
+
message.escrowedAmount = object2.escrowedAmount !== void 0 && object2.escrowedAmount !== null ? Coin.fromPartial(object2.escrowedAmount) : void 0;
|
|
16224
16442
|
return message;
|
|
16225
16443
|
}
|
|
16226
16444
|
};
|
|
16227
|
-
function
|
|
16228
|
-
|
|
16229
|
-
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
16230
|
-
} else {
|
|
16231
|
-
const bin = globalThis.atob(b64);
|
|
16232
|
-
const arr = new Uint8Array(bin.length);
|
|
16233
|
-
for (let i = 0; i < bin.length; ++i) {
|
|
16234
|
-
arr[i] = bin.charCodeAt(i);
|
|
16235
|
-
}
|
|
16236
|
-
return arr;
|
|
16237
|
-
}
|
|
16238
|
-
}
|
|
16239
|
-
function base64FromBytes8(arr) {
|
|
16240
|
-
if (globalThis.Buffer) {
|
|
16241
|
-
return globalThis.Buffer.from(arr).toString("base64");
|
|
16242
|
-
} else {
|
|
16243
|
-
const bin = [];
|
|
16244
|
-
arr.forEach((byte) => {
|
|
16245
|
-
bin.push(globalThis.String.fromCharCode(byte));
|
|
16246
|
-
});
|
|
16247
|
-
return globalThis.btoa(bin.join(""));
|
|
16248
|
-
}
|
|
16249
|
-
}
|
|
16250
|
-
function toTimestamp7(date) {
|
|
16251
|
-
const seconds = BigInt(Math.trunc(date.getTime() / 1e3));
|
|
16252
|
-
const nanos = date.getTime() % 1e3 * 1e6;
|
|
16253
|
-
return { seconds, nanos };
|
|
16254
|
-
}
|
|
16255
|
-
function fromTimestamp7(t) {
|
|
16256
|
-
let millis = (globalThis.Number(t.seconds.toString()) || 0) * 1e3;
|
|
16257
|
-
millis += (t.nanos || 0) / 1e6;
|
|
16258
|
-
return new globalThis.Date(millis);
|
|
16259
|
-
}
|
|
16260
|
-
function fromJsonTimestamp7(o) {
|
|
16261
|
-
if (o instanceof globalThis.Date) {
|
|
16262
|
-
return o;
|
|
16263
|
-
} else if (typeof o === "string") {
|
|
16264
|
-
return new globalThis.Date(o);
|
|
16265
|
-
} else {
|
|
16266
|
-
return fromTimestamp7(Timestamp.fromJSON(o));
|
|
16267
|
-
}
|
|
16268
|
-
}
|
|
16269
|
-
function isSet35(value) {
|
|
16270
|
-
return value !== null && value !== void 0;
|
|
16271
|
-
}
|
|
16272
|
-
|
|
16273
|
-
// src/proto/gen/ault/license/v1/tx.ts
|
|
16274
|
-
var import_wire38 = require("@bufbuild/protobuf/wire");
|
|
16275
|
-
function createBaseMsgMintLicense() {
|
|
16276
|
-
return { minter: "", to: "", uri: "", reason: "" };
|
|
16445
|
+
function createBaseScaleOrderResult() {
|
|
16446
|
+
return { orderId: new Uint8Array(0), price: "", quantity: "" };
|
|
16277
16447
|
}
|
|
16278
|
-
var
|
|
16279
|
-
encode(message, writer = new
|
|
16280
|
-
if (message.
|
|
16281
|
-
writer.uint32(10).
|
|
16282
|
-
}
|
|
16283
|
-
if (message.to !== "") {
|
|
16284
|
-
writer.uint32(18).string(message.to);
|
|
16448
|
+
var ScaleOrderResult = {
|
|
16449
|
+
encode(message, writer = new import_wire37.BinaryWriter()) {
|
|
16450
|
+
if (message.orderId.length !== 0) {
|
|
16451
|
+
writer.uint32(10).bytes(message.orderId);
|
|
16285
16452
|
}
|
|
16286
|
-
if (message.
|
|
16287
|
-
writer.uint32(
|
|
16453
|
+
if (message.price !== "") {
|
|
16454
|
+
writer.uint32(18).string(message.price);
|
|
16288
16455
|
}
|
|
16289
|
-
if (message.
|
|
16290
|
-
writer.uint32(
|
|
16456
|
+
if (message.quantity !== "") {
|
|
16457
|
+
writer.uint32(26).string(message.quantity);
|
|
16291
16458
|
}
|
|
16292
16459
|
return writer;
|
|
16293
16460
|
},
|
|
16294
16461
|
decode(input, length) {
|
|
16295
|
-
const reader = input instanceof
|
|
16462
|
+
const reader = input instanceof import_wire37.BinaryReader ? input : new import_wire37.BinaryReader(input);
|
|
16296
16463
|
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
16297
|
-
const message =
|
|
16464
|
+
const message = createBaseScaleOrderResult();
|
|
16298
16465
|
while (reader.pos < end) {
|
|
16299
16466
|
const tag = reader.uint32();
|
|
16300
16467
|
switch (tag >>> 3) {
|
|
@@ -16302,7 +16469,209 @@ var MsgMintLicense = {
|
|
|
16302
16469
|
if (tag !== 10) {
|
|
16303
16470
|
break;
|
|
16304
16471
|
}
|
|
16305
|
-
message.
|
|
16472
|
+
message.orderId = reader.bytes();
|
|
16473
|
+
continue;
|
|
16474
|
+
}
|
|
16475
|
+
case 2: {
|
|
16476
|
+
if (tag !== 18) {
|
|
16477
|
+
break;
|
|
16478
|
+
}
|
|
16479
|
+
message.price = reader.string();
|
|
16480
|
+
continue;
|
|
16481
|
+
}
|
|
16482
|
+
case 3: {
|
|
16483
|
+
if (tag !== 26) {
|
|
16484
|
+
break;
|
|
16485
|
+
}
|
|
16486
|
+
message.quantity = reader.string();
|
|
16487
|
+
continue;
|
|
16488
|
+
}
|
|
16489
|
+
}
|
|
16490
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
16491
|
+
break;
|
|
16492
|
+
}
|
|
16493
|
+
reader.skip(tag & 7);
|
|
16494
|
+
}
|
|
16495
|
+
return message;
|
|
16496
|
+
},
|
|
16497
|
+
fromJSON(object2) {
|
|
16498
|
+
return {
|
|
16499
|
+
orderId: isSet35(object2.orderId) ? bytesFromBase648(object2.orderId) : isSet35(object2.order_id) ? bytesFromBase648(object2.order_id) : new Uint8Array(0),
|
|
16500
|
+
price: isSet35(object2.price) ? globalThis.String(object2.price) : "",
|
|
16501
|
+
quantity: isSet35(object2.quantity) ? globalThis.String(object2.quantity) : ""
|
|
16502
|
+
};
|
|
16503
|
+
},
|
|
16504
|
+
toJSON(message) {
|
|
16505
|
+
const obj = {};
|
|
16506
|
+
if (message.orderId.length !== 0) {
|
|
16507
|
+
obj.orderId = base64FromBytes8(message.orderId);
|
|
16508
|
+
}
|
|
16509
|
+
if (message.price !== "") {
|
|
16510
|
+
obj.price = message.price;
|
|
16511
|
+
}
|
|
16512
|
+
if (message.quantity !== "") {
|
|
16513
|
+
obj.quantity = message.quantity;
|
|
16514
|
+
}
|
|
16515
|
+
return obj;
|
|
16516
|
+
},
|
|
16517
|
+
create(base) {
|
|
16518
|
+
return ScaleOrderResult.fromPartial(base ?? {});
|
|
16519
|
+
},
|
|
16520
|
+
fromPartial(object2) {
|
|
16521
|
+
const message = createBaseScaleOrderResult();
|
|
16522
|
+
message.orderId = object2.orderId ?? new Uint8Array(0);
|
|
16523
|
+
message.price = object2.price ?? "";
|
|
16524
|
+
message.quantity = object2.quantity ?? "";
|
|
16525
|
+
return message;
|
|
16526
|
+
}
|
|
16527
|
+
};
|
|
16528
|
+
function createBaseMsgUpdateParams3() {
|
|
16529
|
+
return { authority: "", params: void 0 };
|
|
16530
|
+
}
|
|
16531
|
+
var MsgUpdateParams3 = {
|
|
16532
|
+
encode(message, writer = new import_wire37.BinaryWriter()) {
|
|
16533
|
+
if (message.authority !== "") {
|
|
16534
|
+
writer.uint32(10).string(message.authority);
|
|
16535
|
+
}
|
|
16536
|
+
if (message.params !== void 0) {
|
|
16537
|
+
Params4.encode(message.params, writer.uint32(18).fork()).join();
|
|
16538
|
+
}
|
|
16539
|
+
return writer;
|
|
16540
|
+
},
|
|
16541
|
+
decode(input, length) {
|
|
16542
|
+
const reader = input instanceof import_wire37.BinaryReader ? input : new import_wire37.BinaryReader(input);
|
|
16543
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
16544
|
+
const message = createBaseMsgUpdateParams3();
|
|
16545
|
+
while (reader.pos < end) {
|
|
16546
|
+
const tag = reader.uint32();
|
|
16547
|
+
switch (tag >>> 3) {
|
|
16548
|
+
case 1: {
|
|
16549
|
+
if (tag !== 10) {
|
|
16550
|
+
break;
|
|
16551
|
+
}
|
|
16552
|
+
message.authority = reader.string();
|
|
16553
|
+
continue;
|
|
16554
|
+
}
|
|
16555
|
+
case 2: {
|
|
16556
|
+
if (tag !== 18) {
|
|
16557
|
+
break;
|
|
16558
|
+
}
|
|
16559
|
+
message.params = Params4.decode(reader, reader.uint32());
|
|
16560
|
+
continue;
|
|
16561
|
+
}
|
|
16562
|
+
}
|
|
16563
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
16564
|
+
break;
|
|
16565
|
+
}
|
|
16566
|
+
reader.skip(tag & 7);
|
|
16567
|
+
}
|
|
16568
|
+
return message;
|
|
16569
|
+
},
|
|
16570
|
+
fromJSON(object2) {
|
|
16571
|
+
return {
|
|
16572
|
+
authority: isSet35(object2.authority) ? globalThis.String(object2.authority) : "",
|
|
16573
|
+
params: isSet35(object2.params) ? Params4.fromJSON(object2.params) : void 0
|
|
16574
|
+
};
|
|
16575
|
+
},
|
|
16576
|
+
toJSON(message) {
|
|
16577
|
+
const obj = {};
|
|
16578
|
+
if (message.authority !== "") {
|
|
16579
|
+
obj.authority = message.authority;
|
|
16580
|
+
}
|
|
16581
|
+
if (message.params !== void 0) {
|
|
16582
|
+
obj.params = Params4.toJSON(message.params);
|
|
16583
|
+
}
|
|
16584
|
+
return obj;
|
|
16585
|
+
},
|
|
16586
|
+
create(base) {
|
|
16587
|
+
return MsgUpdateParams3.fromPartial(base ?? {});
|
|
16588
|
+
},
|
|
16589
|
+
fromPartial(object2) {
|
|
16590
|
+
const message = createBaseMsgUpdateParams3();
|
|
16591
|
+
message.authority = object2.authority ?? "";
|
|
16592
|
+
message.params = object2.params !== void 0 && object2.params !== null ? Params4.fromPartial(object2.params) : void 0;
|
|
16593
|
+
return message;
|
|
16594
|
+
}
|
|
16595
|
+
};
|
|
16596
|
+
function bytesFromBase648(b64) {
|
|
16597
|
+
if (globalThis.Buffer) {
|
|
16598
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
16599
|
+
} else {
|
|
16600
|
+
const bin = globalThis.atob(b64);
|
|
16601
|
+
const arr = new Uint8Array(bin.length);
|
|
16602
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
16603
|
+
arr[i] = bin.charCodeAt(i);
|
|
16604
|
+
}
|
|
16605
|
+
return arr;
|
|
16606
|
+
}
|
|
16607
|
+
}
|
|
16608
|
+
function base64FromBytes8(arr) {
|
|
16609
|
+
if (globalThis.Buffer) {
|
|
16610
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
16611
|
+
} else {
|
|
16612
|
+
const bin = [];
|
|
16613
|
+
arr.forEach((byte) => {
|
|
16614
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
16615
|
+
});
|
|
16616
|
+
return globalThis.btoa(bin.join(""));
|
|
16617
|
+
}
|
|
16618
|
+
}
|
|
16619
|
+
function toTimestamp7(date) {
|
|
16620
|
+
const seconds = BigInt(Math.trunc(date.getTime() / 1e3));
|
|
16621
|
+
const nanos = date.getTime() % 1e3 * 1e6;
|
|
16622
|
+
return { seconds, nanos };
|
|
16623
|
+
}
|
|
16624
|
+
function fromTimestamp7(t) {
|
|
16625
|
+
let millis = (globalThis.Number(t.seconds.toString()) || 0) * 1e3;
|
|
16626
|
+
millis += (t.nanos || 0) / 1e6;
|
|
16627
|
+
return new globalThis.Date(millis);
|
|
16628
|
+
}
|
|
16629
|
+
function fromJsonTimestamp7(o) {
|
|
16630
|
+
if (o instanceof globalThis.Date) {
|
|
16631
|
+
return o;
|
|
16632
|
+
} else if (typeof o === "string") {
|
|
16633
|
+
return new globalThis.Date(o);
|
|
16634
|
+
} else {
|
|
16635
|
+
return fromTimestamp7(Timestamp.fromJSON(o));
|
|
16636
|
+
}
|
|
16637
|
+
}
|
|
16638
|
+
function isSet35(value) {
|
|
16639
|
+
return value !== null && value !== void 0;
|
|
16640
|
+
}
|
|
16641
|
+
|
|
16642
|
+
// src/proto/gen/ault/license/v1/tx.ts
|
|
16643
|
+
var import_wire38 = require("@bufbuild/protobuf/wire");
|
|
16644
|
+
function createBaseMsgMintLicense() {
|
|
16645
|
+
return { minter: "", to: "", uri: "", reason: "" };
|
|
16646
|
+
}
|
|
16647
|
+
var MsgMintLicense = {
|
|
16648
|
+
encode(message, writer = new import_wire38.BinaryWriter()) {
|
|
16649
|
+
if (message.minter !== "") {
|
|
16650
|
+
writer.uint32(10).string(message.minter);
|
|
16651
|
+
}
|
|
16652
|
+
if (message.to !== "") {
|
|
16653
|
+
writer.uint32(18).string(message.to);
|
|
16654
|
+
}
|
|
16655
|
+
if (message.uri !== "") {
|
|
16656
|
+
writer.uint32(26).string(message.uri);
|
|
16657
|
+
}
|
|
16658
|
+
if (message.reason !== "") {
|
|
16659
|
+
writer.uint32(34).string(message.reason);
|
|
16660
|
+
}
|
|
16661
|
+
return writer;
|
|
16662
|
+
},
|
|
16663
|
+
decode(input, length) {
|
|
16664
|
+
const reader = input instanceof import_wire38.BinaryReader ? input : new import_wire38.BinaryReader(input);
|
|
16665
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
16666
|
+
const message = createBaseMsgMintLicense();
|
|
16667
|
+
while (reader.pos < end) {
|
|
16668
|
+
const tag = reader.uint32();
|
|
16669
|
+
switch (tag >>> 3) {
|
|
16670
|
+
case 1: {
|
|
16671
|
+
if (tag !== 10) {
|
|
16672
|
+
break;
|
|
16673
|
+
}
|
|
16674
|
+
message.minter = reader.string();
|
|
16306
16675
|
continue;
|
|
16307
16676
|
}
|
|
16308
16677
|
case 2: {
|
|
@@ -21912,6 +22281,7 @@ async function pollTxInclusion(network, txHash, fetchFn, fetchOptions, timeoutMs
|
|
|
21912
22281
|
return {
|
|
21913
22282
|
code: result.tx_response.code,
|
|
21914
22283
|
rawLog: result.tx_response.raw_log,
|
|
22284
|
+
data: result.tx_response.data,
|
|
21915
22285
|
confirmed: true
|
|
21916
22286
|
};
|
|
21917
22287
|
} catch (error) {
|
|
@@ -21960,6 +22330,7 @@ async function signAndBroadcastEip712({
|
|
|
21960
22330
|
feeDenom,
|
|
21961
22331
|
feeAmount,
|
|
21962
22332
|
confirmationTimeoutMs,
|
|
22333
|
+
wait = true,
|
|
21963
22334
|
fetchFn,
|
|
21964
22335
|
fetchOptions,
|
|
21965
22336
|
cache,
|
|
@@ -22058,6 +22429,15 @@ async function signAndBroadcastEip712({
|
|
|
22058
22429
|
confirmed: true
|
|
22059
22430
|
});
|
|
22060
22431
|
}
|
|
22432
|
+
if (!wait) {
|
|
22433
|
+
if (cache) cache.nextSequence = getNextSequence(sequence);
|
|
22434
|
+
return {
|
|
22435
|
+
txHash,
|
|
22436
|
+
code: 0,
|
|
22437
|
+
rawLog: result.tx_response.raw_log,
|
|
22438
|
+
confirmed: false
|
|
22439
|
+
};
|
|
22440
|
+
}
|
|
22061
22441
|
const deliverResult = await pollTxInclusion(
|
|
22062
22442
|
network,
|
|
22063
22443
|
txHash,
|
|
@@ -22100,6 +22480,7 @@ async function signAndBroadcastEip712({
|
|
|
22100
22480
|
txHash,
|
|
22101
22481
|
code: 0,
|
|
22102
22482
|
rawLog: deliverResult.rawLog,
|
|
22483
|
+
data: deliverResult.data,
|
|
22103
22484
|
confirmed: true
|
|
22104
22485
|
};
|
|
22105
22486
|
}
|
|
@@ -22509,59 +22890,278 @@ function buildScaleOrderMsg(sender, params) {
|
|
|
22509
22890
|
});
|
|
22510
22891
|
}
|
|
22511
22892
|
|
|
22893
|
+
// src/utils/opaque-id.ts
|
|
22894
|
+
var import_viem4 = require("viem");
|
|
22895
|
+
function decodeHex(input) {
|
|
22896
|
+
const clean = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
|
|
22897
|
+
if (clean.length % 2 !== 0) {
|
|
22898
|
+
throw new Error(`invalid hex length: "${input}"`);
|
|
22899
|
+
}
|
|
22900
|
+
if (clean.length > 0 && !/^[0-9a-fA-F]+$/.test(clean)) {
|
|
22901
|
+
throw new Error(`invalid hex characters: "${input}"`);
|
|
22902
|
+
}
|
|
22903
|
+
return (0, import_viem4.hexToBytes)(`0x${clean}`);
|
|
22904
|
+
}
|
|
22905
|
+
function encodeHex(bytes) {
|
|
22906
|
+
return (0, import_viem4.bytesToHex)(bytes).slice(2);
|
|
22907
|
+
}
|
|
22908
|
+
function bytesEqual(a, b) {
|
|
22909
|
+
if (a.length !== b.length) return false;
|
|
22910
|
+
for (let i = 0; i < a.length; i++) {
|
|
22911
|
+
if (a[i] !== b[i]) return false;
|
|
22912
|
+
}
|
|
22913
|
+
return true;
|
|
22914
|
+
}
|
|
22915
|
+
var OpaqueId = class {
|
|
22916
|
+
constructor(bytes) {
|
|
22917
|
+
this.bytes = bytes;
|
|
22918
|
+
}
|
|
22919
|
+
toBytes() {
|
|
22920
|
+
return new Uint8Array(this.bytes);
|
|
22921
|
+
}
|
|
22922
|
+
toHex() {
|
|
22923
|
+
return encodeHex(this.bytes);
|
|
22924
|
+
}
|
|
22925
|
+
toBase64() {
|
|
22926
|
+
return bytesToBase64(this.bytes);
|
|
22927
|
+
}
|
|
22928
|
+
toString() {
|
|
22929
|
+
return this.toHex();
|
|
22930
|
+
}
|
|
22931
|
+
equalsBytes(other) {
|
|
22932
|
+
return bytesEqual(this.bytes, other.bytes);
|
|
22933
|
+
}
|
|
22934
|
+
};
|
|
22935
|
+
var MarketId = class _MarketId extends OpaqueId {
|
|
22936
|
+
static fromHex(hex) {
|
|
22937
|
+
return new _MarketId(_MarketId.assertNonEmpty(decodeHex(hex), `hex "${hex}"`));
|
|
22938
|
+
}
|
|
22939
|
+
static fromBase64(b64) {
|
|
22940
|
+
return new _MarketId(_MarketId.assertNonEmpty(base64ToBytes(b64), `base64 "${b64}"`));
|
|
22941
|
+
}
|
|
22942
|
+
static fromBytes(bytes) {
|
|
22943
|
+
return new _MarketId(_MarketId.assertNonEmpty(new Uint8Array(bytes), "bytes"));
|
|
22944
|
+
}
|
|
22945
|
+
static assertNonEmpty(bytes, source) {
|
|
22946
|
+
if (bytes.length === 0) {
|
|
22947
|
+
throw new Error(`MarketId: empty bytes from ${source}`);
|
|
22948
|
+
}
|
|
22949
|
+
return bytes;
|
|
22950
|
+
}
|
|
22951
|
+
equals(other) {
|
|
22952
|
+
return this.equalsBytes(other);
|
|
22953
|
+
}
|
|
22954
|
+
};
|
|
22955
|
+
var ORDER_ID_LENGTH = 16;
|
|
22956
|
+
var OrderId = class _OrderId extends OpaqueId {
|
|
22957
|
+
static fromHex(hex) {
|
|
22958
|
+
return new _OrderId(_OrderId.assertLength(decodeHex(hex), `hex "${hex}"`));
|
|
22959
|
+
}
|
|
22960
|
+
static fromBase64(b64) {
|
|
22961
|
+
return new _OrderId(_OrderId.assertLength(base64ToBytes(b64), `base64 "${b64}"`));
|
|
22962
|
+
}
|
|
22963
|
+
static fromBytes(bytes) {
|
|
22964
|
+
return new _OrderId(_OrderId.assertLength(new Uint8Array(bytes), "bytes"));
|
|
22965
|
+
}
|
|
22966
|
+
static assertLength(bytes, source) {
|
|
22967
|
+
if (bytes.length !== ORDER_ID_LENGTH) {
|
|
22968
|
+
throw new Error(
|
|
22969
|
+
`OrderId: expected ${ORDER_ID_LENGTH} bytes (chain layout), got ${bytes.length} from ${source}`
|
|
22970
|
+
);
|
|
22971
|
+
}
|
|
22972
|
+
return bytes;
|
|
22973
|
+
}
|
|
22974
|
+
equals(other) {
|
|
22975
|
+
return this.equalsBytes(other);
|
|
22976
|
+
}
|
|
22977
|
+
};
|
|
22978
|
+
|
|
22979
|
+
// src/core/clob-responses.ts
|
|
22980
|
+
async function withWaitDecode(wait, run, decode) {
|
|
22981
|
+
const w = wait ?? false;
|
|
22982
|
+
const res = await run(w);
|
|
22983
|
+
return w ? decode(res.msgResponses, res) : res;
|
|
22984
|
+
}
|
|
22985
|
+
var LIMIT_RESPONSE_TYPE = "/ault.clob.v1.MsgPlaceLimitOrderResponse";
|
|
22986
|
+
var MARKET_RESPONSE_TYPE = "/ault.clob.v1.MsgPlaceMarketOrderResponse";
|
|
22987
|
+
var SCALE_RESPONSE_TYPE = "/ault.clob.v1.MsgPlaceScaleOrderResponse";
|
|
22988
|
+
var CANCEL_RESPONSE_TYPE = "/ault.clob.v1.MsgCancelOrdersResponse";
|
|
22989
|
+
function findResponse(msgResponses, typeUrl, txHash) {
|
|
22990
|
+
const match = msgResponses?.find((r) => r.typeUrl === typeUrl);
|
|
22991
|
+
if (!match) {
|
|
22992
|
+
throw new MissingMsgResponseError(typeUrl, txHash);
|
|
22993
|
+
}
|
|
22994
|
+
return match.value;
|
|
22995
|
+
}
|
|
22996
|
+
function coinOrUndefined(coin) {
|
|
22997
|
+
return coin && coin.denom !== "" ? coin : void 0;
|
|
22998
|
+
}
|
|
22999
|
+
function decodeLimitOrderResult(msgResponses, base) {
|
|
23000
|
+
const decoded = MsgPlaceLimitOrderResponse.decode(
|
|
23001
|
+
findResponse(msgResponses, LIMIT_RESPONSE_TYPE, base.txHash)
|
|
23002
|
+
);
|
|
23003
|
+
return {
|
|
23004
|
+
...base,
|
|
23005
|
+
orderId: OrderId.fromBytes(decoded.orderId).toHex(),
|
|
23006
|
+
...coinOrUndefined(decoded.escrowedAmount) && { escrowedAmount: decoded.escrowedAmount }
|
|
23007
|
+
};
|
|
23008
|
+
}
|
|
23009
|
+
function decodeMarketOrderResult(msgResponses, base) {
|
|
23010
|
+
const decoded = MsgPlaceMarketOrderResponse.decode(
|
|
23011
|
+
findResponse(msgResponses, MARKET_RESPONSE_TYPE, base.txHash)
|
|
23012
|
+
);
|
|
23013
|
+
return {
|
|
23014
|
+
...base,
|
|
23015
|
+
orderId: OrderId.fromBytes(decoded.orderId).toHex(),
|
|
23016
|
+
...coinOrUndefined(decoded.escrowedAmount) && { escrowedAmount: decoded.escrowedAmount }
|
|
23017
|
+
};
|
|
23018
|
+
}
|
|
23019
|
+
function decodeScaleOrderResult(msgResponses, base) {
|
|
23020
|
+
const decoded = MsgPlaceScaleOrderResponse.decode(
|
|
23021
|
+
findResponse(msgResponses, SCALE_RESPONSE_TYPE, base.txHash)
|
|
23022
|
+
);
|
|
23023
|
+
return {
|
|
23024
|
+
...base,
|
|
23025
|
+
orders: decoded.orders.map((o) => ({
|
|
23026
|
+
orderId: OrderId.fromBytes(o.orderId).toHex(),
|
|
23027
|
+
price: o.price,
|
|
23028
|
+
quantity: o.quantity
|
|
23029
|
+
})),
|
|
23030
|
+
...coinOrUndefined(decoded.escrowedAmount) && { escrowedAmount: decoded.escrowedAmount }
|
|
23031
|
+
};
|
|
23032
|
+
}
|
|
23033
|
+
function decodeCancelOrdersResult(msgResponses, base) {
|
|
23034
|
+
const decoded = MsgCancelOrdersResponse.decode(
|
|
23035
|
+
findResponse(msgResponses, CANCEL_RESPONSE_TYPE, base.txHash)
|
|
23036
|
+
);
|
|
23037
|
+
return {
|
|
23038
|
+
...base,
|
|
23039
|
+
succeeded: decoded.succeeded.map((id) => OrderId.fromBytes(id).toHex()),
|
|
23040
|
+
failed: decoded.failed.map((id) => OrderId.fromBytes(id).toHex())
|
|
23041
|
+
};
|
|
23042
|
+
}
|
|
23043
|
+
|
|
23044
|
+
// src/core/clob-gas.ts
|
|
23045
|
+
function limitOrderGas(gas) {
|
|
23046
|
+
return computeFeeFreeGas(gas.LIMIT_ORDER, 1, gas.FEE_FREE_GAS_MULTIPLIER);
|
|
23047
|
+
}
|
|
23048
|
+
function marketOrderGas(gas) {
|
|
23049
|
+
return computeFeeFreeGas(gas.MARKET_ORDER, 1, gas.FEE_FREE_GAS_MULTIPLIER);
|
|
23050
|
+
}
|
|
23051
|
+
function scaleOrderGas(gas, subOrderCount) {
|
|
23052
|
+
return computeFeeFreeGasCompound(
|
|
23053
|
+
gas.SCALE_ORDER_BASE,
|
|
23054
|
+
gas.SCALE_ORDER_PER_SUB,
|
|
23055
|
+
subOrderCount,
|
|
23056
|
+
gas.FEE_FREE_GAS_MULTIPLIER
|
|
23057
|
+
);
|
|
23058
|
+
}
|
|
23059
|
+
function cancelOrdersGas(gas, orderCount, includeAnte) {
|
|
23060
|
+
const feeFree = computeFeeFreeGasCompound(
|
|
23061
|
+
gas.CANCEL_ORDER_BASE,
|
|
23062
|
+
gas.CANCEL_ORDER_PER_ID,
|
|
23063
|
+
orderCount,
|
|
23064
|
+
gas.FEE_FREE_GAS_MULTIPLIER
|
|
23065
|
+
);
|
|
23066
|
+
if (!includeAnte) return feeFree;
|
|
23067
|
+
return (BigInt(feeFree) + BigInt(gas.EIP712_ANTE_GAS)).toString();
|
|
23068
|
+
}
|
|
23069
|
+
|
|
22512
23070
|
// src/high-level/tx/clob.ts
|
|
22513
23071
|
function createClobTxApi({ signerAddress, exec, getGas }) {
|
|
22514
|
-
|
|
22515
|
-
async placeLimitOrder({
|
|
23072
|
+
const api = {
|
|
23073
|
+
async placeLimitOrder({
|
|
23074
|
+
wait,
|
|
23075
|
+
gasLimit,
|
|
23076
|
+
feeAmount,
|
|
23077
|
+
memo,
|
|
23078
|
+
confirmationTimeoutMs,
|
|
23079
|
+
...params
|
|
23080
|
+
}) {
|
|
22516
23081
|
const gas = getGas();
|
|
22517
|
-
return
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
|
|
23082
|
+
return withWaitDecode(
|
|
23083
|
+
wait,
|
|
23084
|
+
(w) => exec([buildLimitOrderMsg(signerAddress, params)], {
|
|
23085
|
+
gasLimit: gasLimit ?? limitOrderGas(gas),
|
|
23086
|
+
feeAmount,
|
|
23087
|
+
memo,
|
|
23088
|
+
confirmationTimeoutMs,
|
|
23089
|
+
wait: w
|
|
23090
|
+
}),
|
|
23091
|
+
decodeLimitOrderResult
|
|
23092
|
+
);
|
|
22523
23093
|
},
|
|
22524
|
-
async placeMarketOrder({
|
|
23094
|
+
async placeMarketOrder({
|
|
23095
|
+
wait,
|
|
23096
|
+
gasLimit,
|
|
23097
|
+
feeAmount,
|
|
23098
|
+
memo,
|
|
23099
|
+
confirmationTimeoutMs,
|
|
23100
|
+
...params
|
|
23101
|
+
}) {
|
|
22525
23102
|
const gas = getGas();
|
|
22526
|
-
return
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
23103
|
+
return withWaitDecode(
|
|
23104
|
+
wait,
|
|
23105
|
+
(w) => exec([buildMarketOrderMsg(signerAddress, params)], {
|
|
23106
|
+
gasLimit: gasLimit ?? marketOrderGas(gas),
|
|
23107
|
+
feeAmount,
|
|
23108
|
+
memo,
|
|
23109
|
+
confirmationTimeoutMs,
|
|
23110
|
+
wait: w
|
|
23111
|
+
}),
|
|
23112
|
+
decodeMarketOrderResult
|
|
23113
|
+
);
|
|
22532
23114
|
},
|
|
22533
|
-
async cancelOrders({
|
|
23115
|
+
async cancelOrders({
|
|
23116
|
+
orderIds,
|
|
23117
|
+
wait,
|
|
23118
|
+
gasLimit,
|
|
23119
|
+
feeAmount,
|
|
23120
|
+
memo,
|
|
23121
|
+
confirmationTimeoutMs
|
|
23122
|
+
}) {
|
|
22534
23123
|
const gas = getGas();
|
|
22535
|
-
const cancelGas = gasLimit ?? (
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22539
|
-
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
confirmationTimeoutMs
|
|
22548
|
-
});
|
|
23124
|
+
const cancelGas = gasLimit ?? cancelOrdersGas(gas, orderIds.length, true);
|
|
23125
|
+
return withWaitDecode(
|
|
23126
|
+
wait,
|
|
23127
|
+
(w) => exec([buildCancelOrdersMsg(signerAddress, orderIds)], {
|
|
23128
|
+
gasLimit: cancelGas,
|
|
23129
|
+
feeAmount,
|
|
23130
|
+
memo,
|
|
23131
|
+
confirmationTimeoutMs,
|
|
23132
|
+
wait: w
|
|
23133
|
+
}),
|
|
23134
|
+
decodeCancelOrdersResult
|
|
23135
|
+
);
|
|
22549
23136
|
},
|
|
22550
|
-
async placeScaleOrder({
|
|
23137
|
+
async placeScaleOrder({
|
|
23138
|
+
wait,
|
|
23139
|
+
gasLimit,
|
|
23140
|
+
feeAmount,
|
|
23141
|
+
memo,
|
|
23142
|
+
confirmationTimeoutMs,
|
|
23143
|
+
...params
|
|
23144
|
+
}) {
|
|
22551
23145
|
const gas = getGas();
|
|
22552
|
-
return
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
gas.
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22562
|
-
|
|
23146
|
+
return withWaitDecode(
|
|
23147
|
+
wait,
|
|
23148
|
+
(w) => exec([buildScaleOrderMsg(signerAddress, params)], {
|
|
23149
|
+
gasLimit: gasLimit ?? scaleOrderGas(gas, params.weights.length),
|
|
23150
|
+
feeAmount,
|
|
23151
|
+
memo,
|
|
23152
|
+
confirmationTimeoutMs,
|
|
23153
|
+
wait: w
|
|
23154
|
+
}),
|
|
23155
|
+
decodeScaleOrderResult
|
|
23156
|
+
);
|
|
22563
23157
|
},
|
|
22564
|
-
async updateClobParams({
|
|
23158
|
+
async updateClobParams({
|
|
23159
|
+
params,
|
|
23160
|
+
gasLimit,
|
|
23161
|
+
feeAmount,
|
|
23162
|
+
memo,
|
|
23163
|
+
confirmationTimeoutMs
|
|
23164
|
+
}) {
|
|
22565
23165
|
return exec([msg.clob.updateParams({ authority: signerAddress, params })], {
|
|
22566
23166
|
gasLimit,
|
|
22567
23167
|
feeAmount,
|
|
@@ -22570,6 +23170,7 @@ function createClobTxApi({ signerAddress, exec, getGas }) {
|
|
|
22570
23170
|
});
|
|
22571
23171
|
}
|
|
22572
23172
|
};
|
|
23173
|
+
return api;
|
|
22573
23174
|
}
|
|
22574
23175
|
|
|
22575
23176
|
// src/high-level/tx/license.ts
|
|
@@ -23398,9 +23999,9 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
|
23398
23999
|
}
|
|
23399
24000
|
|
|
23400
24001
|
// src/high-level/tx/tokenregistry.ts
|
|
23401
|
-
var
|
|
24002
|
+
var import_viem5 = require("viem");
|
|
23402
24003
|
function normalizeErc20Address(address) {
|
|
23403
|
-
return (0,
|
|
24004
|
+
return (0, import_viem5.getAddress)(address);
|
|
23404
24005
|
}
|
|
23405
24006
|
function createTokenRegistryTxApi({
|
|
23406
24007
|
signerAddress,
|
|
@@ -23475,6 +24076,43 @@ function createTokenRegistryTxApi({
|
|
|
23475
24076
|
};
|
|
23476
24077
|
}
|
|
23477
24078
|
|
|
24079
|
+
// src/proto/tx-decode.ts
|
|
24080
|
+
var import_wire46 = require("@bufbuild/protobuf/wire");
|
|
24081
|
+
function decodeTxMsgResponses(dataHex) {
|
|
24082
|
+
if (!dataHex) return [];
|
|
24083
|
+
const bytes = hexToBytes2(dataHex);
|
|
24084
|
+
if (bytes.length === 0) return [];
|
|
24085
|
+
const reader = new import_wire46.BinaryReader(bytes);
|
|
24086
|
+
const responses = [];
|
|
24087
|
+
while (reader.pos < reader.len) {
|
|
24088
|
+
const tag = reader.uint32();
|
|
24089
|
+
if (tag === 18) {
|
|
24090
|
+
const any = Any.decode(reader, reader.uint32());
|
|
24091
|
+
responses.push({ typeUrl: any.typeUrl, value: any.value });
|
|
24092
|
+
continue;
|
|
24093
|
+
}
|
|
24094
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
24095
|
+
break;
|
|
24096
|
+
}
|
|
24097
|
+
reader.skip(tag & 7);
|
|
24098
|
+
}
|
|
24099
|
+
return responses;
|
|
24100
|
+
}
|
|
24101
|
+
function hexToBytes2(hex) {
|
|
24102
|
+
const clean = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
24103
|
+
if (clean.length % 2 !== 0) {
|
|
24104
|
+
throw new Error(`decodeTxMsgResponses: invalid hex length in tx_response.data`);
|
|
24105
|
+
}
|
|
24106
|
+
if (!/^[0-9a-fA-F]*$/.test(clean)) {
|
|
24107
|
+
throw new Error(`decodeTxMsgResponses: invalid hex character in tx_response.data`);
|
|
24108
|
+
}
|
|
24109
|
+
const out = new Uint8Array(clean.length / 2);
|
|
24110
|
+
for (let i = 0; i < out.length; i++) {
|
|
24111
|
+
out[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
24112
|
+
}
|
|
24113
|
+
return out;
|
|
24114
|
+
}
|
|
24115
|
+
|
|
23478
24116
|
// src/high-level/tx-executor.ts
|
|
23479
24117
|
function createTxExecutor(options) {
|
|
23480
24118
|
const defaultMemo = options.defaultMemo ?? "";
|
|
@@ -23499,17 +24137,20 @@ function createTxExecutor(options) {
|
|
|
23499
24137
|
feeAmount: txOptions?.feeAmount,
|
|
23500
24138
|
memo: txOptions?.memo ?? defaultMemo,
|
|
23501
24139
|
confirmationTimeoutMs: txOptions?.confirmationTimeoutMs ?? defaultConfirmationTimeoutMs,
|
|
24140
|
+
wait: txOptions?.wait ?? true,
|
|
23502
24141
|
fetchFn: options.fetchFn,
|
|
23503
24142
|
fetchOptions,
|
|
23504
24143
|
cache,
|
|
23505
24144
|
feeMarketCache
|
|
23506
24145
|
});
|
|
24146
|
+
const msgResponses = result.data ? decodeTxMsgResponses(result.data) : void 0;
|
|
23507
24147
|
return {
|
|
23508
24148
|
txHash: result.txHash,
|
|
23509
|
-
code:
|
|
24149
|
+
code: result.code,
|
|
23510
24150
|
rawLog: result.rawLog,
|
|
23511
|
-
confirmed:
|
|
23512
|
-
success: true
|
|
24151
|
+
confirmed: result.confirmed,
|
|
24152
|
+
success: result.confirmed === true && result.code === 0,
|
|
24153
|
+
...msgResponses && { msgResponses }
|
|
23513
24154
|
};
|
|
23514
24155
|
};
|
|
23515
24156
|
}
|
|
@@ -23742,12 +24383,12 @@ function createStaticResolver(optsOrNetwork, legacyManifest) {
|
|
|
23742
24383
|
|
|
23743
24384
|
// src/agent/attach.ts
|
|
23744
24385
|
var import_secp256k12 = require("@noble/curves/secp256k1");
|
|
23745
|
-
var
|
|
24386
|
+
var import_viem7 = require("viem");
|
|
23746
24387
|
var import_encoding3 = require("@cosmjs/encoding");
|
|
23747
24388
|
|
|
23748
24389
|
// src/agent/sign-and-broadcast.ts
|
|
23749
24390
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
23750
|
-
var
|
|
24391
|
+
var import_viem6 = require("viem");
|
|
23751
24392
|
var AGENT_DEFAULTS = {
|
|
23752
24393
|
GAS_LIMIT: "147600",
|
|
23753
24394
|
TIMEOUT_SECONDS: 300,
|
|
@@ -23756,7 +24397,7 @@ var AGENT_DEFAULTS = {
|
|
|
23756
24397
|
};
|
|
23757
24398
|
function computeAgentKeyMaterial(agentPrivateKey) {
|
|
23758
24399
|
const normalized = agentPrivateKey.startsWith("0x") ? agentPrivateKey : `0x${agentPrivateKey}`;
|
|
23759
|
-
const privKeyBytes = (0,
|
|
24400
|
+
const privKeyBytes = (0, import_viem6.hexToBytes)(normalized);
|
|
23760
24401
|
const compressedPubkey = import_secp256k1.secp256k1.getPublicKey(privKeyBytes, true);
|
|
23761
24402
|
return { privKeyBytes, compressedPubkey };
|
|
23762
24403
|
}
|
|
@@ -23776,6 +24417,7 @@ async function signAndBroadcastAgentTx({
|
|
|
23776
24417
|
memo = "",
|
|
23777
24418
|
gasLimit,
|
|
23778
24419
|
confirmationTimeoutMs,
|
|
24420
|
+
wait = true,
|
|
23779
24421
|
timeoutSeconds,
|
|
23780
24422
|
timeoutTimestamp,
|
|
23781
24423
|
fetchFn,
|
|
@@ -23836,7 +24478,7 @@ async function signAndBroadcastAgentTx({
|
|
|
23836
24478
|
chainId: network.chainId,
|
|
23837
24479
|
accountNumber: BigInt(accountNumber)
|
|
23838
24480
|
});
|
|
23839
|
-
const hash = (0,
|
|
24481
|
+
const hash = (0, import_viem6.hexToBytes)((0, import_viem6.keccak256)(signDocBytes));
|
|
23840
24482
|
const sig = import_secp256k1.secp256k1.sign(hash, privKeyBytes);
|
|
23841
24483
|
const signatureBytes = sig.toCompactRawBytes();
|
|
23842
24484
|
const txRawBytes = encodeTxRaw({
|
|
@@ -23860,6 +24502,14 @@ async function signAndBroadcastAgentTx({
|
|
|
23860
24502
|
confirmed: true
|
|
23861
24503
|
});
|
|
23862
24504
|
}
|
|
24505
|
+
if (!wait) {
|
|
24506
|
+
return {
|
|
24507
|
+
txHash,
|
|
24508
|
+
code: 0,
|
|
24509
|
+
rawLog: result.tx_response.raw_log,
|
|
24510
|
+
confirmed: false
|
|
24511
|
+
};
|
|
24512
|
+
}
|
|
23863
24513
|
const deliverResult = await pollTxInclusion(
|
|
23864
24514
|
network,
|
|
23865
24515
|
txHash,
|
|
@@ -23895,6 +24545,7 @@ async function signAndBroadcastAgentTx({
|
|
|
23895
24545
|
txHash,
|
|
23896
24546
|
code: 0,
|
|
23897
24547
|
rawLog: deliverResult.rawLog,
|
|
24548
|
+
data: deliverResult.data,
|
|
23898
24549
|
confirmed: true
|
|
23899
24550
|
};
|
|
23900
24551
|
}
|
|
@@ -23921,17 +24572,20 @@ function createAgentTxExecutor(options) {
|
|
|
23921
24572
|
gasLimit: txOptions?.gasLimit ?? defaultGasLimit,
|
|
23922
24573
|
memo: txOptions?.memo ?? defaultMemo,
|
|
23923
24574
|
confirmationTimeoutMs: txOptions?.confirmationTimeoutMs ?? defaultConfirmationTimeoutMs,
|
|
24575
|
+
wait: txOptions?.wait ?? true,
|
|
23924
24576
|
timeoutSeconds: txOptions?.timeoutSeconds ?? defaultTimeoutSeconds,
|
|
23925
24577
|
fetchFn: options.fetchFn,
|
|
23926
24578
|
fetchOptions,
|
|
23927
24579
|
cache
|
|
23928
24580
|
});
|
|
24581
|
+
const msgResponses = result.data ? decodeTxMsgResponses(result.data) : void 0;
|
|
23929
24582
|
return {
|
|
23930
24583
|
txHash: result.txHash,
|
|
23931
|
-
code:
|
|
24584
|
+
code: result.code,
|
|
23932
24585
|
rawLog: result.rawLog,
|
|
23933
|
-
confirmed:
|
|
23934
|
-
success: true
|
|
24586
|
+
confirmed: result.confirmed,
|
|
24587
|
+
success: result.confirmed === true && result.code === 0,
|
|
24588
|
+
...msgResponses && { msgResponses }
|
|
23935
24589
|
};
|
|
23936
24590
|
};
|
|
23937
24591
|
}
|
|
@@ -23942,63 +24596,103 @@ function createAgentClobTxApi({
|
|
|
23942
24596
|
exec,
|
|
23943
24597
|
getGas
|
|
23944
24598
|
}) {
|
|
23945
|
-
|
|
23946
|
-
async placeLimitOrder({
|
|
24599
|
+
const api = {
|
|
24600
|
+
async placeLimitOrder({
|
|
24601
|
+
wait,
|
|
24602
|
+
gasLimit,
|
|
24603
|
+
memo,
|
|
24604
|
+
confirmationTimeoutMs,
|
|
24605
|
+
timeoutSeconds,
|
|
24606
|
+
...params
|
|
24607
|
+
}) {
|
|
23947
24608
|
const gas = getGas();
|
|
23948
|
-
return
|
|
23949
|
-
|
|
23950
|
-
|
|
23951
|
-
|
|
23952
|
-
|
|
23953
|
-
|
|
24609
|
+
return withWaitDecode(
|
|
24610
|
+
wait,
|
|
24611
|
+
(w) => exec([buildLimitOrderMsg(masterAddress, params)], {
|
|
24612
|
+
gasLimit: gasLimit ?? limitOrderGas(gas),
|
|
24613
|
+
memo,
|
|
24614
|
+
confirmationTimeoutMs,
|
|
24615
|
+
timeoutSeconds,
|
|
24616
|
+
wait: w
|
|
24617
|
+
}),
|
|
24618
|
+
decodeLimitOrderResult
|
|
24619
|
+
);
|
|
23954
24620
|
},
|
|
23955
|
-
async placeMarketOrder({
|
|
24621
|
+
async placeMarketOrder({
|
|
24622
|
+
wait,
|
|
24623
|
+
gasLimit,
|
|
24624
|
+
memo,
|
|
24625
|
+
confirmationTimeoutMs,
|
|
24626
|
+
timeoutSeconds,
|
|
24627
|
+
...params
|
|
24628
|
+
}) {
|
|
23956
24629
|
const gas = getGas();
|
|
23957
|
-
return
|
|
23958
|
-
|
|
23959
|
-
|
|
23960
|
-
|
|
23961
|
-
|
|
23962
|
-
|
|
24630
|
+
return withWaitDecode(
|
|
24631
|
+
wait,
|
|
24632
|
+
(w) => exec([buildMarketOrderMsg(masterAddress, params)], {
|
|
24633
|
+
gasLimit: gasLimit ?? marketOrderGas(gas),
|
|
24634
|
+
memo,
|
|
24635
|
+
confirmationTimeoutMs,
|
|
24636
|
+
timeoutSeconds,
|
|
24637
|
+
wait: w
|
|
24638
|
+
}),
|
|
24639
|
+
decodeMarketOrderResult
|
|
24640
|
+
);
|
|
23963
24641
|
},
|
|
23964
|
-
async cancelOrders({
|
|
24642
|
+
async cancelOrders({
|
|
24643
|
+
orderIds,
|
|
24644
|
+
wait,
|
|
24645
|
+
gasLimit,
|
|
24646
|
+
memo,
|
|
24647
|
+
confirmationTimeoutMs,
|
|
24648
|
+
timeoutSeconds
|
|
24649
|
+
}) {
|
|
23965
24650
|
const gas = getGas();
|
|
23966
|
-
return
|
|
23967
|
-
|
|
23968
|
-
|
|
23969
|
-
gas.
|
|
23970
|
-
orderIds.length,
|
|
23971
|
-
|
|
23972
|
-
|
|
23973
|
-
|
|
23974
|
-
|
|
23975
|
-
|
|
23976
|
-
|
|
24651
|
+
return withWaitDecode(
|
|
24652
|
+
wait,
|
|
24653
|
+
(w) => exec([buildCancelOrdersMsg(masterAddress, orderIds)], {
|
|
24654
|
+
// Agent cancels are gas-capped: no EIP-712 ante (includeAnte: false).
|
|
24655
|
+
gasLimit: gasLimit ?? cancelOrdersGas(gas, orderIds.length, false),
|
|
24656
|
+
memo,
|
|
24657
|
+
confirmationTimeoutMs,
|
|
24658
|
+
timeoutSeconds,
|
|
24659
|
+
wait: w
|
|
24660
|
+
}),
|
|
24661
|
+
decodeCancelOrdersResult
|
|
24662
|
+
);
|
|
23977
24663
|
},
|
|
23978
|
-
async placeScaleOrder({
|
|
24664
|
+
async placeScaleOrder({
|
|
24665
|
+
wait,
|
|
24666
|
+
gasLimit,
|
|
24667
|
+
memo,
|
|
24668
|
+
confirmationTimeoutMs,
|
|
24669
|
+
timeoutSeconds,
|
|
24670
|
+
...params
|
|
24671
|
+
}) {
|
|
23979
24672
|
const gas = getGas();
|
|
23980
|
-
return
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
gas.
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
|
|
23990
|
-
|
|
24673
|
+
return withWaitDecode(
|
|
24674
|
+
wait,
|
|
24675
|
+
(w) => exec([buildScaleOrderMsg(masterAddress, params)], {
|
|
24676
|
+
gasLimit: gasLimit ?? scaleOrderGas(gas, params.weights.length),
|
|
24677
|
+
memo,
|
|
24678
|
+
confirmationTimeoutMs,
|
|
24679
|
+
timeoutSeconds,
|
|
24680
|
+
wait: w
|
|
24681
|
+
}),
|
|
24682
|
+
decodeScaleOrderResult
|
|
24683
|
+
);
|
|
23991
24684
|
}
|
|
23992
24685
|
};
|
|
24686
|
+
return api;
|
|
23993
24687
|
}
|
|
23994
24688
|
|
|
23995
24689
|
// src/agent/attach.ts
|
|
23996
24690
|
function deriveAgentAddress(privateKeyHex) {
|
|
23997
|
-
const privKeyBytes = (0,
|
|
24691
|
+
const privKeyBytes = (0, import_viem7.hexToBytes)(
|
|
23998
24692
|
privateKeyHex.startsWith("0x") ? privateKeyHex : `0x${privateKeyHex}`
|
|
23999
24693
|
);
|
|
24000
24694
|
const uncompressedPubkey = import_secp256k12.secp256k1.getPublicKey(privKeyBytes, false);
|
|
24001
|
-
const pubkeyHash = (0,
|
|
24695
|
+
const pubkeyHash = (0, import_viem7.hexToBytes)((0, import_viem7.keccak256)(uncompressedPubkey.slice(1)));
|
|
24002
24696
|
const evmAddressBytes = pubkeyHash.slice(12);
|
|
24003
24697
|
const evmHex = `0x${(0, import_encoding3.toHex)(evmAddressBytes)}`;
|
|
24004
24698
|
return evmToAult(evmHex);
|
|
@@ -24129,92 +24823,6 @@ async function buildClient(options, resolver) {
|
|
|
24129
24823
|
return client;
|
|
24130
24824
|
}
|
|
24131
24825
|
|
|
24132
|
-
// src/utils/opaque-id.ts
|
|
24133
|
-
var import_viem7 = require("viem");
|
|
24134
|
-
function decodeHex(input) {
|
|
24135
|
-
const clean = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
|
|
24136
|
-
if (clean.length % 2 !== 0) {
|
|
24137
|
-
throw new Error(`invalid hex length: "${input}"`);
|
|
24138
|
-
}
|
|
24139
|
-
if (clean.length > 0 && !/^[0-9a-fA-F]+$/.test(clean)) {
|
|
24140
|
-
throw new Error(`invalid hex characters: "${input}"`);
|
|
24141
|
-
}
|
|
24142
|
-
return (0, import_viem7.hexToBytes)(`0x${clean}`);
|
|
24143
|
-
}
|
|
24144
|
-
function encodeHex(bytes) {
|
|
24145
|
-
return (0, import_viem7.bytesToHex)(bytes).slice(2);
|
|
24146
|
-
}
|
|
24147
|
-
function bytesEqual(a, b) {
|
|
24148
|
-
if (a.length !== b.length) return false;
|
|
24149
|
-
for (let i = 0; i < a.length; i++) {
|
|
24150
|
-
if (a[i] !== b[i]) return false;
|
|
24151
|
-
}
|
|
24152
|
-
return true;
|
|
24153
|
-
}
|
|
24154
|
-
var OpaqueId = class {
|
|
24155
|
-
constructor(bytes) {
|
|
24156
|
-
this.bytes = bytes;
|
|
24157
|
-
}
|
|
24158
|
-
toBytes() {
|
|
24159
|
-
return new Uint8Array(this.bytes);
|
|
24160
|
-
}
|
|
24161
|
-
toHex() {
|
|
24162
|
-
return encodeHex(this.bytes);
|
|
24163
|
-
}
|
|
24164
|
-
toBase64() {
|
|
24165
|
-
return bytesToBase64(this.bytes);
|
|
24166
|
-
}
|
|
24167
|
-
toString() {
|
|
24168
|
-
return this.toHex();
|
|
24169
|
-
}
|
|
24170
|
-
equalsBytes(other) {
|
|
24171
|
-
return bytesEqual(this.bytes, other.bytes);
|
|
24172
|
-
}
|
|
24173
|
-
};
|
|
24174
|
-
var MarketId = class _MarketId extends OpaqueId {
|
|
24175
|
-
static fromHex(hex) {
|
|
24176
|
-
return new _MarketId(_MarketId.assertNonEmpty(decodeHex(hex), `hex "${hex}"`));
|
|
24177
|
-
}
|
|
24178
|
-
static fromBase64(b64) {
|
|
24179
|
-
return new _MarketId(_MarketId.assertNonEmpty(base64ToBytes(b64), `base64 "${b64}"`));
|
|
24180
|
-
}
|
|
24181
|
-
static fromBytes(bytes) {
|
|
24182
|
-
return new _MarketId(_MarketId.assertNonEmpty(new Uint8Array(bytes), "bytes"));
|
|
24183
|
-
}
|
|
24184
|
-
static assertNonEmpty(bytes, source) {
|
|
24185
|
-
if (bytes.length === 0) {
|
|
24186
|
-
throw new Error(`MarketId: empty bytes from ${source}`);
|
|
24187
|
-
}
|
|
24188
|
-
return bytes;
|
|
24189
|
-
}
|
|
24190
|
-
equals(other) {
|
|
24191
|
-
return this.equalsBytes(other);
|
|
24192
|
-
}
|
|
24193
|
-
};
|
|
24194
|
-
var ORDER_ID_LENGTH = 16;
|
|
24195
|
-
var OrderId = class _OrderId extends OpaqueId {
|
|
24196
|
-
static fromHex(hex) {
|
|
24197
|
-
return new _OrderId(_OrderId.assertLength(decodeHex(hex), `hex "${hex}"`));
|
|
24198
|
-
}
|
|
24199
|
-
static fromBase64(b64) {
|
|
24200
|
-
return new _OrderId(_OrderId.assertLength(base64ToBytes(b64), `base64 "${b64}"`));
|
|
24201
|
-
}
|
|
24202
|
-
static fromBytes(bytes) {
|
|
24203
|
-
return new _OrderId(_OrderId.assertLength(new Uint8Array(bytes), "bytes"));
|
|
24204
|
-
}
|
|
24205
|
-
static assertLength(bytes, source) {
|
|
24206
|
-
if (bytes.length !== ORDER_ID_LENGTH) {
|
|
24207
|
-
throw new Error(
|
|
24208
|
-
`OrderId: expected ${ORDER_ID_LENGTH} bytes (chain layout), got ${bytes.length} from ${source}`
|
|
24209
|
-
);
|
|
24210
|
-
}
|
|
24211
|
-
return bytes;
|
|
24212
|
-
}
|
|
24213
|
-
equals(other) {
|
|
24214
|
-
return this.equalsBytes(other);
|
|
24215
|
-
}
|
|
24216
|
-
};
|
|
24217
|
-
|
|
24218
24826
|
// src/rest/types.ts
|
|
24219
24827
|
var import_zod2 = require("zod");
|
|
24220
24828
|
var PageResponseSchema = import_zod2.z.object({
|
|
@@ -24929,7 +25537,7 @@ function createDexWs(url, options) {
|
|
|
24929
25537
|
}
|
|
24930
25538
|
|
|
24931
25539
|
// src/index.ts
|
|
24932
|
-
var SDK_VERSION = "0.0.2-alpha.
|
|
25540
|
+
var SDK_VERSION = "0.0.2-alpha.25";
|
|
24933
25541
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24934
25542
|
0 && (module.exports = {
|
|
24935
25543
|
AGENT_DEFAULTS,
|
|
@@ -25000,6 +25608,7 @@ var SDK_VERSION = "0.0.2-alpha.23";
|
|
|
25000
25608
|
ManifestUrlsSchema,
|
|
25001
25609
|
MarketId,
|
|
25002
25610
|
MarketType,
|
|
25611
|
+
MissingMsgResponseError,
|
|
25003
25612
|
NETWORKS,
|
|
25004
25613
|
NetworkError,
|
|
25005
25614
|
OrderId,
|