@t2000/cli 5.6.0 → 5.6.1

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.
@@ -14793,9 +14793,6 @@ function getIdFromCallArg(arg) {
14793
14793
  }
14794
14794
  if (arg.UnresolvedObject) return normalizeSuiAddress(arg.UnresolvedObject.objectId);
14795
14795
  }
14796
- function isArgument(value) {
14797
- return /* @__PURE__ */ is(ArgumentSchema, value);
14798
- }
14799
14796
  function remapCommandArguments(command, inputMapping, commandMapping) {
14800
14797
  const remapArg = (arg) => {
14801
14798
  switch (arg.$kind) {
@@ -14860,8 +14857,6 @@ function remapCommandArguments(command, inputMapping, commandMapping) {
14860
14857
  var init_utils4 = __esm({
14861
14858
  "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/utils.mjs"() {
14862
14859
  init_sui_types();
14863
- init_internal();
14864
- init_dist3();
14865
14860
  }
14866
14861
  });
14867
14862
  function serializeV1TransactionData(transactionData) {
@@ -15428,7 +15423,6 @@ var init_TransactionData = __esm({
15428
15423
  };
15429
15424
  }
15430
15425
  });
15431
- var UpgradePolicy;
15432
15426
  var TransactionCommands;
15433
15427
  var init_Commands = __esm({
15434
15428
  "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Commands.mjs"() {
@@ -15436,12 +15430,6 @@ var init_Commands = __esm({
15436
15430
  init_internal();
15437
15431
  init_dist2();
15438
15432
  init_dist3();
15439
- UpgradePolicy = /* @__PURE__ */ (function(UpgradePolicy$1) {
15440
- UpgradePolicy$1[UpgradePolicy$1["COMPATIBLE"] = 0] = "COMPATIBLE";
15441
- UpgradePolicy$1[UpgradePolicy$1["ADDITIVE"] = 128] = "ADDITIVE";
15442
- UpgradePolicy$1[UpgradePolicy$1["DEP_ONLY"] = 192] = "DEP_ONLY";
15443
- return UpgradePolicy$1;
15444
- })({});
15445
15433
  TransactionCommands = {
15446
15434
  MoveCall(input) {
15447
15435
  const [pkg, mod3 = "", fn = ""] = "target" in input ? input.target.split("::") : [
@@ -15655,58 +15643,6 @@ function getPureBcsSchema(typeSignature) {
15655
15643
  return null;
15656
15644
  }
15657
15645
  }
15658
- function normalizedTypeToMoveTypeSignature(type) {
15659
- if (typeof type === "object" && "Reference" in type) return {
15660
- reference: "immutable",
15661
- body: normalizedTypeToMoveTypeSignatureBody(type.Reference)
15662
- };
15663
- if (typeof type === "object" && "MutableReference" in type) return {
15664
- reference: "mutable",
15665
- body: normalizedTypeToMoveTypeSignatureBody(type.MutableReference)
15666
- };
15667
- return {
15668
- reference: null,
15669
- body: normalizedTypeToMoveTypeSignatureBody(type)
15670
- };
15671
- }
15672
- function normalizedTypeToMoveTypeSignatureBody(type) {
15673
- if (typeof type === "string") switch (type) {
15674
- case "Address":
15675
- return { $kind: "address" };
15676
- case "Bool":
15677
- return { $kind: "bool" };
15678
- case "U8":
15679
- return { $kind: "u8" };
15680
- case "U16":
15681
- return { $kind: "u16" };
15682
- case "U32":
15683
- return { $kind: "u32" };
15684
- case "U64":
15685
- return { $kind: "u64" };
15686
- case "U128":
15687
- return { $kind: "u128" };
15688
- case "U256":
15689
- return { $kind: "u256" };
15690
- default:
15691
- throw new Error(`Unexpected type ${type}`);
15692
- }
15693
- if ("Vector" in type) return {
15694
- $kind: "vector",
15695
- vector: normalizedTypeToMoveTypeSignatureBody(type.Vector)
15696
- };
15697
- if ("Struct" in type) return {
15698
- $kind: "datatype",
15699
- datatype: {
15700
- typeName: `${type.Struct.address}::${type.Struct.module}::${type.Struct.name}`,
15701
- typeParameters: type.Struct.typeArguments.map(normalizedTypeToMoveTypeSignatureBody)
15702
- }
15703
- };
15704
- if ("TypeParameter" in type) return {
15705
- $kind: "typeParameter",
15706
- index: type.TypeParameter
15707
- };
15708
- throw new Error(`Unexpected type ${JSON.stringify(type)}`);
15709
- }
15710
15646
  var init_serializer = __esm({
15711
15647
  "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/serializer.mjs"() {
15712
15648
  init_sui_types();
@@ -16244,22 +16180,6 @@ var init_chunk = __esm({
16244
16180
  "../../node_modules/.pnpm/@mysten+utils@0.3.3/node_modules/@mysten/utils/dist/chunk.mjs"() {
16245
16181
  }
16246
16182
  });
16247
- function promiseWithResolvers() {
16248
- let resolver;
16249
- let rejecter;
16250
- return {
16251
- promise: new Promise((resolve2, reject) => {
16252
- resolver = resolve2;
16253
- rejecter = reject;
16254
- }),
16255
- resolve: resolver,
16256
- reject: rejecter
16257
- };
16258
- }
16259
- var init_with_resolver = __esm({
16260
- "../../node_modules/.pnpm/@mysten+utils@0.3.3/node_modules/@mysten/utils/dist/with-resolver.mjs"() {
16261
- }
16262
- });
16263
16183
  function getCurrentBatch(loader) {
16264
16184
  const existingBatch = loader._batch;
16265
16185
  if (existingBatch !== null && !existingBatch.hasDispatched && existingBatch.keys.length < loader._maxBatchSize) return existingBatch;
@@ -16490,7 +16410,6 @@ var init_dist4 = __esm({
16490
16410
  "../../node_modules/.pnpm/@mysten+utils@0.3.3/node_modules/@mysten/utils/dist/index.mjs"() {
16491
16411
  init_b642();
16492
16412
  init_chunk();
16493
- init_with_resolver();
16494
16413
  init_dataloader();
16495
16414
  }
16496
16415
  });
@@ -17710,777 +17629,10 @@ var init_Transaction = __esm({
17710
17629
  };
17711
17630
  }
17712
17631
  });
17713
- var AsyncCache;
17714
- var InMemoryCache;
17715
- var ObjectCache;
17716
- var init_ObjectCache = __esm({
17717
- "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/ObjectCache.mjs"() {
17718
- init_sui_types();
17719
- AsyncCache = class {
17720
- async getObject(id) {
17721
- const [owned, shared] = await Promise.all([this.get("OwnedObject", id), this.get("SharedOrImmutableObject", id)]);
17722
- return owned ?? shared ?? null;
17723
- }
17724
- async getObjects(ids) {
17725
- return Promise.all(ids.map((id) => this.getObject(id)));
17726
- }
17727
- async addObject(object4) {
17728
- if (object4.owner) await this.set("OwnedObject", object4.objectId, object4);
17729
- else await this.set("SharedOrImmutableObject", object4.objectId, object4);
17730
- return object4;
17731
- }
17732
- async addObjects(objects) {
17733
- await Promise.all(objects.map(async (object4) => this.addObject(object4)));
17734
- }
17735
- async deleteObject(id) {
17736
- await Promise.all([this.delete("OwnedObject", id), this.delete("SharedOrImmutableObject", id)]);
17737
- }
17738
- async deleteObjects(ids) {
17739
- await Promise.all(ids.map((id) => this.deleteObject(id)));
17740
- }
17741
- async getMoveFunctionDefinition(ref) {
17742
- const functionName = `${normalizeSuiAddress(ref.package)}::${ref.module}::${ref.function}`;
17743
- return this.get("MoveFunction", functionName);
17744
- }
17745
- async addMoveFunctionDefinition(functionEntry) {
17746
- const pkg = normalizeSuiAddress(functionEntry.package);
17747
- const functionName = `${pkg}::${functionEntry.module}::${functionEntry.function}`;
17748
- const entry = {
17749
- ...functionEntry,
17750
- package: pkg
17751
- };
17752
- await this.set("MoveFunction", functionName, entry);
17753
- return entry;
17754
- }
17755
- async deleteMoveFunctionDefinition(ref) {
17756
- const functionName = `${normalizeSuiAddress(ref.package)}::${ref.module}::${ref.function}`;
17757
- await this.delete("MoveFunction", functionName);
17758
- }
17759
- async getCustom(key) {
17760
- return this.get("Custom", key);
17761
- }
17762
- async setCustom(key, value) {
17763
- return this.set("Custom", key, value);
17764
- }
17765
- async deleteCustom(key) {
17766
- return this.delete("Custom", key);
17767
- }
17768
- };
17769
- InMemoryCache = class extends AsyncCache {
17770
- #caches = {
17771
- OwnedObject: /* @__PURE__ */ new Map(),
17772
- SharedOrImmutableObject: /* @__PURE__ */ new Map(),
17773
- MoveFunction: /* @__PURE__ */ new Map(),
17774
- Custom: /* @__PURE__ */ new Map()
17775
- };
17776
- async get(type, key) {
17777
- return this.#caches[type].get(key) ?? null;
17778
- }
17779
- async set(type, key, value) {
17780
- this.#caches[type].set(key, value);
17781
- }
17782
- async delete(type, key) {
17783
- this.#caches[type].delete(key);
17784
- }
17785
- async clear(type) {
17786
- if (type) this.#caches[type].clear();
17787
- else for (const cache of Object.values(this.#caches)) cache.clear();
17788
- }
17789
- };
17790
- ObjectCache = class {
17791
- #cache;
17792
- #onEffects;
17793
- constructor({ cache = new InMemoryCache(), onEffects }) {
17794
- this.#cache = cache;
17795
- this.#onEffects = onEffects;
17796
- }
17797
- asPlugin() {
17798
- return async (transactionData, _options, next) => {
17799
- const unresolvedObjects = transactionData.inputs.filter((input) => input.UnresolvedObject).map((input) => input.UnresolvedObject.objectId);
17800
- const cached2 = (await this.#cache.getObjects(unresolvedObjects)).filter((obj) => obj !== null);
17801
- const byId = new Map(cached2.map((obj) => [obj.objectId, obj]));
17802
- for (const input of transactionData.inputs) {
17803
- if (!input.UnresolvedObject) continue;
17804
- const cached$1 = byId.get(input.UnresolvedObject.objectId);
17805
- if (!cached$1) continue;
17806
- if (cached$1.initialSharedVersion && !input.UnresolvedObject.initialSharedVersion) input.UnresolvedObject.initialSharedVersion = cached$1.initialSharedVersion;
17807
- else {
17808
- if (cached$1.version && !input.UnresolvedObject.version) input.UnresolvedObject.version = cached$1.version;
17809
- if (cached$1.digest && !input.UnresolvedObject.digest) input.UnresolvedObject.digest = cached$1.digest;
17810
- }
17811
- }
17812
- await Promise.all(transactionData.commands.map(async (commands) => {
17813
- if (commands.MoveCall) {
17814
- const def = await this.getMoveFunctionDefinition({
17815
- package: commands.MoveCall.package,
17816
- module: commands.MoveCall.module,
17817
- function: commands.MoveCall.function
17818
- });
17819
- if (def) commands.MoveCall._argumentTypes = def.parameters;
17820
- }
17821
- }));
17822
- await next();
17823
- await Promise.all(transactionData.commands.map(async (commands) => {
17824
- if (commands.MoveCall?._argumentTypes) await this.#cache.addMoveFunctionDefinition({
17825
- package: commands.MoveCall.package,
17826
- module: commands.MoveCall.module,
17827
- function: commands.MoveCall.function,
17828
- parameters: commands.MoveCall._argumentTypes
17829
- });
17830
- }));
17831
- };
17832
- }
17833
- async clear() {
17834
- await this.#cache.clear();
17835
- }
17836
- async getMoveFunctionDefinition(ref) {
17837
- return this.#cache.getMoveFunctionDefinition(ref);
17838
- }
17839
- async getObjects(ids) {
17840
- return this.#cache.getObjects(ids);
17841
- }
17842
- async deleteObjects(ids) {
17843
- return this.#cache.deleteObjects(ids);
17844
- }
17845
- async clearOwnedObjects() {
17846
- await this.#cache.clear("OwnedObject");
17847
- }
17848
- async clearCustom() {
17849
- await this.#cache.clear("Custom");
17850
- }
17851
- async getCustom(key) {
17852
- return this.#cache.getCustom(key);
17853
- }
17854
- async setCustom(key, value) {
17855
- return this.#cache.setCustom(key, value);
17856
- }
17857
- async deleteCustom(key) {
17858
- return this.#cache.deleteCustom(key);
17859
- }
17860
- async applyEffects(effects) {
17861
- if (!effects.V2) throw new Error(`Unsupported transaction effects version ${effects.$kind}`);
17862
- const { lamportVersion, changedObjects } = effects.V2;
17863
- const deletedIds = [];
17864
- const addedObjects = [];
17865
- changedObjects.forEach(([id, change]) => {
17866
- if (change.outputState.NotExist) deletedIds.push(id);
17867
- else if (change.outputState.ObjectWrite) {
17868
- const [digest, owner] = change.outputState.ObjectWrite;
17869
- addedObjects.push({
17870
- objectId: id,
17871
- digest,
17872
- version: lamportVersion,
17873
- owner: owner.AddressOwner ?? owner.ObjectOwner ?? null,
17874
- initialSharedVersion: owner.Shared?.initialSharedVersion ?? null
17875
- });
17876
- }
17877
- });
17878
- await Promise.all([
17879
- this.#cache.addObjects(addedObjects),
17880
- this.#cache.deleteObjects(deletedIds),
17881
- this.#onEffects?.(effects)
17882
- ]);
17883
- }
17884
- };
17885
- }
17886
- });
17887
- var CachingTransactionExecutor;
17888
- var init_caching = __esm({
17889
- "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/executor/caching.mjs"() {
17890
- init_bcs3();
17891
- init_core_resolver();
17892
- init_Transaction();
17893
- init_ObjectCache();
17894
- CachingTransactionExecutor = class {
17895
- #client;
17896
- #lastDigest = null;
17897
- constructor({ client, ...options }) {
17898
- this.#client = client;
17899
- this.cache = new ObjectCache(options);
17900
- }
17901
- /**
17902
- * Clears all Owned objects
17903
- * Immutable objects, Shared objects, and Move function definitions will be preserved
17904
- */
17905
- async reset() {
17906
- await Promise.all([
17907
- this.cache.clearOwnedObjects(),
17908
- this.cache.clearCustom(),
17909
- this.waitForLastTransaction()
17910
- ]);
17911
- }
17912
- async buildTransaction({ transaction, ...options }) {
17913
- transaction.addBuildPlugin(this.cache.asPlugin());
17914
- transaction.addBuildPlugin(coreClientResolveTransactionPlugin);
17915
- return transaction.build({
17916
- client: this.#client,
17917
- ...options
17918
- });
17919
- }
17920
- async executeTransaction({ transaction, signatures, include }) {
17921
- const bytes = isTransaction(transaction) ? await this.buildTransaction({ transaction }) : transaction;
17922
- const results = await this.#client.core.executeTransaction({
17923
- transaction: bytes,
17924
- signatures,
17925
- include: {
17926
- ...include,
17927
- effects: true
17928
- }
17929
- });
17930
- const tx = results.$kind === "Transaction" ? results.Transaction : results.FailedTransaction;
17931
- if (tx.effects?.bcs) {
17932
- const effects = suiBcs.TransactionEffects.parse(tx.effects.bcs);
17933
- await this.applyEffects(effects);
17934
- }
17935
- return results;
17936
- }
17937
- async signAndExecuteTransaction({ include, transaction, signer }) {
17938
- transaction.setSenderIfNotSet(signer.toSuiAddress());
17939
- const bytes = await this.buildTransaction({ transaction });
17940
- const { signature } = await signer.signTransaction(bytes);
17941
- return this.executeTransaction({
17942
- transaction: bytes,
17943
- signatures: [signature],
17944
- include
17945
- });
17946
- }
17947
- async applyEffects(effects) {
17948
- this.#lastDigest = effects.V2?.transactionDigest ?? null;
17949
- await this.cache.applyEffects(effects);
17950
- }
17951
- async waitForLastTransaction() {
17952
- if (this.#lastDigest) {
17953
- await this.#client.core.waitForTransaction({ digest: this.#lastDigest });
17954
- this.#lastDigest = null;
17955
- }
17956
- }
17957
- };
17958
- }
17959
- });
17960
- var SerialQueue;
17961
- var ParallelQueue;
17962
- var init_queue = __esm({
17963
- "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/executor/queue.mjs"() {
17964
- SerialQueue = class {
17965
- #queue = [];
17966
- async runTask(task) {
17967
- return new Promise((resolve2, reject) => {
17968
- this.#queue.push(() => {
17969
- task().finally(() => {
17970
- this.#queue.shift();
17971
- if (this.#queue.length > 0) this.#queue[0]();
17972
- }).then(resolve2, reject);
17973
- });
17974
- if (this.#queue.length === 1) this.#queue[0]();
17975
- });
17976
- }
17977
- };
17978
- ParallelQueue = class {
17979
- #queue = [];
17980
- constructor(maxTasks) {
17981
- this.activeTasks = 0;
17982
- this.maxTasks = maxTasks;
17983
- }
17984
- runTask(task) {
17985
- return new Promise((resolve2, reject) => {
17986
- if (this.activeTasks < this.maxTasks) {
17987
- this.activeTasks++;
17988
- task().finally(() => {
17989
- if (this.#queue.length > 0) this.#queue.shift()();
17990
- else this.activeTasks--;
17991
- }).then(resolve2, reject);
17992
- } else this.#queue.push(() => {
17993
- task().finally(() => {
17994
- if (this.#queue.length > 0) this.#queue.shift()();
17995
- else this.activeTasks--;
17996
- }).then(resolve2, reject);
17997
- });
17998
- });
17999
- }
18000
- };
18001
- }
18002
- });
18003
- function getGasCoinFromEffects(effects) {
18004
- if (!effects.V2) throw new Error("Unexpected effects version");
18005
- const gasObjectChange = effects.V2.changedObjects[effects.V2.gasObjectIndex];
18006
- if (!gasObjectChange) throw new Error("Gas object not found in effects");
18007
- const [objectId, { outputState }] = gasObjectChange;
18008
- if (!outputState.ObjectWrite) throw new Error("Unexpected gas object state");
18009
- const [digest, owner] = outputState.ObjectWrite;
18010
- return {
18011
- ref: {
18012
- objectId,
18013
- digest,
18014
- version: effects.V2.lamportVersion
18015
- },
18016
- owner: owner.AddressOwner || owner.ObjectOwner
18017
- };
18018
- }
18019
- var EPOCH_BOUNDARY_WINDOW;
18020
- var SerialTransactionExecutor;
18021
- var init_serial = __esm({
18022
- "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/executor/serial.mjs"() {
18023
- init_Transaction();
18024
- init_caching();
18025
- init_queue();
18026
- EPOCH_BOUNDARY_WINDOW = 6e4;
18027
- SerialTransactionExecutor = class {
18028
- #queue = new SerialQueue();
18029
- #signer;
18030
- #client;
18031
- #cache;
18032
- #defaultGasBudget;
18033
- #gasMode;
18034
- #epochInfo = null;
18035
- #epochInfoPromise = null;
18036
- constructor(options) {
18037
- const { signer, defaultGasBudget = 50000000n, client, cache } = options;
18038
- this.#signer = signer;
18039
- this.#client = client;
18040
- this.#defaultGasBudget = defaultGasBudget;
18041
- this.#gasMode = options.gasMode ?? "coins";
18042
- this.#cache = new CachingTransactionExecutor({
18043
- client,
18044
- cache,
18045
- onEffects: (effects) => this.#cacheGasCoin(effects)
18046
- });
18047
- }
18048
- async applyEffects(effects) {
18049
- return this.#cache.applyEffects(effects);
18050
- }
18051
- #cacheGasCoin = async (effects) => {
18052
- if (this.#gasMode === "addressBalance" || !effects.V2) return;
18053
- const gasCoin = getGasCoinFromEffects(effects).ref;
18054
- if (gasCoin) this.#cache.cache.setCustom("gasCoin", gasCoin);
18055
- else this.#cache.cache.deleteCustom("gasCoin");
18056
- };
18057
- async buildTransaction(transaction) {
18058
- return this.#queue.runTask(() => this.#buildTransaction(transaction));
18059
- }
18060
- #buildTransaction = async (transaction) => {
18061
- await transaction.prepareForSerialization({
18062
- client: this.#client,
18063
- supportedIntents: ["CoinWithBalance"]
18064
- });
18065
- const copy2 = Transaction.from(transaction);
18066
- if (this.#gasMode === "addressBalance") {
18067
- copy2.setGasPayment([]);
18068
- copy2.setExpiration(await this.#getValidDuringExpiration());
18069
- } else {
18070
- const gasCoin = await this.#cache.cache.getCustom("gasCoin");
18071
- if (gasCoin) copy2.setGasPayment([gasCoin]);
18072
- }
18073
- copy2.setGasBudgetIfNotSet(this.#defaultGasBudget);
18074
- copy2.setSenderIfNotSet(this.#signer.toSuiAddress());
18075
- return this.#cache.buildTransaction({ transaction: copy2 });
18076
- };
18077
- async #getValidDuringExpiration() {
18078
- await this.#ensureEpochInfo();
18079
- const currentEpoch = BigInt(this.#epochInfo.epoch);
18080
- return { ValidDuring: {
18081
- minEpoch: String(currentEpoch),
18082
- maxEpoch: String(currentEpoch + 1n),
18083
- minTimestamp: null,
18084
- maxTimestamp: null,
18085
- chain: this.#epochInfo.chainIdentifier,
18086
- nonce: Math.random() * 4294967296 >>> 0
18087
- } };
18088
- }
18089
- async #ensureEpochInfo() {
18090
- if (this.#epochInfo && this.#epochInfo.expiration - EPOCH_BOUNDARY_WINDOW - Date.now() > 0) return;
18091
- if (this.#epochInfoPromise) {
18092
- await this.#epochInfoPromise;
18093
- return;
18094
- }
18095
- this.#epochInfoPromise = this.#fetchEpochInfo();
18096
- try {
18097
- await this.#epochInfoPromise;
18098
- } finally {
18099
- this.#epochInfoPromise = null;
18100
- }
18101
- }
18102
- async #fetchEpochInfo() {
18103
- const [{ systemState }, { chainIdentifier }] = await Promise.all([this.#client.core.getCurrentSystemState(), this.#client.core.getChainIdentifier()]);
18104
- this.#epochInfo = {
18105
- epoch: systemState.epoch,
18106
- expiration: Number(systemState.epochStartTimestampMs) + Number(systemState.parameters.epochDurationMs),
18107
- chainIdentifier
18108
- };
18109
- }
18110
- resetCache() {
18111
- return this.#cache.reset();
18112
- }
18113
- waitForLastTransaction() {
18114
- return this.#cache.waitForLastTransaction();
18115
- }
18116
- executeTransaction(transaction, include, additionalSignatures = []) {
18117
- return this.#queue.runTask(async () => {
18118
- const bytes = isTransaction(transaction) ? await this.#buildTransaction(transaction) : transaction;
18119
- const { signature } = await this.#signer.signTransaction(bytes);
18120
- return this.#cache.executeTransaction({
18121
- signatures: [signature, ...additionalSignatures],
18122
- transaction: bytes,
18123
- include
18124
- }).catch(async (error2) => {
18125
- await this.resetCache();
18126
- throw error2;
18127
- });
18128
- });
18129
- }
18130
- };
18131
- }
18132
- });
18133
- var PARALLEL_EXECUTOR_DEFAULTS;
18134
- var EPOCH_BOUNDARY_WINDOW2;
18135
- var ParallelTransactionExecutor;
18136
- var init_parallel = __esm({
18137
- "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/executor/parallel.mjs"() {
18138
- init_TransactionData();
18139
- init_core_resolver();
18140
- init_Transaction();
18141
- init_caching();
18142
- init_queue();
18143
- init_dist4();
18144
- PARALLEL_EXECUTOR_DEFAULTS = {
18145
- coinBatchSize: 20,
18146
- initialCoinBalance: 200000000n,
18147
- minimumCoinBalance: 50000000n,
18148
- maxPoolSize: 50
18149
- };
18150
- EPOCH_BOUNDARY_WINDOW2 = 6e4;
18151
- ParallelTransactionExecutor = class {
18152
- #signer;
18153
- #client;
18154
- #gasMode;
18155
- #coinBatchSize;
18156
- #initialCoinBalance;
18157
- #minimumCoinBalance;
18158
- #defaultGasBudget;
18159
- #maxPoolSize;
18160
- #sourceCoins;
18161
- #coinPool = [];
18162
- #cache;
18163
- #objectIdQueues = /* @__PURE__ */ new Map();
18164
- #buildQueue = new SerialQueue();
18165
- #executeQueue;
18166
- #lastDigest = null;
18167
- #cacheLock = null;
18168
- #pendingTransactions = 0;
18169
- #epochInfo = null;
18170
- #epochInfoPromise = null;
18171
- constructor(options) {
18172
- this.#signer = options.signer;
18173
- this.#client = options.client;
18174
- this.#gasMode = options.gasMode ?? "coins";
18175
- if (this.#gasMode === "coins") {
18176
- const coinOptions = options;
18177
- this.#coinBatchSize = coinOptions.coinBatchSize ?? PARALLEL_EXECUTOR_DEFAULTS.coinBatchSize;
18178
- this.#initialCoinBalance = coinOptions.initialCoinBalance ?? PARALLEL_EXECUTOR_DEFAULTS.initialCoinBalance;
18179
- this.#minimumCoinBalance = coinOptions.minimumCoinBalance ?? PARALLEL_EXECUTOR_DEFAULTS.minimumCoinBalance;
18180
- this.#sourceCoins = coinOptions.sourceCoins ? new Map(coinOptions.sourceCoins.map((id) => [id, null])) : null;
18181
- } else {
18182
- this.#coinBatchSize = 0;
18183
- this.#initialCoinBalance = 0n;
18184
- this.#minimumCoinBalance = PARALLEL_EXECUTOR_DEFAULTS.minimumCoinBalance;
18185
- this.#sourceCoins = null;
18186
- }
18187
- this.#defaultGasBudget = options.defaultGasBudget ?? this.#minimumCoinBalance;
18188
- this.#maxPoolSize = options.maxPoolSize ?? PARALLEL_EXECUTOR_DEFAULTS.maxPoolSize;
18189
- this.#cache = new CachingTransactionExecutor({
18190
- client: options.client,
18191
- cache: options.cache
18192
- });
18193
- this.#executeQueue = new ParallelQueue(this.#maxPoolSize);
18194
- }
18195
- resetCache() {
18196
- this.#epochInfo = null;
18197
- return this.#updateCache(() => this.#cache.reset());
18198
- }
18199
- async waitForLastTransaction() {
18200
- await this.#updateCache(() => this.#waitForLastDigest());
18201
- }
18202
- async executeTransaction(transaction, include, additionalSignatures = []) {
18203
- const { promise, resolve: resolve2, reject } = promiseWithResolvers();
18204
- const usedObjects = await this.#getUsedObjects(transaction);
18205
- const execute = () => {
18206
- this.#executeQueue.runTask(() => {
18207
- return this.#execute(transaction, usedObjects, include, additionalSignatures).then(resolve2, reject);
18208
- });
18209
- };
18210
- const conflicts = /* @__PURE__ */ new Set();
18211
- usedObjects.forEach((objectId) => {
18212
- if (this.#objectIdQueues.get(objectId)) {
18213
- conflicts.add(objectId);
18214
- this.#objectIdQueues.get(objectId).push(() => {
18215
- conflicts.delete(objectId);
18216
- if (conflicts.size === 0) execute();
18217
- });
18218
- } else this.#objectIdQueues.set(objectId, []);
18219
- });
18220
- if (conflicts.size === 0) execute();
18221
- return promise;
18222
- }
18223
- async #getUsedObjects(transaction) {
18224
- const usedObjects = /* @__PURE__ */ new Set();
18225
- let serialized = false;
18226
- transaction.addSerializationPlugin(async (blockData, _options, next) => {
18227
- await next();
18228
- if (serialized) return;
18229
- serialized = true;
18230
- blockData.inputs.forEach((input) => {
18231
- if (input.Object?.ImmOrOwnedObject?.objectId) usedObjects.add(input.Object.ImmOrOwnedObject.objectId);
18232
- else if (input.Object?.Receiving?.objectId) usedObjects.add(input.Object.Receiving.objectId);
18233
- else if (input.UnresolvedObject?.objectId && !input.UnresolvedObject.initialSharedVersion) usedObjects.add(input.UnresolvedObject.objectId);
18234
- });
18235
- });
18236
- await transaction.prepareForSerialization({ client: this.#client });
18237
- return usedObjects;
18238
- }
18239
- async #execute(transaction, usedObjects, include, additionalSignatures = []) {
18240
- let gasCoin = null;
18241
- try {
18242
- transaction.setSenderIfNotSet(this.#signer.toSuiAddress());
18243
- await this.#buildQueue.runTask(async () => {
18244
- if (!transaction.getData().gasData.price) transaction.setGasPrice(await this.#getGasPrice());
18245
- transaction.setGasBudgetIfNotSet(this.#defaultGasBudget);
18246
- await this.#updateCache();
18247
- this.#pendingTransactions++;
18248
- if (this.#gasMode === "addressBalance") {
18249
- transaction.setGasPayment([]);
18250
- transaction.setExpiration(await this.#getValidDuringExpiration());
18251
- } else {
18252
- gasCoin = await this.#getGasCoin();
18253
- transaction.setGasPayment([{
18254
- objectId: gasCoin.id,
18255
- version: gasCoin.version,
18256
- digest: gasCoin.digest
18257
- }]);
18258
- }
18259
- await this.#cache.buildTransaction({
18260
- transaction,
18261
- onlyTransactionKind: true
18262
- });
18263
- });
18264
- const bytes = await transaction.build({ client: this.#client });
18265
- const { signature } = await this.#signer.signTransaction(bytes);
18266
- const results = await this.#cache.executeTransaction({
18267
- transaction: bytes,
18268
- signatures: [signature, ...additionalSignatures],
18269
- include
18270
- });
18271
- const tx = results.$kind === "Transaction" ? results.Transaction : results.FailedTransaction;
18272
- const effects = tx.effects;
18273
- const gasObject = effects.gasObject;
18274
- const gasUsed = effects.gasUsed;
18275
- if (gasCoin && gasUsed && gasObject) {
18276
- const coin = gasCoin;
18277
- if ((gasObject.outputOwner?.AddressOwner ?? gasObject.outputOwner?.ObjectOwner) === this.#signer.toSuiAddress()) {
18278
- const totalUsed = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
18279
- const remainingBalance = coin.balance - totalUsed;
18280
- let usesGasCoin = false;
18281
- new TransactionDataBuilder(transaction.getData()).mapArguments((arg) => {
18282
- if (arg.$kind === "GasCoin") usesGasCoin = true;
18283
- return arg;
18284
- });
18285
- const gasRef = {
18286
- objectId: gasObject.objectId,
18287
- version: gasObject.outputVersion,
18288
- digest: gasObject.outputDigest
18289
- };
18290
- if (!usesGasCoin && remainingBalance >= this.#minimumCoinBalance) this.#coinPool.push({
18291
- id: gasRef.objectId,
18292
- version: gasRef.version,
18293
- digest: gasRef.digest,
18294
- balance: remainingBalance
18295
- });
18296
- else {
18297
- if (!this.#sourceCoins) this.#sourceCoins = /* @__PURE__ */ new Map();
18298
- this.#sourceCoins.set(gasRef.objectId, gasRef);
18299
- }
18300
- }
18301
- }
18302
- this.#lastDigest = tx.digest;
18303
- return results;
18304
- } catch (error2) {
18305
- if (gasCoin) {
18306
- if (!this.#sourceCoins) this.#sourceCoins = /* @__PURE__ */ new Map();
18307
- this.#sourceCoins.set(gasCoin.id, null);
18308
- }
18309
- await this.#updateCache(async () => {
18310
- await Promise.all([this.#cache.cache.deleteObjects([...usedObjects]), this.#waitForLastDigest()]);
18311
- });
18312
- throw error2;
18313
- } finally {
18314
- usedObjects.forEach((objectId) => {
18315
- const queue = this.#objectIdQueues.get(objectId);
18316
- if (queue && queue.length > 0) queue.shift()();
18317
- else if (queue) this.#objectIdQueues.delete(objectId);
18318
- });
18319
- this.#pendingTransactions--;
18320
- }
18321
- }
18322
- /** Helper for synchronizing cache updates, by ensuring only one update happens at a time. This can also be used to wait for any pending cache updates */
18323
- async #updateCache(fn) {
18324
- if (this.#cacheLock) await this.#cacheLock;
18325
- this.#cacheLock = fn?.().then(() => {
18326
- this.#cacheLock = null;
18327
- }, () => {
18328
- }) ?? null;
18329
- }
18330
- async #waitForLastDigest() {
18331
- const digest = this.#lastDigest;
18332
- if (digest) {
18333
- this.#lastDigest = null;
18334
- await this.#client.core.waitForTransaction({ digest });
18335
- }
18336
- }
18337
- async #getGasCoin() {
18338
- if (this.#coinPool.length === 0 && this.#pendingTransactions <= this.#maxPoolSize) await this.#refillCoinPool();
18339
- if (this.#coinPool.length === 0) throw new Error("No coins available");
18340
- return this.#coinPool.shift();
18341
- }
18342
- async #getGasPrice() {
18343
- await this.#ensureEpochInfo();
18344
- return this.#epochInfo.price;
18345
- }
18346
- async #getValidDuringExpiration() {
18347
- await this.#ensureEpochInfo();
18348
- const currentEpoch = BigInt(this.#epochInfo.epoch);
18349
- return { ValidDuring: {
18350
- minEpoch: String(currentEpoch),
18351
- maxEpoch: String(currentEpoch + 1n),
18352
- minTimestamp: null,
18353
- maxTimestamp: null,
18354
- chain: this.#epochInfo.chainIdentifier,
18355
- nonce: Math.random() * 4294967296 >>> 0
18356
- } };
18357
- }
18358
- async #ensureEpochInfo() {
18359
- if (this.#epochInfo && this.#epochInfo.expiration - EPOCH_BOUNDARY_WINDOW2 - Date.now() > 0) return;
18360
- if (this.#epochInfoPromise) {
18361
- await this.#epochInfoPromise;
18362
- return;
18363
- }
18364
- this.#epochInfoPromise = this.#fetchEpochInfo();
18365
- try {
18366
- await this.#epochInfoPromise;
18367
- } finally {
18368
- this.#epochInfoPromise = null;
18369
- }
18370
- }
18371
- async #fetchEpochInfo() {
18372
- const [{ systemState }, { chainIdentifier }] = await Promise.all([this.#client.core.getCurrentSystemState(), this.#client.core.getChainIdentifier()]);
18373
- this.#epochInfo = {
18374
- epoch: systemState.epoch,
18375
- price: BigInt(systemState.referenceGasPrice),
18376
- expiration: Number(systemState.epochStartTimestampMs) + Number(systemState.parameters.epochDurationMs),
18377
- chainIdentifier
18378
- };
18379
- }
18380
- async #refillCoinPool() {
18381
- const batchSize = Math.min(this.#coinBatchSize, this.#maxPoolSize - (this.#coinPool.length + this.#pendingTransactions) + 1);
18382
- if (batchSize === 0) return;
18383
- const txb = new Transaction();
18384
- const address = this.#signer.toSuiAddress();
18385
- txb.setSender(address);
18386
- if (this.#sourceCoins) {
18387
- const refs = [];
18388
- const ids = [];
18389
- for (const [id, ref] of this.#sourceCoins) if (ref) refs.push(ref);
18390
- else ids.push(id);
18391
- if (ids.length > 0) {
18392
- const { objects } = await this.#client.core.getObjects({ objectIds: ids });
18393
- refs.push(...objects.filter((obj) => !(obj instanceof Error)).map((obj) => ({
18394
- objectId: obj.objectId,
18395
- version: obj.version,
18396
- digest: obj.digest
18397
- })));
18398
- }
18399
- txb.setGasPayment(refs);
18400
- this.#sourceCoins = /* @__PURE__ */ new Map();
18401
- }
18402
- const amounts = new Array(batchSize).fill(this.#initialCoinBalance);
18403
- const splitResults = txb.splitCoins(txb.gas, amounts);
18404
- const coinResults = [];
18405
- for (let i = 0; i < amounts.length; i++) coinResults.push(splitResults[i]);
18406
- txb.transferObjects(coinResults, address);
18407
- await this.waitForLastTransaction();
18408
- txb.addBuildPlugin(coreClientResolveTransactionPlugin);
18409
- const bytes = await txb.build({ client: this.#client });
18410
- const { signature } = await this.#signer.signTransaction(bytes);
18411
- const result = await this.#client.core.executeTransaction({
18412
- transaction: bytes,
18413
- signatures: [signature],
18414
- include: { effects: true }
18415
- });
18416
- const tx = result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
18417
- const effects = tx.effects;
18418
- effects.changedObjects.forEach((changedObj) => {
18419
- if (changedObj.objectId === effects.gasObject?.objectId || changedObj.outputState !== "ObjectWrite") return;
18420
- this.#coinPool.push({
18421
- id: changedObj.objectId,
18422
- version: changedObj.outputVersion,
18423
- digest: changedObj.outputDigest,
18424
- balance: BigInt(this.#initialCoinBalance)
18425
- });
18426
- });
18427
- if (!this.#sourceCoins) this.#sourceCoins = /* @__PURE__ */ new Map();
18428
- const gasObject = effects.gasObject;
18429
- this.#sourceCoins.set(gasObject.objectId, {
18430
- objectId: gasObject.objectId,
18431
- version: gasObject.outputVersion,
18432
- digest: gasObject.outputDigest
18433
- });
18434
- await this.#client.core.waitForTransaction({ digest: tx.digest });
18435
- }
18436
- };
18437
- }
18438
- });
18439
- var Arguments;
18440
- var init_Arguments = __esm({
18441
- "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Arguments.mjs"() {
18442
- init_object();
18443
- init_pure2();
18444
- Arguments = {
18445
- pure: createPure((value) => (tx) => tx.pure(value)),
18446
- object: createObjectMethods((value) => (tx) => tx.object(value)),
18447
- sharedObjectRef: (...args) => (tx) => tx.sharedObjectRef(...args),
18448
- objectRef: (...args) => (tx) => tx.objectRef(...args),
18449
- receivingRef: (...args) => (tx) => tx.receivingRef(...args)
18450
- };
18451
- }
18452
- });
18453
- var transactions_exports = {};
18454
- __export(transactions_exports, {
18455
- Arguments: () => Arguments,
18456
- AsyncCache: () => AsyncCache,
18457
- Inputs: () => Inputs,
18458
- ObjectCache: () => ObjectCache,
18459
- ParallelTransactionExecutor: () => ParallelTransactionExecutor,
18460
- SerialTransactionExecutor: () => SerialTransactionExecutor,
18461
- Transaction: () => Transaction,
18462
- TransactionCommands: () => TransactionCommands,
18463
- TransactionDataBuilder: () => TransactionDataBuilder,
18464
- UpgradePolicy: () => UpgradePolicy,
18465
- coinWithBalance: () => coinWithBalance,
18466
- getPureBcsSchema: () => getPureBcsSchema,
18467
- isArgument: () => isArgument,
18468
- isTransaction: () => isTransaction,
18469
- normalizedTypeToMoveTypeSignature: () => normalizedTypeToMoveTypeSignature
18470
- });
18471
17632
  var init_transactions = __esm({
18472
17633
  "../../node_modules/.pnpm/@mysten+sui@2.17.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/index.mjs"() {
18473
- init_utils4();
18474
- init_TransactionData();
18475
- init_Commands();
18476
- init_Inputs();
18477
- init_serializer();
18478
17634
  init_CoinWithBalance();
18479
17635
  init_Transaction();
18480
- init_ObjectCache();
18481
- init_serial();
18482
- init_parallel();
18483
- init_Arguments();
18484
17636
  }
18485
17637
  });
