ault-sdk-ts 0.0.2-alpha.23 → 0.0.2-alpha.24

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