@mysten/zksend 0.9.10 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -6
- package/dist/cjs/links/builder.js +43 -57
- package/dist/cjs/links/builder.js.map +2 -2
- package/dist/cjs/links/claim.js +39 -68
- package/dist/cjs/links/claim.js.map +2 -2
- package/dist/cjs/links/get-sent-transactions.js.map +2 -2
- package/dist/cjs/links/list-created-links.js.map +1 -1
- package/dist/cjs/links/zk-bag.d.ts +14 -14
- package/dist/cjs/links/zk-bag.js +59 -62
- package/dist/cjs/links/zk-bag.js.map +2 -2
- package/dist/cjs/wallet/channel/events.d.ts +78 -283
- package/dist/cjs/wallet/channel/events.js +3 -3
- package/dist/cjs/wallet/channel/events.js.map +2 -2
- package/dist/cjs/wallet/channel/index.d.ts +3 -3
- package/dist/cjs/wallet/channel/index.js +25 -40
- package/dist/cjs/wallet/channel/index.js.map +2 -2
- package/dist/cjs/wallet/index.js +19 -33
- package/dist/cjs/wallet/index.js.map +1 -1
- package/dist/esm/links/builder.js +42 -56
- package/dist/esm/links/builder.js.map +2 -2
- package/dist/esm/links/claim.js +38 -67
- package/dist/esm/links/claim.js.map +2 -2
- package/dist/esm/links/get-sent-transactions.js.map +2 -2
- package/dist/esm/links/list-created-links.js.map +1 -1
- package/dist/esm/links/zk-bag.d.ts +14 -14
- package/dist/esm/links/zk-bag.js +58 -61
- package/dist/esm/links/zk-bag.js.map +2 -2
- package/dist/esm/wallet/channel/events.d.ts +78 -283
- package/dist/esm/wallet/channel/events.js +4 -4
- package/dist/esm/wallet/channel/events.js.map +2 -2
- package/dist/esm/wallet/channel/index.d.ts +3 -3
- package/dist/esm/wallet/channel/index.js +24 -39
- package/dist/esm/wallet/channel/index.js.map +2 -2
- package/dist/esm/wallet/index.js +18 -32
- package/dist/esm/wallet/index.js.map +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mysten/zksend
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0f27a97: Update dependencies
|
|
8
|
+
- Updated dependencies [7fc464a]
|
|
9
|
+
- Updated dependencies [086b2bc]
|
|
10
|
+
- Updated dependencies [0fb0628]
|
|
11
|
+
- Updated dependencies [cdedf69]
|
|
12
|
+
- Updated dependencies [0f27a97]
|
|
13
|
+
- Updated dependencies [beed646]
|
|
14
|
+
- @mysten/sui@1.3.0
|
|
15
|
+
- @mysten/wallet-standard@0.12.12
|
|
16
|
+
|
|
17
|
+
## 0.10.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 45877014d1: Update ZkBag class to return functions to improve compatibility with new plugin API
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [06a900c1ab]
|
|
26
|
+
- Updated dependencies [45877014d1]
|
|
27
|
+
- Updated dependencies [87d6f75403]
|
|
28
|
+
- @mysten/sui@1.2.1
|
|
29
|
+
- @mysten/wallet-standard@0.12.11
|
|
30
|
+
|
|
3
31
|
## 0.9.10
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -84,8 +112,10 @@
|
|
|
84
112
|
|
|
85
113
|
### Minor Changes
|
|
86
114
|
|
|
87
|
-
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
88
|
-
|
|
115
|
+
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
116
|
+
and breaking changes. See the
|
|
117
|
+
[full migration guide](https://sdk.mystenlabs.com/typescript/migrations/sui-1.0) for details on
|
|
118
|
+
how to upgrade.
|
|
89
119
|
|
|
90
120
|
### Patch Changes
|
|
91
121
|
|
|
@@ -152,7 +182,8 @@
|
|
|
152
182
|
|
|
153
183
|
### Patch Changes
|
|
154
184
|
|
|
155
|
-
- 9a9ff3cde1: Fix assets extracted from transactionBlocks using type instead of objectType from
|
|
185
|
+
- 9a9ff3cde1: Fix assets extracted from transactionBlocks using type instead of objectType from
|
|
186
|
+
object changes"
|
|
156
187
|
|
|
157
188
|
## 0.5.0
|
|
158
189
|
|
|
@@ -195,7 +226,8 @@
|
|
|
195
226
|
|
|
196
227
|
### Minor Changes
|
|
197
228
|
|
|
198
|
-
- c05a4e8cb7: removed listClaimableAssets, and added new assets and claimed properties to link
|
|
229
|
+
- c05a4e8cb7: removed listClaimableAssets, and added new assets and claimed properties to link
|
|
230
|
+
instances
|
|
199
231
|
- c05a4e8cb7: Use contract by default for new links
|
|
200
232
|
- c05a4e8cb7: Add helper for bulk link creation
|
|
201
233
|
- c05a4e8cb7: Removed options for filtering claims
|
|
@@ -227,7 +259,8 @@
|
|
|
227
259
|
### Patch Changes
|
|
228
260
|
|
|
229
261
|
- 4830361fa4: Updated typescript version
|
|
230
|
-
- 4fd676671b: Fix issue with overwriting balances when adding multiple balances for the same
|
|
262
|
+
- 4fd676671b: Fix issue with overwriting balances when adding multiple balances for the same
|
|
263
|
+
unnormalized coinType"
|
|
231
264
|
- Updated dependencies [4830361fa4]
|
|
232
265
|
- @mysten/wallet-standard@0.10.3
|
|
233
266
|
- @mysten/sui.js@0.50.1
|
|
@@ -257,7 +290,8 @@
|
|
|
257
290
|
- 66fbbc7faa: Detect gasCoin when claiming
|
|
258
291
|
- 7b8d044603: Detect wallet closing
|
|
259
292
|
- c6b3066069: Improve zkSend error messages
|
|
260
|
-
- a2904e0075: Fix for claimable assets not accounting for cases where claimable balance comes from
|
|
293
|
+
- a2904e0075: Fix for claimable assets not accounting for cases where claimable balance comes from
|
|
294
|
+
gas coin
|
|
261
295
|
- ea2744b0c3: Add redirect parameter and fix listing assets on links without Sui
|
|
262
296
|
- 44a1f9ea0b: Tweak types of events sent over the bridge
|
|
263
297
|
- 7cc09a7bb4: Handle cases where list of objects to transfer is empty
|
|
@@ -3,6 +3,9 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,28 +19,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __accessCheck = (obj, member, msg) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
__accessCheck(obj, member, "read from private field");
|
|
25
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
26
|
-
};
|
|
27
|
-
var __privateAdd = (obj, member, value) => {
|
|
28
|
-
if (member.has(obj))
|
|
29
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
30
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
31
|
-
};
|
|
32
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
33
|
-
__accessCheck(obj, member, "write to private field");
|
|
34
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
35
|
-
return value;
|
|
36
|
-
};
|
|
37
|
-
var __privateMethod = (obj, member, method) => {
|
|
38
|
-
__accessCheck(obj, member, "access private method");
|
|
39
|
-
return method;
|
|
40
|
-
};
|
|
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 __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
26
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
41
27
|
var builder_exports = {};
|
|
42
28
|
__export(builder_exports, {
|
|
43
29
|
ZkSendLinkBuilder: () => ZkSendLinkBuilder
|
|
@@ -49,14 +35,14 @@ var import_ed25519 = require("@mysten/sui/keypairs/ed25519");
|
|
|
49
35
|
var import_transactions = require("@mysten/sui/transactions");
|
|
50
36
|
var import_utils = require("@mysten/sui/utils");
|
|
51
37
|
var import_zk_bag = require("./zk-bag.js");
|
|
52
|
-
var _host, _path, _client, _redirect, _coinsByType, _contract,
|
|
38
|
+
var _host, _path, _client, _redirect, _coinsByType, _contract, _ZkSendLinkBuilder_instances, objectsToTransfer_fn, createSendTransactionWithoutContract_fn, estimateClaimGasFee_fn, getCoinsByType_fn;
|
|
53
39
|
const DEFAULT_ZK_SEND_LINK_OPTIONS = {
|
|
54
40
|
host: "https://zksend.com",
|
|
55
41
|
path: "/claim",
|
|
56
42
|
network: "mainnet"
|
|
57
43
|
};
|
|
58
44
|
const SUI_COIN_TYPE = (0, import_utils.normalizeStructTag)(import_utils.SUI_TYPE_ARG);
|
|
59
|
-
const _ZkSendLinkBuilder = class {
|
|
45
|
+
const _ZkSendLinkBuilder = class _ZkSendLinkBuilder {
|
|
60
46
|
constructor({
|
|
61
47
|
host = DEFAULT_ZK_SEND_LINK_OPTIONS.host,
|
|
62
48
|
path = DEFAULT_ZK_SEND_LINK_OPTIONS.path,
|
|
@@ -67,19 +53,16 @@ const _ZkSendLinkBuilder = class {
|
|
|
67
53
|
redirect,
|
|
68
54
|
contract = network === "mainnet" ? import_zk_bag.MAINNET_CONTRACT_IDS : void 0
|
|
69
55
|
}) {
|
|
70
|
-
__privateAdd(this,
|
|
71
|
-
__privateAdd(this, _createSendTransactionWithoutContract);
|
|
72
|
-
__privateAdd(this, _estimateClaimGasFee);
|
|
73
|
-
__privateAdd(this, _getCoinsByType);
|
|
56
|
+
__privateAdd(this, _ZkSendLinkBuilder_instances);
|
|
74
57
|
this.objectIds = /* @__PURE__ */ new Set();
|
|
75
58
|
this.objectRefs = [];
|
|
76
59
|
this.balances = /* @__PURE__ */ new Map();
|
|
77
|
-
__privateAdd(this, _host
|
|
78
|
-
__privateAdd(this, _path
|
|
79
|
-
__privateAdd(this, _client
|
|
80
|
-
__privateAdd(this, _redirect
|
|
60
|
+
__privateAdd(this, _host);
|
|
61
|
+
__privateAdd(this, _path);
|
|
62
|
+
__privateAdd(this, _client);
|
|
63
|
+
__privateAdd(this, _redirect);
|
|
81
64
|
__privateAdd(this, _coinsByType, /* @__PURE__ */ new Map());
|
|
82
|
-
__privateAdd(this, _contract
|
|
65
|
+
__privateAdd(this, _contract);
|
|
83
66
|
__privateSet(this, _host, host);
|
|
84
67
|
__privateSet(this, _path, path);
|
|
85
68
|
__privateSet(this, _redirect, redirect);
|
|
@@ -136,7 +119,7 @@ const _ZkSendLinkBuilder = class {
|
|
|
136
119
|
calculateGas
|
|
137
120
|
} = {}) {
|
|
138
121
|
if (!__privateGet(this, _contract)) {
|
|
139
|
-
return __privateMethod(this,
|
|
122
|
+
return __privateMethod(this, _ZkSendLinkBuilder_instances, createSendTransactionWithoutContract_fn).call(this, { transaction, calculateGas });
|
|
140
123
|
}
|
|
141
124
|
transaction.setSenderIfNotSet(this.sender);
|
|
142
125
|
return _ZkSendLinkBuilder.createLinks({
|
|
@@ -150,7 +133,7 @@ const _ZkSendLinkBuilder = class {
|
|
|
150
133
|
transaction = new import_transactions.Transaction(),
|
|
151
134
|
address
|
|
152
135
|
}) {
|
|
153
|
-
const objectsToTransfer = (await __privateMethod(this,
|
|
136
|
+
const objectsToTransfer = (await __privateMethod(this, _ZkSendLinkBuilder_instances, objectsToTransfer_fn).call(this, transaction)).map((obj) => obj.ref);
|
|
154
137
|
transaction.setSenderIfNotSet(this.sender);
|
|
155
138
|
transaction.transferObjects(objectsToTransfer, address);
|
|
156
139
|
return transaction;
|
|
@@ -227,22 +210,26 @@ const _ZkSendLinkBuilder = class {
|
|
|
227
210
|
}
|
|
228
211
|
for (const link of links) {
|
|
229
212
|
const receiver = link.keypair.toSuiAddress();
|
|
230
|
-
contract.new(
|
|
213
|
+
transaction.add(contract.new({ arguments: [store, receiver] }));
|
|
231
214
|
link.objectRefs.forEach(({ ref, type }) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
215
|
+
transaction.add(
|
|
216
|
+
contract.add({
|
|
217
|
+
arguments: [store, receiver, ref],
|
|
218
|
+
typeArguments: [type]
|
|
219
|
+
})
|
|
220
|
+
);
|
|
236
221
|
});
|
|
237
222
|
link.objectIds.forEach((id) => {
|
|
238
223
|
const object = objectRefs.get(id);
|
|
239
224
|
if (!object) {
|
|
240
225
|
throw new Error(`Object ${id} not found`);
|
|
241
226
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
227
|
+
transaction.add(
|
|
228
|
+
contract.add({
|
|
229
|
+
arguments: [store, receiver, object.ref],
|
|
230
|
+
typeArguments: [object.type]
|
|
231
|
+
})
|
|
232
|
+
);
|
|
246
233
|
});
|
|
247
234
|
}
|
|
248
235
|
for (const [coinType, merged] of mergedCoins) {
|
|
@@ -253,23 +240,24 @@ const _ZkSendLinkBuilder = class {
|
|
|
253
240
|
const balances = linksWithCoin.map((link) => link.balances.get(coinType));
|
|
254
241
|
const splits = transaction.splitCoins(merged, balances);
|
|
255
242
|
for (const [i, link] of linksWithCoin.entries()) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
243
|
+
transaction.add(
|
|
244
|
+
contract.add({
|
|
245
|
+
arguments: [store, link.keypair.toSuiAddress(), splits[i]],
|
|
246
|
+
typeArguments: [`0x2::coin::Coin<${coinType}>`]
|
|
247
|
+
})
|
|
248
|
+
);
|
|
260
249
|
}
|
|
261
250
|
}
|
|
262
251
|
return transaction;
|
|
263
252
|
}
|
|
264
253
|
};
|
|
265
|
-
let ZkSendLinkBuilder = _ZkSendLinkBuilder;
|
|
266
254
|
_host = new WeakMap();
|
|
267
255
|
_path = new WeakMap();
|
|
268
256
|
_client = new WeakMap();
|
|
269
257
|
_redirect = new WeakMap();
|
|
270
258
|
_coinsByType = new WeakMap();
|
|
271
259
|
_contract = new WeakMap();
|
|
272
|
-
|
|
260
|
+
_ZkSendLinkBuilder_instances = new WeakSet();
|
|
273
261
|
objectsToTransfer_fn = async function(tx) {
|
|
274
262
|
const objectIDs = [...this.objectIds];
|
|
275
263
|
const refsWithType = this.objectRefs.concat(
|
|
@@ -300,7 +288,7 @@ objectsToTransfer_fn = async function(tx) {
|
|
|
300
288
|
type: `0x2::coin::Coin<${coinType}>`
|
|
301
289
|
});
|
|
302
290
|
} else {
|
|
303
|
-
const coins = (await __privateMethod(this,
|
|
291
|
+
const coins = (await __privateMethod(this, _ZkSendLinkBuilder_instances, getCoinsByType_fn).call(this, coinType)).map((coin) => coin.coinObjectId);
|
|
304
292
|
if (coins.length > 1) {
|
|
305
293
|
tx.mergeCoins(coins[0], coins.slice(1));
|
|
306
294
|
}
|
|
@@ -313,12 +301,11 @@ objectsToTransfer_fn = async function(tx) {
|
|
|
313
301
|
}
|
|
314
302
|
return refsWithType;
|
|
315
303
|
};
|
|
316
|
-
_createSendTransactionWithoutContract = new WeakSet();
|
|
317
304
|
createSendTransactionWithoutContract_fn = async function({
|
|
318
305
|
transaction: tx = new import_transactions.Transaction(),
|
|
319
306
|
calculateGas
|
|
320
307
|
} = {}) {
|
|
321
|
-
const gasEstimateFromDryRun = await __privateMethod(this,
|
|
308
|
+
const gasEstimateFromDryRun = await __privateMethod(this, _ZkSendLinkBuilder_instances, estimateClaimGasFee_fn).call(this);
|
|
322
309
|
const baseGasAmount = calculateGas ? await calculateGas({
|
|
323
310
|
balances: this.balances,
|
|
324
311
|
objects: [...this.objectIds],
|
|
@@ -327,14 +314,13 @@ createSendTransactionWithoutContract_fn = async function({
|
|
|
327
314
|
const gasWithBuffer = baseGasAmount + 1013n;
|
|
328
315
|
const roundedGasAmount = gasWithBuffer - gasWithBuffer % 1000n - 13n;
|
|
329
316
|
const address = this.keypair.toSuiAddress();
|
|
330
|
-
const objectsToTransfer = (await __privateMethod(this,
|
|
317
|
+
const objectsToTransfer = (await __privateMethod(this, _ZkSendLinkBuilder_instances, objectsToTransfer_fn).call(this, tx)).map((obj) => obj.ref);
|
|
331
318
|
const [gas] = tx.splitCoins(tx.gas, [roundedGasAmount]);
|
|
332
319
|
objectsToTransfer.push(gas);
|
|
333
320
|
tx.setSenderIfNotSet(this.sender);
|
|
334
321
|
tx.transferObjects(objectsToTransfer, address);
|
|
335
322
|
return tx;
|
|
336
323
|
};
|
|
337
|
-
_estimateClaimGasFee = new WeakSet();
|
|
338
324
|
estimateClaimGasFee_fn = async function() {
|
|
339
325
|
const tx = new import_transactions.Transaction();
|
|
340
326
|
tx.setSender(this.sender);
|
|
@@ -342,7 +328,7 @@ estimateClaimGasFee_fn = async function() {
|
|
|
342
328
|
tx.transferObjects([tx.gas], this.keypair.toSuiAddress());
|
|
343
329
|
const idsToTransfer = [...this.objectIds];
|
|
344
330
|
for (const [coinType] of this.balances) {
|
|
345
|
-
const coins = await __privateMethod(this,
|
|
331
|
+
const coins = await __privateMethod(this, _ZkSendLinkBuilder_instances, getCoinsByType_fn).call(this, coinType);
|
|
346
332
|
if (!coins.length) {
|
|
347
333
|
throw new Error(`Sending account does not contain any coins of type ${coinType}`);
|
|
348
334
|
}
|
|
@@ -359,7 +345,6 @@ estimateClaimGasFee_fn = async function() {
|
|
|
359
345
|
});
|
|
360
346
|
return BigInt(result.effects.gasUsed.computationCost) + BigInt(result.effects.gasUsed.storageCost) - BigInt(result.effects.gasUsed.storageRebate);
|
|
361
347
|
};
|
|
362
|
-
_getCoinsByType = new WeakSet();
|
|
363
348
|
getCoinsByType_fn = async function(coinType) {
|
|
364
349
|
if (__privateGet(this, _coinsByType).has(coinType)) {
|
|
365
350
|
return __privateGet(this, _coinsByType).get(coinType);
|
|
@@ -371,4 +356,5 @@ getCoinsByType_fn = async function(coinType) {
|
|
|
371
356
|
__privateGet(this, _coinsByType).set(coinType, coins.data);
|
|
372
357
|
return coins.data;
|
|
373
358
|
};
|
|
359
|
+
let ZkSendLinkBuilder = _ZkSendLinkBuilder;
|
|
374
360
|
//# sourceMappingURL=builder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/links/builder.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui/client';\nimport type { CoinStruct } from '@mysten/sui/client';\nimport { decodeSuiPrivateKey } from '@mysten/sui/cryptography';\nimport type { Keypair, Signer } from '@mysten/sui/cryptography';\nimport { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';\nimport type { TransactionObjectArgument, TransactionObjectInput } from '@mysten/sui/transactions';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress, SUI_TYPE_ARG, toB64 } from '@mysten/sui/utils';\n\nimport type { ZkBagContractOptions } from './zk-bag.js';\nimport { MAINNET_CONTRACT_IDS, ZkBag } from './zk-bag.js';\n\ninterface ZkSendLinkRedirect {\n\turl: string;\n\tname?: string;\n}\n\nexport interface ZkSendLinkBuilderOptions {\n\thost?: string;\n\tpath?: string;\n\tkeypair?: Keypair;\n\tnetwork?: 'mainnet' | 'testnet';\n\tclient?: SuiClient;\n\tsender: string;\n\tredirect?: ZkSendLinkRedirect;\n\tcontract?: ZkBagContractOptions | null;\n}\n\nconst DEFAULT_ZK_SEND_LINK_OPTIONS = {\n\thost: 'https://zksend.com',\n\tpath: '/claim',\n\tnetwork: 'mainnet' as const,\n};\n\nconst SUI_COIN_TYPE = normalizeStructTag(SUI_TYPE_ARG);\n\nexport interface CreateZkSendLinkOptions {\n\ttransaction?: Transaction;\n\tcalculateGas?: (options: {\n\t\tbalances: Map<string, bigint>;\n\t\tobjects: TransactionObjectInput[];\n\t\tgasEstimateFromDryRun: bigint;\n\t}) => Promise<bigint> | bigint;\n}\n\nexport class ZkSendLinkBuilder {\n\tobjectIds = new Set<string>();\n\tobjectRefs: {\n\t\tref: TransactionObjectArgument;\n\t\ttype: string;\n\t}[] = [];\n\tbalances = new Map<string, bigint>();\n\tsender: string;\n\t#host: string;\n\t#path: string;\n\tkeypair: Keypair;\n\t#client: SuiClient;\n\t#redirect?: ZkSendLinkRedirect;\n\t#coinsByType = new Map<string, CoinStruct[]>();\n\t#contract?: ZkBag<ZkBagContractOptions>;\n\n\tconstructor({\n\t\thost = DEFAULT_ZK_SEND_LINK_OPTIONS.host,\n\t\tpath = DEFAULT_ZK_SEND_LINK_OPTIONS.path,\n\t\tkeypair = new Ed25519Keypair(),\n\t\tnetwork = DEFAULT_ZK_SEND_LINK_OPTIONS.network,\n\t\tclient = new SuiClient({ url: getFullnodeUrl(network) }),\n\t\tsender,\n\t\tredirect,\n\t\tcontract = network === 'mainnet' ? MAINNET_CONTRACT_IDS : undefined,\n\t}: ZkSendLinkBuilderOptions) {\n\t\tthis.#host = host;\n\t\tthis.#path = path;\n\t\tthis.#redirect = redirect;\n\t\tthis.keypair = keypair;\n\t\tthis.#client = client;\n\t\tthis.sender = normalizeSuiAddress(sender);\n\n\t\tif (contract) {\n\t\t\tthis.#contract = new ZkBag(contract.packageId, contract);\n\t\t}\n\t}\n\n\taddClaimableMist(amount: bigint) {\n\t\tthis.addClaimableBalance(SUI_COIN_TYPE, amount);\n\t}\n\n\taddClaimableBalance(coinType: string, amount: bigint) {\n\t\tconst normalizedType = normalizeStructTag(coinType);\n\t\tthis.balances.set(normalizedType, (this.balances.get(normalizedType) ?? 0n) + amount);\n\t}\n\n\taddClaimableObject(id: string) {\n\t\tthis.objectIds.add(id);\n\t}\n\n\taddClaimableObjectRef(ref: TransactionObjectArgument, type: string) {\n\t\tthis.objectRefs.push({ ref, type });\n\t}\n\n\tgetLink(): string {\n\t\tconst link = new URL(this.#host);\n\t\tlink.pathname = this.#path;\n\t\tlink.hash = `${this.#contract ? '$' : ''}${toB64(\n\t\t\tdecodeSuiPrivateKey(this.keypair.getSecretKey()).secretKey,\n\t\t)}`;\n\n\t\tif (this.#redirect) {\n\t\t\tlink.searchParams.set('redirect_url', this.#redirect.url);\n\t\t\tif (this.#redirect.name) {\n\t\t\t\tlink.searchParams.set('name', this.#redirect.name);\n\t\t\t}\n\t\t}\n\n\t\treturn link.toString();\n\t}\n\n\tasync create({\n\t\tsigner,\n\t\t...options\n\t}: CreateZkSendLinkOptions & {\n\t\tsigner: Signer;\n\t\twaitForTransaction?: boolean;\n\t}) {\n\t\tconst tx = await this.createSendTransaction(options);\n\n\t\tconst result = await this.#client.signAndExecuteTransaction({\n\t\t\ttransaction: await tx.build({ client: this.#client }),\n\t\t\tsigner,\n\t\t});\n\n\t\tif (options.waitForTransaction) {\n\t\t\tawait this.#client.waitForTransaction({ digest: result.digest });\n\t\t}\n\n\t\treturn result;\n\t}\n\tasync createSendTransaction({\n\t\ttransaction = new Transaction(),\n\t\tcalculateGas,\n\t}: CreateZkSendLinkOptions = {}) {\n\t\tif (!this.#contract) {\n\t\t\treturn this.#createSendTransactionWithoutContract({ transaction, calculateGas });\n\t\t}\n\n\t\ttransaction.setSenderIfNotSet(this.sender);\n\n\t\treturn ZkSendLinkBuilder.createLinks({\n\t\t\ttransaction,\n\t\t\tclient: this.#client,\n\t\t\tcontract: this.#contract.ids,\n\t\t\tlinks: [this],\n\t\t});\n\t}\n\n\tasync createSendToAddressTransaction({\n\t\ttransaction = new Transaction(),\n\t\taddress,\n\t}: CreateZkSendLinkOptions & {\n\t\taddress: string;\n\t}) {\n\t\tconst objectsToTransfer = (await this.#objectsToTransfer(transaction)).map((obj) => obj.ref);\n\n\t\ttransaction.setSenderIfNotSet(this.sender);\n\t\ttransaction.transferObjects(objectsToTransfer, address);\n\n\t\treturn transaction;\n\t}\n\n\tasync #objectsToTransfer(tx: Transaction) {\n\t\tconst objectIDs = [...this.objectIds];\n\t\tconst refsWithType = this.objectRefs.concat(\n\t\t\t(objectIDs.length > 0\n\t\t\t\t? await this.#client.multiGetObjects({\n\t\t\t\t\t\tids: objectIDs,\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tshowType: true,\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: []\n\t\t\t).map((res, i) => {\n\t\t\t\tif (!res.data || res.error) {\n\t\t\t\t\tthrow new Error(`Failed to load object ${objectIDs[i]} (${res.error?.code})`);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tref: tx.objectRef({\n\t\t\t\t\t\tversion: res.data.version,\n\t\t\t\t\t\tdigest: res.data.digest,\n\t\t\t\t\t\tobjectId: res.data.objectId,\n\t\t\t\t\t}),\n\t\t\t\t\ttype: res.data.type!,\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\n\t\tfor (const [coinType, amount] of this.balances) {\n\t\t\tif (coinType === SUI_COIN_TYPE) {\n\t\t\t\tconst [sui] = tx.splitCoins(tx.gas, [amount]);\n\t\t\t\trefsWithType.push({\n\t\t\t\t\tref: sui,\n\t\t\t\t\ttype: `0x2::coin::Coin<${coinType}>`,\n\t\t\t\t} as never);\n\t\t\t} else {\n\t\t\t\tconst coins = (await this.#getCoinsByType(coinType)).map((coin) => coin.coinObjectId);\n\n\t\t\t\tif (coins.length > 1) {\n\t\t\t\t\ttx.mergeCoins(coins[0], coins.slice(1));\n\t\t\t\t}\n\t\t\t\tconst [split] = tx.splitCoins(coins[0], [amount]);\n\t\t\t\trefsWithType.push({\n\t\t\t\t\tref: split,\n\t\t\t\t\ttype: `0x2::coin::Coin<${coinType}>`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn refsWithType;\n\t}\n\n\tasync #createSendTransactionWithoutContract({\n\t\ttransaction: tx = new Transaction(),\n\t\tcalculateGas,\n\t}: CreateZkSendLinkOptions = {}) {\n\t\tconst gasEstimateFromDryRun = await this.#estimateClaimGasFee();\n\t\tconst baseGasAmount = calculateGas\n\t\t\t? await calculateGas({\n\t\t\t\t\tbalances: this.balances,\n\t\t\t\t\tobjects: [...this.objectIds],\n\t\t\t\t\tgasEstimateFromDryRun,\n\t\t\t })\n\t\t\t: gasEstimateFromDryRun * 2n;\n\n\t\t// Ensure that rounded gas is not less than the calculated gas\n\t\tconst gasWithBuffer = baseGasAmount + 1013n;\n\t\t// Ensure that gas amount ends in 987\n\t\tconst roundedGasAmount = gasWithBuffer - (gasWithBuffer % 1000n) - 13n;\n\n\t\tconst address = this.keypair.toSuiAddress();\n\t\tconst objectsToTransfer = (await this.#objectsToTransfer(tx)).map((obj) => obj.ref);\n\t\tconst [gas] = tx.splitCoins(tx.gas, [roundedGasAmount]);\n\t\tobjectsToTransfer.push(gas);\n\n\t\ttx.setSenderIfNotSet(this.sender);\n\t\ttx.transferObjects(objectsToTransfer, address);\n\n\t\treturn tx;\n\t}\n\n\tasync #estimateClaimGasFee(): Promise<bigint> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.sender);\n\t\ttx.setGasPayment([]);\n\t\ttx.transferObjects([tx.gas], this.keypair.toSuiAddress());\n\n\t\tconst idsToTransfer = [...this.objectIds];\n\n\t\tfor (const [coinType] of this.balances) {\n\t\t\tconst coins = await this.#getCoinsByType(coinType);\n\n\t\t\tif (!coins.length) {\n\t\t\t\tthrow new Error(`Sending account does not contain any coins of type ${coinType}`);\n\t\t\t}\n\n\t\t\tidsToTransfer.push(coins[0].coinObjectId);\n\t\t}\n\n\t\tif (idsToTransfer.length > 0) {\n\t\t\ttx.transferObjects(\n\t\t\t\tidsToTransfer.map((id) => tx.object(id)),\n\t\t\t\tthis.keypair.toSuiAddress(),\n\t\t\t);\n\t\t}\n\n\t\tconst result = await this.#client.dryRunTransactionBlock({\n\t\t\ttransactionBlock: await tx.build({ client: this.#client }),\n\t\t});\n\n\t\treturn (\n\t\t\tBigInt(result.effects.gasUsed.computationCost) +\n\t\t\tBigInt(result.effects.gasUsed.storageCost) -\n\t\t\tBigInt(result.effects.gasUsed.storageRebate)\n\t\t);\n\t}\n\n\tasync #getCoinsByType(coinType: string) {\n\t\tif (this.#coinsByType.has(coinType)) {\n\t\t\treturn this.#coinsByType.get(coinType)!;\n\t\t}\n\n\t\tconst coins = await this.#client.getCoins({\n\t\t\tcoinType,\n\t\t\towner: this.sender,\n\t\t});\n\n\t\tthis.#coinsByType.set(coinType, coins.data);\n\n\t\treturn coins.data;\n\t}\n\n\tstatic async createLinks({\n\t\tlinks,\n\t\tnetwork = 'mainnet',\n\t\tclient = new SuiClient({ url: getFullnodeUrl(network) }),\n\t\ttransaction = new Transaction(),\n\t\tcontract: contractIds = MAINNET_CONTRACT_IDS,\n\t}: {\n\t\ttransaction?: Transaction;\n\t\tclient?: SuiClient;\n\t\tnetwork?: 'mainnet' | 'testnet';\n\t\tlinks: ZkSendLinkBuilder[];\n\t\tcontract?: ZkBagContractOptions;\n\t}) {\n\t\tconst contract = new ZkBag(contractIds.packageId, contractIds);\n\t\tconst store = transaction.object(contract.ids.bagStoreId);\n\n\t\tconst coinsByType = new Map<string, CoinStruct[]>();\n\t\tconst allIds = links.flatMap((link) => [...link.objectIds]);\n\t\tconst sender = links[0].sender;\n\t\ttransaction.setSenderIfNotSet(sender);\n\n\t\tawait Promise.all(\n\t\t\t[...new Set(links.flatMap((link) => [...link.balances.keys()]))].map(async (coinType) => {\n\t\t\t\tconst coins = await client.getCoins({\n\t\t\t\t\tcoinType,\n\t\t\t\t\towner: sender,\n\t\t\t\t});\n\n\t\t\t\tcoinsByType.set(\n\t\t\t\t\tcoinType,\n\t\t\t\t\tcoins.data.filter((coin) => !allIds.includes(coin.coinObjectId)),\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\n\t\tconst objectRefs = new Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tref: TransactionObjectArgument;\n\t\t\t\ttype: string;\n\t\t\t}\n\t\t>();\n\n\t\tconst pageSize = 50;\n\t\tlet offset = 0;\n\t\twhile (offset < allIds.length) {\n\t\t\tlet chunk = allIds.slice(offset, offset + pageSize);\n\t\t\toffset += pageSize;\n\n\t\t\tconst objects = await client.multiGetObjects({\n\t\t\t\tids: chunk,\n\t\t\t\toptions: {\n\t\t\t\t\tshowType: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tfor (const [i, res] of objects.entries()) {\n\t\t\t\tif (!res.data || res.error) {\n\t\t\t\t\tthrow new Error(`Failed to load object ${chunk[i]} (${res.error?.code})`);\n\t\t\t\t}\n\t\t\t\tobjectRefs.set(chunk[i], {\n\t\t\t\t\tref: transaction.objectRef({\n\t\t\t\t\t\tversion: res.data.version,\n\t\t\t\t\t\tdigest: res.data.digest,\n\t\t\t\t\t\tobjectId: res.data.objectId,\n\t\t\t\t\t}),\n\t\t\t\t\ttype: res.data.type!,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst mergedCoins = new Map<string, TransactionObjectArgument>([\n\t\t\t[SUI_COIN_TYPE, transaction.gas],\n\t\t]);\n\n\t\tfor (const [coinType, coins] of coinsByType) {\n\t\t\tif (coinType === SUI_COIN_TYPE) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst [first, ...rest] = coins.map((coin) =>\n\t\t\t\ttransaction.objectRef({\n\t\t\t\t\tobjectId: coin.coinObjectId,\n\t\t\t\t\tversion: coin.version,\n\t\t\t\t\tdigest: coin.digest,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (rest.length > 0) {\n\t\t\t\ttransaction.mergeCoins(first, rest);\n\t\t\t}\n\t\t\tmergedCoins.set(coinType, transaction.object(first));\n\t\t}\n\n\t\tfor (const link of links) {\n\t\t\tconst receiver = link.keypair.toSuiAddress();\n\t\t\tcontract.new(transaction, { arguments: [store, receiver] });\n\n\t\t\tlink.objectRefs.forEach(({ ref, type }) => {\n\t\t\t\tcontract.add(transaction, {\n\t\t\t\t\targuments: [store, receiver, ref],\n\t\t\t\t\ttypeArguments: [type],\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlink.objectIds.forEach((id) => {\n\t\t\t\tconst object = objectRefs.get(id);\n\t\t\t\tif (!object) {\n\t\t\t\t\tthrow new Error(`Object ${id} not found`);\n\t\t\t\t}\n\t\t\t\tcontract.add(transaction, {\n\t\t\t\t\targuments: [store, receiver, object.ref],\n\t\t\t\t\ttypeArguments: [object.type],\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tfor (const [coinType, merged] of mergedCoins) {\n\t\t\tconst linksWithCoin = links.filter((link) => link.balances.has(coinType));\n\t\t\tif (linksWithCoin.length === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst balances = linksWithCoin.map((link) => link.balances.get(coinType)!);\n\t\t\tconst splits = transaction.splitCoins(merged, balances);\n\t\t\tfor (const [i, link] of linksWithCoin.entries()) {\n\t\t\t\tcontract.add(transaction, {\n\t\t\t\t\targuments: [store, link.keypair.toSuiAddress(), splits[i]],\n\t\t\t\t\ttypeArguments: [`0x2::coin::Coin<${coinType}>`],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn transaction;\n\t}\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui/client';\nimport type { CoinStruct } from '@mysten/sui/client';\nimport { decodeSuiPrivateKey } from '@mysten/sui/cryptography';\nimport type { Keypair, Signer } from '@mysten/sui/cryptography';\nimport { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';\nimport type { TransactionObjectArgument, TransactionObjectInput } from '@mysten/sui/transactions';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress, SUI_TYPE_ARG, toB64 } from '@mysten/sui/utils';\n\nimport type { ZkBagContractOptions } from './zk-bag.js';\nimport { MAINNET_CONTRACT_IDS, ZkBag } from './zk-bag.js';\n\ninterface ZkSendLinkRedirect {\n\turl: string;\n\tname?: string;\n}\n\nexport interface ZkSendLinkBuilderOptions {\n\thost?: string;\n\tpath?: string;\n\tkeypair?: Keypair;\n\tnetwork?: 'mainnet' | 'testnet';\n\tclient?: SuiClient;\n\tsender: string;\n\tredirect?: ZkSendLinkRedirect;\n\tcontract?: ZkBagContractOptions | null;\n}\n\nconst DEFAULT_ZK_SEND_LINK_OPTIONS = {\n\thost: 'https://zksend.com',\n\tpath: '/claim',\n\tnetwork: 'mainnet' as const,\n};\n\nconst SUI_COIN_TYPE = normalizeStructTag(SUI_TYPE_ARG);\n\nexport interface CreateZkSendLinkOptions {\n\ttransaction?: Transaction;\n\tcalculateGas?: (options: {\n\t\tbalances: Map<string, bigint>;\n\t\tobjects: TransactionObjectInput[];\n\t\tgasEstimateFromDryRun: bigint;\n\t}) => Promise<bigint> | bigint;\n}\n\nexport class ZkSendLinkBuilder {\n\tobjectIds = new Set<string>();\n\tobjectRefs: {\n\t\tref: TransactionObjectArgument;\n\t\ttype: string;\n\t}[] = [];\n\tbalances = new Map<string, bigint>();\n\tsender: string;\n\t#host: string;\n\t#path: string;\n\tkeypair: Keypair;\n\t#client: SuiClient;\n\t#redirect?: ZkSendLinkRedirect;\n\t#coinsByType = new Map<string, CoinStruct[]>();\n\t#contract?: ZkBag<ZkBagContractOptions>;\n\n\tconstructor({\n\t\thost = DEFAULT_ZK_SEND_LINK_OPTIONS.host,\n\t\tpath = DEFAULT_ZK_SEND_LINK_OPTIONS.path,\n\t\tkeypair = new Ed25519Keypair(),\n\t\tnetwork = DEFAULT_ZK_SEND_LINK_OPTIONS.network,\n\t\tclient = new SuiClient({ url: getFullnodeUrl(network) }),\n\t\tsender,\n\t\tredirect,\n\t\tcontract = network === 'mainnet' ? MAINNET_CONTRACT_IDS : undefined,\n\t}: ZkSendLinkBuilderOptions) {\n\t\tthis.#host = host;\n\t\tthis.#path = path;\n\t\tthis.#redirect = redirect;\n\t\tthis.keypair = keypair;\n\t\tthis.#client = client;\n\t\tthis.sender = normalizeSuiAddress(sender);\n\n\t\tif (contract) {\n\t\t\tthis.#contract = new ZkBag(contract.packageId, contract);\n\t\t}\n\t}\n\n\taddClaimableMist(amount: bigint) {\n\t\tthis.addClaimableBalance(SUI_COIN_TYPE, amount);\n\t}\n\n\taddClaimableBalance(coinType: string, amount: bigint) {\n\t\tconst normalizedType = normalizeStructTag(coinType);\n\t\tthis.balances.set(normalizedType, (this.balances.get(normalizedType) ?? 0n) + amount);\n\t}\n\n\taddClaimableObject(id: string) {\n\t\tthis.objectIds.add(id);\n\t}\n\n\taddClaimableObjectRef(ref: TransactionObjectArgument, type: string) {\n\t\tthis.objectRefs.push({ ref, type });\n\t}\n\n\tgetLink(): string {\n\t\tconst link = new URL(this.#host);\n\t\tlink.pathname = this.#path;\n\t\tlink.hash = `${this.#contract ? '$' : ''}${toB64(\n\t\t\tdecodeSuiPrivateKey(this.keypair.getSecretKey()).secretKey,\n\t\t)}`;\n\n\t\tif (this.#redirect) {\n\t\t\tlink.searchParams.set('redirect_url', this.#redirect.url);\n\t\t\tif (this.#redirect.name) {\n\t\t\t\tlink.searchParams.set('name', this.#redirect.name);\n\t\t\t}\n\t\t}\n\n\t\treturn link.toString();\n\t}\n\n\tasync create({\n\t\tsigner,\n\t\t...options\n\t}: CreateZkSendLinkOptions & {\n\t\tsigner: Signer;\n\t\twaitForTransaction?: boolean;\n\t}) {\n\t\tconst tx = await this.createSendTransaction(options);\n\n\t\tconst result = await this.#client.signAndExecuteTransaction({\n\t\t\ttransaction: await tx.build({ client: this.#client }),\n\t\t\tsigner,\n\t\t});\n\n\t\tif (options.waitForTransaction) {\n\t\t\tawait this.#client.waitForTransaction({ digest: result.digest });\n\t\t}\n\n\t\treturn result;\n\t}\n\tasync createSendTransaction({\n\t\ttransaction = new Transaction(),\n\t\tcalculateGas,\n\t}: CreateZkSendLinkOptions = {}) {\n\t\tif (!this.#contract) {\n\t\t\treturn this.#createSendTransactionWithoutContract({ transaction, calculateGas });\n\t\t}\n\n\t\ttransaction.setSenderIfNotSet(this.sender);\n\n\t\treturn ZkSendLinkBuilder.createLinks({\n\t\t\ttransaction,\n\t\t\tclient: this.#client,\n\t\t\tcontract: this.#contract.ids,\n\t\t\tlinks: [this],\n\t\t});\n\t}\n\n\tasync createSendToAddressTransaction({\n\t\ttransaction = new Transaction(),\n\t\taddress,\n\t}: CreateZkSendLinkOptions & {\n\t\taddress: string;\n\t}) {\n\t\tconst objectsToTransfer = (await this.#objectsToTransfer(transaction)).map((obj) => obj.ref);\n\n\t\ttransaction.setSenderIfNotSet(this.sender);\n\t\ttransaction.transferObjects(objectsToTransfer, address);\n\n\t\treturn transaction;\n\t}\n\n\tasync #objectsToTransfer(tx: Transaction) {\n\t\tconst objectIDs = [...this.objectIds];\n\t\tconst refsWithType = this.objectRefs.concat(\n\t\t\t(objectIDs.length > 0\n\t\t\t\t? await this.#client.multiGetObjects({\n\t\t\t\t\t\tids: objectIDs,\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tshowType: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t: []\n\t\t\t).map((res, i) => {\n\t\t\t\tif (!res.data || res.error) {\n\t\t\t\t\tthrow new Error(`Failed to load object ${objectIDs[i]} (${res.error?.code})`);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tref: tx.objectRef({\n\t\t\t\t\t\tversion: res.data.version,\n\t\t\t\t\t\tdigest: res.data.digest,\n\t\t\t\t\t\tobjectId: res.data.objectId,\n\t\t\t\t\t}),\n\t\t\t\t\ttype: res.data.type!,\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\n\t\tfor (const [coinType, amount] of this.balances) {\n\t\t\tif (coinType === SUI_COIN_TYPE) {\n\t\t\t\tconst [sui] = tx.splitCoins(tx.gas, [amount]);\n\t\t\t\trefsWithType.push({\n\t\t\t\t\tref: sui,\n\t\t\t\t\ttype: `0x2::coin::Coin<${coinType}>`,\n\t\t\t\t} as never);\n\t\t\t} else {\n\t\t\t\tconst coins = (await this.#getCoinsByType(coinType)).map((coin) => coin.coinObjectId);\n\n\t\t\t\tif (coins.length > 1) {\n\t\t\t\t\ttx.mergeCoins(coins[0], coins.slice(1));\n\t\t\t\t}\n\t\t\t\tconst [split] = tx.splitCoins(coins[0], [amount]);\n\t\t\t\trefsWithType.push({\n\t\t\t\t\tref: split,\n\t\t\t\t\ttype: `0x2::coin::Coin<${coinType}>`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn refsWithType;\n\t}\n\n\tasync #createSendTransactionWithoutContract({\n\t\ttransaction: tx = new Transaction(),\n\t\tcalculateGas,\n\t}: CreateZkSendLinkOptions = {}) {\n\t\tconst gasEstimateFromDryRun = await this.#estimateClaimGasFee();\n\t\tconst baseGasAmount = calculateGas\n\t\t\t? await calculateGas({\n\t\t\t\t\tbalances: this.balances,\n\t\t\t\t\tobjects: [...this.objectIds],\n\t\t\t\t\tgasEstimateFromDryRun,\n\t\t\t\t})\n\t\t\t: gasEstimateFromDryRun * 2n;\n\n\t\t// Ensure that rounded gas is not less than the calculated gas\n\t\tconst gasWithBuffer = baseGasAmount + 1013n;\n\t\t// Ensure that gas amount ends in 987\n\t\tconst roundedGasAmount = gasWithBuffer - (gasWithBuffer % 1000n) - 13n;\n\n\t\tconst address = this.keypair.toSuiAddress();\n\t\tconst objectsToTransfer = (await this.#objectsToTransfer(tx)).map((obj) => obj.ref);\n\t\tconst [gas] = tx.splitCoins(tx.gas, [roundedGasAmount]);\n\t\tobjectsToTransfer.push(gas);\n\n\t\ttx.setSenderIfNotSet(this.sender);\n\t\ttx.transferObjects(objectsToTransfer, address);\n\n\t\treturn tx;\n\t}\n\n\tasync #estimateClaimGasFee(): Promise<bigint> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.sender);\n\t\ttx.setGasPayment([]);\n\t\ttx.transferObjects([tx.gas], this.keypair.toSuiAddress());\n\n\t\tconst idsToTransfer = [...this.objectIds];\n\n\t\tfor (const [coinType] of this.balances) {\n\t\t\tconst coins = await this.#getCoinsByType(coinType);\n\n\t\t\tif (!coins.length) {\n\t\t\t\tthrow new Error(`Sending account does not contain any coins of type ${coinType}`);\n\t\t\t}\n\n\t\t\tidsToTransfer.push(coins[0].coinObjectId);\n\t\t}\n\n\t\tif (idsToTransfer.length > 0) {\n\t\t\ttx.transferObjects(\n\t\t\t\tidsToTransfer.map((id) => tx.object(id)),\n\t\t\t\tthis.keypair.toSuiAddress(),\n\t\t\t);\n\t\t}\n\n\t\tconst result = await this.#client.dryRunTransactionBlock({\n\t\t\ttransactionBlock: await tx.build({ client: this.#client }),\n\t\t});\n\n\t\treturn (\n\t\t\tBigInt(result.effects.gasUsed.computationCost) +\n\t\t\tBigInt(result.effects.gasUsed.storageCost) -\n\t\t\tBigInt(result.effects.gasUsed.storageRebate)\n\t\t);\n\t}\n\n\tasync #getCoinsByType(coinType: string) {\n\t\tif (this.#coinsByType.has(coinType)) {\n\t\t\treturn this.#coinsByType.get(coinType)!;\n\t\t}\n\n\t\tconst coins = await this.#client.getCoins({\n\t\t\tcoinType,\n\t\t\towner: this.sender,\n\t\t});\n\n\t\tthis.#coinsByType.set(coinType, coins.data);\n\n\t\treturn coins.data;\n\t}\n\n\tstatic async createLinks({\n\t\tlinks,\n\t\tnetwork = 'mainnet',\n\t\tclient = new SuiClient({ url: getFullnodeUrl(network) }),\n\t\ttransaction = new Transaction(),\n\t\tcontract: contractIds = MAINNET_CONTRACT_IDS,\n\t}: {\n\t\ttransaction?: Transaction;\n\t\tclient?: SuiClient;\n\t\tnetwork?: 'mainnet' | 'testnet';\n\t\tlinks: ZkSendLinkBuilder[];\n\t\tcontract?: ZkBagContractOptions;\n\t}) {\n\t\tconst contract = new ZkBag(contractIds.packageId, contractIds);\n\t\tconst store = transaction.object(contract.ids.bagStoreId);\n\n\t\tconst coinsByType = new Map<string, CoinStruct[]>();\n\t\tconst allIds = links.flatMap((link) => [...link.objectIds]);\n\t\tconst sender = links[0].sender;\n\t\ttransaction.setSenderIfNotSet(sender);\n\n\t\tawait Promise.all(\n\t\t\t[...new Set(links.flatMap((link) => [...link.balances.keys()]))].map(async (coinType) => {\n\t\t\t\tconst coins = await client.getCoins({\n\t\t\t\t\tcoinType,\n\t\t\t\t\towner: sender,\n\t\t\t\t});\n\n\t\t\t\tcoinsByType.set(\n\t\t\t\t\tcoinType,\n\t\t\t\t\tcoins.data.filter((coin) => !allIds.includes(coin.coinObjectId)),\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\n\t\tconst objectRefs = new Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tref: TransactionObjectArgument;\n\t\t\t\ttype: string;\n\t\t\t}\n\t\t>();\n\n\t\tconst pageSize = 50;\n\t\tlet offset = 0;\n\t\twhile (offset < allIds.length) {\n\t\t\tlet chunk = allIds.slice(offset, offset + pageSize);\n\t\t\toffset += pageSize;\n\n\t\t\tconst objects = await client.multiGetObjects({\n\t\t\t\tids: chunk,\n\t\t\t\toptions: {\n\t\t\t\t\tshowType: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tfor (const [i, res] of objects.entries()) {\n\t\t\t\tif (!res.data || res.error) {\n\t\t\t\t\tthrow new Error(`Failed to load object ${chunk[i]} (${res.error?.code})`);\n\t\t\t\t}\n\t\t\t\tobjectRefs.set(chunk[i], {\n\t\t\t\t\tref: transaction.objectRef({\n\t\t\t\t\t\tversion: res.data.version,\n\t\t\t\t\t\tdigest: res.data.digest,\n\t\t\t\t\t\tobjectId: res.data.objectId,\n\t\t\t\t\t}),\n\t\t\t\t\ttype: res.data.type!,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst mergedCoins = new Map<string, TransactionObjectArgument>([\n\t\t\t[SUI_COIN_TYPE, transaction.gas],\n\t\t]);\n\n\t\tfor (const [coinType, coins] of coinsByType) {\n\t\t\tif (coinType === SUI_COIN_TYPE) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst [first, ...rest] = coins.map((coin) =>\n\t\t\t\ttransaction.objectRef({\n\t\t\t\t\tobjectId: coin.coinObjectId,\n\t\t\t\t\tversion: coin.version,\n\t\t\t\t\tdigest: coin.digest,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (rest.length > 0) {\n\t\t\t\ttransaction.mergeCoins(first, rest);\n\t\t\t}\n\t\t\tmergedCoins.set(coinType, transaction.object(first));\n\t\t}\n\n\t\tfor (const link of links) {\n\t\t\tconst receiver = link.keypair.toSuiAddress();\n\t\t\ttransaction.add(contract.new({ arguments: [store, receiver] }));\n\n\t\t\tlink.objectRefs.forEach(({ ref, type }) => {\n\t\t\t\ttransaction.add(\n\t\t\t\t\tcontract.add({\n\t\t\t\t\t\targuments: [store, receiver, ref],\n\t\t\t\t\t\ttypeArguments: [type],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tlink.objectIds.forEach((id) => {\n\t\t\t\tconst object = objectRefs.get(id);\n\t\t\t\tif (!object) {\n\t\t\t\t\tthrow new Error(`Object ${id} not found`);\n\t\t\t\t}\n\t\t\t\ttransaction.add(\n\t\t\t\t\tcontract.add({\n\t\t\t\t\t\targuments: [store, receiver, object.ref],\n\t\t\t\t\t\ttypeArguments: [object.type],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\tfor (const [coinType, merged] of mergedCoins) {\n\t\t\tconst linksWithCoin = links.filter((link) => link.balances.has(coinType));\n\t\t\tif (linksWithCoin.length === 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst balances = linksWithCoin.map((link) => link.balances.get(coinType)!);\n\t\t\tconst splits = transaction.splitCoins(merged, balances);\n\t\t\tfor (const [i, link] of linksWithCoin.entries()) {\n\t\t\t\ttransaction.add(\n\t\t\t\t\tcontract.add({\n\t\t\t\t\t\targuments: [store, link.keypair.toSuiAddress(), splits[i]],\n\t\t\t\t\t\ttypeArguments: [`0x2::coin::Coin<${coinType}>`],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn transaction;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAE1C,0BAAoC;AAEpC,qBAA+B;AAE/B,0BAA4B;AAC5B,mBAA6E;AAG7E,oBAA4C;AAb5C;AA+BA,MAAM,+BAA+B;AAAA,EACpC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACV;AAEA,MAAM,oBAAgB,iCAAmB,yBAAY;AAW9C,MAAM,qBAAN,MAAM,mBAAkB;AAAA,EAgB9B,YAAY;AAAA,IACX,OAAO,6BAA6B;AAAA,IACpC,OAAO,6BAA6B;AAAA,IACpC,UAAU,IAAI,8BAAe;AAAA,IAC7B,UAAU,6BAA6B;AAAA,IACvC,SAAS,IAAI,wBAAU,EAAE,SAAK,8BAAe,OAAO,EAAE,CAAC;AAAA,IACvD;AAAA,IACA;AAAA,IACA,WAAW,YAAY,YAAY,qCAAuB;AAAA,EAC3D,GAA6B;AAzBvB;AACN,qBAAY,oBAAI,IAAY;AAC5B,sBAGM,CAAC;AACP,oBAAW,oBAAI,IAAoB;AAEnC;AACA;AAEA;AACA;AACA,qCAAe,oBAAI,IAA0B;AAC7C;AAYC,uBAAK,OAAQ;AACb,uBAAK,OAAQ;AACb,uBAAK,WAAY;AACjB,SAAK,UAAU;AACf,uBAAK,SAAU;AACf,SAAK,aAAS,kCAAoB,MAAM;AAExC,QAAI,UAAU;AACb,yBAAK,WAAY,IAAI,oBAAM,SAAS,WAAW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