@truecarry/mcp 0.1.6 → 0.1.7

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/cli.js CHANGED
@@ -2,10 +2,15 @@
2
2
  import { createRequire } from "node:module";
3
3
  import { createServer } from "node:http";
4
4
  import { randomFillSync, randomUUID } from "node:crypto";
5
+ import * as readline from "node:readline";
5
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
7
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
8
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
9
  import { z } from "zod";
10
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
11
+ import { existsSync } from "node:fs";
12
+ import { homedir } from "node:os";
13
+ import { join } from "node:path";
9
14
 
10
15
  //#region \0rolldown/runtime.js
11
16
  var __create = Object.create;
@@ -72002,11 +72007,11 @@ const WalletV5R1CodeCell = import_dist$2.Cell.fromBoc(Buffer.from(WalletV5R1Code
72002
72007
  * LICENSE file in the root directory of this source tree.
72003
72008
  *
72004
72009
  */
72005
- var ActionSendMsg = class ActionSendMsg {
72010
+ var ActionSendMsg$1 = class ActionSendMsg$1 {
72006
72011
  mode;
72007
72012
  outMsg;
72008
72013
  static tag = 247711853;
72009
- tag = ActionSendMsg.tag;
72014
+ tag = ActionSendMsg$1.tag;
72010
72015
  constructor(mode, outMsg) {
72011
72016
  this.mode = mode;
72012
72017
  this.outMsg = outMsg;
@@ -72015,10 +72020,10 @@ var ActionSendMsg = class ActionSendMsg {
72015
72020
  return (0, import_dist$2.beginCell)().storeUint(this.tag, 32).storeUint(this.mode | import_dist$2.SendMode.IGNORE_ERRORS, 8).storeRef((0, import_dist$2.beginCell)().store((0, import_dist$2.storeMessageRelaxed)(this.outMsg)).endCell()).endCell();
72016
72021
  }
72017
72022
  };
72018
- var ActionAddExtension = class ActionAddExtension {
72023
+ var ActionAddExtension$1 = class ActionAddExtension$1 {
72019
72024
  address;
72020
72025
  static tag = 2;
72021
- tag = ActionAddExtension.tag;
72026
+ tag = ActionAddExtension$1.tag;
72022
72027
  constructor(address) {
72023
72028
  this.address = address;
72024
72029
  }
@@ -72026,10 +72031,10 @@ var ActionAddExtension = class ActionAddExtension {
72026
72031
  return (0, import_dist$2.beginCell)().storeUint(this.tag, 8).storeAddress(this.address).endCell();
72027
72032
  }
72028
72033
  };
72029
- var ActionRemoveExtension = class ActionRemoveExtension {
72034
+ var ActionRemoveExtension$1 = class ActionRemoveExtension$1 {
72030
72035
  address;
72031
72036
  static tag = 3;
72032
- tag = ActionRemoveExtension.tag;
72037
+ tag = ActionRemoveExtension$1.tag;
72033
72038
  constructor(address) {
72034
72039
  this.address = address;
72035
72040
  }
@@ -72037,10 +72042,10 @@ var ActionRemoveExtension = class ActionRemoveExtension {
72037
72042
  return (0, import_dist$2.beginCell)().storeUint(this.tag, 8).storeAddress(this.address).endCell();
72038
72043
  }
72039
72044
  };
72040
- var ActionSetSignatureAuthAllowed = class ActionSetSignatureAuthAllowed {
72045
+ var ActionSetSignatureAuthAllowed$1 = class ActionSetSignatureAuthAllowed$1 {
72041
72046
  allowed;
72042
72047
  static tag = 4;
72043
- tag = ActionSetSignatureAuthAllowed.tag;
72048
+ tag = ActionSetSignatureAuthAllowed$1.tag;
72044
72049
  constructor(allowed) {
72045
72050
  this.allowed = allowed;
72046
72051
  }
@@ -72048,43 +72053,43 @@ var ActionSetSignatureAuthAllowed = class ActionSetSignatureAuthAllowed {
72048
72053
  return (0, import_dist$2.beginCell)().storeUint(this.tag, 8).storeUint(this.allowed ? 1 : 0, 1).endCell();
72049
72054
  }
72050
72055
  };
72051
- function isExtendedAction(action) {
72052
- return action.tag === ActionAddExtension.tag || action.tag === ActionRemoveExtension.tag || action.tag === ActionSetSignatureAuthAllowed.tag;
72056
+ function isExtendedAction$1(action) {
72057
+ return action.tag === ActionAddExtension$1.tag || action.tag === ActionRemoveExtension$1.tag || action.tag === ActionSetSignatureAuthAllowed$1.tag;
72053
72058
  }
72054
- function packActionsListOut(actions) {
72059
+ function packActionsListOut$1(actions) {
72055
72060
  if (actions.length === 0) return (0, import_dist$2.beginCell)().endCell();
72056
72061
  const [action, ...rest] = actions;
72057
- if (isExtendedAction(action)) throw new Error("Actions bust be in an order: all extended actions, all out actions");
72058
- return (0, import_dist$2.beginCell)().storeRef(packActionsListOut(rest)).storeSlice(action.serialize().beginParse()).endCell();
72062
+ if (isExtendedAction$1(action)) throw new Error("Actions bust be in an order: all extended actions, all out actions");
72063
+ return (0, import_dist$2.beginCell)().storeRef(packActionsListOut$1(rest)).storeSlice(action.serialize().beginParse()).endCell();
72059
72064
  }
72060
- function packExtendedActions(extendedActions) {
72065
+ function packExtendedActions$1(extendedActions) {
72061
72066
  const first = extendedActions[0];
72062
72067
  const rest = extendedActions.slice(1);
72063
72068
  let builder = (0, import_dist$2.beginCell)().storeSlice(first.serialize().beginParse());
72064
- if (rest.length > 0) builder = builder.storeRef(packExtendedActions(extendedActions.slice(1)));
72069
+ if (rest.length > 0) builder = builder.storeRef(packExtendedActions$1(extendedActions.slice(1)));
72065
72070
  return builder.endCell();
72066
72071
  }
72067
- function packActionsListExtended(actions) {
72072
+ function packActionsListExtended$1(actions) {
72068
72073
  const extendedActions = [];
72069
72074
  const outActions = [];
72070
72075
  actions.forEach((action) => {
72071
- if (isExtendedAction(action)) extendedActions.push(action);
72076
+ if (isExtendedAction$1(action)) extendedActions.push(action);
72072
72077
  else outActions.push(action);
72073
72078
  });
72074
72079
  let builder = (0, import_dist$2.beginCell)();
72075
72080
  if (outActions.length === 0) builder = builder.storeUint(0, 1);
72076
- else builder = builder.storeMaybeRef(packActionsListOut(outActions.slice().reverse()));
72081
+ else builder = builder.storeMaybeRef(packActionsListOut$1(outActions.slice().reverse()));
72077
72082
  if (extendedActions.length === 0) builder = builder.storeUint(0, 1);
72078
72083
  else {
72079
72084
  const first = extendedActions[0];
72080
72085
  const rest = extendedActions.slice(1);
72081
72086
  builder = builder.storeUint(1, 1).storeSlice(first.serialize().beginParse());
72082
- if (rest.length > 0) builder = builder.storeRef(packExtendedActions(rest));
72087
+ if (rest.length > 0) builder = builder.storeRef(packExtendedActions$1(rest));
72083
72088
  }
72084
72089
  return builder.endCell();
72085
72090
  }
72086
- function packActionsList(actions) {
72087
- return packActionsListExtended(actions);
72091
+ function packActionsList$1(actions) {
72092
+ return packActionsListExtended$1(actions);
72088
72093
  }
72089
72094
 
72090
72095
  //#endregion
@@ -72165,7 +72170,7 @@ var WalletV5R1Adapter = class WalletV5R1Adapter {
72165
72170
  return createWalletId(this.getNetwork(), this.getAddress());
72166
72171
  }
72167
72172
  async getSignedSendTransaction(input, options) {
72168
- const actions = packActionsList(input.messages.map((m) => {
72173
+ const actions = packActionsList$1(input.messages.map((m) => {
72169
72174
  let bounce = true;
72170
72175
  if (import_dist$2.Address.parseFriendly(m.address).isBounceable === false) bounce = false;
72171
72176
  const msg = (0, import_dist$2.internal)({
@@ -72186,7 +72191,7 @@ var WalletV5R1Adapter = class WalletV5R1Adapter {
72186
72191
  log$4.warn("Failed to load state init", { error });
72187
72192
  throw WalletKitError.fromError(ERROR_CODES.CONTRACT_VALIDATION_FAILED, "Failed to parse state init", error);
72188
72193
  }
72189
- return new ActionSendMsg(import_dist$2.SendMode.PAY_GAS_SEPARATELY + import_dist$2.SendMode.IGNORE_ERRORS, msg);
72194
+ return new ActionSendMsg$1(import_dist$2.SendMode.PAY_GAS_SEPARATELY + import_dist$2.SendMode.IGNORE_ERRORS, msg);
72190
72195
  }));
72191
72196
  const createBodyOptions = {
72192
72197
  ...options,
@@ -72305,7 +72310,7 @@ var WalletV5R1Adapter = class WalletV5R1Adapter {
72305
72310
  function walletV5ConfigToCell(config) {
72306
72311
  return (0, import_dist$2.beginCell)().storeBit(config.signatureAllowed).storeUint(config.seqno, 32).storeUint(config.walletId, 32).storeUint(config.publicKey, 256).storeDict(config.extensions, import_dist$2.Dictionary.Keys.BigUint(256), import_dist$2.Dictionary.Values.BigInt(1)).endCell();
72307
72312
  }
72308
- const Opcodes = {
72313
+ const Opcodes$1 = {
72309
72314
  action_send_msg: 247711853,
72310
72315
  action_set_code: 2907562126,
72311
72316
  action_extended_set_data: 536406539,
@@ -72368,7 +72373,7 @@ var WalletV5 = class WalletV5 {
72368
72373
  await provider.internal(via, {
72369
72374
  value: opts.value,
72370
72375
  sendMode: import_dist$2.SendMode.PAY_GAS_SEPARATELY,
72371
- body: (0, import_dist$2.beginCell)().storeUint(Opcodes.auth_extension, 32).storeUint(0, 64).storeSlice(opts.body.beginParse()).endCell()
72376
+ body: (0, import_dist$2.beginCell)().storeUint(Opcodes$1.auth_extension, 32).storeUint(0, 64).storeSlice(opts.body.beginParse()).endCell()
72372
72377
  });
72373
72378
  }
72374
72379
  async sendInternal(provider, via, opts) {
@@ -72749,6 +72754,415 @@ var WalletV4R2Adapter = class WalletV4R2Adapter {
72749
72754
  }
72750
72755
  };
72751
72756
 
72757
+ //#endregion
72758
+ //#region src/contracts/w5_ownable/WalletOwnable.ts
72759
+ function walletOwnableConfigToCell(config) {
72760
+ return (0, import_dist$2.beginCell)().storeUint(config.nftInfo.itemIndex, 256).storeAddress(config.nftInfo.collectionAddress).endCell();
72761
+ }
72762
+ const Opcodes = {
72763
+ action_send_msg: 247711853,
72764
+ action_set_code: 2907562126,
72765
+ action_extended_set_data: 536406539,
72766
+ action_extended_add_extension: 2,
72767
+ action_extended_remove_extension: 3,
72768
+ action_extended_set_signature_auth_allowed: 4,
72769
+ auth_extension: 1702392942,
72770
+ auth_signed: 1936287598,
72771
+ auth_signed_internal: 1936289396,
72772
+ internal_request_from_owner: 1935745870,
72773
+ ask_to_change_ownership: 1607220500,
72774
+ notification_for_new_owner: 85167505,
72775
+ return_excesses_back: 3576854235
72776
+ };
72777
+ var WalletOwnableId = class WalletOwnableId {
72778
+ static deserialize(walletId) {
72779
+ return new WalletOwnableId({ subwalletNumber: walletId });
72780
+ }
72781
+ subwalletNumber;
72782
+ serialized;
72783
+ constructor(args) {
72784
+ this.subwalletNumber = args?.subwalletNumber ?? 0;
72785
+ this.serialized = BigInt(this.subwalletNumber);
72786
+ }
72787
+ };
72788
+ var WalletOwnable = class WalletOwnable {
72789
+ subwalletId;
72790
+ constructor(client, address, init) {
72791
+ this.client = client;
72792
+ this.address = address;
72793
+ this.init = init;
72794
+ }
72795
+ static createFromAddress(client, address) {
72796
+ return new WalletOwnable(client, address);
72797
+ }
72798
+ static createFromConfig(config, options) {
72799
+ const data = walletOwnableConfigToCell(config);
72800
+ const init = {
72801
+ code: options.code,
72802
+ data
72803
+ };
72804
+ const wallet = new WalletOwnable(options.client, (0, import_dist$2.contractAddress)(options.workchain, init), init);
72805
+ wallet.subwalletId = config.walletId;
72806
+ return wallet;
72807
+ }
72808
+ async sendInternalSignedMessage(provider, via, opts) {
72809
+ await provider.internal(via, {
72810
+ value: opts.value,
72811
+ sendMode: import_dist$2.SendMode.PAY_GAS_SEPARATELY,
72812
+ body: (0, import_dist$2.beginCell)().storeSlice(opts.body.beginParse()).endCell()
72813
+ });
72814
+ }
72815
+ async sendInternalMessageFromExtension(provider, via, opts) {
72816
+ await provider.internal(via, {
72817
+ value: opts.value,
72818
+ sendMode: import_dist$2.SendMode.PAY_GAS_SEPARATELY,
72819
+ body: (0, import_dist$2.beginCell)().storeUint(Opcodes.auth_extension, 32).storeUint(0, 64).storeSlice(opts.body.beginParse()).endCell()
72820
+ });
72821
+ }
72822
+ async sendInternal(provider, via, opts) {
72823
+ await provider.internal(via, opts);
72824
+ }
72825
+ async sendExternalSignedMessage(provider, body) {
72826
+ await provider.external(body);
72827
+ }
72828
+ async sendExternal(provider, body) {
72829
+ await provider.external(body);
72830
+ }
72831
+ get publicKey() {
72832
+ return this.client.runGetMethod(formatWalletAddress(this.address), "get_public_key").then((data) => {
72833
+ if (data.exitCode === 0) {
72834
+ const parsedStack = ParseStack(data.stack);
72835
+ if (parsedStack[0]?.type === "int") return parsedStack[0].value;
72836
+ else throw new Error("Stack is not an int");
72837
+ } else if (this.init) return this.init.data.asSlice().skip(65).loadUintBig(256);
72838
+ else return 0n;
72839
+ });
72840
+ }
72841
+ get status() {
72842
+ return this.client.getAccountState(formatWalletAddress(this.address)).then((state) => state.status);
72843
+ }
72844
+ get seqno() {
72845
+ return this.client.runGetMethod(formatWalletAddress(this.address), "seqno").then((data) => {
72846
+ if (data.exitCode === 0) {
72847
+ const parsedStack = ParseStack(data.stack);
72848
+ if (parsedStack[0]?.type === "int") return Number(parsedStack[0].value);
72849
+ else throw new Error("Stack is not an int");
72850
+ } else return 0;
72851
+ });
72852
+ }
72853
+ get isSignatureAuthAllowed() {
72854
+ return this.client.runGetMethod(formatWalletAddress(this.address), "is_signature_allowed").then((data) => {
72855
+ if (data.exitCode === 0) {
72856
+ const parsedStack = ParseStack(data.stack);
72857
+ if (parsedStack[0]?.type === "int") return Boolean(parsedStack[0].value);
72858
+ else throw new Error("Stack is not an int");
72859
+ } else return false;
72860
+ });
72861
+ }
72862
+ get walletId() {
72863
+ return WalletOwnableId.deserialize(this.subwalletId);
72864
+ }
72865
+ };
72866
+
72867
+ //#endregion
72868
+ //#region src/contracts/w5_ownable/WalletOwnable.source.ts
72869
+ /**
72870
+ * Copyright (c) TonTech.
72871
+ *
72872
+ * This source code is licensed under the MIT license found in the
72873
+ * LICENSE file in the root directory of this source tree.
72874
+ *
72875
+ */
72876
+ const WalletOwnableCodeBoc = "b5ee9c7241021c01000439000114ff00f4a413f4bcf2c80b01020120021b020148030f0202ce040a0397420d72c239b091a748e2331f404f404d20003f003ed44d0810141d721f401fa4830f892c705f2e521587070f002e0d72c22fe61e8a4e302d72c239b4b73a4e30231d72c232bc3a374e30230805080902fe31ed44d0d640d3ff31f404fa48f89222c705f2e19104d33ffa48fa50f401fa0020d749f2e2c423fa4430f2d14df89370f83af8276f10820afaf080a123945331a0a1de246e91319824fa4430f2d14da2e220c2fff2e1922292365be30d206e93135f038e19c8cf8508fa525003fa028210d53276dbcf0b8acb3fc971fb00e206070048c8cf90144e364626cf0b3f17fa52cec9c8cf85085240fa5258fa0271cf0b6accc971fb00012288f90003c8ce13cbfff400fa52cec9ed541900d0d31fd31fd31ff404f404d20003f00326d749810280be925f07e1268308d722078308d723ed44d0d200d31f20d31fd3fff40506f90140ddf910925f0be1036e12b1f2e0845155baf2e0855067baf2e08603f823bcf2e08801a4c8cf83cb1f14cec9ed54027070f002006ad33f31f404f404d20003f003f892fa44f828fa443058bd925f04e0ed44d0810141d721f4058307f40e6fa131925f03e158707ff0020201200b0e01a5091ba48d0c23909c0975ce4c238b8835d2f000bcb824f00a3cb824f5cb081d8790db3cb824f535c2c1c9255cac3cb822644c38b5ce4c00690871c004b98c1b04a101eefcb824c0fb55788063a0c076cf3816e00c0192eda2edfbeb21d72c08148e2efa4830fa44f828fa443058baf2e091ed44d0810141d718f404c8cf8350428307f453f2e08b01c8cef400cec9ed54e30e21d74a935bdb31e101d74cd0010d00eed72c081c8e37fa4830fa44f828fa443058baf2e091ed44d0d200810140d718f40450448307f45bf2e08c2295206ef2d090df02c8ca00cef400cec9ed548e37d72c082493f2c08de121f2e092ed44d001d70a0001d20020810140d721f4055123bdf2e08f22913195016ef2d08ee201c8ca00cec9ed54e200953b51340835d2b0802456f8085bbcb42534fffe923448be4008aebcb82540b4348034c7f4fffd013e9234417232ffc5be94b240f2328033e40000000084b2c7f2ffc4fd003e94b3327b55200201201017020120111402016e12130017adce76a26869a018eb85ffc00017af1df6a268699018eb858fc002014815160017b325fb513434c00c75c2c7e00011b262fb513435c28020020120181a0163b8fcfed44d020d74ac20099d3fffa48d170596d6de1d20031d31f31d31f31d3ff31f40431fa48d4d1d0d3fffa48d17f881481900000019b8be1ed44d0810141d721f405800d6f2208308d722018308d72320d72c239b4b3b74f2e08ad31fd31fd31ff404f404d20003f003ed44d0d200d31f20d31fd3fff4050cf90140ddf910f2e087096e12b1f2e0845144baf2e0855057baf2e08602f823bcf2e088f800a4c8cf83cb1f13cec9ed54f80f597f70f0023cbf4a56";
72877
+ const WalletOwnableCodeCell = import_dist$2.Cell.fromBoc(Buffer.from(WalletOwnableCodeBoc, "hex"))[0];
72878
+
72879
+ //#endregion
72880
+ //#region src/contracts/w5_ownable/actions.ts
72881
+ var ActionSendMsg = class ActionSendMsg {
72882
+ static tag = 247711853;
72883
+ tag = ActionSendMsg.tag;
72884
+ constructor(mode, outMsg) {
72885
+ this.mode = mode;
72886
+ this.outMsg = outMsg;
72887
+ }
72888
+ serialize() {
72889
+ return (0, import_dist$2.beginCell)().storeUint(this.tag, 32).storeUint(this.mode | import_dist$2.SendMode.IGNORE_ERRORS, 8).storeRef((0, import_dist$2.beginCell)().store((0, import_dist$2.storeMessageRelaxed)(this.outMsg)).endCell()).endCell();
72890
+ }
72891
+ };
72892
+ var ActionAddExtension = class ActionAddExtension {
72893
+ static tag = 2;
72894
+ tag = ActionAddExtension.tag;
72895
+ constructor(address) {
72896
+ this.address = address;
72897
+ }
72898
+ serialize() {
72899
+ return (0, import_dist$2.beginCell)().storeUint(this.tag, 8).storeAddress(this.address).endCell();
72900
+ }
72901
+ };
72902
+ var ActionRemoveExtension = class ActionRemoveExtension {
72903
+ static tag = 3;
72904
+ tag = ActionRemoveExtension.tag;
72905
+ constructor(address) {
72906
+ this.address = address;
72907
+ }
72908
+ serialize() {
72909
+ return (0, import_dist$2.beginCell)().storeUint(this.tag, 8).storeAddress(this.address).endCell();
72910
+ }
72911
+ };
72912
+ var ActionSetSignatureAuthAllowed = class ActionSetSignatureAuthAllowed {
72913
+ static tag = 4;
72914
+ tag = ActionSetSignatureAuthAllowed.tag;
72915
+ constructor(allowed) {
72916
+ this.allowed = allowed;
72917
+ }
72918
+ serialize() {
72919
+ return (0, import_dist$2.beginCell)().storeUint(this.tag, 8).storeUint(this.allowed ? 1 : 0, 1).endCell();
72920
+ }
72921
+ };
72922
+ function isExtendedAction(action) {
72923
+ return action.tag === ActionAddExtension.tag || action.tag === ActionRemoveExtension.tag || action.tag === ActionSetSignatureAuthAllowed.tag;
72924
+ }
72925
+ function packActionsListOut(actions) {
72926
+ if (actions.length === 0) return (0, import_dist$2.beginCell)().endCell();
72927
+ const [action, ...rest] = actions;
72928
+ if (isExtendedAction(action)) throw new Error("Actions bust be in an order: all extended actions, all out actions");
72929
+ return (0, import_dist$2.beginCell)().storeRef(packActionsListOut(rest)).storeSlice(action.serialize().beginParse()).endCell();
72930
+ }
72931
+ function packExtendedActions(extendedActions) {
72932
+ const first = extendedActions[0];
72933
+ const rest = extendedActions.slice(1);
72934
+ let builder = (0, import_dist$2.beginCell)().storeSlice(first.serialize().beginParse());
72935
+ if (rest.length > 0) builder = builder.storeRef(packExtendedActions(extendedActions.slice(1)));
72936
+ return builder.endCell();
72937
+ }
72938
+ function packActionsListExtended(actions) {
72939
+ const extendedActions = [];
72940
+ const outActions = [];
72941
+ actions.forEach((action) => {
72942
+ if (isExtendedAction(action)) extendedActions.push(action);
72943
+ else outActions.push(action);
72944
+ });
72945
+ let builder = (0, import_dist$2.beginCell)();
72946
+ if (outActions.length === 0) builder = builder.storeUint(0, 1);
72947
+ else builder = builder.storeMaybeRef(packActionsListOut(outActions.slice().reverse()));
72948
+ if (extendedActions.length === 0) builder = builder.storeUint(0, 1);
72949
+ else {
72950
+ const first = extendedActions[0];
72951
+ const rest = extendedActions.slice(1);
72952
+ builder = builder.storeUint(1, 1).storeSlice(first.serialize().beginParse());
72953
+ if (rest.length > 0) builder = builder.storeRef(packExtendedActions(rest));
72954
+ }
72955
+ return builder.endCell();
72956
+ }
72957
+ function packActionsList(actions) {
72958
+ return packActionsListExtended(actions);
72959
+ }
72960
+
72961
+ //#endregion
72962
+ //#region src/contracts/w5_ownable/WalletOwnableAdapter.ts
72963
+ const defaultWalletOwnableId = 2147483409;
72964
+ /**
72965
+ * WalletOwnable adapter that implements WalletInterface
72966
+ * Used when MCP controls a user's wallet with its own keypair
72967
+ */
72968
+ var WalletOwnableAdapter = class WalletOwnableAdapter {
72969
+ signer;
72970
+ config;
72971
+ walletContract;
72972
+ client;
72973
+ publicKey;
72974
+ version = "w5_ownable";
72975
+ walletId;
72976
+ /**
72977
+ * Static factory method to create a WalletOwnableAdapter
72978
+ * @param signer - Signer function with publicKey property (from Signer utility)
72979
+ * @param options - Configuration options for the wallet
72980
+ */
72981
+ static async create(signer, options) {
72982
+ return new WalletOwnableAdapter({
72983
+ signer,
72984
+ publicKey: signer.publicKey,
72985
+ tonClient: options.client,
72986
+ network: options.network,
72987
+ walletId: options.walletId,
72988
+ workchain: options.workchain,
72989
+ owner: options.owner,
72990
+ nftInfo: options.nftInfo
72991
+ });
72992
+ }
72993
+ constructor(config) {
72994
+ this.config = config;
72995
+ this.client = config.tonClient;
72996
+ this.signer = config.signer;
72997
+ this.publicKey = this.config.publicKey;
72998
+ const walletId = typeof config.walletId === "bigint" ? Number(config.walletId) : config.walletId ?? defaultWalletOwnableId;
72999
+ this.walletId = BigInt(walletId);
73000
+ const initCell = this.createItemInitAtDeployment();
73001
+ this.config.nftInfo = {
73002
+ itemIndex: BigInt("0x" + initCell.hash().toString("hex")),
73003
+ collectionAddress: config.nftInfo.collectionAddress
73004
+ };
73005
+ this.walletContract = WalletOwnable.createFromConfig({
73006
+ publicKey: HexToBigInt(this.publicKey),
73007
+ seqno: 0,
73008
+ signatureAllowed: true,
73009
+ walletId,
73010
+ extensions: import_dist$2.Dictionary.empty(),
73011
+ owner: config.owner,
73012
+ nftInfo: this.config.nftInfo
73013
+ }, {
73014
+ code: WalletOwnableCodeCell,
73015
+ workchain: config.workchain ?? 0,
73016
+ client: this.client
73017
+ });
73018
+ }
73019
+ getPublicKey() {
73020
+ return this.publicKey;
73021
+ }
73022
+ getClient() {
73023
+ return this.client;
73024
+ }
73025
+ /**
73026
+ * Sign raw bytes with wallet's private key
73027
+ */
73028
+ async sign(bytes) {
73029
+ return this.signer.sign(bytes);
73030
+ }
73031
+ getNetwork() {
73032
+ return this.config.network;
73033
+ }
73034
+ /**
73035
+ * Get wallet's TON address
73036
+ */
73037
+ getAddress(options) {
73038
+ return formatWalletAddress(this.walletContract.address, options?.testnet);
73039
+ }
73040
+ getWalletId() {
73041
+ return createWalletId(this.getNetwork(), this.getAddress());
73042
+ }
73043
+ async getSignedSendTransaction(input, options) {
73044
+ const actions = packActionsList(input.messages.map((m) => {
73045
+ let bounce = true;
73046
+ if (import_dist$2.Address.parseFriendly(m.address).isBounceable === false) bounce = false;
73047
+ const msg = (0, import_dist$2.internal)({
73048
+ to: m.address,
73049
+ value: BigInt(m.amount),
73050
+ bounce,
73051
+ extracurrency: m.extraCurrency ? Object.fromEntries(Object.entries(m.extraCurrency).map(([k, v]) => [Number(k), BigInt(v)])) : void 0
73052
+ });
73053
+ if (m.payload) try {
73054
+ msg.body = import_dist$2.Cell.fromBase64(m.payload);
73055
+ } catch (error) {
73056
+ throw WalletKitError.fromError(ERROR_CODES.CONTRACT_VALIDATION_FAILED, "Failed to parse transaction payload", error);
73057
+ }
73058
+ if (m.stateInit) try {
73059
+ msg.init = (0, import_dist$2.loadStateInit)(import_dist$2.Cell.fromBase64(m.stateInit).asSlice());
73060
+ } catch (error) {
73061
+ throw WalletKitError.fromError(ERROR_CODES.CONTRACT_VALIDATION_FAILED, "Failed to parse state init", error);
73062
+ }
73063
+ return new ActionSendMsg(import_dist$2.SendMode.PAY_GAS_SEPARATELY + import_dist$2.SendMode.IGNORE_ERRORS, msg);
73064
+ }));
73065
+ const createBodyOptions = {
73066
+ ...options,
73067
+ validUntil: void 0
73068
+ };
73069
+ if (input.validUntil) {
73070
+ const now = Math.floor(Date.now() / 1e3);
73071
+ const maxValidUntil = now + 600;
73072
+ if (input.validUntil < now) throw new WalletKitError(ERROR_CODES.VALIDATION_ERROR, "Transaction valid_until timestamp is in the past", void 0, {
73073
+ validUntil: input.validUntil,
73074
+ currentTime: now
73075
+ });
73076
+ else if (input.validUntil > maxValidUntil) createBodyOptions.validUntil = maxValidUntil;
73077
+ else createBodyOptions.validUntil = input.validUntil;
73078
+ }
73079
+ let seqno = 0;
73080
+ try {
73081
+ seqno = await CallForSuccess(async () => this.getSeqno(), 5, 1e3);
73082
+ } catch (_) {}
73083
+ const walletId = (await this.walletContract.walletId).serialized;
73084
+ if (!walletId) throw new Error("Failed to get seqno or walletId");
73085
+ const transfer = await this.createBody(seqno, walletId, actions, createBodyOptions);
73086
+ const ext = (0, import_dist$2.external)({
73087
+ to: this.walletContract.address,
73088
+ init: this.walletContract.init,
73089
+ body: transfer
73090
+ });
73091
+ return (0, import_dist$2.beginCell)().store((0, import_dist$2.storeMessage)(ext)).endCell().toBoc().toString("base64");
73092
+ }
73093
+ /**
73094
+ * Get state init for wallet deployment
73095
+ */
73096
+ async getStateInit() {
73097
+ if (!this.walletContract.init) throw new Error("Wallet contract not properly initialized");
73098
+ return (0, import_dist$2.beginCell)().store((0, import_dist$2.storeStateInit)(this.walletContract.init)).endCell().toBoc().toString("base64");
73099
+ }
73100
+ /**
73101
+ * Get the underlying WalletOwnable contract
73102
+ */
73103
+ getContract() {
73104
+ return this.walletContract;
73105
+ }
73106
+ /**
73107
+ * Get current sequence number
73108
+ */
73109
+ async getSeqno() {
73110
+ return await this.walletContract.seqno;
73111
+ }
73112
+ /**
73113
+ * Get wallet ID
73114
+ */
73115
+ async getWalletOwnableId() {
73116
+ try {
73117
+ return this.walletContract.walletId;
73118
+ } catch (_error) {
73119
+ const walletId = this.config.walletId;
73120
+ return new WalletOwnableId({ subwalletNumber: typeof walletId === "bigint" ? Number(walletId) : walletId || 0 });
73121
+ }
73122
+ }
73123
+ /**
73124
+ * Check if wallet is deployed on the network
73125
+ */
73126
+ async isDeployed() {
73127
+ try {
73128
+ return (await this.client.getAccountState(formatWalletAddress(this.walletContract.address))).status === "active";
73129
+ } catch (_error) {
73130
+ return false;
73131
+ }
73132
+ }
73133
+ createItemInitAtDeployment() {
73134
+ return (0, import_dist$2.beginCell)().storeUint(1, 1).storeUint(Number(this.walletId), 32).storeUint(HexToBigInt(this.publicKey), 256).storeBit(0).storeAddress(this.config.owner).endCell();
73135
+ }
73136
+ async createBody(seqno, walletId, actionsList, options) {
73137
+ const Opcodes = { auth_signed: 1936287598 };
73138
+ const expireAt = options.validUntil ?? Math.floor(Date.now() / 1e3) + 300;
73139
+ const payload = (0, import_dist$2.beginCell)().storeUint(Opcodes.auth_signed, 32).storeUint(walletId, 32).storeUint(expireAt, 32).storeUint(seqno, 32).storeMaybeRef(this.createItemInitAtDeployment()).storeSlice(actionsList.beginParse()).endCell();
73140
+ const signingData = payload.hash();
73141
+ const signature = options.fakeSignature ? FakeSignature(signingData) : await this.sign(signingData);
73142
+ return (0, import_dist$2.beginCell)().storeSlice(payload.beginParse()).storeBuffer(Buffer.from(HexToUint8Array(signature))).endCell();
73143
+ }
73144
+ async getSignedSignData(input) {
73145
+ return await this.sign(HexToUint8Array(input.hash));
73146
+ }
73147
+ async getSignedTonProof(input) {
73148
+ const message = await CreateTonProofMessageBytes(input);
73149
+ return await this.sign(message);
73150
+ }
73151
+ getSupportedFeatures() {
73152
+ return [{
73153
+ name: "SendTransaction",
73154
+ maxMessages: 255
73155
+ }, {
73156
+ name: "SignData",
73157
+ types: [
73158
+ "binary",
73159
+ "cell",
73160
+ "text"
73161
+ ]
73162
+ }];
73163
+ }
73164
+ };
73165
+
72752
73166
  //#endregion
72753
73167
  //#region ../../node_modules/@ston-fi/omniston-sdk/node_modules/rxjs/dist/cjs/internal/util/isFunction.js
72754
73168
  var require_isFunction = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -86105,7 +86519,7 @@ function createBaseAddress() {
86105
86519
  address: ""
86106
86520
  };
86107
86521
  }
86108
- const Address$2 = {
86522
+ const Address$3 = {
86109
86523
  fromJSON(object) {
86110
86524
  return {
86111
86525
  blockchain: isSet$7(object.blockchain) ? globalThis.Number(object.blockchain) : 0,
@@ -86119,7 +86533,7 @@ const Address$2 = {
86119
86533
  return obj;
86120
86534
  },
86121
86535
  create(base) {
86122
- return Address$2.fromPartial(base ?? {});
86536
+ return Address$3.fromPartial(base ?? {});
86123
86537
  },
86124
86538
  fromPartial(object) {
86125
86539
  const message = createBaseAddress();
@@ -86196,15 +86610,15 @@ function createBaseSwapStep() {
86196
86610
  const SwapStep = {
86197
86611
  fromJSON(object) {
86198
86612
  return {
86199
- bidAssetAddress: isSet$6(object.bid_asset_address) ? Address$2.fromJSON(object.bid_asset_address) : void 0,
86200
- askAssetAddress: isSet$6(object.ask_asset_address) ? Address$2.fromJSON(object.ask_asset_address) : void 0,
86613
+ bidAssetAddress: isSet$6(object.bid_asset_address) ? Address$3.fromJSON(object.bid_asset_address) : void 0,
86614
+ askAssetAddress: isSet$6(object.ask_asset_address) ? Address$3.fromJSON(object.ask_asset_address) : void 0,
86201
86615
  chunks: globalThis.Array.isArray(object?.chunks) ? object.chunks.map((e) => SwapChunk.fromJSON(e)) : []
86202
86616
  };
86203
86617
  },
86204
86618
  toJSON(message) {
86205
86619
  const obj = {};
86206
- if (message.bidAssetAddress !== void 0) obj.bid_asset_address = Address$2.toJSON(message.bidAssetAddress);
86207
- if (message.askAssetAddress !== void 0) obj.ask_asset_address = Address$2.toJSON(message.askAssetAddress);
86620
+ if (message.bidAssetAddress !== void 0) obj.bid_asset_address = Address$3.toJSON(message.bidAssetAddress);
86621
+ if (message.askAssetAddress !== void 0) obj.ask_asset_address = Address$3.toJSON(message.askAssetAddress);
86208
86622
  if (message.chunks?.length) obj.chunks = message.chunks.map((e) => SwapChunk.toJSON(e));
86209
86623
  return obj;
86210
86624
  },
@@ -86213,8 +86627,8 @@ const SwapStep = {
86213
86627
  },
86214
86628
  fromPartial(object) {
86215
86629
  const message = createBaseSwapStep();
86216
- message.bidAssetAddress = object.bidAssetAddress !== void 0 && object.bidAssetAddress !== null ? Address$2.fromPartial(object.bidAssetAddress) : void 0;
86217
- message.askAssetAddress = object.askAssetAddress !== void 0 && object.askAssetAddress !== null ? Address$2.fromPartial(object.askAssetAddress) : void 0;
86630
+ message.bidAssetAddress = object.bidAssetAddress !== void 0 && object.bidAssetAddress !== null ? Address$3.fromPartial(object.bidAssetAddress) : void 0;
86631
+ message.askAssetAddress = object.askAssetAddress !== void 0 && object.askAssetAddress !== null ? Address$3.fromPartial(object.askAssetAddress) : void 0;
86218
86632
  message.chunks = object.chunks?.map((e) => SwapChunk.fromPartial(e)) || [];
86219
86633
  return message;
86220
86634
  }
@@ -86374,16 +86788,16 @@ function createBaseEscrowSettlementParams() {
86374
86788
  const EscrowSettlementParams = {
86375
86789
  fromJSON(object) {
86376
86790
  return {
86377
- contractAddress: isSet$5(object.contract_address) ? Address$2.fromJSON(object.contract_address) : void 0,
86378
- resolverAddress: isSet$5(object.resolver_address) ? Address$2.fromJSON(object.resolver_address) : void 0,
86791
+ contractAddress: isSet$5(object.contract_address) ? Address$3.fromJSON(object.contract_address) : void 0,
86792
+ resolverAddress: isSet$5(object.resolver_address) ? Address$3.fromJSON(object.resolver_address) : void 0,
86379
86793
  resolveTimeout: isSet$5(object.resolve_timeout) ? globalThis.Number(object.resolve_timeout) : 0,
86380
86794
  gasless: isSet$5(object.gasless) ? globalThis.Boolean(object.gasless) : false
86381
86795
  };
86382
86796
  },
86383
86797
  toJSON(message) {
86384
86798
  const obj = {};
86385
- if (message.contractAddress !== void 0) obj.contract_address = Address$2.toJSON(message.contractAddress);
86386
- if (message.resolverAddress !== void 0) obj.resolver_address = Address$2.toJSON(message.resolverAddress);
86799
+ if (message.contractAddress !== void 0) obj.contract_address = Address$3.toJSON(message.contractAddress);
86800
+ if (message.resolverAddress !== void 0) obj.resolver_address = Address$3.toJSON(message.resolverAddress);
86387
86801
  if (message.resolveTimeout !== void 0) obj.resolve_timeout = Math.round(message.resolveTimeout);
86388
86802
  if (message.gasless !== void 0) obj.gasless = message.gasless;
86389
86803
  return obj;
@@ -86393,8 +86807,8 @@ const EscrowSettlementParams = {
86393
86807
  },
86394
86808
  fromPartial(object) {
86395
86809
  const message = createBaseEscrowSettlementParams();
86396
- message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$2.fromPartial(object.contractAddress) : void 0;
86397
- message.resolverAddress = object.resolverAddress !== void 0 && object.resolverAddress !== null ? Address$2.fromPartial(object.resolverAddress) : void 0;
86810
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$3.fromPartial(object.contractAddress) : void 0;
86811
+ message.resolverAddress = object.resolverAddress !== void 0 && object.resolverAddress !== null ? Address$3.fromPartial(object.resolverAddress) : void 0;
86398
86812
  message.resolveTimeout = object.resolveTimeout ?? 0;
86399
86813
  message.gasless = object.gasless ?? false;
86400
86814
  return message;
@@ -86410,15 +86824,15 @@ function createBaseHtlcSettlementParams() {
86410
86824
  const HtlcSettlementParams = {
86411
86825
  fromJSON(object) {
86412
86826
  return {
86413
- contractAddress: isSet$5(object.contract_address) ? Address$2.fromJSON(object.contract_address) : void 0,
86414
- resolverAddress: isSet$5(object.resolver_address) ? Address$2.fromJSON(object.resolver_address) : void 0,
86827
+ contractAddress: isSet$5(object.contract_address) ? Address$3.fromJSON(object.contract_address) : void 0,
86828
+ resolverAddress: isSet$5(object.resolver_address) ? Address$3.fromJSON(object.resolver_address) : void 0,
86415
86829
  resolveTimeout: isSet$5(object.resolve_timeout) ? globalThis.Number(object.resolve_timeout) : 0
86416
86830
  };
86417
86831
  },
86418
86832
  toJSON(message) {
86419
86833
  const obj = {};
86420
- if (message.contractAddress !== void 0) obj.contract_address = Address$2.toJSON(message.contractAddress);
86421
- if (message.resolverAddress !== void 0) obj.resolver_address = Address$2.toJSON(message.resolverAddress);
86834
+ if (message.contractAddress !== void 0) obj.contract_address = Address$3.toJSON(message.contractAddress);
86835
+ if (message.resolverAddress !== void 0) obj.resolver_address = Address$3.toJSON(message.resolverAddress);
86422
86836
  if (message.resolveTimeout !== void 0) obj.resolve_timeout = Math.round(message.resolveTimeout);
86423
86837
  return obj;
86424
86838
  },
@@ -86427,8 +86841,8 @@ const HtlcSettlementParams = {
86427
86841
  },
86428
86842
  fromPartial(object) {
86429
86843
  const message = createBaseHtlcSettlementParams();
86430
- message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$2.fromPartial(object.contractAddress) : void 0;
86431
- message.resolverAddress = object.resolverAddress !== void 0 && object.resolverAddress !== null ? Address$2.fromPartial(object.resolverAddress) : void 0;
86844
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$3.fromPartial(object.contractAddress) : void 0;
86845
+ message.resolverAddress = object.resolverAddress !== void 0 && object.resolverAddress !== null ? Address$3.fromPartial(object.resolverAddress) : void 0;
86432
86846
  message.resolveTimeout = object.resolveTimeout ?? 0;
86433
86847
  return message;
86434
86848
  }
@@ -86447,10 +86861,10 @@ function createBaseQuoteRequest() {
86447
86861
  const QuoteRequest$1 = {
86448
86862
  fromJSON(object) {
86449
86863
  return {
86450
- bidAssetAddress: isSet$5(object.bid_asset_address) ? Address$2.fromJSON(object.bid_asset_address) : void 0,
86451
- askAssetAddress: isSet$5(object.ask_asset_address) ? Address$2.fromJSON(object.ask_asset_address) : void 0,
86864
+ bidAssetAddress: isSet$5(object.bid_asset_address) ? Address$3.fromJSON(object.bid_asset_address) : void 0,
86865
+ askAssetAddress: isSet$5(object.ask_asset_address) ? Address$3.fromJSON(object.ask_asset_address) : void 0,
86452
86866
  amount: isSet$5(object.amount) ? QuoteRequest_AmountOneOf.fromJSON(object.amount) : void 0,
86453
- referrerAddress: isSet$5(object.referrer_address) ? Address$2.fromJSON(object.referrer_address) : void 0,
86867
+ referrerAddress: isSet$5(object.referrer_address) ? Address$3.fromJSON(object.referrer_address) : void 0,
86454
86868
  referrerFeeBps: isSet$5(object.referrer_fee_bps) ? globalThis.Number(object.referrer_fee_bps) : 0,
86455
86869
  settlementMethods: globalThis.Array.isArray(object?.settlement_methods) ? object.settlement_methods.map((e) => settlementMethodFromJSON(e)) : [],
86456
86870
  settlementParams: isSet$5(object.settlement_params) ? RequestSettlementParams.fromJSON(object.settlement_params) : void 0
@@ -86458,10 +86872,10 @@ const QuoteRequest$1 = {
86458
86872
  },
86459
86873
  toJSON(message) {
86460
86874
  const obj = {};
86461
- if (message.bidAssetAddress !== void 0) obj.bid_asset_address = Address$2.toJSON(message.bidAssetAddress);
86462
- if (message.askAssetAddress !== void 0) obj.ask_asset_address = Address$2.toJSON(message.askAssetAddress);
86875
+ if (message.bidAssetAddress !== void 0) obj.bid_asset_address = Address$3.toJSON(message.bidAssetAddress);
86876
+ if (message.askAssetAddress !== void 0) obj.ask_asset_address = Address$3.toJSON(message.askAssetAddress);
86463
86877
  if (message.amount !== void 0) obj.amount = QuoteRequest_AmountOneOf.toJSON(message.amount);
86464
- if (message.referrerAddress !== void 0) obj.referrer_address = Address$2.toJSON(message.referrerAddress);
86878
+ if (message.referrerAddress !== void 0) obj.referrer_address = Address$3.toJSON(message.referrerAddress);
86465
86879
  if (message.referrerFeeBps !== void 0) obj.referrer_fee_bps = Math.round(message.referrerFeeBps);
86466
86880
  if (message.settlementMethods?.length) obj.settlement_methods = message.settlementMethods.map((e) => settlementMethodToJSON(e));
86467
86881
  if (message.settlementParams !== void 0) obj.settlement_params = RequestSettlementParams.toJSON(message.settlementParams);
@@ -86472,10 +86886,10 @@ const QuoteRequest$1 = {
86472
86886
  },
86473
86887
  fromPartial(object) {
86474
86888
  const message = createBaseQuoteRequest();
86475
- message.bidAssetAddress = object.bidAssetAddress !== void 0 && object.bidAssetAddress !== null ? Address$2.fromPartial(object.bidAssetAddress) : void 0;
86476
- message.askAssetAddress = object.askAssetAddress !== void 0 && object.askAssetAddress !== null ? Address$2.fromPartial(object.askAssetAddress) : void 0;
86889
+ message.bidAssetAddress = object.bidAssetAddress !== void 0 && object.bidAssetAddress !== null ? Address$3.fromPartial(object.bidAssetAddress) : void 0;
86890
+ message.askAssetAddress = object.askAssetAddress !== void 0 && object.askAssetAddress !== null ? Address$3.fromPartial(object.askAssetAddress) : void 0;
86477
86891
  message.amount = object.amount !== void 0 && object.amount !== null ? QuoteRequest_AmountOneOf.fromPartial(object.amount) : void 0;
86478
- message.referrerAddress = object.referrerAddress !== void 0 && object.referrerAddress !== null ? Address$2.fromPartial(object.referrerAddress) : void 0;
86892
+ message.referrerAddress = object.referrerAddress !== void 0 && object.referrerAddress !== null ? Address$3.fromPartial(object.referrerAddress) : void 0;
86479
86893
  message.referrerFeeBps = object.referrerFeeBps ?? 0;
86480
86894
  message.settlementMethods = object.settlementMethods?.map((e) => e) || [];
86481
86895
  message.settlementParams = object.settlementParams !== void 0 && object.settlementParams !== null ? RequestSettlementParams.fromPartial(object.settlementParams) : void 0;
@@ -86538,14 +86952,14 @@ const Quote = {
86538
86952
  quoteId: isSet$5(object.quote_id) ? globalThis.String(object.quote_id) : "",
86539
86953
  resolverId: isSet$5(object.resolver_id) ? globalThis.String(object.resolver_id) : "",
86540
86954
  resolverName: isSet$5(object.resolver_name) ? globalThis.String(object.resolver_name) : "",
86541
- bidAssetAddress: isSet$5(object.bid_asset_address) ? Address$2.fromJSON(object.bid_asset_address) : void 0,
86542
- askAssetAddress: isSet$5(object.ask_asset_address) ? Address$2.fromJSON(object.ask_asset_address) : void 0,
86955
+ bidAssetAddress: isSet$5(object.bid_asset_address) ? Address$3.fromJSON(object.bid_asset_address) : void 0,
86956
+ askAssetAddress: isSet$5(object.ask_asset_address) ? Address$3.fromJSON(object.ask_asset_address) : void 0,
86543
86957
  bidUnits: isSet$5(object.bid_units) ? globalThis.String(object.bid_units) : "",
86544
86958
  askUnits: isSet$5(object.ask_units) ? globalThis.String(object.ask_units) : "",
86545
- referrerAddress: isSet$5(object.referrer_address) ? Address$2.fromJSON(object.referrer_address) : void 0,
86546
- referrerFeeAsset: isSet$5(object.referrer_fee_asset) ? Address$2.fromJSON(object.referrer_fee_asset) : void 0,
86959
+ referrerAddress: isSet$5(object.referrer_address) ? Address$3.fromJSON(object.referrer_address) : void 0,
86960
+ referrerFeeAsset: isSet$5(object.referrer_fee_asset) ? Address$3.fromJSON(object.referrer_fee_asset) : void 0,
86547
86961
  referrerFeeUnits: isSet$5(object.referrer_fee_units) ? globalThis.String(object.referrer_fee_units) : "",
86548
- protocolFeeAsset: isSet$5(object.protocol_fee_asset) ? Address$2.fromJSON(object.protocol_fee_asset) : void 0,
86962
+ protocolFeeAsset: isSet$5(object.protocol_fee_asset) ? Address$3.fromJSON(object.protocol_fee_asset) : void 0,
86549
86963
  protocolFeeUnits: isSet$5(object.protocol_fee_units) ? globalThis.String(object.protocol_fee_units) : "",
86550
86964
  quoteTimestamp: isSet$5(object.quote_timestamp) ? globalThis.Number(object.quote_timestamp) : 0,
86551
86965
  tradeStartDeadline: isSet$5(object.trade_start_deadline) ? globalThis.Number(object.trade_start_deadline) : 0,
@@ -86559,14 +86973,14 @@ const Quote = {
86559
86973
  if (message.quoteId !== void 0) obj.quote_id = message.quoteId;
86560
86974
  if (message.resolverId !== void 0) obj.resolver_id = message.resolverId;
86561
86975
  if (message.resolverName !== void 0) obj.resolver_name = message.resolverName;
86562
- if (message.bidAssetAddress !== void 0) obj.bid_asset_address = Address$2.toJSON(message.bidAssetAddress);
86563
- if (message.askAssetAddress !== void 0) obj.ask_asset_address = Address$2.toJSON(message.askAssetAddress);
86976
+ if (message.bidAssetAddress !== void 0) obj.bid_asset_address = Address$3.toJSON(message.bidAssetAddress);
86977
+ if (message.askAssetAddress !== void 0) obj.ask_asset_address = Address$3.toJSON(message.askAssetAddress);
86564
86978
  if (message.bidUnits !== void 0) obj.bid_units = message.bidUnits;
86565
86979
  if (message.askUnits !== void 0) obj.ask_units = message.askUnits;
86566
- if (message.referrerAddress !== void 0) obj.referrer_address = Address$2.toJSON(message.referrerAddress);
86567
- if (message.referrerFeeAsset !== void 0) obj.referrer_fee_asset = Address$2.toJSON(message.referrerFeeAsset);
86980
+ if (message.referrerAddress !== void 0) obj.referrer_address = Address$3.toJSON(message.referrerAddress);
86981
+ if (message.referrerFeeAsset !== void 0) obj.referrer_fee_asset = Address$3.toJSON(message.referrerFeeAsset);
86568
86982
  if (message.referrerFeeUnits !== void 0) obj.referrer_fee_units = message.referrerFeeUnits;
86569
- if (message.protocolFeeAsset !== void 0) obj.protocol_fee_asset = Address$2.toJSON(message.protocolFeeAsset);
86983
+ if (message.protocolFeeAsset !== void 0) obj.protocol_fee_asset = Address$3.toJSON(message.protocolFeeAsset);
86570
86984
  if (message.protocolFeeUnits !== void 0) obj.protocol_fee_units = message.protocolFeeUnits;
86571
86985
  if (message.quoteTimestamp !== void 0) obj.quote_timestamp = Math.round(message.quoteTimestamp);
86572
86986
  if (message.tradeStartDeadline !== void 0) obj.trade_start_deadline = Math.round(message.tradeStartDeadline);
@@ -86583,14 +86997,14 @@ const Quote = {
86583
86997
  message.quoteId = object.quoteId ?? "";
86584
86998
  message.resolverId = object.resolverId ?? "";
86585
86999
  message.resolverName = object.resolverName ?? "";
86586
- message.bidAssetAddress = object.bidAssetAddress !== void 0 && object.bidAssetAddress !== null ? Address$2.fromPartial(object.bidAssetAddress) : void 0;
86587
- message.askAssetAddress = object.askAssetAddress !== void 0 && object.askAssetAddress !== null ? Address$2.fromPartial(object.askAssetAddress) : void 0;
87000
+ message.bidAssetAddress = object.bidAssetAddress !== void 0 && object.bidAssetAddress !== null ? Address$3.fromPartial(object.bidAssetAddress) : void 0;
87001
+ message.askAssetAddress = object.askAssetAddress !== void 0 && object.askAssetAddress !== null ? Address$3.fromPartial(object.askAssetAddress) : void 0;
86588
87002
  message.bidUnits = object.bidUnits ?? "";
86589
87003
  message.askUnits = object.askUnits ?? "";
86590
- message.referrerAddress = object.referrerAddress !== void 0 && object.referrerAddress !== null ? Address$2.fromPartial(object.referrerAddress) : void 0;
86591
- message.referrerFeeAsset = object.referrerFeeAsset !== void 0 && object.referrerFeeAsset !== null ? Address$2.fromPartial(object.referrerFeeAsset) : void 0;
87004
+ message.referrerAddress = object.referrerAddress !== void 0 && object.referrerAddress !== null ? Address$3.fromPartial(object.referrerAddress) : void 0;
87005
+ message.referrerFeeAsset = object.referrerFeeAsset !== void 0 && object.referrerFeeAsset !== null ? Address$3.fromPartial(object.referrerFeeAsset) : void 0;
86592
87006
  message.referrerFeeUnits = object.referrerFeeUnits ?? "";
86593
- message.protocolFeeAsset = object.protocolFeeAsset !== void 0 && object.protocolFeeAsset !== null ? Address$2.fromPartial(object.protocolFeeAsset) : void 0;
87007
+ message.protocolFeeAsset = object.protocolFeeAsset !== void 0 && object.protocolFeeAsset !== null ? Address$3.fromPartial(object.protocolFeeAsset) : void 0;
86594
87008
  message.protocolFeeUnits = object.protocolFeeUnits ?? "";
86595
87009
  message.quoteTimestamp = object.quoteTimestamp ?? 0;
86596
87010
  message.tradeStartDeadline = object.tradeStartDeadline ?? 0;
@@ -86645,11 +87059,11 @@ function createBaseEscrowOrderListRequest() {
86645
87059
  }
86646
87060
  const EscrowOrderListRequest$1 = {
86647
87061
  fromJSON(object) {
86648
- return { traderWalletAddress: isSet$4(object.trader_wallet_address) ? Address$2.fromJSON(object.trader_wallet_address) : void 0 };
87062
+ return { traderWalletAddress: isSet$4(object.trader_wallet_address) ? Address$3.fromJSON(object.trader_wallet_address) : void 0 };
86649
87063
  },
86650
87064
  toJSON(message) {
86651
87065
  const obj = {};
86652
- if (message.traderWalletAddress !== void 0) obj.trader_wallet_address = Address$2.toJSON(message.traderWalletAddress);
87066
+ if (message.traderWalletAddress !== void 0) obj.trader_wallet_address = Address$3.toJSON(message.traderWalletAddress);
86653
87067
  return obj;
86654
87068
  },
86655
87069
  create(base) {
@@ -86657,7 +87071,7 @@ const EscrowOrderListRequest$1 = {
86657
87071
  },
86658
87072
  fromPartial(object) {
86659
87073
  const message = createBaseEscrowOrderListRequest();
86660
- message.traderWalletAddress = object.traderWalletAddress !== void 0 && object.traderWalletAddress !== null ? Address$2.fromPartial(object.traderWalletAddress) : void 0;
87074
+ message.traderWalletAddress = object.traderWalletAddress !== void 0 && object.traderWalletAddress !== null ? Address$3.fromPartial(object.traderWalletAddress) : void 0;
86661
87075
  return message;
86662
87076
  }
86663
87077
  };
@@ -86693,14 +87107,14 @@ const EscrowOrderData$1 = {
86693
87107
  fromJSON(object) {
86694
87108
  return {
86695
87109
  quote: isSet$4(object.quote) ? Quote.fromJSON(object.quote) : void 0,
86696
- escrowItemAddress: isSet$4(object.escrow_item_address) ? Address$2.fromJSON(object.escrow_item_address) : void 0,
87110
+ escrowItemAddress: isSet$4(object.escrow_item_address) ? Address$3.fromJSON(object.escrow_item_address) : void 0,
86697
87111
  outgoingTxHash: isSet$4(object.outgoing_tx_hash) ? globalThis.String(object.outgoing_tx_hash) : ""
86698
87112
  };
86699
87113
  },
86700
87114
  toJSON(message) {
86701
87115
  const obj = {};
86702
87116
  if (message.quote !== void 0) obj.quote = Quote.toJSON(message.quote);
86703
- if (message.escrowItemAddress !== void 0) obj.escrow_item_address = Address$2.toJSON(message.escrowItemAddress);
87117
+ if (message.escrowItemAddress !== void 0) obj.escrow_item_address = Address$3.toJSON(message.escrowItemAddress);
86704
87118
  if (message.outgoingTxHash !== void 0) obj.outgoing_tx_hash = message.outgoingTxHash;
86705
87119
  return obj;
86706
87120
  },
@@ -86710,7 +87124,7 @@ const EscrowOrderData$1 = {
86710
87124
  fromPartial(object) {
86711
87125
  const message = createBaseEscrowOrderData();
86712
87126
  message.quote = object.quote !== void 0 && object.quote !== null ? Quote.fromPartial(object.quote) : void 0;
86713
- message.escrowItemAddress = object.escrowItemAddress !== void 0 && object.escrowItemAddress !== null ? Address$2.fromPartial(object.escrowItemAddress) : void 0;
87127
+ message.escrowItemAddress = object.escrowItemAddress !== void 0 && object.escrowItemAddress !== null ? Address$3.fromPartial(object.escrowItemAddress) : void 0;
86714
87128
  message.outgoingTxHash = object.outgoingTxHash ?? "";
86715
87129
  return message;
86716
87130
  }
@@ -87014,7 +87428,7 @@ const SwapChunkStatus = {
87014
87428
  fromJSON(object) {
87015
87429
  return {
87016
87430
  protocol: isSet$2(object.protocol) ? globalThis.String(object.protocol) : "",
87017
- targetAddress: isSet$2(object.target_address) ? Address$2.fromJSON(object.target_address) : void 0,
87431
+ targetAddress: isSet$2(object.target_address) ? Address$3.fromJSON(object.target_address) : void 0,
87018
87432
  bidUnits: isSet$2(object.bid_units) ? globalThis.String(object.bid_units) : "",
87019
87433
  expectedAskUnits: isSet$2(object.expected_ask_units) ? globalThis.String(object.expected_ask_units) : "",
87020
87434
  actualAskUnits: isSet$2(object.actual_ask_units) ? globalThis.String(object.actual_ask_units) : "",
@@ -87025,7 +87439,7 @@ const SwapChunkStatus = {
87025
87439
  toJSON(message) {
87026
87440
  const obj = {};
87027
87441
  if (message.protocol !== void 0) obj.protocol = message.protocol;
87028
- if (message.targetAddress !== void 0) obj.target_address = Address$2.toJSON(message.targetAddress);
87442
+ if (message.targetAddress !== void 0) obj.target_address = Address$3.toJSON(message.targetAddress);
87029
87443
  if (message.bidUnits !== void 0) obj.bid_units = message.bidUnits;
87030
87444
  if (message.expectedAskUnits !== void 0) obj.expected_ask_units = message.expectedAskUnits;
87031
87445
  if (message.actualAskUnits !== void 0) obj.actual_ask_units = message.actualAskUnits;
@@ -87039,7 +87453,7 @@ const SwapChunkStatus = {
87039
87453
  fromPartial(object) {
87040
87454
  const message = createBaseSwapChunkStatus();
87041
87455
  message.protocol = object.protocol ?? "";
87042
- message.targetAddress = object.targetAddress !== void 0 && object.targetAddress !== null ? Address$2.fromPartial(object.targetAddress) : void 0;
87456
+ message.targetAddress = object.targetAddress !== void 0 && object.targetAddress !== null ? Address$3.fromPartial(object.targetAddress) : void 0;
87043
87457
  message.bidUnits = object.bidUnits ?? "";
87044
87458
  message.expectedAskUnits = object.expectedAskUnits ?? "";
87045
87459
  message.actualAskUnits = object.actualAskUnits ?? "";
@@ -87100,14 +87514,14 @@ function createBaseEscrowOrderStatus() {
87100
87514
  const EscrowOrderStatus = {
87101
87515
  fromJSON(object) {
87102
87516
  return {
87103
- targetAddress: isSet$2(object.target_address) ? Address$2.fromJSON(object.target_address) : void 0,
87517
+ targetAddress: isSet$2(object.target_address) ? Address$3.fromJSON(object.target_address) : void 0,
87104
87518
  askUnits: isSet$2(object.ask_units) ? globalThis.String(object.ask_units) : "",
87105
87519
  txHash: isSet$2(object.tx_hash) ? globalThis.String(object.tx_hash) : ""
87106
87520
  };
87107
87521
  },
87108
87522
  toJSON(message) {
87109
87523
  const obj = {};
87110
- if (message.targetAddress !== void 0) obj.target_address = Address$2.toJSON(message.targetAddress);
87524
+ if (message.targetAddress !== void 0) obj.target_address = Address$3.toJSON(message.targetAddress);
87111
87525
  if (message.askUnits !== void 0) obj.ask_units = message.askUnits;
87112
87526
  if (message.txHash !== void 0) obj.tx_hash = message.txHash;
87113
87527
  return obj;
@@ -87117,7 +87531,7 @@ const EscrowOrderStatus = {
87117
87531
  },
87118
87532
  fromPartial(object) {
87119
87533
  const message = createBaseEscrowOrderStatus();
87120
- message.targetAddress = object.targetAddress !== void 0 && object.targetAddress !== null ? Address$2.fromPartial(object.targetAddress) : void 0;
87534
+ message.targetAddress = object.targetAddress !== void 0 && object.targetAddress !== null ? Address$3.fromPartial(object.targetAddress) : void 0;
87121
87535
  message.askUnits = object.askUnits ?? "";
87122
87536
  message.txHash = object.txHash ?? "";
87123
87537
  return message;
@@ -87134,14 +87548,14 @@ const TrackTradeRequest$1 = {
87134
87548
  fromJSON(object) {
87135
87549
  return {
87136
87550
  quoteId: isSet$2(object.quote_id) ? globalThis.String(object.quote_id) : "",
87137
- traderWalletAddress: isSet$2(object.trader_wallet_address) ? Address$2.fromJSON(object.trader_wallet_address) : void 0,
87551
+ traderWalletAddress: isSet$2(object.trader_wallet_address) ? Address$3.fromJSON(object.trader_wallet_address) : void 0,
87138
87552
  outgoingTxHash: isSet$2(object.outgoing_tx_hash) ? globalThis.String(object.outgoing_tx_hash) : ""
87139
87553
  };
87140
87554
  },
87141
87555
  toJSON(message) {
87142
87556
  const obj = {};
87143
87557
  if (message.quoteId !== void 0) obj.quote_id = message.quoteId;
87144
- if (message.traderWalletAddress !== void 0) obj.trader_wallet_address = Address$2.toJSON(message.traderWalletAddress);
87558
+ if (message.traderWalletAddress !== void 0) obj.trader_wallet_address = Address$3.toJSON(message.traderWalletAddress);
87145
87559
  if (message.outgoingTxHash !== void 0) obj.outgoing_tx_hash = message.outgoingTxHash;
87146
87560
  return obj;
87147
87561
  },
@@ -87151,7 +87565,7 @@ const TrackTradeRequest$1 = {
87151
87565
  fromPartial(object) {
87152
87566
  const message = createBaseTrackTradeRequest();
87153
87567
  message.quoteId = object.quoteId ?? "";
87154
- message.traderWalletAddress = object.traderWalletAddress !== void 0 && object.traderWalletAddress !== null ? Address$2.fromPartial(object.traderWalletAddress) : void 0;
87568
+ message.traderWalletAddress = object.traderWalletAddress !== void 0 && object.traderWalletAddress !== null ? Address$3.fromPartial(object.traderWalletAddress) : void 0;
87155
87569
  message.outgoingTxHash = object.outgoingTxHash ?? "";
87156
87570
  return message;
87157
87571
  }
@@ -87237,13 +87651,13 @@ function createBaseClaimAvailable() {
87237
87651
  const ClaimAvailable = {
87238
87652
  fromJSON(object) {
87239
87653
  return {
87240
- contractAddress: isSet$2(object.contract_address) ? Address$2.fromJSON(object.contract_address) : void 0,
87654
+ contractAddress: isSet$2(object.contract_address) ? Address$3.fromJSON(object.contract_address) : void 0,
87241
87655
  depositIndex: isSet$2(object.deposit_index) ? globalThis.Number(object.deposit_index) : 0
87242
87656
  };
87243
87657
  },
87244
87658
  toJSON(message) {
87245
87659
  const obj = {};
87246
- if (message.contractAddress !== void 0) obj.contract_address = Address$2.toJSON(message.contractAddress);
87660
+ if (message.contractAddress !== void 0) obj.contract_address = Address$3.toJSON(message.contractAddress);
87247
87661
  if (message.depositIndex !== void 0) obj.deposit_index = Math.round(message.depositIndex);
87248
87662
  return obj;
87249
87663
  },
@@ -87252,7 +87666,7 @@ const ClaimAvailable = {
87252
87666
  },
87253
87667
  fromPartial(object) {
87254
87668
  const message = createBaseClaimAvailable();
87255
- message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$2.fromPartial(object.contractAddress) : void 0;
87669
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$3.fromPartial(object.contractAddress) : void 0;
87256
87670
  message.depositIndex = object.depositIndex ?? 0;
87257
87671
  return message;
87258
87672
  }
@@ -87262,11 +87676,11 @@ function createBaseRefundAvailable() {
87262
87676
  }
87263
87677
  const RefundAvailable = {
87264
87678
  fromJSON(object) {
87265
- return { contractAddress: isSet$2(object.contract_address) ? Address$2.fromJSON(object.contract_address) : void 0 };
87679
+ return { contractAddress: isSet$2(object.contract_address) ? Address$3.fromJSON(object.contract_address) : void 0 };
87266
87680
  },
87267
87681
  toJSON(message) {
87268
87682
  const obj = {};
87269
- if (message.contractAddress !== void 0) obj.contract_address = Address$2.toJSON(message.contractAddress);
87683
+ if (message.contractAddress !== void 0) obj.contract_address = Address$3.toJSON(message.contractAddress);
87270
87684
  return obj;
87271
87685
  },
87272
87686
  create(base) {
@@ -87274,7 +87688,7 @@ const RefundAvailable = {
87274
87688
  },
87275
87689
  fromPartial(object) {
87276
87690
  const message = createBaseRefundAvailable();
87277
- message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$2.fromPartial(object.contractAddress) : void 0;
87691
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? Address$3.fromPartial(object.contractAddress) : void 0;
87278
87692
  return message;
87279
87693
  }
87280
87694
  };
@@ -87443,20 +87857,20 @@ function createBaseBuildTransferRequest() {
87443
87857
  const BuildTransferRequest$1 = {
87444
87858
  fromJSON(object) {
87445
87859
  return {
87446
- sourceAddress: isSet$1(object.source_address) ? Address$2.fromJSON(object.source_address) : void 0,
87447
- destinationAddress: isSet$1(object.destination_address) ? Address$2.fromJSON(object.destination_address) : void 0,
87448
- gasExcessAddress: isSet$1(object.gas_excess_address) ? Address$2.fromJSON(object.gas_excess_address) : void 0,
87449
- refundAddress: isSet$1(object.refund_address) ? Address$2.fromJSON(object.refund_address) : void 0,
87860
+ sourceAddress: isSet$1(object.source_address) ? Address$3.fromJSON(object.source_address) : void 0,
87861
+ destinationAddress: isSet$1(object.destination_address) ? Address$3.fromJSON(object.destination_address) : void 0,
87862
+ gasExcessAddress: isSet$1(object.gas_excess_address) ? Address$3.fromJSON(object.gas_excess_address) : void 0,
87863
+ refundAddress: isSet$1(object.refund_address) ? Address$3.fromJSON(object.refund_address) : void 0,
87450
87864
  quote: isSet$1(object.quote) ? Quote.fromJSON(object.quote) : void 0,
87451
87865
  useRecommendedSlippage: isSet$1(object.use_recommended_slippage) ? globalThis.Boolean(object.use_recommended_slippage) : false
87452
87866
  };
87453
87867
  },
87454
87868
  toJSON(message) {
87455
87869
  const obj = {};
87456
- if (message.sourceAddress !== void 0) obj.source_address = Address$2.toJSON(message.sourceAddress);
87457
- if (message.destinationAddress !== void 0) obj.destination_address = Address$2.toJSON(message.destinationAddress);
87458
- if (message.gasExcessAddress !== void 0) obj.gas_excess_address = Address$2.toJSON(message.gasExcessAddress);
87459
- if (message.refundAddress !== void 0) obj.refund_address = Address$2.toJSON(message.refundAddress);
87870
+ if (message.sourceAddress !== void 0) obj.source_address = Address$3.toJSON(message.sourceAddress);
87871
+ if (message.destinationAddress !== void 0) obj.destination_address = Address$3.toJSON(message.destinationAddress);
87872
+ if (message.gasExcessAddress !== void 0) obj.gas_excess_address = Address$3.toJSON(message.gasExcessAddress);
87873
+ if (message.refundAddress !== void 0) obj.refund_address = Address$3.toJSON(message.refundAddress);
87460
87874
  if (message.quote !== void 0) obj.quote = Quote.toJSON(message.quote);
87461
87875
  if (message.useRecommendedSlippage !== void 0) obj.use_recommended_slippage = message.useRecommendedSlippage;
87462
87876
  return obj;
@@ -87466,10 +87880,10 @@ const BuildTransferRequest$1 = {
87466
87880
  },
87467
87881
  fromPartial(object) {
87468
87882
  const message = createBaseBuildTransferRequest();
87469
- message.sourceAddress = object.sourceAddress !== void 0 && object.sourceAddress !== null ? Address$2.fromPartial(object.sourceAddress) : void 0;
87470
- message.destinationAddress = object.destinationAddress !== void 0 && object.destinationAddress !== null ? Address$2.fromPartial(object.destinationAddress) : void 0;
87471
- message.gasExcessAddress = object.gasExcessAddress !== void 0 && object.gasExcessAddress !== null ? Address$2.fromPartial(object.gasExcessAddress) : void 0;
87472
- message.refundAddress = object.refundAddress !== void 0 && object.refundAddress !== null ? Address$2.fromPartial(object.refundAddress) : void 0;
87883
+ message.sourceAddress = object.sourceAddress !== void 0 && object.sourceAddress !== null ? Address$3.fromPartial(object.sourceAddress) : void 0;
87884
+ message.destinationAddress = object.destinationAddress !== void 0 && object.destinationAddress !== null ? Address$3.fromPartial(object.destinationAddress) : void 0;
87885
+ message.gasExcessAddress = object.gasExcessAddress !== void 0 && object.gasExcessAddress !== null ? Address$3.fromPartial(object.gasExcessAddress) : void 0;
87886
+ message.refundAddress = object.refundAddress !== void 0 && object.refundAddress !== null ? Address$3.fromPartial(object.refundAddress) : void 0;
87473
87887
  message.quote = object.quote !== void 0 && object.quote !== null ? Quote.fromPartial(object.quote) : void 0;
87474
87888
  message.useRecommendedSlippage = object.useRecommendedSlippage ?? false;
87475
87889
  return message;
@@ -87485,16 +87899,16 @@ function createBaseBuildWithdrawalRequest() {
87485
87899
  const BuildWithdrawalRequest$1 = {
87486
87900
  fromJSON(object) {
87487
87901
  return {
87488
- sourceAddress: isSet$1(object.source_address) ? Address$2.fromJSON(object.source_address) : void 0,
87902
+ sourceAddress: isSet$1(object.source_address) ? Address$3.fromJSON(object.source_address) : void 0,
87489
87903
  quoteId: isSet$1(object.quote_id) ? globalThis.String(object.quote_id) : "",
87490
- gasExcessAddress: isSet$1(object.gas_excess_address) ? Address$2.fromJSON(object.gas_excess_address) : void 0
87904
+ gasExcessAddress: isSet$1(object.gas_excess_address) ? Address$3.fromJSON(object.gas_excess_address) : void 0
87491
87905
  };
87492
87906
  },
87493
87907
  toJSON(message) {
87494
87908
  const obj = {};
87495
- if (message.sourceAddress !== void 0) obj.source_address = Address$2.toJSON(message.sourceAddress);
87909
+ if (message.sourceAddress !== void 0) obj.source_address = Address$3.toJSON(message.sourceAddress);
87496
87910
  if (message.quoteId !== void 0) obj.quote_id = message.quoteId;
87497
- if (message.gasExcessAddress !== void 0) obj.gas_excess_address = Address$2.toJSON(message.gasExcessAddress);
87911
+ if (message.gasExcessAddress !== void 0) obj.gas_excess_address = Address$3.toJSON(message.gasExcessAddress);
87498
87912
  return obj;
87499
87913
  },
87500
87914
  create(base) {
@@ -87502,9 +87916,9 @@ const BuildWithdrawalRequest$1 = {
87502
87916
  },
87503
87917
  fromPartial(object) {
87504
87918
  const message = createBaseBuildWithdrawalRequest();
87505
- message.sourceAddress = object.sourceAddress !== void 0 && object.sourceAddress !== null ? Address$2.fromPartial(object.sourceAddress) : void 0;
87919
+ message.sourceAddress = object.sourceAddress !== void 0 && object.sourceAddress !== null ? Address$3.fromPartial(object.sourceAddress) : void 0;
87506
87920
  message.quoteId = object.quoteId ?? "";
87507
- message.gasExcessAddress = object.gasExcessAddress !== void 0 && object.gasExcessAddress !== null ? Address$2.fromPartial(object.gasExcessAddress) : void 0;
87921
+ message.gasExcessAddress = object.gasExcessAddress !== void 0 && object.gasExcessAddress !== null ? Address$3.fromPartial(object.gasExcessAddress) : void 0;
87508
87922
  return message;
87509
87923
  }
87510
87924
  };
@@ -89246,6 +89660,91 @@ async function createTonWalletMCP(config) {
89246
89660
  return server;
89247
89661
  }
89248
89662
 
89663
+ //#endregion
89664
+ //#region src/services/KeyManager.ts
89665
+ /**
89666
+ * Copyright (c) TonTech.
89667
+ *
89668
+ * This source code is licensed under the MIT license found in the
89669
+ * LICENSE file in the root directory of this source tree.
89670
+ *
89671
+ */
89672
+ /**
89673
+ * KeyManager - Manages keypair storage for MCP controlled wallets
89674
+ *
89675
+ * Stores keys in ~/.ton/key.json
89676
+ */
89677
+ const KEY_DIR = join(homedir(), ".ton");
89678
+ const KEY_FILE = join(KEY_DIR, "key.json");
89679
+ /**
89680
+ * KeyManager handles creation and storage of keypairs for controlled wallets
89681
+ */
89682
+ var KeyManager = class KeyManager {
89683
+ /**
89684
+ * Check if a key file exists
89685
+ */
89686
+ static async hasStoredKey() {
89687
+ return existsSync(KEY_FILE);
89688
+ }
89689
+ /**
89690
+ * Load stored key data from ~/.ton/key.json
89691
+ */
89692
+ static async loadKey() {
89693
+ try {
89694
+ if (!existsSync(KEY_FILE)) return null;
89695
+ const data = await readFile(KEY_FILE, "utf-8");
89696
+ return JSON.parse(data);
89697
+ } catch {
89698
+ return null;
89699
+ }
89700
+ }
89701
+ /**
89702
+ * Generate a new keypair and store it
89703
+ */
89704
+ static async generateAndStoreKey(walletAddress, network) {
89705
+ const keyPair = await (0, import_dist$1.mnemonicToPrivateKey)(await (0, import_dist$1.mnemonicNew)(24));
89706
+ const keyData = {
89707
+ walletAddress,
89708
+ publicKey: Buffer.from(keyPair.publicKey).toString("hex"),
89709
+ privateKey: Buffer.from(keyPair.secretKey.slice(0, 32)).toString("hex"),
89710
+ network,
89711
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
89712
+ };
89713
+ await KeyManager.saveKey(keyData);
89714
+ return keyData;
89715
+ }
89716
+ /**
89717
+ * Save key data to ~/.ton/key.json
89718
+ */
89719
+ static async saveKey(keyData) {
89720
+ if (!existsSync(KEY_DIR)) await mkdir(KEY_DIR, { recursive: true });
89721
+ await writeFile(KEY_FILE, JSON.stringify(keyData, null, 2), "utf-8");
89722
+ }
89723
+ /**
89724
+ * Get keypair from stored key data
89725
+ */
89726
+ static getKeyPair(keyData) {
89727
+ const keyPair = (0, import_dist$1.keyPairFromSeed)(Buffer.from(keyData.privateKey, "hex"));
89728
+ return {
89729
+ publicKey: keyPair.publicKey,
89730
+ secretKey: keyPair.secretKey
89731
+ };
89732
+ }
89733
+ /**
89734
+ * Get the path to the key file
89735
+ */
89736
+ static getKeyFilePath() {
89737
+ return KEY_FILE;
89738
+ }
89739
+ /**
89740
+ * Delete stored key
89741
+ */
89742
+ static async deleteKey() {
89743
+ const { unlink } = await import("node:fs/promises");
89744
+ if (existsSync(KEY_FILE)) await unlink(KEY_FILE);
89745
+ }
89746
+ };
89747
+
89249
89748
  //#endregion
89250
89749
  //#region src/cli.ts
89251
89750
  /**
@@ -89269,13 +89768,22 @@ async function createTonWalletMCP(config) {
89269
89768
  *
89270
89769
  * Environment variables:
89271
89770
  * NETWORK - Network to use (mainnet or testnet, default: mainnet)
89272
- * MNEMONIC - 24-word mnemonic phrase for wallet (if not provided, a new wallet is created)
89771
+ * MNEMONIC - 24-word mnemonic phrase for wallet (if not provided, controlled wallet mode is used)
89273
89772
  * WALLET_VERSION - Wallet version (v5r1 or v4r2, default: v5r1)
89773
+ * WALLET_ADDRESS - User's wallet address (required for controlled wallet mode)
89774
+ *
89775
+ * Controlled Wallet Mode:
89776
+ * When MNEMONIC is not provided, the MCP will:
89777
+ * 1. Check for existing keypair in ~/.ton/key.json
89778
+ * 2. If not found, require WALLET_ADDRESS and generate a new keypair
89779
+ * 3. Store the keypair in ~/.ton/key.json
89780
+ * 4. Use this keypair to sign transactions for the user's wallet
89274
89781
  */
89275
89782
  const SERVER_NAME = "ton-mcp";
89276
89783
  const NETWORK = process.env.NETWORK || "mainnet";
89277
89784
  const MNEMONIC = process.env.MNEMONIC;
89278
89785
  const WALLET_VERSION = process.env.WALLET_VERSION || "v5r1";
89786
+ const WALLET_ADDRESS = process.env.WALLET_ADDRESS;
89279
89787
  const TONCENTER_API_KEY = process.env.TONCENTER_API_KEY;
89280
89788
  function log(message) {
89281
89789
  console.error(`[${SERVER_NAME}] ${message}`);
@@ -89294,6 +89802,79 @@ function parseArgs() {
89294
89802
  host: hostArg && !hostArg.startsWith("-") ? hostArg : "0.0.0.0"
89295
89803
  };
89296
89804
  }
89805
+ /**
89806
+ * Prompt user for input via stdin
89807
+ */
89808
+ async function promptUser(question) {
89809
+ const rl = readline.createInterface({
89810
+ input: process.stdin,
89811
+ output: process.stderr
89812
+ });
89813
+ return new Promise((resolve) => {
89814
+ rl.question(question, (answer) => {
89815
+ rl.close();
89816
+ resolve(answer.trim());
89817
+ });
89818
+ });
89819
+ }
89820
+ /**
89821
+ * Create wallet using mnemonic (traditional mode)
89822
+ */
89823
+ async function createMnemonicWallet(kit, network, mnemonic) {
89824
+ const signer = await Signer.fromMnemonic(mnemonic, { type: "ton" });
89825
+ const walletAdapter = WALLET_VERSION === "v5r1" ? await WalletV5R1Adapter.create(signer, {
89826
+ client: kit.getApiClient(network),
89827
+ network
89828
+ }) : await WalletV4R2Adapter.create(signer, {
89829
+ client: kit.getApiClient(network),
89830
+ network
89831
+ });
89832
+ let wallet = await kit.addWallet(walletAdapter);
89833
+ if (!wallet) wallet = kit.getWallet(walletAdapter.getWalletId());
89834
+ if (!wallet) throw new Error("Failed to create wallet");
89835
+ return wallet;
89836
+ }
89837
+ /**
89838
+ * Create controlled wallet (MCP keypair mode)
89839
+ */
89840
+ async function createControlledWallet(kit, network) {
89841
+ let keyData = await KeyManager.loadKey();
89842
+ if (!keyData) {
89843
+ let walletAddress = WALLET_ADDRESS;
89844
+ if (!walletAddress) {
89845
+ log("No mnemonic provided. Running in controlled wallet mode.");
89846
+ log("Please provide your wallet address to set up MCP control.");
89847
+ walletAddress = await promptUser("Enter your TON wallet address: ");
89848
+ }
89849
+ if (!walletAddress) throw new Error("Wallet address is required for controlled wallet mode");
89850
+ log(`Generating new keypair for wallet: ${walletAddress}`);
89851
+ keyData = await KeyManager.generateAndStoreKey(walletAddress, NETWORK);
89852
+ log(`Keypair stored in ${KeyManager.getKeyFilePath()}`);
89853
+ log(`Public key: ${keyData.publicKey}`);
89854
+ log("");
89855
+ log("IMPORTANT: To enable MCP to control your wallet, you need to:");
89856
+ log("1. Add this public key as an extension to your wallet contract");
89857
+ log("2. Or use a wallet that supports delegated signing");
89858
+ } else {
89859
+ log(`Using stored keypair for wallet: ${keyData.walletAddress}`);
89860
+ log(`Public key: ${keyData.publicKey}`);
89861
+ }
89862
+ const keyPair = KeyManager.getKeyPair(keyData);
89863
+ const signer = await Signer.fromPrivateKey(keyPair.secretKey.slice(0, 32));
89864
+ const walletAdapter = await WalletOwnableAdapter.create(signer, {
89865
+ client: kit.getApiClient(network),
89866
+ network,
89867
+ nftInfo: {
89868
+ itemIndex: 0n,
89869
+ collectionAddress: import_dist$2.Address.parse("EQC8EqPgaPlrApfYxtG0Rcz8bnU3yC1enq9DfuFbZlpEDTG5")
89870
+ },
89871
+ owner: import_dist$2.Address.parse(keyData.walletAddress ?? "")
89872
+ });
89873
+ let wallet = await kit.addWallet(walletAdapter);
89874
+ if (!wallet) wallet = kit.getWallet(walletAdapter.getWalletId());
89875
+ if (!wallet) throw new Error("Failed to create controlled wallet");
89876
+ return wallet;
89877
+ }
89297
89878
  async function createWalletAndServer() {
89298
89879
  const network = NETWORK === "mainnet" ? Network.mainnet() : Network.testnet();
89299
89880
  const apiConfig = {};
@@ -89306,26 +89887,21 @@ async function createWalletAndServer() {
89306
89887
  storage: new MemoryStorageAdapter()
89307
89888
  });
89308
89889
  await kit.waitForReady();
89309
- let mnemonic;
89890
+ let wallet;
89310
89891
  if (MNEMONIC) {
89311
- mnemonic = MNEMONIC.trim().split(/\s+/);
89892
+ const mnemonic = MNEMONIC.trim().split(/\s+/);
89312
89893
  if (mnemonic.length !== 24) throw new Error(`Invalid mnemonic: expected 24 words, got ${mnemonic.length}`);
89313
89894
  log("Using provided mnemonic");
89314
- } else throw new Error("MNEMONIC is required");
89315
- const signer = await Signer.fromMnemonic(mnemonic, { type: "ton" });
89316
- const walletAdapter = WALLET_VERSION === "v5r1" ? await WalletV5R1Adapter.create(signer, {
89317
- client: kit.getApiClient(network),
89318
- network
89319
- }) : await WalletV4R2Adapter.create(signer, {
89320
- client: kit.getApiClient(network),
89321
- network
89322
- });
89323
- let wallet = await kit.addWallet(walletAdapter);
89324
- if (!wallet) wallet = kit.getWallet(walletAdapter.getWalletId());
89325
- if (!wallet) throw new Error("Failed to create wallet");
89326
- log(`Wallet address: ${wallet.getAddress()}`);
89327
- log(`Network: ${NETWORK}`);
89328
- log(`Version: ${WALLET_VERSION}`);
89895
+ wallet = await createMnemonicWallet(kit, network, mnemonic);
89896
+ log(`Wallet address: ${wallet.getAddress()}`);
89897
+ log(`Network: ${NETWORK}`);
89898
+ log(`Version: ${WALLET_VERSION}`);
89899
+ } else {
89900
+ wallet = await createControlledWallet(kit, network);
89901
+ log(`Controlled wallet address: ${wallet.getAddress()}`);
89902
+ log(`Network: ${NETWORK}`);
89903
+ log("Mode: Controlled (MCP keypair)");
89904
+ }
89329
89905
  return {
89330
89906
  server: await createTonWalletMCP({
89331
89907
  wallet,