18486
17638
  var require_bignumber = __commonJS({
@@ -78776,6 +77928,7 @@ var init_token_registry = __esm2({
78776
77928
  });
78777
77929
  var coinSelection_exports = {};
78778
77930
  __export2(coinSelection_exports, {
77931
+ buildCoinToAddressBalanceMigration: () => buildCoinToAddressBalanceMigration,
78779
77932
  fetchAllCoins: () => fetchAllCoins,
78780
77933
  selectAndSplitCoin: () => selectAndSplitCoin,
78781
77934
  selectSuiCoin: () => selectSuiCoin
@@ -78890,6 +78043,32 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
78890
78043
  });
78891
78044
  return { coin, effectiveAmount, swapAll };
78892
78045
  }
78046
+ function buildCoinToAddressBalanceMigration(args) {
78047
+ const { coins, coinType, owner, minAmount } = args;
78048
+ const sorted = [...coins].filter((c) => c.balance > 0n).sort((a, b) => b.balance > a.balance ? 1 : b.balance < a.balance ? -1 : 0);
78049
+ const selected = [];
78050
+ let migratedRaw = 0n;
78051
+ for (const c of sorted) {
78052
+ if (migratedRaw >= minAmount) break;
78053
+ selected.push(c);
78054
+ migratedRaw += c.balance;
78055
+ }
78056
+ if (migratedRaw < minAmount) {
78057
+ throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${coinType} coin objects to migrate`, {
78058
+ available: migratedRaw.toString(),
78059
+ required: minAmount.toString()
78060
+ });
78061
+ }
78062
+ const tx = new Transaction();
78063
+ for (const c of selected) {
78064
+ tx.moveCall({
78065
+ target: "0x2::coin::send_funds",
78066
+ typeArguments: [coinType],
78067
+ arguments: [tx.object(c.objectId), tx.pure.address(owner)]
78068
+ });
78069
+ }
78070
+ return { tx, migratedRaw };
78071
+ }
78893
78072
  async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
78894
78073
  if (sponsoredContext) {
78895
78074
  const { SUI_TYPE: SUI_TYPE22 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
@@ -79619,40 +78798,26 @@ async function ensureAddressBalanceCovers(args) {
79619
78798
  required: amountRaw.toString()
79620
78799
  });
79621
78800
  }
78801
+ const coins = [];
79622
78802
  let coinSum = 0n;
79623
78803
  let cursor;
79624
78804
  let hasNext = true;
79625
78805
  while (hasNext) {
79626
78806
  const page = await client.core.listCoins({ owner, coinType: asset, cursor: cursor ?? void 0 });
79627
- for (const c of page.objects) coinSum += BigInt(c.balance);
78807
+ for (const c of page.objects) {
78808
+ coins.push({ objectId: c.objectId, balance: BigInt(c.balance) });
78809
+ coinSum += BigInt(c.balance);
78810
+ }
79628
78811
  cursor = page.cursor;
79629
78812
  hasNext = page.hasNextPage;
79630
78813
  }
79631
78814
  const addressBalance = total - coinSum;
79632
78815
  if (addressBalance >= amountRaw) return 0;
79633
78816
  const shortfall = amountRaw - addressBalance;
79634
- const { Transaction: Transaction6 } = await Promise.resolve().then(() => (init_transactions(), transactions_exports));
79635
- const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
78817
+ const { buildCoinToAddressBalanceMigration: buildCoinToAddressBalanceMigration2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
79636
78818
  const grpcClient = await makeGrpcBuildClient(client);
79637
- const migration = await executeTx(
79638
- client,
79639
- signer,
79640
- async () => {
79641
- const tx = new Transaction6();
79642
- const { coin } = await selectAndSplitCoin2(tx, client, owner, asset, shortfall, {
79643
- sponsoredContext: true,
79644
- // coin-objects-only — never the address balance
79645
- allowSwapAll: false
79646
- });
79647
- tx.moveCall({
79648
- target: "0x2::coin::send_funds",
79649
- typeArguments: [asset],
79650
- arguments: [coin, tx.pure.address(owner)]
79651
- });
79652
- return tx;
79653
- },
79654
- { buildClient: grpcClient }
79655
- );
78819
+ const { tx } = buildCoinToAddressBalanceMigration2({ coins, coinType: asset, owner, minAmount: shortfall });
78820
+ const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
79656
78821
  return migration.gasCostSui;
79657
78822
  }
79658
78823
  async function finalize(response, opts) {
@@ -81166,7 +80331,7 @@ Through this wallet you can reach essentially any major external API, billed to
81166
80331
  CRITICAL: When the user asks to use any external or paid API, names a provider (e.g. "via fal.ai", "with ElevenLabs"), or requests a capability one of the services above provides, DO NOT say you cannot reach that service, that it isn't on an allowlist, or that there's no connector \u2014 and do NOT fall back to writing a script for the user to run. You CAN do it directly through this wallet. Use t2000_services to discover the endpoint and request shape, then t2000_pay to execute, then show the user the result (display image/audio URLs returned in the response).
81167
80332
 
81168
80333
  Spending is the user's own USDC and every t2000_pay call is bounded by maxPrice. For larger or multi-step spends, state the estimated cost first and proceed once the user is happy. Use t2000_balance to check funds. The v4 wallet is payments-only; savings / lending live on audric.ai.`;
81169
- var PKG_VERSION = "5.6.0";
80334
+ var PKG_VERSION = "5.6.1";
81170
80335
  console.log = (...args) => console.error("[log]", ...args);
81171
80336
  console.warn = (...args) => console.error("[warn]", ...args);
81172
80337
  async function startMcpServer(opts) {
@@ -81232,4 +80397,4 @@ mime-types/index.js:
81232
80397
  @scure/bip39/index.js:
81233
80398
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
81234
80399
  */
81235
- //# sourceMappingURL=dist-ULTRYNV7.js.map
80400
+ //# sourceMappingURL=dist-5TKR5HBZ.js.map