@mysten/payment-kit 0.0.0-experimental-20251001205708
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/README.md +126 -0
- package/dist/cjs/client.d.ts +6 -0
- package/dist/cjs/client.js +62 -0
- package/dist/cjs/client.js.map +7 -0
- package/dist/cjs/constants.d.ts +6 -0
- package/dist/cjs/constants.js +31 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/config.d.ts +14 -0
- package/dist/cjs/contracts/payment_kit/config.js +50 -0
- package/dist/cjs/contracts/payment_kit/config.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/deps/std/type_name.d.ts +14 -0
- package/dist/cjs/contracts/payment_kit/deps/std/type_name.js +42 -0
- package/dist/cjs/contracts/payment_kit/deps/std/type_name.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/object.d.ts +5 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/object.js +33 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/object.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/vec_map.d.ts +27 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/vec_map.js +45 -0
- package/dist/cjs/contracts/payment_kit/deps/sui/vec_map.js.map +7 -0
- package/dist/cjs/contracts/payment_kit/payment_kit.d.ts +233 -0
- package/dist/cjs/contracts/payment_kit/payment_kit.js +252 -0
- package/dist/cjs/contracts/payment_kit/payment_kit.js.map +7 -0
- package/dist/cjs/contracts/utils/index.d.ts +12 -0
- package/dist/cjs/contracts/utils/index.js +151 -0
- package/dist/cjs/contracts/utils/index.js.map +7 -0
- package/dist/cjs/error.d.ts +2 -0
- package/dist/cjs/error.js +26 -0
- package/dist/cjs/error.js.map +7 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/types.d.ts +10 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/esm/client.d.ts +6 -0
- package/dist/esm/client.js +45 -0
- package/dist/esm/client.js.map +7 -0
- package/dist/esm/constants.d.ts +6 -0
- package/dist/esm/constants.js +11 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/contracts/payment_kit/config.d.ts +14 -0
- package/dist/esm/contracts/payment_kit/config.js +20 -0
- package/dist/esm/contracts/payment_kit/config.js.map +7 -0
- package/dist/esm/contracts/payment_kit/deps/std/type_name.d.ts +14 -0
- package/dist/esm/contracts/payment_kit/deps/std/type_name.js +22 -0
- package/dist/esm/contracts/payment_kit/deps/std/type_name.js.map +7 -0
- package/dist/esm/contracts/payment_kit/deps/sui/object.d.ts +5 -0
- package/dist/esm/contracts/payment_kit/deps/sui/object.js +13 -0
- package/dist/esm/contracts/payment_kit/deps/sui/object.js.map +7 -0
- package/dist/esm/contracts/payment_kit/deps/sui/vec_map.d.ts +27 -0
- package/dist/esm/contracts/payment_kit/deps/sui/vec_map.js +25 -0
- package/dist/esm/contracts/payment_kit/deps/sui/vec_map.js.map +7 -0
- package/dist/esm/contracts/payment_kit/payment_kit.d.ts +233 -0
- package/dist/esm/contracts/payment_kit/payment_kit.js +222 -0
- package/dist/esm/contracts/payment_kit/payment_kit.js.map +7 -0
- package/dist/esm/contracts/utils/index.d.ts +12 -0
- package/dist/esm/contracts/utils/index.js +131 -0
- package/dist/esm/contracts/utils/index.js.map +7 -0
- package/dist/esm/error.d.ts +2 -0
- package/dist/esm/error.js +6 -0
- package/dist/esm/error.js.map +7 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/types.d.ts +10 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
MoveEnum: () => MoveEnum,
|
|
22
|
+
MoveStruct: () => MoveStruct,
|
|
23
|
+
MoveTuple: () => MoveTuple,
|
|
24
|
+
getPureBcsSchema: () => getPureBcsSchema,
|
|
25
|
+
normalizeMoveArguments: () => normalizeMoveArguments
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(utils_exports);
|
|
28
|
+
var import_bcs = require("@mysten/sui/bcs");
|
|
29
|
+
var import_utils = require("@mysten/sui/utils");
|
|
30
|
+
var import_transactions = require("@mysten/sui/transactions");
|
|
31
|
+
const MOVE_STDLIB_ADDRESS = (0, import_utils.normalizeSuiAddress)("0x1");
|
|
32
|
+
const SUI_FRAMEWORK_ADDRESS = (0, import_utils.normalizeSuiAddress)("0x2");
|
|
33
|
+
const SUI_SYSTEM_ADDRESS = (0, import_utils.normalizeSuiAddress)("0x3");
|
|
34
|
+
function getPureBcsSchema(typeTag) {
|
|
35
|
+
const parsedTag = typeof typeTag === "string" ? import_bcs.TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
36
|
+
if ("u8" in parsedTag) {
|
|
37
|
+
return import_bcs.bcs.U8;
|
|
38
|
+
} else if ("u16" in parsedTag) {
|
|
39
|
+
return import_bcs.bcs.U16;
|
|
40
|
+
} else if ("u32" in parsedTag) {
|
|
41
|
+
return import_bcs.bcs.U32;
|
|
42
|
+
} else if ("u64" in parsedTag) {
|
|
43
|
+
return import_bcs.bcs.U64;
|
|
44
|
+
} else if ("u128" in parsedTag) {
|
|
45
|
+
return import_bcs.bcs.U128;
|
|
46
|
+
} else if ("u256" in parsedTag) {
|
|
47
|
+
return import_bcs.bcs.U256;
|
|
48
|
+
} else if ("address" in parsedTag) {
|
|
49
|
+
return import_bcs.bcs.Address;
|
|
50
|
+
} else if ("bool" in parsedTag) {
|
|
51
|
+
return import_bcs.bcs.Bool;
|
|
52
|
+
} else if ("vector" in parsedTag) {
|
|
53
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
54
|
+
return type ? import_bcs.bcs.vector(type) : null;
|
|
55
|
+
} else if ("struct" in parsedTag) {
|
|
56
|
+
const structTag = parsedTag.struct;
|
|
57
|
+
const pkg = (0, import_utils.normalizeSuiAddress)(parsedTag.struct.address);
|
|
58
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
59
|
+
if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") {
|
|
60
|
+
return import_bcs.bcs.String;
|
|
61
|
+
}
|
|
62
|
+
if (structTag.module === "option" && structTag.name === "Option") {
|
|
63
|
+
const type = getPureBcsSchema(structTag.typeParams[0]);
|
|
64
|
+
return type ? import_bcs.bcs.option(type) : null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === "Object" && structTag.name === "ID") {
|
|
68
|
+
return import_bcs.bcs.Address;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
74
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
75
|
+
if (parameterNames && argLen !== parameterNames.length) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const normalizedArgs = [];
|
|
81
|
+
let index = 0;
|
|
82
|
+
for (const [i, argType] of argTypes.entries()) {
|
|
83
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {
|
|
84
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {
|
|
88
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {
|
|
92
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {
|
|
96
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
let arg;
|
|
100
|
+
if (Array.isArray(args)) {
|
|
101
|
+
if (index >= args.length) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
arg = args[index];
|
|
107
|
+
} else {
|
|
108
|
+
if (!parameterNames) {
|
|
109
|
+
throw new Error(`Expected arguments to be passed as an array`);
|
|
110
|
+
}
|
|
111
|
+
const name = parameterNames[index];
|
|
112
|
+
arg = args[name];
|
|
113
|
+
if (arg == null) {
|
|
114
|
+
throw new Error(`Parameter ${name} is required`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
index += 1;
|
|
118
|
+
if (typeof arg === "function" || (0, import_transactions.isArgument)(arg)) {
|
|
119
|
+
normalizedArgs.push(arg);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const type = argTypes[i];
|
|
123
|
+
const bcsType = getPureBcsSchema(type);
|
|
124
|
+
if (bcsType) {
|
|
125
|
+
const bytes = bcsType.serialize(arg);
|
|
126
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
127
|
+
continue;
|
|
128
|
+
} else if (typeof arg === "string") {
|
|
129
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
133
|
+
}
|
|
134
|
+
return normalizedArgs;
|
|
135
|
+
}
|
|
136
|
+
class MoveStruct extends import_bcs.BcsStruct {
|
|
137
|
+
}
|
|
138
|
+
class MoveEnum extends import_bcs.BcsEnum {
|
|
139
|
+
}
|
|
140
|
+
class MoveTuple extends import_bcs.BcsTuple {
|
|
141
|
+
}
|
|
142
|
+
function stringify(val) {
|
|
143
|
+
if (typeof val === "object") {
|
|
144
|
+
return JSON.stringify(val, (val2) => val2);
|
|
145
|
+
}
|
|
146
|
+
if (typeof val === "bigint") {
|
|
147
|
+
return val.toString();
|
|
148
|
+
}
|
|
149
|
+
return val;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/contracts/utils/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { BcsType, TypeTag } from '@mysten/sui/bcs';\nimport { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport type { TransactionArgument } from '@mysten/sui/transactions';\nimport { isArgument } from '@mysten/sui/transactions';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\nconst SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(parsedTag.struct.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst type = getPureBcsSchema(structTag.typeParams[0]!);\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: string[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const [i, argType] of argTypes.entries()) {\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg == null) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst type = argTypes[i]!;\n\t\tconst bcsType = getPureBcsSchema(type);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t} else if (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${type}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tT extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["val"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var error_exports = {};
|
|
20
|
+
__export(error_exports, {
|
|
21
|
+
PaymentKitClientError: () => PaymentKitClientError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(error_exports);
|
|
24
|
+
class PaymentKitClientError extends Error {
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/error.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport class PaymentKitClientError extends Error {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,8BAA8B,MAAM;AAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
PaymentKitClient: () => import_client.PaymentKitClient
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
|
+
var import_client = require("./client.js");
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { PaymentKitClient } from './client.js';\nexport type {\n\tPaymentKitCompatibleClient,\n\tPaymentKitClientConfig,\n\tPaymentKitPackageConfig,\n} from './types.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAiC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClientWithExtensions, Experimental_CoreClient } from '@mysten/sui/experimental';
|
|
2
|
+
export type PaymentKitPackageConfig = {
|
|
3
|
+
packageId: string;
|
|
4
|
+
};
|
|
5
|
+
export type PaymentKitCompatibleClient = ClientWithExtensions<{
|
|
6
|
+
core: Experimental_CoreClient;
|
|
7
|
+
}>;
|
|
8
|
+
export interface PaymentKitClientConfig {
|
|
9
|
+
suiClient: PaymentKitCompatibleClient;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ClientWithExtensions, Experimental_CoreClient } from '@mysten/sui/experimental';\n\nexport type PaymentKitPackageConfig = {\n\tpackageId: string;\n};\n\nexport type PaymentKitCompatibleClient = ClientWithExtensions<{\n\tcore: Experimental_CoreClient;\n}>;\n\nexport interface PaymentKitClientConfig {\n\tsuiClient: PaymentKitCompatibleClient;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
var _packageConfig, _suiClient;
|
|
9
|
+
import { PaymentKitClientError } from "./error.js";
|
|
10
|
+
import {
|
|
11
|
+
MAINNET_PAYMENT_KIT_PACKAGE_CONFIG,
|
|
12
|
+
TESTNET_PAYMENT_KIT_PACKAGE_CONFIG
|
|
13
|
+
} from "./constants.js";
|
|
14
|
+
class PaymentKitClient {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
__privateAdd(this, _packageConfig);
|
|
17
|
+
// @ts-expect-error - suiClient will be used in a later PR
|
|
18
|
+
__privateAdd(this, _suiClient);
|
|
19
|
+
if (config.suiClient) {
|
|
20
|
+
__privateSet(this, _suiClient, config.suiClient);
|
|
21
|
+
} else {
|
|
22
|
+
throw new PaymentKitClientError("suiClient must be provided");
|
|
23
|
+
}
|
|
24
|
+
const network = config.suiClient.network;
|
|
25
|
+
switch (network) {
|
|
26
|
+
case "testnet":
|
|
27
|
+
__privateSet(this, _packageConfig, TESTNET_PAYMENT_KIT_PACKAGE_CONFIG);
|
|
28
|
+
break;
|
|
29
|
+
case "mainnet":
|
|
30
|
+
__privateSet(this, _packageConfig, MAINNET_PAYMENT_KIT_PACKAGE_CONFIG);
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
throw new PaymentKitClientError(`Unsupported network: ${network}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get packageConfig() {
|
|
37
|
+
return __privateGet(this, _packageConfig);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
_packageConfig = new WeakMap();
|
|
41
|
+
_suiClient = new WeakMap();
|
|
42
|
+
export {
|
|
43
|
+
PaymentKitClient
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/client.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PaymentKitClientError } from './error.js';\n\nimport {\n\tMAINNET_PAYMENT_KIT_PACKAGE_CONFIG,\n\tTESTNET_PAYMENT_KIT_PACKAGE_CONFIG,\n} from './constants.js';\nimport type {\n\tPaymentKitClientConfig,\n\tPaymentKitCompatibleClient,\n\tPaymentKitPackageConfig,\n} from './types.js';\n\nexport class PaymentKitClient {\n\t#packageConfig: PaymentKitPackageConfig;\n\t// @ts-expect-error - suiClient will be used in a later PR\n\t#suiClient: PaymentKitCompatibleClient;\n\n\tprivate constructor(config: PaymentKitClientConfig) {\n\t\tif (config.suiClient) {\n\t\t\tthis.#suiClient = config.suiClient;\n\t\t} else {\n\t\t\tthrow new PaymentKitClientError('suiClient must be provided');\n\t\t}\n\n\t\tconst network = config.suiClient.network;\n\t\tswitch (network) {\n\t\t\tcase 'testnet':\n\t\t\t\tthis.#packageConfig = TESTNET_PAYMENT_KIT_PACKAGE_CONFIG;\n\t\t\t\tbreak;\n\t\t\tcase 'mainnet':\n\t\t\t\tthis.#packageConfig = MAINNET_PAYMENT_KIT_PACKAGE_CONFIG;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new PaymentKitClientError(`Unsupported network: ${network}`);\n\t\t}\n\t}\n\n\tget packageConfig() {\n\t\treturn this.#packageConfig;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA;AAGA,SAAS,6BAA6B;AAEtC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAOA,MAAM,iBAAiB;AAAA,EAKrB,YAAY,QAAgC;AAJpD;AAEA;AAAA;AAGC,QAAI,OAAO,WAAW;AACrB,yBAAK,YAAa,OAAO;AAAA,IAC1B,OAAO;AACN,YAAM,IAAI,sBAAsB,4BAA4B;AAAA,IAC7D;AAEA,UAAM,UAAU,OAAO,UAAU;AACjC,YAAQ,SAAS;AAAA,MAChB,KAAK;AACJ,2BAAK,gBAAiB;AACtB;AAAA,MACD,KAAK;AACJ,2BAAK,gBAAiB;AACtB;AAAA,MACD;AACC,cAAM,IAAI,sBAAsB,wBAAwB,OAAO,EAAE;AAAA,IACnE;AAAA,EACD;AAAA,EAEA,IAAI,gBAAgB;AACnB,WAAO,mBAAK;AAAA,EACb;AACD;AA3BC;AAEA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const TESTNET_PAYMENT_KIT_PACKAGE_CONFIG = {
|
|
2
|
+
packageId: "0x6d40694388297e1fae93ddbb7ef575ca961af225727c2a389259b29903d0fced"
|
|
3
|
+
};
|
|
4
|
+
const MAINNET_PAYMENT_KIT_PACKAGE_CONFIG = {
|
|
5
|
+
packageId: "0x73cdadfc6c49df26d90055fd40a2b487fbe3021c8a8efed1696fb9cd51d23130"
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
MAINNET_PAYMENT_KIT_PACKAGE_CONFIG,
|
|
9
|
+
TESTNET_PAYMENT_KIT_PACKAGE_CONFIG
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { PaymentKitPackageConfig } from './types.js';\n\nexport const TESTNET_PAYMENT_KIT_PACKAGE_CONFIG = {\n\tpackageId: '0x6d40694388297e1fae93ddbb7ef575ca961af225727c2a389259b29903d0fced',\n} satisfies PaymentKitPackageConfig;\n\nexport const MAINNET_PAYMENT_KIT_PACKAGE_CONFIG = {\n\tpackageId: '0x73cdadfc6c49df26d90055fd40a2b487fbe3021c8a8efed1696fb9cd51d23130',\n} satisfies PaymentKitPackageConfig;\n"],
|
|
5
|
+
"mappings": "AAIO,MAAM,qCAAqC;AAAA,EACjD,WAAW;AACZ;AAEO,MAAM,qCAAqC;AAAA,EACjD,WAAW;AACZ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MoveEnum } from '../utils/index.js';
|
|
2
|
+
export declare const Value: MoveEnum<{
|
|
3
|
+
U64: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
4
|
+
Address: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
5
|
+
String: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
6
|
+
AsciiString: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
7
|
+
Bool: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
8
|
+
Bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
|
|
9
|
+
length: number;
|
|
10
|
+
}, string>;
|
|
11
|
+
Type: import("../utils/index.js").MoveStruct<{
|
|
12
|
+
name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
13
|
+
}, "std::type_name::TypeName">;
|
|
14
|
+
}, "@local-pkg/payment-kit::config::Value">;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MoveEnum } from "../utils/index.js";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
import * as type_name from "./deps/std/type_name.js";
|
|
4
|
+
const $moduleName = "@local-pkg/payment-kit::config";
|
|
5
|
+
const Value = new MoveEnum({
|
|
6
|
+
name: `${$moduleName}::Value`,
|
|
7
|
+
fields: {
|
|
8
|
+
U64: bcs.u64(),
|
|
9
|
+
Address: bcs.Address,
|
|
10
|
+
String: bcs.string(),
|
|
11
|
+
AsciiString: bcs.string(),
|
|
12
|
+
Bool: bcs.bool(),
|
|
13
|
+
Bytes: bcs.vector(bcs.u8()),
|
|
14
|
+
Type: type_name.TypeName
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
Value
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/contracts/payment_kit/config.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { MoveEnum } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport * as type_name from './deps/std/type_name.js';\nconst $moduleName = '@local-pkg/payment-kit::config';\nexport const Value = new MoveEnum({\n\tname: `${$moduleName}::Value`,\n\tfields: {\n\t\tU64: bcs.u64(),\n\t\tAddress: bcs.Address,\n\t\tString: bcs.string(),\n\t\tAsciiString: bcs.string(),\n\t\tBool: bcs.bool(),\n\t\tBytes: bcs.vector(bcs.u8()),\n\t\tType: type_name.TypeName,\n\t},\n});\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,gBAAgB;AACzB,SAAS,WAAW;AACpB,YAAY,eAAe;AAC3B,MAAM,cAAc;AACb,MAAM,QAAQ,IAAI,SAAS;AAAA,EACjC,MAAM,GAAG,WAAW;AAAA,EACpB,QAAQ;AAAA,IACP,KAAK,IAAI,IAAI;AAAA,IACb,SAAS,IAAI;AAAA,IACb,QAAQ,IAAI,OAAO;AAAA,IACnB,aAAa,IAAI,OAAO;AAAA,IACxB,MAAM,IAAI,KAAK;AAAA,IACf,OAAO,IAAI,OAAO,IAAI,GAAG,CAAC;AAAA,IAC1B,MAAM,UAAU;AAAA,EACjB;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Functionality for converting Move types into values. Use with care! */
|
|
2
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
3
|
+
export declare const TypeName: MoveStruct<{
|
|
4
|
+
/**
|
|
5
|
+
* String representation of the type. All types are represented using their source
|
|
6
|
+
* syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types.
|
|
7
|
+
* Struct types are represented as fully qualified type names; e.g.
|
|
8
|
+
* `00000000000000000000000000000001::string::String` or
|
|
9
|
+
* `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`
|
|
10
|
+
* Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or
|
|
11
|
+
* 32 depending on the Move platform)
|
|
12
|
+
*/
|
|
13
|
+
name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
14
|
+
}, "std::type_name::TypeName">;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
const $moduleName = "std::type_name";
|
|
4
|
+
const TypeName = new MoveStruct({
|
|
5
|
+
name: `${$moduleName}::TypeName`,
|
|
6
|
+
fields: {
|
|
7
|
+
/**
|
|
8
|
+
* String representation of the type. All types are represented using their source
|
|
9
|
+
* syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types.
|
|
10
|
+
* Struct types are represented as fully qualified type names; e.g.
|
|
11
|
+
* `00000000000000000000000000000001::string::String` or
|
|
12
|
+
* `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`
|
|
13
|
+
* Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or
|
|
14
|
+
* 32 depending on the Move platform)
|
|
15
|
+
*/
|
|
16
|
+
name: bcs.string()
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
TypeName
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=type_name.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/contracts/payment_kit/deps/std/type_name.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/** Functionality for converting Move types into values. Use with care! */\n\nimport { MoveStruct } from '../../../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nconst $moduleName = 'std::type_name';\nexport const TypeName = new MoveStruct({\n\tname: `${$moduleName}::TypeName`,\n\tfields: {\n\t\t/**\n\t\t * String representation of the type. All types are represented using their source\n\t\t * syntax: \"u8\", \"u64\", \"bool\", \"address\", \"vector\", and so on for primitive types.\n\t\t * Struct types are represented as fully qualified type names; e.g.\n\t\t * `00000000000000000000000000000001::string::String` or\n\t\t * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>>`\n\t\t * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or\n\t\t * 32 depending on the Move platform)\n\t\t */\n\t\tname: bcs.string(),\n\t},\n});\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AACpB,MAAM,cAAc;AACb,MAAM,WAAW,IAAI,WAAW;AAAA,EACtC,MAAM,GAAG,WAAW;AAAA,EACpB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUP,MAAM,IAAI,OAAO;AAAA,EAClB;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
const $moduleName = "0x2::object";
|
|
4
|
+
const UID = new MoveStruct({
|
|
5
|
+
name: `${$moduleName}::UID`,
|
|
6
|
+
fields: {
|
|
7
|
+
id: bcs.Address
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
export {
|
|
11
|
+
UID
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/contracts/payment_kit/deps/sui/object.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/** Sui object identifiers */\n\nimport { MoveStruct } from '../../../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nconst $moduleName = '0x2::object';\nexport const UID = new MoveStruct({\n\tname: `${$moduleName}::UID`,\n\tfields: {\n\t\tid: bcs.Address,\n\t},\n});\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AACpB,MAAM,cAAc;AACb,MAAM,MAAM,IAAI,WAAW;AAAA,EACjC,MAAM,GAAG,WAAW;AAAA,EACpB,QAAQ;AAAA,IACP,IAAI,IAAI;AAAA,EACT;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BcsType } from '@mysten/sui/bcs';
|
|
2
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
3
|
+
/** An entry in the map */
|
|
4
|
+
export declare function Entry<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [K, V]): MoveStruct<{
|
|
5
|
+
key: K;
|
|
6
|
+
value: V;
|
|
7
|
+
}, `0x2::vec_map::Entry<${K["name"]}, ${V["name"]}>`>;
|
|
8
|
+
/**
|
|
9
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
10
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
11
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
12
|
+
* of this data structure is only to provide the convenience of programming against
|
|
13
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
14
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
15
|
+
* also be handwritten.
|
|
16
|
+
*/
|
|
17
|
+
export declare function VecMap<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [K, V]): MoveStruct<{
|
|
18
|
+
contents: BcsType<{
|
|
19
|
+
key: K extends BcsType<infer U, any, string> ? U : never;
|
|
20
|
+
value: V extends BcsType<infer U, any, string> ? U : never;
|
|
21
|
+
}[], Iterable<{
|
|
22
|
+
key: K extends BcsType<any, infer U_1, string> ? U_1 : never;
|
|
23
|
+
value: V extends BcsType<any, infer U_1, string> ? U_1 : never;
|
|
24
|
+
}> & {
|
|
25
|
+
length: number;
|
|
26
|
+
}, string>;
|
|
27
|
+
}, `0x2::vec_map::VecMap<${K["name"]}, ${V["name"]}>`>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
2
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
3
|
+
const $moduleName = "0x2::vec_map";
|
|
4
|
+
function Entry(...typeParameters) {
|
|
5
|
+
return new MoveStruct({
|
|
6
|
+
name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
|
|
7
|
+
fields: {
|
|
8
|
+
key: typeParameters[0],
|
|
9
|
+
value: typeParameters[1]
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function VecMap(...typeParameters) {
|
|
14
|
+
return new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
|
|
16
|
+
fields: {
|
|
17
|
+
contents: bcs.vector(Entry(typeParameters[0], typeParameters[1]))
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
Entry,
|
|
23
|
+
VecMap
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=vec_map.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/contracts/payment_kit/deps/sui/vec_map.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type { BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\nconst $moduleName = '0x2::vec_map';\n/** An entry in the map */\nexport function Entry<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [K, V]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\n/**\n * A map data structure backed by a vector. The map is guaranteed not to contain\n * duplicate keys, but entries are _not_ sorted by key--entries are included in\n * insertion order. All operations are O(N) in the size of the map--the intention\n * of this data structure is only to provide the convenience of programming against\n * a map API. Large maps should use handwritten parent/child relationships instead.\n * Maps that need sorted iteration rather than insertion order iteration should\n * also be handwritten.\n */\nexport function VecMap<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [K, V]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,WAAW;AAEpB,SAAS,kBAAkB;AAC3B,MAAM,cAAc;AAEb,SAAS,SAAyD,gBAAwB;AAChG,SAAO,IAAI,WAAW;AAAA,IACrB,MAAM,GAAG,WAAW,WAAW,eAAe,CAAC,EAAE,IAAiB,KAAK,eAAe,CAAC,EAAE,IAAiB;AAAA,IAC1G,QAAQ;AAAA,MACP,KAAK,eAAe,CAAC;AAAA,MACrB,OAAO,eAAe,CAAC;AAAA,IACxB;AAAA,EACD,CAAC;AACF;AAUO,SAAS,UAA0D,gBAAwB;AACjG,SAAO,IAAI,WAAW;AAAA,IACrB,MAAM,GAAG,WAAW,YAAY,eAAe,CAAC,EAAE,IAAiB,KAAK,eAAe,CAAC,EAAE,IAAiB;AAAA,IAC3G,QAAQ;AAAA,MACP,UAAU,IAAI,OAAO,MAAM,eAAe,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;AAAA,IACjE;AAAA,EACD,CAAC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|