@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.js +1031 -874
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1031 -874
- package/dist/index.mjs.map +1 -1
- package/dist/vortex-api.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/vortex-api.ts +5 -1
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
|
|
2838
|
+
struct: bcs.lazy(() => StructTag),
|
|
2839
2839
|
u16: null,
|
|
2840
2840
|
u32: null,
|
|
2841
2841
|
u256: null
|
|
2842
2842
|
});
|
|
2843
|
-
const TypeTag
|
|
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
|
|
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
|
|
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$
|
|
2938
|
+
const TransactionExpiration$2 = bcs.enum("TransactionExpiration", {
|
|
2939
2939
|
None: null,
|
|
2940
2940
|
Epoch: unsafe_u64()
|
|
2941
2941
|
});
|
|
2942
|
-
const 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$
|
|
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
|
|
3284
|
+
StructTag,
|
|
3285
3285
|
SuiObjectRef,
|
|
3286
3286
|
TransactionData,
|
|
3287
3287
|
TransactionDataV1,
|
|
3288
3288
|
TransactionEffects,
|
|
3289
|
-
TransactionExpiration: TransactionExpiration$
|
|
3289
|
+
TransactionExpiration: TransactionExpiration$2,
|
|
3290
3290
|
TransactionKind,
|
|
3291
|
-
TypeTag
|
|
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.
|
|
3426
|
-
const TARGETED_RPC_VERSION = "1.
|
|
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
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
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
|
-
|
|
3841
|
-
|
|
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
|
-
|
|
3858
|
+
return store$3?.get(lang);
|
|
3844
3859
|
}
|
|
3845
3860
|
|
|
3846
|
-
|
|
3847
|
-
|
|
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
|
-
|
|
3873
|
+
return store$2?.get(lang);
|
|
3850
3874
|
}
|
|
3851
3875
|
|
|
3852
|
-
|
|
3853
|
-
|
|
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
|
-
|
|
3889
|
+
return store$1?.get(reference)?.get(lang);
|
|
3856
3890
|
}
|
|
3857
3891
|
|
|
3858
|
-
|
|
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
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
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
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
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
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
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
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
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
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
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
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4133
|
+
return !schema["~run"]({ value: input }, { abortEarly: true }).issues;
|
|
3999
4134
|
}
|
|
4000
4135
|
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
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
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
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
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
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
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
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
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
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
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
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
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
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
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
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
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
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
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
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
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
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
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
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
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
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
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
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
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
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(
|
|
4601
|
-
|
|
4602
|
-
|
|
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$
|
|
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$
|
|
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
|
-
|
|
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 <
|
|
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
|
|
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]
|
|
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$
|
|
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
|
-
|
|
7804
|
-
|
|
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({
|
|
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++;
|