@mysten/walrus 0.0.2 → 0.0.4
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/CHANGELOG.md +14 -0
- package/README.md +6 -8
- package/dist/cjs/client.d.ts +5 -89
- package/dist/cjs/client.js +194 -137
- package/dist/cjs/client.js.map +3 -3
- package/dist/cjs/constants.d.ts +13 -2
- package/dist/cjs/constants.js +6 -3
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/contracts/subsidies.d.ts +83 -0
- package/dist/cjs/contracts/subsidies.js +253 -0
- package/dist/cjs/contracts/subsidies.js.map +7 -0
- package/dist/cjs/types.d.ts +5 -6
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +2 -0
- package/dist/cjs/utils/index.js +46 -1
- package/dist/cjs/utils/index.js.map +2 -2
- package/dist/cjs/utils/memo.d.ts +5 -0
- package/dist/cjs/utils/memo.js +59 -0
- package/dist/cjs/utils/memo.js.map +7 -0
- package/dist/cjs/utils/object-loader.js +2 -2
- package/dist/cjs/utils/object-loader.js.map +2 -2
- package/dist/esm/client.d.ts +5 -89
- package/dist/esm/client.js +182 -120
- package/dist/esm/client.js.map +3 -3
- package/dist/esm/constants.d.ts +13 -2
- package/dist/esm/constants.js +6 -3
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/contracts/subsidies.d.ts +83 -0
- package/dist/esm/contracts/subsidies.js +223 -0
- package/dist/esm/contracts/subsidies.js.map +7 -0
- package/dist/esm/types.d.ts +5 -6
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.js +46 -1
- package/dist/esm/utils/index.js.map +2 -2
- package/dist/esm/utils/memo.d.ts +5 -0
- package/dist/esm/utils/memo.js +39 -0
- package/dist/esm/utils/memo.js.map +7 -0
- package/dist/esm/utils/object-loader.js +2 -2
- package/dist/esm/utils/object-loader.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var subsidies_exports = {};
|
|
30
|
+
__export(subsidies_exports, {
|
|
31
|
+
AdminCap: () => AdminCap,
|
|
32
|
+
Subsidies: () => Subsidies,
|
|
33
|
+
init: () => init
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(subsidies_exports);
|
|
36
|
+
var import_bcs = require("@mysten/sui/bcs");
|
|
37
|
+
var balance = __toESM(require("./deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.js"));
|
|
38
|
+
var object = __toESM(require("./deps/0x0000000000000000000000000000000000000000000000000000000000000002/object.js"));
|
|
39
|
+
var import_utils = require("./utils/index.js");
|
|
40
|
+
function AdminCap() {
|
|
41
|
+
return import_bcs.bcs.struct("AdminCap", {
|
|
42
|
+
id: object.UID(),
|
|
43
|
+
subsidies_id: import_bcs.bcs.Address
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function Subsidies() {
|
|
47
|
+
return import_bcs.bcs.struct("Subsidies", {
|
|
48
|
+
id: object.UID(),
|
|
49
|
+
buyer_subsidy_rate: import_bcs.bcs.u16(),
|
|
50
|
+
system_subsidy_rate: import_bcs.bcs.u16(),
|
|
51
|
+
subsidy_pool: balance.Balance(),
|
|
52
|
+
package_id: import_bcs.bcs.Address,
|
|
53
|
+
version: import_bcs.bcs.u64()
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function init(packageAddress) {
|
|
57
|
+
function _new(options) {
|
|
58
|
+
const argumentsTypes = [
|
|
59
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::ID"
|
|
60
|
+
];
|
|
61
|
+
return (tx) => tx.moveCall({
|
|
62
|
+
package: packageAddress,
|
|
63
|
+
module: "subsidies",
|
|
64
|
+
function: "new",
|
|
65
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function new_with_initial_rates_and_funds(options) {
|
|
69
|
+
const argumentsTypes = [
|
|
70
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::ID",
|
|
71
|
+
"u16",
|
|
72
|
+
"u16",
|
|
73
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`
|
|
74
|
+
];
|
|
75
|
+
return (tx) => tx.moveCall({
|
|
76
|
+
package: packageAddress,
|
|
77
|
+
module: "subsidies",
|
|
78
|
+
function: "new_with_initial_rates_and_funds",
|
|
79
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function add_funds(options) {
|
|
83
|
+
const argumentsTypes = [
|
|
84
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
85
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`
|
|
86
|
+
];
|
|
87
|
+
return (tx) => tx.moveCall({
|
|
88
|
+
package: packageAddress,
|
|
89
|
+
module: "subsidies",
|
|
90
|
+
function: "add_funds",
|
|
91
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function check_admin(options) {
|
|
95
|
+
const argumentsTypes = [
|
|
96
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
97
|
+
`${packageAddress}::subsidies::AdminCap`
|
|
98
|
+
];
|
|
99
|
+
return (tx) => tx.moveCall({
|
|
100
|
+
package: packageAddress,
|
|
101
|
+
module: "subsidies",
|
|
102
|
+
function: "check_admin",
|
|
103
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function check_version_upgrade(options) {
|
|
107
|
+
const argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];
|
|
108
|
+
return (tx) => tx.moveCall({
|
|
109
|
+
package: packageAddress,
|
|
110
|
+
module: "subsidies",
|
|
111
|
+
function: "check_version_upgrade",
|
|
112
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function set_buyer_subsidy_rate(options) {
|
|
116
|
+
const argumentsTypes = [
|
|
117
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
118
|
+
`${packageAddress}::subsidies::AdminCap`,
|
|
119
|
+
"u16"
|
|
120
|
+
];
|
|
121
|
+
return (tx) => tx.moveCall({
|
|
122
|
+
package: packageAddress,
|
|
123
|
+
module: "subsidies",
|
|
124
|
+
function: "set_buyer_subsidy_rate",
|
|
125
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function set_system_subsidy_rate(options) {
|
|
129
|
+
const argumentsTypes = [
|
|
130
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
131
|
+
`${packageAddress}::subsidies::AdminCap`,
|
|
132
|
+
"u16"
|
|
133
|
+
];
|
|
134
|
+
return (tx) => tx.moveCall({
|
|
135
|
+
package: packageAddress,
|
|
136
|
+
module: "subsidies",
|
|
137
|
+
function: "set_system_subsidy_rate",
|
|
138
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function apply_subsidies(options) {
|
|
142
|
+
const argumentsTypes = [
|
|
143
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
144
|
+
"u64",
|
|
145
|
+
"u32",
|
|
146
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,
|
|
147
|
+
`${packageAddress}::system::System`
|
|
148
|
+
];
|
|
149
|
+
return (tx) => tx.moveCall({
|
|
150
|
+
package: packageAddress,
|
|
151
|
+
module: "subsidies",
|
|
152
|
+
function: "apply_subsidies",
|
|
153
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function extend_blob(options) {
|
|
157
|
+
const argumentsTypes = [
|
|
158
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
159
|
+
`${packageAddress}::system::System`,
|
|
160
|
+
`${packageAddress}::blob::Blob`,
|
|
161
|
+
"u32",
|
|
162
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`
|
|
163
|
+
];
|
|
164
|
+
return (tx) => tx.moveCall({
|
|
165
|
+
package: packageAddress,
|
|
166
|
+
module: "subsidies",
|
|
167
|
+
function: "extend_blob",
|
|
168
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function reserve_space(options) {
|
|
172
|
+
const argumentsTypes = [
|
|
173
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
174
|
+
`${packageAddress}::system::System`,
|
|
175
|
+
"u64",
|
|
176
|
+
"u32",
|
|
177
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`
|
|
178
|
+
];
|
|
179
|
+
return (tx) => tx.moveCall({
|
|
180
|
+
package: packageAddress,
|
|
181
|
+
module: "subsidies",
|
|
182
|
+
function: "reserve_space",
|
|
183
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function migrate(options) {
|
|
187
|
+
const argumentsTypes = [
|
|
188
|
+
`${packageAddress}::subsidies::Subsidies`,
|
|
189
|
+
`${packageAddress}::subsidies::AdminCap`,
|
|
190
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::ID"
|
|
191
|
+
];
|
|
192
|
+
return (tx) => tx.moveCall({
|
|
193
|
+
package: packageAddress,
|
|
194
|
+
module: "subsidies",
|
|
195
|
+
function: "migrate",
|
|
196
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function admin_cap_subsidies_id(options) {
|
|
200
|
+
const argumentsTypes = [`${packageAddress}::subsidies::AdminCap`];
|
|
201
|
+
return (tx) => tx.moveCall({
|
|
202
|
+
package: packageAddress,
|
|
203
|
+
module: "subsidies",
|
|
204
|
+
function: "admin_cap_subsidies_id",
|
|
205
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function subsidy_pool_value(options) {
|
|
209
|
+
const argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];
|
|
210
|
+
return (tx) => tx.moveCall({
|
|
211
|
+
package: packageAddress,
|
|
212
|
+
module: "subsidies",
|
|
213
|
+
function: "subsidy_pool_value",
|
|
214
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function buyer_subsidy_rate(options) {
|
|
218
|
+
const argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];
|
|
219
|
+
return (tx) => tx.moveCall({
|
|
220
|
+
package: packageAddress,
|
|
221
|
+
module: "subsidies",
|
|
222
|
+
function: "buyer_subsidy_rate",
|
|
223
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function system_subsidy_rate(options) {
|
|
227
|
+
const argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];
|
|
228
|
+
return (tx) => tx.moveCall({
|
|
229
|
+
package: packageAddress,
|
|
230
|
+
module: "subsidies",
|
|
231
|
+
function: "system_subsidy_rate",
|
|
232
|
+
arguments: (0, import_utils.normalizeMoveArguments)(options.arguments, argumentsTypes)
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
_new,
|
|
237
|
+
new_with_initial_rates_and_funds,
|
|
238
|
+
add_funds,
|
|
239
|
+
check_admin,
|
|
240
|
+
check_version_upgrade,
|
|
241
|
+
set_buyer_subsidy_rate,
|
|
242
|
+
set_system_subsidy_rate,
|
|
243
|
+
apply_subsidies,
|
|
244
|
+
extend_blob,
|
|
245
|
+
reserve_space,
|
|
246
|
+
migrate,
|
|
247
|
+
admin_cap_subsidies_id,
|
|
248
|
+
subsidy_pool_value,
|
|
249
|
+
buyer_subsidy_rate,
|
|
250
|
+
system_subsidy_rate
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=subsidies.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/contracts/subsidies.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport * as balance from './deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.js';\nimport * as object from './deps/0x0000000000000000000000000000000000000000000000000000000000000002/object.js';\nimport { normalizeMoveArguments } from './utils/index.js';\nimport type { RawTransactionArgument } from './utils/index.js';\n\nexport function AdminCap() {\n\treturn bcs.struct('AdminCap', {\n\t\tid: object.UID(),\n\t\tsubsidies_id: bcs.Address,\n\t});\n}\nexport function Subsidies() {\n\treturn bcs.struct('Subsidies', {\n\t\tid: object.UID(),\n\t\tbuyer_subsidy_rate: bcs.u16(),\n\t\tsystem_subsidy_rate: bcs.u16(),\n\t\tsubsidy_pool: balance.Balance(),\n\t\tpackage_id: bcs.Address,\n\t\tversion: bcs.u64(),\n\t});\n}\nexport function init(packageAddress: string) {\n\tfunction _new(options: { arguments: [RawTransactionArgument<string>] }) {\n\t\tconst argumentsTypes = [\n\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::object::ID',\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'new',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction new_with_initial_rates_and_funds(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<number>,\n\t\t\tRawTransactionArgument<number>,\n\t\t\tRawTransactionArgument<string>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::object::ID',\n\t\t\t'u16',\n\t\t\t'u16',\n\t\t\t`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'new_with_initial_rates_and_funds',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction add_funds(options: {\n\t\targuments: [RawTransactionArgument<string>, RawTransactionArgument<string>];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'add_funds',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction check_admin(options: {\n\t\targuments: [RawTransactionArgument<string>, RawTransactionArgument<string>];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`${packageAddress}::subsidies::AdminCap`,\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'check_admin',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction check_version_upgrade(options: { arguments: [RawTransactionArgument<string>] }) {\n\t\tconst argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'check_version_upgrade',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction set_buyer_subsidy_rate(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<number>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`${packageAddress}::subsidies::AdminCap`,\n\t\t\t'u16',\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'set_buyer_subsidy_rate',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction set_system_subsidy_rate(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<number>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`${packageAddress}::subsidies::AdminCap`,\n\t\t\t'u16',\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'set_system_subsidy_rate',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction apply_subsidies(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<number | bigint>,\n\t\t\tRawTransactionArgument<number>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t'u64',\n\t\t\t'u32',\n\t\t\t`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,\n\t\t\t`${packageAddress}::system::System`,\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'apply_subsidies',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction extend_blob(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<number>,\n\t\t\tRawTransactionArgument<string>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`${packageAddress}::system::System`,\n\t\t\t`${packageAddress}::blob::Blob`,\n\t\t\t'u32',\n\t\t\t`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'extend_blob',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction reserve_space(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<number | bigint>,\n\t\t\tRawTransactionArgument<number>,\n\t\t\tRawTransactionArgument<string>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`${packageAddress}::system::System`,\n\t\t\t'u64',\n\t\t\t'u32',\n\t\t\t`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'reserve_space',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction migrate(options: {\n\t\targuments: [\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t\tRawTransactionArgument<string>,\n\t\t];\n\t}) {\n\t\tconst argumentsTypes = [\n\t\t\t`${packageAddress}::subsidies::Subsidies`,\n\t\t\t`${packageAddress}::subsidies::AdminCap`,\n\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::object::ID',\n\t\t];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'migrate',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction admin_cap_subsidies_id(options: { arguments: [RawTransactionArgument<string>] }) {\n\t\tconst argumentsTypes = [`${packageAddress}::subsidies::AdminCap`];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'admin_cap_subsidies_id',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction subsidy_pool_value(options: { arguments: [RawTransactionArgument<string>] }) {\n\t\tconst argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'subsidy_pool_value',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction buyer_subsidy_rate(options: { arguments: [RawTransactionArgument<string>] }) {\n\t\tconst argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'buyer_subsidy_rate',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\tfunction system_subsidy_rate(options: { arguments: [RawTransactionArgument<string>] }) {\n\t\tconst argumentsTypes = [`${packageAddress}::subsidies::Subsidies`];\n\t\treturn (tx: Transaction) =>\n\t\t\ttx.moveCall({\n\t\t\t\tpackage: packageAddress,\n\t\t\t\tmodule: 'subsidies',\n\t\t\t\tfunction: 'system_subsidy_rate',\n\t\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\t});\n\t}\n\treturn {\n\t\t_new,\n\t\tnew_with_initial_rates_and_funds,\n\t\tadd_funds,\n\t\tcheck_admin,\n\t\tcheck_version_upgrade,\n\t\tset_buyer_subsidy_rate,\n\t\tset_system_subsidy_rate,\n\t\tapply_subsidies,\n\t\textend_blob,\n\t\treserve_space,\n\t\tmigrate,\n\t\tadmin_cap_subsidies_id,\n\t\tsubsidy_pool_value,\n\t\tbuyer_subsidy_rate,\n\t\tsystem_subsidy_rate,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAGpB,cAAyB;AACzB,aAAwB;AACxB,mBAAuC;AAGhC,SAAS,WAAW;AAC1B,SAAO,eAAI,OAAO,YAAY;AAAA,IAC7B,IAAI,OAAO,IAAI;AAAA,I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AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,eAAW,qCAAuB,QAAQ,WAAW,cAAc;AAAA,IACpE,CAAC;AAAA,EACH;AACA,WAAS,mBAAmB,SAA0D;AACrF,UAAM,iBAAiB,CAAC,GAAG,cAAc,wBAAwB;AACjE,WAAO,CAAC,OACP,GAAG,SAAS;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,eAAW,qCAAuB,QAAQ,WAAW,cAAc;AAAA,IACpE,CAAC;AAAA,EACH;AACA,WAAS,oBAAoB,SAA0D;AACtF,UAAM,iBAAiB,CAAC,GAAG,cAAc,wBAAwB;AACjE,WAAO,CAAC,OACP,GAAG,SAAS;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,eAAW,qCAAuB,QAAQ,WAAW,cAAc;AAAA,IACpE,CAAC;AAAA,EACH;AACA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -11,15 +11,11 @@ import type { BlobMetadata, EncodingType } from './utils/bcs.js';
|
|
|
11
11
|
* This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.
|
|
12
12
|
*/
|
|
13
13
|
export interface WalrusPackageConfig {
|
|
14
|
-
/** The package ID of the Walrus package */
|
|
15
|
-
packageId: string;
|
|
16
|
-
latestPackageId: string;
|
|
17
14
|
/** The system object ID of the Walrus package */
|
|
18
15
|
systemObjectId: string;
|
|
19
16
|
/** The staking pool ID of the Walrus package */
|
|
20
17
|
stakingPoolId: string;
|
|
21
|
-
|
|
22
|
-
walPackageId: string;
|
|
18
|
+
subsidiesObjectId?: string;
|
|
23
19
|
exchange?: {
|
|
24
20
|
packageId: string;
|
|
25
21
|
exchangeIds: string[];
|
|
@@ -33,7 +29,7 @@ type SuiClientOrRpcUrl = {
|
|
|
33
29
|
suiClient?: never;
|
|
34
30
|
};
|
|
35
31
|
type WalrusNetworkOrPackageConfig = {
|
|
36
|
-
network: 'testnet';
|
|
32
|
+
network: 'mainnet' | 'testnet';
|
|
37
33
|
packageConfig?: WalrusPackageConfig;
|
|
38
34
|
} | {
|
|
39
35
|
network?: never;
|
|
@@ -64,6 +60,8 @@ export interface StorageWithSizeOptions {
|
|
|
64
60
|
size: number;
|
|
65
61
|
/** The number of epoch the storage will be reserved for. */
|
|
66
62
|
epochs: number;
|
|
63
|
+
/** Owner of the storage object. */
|
|
64
|
+
owner: string;
|
|
67
65
|
/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */
|
|
68
66
|
walCoin?: TransactionObjectArgument;
|
|
69
67
|
}
|
|
@@ -154,6 +152,7 @@ export interface DeleteBlobOptions {
|
|
|
154
152
|
}
|
|
155
153
|
export type ExtendBlobOptions = {
|
|
156
154
|
blobObjectId: string;
|
|
155
|
+
owner: string;
|
|
157
156
|
/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */
|
|
158
157
|
walCoin?: TransactionObjectArgument;
|
|
159
158
|
} & ({
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/storage_node.js';\nimport type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';\nimport type {\n\tStorageConfirmation,\n\tStoreBlobMetadataRequestInput,\n\tStoreSliverRequestInput,\n\tUploadable,\n} from './storage-node/types.js';\nimport type { BlobMetadata, EncodingType } from './utils/bcs.js';\n\n/**\n * Configuration for the Walrus package on sui\n *\n * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.\n */\nexport interface WalrusPackageConfig {\n\t/** The
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { StorageNodeInfo } from './contracts/storage_node.js';\nimport type { RequestOptions, StorageNodeClientOptions } from './storage-node/client.js';\nimport type {\n\tStorageConfirmation,\n\tStoreBlobMetadataRequestInput,\n\tStoreSliverRequestInput,\n\tUploadable,\n} from './storage-node/types.js';\nimport type { BlobMetadata, EncodingType } from './utils/bcs.js';\n\n/**\n * Configuration for the Walrus package on sui\n *\n * This is used to configure the Walrus package to use a specific package ID, system object ID, staking pool ID, and WAL package ID.\n */\nexport interface WalrusPackageConfig {\n\t/** The system object ID of the Walrus package */\n\tsystemObjectId: string;\n\t/** The staking pool ID of the Walrus package */\n\tstakingPoolId: string;\n\tsubsidiesObjectId?: string;\n\texchange?: {\n\t\tpackageId: string;\n\t\texchangeIds: string[];\n\t};\n}\n\ntype SuiClientOrRpcUrl =\n\t| {\n\t\t\tsuiClient: SuiClient;\n\t\t\tsuiRpcUrl?: never;\n\t }\n\t| {\n\t\t\tsuiRpcUrl: string;\n\t\t\tsuiClient?: never;\n\t };\n\ntype WalrusNetworkOrPackageConfig =\n\t| {\n\t\t\tnetwork: 'mainnet' | 'testnet';\n\t\t\tpackageConfig?: WalrusPackageConfig;\n\t }\n\t| {\n\t\t\tnetwork?: never;\n\t\t\tpackageConfig: WalrusPackageConfig;\n\t };\n\n/**\n * Configuration for the Walrus client.\n *\n * This is used to configure the Walrus client to use a specific storage node client options, network, and Sui client or RPC URL.\n */\nexport type WalrusClientConfig = {\n\tstorageNodeClientOptions?: StorageNodeClientOptions;\n} & WalrusNetworkOrPackageConfig &\n\tSuiClientOrRpcUrl;\n\nexport type WalrusClientRequestOptions = Pick<RequestOptions, 'signal'>;\n\nexport interface StorageNode {\n\tnetworkUrl: string;\n\tinfo: ReturnType<typeof StorageNodeInfo>['$inferType'];\n\tshardIndices: number[];\n\tnodeIndex: number;\n\tid: string;\n}\n\nexport interface CommitteeInfo {\n\tbyShardIndex: Map<number, StorageNode>;\n\tnodes: StorageNode[];\n}\n\nexport interface StorageWithSizeOptions {\n\t/** The encoded size of the blob. */\n\tsize: number;\n\t/** The number of epoch the storage will be reserved for. */\n\tepochs: number;\n\t/** Owner of the storage object. */\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n}\n\nexport interface RegisterBlobOptions extends StorageWithSizeOptions {\n\tblobId: string;\n\trootHash: Uint8Array;\n\tdeletable: boolean;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n}\n\nexport interface CertifyBlobOptions {\n\tblobId: string;\n\tblobObjectId: string;\n\t/** An array of confirmations.\n\t * These confirmations must be provided in the same order as the nodes in the committee.\n\t * For nodes that have not provided a confirmation you can pass `null` */\n\tconfirmations: (StorageConfirmation | null)[];\n\tdeletable: boolean;\n}\n\ntype DeletableConfirmationOptions =\n\t| { deletable: false; objectId?: string }\n\t| { deletable: true; objectId: string };\n\nexport type GetStorageConfirmationOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type ReadBlobOptions = {\n\tblobId: string;\n} & WalrusClientRequestOptions;\n\nexport type GetCertificationEpochOptions = ReadBlobOptions;\n\nexport type GetBlobMetadataOptions = ReadBlobOptions;\n\nexport type GetSliversOptions = ReadBlobOptions;\n\nexport type GetVerifiedBlobStatusOptions = ReadBlobOptions;\n\nexport interface SliversForNode {\n\tprimary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n\tsecondary: {\n\t\tsliverIndex: number;\n\t\tsliverPairIndex: number;\n\t\tshardIndex: number;\n\t\tsliver: Uint8Array;\n\t}[];\n}\n\nexport type WriteSliversToNodeOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tslivers: SliversForNode;\n} & WalrusClientRequestOptions;\n\nexport type WriteSliverOptions = StoreSliverRequestInput & WalrusClientRequestOptions;\n\nexport type WriteMetadataOptions = {\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n} & StoreBlobMetadataRequestInput &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobOptions = {\n\tblobId: string;\n\tnodeIndex: number;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tslivers: SliversForNode;\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteEncodedBlobToNodesOptions = {\n\tblobId: string;\n\tmetadata: Uploadable | typeof BlobMetadata.$inferInput;\n\tsliversByNode: SliversForNode[];\n} & DeletableConfirmationOptions &\n\tWalrusClientRequestOptions;\n\nexport type WriteBlobOptions = {\n\tblob: Uint8Array;\n\tdeletable: boolean;\n\t/** The number of epochs the blob should be stored for. */\n\tepochs: number;\n\tsigner: Signer;\n\t/** Where the blob should be transferred to after it is registered. Defaults to the signer address. */\n\towner?: string;\n\t/** The attributes to write for the blob. */\n\tattributes?: Record<string, string | null>;\n} & WalrusClientRequestOptions;\n\nexport interface DeleteBlobOptions {\n\tblobObjectId: string;\n}\n\nexport type ExtendBlobOptions = {\n\tblobObjectId: string;\n\towner: string;\n\t/** optionally specify a WAL coin pay for the registration. This will consume WAL from the signer by default. */\n\twalCoin?: TransactionObjectArgument;\n} & (\n\t| {\n\t\t\t/** The number of epochs the blob should be stored for. */\n\t\t\tepochs: number;\n\t\t\tendEpoch?: never;\n\t }\n\t| {\n\t\t\t/** The new end epoch for the storage period of the blob. */\n\t\t\tendEpoch: number;\n\t\t\tepochs?: never;\n\t }\n);\n\nexport type WriteBlobAttributesOptions = {\n\tattributes: Record<string, string | null>;\n} & (\n\t| {\n\t\t\tblobObject: TransactionObjectArgument;\n\t\t\tblobObjectId?: never;\n\t }\n\t| {\n\t\t\tblobObjectId: string;\n\t\t\tblobObject?: never;\n\t }\n);\n\nexport type EncodingType = Extract<typeof EncodingType.$inferInput, string>;\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InferBcsType } from '@mysten/bcs';
|
|
2
|
+
import type { SuiMoveNormalizedType } from '@mysten/sui/client';
|
|
2
3
|
import type { Committee } from '../contracts/committee.js';
|
|
3
4
|
import type { EncodingType } from '../types.js';
|
|
4
5
|
export declare function encodedBlobLength(unencodedLength: number, nShards: number, encodingType?: EncodingType): number;
|
|
@@ -16,3 +17,4 @@ export declare function signersToBitmap(signers: number[], committeeSize: number
|
|
|
16
17
|
export declare function getShardIndicesByNodeId(committee: InferBcsType<ReturnType<typeof Committee>>): Map<string, number[]>;
|
|
17
18
|
export declare function nodesByShardIndex(committee: InferBcsType<ReturnType<typeof Committee>>): Map<number, string>;
|
|
18
19
|
export declare function chunk<T>(array: T[], size: number): T[][];
|
|
20
|
+
export declare function toTypeString(type: SuiMoveNormalizedType): string;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -29,7 +29,8 @@ __export(utils_exports, {
|
|
|
29
29
|
signersToBitmap: () => signersToBitmap,
|
|
30
30
|
storageUnitsFromSize: () => storageUnitsFromSize,
|
|
31
31
|
toPairIndex: () => toPairIndex,
|
|
32
|
-
toShardIndex: () => toShardIndex
|
|
32
|
+
toShardIndex: () => toShardIndex,
|
|
33
|
+
toTypeString: () => toTypeString
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(utils_exports);
|
|
35
36
|
var import_bcs = require("./bcs.js");
|
|
@@ -124,4 +125,48 @@ function chunk(array, size) {
|
|
|
124
125
|
return array.slice(i * size, (i + 1) * size);
|
|
125
126
|
});
|
|
126
127
|
}
|
|
128
|
+
function toTypeString(type) {
|
|
129
|
+
if (typeof type === "string") {
|
|
130
|
+
switch (type) {
|
|
131
|
+
case "Address":
|
|
132
|
+
return "address";
|
|
133
|
+
case "Bool":
|
|
134
|
+
return "bool";
|
|
135
|
+
case "U8":
|
|
136
|
+
return "u8";
|
|
137
|
+
case "U16":
|
|
138
|
+
return "u16";
|
|
139
|
+
case "U32":
|
|
140
|
+
return "u32";
|
|
141
|
+
case "U64":
|
|
142
|
+
return "u64";
|
|
143
|
+
case "U128":
|
|
144
|
+
return "u128";
|
|
145
|
+
case "U256":
|
|
146
|
+
return "u256";
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unexpected type ${type}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if ("Vector" in type) {
|
|
152
|
+
return `vector<${toTypeString(type.Vector)}>`;
|
|
153
|
+
}
|
|
154
|
+
if ("Struct" in type) {
|
|
155
|
+
if (type.Struct.typeArguments.length > 0) {
|
|
156
|
+
return `${type.Struct.address}::${type.Struct.module}::${type.Struct.name}<${type.Struct.typeArguments.map(toTypeString).join(",")}>`;
|
|
157
|
+
} else {
|
|
158
|
+
return `${type.Struct.address}::${type.Struct.module}::${type.Struct.name}`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if ("TypeParameter" in type) {
|
|
162
|
+
throw new Error(`Type parameters can't be converted to type strings`);
|
|
163
|
+
}
|
|
164
|
+
if ("Reference" in type) {
|
|
165
|
+
return toTypeString(type.Reference);
|
|
166
|
+
}
|
|
167
|
+
if ("MutableReference" in type) {
|
|
168
|
+
return toTypeString(type.MutableReference);
|
|
169
|
+
}
|
|
170
|
+
throw new Error(`Unexpected type ${JSON.stringify(type)}`);
|
|
171
|
+
}
|
|
127
172
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\n\nimport type { Committee } from '../contracts/committee.js';\nimport type { EncodingType } from '../types.js';\nimport { BlobId } from './bcs.js';\n\nconst DIGEST_LEN = 32;\nconst BLOB_ID_LEN = 32;\n\nexport function encodedBlobLength(\n\tunencodedLength: number,\n\tnShards: number,\n\tencodingType: EncodingType = 'RS2',\n): number {\n\tconst { primarySymbols, secondarySymbols } = getSourceSymbols(nShards, encodingType);\n\n\tlet size =\n\t\tMath.floor((Math.max(unencodedLength, 1) - 1) / (primarySymbols * secondarySymbols)) + 1;\n\n\tif (encodingType === 'RS2' && size % 2 === 1) {\n\t\tsize = size + 1;\n\t}\n\n\tconst sliversSize = (primarySymbols + secondarySymbols) * size * nShards;\n\tconst metadata = nShards * DIGEST_LEN * 2 + BLOB_ID_LEN;\n\treturn nShards * metadata + sliversSize;\n}\n\nexport function getSourceSymbols(nShards: number, encodingType: EncodingType = 'RS2') {\n\tconst safetyLimit = decodingSafetyLimit(nShards, encodingType);\n\tconst maxFaulty = getMaxFaultyNodes(nShards);\n\tconst minCorrect = nShards - maxFaulty;\n\n\treturn {\n\t\tprimarySymbols: minCorrect - maxFaulty - safetyLimit,\n\t\tsecondarySymbols: minCorrect - safetyLimit,\n\t};\n}\n\nexport function isQuorum(size: number, nShards: number): boolean {\n\tconst maxFaulty = getMaxFaultyNodes(nShards);\n\treturn size > 2 * maxFaulty;\n}\n\nexport function isAboveValidity(size: number, nShards: number): boolean {\n\tconst maxFaulty = getMaxFaultyNodes(nShards);\n\treturn size > maxFaulty;\n}\n\nexport function getMaxFaultyNodes(nShards: number): number {\n\treturn Math.floor((nShards - 1) / 3);\n}\n\nfunction decodingSafetyLimit(nShards: number, encodingType: EncodingType): number {\n\tswitch (encodingType) {\n\t\tcase 'RedStuff':\n\t\t\treturn Math.min(5, Math.floor(getMaxFaultyNodes(nShards) / 5));\n\t\tcase 'RS2':\n\t\t\treturn 0;\n\t\tdefault:\n\t\t\tthrow new Error(`Encountered unknown encoding type of ${encodingType}`);\n\t}\n}\n\nconst BYTES_PER_UNIT_SIZE = 1024 * 1024;\n\nexport function storageUnitsFromSize(size: number): number {\n\treturn Math.ceil(size / BYTES_PER_UNIT_SIZE);\n}\n\nfunction rotationOffset(bytes: Uint8Array, modulus: number): number {\n\treturn bytes.reduce((acc, byte) => (acc * 256 + byte) % modulus, 0);\n}\n\nexport function toShardIndex(sliverPairIndex: number, blobId: string, numShards: number): number {\n\tconst offset = rotationOffset(BlobId.serialize(blobId).toBytes(), numShards);\n\treturn (sliverPairIndex + offset) % numShards;\n}\n\nexport function toPairIndex(shardIndex: number, blobId: string, numShards: number): number {\n\tconst offset = rotationOffset(BlobId.serialize(blobId).toBytes(), numShards);\n\treturn (numShards + shardIndex - offset) % numShards;\n}\n\nexport function signersToBitmap(signers: number[], committeeSize: number): Uint8Array {\n\tconst bitmapSize = Math.ceil(committeeSize / 8);\n\tconst bitmap = new Uint8Array(bitmapSize);\n\n\tfor (const signer of signers) {\n\t\tconst byteIndex = Math.floor(signer / 8);\n\t\tconst bitIndex = signer % 8;\n\t\tbitmap[byteIndex] |= 1 << bitIndex;\n\t}\n\n\treturn bitmap;\n}\n\nexport function getShardIndicesByNodeId(committee: InferBcsType<ReturnType<typeof Committee>>) {\n\tconst shardIndicesByNodeId = new Map<string, number[]>();\n\n\tfor (const node of committee.pos0.contents) {\n\t\tif (!shardIndicesByNodeId.has(node.key)) {\n\t\t\tshardIndicesByNodeId.set(node.key, []);\n\t\t}\n\t\tshardIndicesByNodeId.get(node.key)!.push(...node.value);\n\t}\n\n\treturn shardIndicesByNodeId;\n}\n\nexport function nodesByShardIndex(committee: InferBcsType<ReturnType<typeof Committee>>) {\n\tconst nodesByShardIndex = new Map<number, string>();\n\n\tfor (const node of committee.pos0.contents) {\n\t\tfor (const shardIndex of node.value) {\n\t\t\tnodesByShardIndex.set(shardIndex, node.key);\n\t\t}\n\t}\n\n\treturn nodesByShardIndex;\n}\n\nexport function chunk<T>(array: T[], size: number) {\n\treturn Array.from({ length: Math.ceil(array.length / size) }, (_, i) => {\n\t\treturn array.slice(i * size, (i + 1) * size);\n\t});\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\nimport type { SuiMoveNormalizedType } from '@mysten/sui/client';\n\nimport type { Committee } from '../contracts/committee.js';\nimport type { EncodingType } from '../types.js';\nimport { BlobId } from './bcs.js';\n\nconst DIGEST_LEN = 32;\nconst BLOB_ID_LEN = 32;\n\nexport function encodedBlobLength(\n\tunencodedLength: number,\n\tnShards: number,\n\tencodingType: EncodingType = 'RS2',\n): number {\n\tconst { primarySymbols, secondarySymbols } = getSourceSymbols(nShards, encodingType);\n\n\tlet size =\n\t\tMath.floor((Math.max(unencodedLength, 1) - 1) / (primarySymbols * secondarySymbols)) + 1;\n\n\tif (encodingType === 'RS2' && size % 2 === 1) {\n\t\tsize = size + 1;\n\t}\n\n\tconst sliversSize = (primarySymbols + secondarySymbols) * size * nShards;\n\tconst metadata = nShards * DIGEST_LEN * 2 + BLOB_ID_LEN;\n\treturn nShards * metadata + sliversSize;\n}\n\nexport function getSourceSymbols(nShards: number, encodingType: EncodingType = 'RS2') {\n\tconst safetyLimit = decodingSafetyLimit(nShards, encodingType);\n\tconst maxFaulty = getMaxFaultyNodes(nShards);\n\tconst minCorrect = nShards - maxFaulty;\n\n\treturn {\n\t\tprimarySymbols: minCorrect - maxFaulty - safetyLimit,\n\t\tsecondarySymbols: minCorrect - safetyLimit,\n\t};\n}\n\nexport function isQuorum(size: number, nShards: number): boolean {\n\tconst maxFaulty = getMaxFaultyNodes(nShards);\n\treturn size > 2 * maxFaulty;\n}\n\nexport function isAboveValidity(size: number, nShards: number): boolean {\n\tconst maxFaulty = getMaxFaultyNodes(nShards);\n\treturn size > maxFaulty;\n}\n\nexport function getMaxFaultyNodes(nShards: number): number {\n\treturn Math.floor((nShards - 1) / 3);\n}\n\nfunction decodingSafetyLimit(nShards: number, encodingType: EncodingType): number {\n\tswitch (encodingType) {\n\t\tcase 'RedStuff':\n\t\t\treturn Math.min(5, Math.floor(getMaxFaultyNodes(nShards) / 5));\n\t\tcase 'RS2':\n\t\t\treturn 0;\n\t\tdefault:\n\t\t\tthrow new Error(`Encountered unknown encoding type of ${encodingType}`);\n\t}\n}\n\nconst BYTES_PER_UNIT_SIZE = 1024 * 1024;\n\nexport function storageUnitsFromSize(size: number): number {\n\treturn Math.ceil(size / BYTES_PER_UNIT_SIZE);\n}\n\nfunction rotationOffset(bytes: Uint8Array, modulus: number): number {\n\treturn bytes.reduce((acc, byte) => (acc * 256 + byte) % modulus, 0);\n}\n\nexport function toShardIndex(sliverPairIndex: number, blobId: string, numShards: number): number {\n\tconst offset = rotationOffset(BlobId.serialize(blobId).toBytes(), numShards);\n\treturn (sliverPairIndex + offset) % numShards;\n}\n\nexport function toPairIndex(shardIndex: number, blobId: string, numShards: number): number {\n\tconst offset = rotationOffset(BlobId.serialize(blobId).toBytes(), numShards);\n\treturn (numShards + shardIndex - offset) % numShards;\n}\n\nexport function signersToBitmap(signers: number[], committeeSize: number): Uint8Array {\n\tconst bitmapSize = Math.ceil(committeeSize / 8);\n\tconst bitmap = new Uint8Array(bitmapSize);\n\n\tfor (const signer of signers) {\n\t\tconst byteIndex = Math.floor(signer / 8);\n\t\tconst bitIndex = signer % 8;\n\t\tbitmap[byteIndex] |= 1 << bitIndex;\n\t}\n\n\treturn bitmap;\n}\n\nexport function getShardIndicesByNodeId(committee: InferBcsType<ReturnType<typeof Committee>>) {\n\tconst shardIndicesByNodeId = new Map<string, number[]>();\n\n\tfor (const node of committee.pos0.contents) {\n\t\tif (!shardIndicesByNodeId.has(node.key)) {\n\t\t\tshardIndicesByNodeId.set(node.key, []);\n\t\t}\n\t\tshardIndicesByNodeId.get(node.key)!.push(...node.value);\n\t}\n\n\treturn shardIndicesByNodeId;\n}\n\nexport function nodesByShardIndex(committee: InferBcsType<ReturnType<typeof Committee>>) {\n\tconst nodesByShardIndex = new Map<number, string>();\n\n\tfor (const node of committee.pos0.contents) {\n\t\tfor (const shardIndex of node.value) {\n\t\t\tnodesByShardIndex.set(shardIndex, node.key);\n\t\t}\n\t}\n\n\treturn nodesByShardIndex;\n}\n\nexport function chunk<T>(array: T[], size: number) {\n\treturn Array.from({ length: Math.ceil(array.length / size) }, (_, i) => {\n\t\treturn array.slice(i * size, (i + 1) * size);\n\t});\n}\n\nexport function toTypeString(type: SuiMoveNormalizedType): string {\n\tif (typeof type === 'string') {\n\t\tswitch (type) {\n\t\t\tcase 'Address':\n\t\t\t\treturn 'address';\n\t\t\tcase 'Bool':\n\t\t\t\treturn 'bool';\n\t\t\tcase 'U8':\n\t\t\t\treturn 'u8';\n\t\t\tcase 'U16':\n\t\t\t\treturn 'u16';\n\t\t\tcase 'U32':\n\t\t\t\treturn 'u32';\n\t\t\tcase 'U64':\n\t\t\t\treturn 'u64';\n\t\t\tcase 'U128':\n\t\t\t\treturn 'u128';\n\t\t\tcase 'U256':\n\t\t\t\treturn 'u256';\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unexpected type ${type}`);\n\t\t}\n\t}\n\n\tif ('Vector' in type) {\n\t\treturn `vector<${toTypeString(type.Vector)}>`;\n\t}\n\n\tif ('Struct' in type) {\n\t\tif (type.Struct.typeArguments.length > 0) {\n\t\t\treturn `${type.Struct.address}::${type.Struct.module}::${type.Struct.name}<${type.Struct.typeArguments.map(toTypeString).join(',')}>`;\n\t\t} else {\n\t\t\treturn `${type.Struct.address}::${type.Struct.module}::${type.Struct.name}`;\n\t\t}\n\t}\n\n\tif ('TypeParameter' in type) {\n\t\tthrow new Error(`Type parameters can't be converted to type strings`);\n\t}\n\n\tif ('Reference' in type) {\n\t\treturn toTypeString(type.Reference);\n\t}\n\n\tif ('MutableReference' in type) {\n\t\treturn toTypeString(type.MutableReference);\n\t}\n\n\tthrow new Error(`Unexpected type ${JSON.stringify(type)}`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,iBAAuB;AAEvB,MAAM,aAAa;AACnB,MAAM,cAAc;AAEb,SAAS,kBACf,iBACA,SACA,eAA6B,OACpB;AACT,QAAM,EAAE,gBAAgB,iBAAiB,IAAI,iBAAiB,SAAS,YAAY;AAEnF,MAAI,OACH,KAAK,OAAO,KAAK,IAAI,iBAAiB,CAAC,IAAI,MAAM,iBAAiB,iBAAiB,IAAI;AAExF,MAAI,iBAAiB,SAAS,OAAO,MAAM,GAAG;AAC7C,WAAO,OAAO;AAAA,EACf;AAEA,QAAM,eAAe,iBAAiB,oBAAoB,OAAO;AACjE,QAAM,WAAW,UAAU,aAAa,IAAI;AAC5C,SAAO,UAAU,WAAW;AAC7B;AAEO,SAAS,iBAAiB,SAAiB,eAA6B,OAAO;AACrF,QAAM,cAAc,oBAAoB,SAAS,YAAY;AAC7D,QAAM,YAAY,kBAAkB,OAAO;AAC3C,QAAM,aAAa,UAAU;AAE7B,SAAO;AAAA,IACN,gBAAgB,aAAa,YAAY;AAAA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ACrB,WAAO,UAAU,aAAa,KAAK,MAAM,CAAC;AAAA,EAC3C;AAEA,MAAI,YAAY,MAAM;AACrB,QAAI,KAAK,OAAO,cAAc,SAAS,GAAG;AACzC,aAAO,GAAG,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,cAAc,IAAI,YAAY,EAAE,KAAK,GAAG,CAAC;AAAA,IACnI,OAAO;AACN,aAAO,GAAG,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO,MAAM,KAAK,KAAK,OAAO,IAAI;AAAA,IAC1E;AAAA,EACD;AAEA,MAAI,mBAAmB,MAAM;AAC5B,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACrE;AAEA,MAAI,eAAe,MAAM;AACxB,WAAO,aAAa,KAAK,SAAS;AAAA,EACnC;AAEA,MAAI,sBAAsB,MAAM;AAC/B,WAAO,aAAa,KAAK,gBAAgB;AAAA,EAC1C;AAEA,QAAM,IAAI,MAAM,mBAAmB,KAAK,UAAU,IAAI,CAAC,EAAE;AAC1D;",
|
|
6
6
|
"names": ["nodesByShardIndex"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
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);
|
|
25
|
+
var memo_exports = {};
|
|
26
|
+
__export(memo_exports, {
|
|
27
|
+
MemoCache: () => MemoCache
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(memo_exports);
|
|
30
|
+
var _methods, _cache;
|
|
31
|
+
class MemoCache {
|
|
32
|
+
constructor() {
|
|
33
|
+
__privateAdd(this, _methods, /* @__PURE__ */ new Set());
|
|
34
|
+
__privateAdd(this, _cache, /* @__PURE__ */ new Map());
|
|
35
|
+
}
|
|
36
|
+
create(key, fn) {
|
|
37
|
+
if (__privateGet(this, _methods).has(key)) {
|
|
38
|
+
throw new Error(`Method ${key} already exists`);
|
|
39
|
+
}
|
|
40
|
+
__privateGet(this, _methods).add(key);
|
|
41
|
+
return () => {
|
|
42
|
+
if (__privateGet(this, _cache).has(key)) {
|
|
43
|
+
return __privateGet(this, _cache).get(key);
|
|
44
|
+
}
|
|
45
|
+
const promise = fn();
|
|
46
|
+
__privateGet(this, _cache).set(key, promise);
|
|
47
|
+
promise.then((val) => __privateGet(this, _cache).set(key, val)).catch(() => {
|
|
48
|
+
__privateGet(this, _cache).delete(key);
|
|
49
|
+
});
|
|
50
|
+
return promise;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
reset() {
|
|
54
|
+
__privateGet(this, _cache).clear();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
_methods = new WeakMap();
|
|
58
|
+
_cache = new WeakMap();
|
|
59
|
+
//# sourceMappingURL=memo.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/memo.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport class MemoCache {\n\t#methods = new Set<string>();\n\t#cache: Map<string, unknown> = new Map();\n\n\tcreate<R>(key: string, fn: () => Promise<R>) {\n\t\tif (this.#methods.has(key)) {\n\t\t\tthrow new Error(`Method ${key} already exists`);\n\t\t}\n\n\t\tthis.#methods.add(key);\n\n\t\treturn (): R | Promise<R> => {\n\t\t\tif (this.#cache.has(key)) {\n\t\t\t\treturn this.#cache.get(key) as Promise<R>;\n\t\t\t}\n\n\t\t\tconst promise = fn();\n\t\t\tthis.#cache.set(key, promise);\n\n\t\t\tpromise\n\t\t\t\t.then((val) => this.#cache.set(key, val))\n\t\t\t\t.catch(() => {\n\t\t\t\t\tthis.#cache.delete(key);\n\t\t\t\t});\n\n\t\t\treturn promise;\n\t\t};\n\t}\n\n\treset() {\n\t\tthis.#cache.clear();\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAAA,EAAhB;AACN,iCAAW,oBAAI,IAAY;AAC3B,+BAA+B,oBAAI,IAAI;AAAA;AAAA,EAEvC,OAAU,KAAa,IAAsB;AAC5C,QAAI,mBAAK,UAAS,IAAI,GAAG,GAAG;AAC3B,YAAM,IAAI,MAAM,UAAU,GAAG,iBAAiB;AAAA,IAC/C;AAEA,uBAAK,UAAS,IAAI,GAAG;AAErB,WAAO,MAAsB;AAC5B,UAAI,mBAAK,QAAO,IAAI,GAAG,GAAG;AACzB,eAAO,mBAAK,QAAO,IAAI,GAAG;AAAA,MAC3B;AAEA,YAAM,UAAU,GAAG;AACnB,yBAAK,QAAO,IAAI,KAAK,OAAO;AAE5B,cACE,KAAK,CAAC,QAAQ,mBAAK,QAAO,IAAI,KAAK,GAAG,CAAC,EACvC,MAAM,MAAM;AACZ,2BAAK,QAAO,OAAO,GAAG;AAAA,MACvB,CAAC;AAEF,aAAO;AAAA,IACR;AAAA,EACD;AAAA,EAEA,QAAQ;AACP,uBAAK,QAAO,MAAM;AAAA,EACnB;AACD;AA/BC;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -50,8 +50,8 @@ class SuiObjectDataLoader extends import_dataloader.default {
|
|
|
50
50
|
const objects = await suiClient.multiGetObjects({
|
|
51
51
|
ids,
|
|
52
52
|
options: {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
showType: true,
|
|
54
|
+
showBcs: true
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
return objects.map((object, i) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/object-loader.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/bcs';\nimport { pureBcsSchemaFromTypeName } from '@mysten/sui/bcs';\nimport type { PureTypeName, ShapeFromPureTypeName } from '@mysten/sui/bcs';\nimport type { SuiClient, SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';\nimport { deriveDynamicFieldID } from '@mysten/sui/utils';\nimport DataLoader from 'dataloader';\n\nimport { Field } from '../contracts/deps/0x0000000000000000000000000000000000000000000000000000000000000002/dynamic_field.js';\n\nexport class SuiObjectDataLoader extends DataLoader<string, SuiObjectData> {\n\t#dynamicFieldCache = new Map<string, Map<string, SuiObjectData>>();\n\tconstructor(suiClient: SuiClient) {\n\t\tsuper(\n\t\t\tasync (ids: readonly string[]) => {\n\t\t\t\tconst objects = await suiClient.multiGetObjects({\n\t\t\t\t\tids: ids as string[],\n\t\t\t\t\toptions: {\n\t\t\t\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAA0C;AAG1C,mBAAqC;AACrC,wBAAuB;AAEvB,2BAAsB;AAVtB;AAYO,MAAM,4BAA4B,kBAAAA,QAAkC;AAAA,EAE1E,YAAY,WAAsB;AACjC;AAAA,MACC,OAAO,QAA2B;AACjC,cAAM,UAAU,MAAM,UAAU,gBAAgB;AAAA,UAC/C;AAAA,UACA,SAAS;AAAA,YACR,
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType } from '@mysten/bcs';\nimport { pureBcsSchemaFromTypeName } from '@mysten/sui/bcs';\nimport type { PureTypeName, ShapeFromPureTypeName } from '@mysten/sui/bcs';\nimport type { SuiClient, SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';\nimport { deriveDynamicFieldID } from '@mysten/sui/utils';\nimport DataLoader from 'dataloader';\n\nimport { Field } from '../contracts/deps/0x0000000000000000000000000000000000000000000000000000000000000002/dynamic_field.js';\n\nexport class SuiObjectDataLoader extends DataLoader<string, SuiObjectData> {\n\t#dynamicFieldCache = new Map<string, Map<string, SuiObjectData>>();\n\tconstructor(suiClient: SuiClient) {\n\t\tsuper(\n\t\t\tasync (ids: readonly string[]) => {\n\t\t\t\tconst objects = await suiClient.multiGetObjects({\n\t\t\t\t\tids: ids as string[],\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tshowType: true,\n\t\t\t\t\t\tshowBcs: true,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\treturn objects.map((object, i) => {\n\t\t\t\t\treturn this.#getObjectFromResponse(ids[i], object);\n\t\t\t\t});\n\t\t\t},\n\t\t\t{\n\t\t\t\tmaxBatchSize: 50,\n\t\t\t},\n\t\t);\n\t}\n\n\toverride async load<T = SuiObjectData>(id: string, schema?: BcsType<T, any>): Promise<T> {\n\t\tconst data = await super.load(id);\n\n\t\tif (schema) {\n\t\t\tif (data.bcs?.dataType !== 'moveObject') {\n\t\t\t\tthrow new Error(`Object ${id} is not a move object`);\n\t\t\t}\n\n\t\t\treturn schema.fromBase64(data.bcs.bcsBytes);\n\t\t}\n\n\t\treturn data as T;\n\t}\n\n\toverride async loadMany<T = SuiObjectData>(\n\t\tids: string[],\n\t\tschema?: BcsType<T, any>,\n\t): Promise<(T | Error)[]> {\n\t\tconst data = await super.loadMany(ids);\n\n\t\tif (!schema) {\n\t\t\treturn data as (T | Error)[];\n\t\t}\n\n\t\treturn data.map((d, i) => {\n\t\t\tif (d instanceof Error) {\n\t\t\t\treturn d;\n\t\t\t}\n\n\t\t\tif (d.bcs?.dataType !== 'moveObject') {\n\t\t\t\treturn new Error(`Object ${ids[i]} is not a move object`);\n\t\t\t}\n\n\t\t\treturn schema.fromBase64(d.bcs.bcsBytes);\n\t\t});\n\t}\n\n\tasync loadManyOrThrow<T>(ids: string[], schema: BcsType<T, any>): Promise<T[]> {\n\t\tconst data = await this.loadMany(ids, schema);\n\n\t\tfor (const d of data) {\n\t\t\tif (d instanceof Error) {\n\t\t\t\tthrow d;\n\t\t\t}\n\t\t}\n\n\t\treturn data as T[];\n\t}\n\n\toverride clearAll() {\n\t\tthis.#dynamicFieldCache.clear();\n\t\treturn super.clearAll();\n\t}\n\n\toverride clear(key: string) {\n\t\tthis.#dynamicFieldCache.delete(key);\n\t\treturn super.clear(key);\n\t}\n\n\t#getObjectFromResponse(id: string, response: SuiObjectResponse) {\n\t\tif (response.error || !response.data) {\n\t\t\tthrow new Error(`Failed to fetch object ${id}: ${response.error}`);\n\t\t}\n\n\t\treturn response.data;\n\t}\n\n\tasync loadFieldObject<K extends PureTypeName, T>(\n\t\tparent: string,\n\t\tname: {\n\t\t\ttype: K;\n\t\t\tvalue: ShapeFromPureTypeName<K>;\n\t\t},\n\t\ttype: BcsType<T, any>,\n\t): Promise<T> {\n\t\tconst schema = pureBcsSchemaFromTypeName<K>(name.type as never);\n\t\tconst id = deriveDynamicFieldID(parent, 'u64', schema.serialize(name.value).toBytes());\n\n\t\treturn (await this.load(id, Field(schema, type))).value;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAA0C;AAG1C,mBAAqC;AACrC,wBAAuB;AAEvB,2BAAsB;AAVtB;AAYO,MAAM,4BAA4B,kBAAAA,QAAkC;AAAA,EAE1E,YAAY,WAAsB;AACjC;AAAA,MACC,OAAO,QAA2B;AACjC,cAAM,UAAU,MAAM,UAAU,gBAAgB;AAAA,UAC/C;AAAA,UACA,SAAS;AAAA,YACR,UAAU;AAAA,YACV,SAAS;AAAA,UACV;AAAA,QACD,CAAC;AAED,eAAO,QAAQ,IAAI,CAAC,QAAQ,MAAM;AACjC,iBAAO,sBAAK,0DAAL,WAA4B,IAAI,CAAC,GAAG;AAAA,QAC5C,CAAC;AAAA,MACF;AAAA,MACA;AAAA,QACC,cAAc;AAAA,MACf;AAAA,IACD;AApBK;AACN,2CAAqB,oBAAI,IAAwC;AAAA,EAoBjE;AAAA,EAEA,MAAe,KAAwB,IAAY,QAAsC;AACxF,UAAM,OAAO,MAAM,MAAM,KAAK,EAAE;AAEhC,QAAI,QAAQ;AACX,UAAI,KAAK,KAAK,aAAa,cAAc;AACxC,cAAM,IAAI,MAAM,UAAU,EAAE,uBAAuB;AAAA,MACpD;AAEA,aAAO,OAAO,WAAW,KAAK,IAAI,QAAQ;AAAA,IAC3C;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,MAAe,SACd,KACA,QACyB;AACzB,UAAM,OAAO,MAAM,MAAM,SAAS,GAAG;AAErC,QAAI,CAAC,QAAQ;AACZ,aAA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