@interest-protocol/vortex-sdk 11.3.0 → 11.3.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.
package/dist/index.mjs CHANGED
@@ -2835,12 +2835,12 @@ const InnerTypeTag = bcs.enum("TypeTag", {
2835
2835
  address: null,
2836
2836
  signer: null,
2837
2837
  vector: bcs.lazy(() => InnerTypeTag),
2838
- struct: bcs.lazy(() => StructTag$1),
2838
+ struct: bcs.lazy(() => StructTag),
2839
2839
  u16: null,
2840
2840
  u32: null,
2841
2841
  u256: null
2842
2842
  });
2843
- const TypeTag$1 = InnerTypeTag.transform({
2843
+ const TypeTag = InnerTypeTag.transform({
2844
2844
  input: (typeTag) => typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag, true) : typeTag,
2845
2845
  output: (typeTag) => TypeTagSerializer.tagToString(typeTag)
2846
2846
  });
@@ -2854,7 +2854,7 @@ const ProgrammableMoveCall$1 = bcs.struct("ProgrammableMoveCall", {
2854
2854
  package: Address,
2855
2855
  module: bcs.string(),
2856
2856
  function: bcs.string(),
2857
- typeArguments: bcs.vector(TypeTag$1),
2857
+ typeArguments: bcs.vector(TypeTag),
2858
2858
  arguments: bcs.vector(Argument$1)
2859
2859
  });
2860
2860
  const Command$1 = bcs.enum("Command", {
@@ -2903,7 +2903,7 @@ const Command$1 = bcs.enum("Command", {
2903
2903
  // * so this call serves a utility function.
2904
2904
  // */
2905
2905
  MakeMoveVec: bcs.struct("MakeMoveVec", {
2906
- type: optionEnum(TypeTag$1).transform({
2906
+ type: optionEnum(TypeTag).transform({
2907
2907
  input: (val) => val === null ? {
2908
2908
  None: true
2909
2909
  } : {
@@ -2935,11 +2935,11 @@ const TransactionKind = bcs.enum("TransactionKind", {
2935
2935
  Genesis: null,
2936
2936
  ConsensusCommitPrologue: null
2937
2937
  });
2938
- const TransactionExpiration$3 = bcs.enum("TransactionExpiration", {
2938
+ const TransactionExpiration$2 = bcs.enum("TransactionExpiration", {
2939
2939
  None: null,
2940
2940
  Epoch: unsafe_u64()
2941
2941
  });
2942
- const StructTag$1 = bcs.struct("StructTag", {
2942
+ const StructTag = bcs.struct("StructTag", {
2943
2943
  address: Address,
2944
2944
  module: bcs.string(),
2945
2945
  name: bcs.string(),
@@ -2955,7 +2955,7 @@ const TransactionDataV1 = bcs.struct("TransactionDataV1", {
2955
2955
  kind: TransactionKind,
2956
2956
  sender: Address,
2957
2957
  gasData: GasData$1,
2958
- expiration: TransactionExpiration$3
2958
+ expiration: TransactionExpiration$2
2959
2959
  });
2960
2960
  const TransactionData = bcs.enum("TransactionData", {
2961
2961
  V1: TransactionDataV1
@@ -3281,14 +3281,14 @@ const suiBcs = {
3281
3281
  SenderSignedData,
3282
3282
  SenderSignedTransaction,
3283
3283
  SharedObjectRef,
3284
- StructTag: StructTag$1,
3284
+ StructTag,
3285
3285
  SuiObjectRef,
3286
3286
  TransactionData,
3287
3287
  TransactionDataV1,
3288
3288
  TransactionEffects,
3289
- TransactionExpiration: TransactionExpiration$3,
3289
+ TransactionExpiration: TransactionExpiration$2,
3290
3290
  TransactionKind,
3291
- TypeTag: TypeTag$1
3291
+ TypeTag
3292
3292
  };
3293
3293
 
3294
3294
  function deriveDynamicFieldID(parentId, typeTag, key) {
@@ -3422,8 +3422,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
3422
3422
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3423
3423
  };
3424
3424
 
3425
- const PACKAGE_VERSION = "1.43.2";
3426
- const TARGETED_RPC_VERSION = "1.60.0";
3425
+ const PACKAGE_VERSION = "1.45.2";
3426
+ const TARGETED_RPC_VERSION = "1.62.0";
3427
3427
 
3428
3428
  const CODE_TO_ERROR_TYPE = {
3429
3429
  "-32700": "ParseError",
@@ -3824,783 +3824,914 @@ class Experimental_BaseClient {
3824
3824
  }
3825
3825
  }
3826
3826
 
3827
- // src/actions/await/awaitAsync.ts
3828
-
3829
- // src/storages/globalConfig/globalConfig.ts
3830
- var store;
3831
- function getGlobalConfig(config2) {
3832
- return {
3833
- lang: config2?.lang ?? store?.lang,
3834
- message: config2?.message,
3835
- abortEarly: config2?.abortEarly ?? store?.abortEarly,
3836
- abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
3837
- };
3827
+ //#region src/storages/globalConfig/globalConfig.ts
3828
+ let store$4;
3829
+ /**
3830
+ * Returns the global configuration.
3831
+ *
3832
+ * @param config The config to merge.
3833
+ *
3834
+ * @returns The configuration.
3835
+ */
3836
+ /* @__NO_SIDE_EFFECTS__ */
3837
+ function getGlobalConfig(config$1) {
3838
+ return {
3839
+ lang: config$1?.lang ?? store$4?.lang,
3840
+ message: config$1?.message,
3841
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
3842
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
3843
+ };
3838
3844
  }
3839
3845
 
3840
- // src/storages/globalMessage/globalMessage.ts
3841
- var store2;
3846
+ //#endregion
3847
+ //#region src/storages/globalMessage/globalMessage.ts
3848
+ let store$3;
3849
+ /**
3850
+ * Returns a global error message.
3851
+ *
3852
+ * @param lang The language of the message.
3853
+ *
3854
+ * @returns The error message.
3855
+ */
3856
+ /* @__NO_SIDE_EFFECTS__ */
3842
3857
  function getGlobalMessage(lang) {
3843
- return store2?.get(lang);
3858
+ return store$3?.get(lang);
3844
3859
  }
3845
3860
 
3846
- // src/storages/schemaMessage/schemaMessage.ts
3847
- var store3;
3861
+ //#endregion
3862
+ //#region src/storages/schemaMessage/schemaMessage.ts
3863
+ let store$2;
3864
+ /**
3865
+ * Returns a schema error message.
3866
+ *
3867
+ * @param lang The language of the message.
3868
+ *
3869
+ * @returns The error message.
3870
+ */
3871
+ /* @__NO_SIDE_EFFECTS__ */
3848
3872
  function getSchemaMessage(lang) {
3849
- return store3?.get(lang);
3873
+ return store$2?.get(lang);
3850
3874
  }
3851
3875
 
3852
- // src/storages/specificMessage/specificMessage.ts
3853
- var store4;
3876
+ //#endregion
3877
+ //#region src/storages/specificMessage/specificMessage.ts
3878
+ let store$1;
3879
+ /**
3880
+ * Returns a specific error message.
3881
+ *
3882
+ * @param reference The identifier reference.
3883
+ * @param lang The language of the message.
3884
+ *
3885
+ * @returns The error message.
3886
+ */
3887
+ /* @__NO_SIDE_EFFECTS__ */
3854
3888
  function getSpecificMessage(reference, lang) {
3855
- return store4?.get(reference)?.get(lang);
3889
+ return store$1?.get(reference)?.get(lang);
3856
3890
  }
3857
3891
 
3858
- // src/utils/_stringify/_stringify.ts
3892
+ //#endregion
3893
+ //#region src/utils/_stringify/_stringify.ts
3894
+ /**
3895
+ * Stringifies an unknown input to a literal or type string.
3896
+ *
3897
+ * @param input The unknown input.
3898
+ *
3899
+ * @returns A literal or type string.
3900
+ *
3901
+ * @internal
3902
+ */
3903
+ /* @__NO_SIDE_EFFECTS__ */
3859
3904
  function _stringify(input) {
3860
- const type = typeof input;
3861
- if (type === "string") {
3862
- return `"${input}"`;
3863
- }
3864
- if (type === "number" || type === "bigint" || type === "boolean") {
3865
- return `${input}`;
3866
- }
3867
- if (type === "object" || type === "function") {
3868
- return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
3869
- }
3870
- return type;
3905
+ const type = typeof input;
3906
+ if (type === "string") return `"${input}"`;
3907
+ if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
3908
+ if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
3909
+ return type;
3871
3910
  }
3872
3911
 
3873
- // src/utils/_addIssue/_addIssue.ts
3874
- function _addIssue(context, label, dataset, config2, other) {
3875
- const input = other && "input" in other ? other.input : dataset.value;
3876
- const expected = other?.expected ?? context.expects ?? null;
3877
- const received = other?.received ?? _stringify(input);
3878
- const issue = {
3879
- kind: context.kind,
3880
- type: context.type,
3881
- input,
3882
- expected,
3883
- received,
3884
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
3885
- // @ts-expect-error
3886
- requirement: context.requirement,
3887
- path: other?.path,
3888
- issues: other?.issues,
3889
- lang: config2.lang,
3890
- abortEarly: config2.abortEarly,
3891
- abortPipeEarly: config2.abortPipeEarly
3892
- };
3893
- const isSchema = context.kind === "schema";
3894
- const message = other?.message ?? // @ts-expect-error
3895
- context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
3896
- if (message) {
3897
- issue.message = typeof message === "function" ? message(issue) : message;
3898
- }
3899
- if (isSchema) {
3900
- dataset.typed = false;
3901
- }
3902
- if (dataset.issues) {
3903
- dataset.issues.push(issue);
3904
- } else {
3905
- dataset.issues = [issue];
3906
- }
3912
+ //#endregion
3913
+ //#region src/utils/_addIssue/_addIssue.ts
3914
+ /**
3915
+ * Adds an issue to the dataset.
3916
+ *
3917
+ * @param context The issue context.
3918
+ * @param label The issue label.
3919
+ * @param dataset The input dataset.
3920
+ * @param config The configuration.
3921
+ * @param other The optional props.
3922
+ *
3923
+ * @internal
3924
+ */
3925
+ function _addIssue(context, label, dataset, config$1, other) {
3926
+ const input = other && "input" in other ? other.input : dataset.value;
3927
+ const expected = other?.expected ?? context.expects ?? null;
3928
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
3929
+ const issue = {
3930
+ kind: context.kind,
3931
+ type: context.type,
3932
+ input,
3933
+ expected,
3934
+ received,
3935
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
3936
+ requirement: context.requirement,
3937
+ path: other?.path,
3938
+ issues: other?.issues,
3939
+ lang: config$1.lang,
3940
+ abortEarly: config$1.abortEarly,
3941
+ abortPipeEarly: config$1.abortPipeEarly
3942
+ };
3943
+ const isSchema = context.kind === "schema";
3944
+ const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
3945
+ if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
3946
+ if (isSchema) dataset.typed = false;
3947
+ if (dataset.issues) dataset.issues.push(issue);
3948
+ else dataset.issues = [issue];
3907
3949
  }
3908
3950
 
3909
- // src/utils/_isValidObjectKey/_isValidObjectKey.ts
3910
- function _isValidObjectKey(object2, key) {
3911
- return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
3951
+ //#endregion
3952
+ //#region src/utils/_getStandardProps/_getStandardProps.ts
3953
+ /**
3954
+ * Returns the Standard Schema properties.
3955
+ *
3956
+ * @param context The schema context.
3957
+ *
3958
+ * @returns The Standard Schema properties.
3959
+ */
3960
+ /* @__NO_SIDE_EFFECTS__ */
3961
+ function _getStandardProps(context) {
3962
+ return {
3963
+ version: 1,
3964
+ vendor: "valibot",
3965
+ validate(value$1) {
3966
+ return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
3967
+ }
3968
+ };
3912
3969
  }
3913
3970
 
3914
- // src/utils/ValiError/ValiError.ts
3971
+ //#endregion
3972
+ //#region src/utils/_isValidObjectKey/_isValidObjectKey.ts
3973
+ /**
3974
+ * Disallows inherited object properties and prevents object prototype
3975
+ * pollution by disallowing certain keys.
3976
+ *
3977
+ * @param object The object to check.
3978
+ * @param key The key to check.
3979
+ *
3980
+ * @returns Whether the key is allowed.
3981
+ *
3982
+ * @internal
3983
+ */
3984
+ /* @__NO_SIDE_EFFECTS__ */
3985
+ function _isValidObjectKey(object$1, key) {
3986
+ return Object.hasOwn(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
3987
+ }
3988
+
3989
+ //#endregion
3990
+ //#region src/utils/_joinExpects/_joinExpects.ts
3991
+ /**
3992
+ * Joins multiple `expects` values with the given separator.
3993
+ *
3994
+ * @param values The `expects` values.
3995
+ * @param separator The separator.
3996
+ *
3997
+ * @returns The joined `expects` property.
3998
+ *
3999
+ * @internal
4000
+ */
4001
+ /* @__NO_SIDE_EFFECTS__ */
4002
+ function _joinExpects(values$1, separator) {
4003
+ const list = [...new Set(values$1)];
4004
+ if (list.length > 1) return `(${list.join(` ${separator} `)})`;
4005
+ return list[0] ?? "never";
4006
+ }
4007
+
4008
+ //#endregion
4009
+ //#region src/utils/ValiError/ValiError.ts
4010
+ /**
4011
+ * A Valibot error with useful information.
4012
+ */
3915
4013
  var ValiError = class extends Error {
3916
- /**
3917
- * The error issues.
3918
- */
3919
- issues;
3920
- /**
3921
- * Creates a Valibot error with useful information.
3922
- *
3923
- * @param issues The error issues.
3924
- */
3925
- constructor(issues) {
3926
- super(issues[0].message);
3927
- this.name = "ValiError";
3928
- this.issues = issues;
3929
- }
4014
+ /**
4015
+ * Creates a Valibot error with useful information.
4016
+ *
4017
+ * @param issues The error issues.
4018
+ */
4019
+ constructor(issues) {
4020
+ super(issues[0].message);
4021
+ this.name = "ValiError";
4022
+ this.issues = issues;
4023
+ }
3930
4024
  };
3931
4025
 
3932
- // src/actions/check/check.ts
3933
- function check(requirement, message) {
3934
- return {
3935
- kind: "validation",
3936
- type: "check",
3937
- reference: check,
3938
- async: false,
3939
- expects: null,
3940
- requirement,
3941
- message,
3942
- _run(dataset, config2) {
3943
- if (dataset.typed && !this.requirement(dataset.value)) {
3944
- _addIssue(this, "input", dataset, config2);
3945
- }
3946
- return dataset;
3947
- }
3948
- };
4026
+ //#endregion
4027
+ //#region src/actions/check/check.ts
4028
+ /* @__NO_SIDE_EFFECTS__ */
4029
+ function check(requirement, message$1) {
4030
+ return {
4031
+ kind: "validation",
4032
+ type: "check",
4033
+ reference: check,
4034
+ async: false,
4035
+ expects: null,
4036
+ requirement,
4037
+ message: message$1,
4038
+ "~run"(dataset, config$1) {
4039
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
4040
+ return dataset;
4041
+ }
4042
+ };
3949
4043
  }
3950
4044
 
3951
- // src/actions/integer/integer.ts
3952
- function integer(message) {
3953
- return {
3954
- kind: "validation",
3955
- type: "integer",
3956
- reference: integer,
3957
- async: false,
3958
- expects: null,
3959
- requirement: Number.isInteger,
3960
- message,
3961
- _run(dataset, config2) {
3962
- if (dataset.typed && !this.requirement(dataset.value)) {
3963
- _addIssue(this, "integer", dataset, config2);
3964
- }
3965
- return dataset;
3966
- }
3967
- };
4045
+ //#endregion
4046
+ //#region src/actions/integer/integer.ts
4047
+ /* @__NO_SIDE_EFFECTS__ */
4048
+ function integer(message$1) {
4049
+ return {
4050
+ kind: "validation",
4051
+ type: "integer",
4052
+ reference: integer,
4053
+ async: false,
4054
+ expects: null,
4055
+ requirement: Number.isInteger,
4056
+ message: message$1,
4057
+ "~run"(dataset, config$1) {
4058
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
4059
+ return dataset;
4060
+ }
4061
+ };
3968
4062
  }
3969
4063
 
3970
- // src/actions/transform/transform.ts
4064
+ //#endregion
4065
+ //#region src/actions/transform/transform.ts
4066
+ /**
4067
+ * Creates a custom transformation action.
4068
+ *
4069
+ * @param operation The transformation operation.
4070
+ *
4071
+ * @returns A transform action.
4072
+ */
4073
+ /* @__NO_SIDE_EFFECTS__ */
3971
4074
  function transform(operation) {
3972
- return {
3973
- kind: "transformation",
3974
- type: "transform",
3975
- reference: transform,
3976
- async: false,
3977
- operation,
3978
- _run(dataset) {
3979
- dataset.value = this.operation(dataset.value);
3980
- return dataset;
3981
- }
3982
- };
4075
+ return {
4076
+ kind: "transformation",
4077
+ type: "transform",
4078
+ reference: transform,
4079
+ async: false,
4080
+ operation,
4081
+ "~run"(dataset) {
4082
+ dataset.value = this.operation(dataset.value);
4083
+ return dataset;
4084
+ }
4085
+ };
3983
4086
  }
3984
4087
 
3985
- // src/methods/getDefault/getDefault.ts
3986
- function getDefault(schema, dataset, config2) {
3987
- return typeof schema.default === "function" ? (
3988
- // @ts-expect-error
3989
- schema.default(dataset, config2)
3990
- ) : (
3991
- // @ts-expect-error
3992
- schema.default
3993
- );
4088
+ //#endregion
4089
+ //#region src/methods/getFallback/getFallback.ts
4090
+ /**
4091
+ * Returns the fallback value of the schema.
4092
+ *
4093
+ * @param schema The schema to get it from.
4094
+ * @param dataset The output dataset if available.
4095
+ * @param config The config if available.
4096
+ *
4097
+ * @returns The fallback value.
4098
+ */
4099
+ /* @__NO_SIDE_EFFECTS__ */
4100
+ function getFallback(schema, dataset, config$1) {
4101
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
3994
4102
  }
3995
4103
 
3996
- // src/methods/is/is.ts
4104
+ //#endregion
4105
+ //#region src/methods/getDefault/getDefault.ts
4106
+ /**
4107
+ * Returns the default value of the schema.
4108
+ *
4109
+ * @param schema The schema to get it from.
4110
+ * @param dataset The input dataset if available.
4111
+ * @param config The config if available.
4112
+ *
4113
+ * @returns The default value.
4114
+ */
4115
+ /* @__NO_SIDE_EFFECTS__ */
4116
+ function getDefault(schema, dataset, config$1) {
4117
+ return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
4118
+ }
4119
+
4120
+ //#endregion
4121
+ //#region src/methods/is/is.ts
4122
+ /**
4123
+ * Checks if the input matches the schema. By using a type predicate, this
4124
+ * function can be used as a type guard.
4125
+ *
4126
+ * @param schema The schema to be used.
4127
+ * @param input The input to be tested.
4128
+ *
4129
+ * @returns Whether the input matches the schema.
4130
+ */
4131
+ /* @__NO_SIDE_EFFECTS__ */
3997
4132
  function is(schema, input) {
3998
- return !schema._run({ typed: false, value: input }, { abortEarly: true }).issues;
4133
+ return !schema["~run"]({ value: input }, { abortEarly: true }).issues;
3999
4134
  }
4000
4135
 
4001
- // src/schemas/array/array.ts
4002
- function array(item, message) {
4003
- return {
4004
- kind: "schema",
4005
- type: "array",
4006
- reference: array,
4007
- expects: "Array",
4008
- async: false,
4009
- item,
4010
- message,
4011
- _run(dataset, config2) {
4012
- const input = dataset.value;
4013
- if (Array.isArray(input)) {
4014
- dataset.typed = true;
4015
- dataset.value = [];
4016
- for (let key = 0; key < input.length; key++) {
4017
- const value2 = input[key];
4018
- const itemDataset = this.item._run({ typed: false, value: value2 }, config2);
4019
- if (itemDataset.issues) {
4020
- const pathItem = {
4021
- type: "array",
4022
- origin: "value",
4023
- input,
4024
- key,
4025
- value: value2
4026
- };
4027
- for (const issue of itemDataset.issues) {
4028
- if (issue.path) {
4029
- issue.path.unshift(pathItem);
4030
- } else {
4031
- issue.path = [pathItem];
4032
- }
4033
- dataset.issues?.push(issue);
4034
- }
4035
- if (!dataset.issues) {
4036
- dataset.issues = itemDataset.issues;
4037
- }
4038
- if (config2.abortEarly) {
4039
- dataset.typed = false;
4040
- break;
4041
- }
4042
- }
4043
- if (!itemDataset.typed) {
4044
- dataset.typed = false;
4045
- }
4046
- dataset.value.push(itemDataset.value);
4047
- }
4048
- } else {
4049
- _addIssue(this, "type", dataset, config2);
4050
- }
4051
- return dataset;
4052
- }
4053
- };
4136
+ //#endregion
4137
+ //#region src/schemas/array/array.ts
4138
+ /* @__NO_SIDE_EFFECTS__ */
4139
+ function array(item, message$1) {
4140
+ return {
4141
+ kind: "schema",
4142
+ type: "array",
4143
+ reference: array,
4144
+ expects: "Array",
4145
+ async: false,
4146
+ item,
4147
+ message: message$1,
4148
+ get "~standard"() {
4149
+ return /* @__PURE__ */ _getStandardProps(this);
4150
+ },
4151
+ "~run"(dataset, config$1) {
4152
+ const input = dataset.value;
4153
+ if (Array.isArray(input)) {
4154
+ dataset.typed = true;
4155
+ dataset.value = [];
4156
+ for (let key = 0; key < input.length; key++) {
4157
+ const value$1 = input[key];
4158
+ const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
4159
+ if (itemDataset.issues) {
4160
+ const pathItem = {
4161
+ type: "array",
4162
+ origin: "value",
4163
+ input,
4164
+ key,
4165
+ value: value$1
4166
+ };
4167
+ for (const issue of itemDataset.issues) {
4168
+ if (issue.path) issue.path.unshift(pathItem);
4169
+ else issue.path = [pathItem];
4170
+ dataset.issues?.push(issue);
4171
+ }
4172
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
4173
+ if (config$1.abortEarly) {
4174
+ dataset.typed = false;
4175
+ break;
4176
+ }
4177
+ }
4178
+ if (!itemDataset.typed) dataset.typed = false;
4179
+ dataset.value.push(itemDataset.value);
4180
+ }
4181
+ } else _addIssue(this, "type", dataset, config$1);
4182
+ return dataset;
4183
+ }
4184
+ };
4054
4185
  }
4055
4186
 
4056
- // src/schemas/bigint/bigint.ts
4057
- function bigint(message) {
4058
- return {
4059
- kind: "schema",
4060
- type: "bigint",
4061
- reference: bigint,
4062
- expects: "bigint",
4063
- async: false,
4064
- message,
4065
- _run(dataset, config2) {
4066
- if (typeof dataset.value === "bigint") {
4067
- dataset.typed = true;
4068
- } else {
4069
- _addIssue(this, "type", dataset, config2);
4070
- }
4071
- return dataset;
4072
- }
4073
- };
4187
+ //#endregion
4188
+ //#region src/schemas/bigint/bigint.ts
4189
+ /* @__NO_SIDE_EFFECTS__ */
4190
+ function bigint(message$1) {
4191
+ return {
4192
+ kind: "schema",
4193
+ type: "bigint",
4194
+ reference: bigint,
4195
+ expects: "bigint",
4196
+ async: false,
4197
+ message: message$1,
4198
+ get "~standard"() {
4199
+ return /* @__PURE__ */ _getStandardProps(this);
4200
+ },
4201
+ "~run"(dataset, config$1) {
4202
+ if (typeof dataset.value === "bigint") dataset.typed = true;
4203
+ else _addIssue(this, "type", dataset, config$1);
4204
+ return dataset;
4205
+ }
4206
+ };
4074
4207
  }
4075
4208
 
4076
- // src/schemas/boolean/boolean.ts
4077
- function boolean(message) {
4078
- return {
4079
- kind: "schema",
4080
- type: "boolean",
4081
- reference: boolean,
4082
- expects: "boolean",
4083
- async: false,
4084
- message,
4085
- _run(dataset, config2) {
4086
- if (typeof dataset.value === "boolean") {
4087
- dataset.typed = true;
4088
- } else {
4089
- _addIssue(this, "type", dataset, config2);
4090
- }
4091
- return dataset;
4092
- }
4093
- };
4209
+ //#endregion
4210
+ //#region src/schemas/boolean/boolean.ts
4211
+ /* @__NO_SIDE_EFFECTS__ */
4212
+ function boolean(message$1) {
4213
+ return {
4214
+ kind: "schema",
4215
+ type: "boolean",
4216
+ reference: boolean,
4217
+ expects: "boolean",
4218
+ async: false,
4219
+ message: message$1,
4220
+ get "~standard"() {
4221
+ return /* @__PURE__ */ _getStandardProps(this);
4222
+ },
4223
+ "~run"(dataset, config$1) {
4224
+ if (typeof dataset.value === "boolean") dataset.typed = true;
4225
+ else _addIssue(this, "type", dataset, config$1);
4226
+ return dataset;
4227
+ }
4228
+ };
4094
4229
  }
4095
4230
 
4096
- // src/schemas/lazy/lazy.ts
4231
+ //#endregion
4232
+ //#region src/schemas/lazy/lazy.ts
4233
+ /**
4234
+ * Creates a lazy schema.
4235
+ *
4236
+ * @param getter The schema getter.
4237
+ *
4238
+ * @returns A lazy schema.
4239
+ */
4240
+ /* @__NO_SIDE_EFFECTS__ */
4097
4241
  function lazy(getter) {
4098
- return {
4099
- kind: "schema",
4100
- type: "lazy",
4101
- reference: lazy,
4102
- expects: "unknown",
4103
- async: false,
4104
- getter,
4105
- _run(dataset, config2) {
4106
- return this.getter(dataset.value)._run(dataset, config2);
4107
- }
4108
- };
4242
+ return {
4243
+ kind: "schema",
4244
+ type: "lazy",
4245
+ reference: lazy,
4246
+ expects: "unknown",
4247
+ async: false,
4248
+ getter,
4249
+ get "~standard"() {
4250
+ return /* @__PURE__ */ _getStandardProps(this);
4251
+ },
4252
+ "~run"(dataset, config$1) {
4253
+ return this.getter(dataset.value)["~run"](dataset, config$1);
4254
+ }
4255
+ };
4109
4256
  }
4110
4257
 
4111
- // src/schemas/literal/literal.ts
4112
- function literal(literal_, message) {
4113
- return {
4114
- kind: "schema",
4115
- type: "literal",
4116
- reference: literal,
4117
- expects: _stringify(literal_),
4118
- async: false,
4119
- literal: literal_,
4120
- message,
4121
- _run(dataset, config2) {
4122
- if (dataset.value === this.literal) {
4123
- dataset.typed = true;
4124
- } else {
4125
- _addIssue(this, "type", dataset, config2);
4126
- }
4127
- return dataset;
4128
- }
4129
- };
4258
+ //#endregion
4259
+ //#region src/schemas/literal/literal.ts
4260
+ /* @__NO_SIDE_EFFECTS__ */
4261
+ function literal(literal_, message$1) {
4262
+ return {
4263
+ kind: "schema",
4264
+ type: "literal",
4265
+ reference: literal,
4266
+ expects: /* @__PURE__ */ _stringify(literal_),
4267
+ async: false,
4268
+ literal: literal_,
4269
+ message: message$1,
4270
+ get "~standard"() {
4271
+ return /* @__PURE__ */ _getStandardProps(this);
4272
+ },
4273
+ "~run"(dataset, config$1) {
4274
+ if (dataset.value === this.literal) dataset.typed = true;
4275
+ else _addIssue(this, "type", dataset, config$1);
4276
+ return dataset;
4277
+ }
4278
+ };
4130
4279
  }
4131
4280
 
4132
- // src/schemas/nullable/nullable.ts
4133
- function nullable(wrapped, ...args) {
4134
- const schema = {
4135
- kind: "schema",
4136
- type: "nullable",
4137
- reference: nullable,
4138
- expects: `${wrapped.expects} | null`,
4139
- async: false,
4140
- wrapped,
4141
- _run(dataset, config2) {
4142
- if (dataset.value === null) {
4143
- if ("default" in this) {
4144
- dataset.value = getDefault(
4145
- this,
4146
- dataset,
4147
- config2
4148
- );
4149
- }
4150
- if (dataset.value === null) {
4151
- dataset.typed = true;
4152
- return dataset;
4153
- }
4154
- }
4155
- return this.wrapped._run(dataset, config2);
4156
- }
4157
- };
4158
- if (0 in args) {
4159
- schema.default = args[0];
4160
- }
4161
- return schema;
4281
+ //#endregion
4282
+ //#region src/schemas/nullable/nullable.ts
4283
+ /* @__NO_SIDE_EFFECTS__ */
4284
+ function nullable(wrapped, default_) {
4285
+ return {
4286
+ kind: "schema",
4287
+ type: "nullable",
4288
+ reference: nullable,
4289
+ expects: `(${wrapped.expects} | null)`,
4290
+ async: false,
4291
+ wrapped,
4292
+ default: default_,
4293
+ get "~standard"() {
4294
+ return /* @__PURE__ */ _getStandardProps(this);
4295
+ },
4296
+ "~run"(dataset, config$1) {
4297
+ if (dataset.value === null) {
4298
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
4299
+ if (dataset.value === null) {
4300
+ dataset.typed = true;
4301
+ return dataset;
4302
+ }
4303
+ }
4304
+ return this.wrapped["~run"](dataset, config$1);
4305
+ }
4306
+ };
4162
4307
  }
4163
4308
 
4164
- // src/schemas/nullish/nullish.ts
4165
- function nullish(wrapped, ...args) {
4166
- const schema = {
4167
- kind: "schema",
4168
- type: "nullish",
4169
- reference: nullish,
4170
- expects: `${wrapped.expects} | null | undefined`,
4171
- async: false,
4172
- wrapped,
4173
- _run(dataset, config2) {
4174
- if (dataset.value === null || dataset.value === void 0) {
4175
- if ("default" in this) {
4176
- dataset.value = getDefault(
4177
- this,
4178
- dataset,
4179
- config2
4180
- );
4181
- }
4182
- if (dataset.value === null || dataset.value === void 0) {
4183
- dataset.typed = true;
4184
- return dataset;
4185
- }
4186
- }
4187
- return this.wrapped._run(dataset, config2);
4188
- }
4189
- };
4190
- if (0 in args) {
4191
- schema.default = args[0];
4192
- }
4193
- return schema;
4309
+ //#endregion
4310
+ //#region src/schemas/nullish/nullish.ts
4311
+ /* @__NO_SIDE_EFFECTS__ */
4312
+ function nullish(wrapped, default_) {
4313
+ return {
4314
+ kind: "schema",
4315
+ type: "nullish",
4316
+ reference: nullish,
4317
+ expects: `(${wrapped.expects} | null | undefined)`,
4318
+ async: false,
4319
+ wrapped,
4320
+ default: default_,
4321
+ get "~standard"() {
4322
+ return /* @__PURE__ */ _getStandardProps(this);
4323
+ },
4324
+ "~run"(dataset, config$1) {
4325
+ if (dataset.value === null || dataset.value === void 0) {
4326
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
4327
+ if (dataset.value === null || dataset.value === void 0) {
4328
+ dataset.typed = true;
4329
+ return dataset;
4330
+ }
4331
+ }
4332
+ return this.wrapped["~run"](dataset, config$1);
4333
+ }
4334
+ };
4194
4335
  }
4195
4336
 
4196
- // src/schemas/number/number.ts
4197
- function number(message) {
4198
- return {
4199
- kind: "schema",
4200
- type: "number",
4201
- reference: number,
4202
- expects: "number",
4203
- async: false,
4204
- message,
4205
- _run(dataset, config2) {
4206
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
4207
- dataset.typed = true;
4208
- } else {
4209
- _addIssue(this, "type", dataset, config2);
4210
- }
4211
- return dataset;
4212
- }
4213
- };
4337
+ //#endregion
4338
+ //#region src/schemas/number/number.ts
4339
+ /* @__NO_SIDE_EFFECTS__ */
4340
+ function number(message$1) {
4341
+ return {
4342
+ kind: "schema",
4343
+ type: "number",
4344
+ reference: number,
4345
+ expects: "number",
4346
+ async: false,
4347
+ message: message$1,
4348
+ get "~standard"() {
4349
+ return /* @__PURE__ */ _getStandardProps(this);
4350
+ },
4351
+ "~run"(dataset, config$1) {
4352
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
4353
+ else _addIssue(this, "type", dataset, config$1);
4354
+ return dataset;
4355
+ }
4356
+ };
4214
4357
  }
4215
4358
 
4216
- // src/schemas/object/object.ts
4217
- function object(entries, message) {
4218
- return {
4219
- kind: "schema",
4220
- type: "object",
4221
- reference: object,
4222
- expects: "Object",
4223
- async: false,
4224
- entries,
4225
- message,
4226
- _run(dataset, config2) {
4227
- const input = dataset.value;
4228
- if (input && typeof input === "object") {
4229
- dataset.typed = true;
4230
- dataset.value = {};
4231
- for (const key in this.entries) {
4232
- const value2 = input[key];
4233
- const valueDataset = this.entries[key]._run(
4234
- { typed: false, value: value2 },
4235
- config2
4236
- );
4237
- if (valueDataset.issues) {
4238
- const pathItem = {
4239
- type: "object",
4240
- origin: "value",
4241
- input,
4242
- key,
4243
- value: value2
4244
- };
4245
- for (const issue of valueDataset.issues) {
4246
- if (issue.path) {
4247
- issue.path.unshift(pathItem);
4248
- } else {
4249
- issue.path = [pathItem];
4250
- }
4251
- dataset.issues?.push(issue);
4252
- }
4253
- if (!dataset.issues) {
4254
- dataset.issues = valueDataset.issues;
4255
- }
4256
- if (config2.abortEarly) {
4257
- dataset.typed = false;
4258
- break;
4259
- }
4260
- }
4261
- if (!valueDataset.typed) {
4262
- dataset.typed = false;
4263
- }
4264
- if (valueDataset.value !== void 0 || key in input) {
4265
- dataset.value[key] = valueDataset.value;
4266
- }
4267
- }
4268
- } else {
4269
- _addIssue(this, "type", dataset, config2);
4270
- }
4271
- return dataset;
4272
- }
4273
- };
4359
+ //#endregion
4360
+ //#region src/schemas/object/object.ts
4361
+ /* @__NO_SIDE_EFFECTS__ */
4362
+ function object(entries$1, message$1) {
4363
+ return {
4364
+ kind: "schema",
4365
+ type: "object",
4366
+ reference: object,
4367
+ expects: "Object",
4368
+ async: false,
4369
+ entries: entries$1,
4370
+ message: message$1,
4371
+ get "~standard"() {
4372
+ return /* @__PURE__ */ _getStandardProps(this);
4373
+ },
4374
+ "~run"(dataset, config$1) {
4375
+ const input = dataset.value;
4376
+ if (input && typeof input === "object") {
4377
+ dataset.typed = true;
4378
+ dataset.value = {};
4379
+ for (const key in this.entries) {
4380
+ const valueSchema = this.entries[key];
4381
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
4382
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
4383
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
4384
+ if (valueDataset.issues) {
4385
+ const pathItem = {
4386
+ type: "object",
4387
+ origin: "value",
4388
+ input,
4389
+ key,
4390
+ value: value$1
4391
+ };
4392
+ for (const issue of valueDataset.issues) {
4393
+ if (issue.path) issue.path.unshift(pathItem);
4394
+ else issue.path = [pathItem];
4395
+ dataset.issues?.push(issue);
4396
+ }
4397
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
4398
+ if (config$1.abortEarly) {
4399
+ dataset.typed = false;
4400
+ break;
4401
+ }
4402
+ }
4403
+ if (!valueDataset.typed) dataset.typed = false;
4404
+ dataset.value[key] = valueDataset.value;
4405
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
4406
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
4407
+ _addIssue(this, "key", dataset, config$1, {
4408
+ input: void 0,
4409
+ expected: `"${key}"`,
4410
+ path: [{
4411
+ type: "object",
4412
+ origin: "key",
4413
+ input,
4414
+ key,
4415
+ value: input[key]
4416
+ }]
4417
+ });
4418
+ if (config$1.abortEarly) break;
4419
+ }
4420
+ }
4421
+ } else _addIssue(this, "type", dataset, config$1);
4422
+ return dataset;
4423
+ }
4424
+ };
4274
4425
  }
4275
4426
 
4276
- // src/schemas/optional/optional.ts
4277
- function optional(wrapped, ...args) {
4278
- const schema = {
4279
- kind: "schema",
4280
- type: "optional",
4281
- reference: optional,
4282
- expects: `${wrapped.expects} | undefined`,
4283
- async: false,
4284
- wrapped,
4285
- _run(dataset, config2) {
4286
- if (dataset.value === void 0) {
4287
- if ("default" in this) {
4288
- dataset.value = getDefault(
4289
- this,
4290
- dataset,
4291
- config2
4292
- );
4293
- }
4294
- if (dataset.value === void 0) {
4295
- dataset.typed = true;
4296
- return dataset;
4297
- }
4298
- }
4299
- return this.wrapped._run(dataset, config2);
4300
- }
4301
- };
4302
- if (0 in args) {
4303
- schema.default = args[0];
4304
- }
4305
- return schema;
4427
+ //#endregion
4428
+ //#region src/schemas/optional/optional.ts
4429
+ /* @__NO_SIDE_EFFECTS__ */
4430
+ function optional(wrapped, default_) {
4431
+ return {
4432
+ kind: "schema",
4433
+ type: "optional",
4434
+ reference: optional,
4435
+ expects: `(${wrapped.expects} | undefined)`,
4436
+ async: false,
4437
+ wrapped,
4438
+ default: default_,
4439
+ get "~standard"() {
4440
+ return /* @__PURE__ */ _getStandardProps(this);
4441
+ },
4442
+ "~run"(dataset, config$1) {
4443
+ if (dataset.value === void 0) {
4444
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
4445
+ if (dataset.value === void 0) {
4446
+ dataset.typed = true;
4447
+ return dataset;
4448
+ }
4449
+ }
4450
+ return this.wrapped["~run"](dataset, config$1);
4451
+ }
4452
+ };
4306
4453
  }
4307
4454
 
4308
- // src/schemas/record/record.ts
4309
- function record(key, value2, message) {
4310
- return {
4311
- kind: "schema",
4312
- type: "record",
4313
- reference: record,
4314
- expects: "Object",
4315
- async: false,
4316
- key,
4317
- value: value2,
4318
- message,
4319
- _run(dataset, config2) {
4320
- const input = dataset.value;
4321
- if (input && typeof input === "object") {
4322
- dataset.typed = true;
4323
- dataset.value = {};
4324
- for (const entryKey in input) {
4325
- if (_isValidObjectKey(input, entryKey)) {
4326
- const entryValue = input[entryKey];
4327
- const keyDataset = this.key._run(
4328
- { typed: false, value: entryKey },
4329
- config2
4330
- );
4331
- if (keyDataset.issues) {
4332
- const pathItem = {
4333
- type: "object",
4334
- origin: "key",
4335
- input,
4336
- key: entryKey,
4337
- value: entryValue
4338
- };
4339
- for (const issue of keyDataset.issues) {
4340
- issue.path = [pathItem];
4341
- dataset.issues?.push(issue);
4342
- }
4343
- if (!dataset.issues) {
4344
- dataset.issues = keyDataset.issues;
4345
- }
4346
- if (config2.abortEarly) {
4347
- dataset.typed = false;
4348
- break;
4349
- }
4350
- }
4351
- const valueDataset = this.value._run(
4352
- { typed: false, value: entryValue },
4353
- config2
4354
- );
4355
- if (valueDataset.issues) {
4356
- const pathItem = {
4357
- type: "object",
4358
- origin: "value",
4359
- input,
4360
- key: entryKey,
4361
- value: entryValue
4362
- };
4363
- for (const issue of valueDataset.issues) {
4364
- if (issue.path) {
4365
- issue.path.unshift(pathItem);
4366
- } else {
4367
- issue.path = [pathItem];
4368
- }
4369
- dataset.issues?.push(issue);
4370
- }
4371
- if (!dataset.issues) {
4372
- dataset.issues = valueDataset.issues;
4373
- }
4374
- if (config2.abortEarly) {
4375
- dataset.typed = false;
4376
- break;
4377
- }
4378
- }
4379
- if (!keyDataset.typed || !valueDataset.typed) {
4380
- dataset.typed = false;
4381
- }
4382
- if (keyDataset.typed) {
4383
- dataset.value[keyDataset.value] = valueDataset.value;
4384
- }
4385
- }
4386
- }
4387
- } else {
4388
- _addIssue(this, "type", dataset, config2);
4389
- }
4390
- return dataset;
4391
- }
4392
- };
4455
+ //#endregion
4456
+ //#region src/schemas/record/record.ts
4457
+ /* @__NO_SIDE_EFFECTS__ */
4458
+ function record(key, value$1, message$1) {
4459
+ return {
4460
+ kind: "schema",
4461
+ type: "record",
4462
+ reference: record,
4463
+ expects: "Object",
4464
+ async: false,
4465
+ key,
4466
+ value: value$1,
4467
+ message: message$1,
4468
+ get "~standard"() {
4469
+ return /* @__PURE__ */ _getStandardProps(this);
4470
+ },
4471
+ "~run"(dataset, config$1) {
4472
+ const input = dataset.value;
4473
+ if (input && typeof input === "object") {
4474
+ dataset.typed = true;
4475
+ dataset.value = {};
4476
+ for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
4477
+ const entryValue = input[entryKey];
4478
+ const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
4479
+ if (keyDataset.issues) {
4480
+ const pathItem = {
4481
+ type: "object",
4482
+ origin: "key",
4483
+ input,
4484
+ key: entryKey,
4485
+ value: entryValue
4486
+ };
4487
+ for (const issue of keyDataset.issues) {
4488
+ issue.path = [pathItem];
4489
+ dataset.issues?.push(issue);
4490
+ }
4491
+ if (!dataset.issues) dataset.issues = keyDataset.issues;
4492
+ if (config$1.abortEarly) {
4493
+ dataset.typed = false;
4494
+ break;
4495
+ }
4496
+ }
4497
+ const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
4498
+ if (valueDataset.issues) {
4499
+ const pathItem = {
4500
+ type: "object",
4501
+ origin: "value",
4502
+ input,
4503
+ key: entryKey,
4504
+ value: entryValue
4505
+ };
4506
+ for (const issue of valueDataset.issues) {
4507
+ if (issue.path) issue.path.unshift(pathItem);
4508
+ else issue.path = [pathItem];
4509
+ dataset.issues?.push(issue);
4510
+ }
4511
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
4512
+ if (config$1.abortEarly) {
4513
+ dataset.typed = false;
4514
+ break;
4515
+ }
4516
+ }
4517
+ if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
4518
+ if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
4519
+ }
4520
+ } else _addIssue(this, "type", dataset, config$1);
4521
+ return dataset;
4522
+ }
4523
+ };
4393
4524
  }
4394
4525
 
4395
- // src/schemas/string/string.ts
4396
- function string(message) {
4397
- return {
4398
- kind: "schema",
4399
- type: "string",
4400
- reference: string,
4401
- expects: "string",
4402
- async: false,
4403
- message,
4404
- _run(dataset, config2) {
4405
- if (typeof dataset.value === "string") {
4406
- dataset.typed = true;
4407
- } else {
4408
- _addIssue(this, "type", dataset, config2);
4409
- }
4410
- return dataset;
4411
- }
4412
- };
4526
+ //#endregion
4527
+ //#region src/schemas/string/string.ts
4528
+ /* @__NO_SIDE_EFFECTS__ */
4529
+ function string(message$1) {
4530
+ return {
4531
+ kind: "schema",
4532
+ type: "string",
4533
+ reference: string,
4534
+ expects: "string",
4535
+ async: false,
4536
+ message: message$1,
4537
+ get "~standard"() {
4538
+ return /* @__PURE__ */ _getStandardProps(this);
4539
+ },
4540
+ "~run"(dataset, config$1) {
4541
+ if (typeof dataset.value === "string") dataset.typed = true;
4542
+ else _addIssue(this, "type", dataset, config$1);
4543
+ return dataset;
4544
+ }
4545
+ };
4413
4546
  }
4414
4547
 
4415
- // src/schemas/tuple/tuple.ts
4416
- function tuple(items, message) {
4417
- return {
4418
- kind: "schema",
4419
- type: "tuple",
4420
- reference: tuple,
4421
- expects: "Array",
4422
- async: false,
4423
- items,
4424
- message,
4425
- _run(dataset, config2) {
4426
- const input = dataset.value;
4427
- if (Array.isArray(input)) {
4428
- dataset.typed = true;
4429
- dataset.value = [];
4430
- for (let key = 0; key < this.items.length; key++) {
4431
- const value2 = input[key];
4432
- const itemDataset = this.items[key]._run(
4433
- { typed: false, value: value2 },
4434
- config2
4435
- );
4436
- if (itemDataset.issues) {
4437
- const pathItem = {
4438
- type: "array",
4439
- origin: "value",
4440
- input,
4441
- key,
4442
- value: value2
4443
- };
4444
- for (const issue of itemDataset.issues) {
4445
- if (issue.path) {
4446
- issue.path.unshift(pathItem);
4447
- } else {
4448
- issue.path = [pathItem];
4449
- }
4450
- dataset.issues?.push(issue);
4451
- }
4452
- if (!dataset.issues) {
4453
- dataset.issues = itemDataset.issues;
4454
- }
4455
- if (config2.abortEarly) {
4456
- dataset.typed = false;
4457
- break;
4458
- }
4459
- }
4460
- if (!itemDataset.typed) {
4461
- dataset.typed = false;
4462
- }
4463
- dataset.value.push(itemDataset.value);
4464
- }
4465
- } else {
4466
- _addIssue(this, "type", dataset, config2);
4467
- }
4468
- return dataset;
4469
- }
4470
- };
4548
+ //#endregion
4549
+ //#region src/schemas/tuple/tuple.ts
4550
+ /* @__NO_SIDE_EFFECTS__ */
4551
+ function tuple(items, message$1) {
4552
+ return {
4553
+ kind: "schema",
4554
+ type: "tuple",
4555
+ reference: tuple,
4556
+ expects: "Array",
4557
+ async: false,
4558
+ items,
4559
+ message: message$1,
4560
+ get "~standard"() {
4561
+ return /* @__PURE__ */ _getStandardProps(this);
4562
+ },
4563
+ "~run"(dataset, config$1) {
4564
+ const input = dataset.value;
4565
+ if (Array.isArray(input)) {
4566
+ dataset.typed = true;
4567
+ dataset.value = [];
4568
+ for (let key = 0; key < this.items.length; key++) {
4569
+ const value$1 = input[key];
4570
+ const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
4571
+ if (itemDataset.issues) {
4572
+ const pathItem = {
4573
+ type: "array",
4574
+ origin: "value",
4575
+ input,
4576
+ key,
4577
+ value: value$1
4578
+ };
4579
+ for (const issue of itemDataset.issues) {
4580
+ if (issue.path) issue.path.unshift(pathItem);
4581
+ else issue.path = [pathItem];
4582
+ dataset.issues?.push(issue);
4583
+ }
4584
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
4585
+ if (config$1.abortEarly) {
4586
+ dataset.typed = false;
4587
+ break;
4588
+ }
4589
+ }
4590
+ if (!itemDataset.typed) dataset.typed = false;
4591
+ dataset.value.push(itemDataset.value);
4592
+ }
4593
+ } else _addIssue(this, "type", dataset, config$1);
4594
+ return dataset;
4595
+ }
4596
+ };
4471
4597
  }
4472
4598
 
4473
- // src/schemas/union/utils/_subIssues/_subIssues.ts
4599
+ //#endregion
4600
+ //#region src/schemas/union/utils/_subIssues/_subIssues.ts
4601
+ /**
4602
+ * Returns the sub issues of the provided datasets for the union issue.
4603
+ *
4604
+ * @param datasets The datasets.
4605
+ *
4606
+ * @returns The sub issues.
4607
+ *
4608
+ * @internal
4609
+ */
4610
+ /* @__NO_SIDE_EFFECTS__ */
4474
4611
  function _subIssues(datasets) {
4475
- let issues;
4476
- if (datasets) {
4477
- for (const dataset of datasets) {
4478
- if (issues) {
4479
- issues.push(...dataset.issues);
4480
- } else {
4481
- issues = dataset.issues;
4482
- }
4483
- }
4484
- }
4485
- return issues;
4612
+ let issues;
4613
+ if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
4614
+ else issues = dataset.issues;
4615
+ return issues;
4486
4616
  }
4487
4617
 
4488
- // src/schemas/union/union.ts
4489
- function union(options, message) {
4490
- return {
4491
- kind: "schema",
4492
- type: "union",
4493
- reference: union,
4494
- expects: [...new Set(options.map((option) => option.expects))].join(" | ") || "never",
4495
- async: false,
4496
- options,
4497
- message,
4498
- _run(dataset, config2) {
4499
- let validDataset;
4500
- let typedDatasets;
4501
- let untypedDatasets;
4502
- for (const schema of this.options) {
4503
- const optionDataset = schema._run(
4504
- { typed: false, value: dataset.value },
4505
- config2
4506
- );
4507
- if (optionDataset.typed) {
4508
- if (optionDataset.issues) {
4509
- if (typedDatasets) {
4510
- typedDatasets.push(optionDataset);
4511
- } else {
4512
- typedDatasets = [optionDataset];
4513
- }
4514
- } else {
4515
- validDataset = optionDataset;
4516
- break;
4517
- }
4518
- } else {
4519
- if (untypedDatasets) {
4520
- untypedDatasets.push(optionDataset);
4521
- } else {
4522
- untypedDatasets = [optionDataset];
4523
- }
4524
- }
4525
- }
4526
- if (validDataset) {
4527
- return validDataset;
4528
- }
4529
- if (typedDatasets) {
4530
- if (typedDatasets.length === 1) {
4531
- return typedDatasets[0];
4532
- }
4533
- _addIssue(this, "type", dataset, config2, {
4534
- issues: _subIssues(typedDatasets)
4535
- });
4536
- dataset.typed = true;
4537
- } else if (untypedDatasets?.length === 1) {
4538
- return untypedDatasets[0];
4539
- } else {
4540
- _addIssue(this, "type", dataset, config2, {
4541
- issues: _subIssues(untypedDatasets)
4542
- });
4543
- }
4544
- return dataset;
4545
- }
4546
- };
4618
+ //#endregion
4619
+ //#region src/schemas/union/union.ts
4620
+ /* @__NO_SIDE_EFFECTS__ */
4621
+ function union(options, message$1) {
4622
+ return {
4623
+ kind: "schema",
4624
+ type: "union",
4625
+ reference: union,
4626
+ expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
4627
+ async: false,
4628
+ options,
4629
+ message: message$1,
4630
+ get "~standard"() {
4631
+ return /* @__PURE__ */ _getStandardProps(this);
4632
+ },
4633
+ "~run"(dataset, config$1) {
4634
+ let validDataset;
4635
+ let typedDatasets;
4636
+ let untypedDatasets;
4637
+ for (const schema of this.options) {
4638
+ const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
4639
+ if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
4640
+ else typedDatasets = [optionDataset];
4641
+ else {
4642
+ validDataset = optionDataset;
4643
+ break;
4644
+ }
4645
+ else if (untypedDatasets) untypedDatasets.push(optionDataset);
4646
+ else untypedDatasets = [optionDataset];
4647
+ }
4648
+ if (validDataset) return validDataset;
4649
+ if (typedDatasets) {
4650
+ if (typedDatasets.length === 1) return typedDatasets[0];
4651
+ _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
4652
+ dataset.typed = true;
4653
+ } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
4654
+ else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
4655
+ return dataset;
4656
+ }
4657
+ };
4547
4658
  }
4548
4659
 
4549
- // src/schemas/unknown/unknown.ts
4660
+ //#endregion
4661
+ //#region src/schemas/unknown/unknown.ts
4662
+ /**
4663
+ * Creates a unknown schema.
4664
+ *
4665
+ * @returns A unknown schema.
4666
+ */
4667
+ /* @__NO_SIDE_EFFECTS__ */
4550
4668
  function unknown() {
4551
- return {
4552
- kind: "schema",
4553
- type: "unknown",
4554
- reference: unknown,
4555
- expects: "unknown",
4556
- async: false,
4557
- _run(dataset) {
4558
- dataset.typed = true;
4559
- return dataset;
4560
- }
4561
- };
4669
+ return {
4670
+ kind: "schema",
4671
+ type: "unknown",
4672
+ reference: unknown,
4673
+ expects: "unknown",
4674
+ async: false,
4675
+ get "~standard"() {
4676
+ return /* @__PURE__ */ _getStandardProps(this);
4677
+ },
4678
+ "~run"(dataset) {
4679
+ dataset.typed = true;
4680
+ return dataset;
4681
+ }
4682
+ };
4562
4683
  }
4563
4684
 
4564
- // src/methods/parse/parse.ts
4565
- function parse(schema, input, config2) {
4566
- const dataset = schema._run(
4567
- { typed: false, value: input },
4568
- getGlobalConfig(config2)
4569
- );
4570
- if (dataset.issues) {
4571
- throw new ValiError(dataset.issues);
4572
- }
4573
- return dataset.value;
4685
+ //#endregion
4686
+ //#region src/methods/parse/parse.ts
4687
+ /**
4688
+ * Parses an unknown input based on a schema.
4689
+ *
4690
+ * @param schema The schema to be used.
4691
+ * @param input The input to be parsed.
4692
+ * @param config The parse configuration.
4693
+ *
4694
+ * @returns The parsed input.
4695
+ */
4696
+ function parse(schema, input, config$1) {
4697
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
4698
+ if (dataset.issues) throw new ValiError(dataset.issues);
4699
+ return dataset.value;
4574
4700
  }
4575
4701
 
4576
- // src/methods/pipe/pipe.ts
4577
- function pipe(...pipe2) {
4578
- return {
4579
- ...pipe2[0],
4580
- pipe: pipe2,
4581
- _run(dataset, config2) {
4582
- for (let index = 0; index < pipe2.length; index++) {
4583
- if (dataset.issues && (pipe2[index].kind === "schema" || pipe2[index].kind === "transformation")) {
4584
- dataset.typed = false;
4585
- break;
4586
- }
4587
- if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
4588
- dataset = pipe2[index]._run(dataset, config2);
4589
- }
4590
- }
4591
- return dataset;
4592
- }
4593
- };
4702
+ //#endregion
4703
+ //#region src/methods/pipe/pipe.ts
4704
+ /* @__NO_SIDE_EFFECTS__ */
4705
+ function pipe(...pipe$1) {
4706
+ return {
4707
+ ...pipe$1[0],
4708
+ pipe: pipe$1,
4709
+ get "~standard"() {
4710
+ return /* @__PURE__ */ _getStandardProps(this);
4711
+ },
4712
+ "~run"(dataset, config$1) {
4713
+ for (const item of pipe$1) if (item.kind !== "metadata") {
4714
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
4715
+ dataset.typed = false;
4716
+ break;
4717
+ }
4718
+ if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
4719
+ }
4720
+ return dataset;
4721
+ }
4722
+ };
4594
4723
  }
4595
4724
 
4596
4725
  function safeEnum(options) {
4597
4726
  const unionOptions = Object.entries(options).map(([key, value]) => object({ [key]: value }));
4598
4727
  return pipe(
4599
4728
  union(unionOptions),
4600
- transform((value) => ({
4601
- ...value,
4602
- $kind: Object.keys(value)[0]
4603
- }))
4729
+ transform(
4730
+ (value) => ({
4731
+ ...value,
4732
+ $kind: Object.keys(value)[0]
4733
+ })
4734
+ )
4604
4735
  );
4605
4736
  }
4606
4737
  const SuiAddress = pipe(
@@ -4746,14 +4877,14 @@ const NormalizedCallArg$1 = safeEnum({
4746
4877
  bytes: BCSBytes
4747
4878
  })
4748
4879
  });
4749
- const TransactionExpiration$2 = safeEnum({
4880
+ const TransactionExpiration$1 = safeEnum({
4750
4881
  None: literal(true),
4751
4882
  Epoch: JsonU64
4752
4883
  });
4753
4884
  const TransactionDataSchema = object({
4754
4885
  version: literal(2),
4755
4886
  sender: nullish(SuiAddress),
4756
- expiration: nullish(TransactionExpiration$2),
4887
+ expiration: nullish(TransactionExpiration$1),
4757
4888
  gasData: GasDataSchema,
4758
4889
  inputs: array(CallArgSchema),
4759
4890
  commands: array(CommandSchema)
@@ -4883,131 +5014,6 @@ const NormalizedCallArg = safeEnum({
4883
5014
  Object: ObjectArg$1,
4884
5015
  Pure: array(pipe(number(), integer()))
4885
5016
  });
4886
- const TransactionInput = union([
4887
- object({
4888
- kind: literal("Input"),
4889
- index: pipe(number(), integer()),
4890
- value: unknown(),
4891
- type: optional(literal("object"))
4892
- }),
4893
- object({
4894
- kind: literal("Input"),
4895
- index: pipe(number(), integer()),
4896
- value: unknown(),
4897
- type: literal("pure")
4898
- })
4899
- ]);
4900
- const TransactionExpiration$1 = union([
4901
- object({ Epoch: pipe(number(), integer()) }),
4902
- object({ None: nullable(literal(true)) })
4903
- ]);
4904
- const StringEncodedBigint = pipe(
4905
- union([number(), string(), bigint()]),
4906
- check((val) => {
4907
- if (!["string", "number", "bigint"].includes(typeof val)) return false;
4908
- try {
4909
- BigInt(val);
4910
- return true;
4911
- } catch {
4912
- return false;
4913
- }
4914
- })
4915
- );
4916
- const TypeTag = union([
4917
- object({ bool: nullable(literal(true)) }),
4918
- object({ u8: nullable(literal(true)) }),
4919
- object({ u64: nullable(literal(true)) }),
4920
- object({ u128: nullable(literal(true)) }),
4921
- object({ address: nullable(literal(true)) }),
4922
- object({ signer: nullable(literal(true)) }),
4923
- object({ vector: lazy(() => TypeTag) }),
4924
- object({ struct: lazy(() => StructTag) }),
4925
- object({ u16: nullable(literal(true)) }),
4926
- object({ u32: nullable(literal(true)) }),
4927
- object({ u256: nullable(literal(true)) })
4928
- ]);
4929
- const StructTag = object({
4930
- address: string(),
4931
- module: string(),
4932
- name: string(),
4933
- typeParams: array(TypeTag)
4934
- });
4935
- const GasConfig = object({
4936
- budget: optional(StringEncodedBigint),
4937
- price: optional(StringEncodedBigint),
4938
- payment: optional(array(ObjectRef)),
4939
- owner: optional(string())
4940
- });
4941
- const TransactionArgumentTypes = [
4942
- TransactionInput,
4943
- object({ kind: literal("GasCoin") }),
4944
- object({ kind: literal("Result"), index: pipe(number(), integer()) }),
4945
- object({
4946
- kind: literal("NestedResult"),
4947
- index: pipe(number(), integer()),
4948
- resultIndex: pipe(number(), integer())
4949
- })
4950
- ];
4951
- const TransactionArgument = union([...TransactionArgumentTypes]);
4952
- const MoveCallTransaction = object({
4953
- kind: literal("MoveCall"),
4954
- target: pipe(
4955
- string(),
4956
- check((target) => target.split("::").length === 3)
4957
- ),
4958
- typeArguments: array(string()),
4959
- arguments: array(TransactionArgument)
4960
- });
4961
- const TransferObjectsTransaction = object({
4962
- kind: literal("TransferObjects"),
4963
- objects: array(TransactionArgument),
4964
- address: TransactionArgument
4965
- });
4966
- const SplitCoinsTransaction = object({
4967
- kind: literal("SplitCoins"),
4968
- coin: TransactionArgument,
4969
- amounts: array(TransactionArgument)
4970
- });
4971
- const MergeCoinsTransaction = object({
4972
- kind: literal("MergeCoins"),
4973
- destination: TransactionArgument,
4974
- sources: array(TransactionArgument)
4975
- });
4976
- const MakeMoveVecTransaction = object({
4977
- kind: literal("MakeMoveVec"),
4978
- type: union([object({ Some: TypeTag }), object({ None: nullable(literal(true)) })]),
4979
- objects: array(TransactionArgument)
4980
- });
4981
- const PublishTransaction = object({
4982
- kind: literal("Publish"),
4983
- modules: array(array(pipe(number(), integer()))),
4984
- dependencies: array(string())
4985
- });
4986
- const UpgradeTransaction = object({
4987
- kind: literal("Upgrade"),
4988
- modules: array(array(pipe(number(), integer()))),
4989
- dependencies: array(string()),
4990
- packageId: string(),
4991
- ticket: TransactionArgument
4992
- });
4993
- const TransactionTypes = [
4994
- MoveCallTransaction,
4995
- TransferObjectsTransaction,
4996
- SplitCoinsTransaction,
4997
- MergeCoinsTransaction,
4998
- PublishTransaction,
4999
- UpgradeTransaction,
5000
- MakeMoveVecTransaction
5001
- ];
5002
- const TransactionType = union([...TransactionTypes]);
5003
- object({
5004
- version: literal(1),
5005
- sender: optional(string()),
5006
- expiration: nullish(TransactionExpiration$1),
5007
- gasConfig: GasConfig,
5008
- inputs: array(TransactionInput),
5009
- transactions: array(TransactionType)
5010
- });
5011
5017
  function serializeV1TransactionData(transactionData) {
5012
5018
  const inputs = transactionData.inputs.map(
5013
5019
  (input, index) => {
@@ -6038,6 +6044,85 @@ function hashTypedData(typeTag, data) {
6038
6044
  return blake2b$1(dataWithTag, { dkLen: 32 });
6039
6045
  }
6040
6046
 
6047
+ function getIdFromCallArg(arg) {
6048
+ if (typeof arg === "string") {
6049
+ return normalizeSuiAddress(arg);
6050
+ }
6051
+ if (arg.Object) {
6052
+ if (arg.Object.ImmOrOwnedObject) {
6053
+ return normalizeSuiAddress(arg.Object.ImmOrOwnedObject.objectId);
6054
+ }
6055
+ if (arg.Object.Receiving) {
6056
+ return normalizeSuiAddress(arg.Object.Receiving.objectId);
6057
+ }
6058
+ return normalizeSuiAddress(arg.Object.SharedObject.objectId);
6059
+ }
6060
+ if (arg.UnresolvedObject) {
6061
+ return normalizeSuiAddress(arg.UnresolvedObject.objectId);
6062
+ }
6063
+ return void 0;
6064
+ }
6065
+ function remapCommandArguments(command, inputMapping, commandMapping) {
6066
+ const remapArg = (arg) => {
6067
+ switch (arg.$kind) {
6068
+ case "Input": {
6069
+ const newInputIndex = inputMapping.get(arg.Input);
6070
+ if (newInputIndex === void 0) {
6071
+ throw new Error(`Input ${arg.Input} not found in input mapping`);
6072
+ }
6073
+ return { ...arg, Input: newInputIndex };
6074
+ }
6075
+ case "Result": {
6076
+ const newCommandIndex = commandMapping.get(arg.Result);
6077
+ if (newCommandIndex !== void 0) {
6078
+ return { ...arg, Result: newCommandIndex };
6079
+ }
6080
+ return arg;
6081
+ }
6082
+ case "NestedResult": {
6083
+ const newCommandIndex = commandMapping.get(arg.NestedResult[0]);
6084
+ if (newCommandIndex !== void 0) {
6085
+ return { ...arg, NestedResult: [newCommandIndex, arg.NestedResult[1]] };
6086
+ }
6087
+ return arg;
6088
+ }
6089
+ default:
6090
+ return arg;
6091
+ }
6092
+ };
6093
+ switch (command.$kind) {
6094
+ case "MoveCall":
6095
+ command.MoveCall.arguments = command.MoveCall.arguments.map(remapArg);
6096
+ break;
6097
+ case "TransferObjects":
6098
+ command.TransferObjects.objects = command.TransferObjects.objects.map(remapArg);
6099
+ command.TransferObjects.address = remapArg(command.TransferObjects.address);
6100
+ break;
6101
+ case "SplitCoins":
6102
+ command.SplitCoins.coin = remapArg(command.SplitCoins.coin);
6103
+ command.SplitCoins.amounts = command.SplitCoins.amounts.map(remapArg);
6104
+ break;
6105
+ case "MergeCoins":
6106
+ command.MergeCoins.destination = remapArg(command.MergeCoins.destination);
6107
+ command.MergeCoins.sources = command.MergeCoins.sources.map(remapArg);
6108
+ break;
6109
+ case "MakeMoveVec":
6110
+ command.MakeMoveVec.elements = command.MakeMoveVec.elements.map(remapArg);
6111
+ break;
6112
+ case "Upgrade":
6113
+ command.Upgrade.ticket = remapArg(command.Upgrade.ticket);
6114
+ break;
6115
+ case "$Intent": {
6116
+ const inputs = command.$Intent.inputs;
6117
+ command.$Intent.inputs = {};
6118
+ for (const [key, value] of Object.entries(inputs)) {
6119
+ command.$Intent.inputs[key] = Array.isArray(value) ? value.map(remapArg) : remapArg(value);
6120
+ }
6121
+ break;
6122
+ }
6123
+ }
6124
+ }
6125
+
6041
6126
  function prepareSuiAddress(address) {
6042
6127
  return normalizeSuiAddress(address).replace("0x", "");
6043
6128
  }
@@ -6239,26 +6324,107 @@ class TransactionDataBuilder {
6239
6324
  return;
6240
6325
  }
6241
6326
  const sizeDiff = replacement.length - 1;
6242
- this.commands.splice(index, 1, ...replacement);
6243
- if (sizeDiff !== 0) {
6327
+ this.commands.splice(index, 1, ...structuredClone(replacement));
6328
+ this.mapArguments((arg, _command, commandIndex) => {
6329
+ if (commandIndex < index + replacement.length) {
6330
+ return arg;
6331
+ }
6332
+ if (typeof resultIndex !== "number") {
6333
+ if (arg.$kind === "Result" && arg.Result === index || arg.$kind === "NestedResult" && arg.NestedResult[0] === index) {
6334
+ if (!("NestedResult" in arg) || arg.NestedResult[1] === 0) {
6335
+ return parse(ArgumentSchema, structuredClone(resultIndex));
6336
+ } else {
6337
+ throw new Error(
6338
+ `Cannot replace command ${index} with a specific result type: NestedResult[${index}, ${arg.NestedResult[1]}] references a nested element that cannot be mapped to the replacement result`
6339
+ );
6340
+ }
6341
+ }
6342
+ }
6343
+ switch (arg.$kind) {
6344
+ case "Result":
6345
+ if (arg.Result === index && typeof resultIndex === "number") {
6346
+ arg.Result = resultIndex;
6347
+ }
6348
+ if (arg.Result > index) {
6349
+ arg.Result += sizeDiff;
6350
+ }
6351
+ break;
6352
+ case "NestedResult":
6353
+ if (arg.NestedResult[0] === index && typeof resultIndex === "number") {
6354
+ return {
6355
+ $kind: "NestedResult",
6356
+ NestedResult: [resultIndex, arg.NestedResult[1]]
6357
+ };
6358
+ }
6359
+ if (arg.NestedResult[0] > index) {
6360
+ arg.NestedResult[0] += sizeDiff;
6361
+ }
6362
+ break;
6363
+ }
6364
+ return arg;
6365
+ });
6366
+ }
6367
+ replaceCommandWithTransaction(index, otherTransaction, result) {
6368
+ if (result.$kind !== "Result" && result.$kind !== "NestedResult") {
6369
+ throw new Error("Result must be of kind Result or NestedResult");
6370
+ }
6371
+ this.insertTransaction(index, otherTransaction);
6372
+ this.replaceCommand(
6373
+ index + otherTransaction.commands.length,
6374
+ [],
6375
+ "Result" in result ? { NestedResult: [result.Result + index, 0] } : {
6376
+ NestedResult: [
6377
+ result.NestedResult[0] + index,
6378
+ result.NestedResult[1]
6379
+ ]
6380
+ }
6381
+ );
6382
+ }
6383
+ insertTransaction(atCommandIndex, otherTransaction) {
6384
+ const inputMapping = /* @__PURE__ */ new Map();
6385
+ const commandMapping = /* @__PURE__ */ new Map();
6386
+ for (let i = 0; i < otherTransaction.inputs.length; i++) {
6387
+ const otherInput = otherTransaction.inputs[i];
6388
+ const id = getIdFromCallArg(otherInput);
6389
+ let existingIndex = -1;
6390
+ if (id !== void 0) {
6391
+ existingIndex = this.inputs.findIndex((input) => getIdFromCallArg(input) === id);
6392
+ if (existingIndex !== -1 && this.inputs[existingIndex].Object?.SharedObject && otherInput.Object?.SharedObject) {
6393
+ this.inputs[existingIndex].Object.SharedObject.mutable = this.inputs[existingIndex].Object.SharedObject.mutable || otherInput.Object.SharedObject.mutable;
6394
+ }
6395
+ }
6396
+ if (existingIndex !== -1) {
6397
+ inputMapping.set(i, existingIndex);
6398
+ } else {
6399
+ const newIndex = this.inputs.length;
6400
+ this.inputs.push(otherInput);
6401
+ inputMapping.set(i, newIndex);
6402
+ }
6403
+ }
6404
+ for (let i = 0; i < otherTransaction.commands.length; i++) {
6405
+ commandMapping.set(i, atCommandIndex + i);
6406
+ }
6407
+ const remappedCommands = [];
6408
+ for (let i = 0; i < otherTransaction.commands.length; i++) {
6409
+ const command = structuredClone(otherTransaction.commands[i]);
6410
+ remapCommandArguments(command, inputMapping, commandMapping);
6411
+ remappedCommands.push(command);
6412
+ }
6413
+ this.commands.splice(atCommandIndex, 0, ...remappedCommands);
6414
+ const sizeDiff = remappedCommands.length;
6415
+ if (sizeDiff > 0) {
6244
6416
  this.mapArguments((arg, _command, commandIndex) => {
6245
- if (commandIndex < index + replacement.length) {
6417
+ if (commandIndex >= atCommandIndex && commandIndex < atCommandIndex + remappedCommands.length) {
6246
6418
  return arg;
6247
6419
  }
6248
6420
  switch (arg.$kind) {
6249
6421
  case "Result":
6250
- if (arg.Result === index) {
6251
- arg.Result = resultIndex;
6252
- }
6253
- if (arg.Result > index) {
6422
+ if (arg.Result >= atCommandIndex) {
6254
6423
  arg.Result += sizeDiff;
6255
6424
  }
6256
6425
  break;
6257
6426
  case "NestedResult":
6258
- if (arg.NestedResult[0] === index) {
6259
- arg.NestedResult[0] = resultIndex;
6260
- }
6261
- if (arg.NestedResult[0] > index) {
6427
+ if (arg.NestedResult[0] >= atCommandIndex) {
6262
6428
  arg.NestedResult[0] += sizeDiff;
6263
6429
  }
6264
6430
  break;
@@ -6359,25 +6525,6 @@ class TransactionDataBuilder {
6359
6525
  }
6360
6526
  }
6361
6527
 
6362
- function getIdFromCallArg(arg) {
6363
- if (typeof arg === "string") {
6364
- return normalizeSuiAddress(arg);
6365
- }
6366
- if (arg.Object) {
6367
- if (arg.Object.ImmOrOwnedObject) {
6368
- return normalizeSuiAddress(arg.Object.ImmOrOwnedObject.objectId);
6369
- }
6370
- if (arg.Object.Receiving) {
6371
- return normalizeSuiAddress(arg.Object.Receiving.objectId);
6372
- }
6373
- return normalizeSuiAddress(arg.Object.SharedObject.objectId);
6374
- }
6375
- if (arg.UnresolvedObject) {
6376
- return normalizeSuiAddress(arg.UnresolvedObject.objectId);
6377
- }
6378
- return void 0;
6379
- }
6380
-
6381
6528
  var __typeError$2 = (msg) => {
6382
6529
  throw TypeError(msg);
6383
6530
  };
@@ -6925,7 +7072,7 @@ const _Transaction = class _Transaction {
6925
7072
  }
6926
7073
  }
6927
7074
  setExpiration(expiration) {
6928
- __privateGet$1(this, _data).expiration = expiration ? parse(TransactionExpiration$2, expiration) : null;
7075
+ __privateGet$1(this, _data).expiration = expiration ? parse(TransactionExpiration$1, expiration) : null;
6929
7076
  }
6930
7077
  setGasPrice(price) {
6931
7078
  __privateGet$1(this, _data).gasConfig.price = String(price);
@@ -7305,6 +7452,7 @@ runPlugins_fn = async function(plugins, options) {
7305
7452
  } finally {
7306
7453
  __privateSet$1(this, _inputSection, __privateGet$1(this, _data).inputs.slice());
7307
7454
  __privateSet$1(this, _commandSection, __privateGet$1(this, _data).commands.slice());
7455
+ __privateSet$1(this, _availableResults, new Set(__privateGet$1(this, _commandSection).map((_, i) => i)));
7308
7456
  }
7309
7457
  };
7310
7458
  waitForPendingTasks_fn = async function() {
@@ -7800,8 +7948,13 @@ class JSONRpcCoreClient extends Experimental_CoreClient {
7800
7948
  errors: result.errors
7801
7949
  };
7802
7950
  }
7803
- resolveNameServiceNames(options) {
7804
- return __privateGet(this, _jsonRpcClient).resolveNameServiceNames(options);
7951
+ async defaultNameServiceName(options) {
7952
+ const name = (await __privateGet(this, _jsonRpcClient).resolveNameServiceNames(options)).data[0];
7953
+ return {
7954
+ data: {
7955
+ name
7956
+ }
7957
+ };
7805
7958
  }
7806
7959
  resolveTransactionPlugin() {
7807
7960
  return jsonRpcClientResolveTransactionPlugin(__privateGet(this, _jsonRpcClient));
@@ -39656,7 +39809,11 @@ class VortexAPI {
39656
39809
  let page = 1;
39657
39810
  let hasNext = true;
39658
39811
  while (hasNext) {
39659
- const response = await this.getCommitments({ ...args, page, apiKey: args.apiKey });
39812
+ const response = await this.getCommitments({
39813
+ ...args,
39814
+ page,
39815
+ apiKey: args.apiKey,
39816
+ });
39660
39817
  allCommitments.push(...response.data.items);
39661
39818
  hasNext = response.data.pagination.hasNext;
39662
39819
  page++;