@mysten/zksend 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/channel/events.d.ts +54 -54
  3. package/dist/cjs/channel/index.d.ts +4 -4
  4. package/dist/cjs/index.d.ts +4 -1
  5. package/dist/cjs/index.js +14 -1
  6. package/dist/cjs/index.js.map +2 -2
  7. package/dist/cjs/index.test.d.ts +9 -1
  8. package/dist/cjs/links/builder.d.ts +41 -0
  9. package/dist/cjs/links/builder.js +264 -0
  10. package/dist/cjs/links/builder.js.map +7 -0
  11. package/dist/cjs/links/claim.d.ts +80 -0
  12. package/dist/cjs/links/claim.js +515 -0
  13. package/dist/cjs/links/claim.js.map +7 -0
  14. package/dist/cjs/links/utils.d.ts +21 -0
  15. package/dist/cjs/links/utils.js +162 -0
  16. package/dist/cjs/links/utils.js.map +7 -0
  17. package/dist/cjs/links/zk-bag.d.ts +79 -0
  18. package/dist/cjs/links/zk-bag.js +129 -0
  19. package/dist/cjs/links/zk-bag.js.map +7 -0
  20. package/dist/esm/channel/events.d.ts +54 -54
  21. package/dist/esm/channel/index.d.ts +4 -4
  22. package/dist/esm/index.d.ts +4 -1
  23. package/dist/esm/index.js +12 -1
  24. package/dist/esm/index.js.map +2 -2
  25. package/dist/esm/index.test.d.ts +9 -1
  26. package/dist/esm/links/builder.d.ts +41 -0
  27. package/dist/esm/links/builder.js +244 -0
  28. package/dist/esm/links/builder.js.map +7 -0
  29. package/dist/esm/links/claim.d.ts +80 -0
  30. package/dist/esm/links/claim.js +503 -0
  31. package/dist/esm/links/claim.js.map +7 -0
  32. package/dist/esm/links/utils.d.ts +21 -0
  33. package/dist/esm/links/utils.js +142 -0
  34. package/dist/esm/links/utils.js.map +7 -0
  35. package/dist/esm/links/zk-bag.d.ts +79 -0
  36. package/dist/esm/links/zk-bag.js +109 -0
  37. package/dist/esm/links/zk-bag.js.map +7 -0
  38. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +2 -3
  41. package/dist/cjs/links.d.ts +0 -80
  42. package/dist/cjs/links.js +0 -374
  43. package/dist/cjs/links.js.map +0 -7
  44. package/dist/esm/links.d.ts +0 -80
  45. package/dist/esm/links.js +0 -362
  46. package/dist/esm/links.js.map +0 -7
@@ -0,0 +1,515 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __accessCheck = (obj, member, msg) => {
20
+ if (!member.has(obj))
21
+ throw TypeError("Cannot " + msg);
22
+ };
23
+ var __privateGet = (obj, member, getter) => {
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
+ };
41
+ var claim_exports = {};
42
+ __export(claim_exports, {
43
+ ZkSendLink: () => ZkSendLink
44
+ });
45
+ module.exports = __toCommonJS(claim_exports);
46
+ var import_client = require("@mysten/sui.js/client");
47
+ var import_ed25519 = require("@mysten/sui.js/keypairs/ed25519");
48
+ var import_transactions = require("@mysten/sui.js/transactions");
49
+ var import_utils = require("@mysten/sui.js/utils");
50
+ var import_builder = require("./builder.js");
51
+ var import_zk_bag = require("./zk-bag.js");
52
+ var _client, _initiallyOwnedObjects, _ownedObjects, _bagObjects, _gasCoin, _hasSui, _contract, _claimApi, _network, _host, _path, _loadBag, loadBag_fn, _createSponsoredTransactionBlock, createSponsoredTransactionBlock_fn, _executeSponsoredTransactionBlock, executeSponsoredTransactionBlock_fn, _fetch, fetch_fn, _listNonContractClaimableAssets, listNonContractClaimableAssets_fn, _createNonContractClaimTransaction, createNonContractClaimTransaction_fn, _loadOwnedObjects, loadOwnedObjects_fn, _loadInitialTransactionData, loadInitialTransactionData_fn;
53
+ const DEFAULT_ZK_SEND_LINK_OPTIONS = {
54
+ host: "https://zksend.com",
55
+ path: "/claim",
56
+ network: "mainnet",
57
+ claimApi: "https://zksend.com/api"
58
+ };
59
+ const SUI_COIN_TYPE = (0, import_utils.normalizeStructTag)(import_utils.SUI_TYPE_ARG);
60
+ const SUI_COIN_OBJECT_TYPE = (0, import_utils.normalizeStructTag)("0x2::coin::Coin<0x2::sui::SUI>");
61
+ const _ZkSendLink = class {
62
+ constructor({
63
+ network = DEFAULT_ZK_SEND_LINK_OPTIONS.network,
64
+ claimApi = DEFAULT_ZK_SEND_LINK_OPTIONS.claimApi,
65
+ client = new import_client.SuiClient({ url: (0, import_client.getFullnodeUrl)(network) }),
66
+ keypair,
67
+ contract,
68
+ address,
69
+ host,
70
+ path,
71
+ isContractLink
72
+ }) {
73
+ __privateAdd(this, _loadBag);
74
+ __privateAdd(this, _createSponsoredTransactionBlock);
75
+ __privateAdd(this, _executeSponsoredTransactionBlock);
76
+ __privateAdd(this, _fetch);
77
+ __privateAdd(this, _listNonContractClaimableAssets);
78
+ __privateAdd(this, _createNonContractClaimTransaction);
79
+ __privateAdd(this, _loadOwnedObjects);
80
+ __privateAdd(this, _loadInitialTransactionData);
81
+ __privateAdd(this, _client, void 0);
82
+ __privateAdd(this, _initiallyOwnedObjects, /* @__PURE__ */ new Set());
83
+ __privateAdd(this, _ownedObjects, []);
84
+ __privateAdd(this, _bagObjects, null);
85
+ __privateAdd(this, _gasCoin, void 0);
86
+ __privateAdd(this, _hasSui, false);
87
+ __privateAdd(this, _contract, void 0);
88
+ __privateAdd(this, _claimApi, void 0);
89
+ __privateAdd(this, _network, void 0);
90
+ __privateAdd(this, _host, void 0);
91
+ __privateAdd(this, _path, void 0);
92
+ if (!keypair && !address) {
93
+ throw new Error("Either keypair or address must be provided");
94
+ }
95
+ __privateSet(this, _client, client);
96
+ this.keypair = keypair;
97
+ this.address = address ?? keypair.toSuiAddress();
98
+ __privateSet(this, _claimApi, claimApi);
99
+ __privateSet(this, _network, network);
100
+ __privateSet(this, _host, host);
101
+ __privateSet(this, _path, path);
102
+ if (isContractLink) {
103
+ if (!contract) {
104
+ throw new Error("Contract options are required for contract based links");
105
+ }
106
+ __privateSet(this, _contract, new import_zk_bag.ZkBag(contract.packageId, contract));
107
+ }
108
+ }
109
+ static async fromUrl(url, {
110
+ contract,
111
+ ...options
112
+ } = {}) {
113
+ const parsed = new URL(url);
114
+ const isContractLink = parsed.hash.startsWith("#$");
115
+ let link;
116
+ if (isContractLink) {
117
+ if (!contract) {
118
+ throw new Error("Contract options are required for contract based links");
119
+ }
120
+ const keypair = import_ed25519.Ed25519Keypair.fromSecretKey((0, import_utils.fromB64)(parsed.hash.slice(2)));
121
+ link = new _ZkSendLink({
122
+ ...options,
123
+ keypair,
124
+ host: `${parsed.protocol}//${parsed.host}`,
125
+ path: parsed.pathname,
126
+ isContractLink: true,
127
+ contract
128
+ });
129
+ } else {
130
+ const keypair = import_ed25519.Ed25519Keypair.fromSecretKey(
131
+ (0, import_utils.fromB64)(isContractLink ? parsed.hash.slice(2) : parsed.hash.slice(1))
132
+ );
133
+ link = new _ZkSendLink({
134
+ ...options,
135
+ keypair,
136
+ host: `${parsed.protocol}//${parsed.host}`,
137
+ path: parsed.pathname,
138
+ isContractLink: false
139
+ });
140
+ }
141
+ await link.loadOwnedData();
142
+ return link;
143
+ }
144
+ static async fromAddress(address, options) {
145
+ const link = new _ZkSendLink({
146
+ ...options,
147
+ address,
148
+ isContractLink: true
149
+ });
150
+ await link.loadOwnedData();
151
+ return link;
152
+ }
153
+ async loadOwnedData() {
154
+ if (__privateGet(this, _contract)) {
155
+ await __privateMethod(this, _loadBag, loadBag_fn).call(this);
156
+ } else {
157
+ await Promise.all([__privateMethod(this, _loadInitialTransactionData, loadInitialTransactionData_fn).call(this), __privateMethod(this, _loadOwnedObjects, loadOwnedObjects_fn).call(this)]);
158
+ }
159
+ }
160
+ async listClaimableAssets(address, options) {
161
+ if (!__privateGet(this, _contract)) {
162
+ return __privateMethod(this, _listNonContractClaimableAssets, listNonContractClaimableAssets_fn).call(this, address, options);
163
+ }
164
+ const coins = [];
165
+ const nfts = [];
166
+ for (const object of __privateGet(this, _bagObjects) ?? []) {
167
+ const type = (0, import_utils.parseStructTag)(object.type);
168
+ if (type.address === (0, import_utils.normalizeSuiAddress)("0x2") && type.module === "coin" && type.name === "Coin") {
169
+ coins.push(object);
170
+ } else {
171
+ nfts.push(object);
172
+ }
173
+ }
174
+ const balances = /* @__PURE__ */ new Map();
175
+ coins.forEach((coin) => {
176
+ if (coin.content?.dataType !== "moveObject") {
177
+ return;
178
+ }
179
+ const amount = BigInt(coin.content.fields.balance);
180
+ const coinType = (0, import_utils.normalizeStructTag)((0, import_utils.parseStructTag)(coin.content.type).typeParams[0]);
181
+ if (!balances.has(coinType)) {
182
+ balances.set(coinType, { coinType, amount });
183
+ } else {
184
+ balances.get(coinType).amount += amount;
185
+ }
186
+ });
187
+ return {
188
+ balances: [...balances.values()],
189
+ nfts,
190
+ coins
191
+ };
192
+ }
193
+ async claimAssets(address, options) {
194
+ if (!this.keypair) {
195
+ throw new Error("Cannot claim assets without links keypair");
196
+ }
197
+ const txb = this.createClaimTransaction(address, options);
198
+ if (!__privateGet(this, _contract) || !__privateGet(this, _bagObjects)) {
199
+ return __privateGet(this, _client).signAndExecuteTransactionBlock({
200
+ transactionBlock: txb,
201
+ signer: this.keypair
202
+ });
203
+ }
204
+ const { digest } = await __privateMethod(this, _executeSponsoredTransactionBlock, executeSponsoredTransactionBlock_fn).call(this, await __privateMethod(this, _createSponsoredTransactionBlock, createSponsoredTransactionBlock_fn).call(this, txb, address, this.keypair.toSuiAddress()), this.keypair);
205
+ return __privateGet(this, _client).waitForTransactionBlock({ digest });
206
+ }
207
+ createClaimTransaction(address, {
208
+ reclaim,
209
+ ...options
210
+ } = {}) {
211
+ if (!__privateGet(this, _contract)) {
212
+ return __privateMethod(this, _createNonContractClaimTransaction, createNonContractClaimTransaction_fn).call(this, address, options);
213
+ }
214
+ if (Object.keys(options).length > 0) {
215
+ throw new Error("Filtering claims is not supported for contract based links");
216
+ }
217
+ if (!this.keypair && !reclaim) {
218
+ throw new Error("Cannot claim assets without the links keypair");
219
+ }
220
+ const txb = new import_transactions.TransactionBlock();
221
+ const sender = reclaim ? address : this.keypair.toSuiAddress();
222
+ txb.setSender(sender);
223
+ const store = txb.object(__privateGet(this, _contract).ids.bagStoreId);
224
+ const [bag, proof] = reclaim ? __privateGet(this, _contract).reclaim(txb, { arguments: [store, this.address] }) : __privateGet(this, _contract).init_claim(txb, { arguments: [store] });
225
+ const objectsToTransfer = [];
226
+ for (const object of __privateGet(this, _bagObjects) ?? []) {
227
+ objectsToTransfer.push(
228
+ __privateGet(this, _contract).claim(txb, {
229
+ arguments: [
230
+ bag,
231
+ proof,
232
+ txb.receivingRef({
233
+ objectId: object.objectId,
234
+ version: object.version,
235
+ digest: object.digest
236
+ })
237
+ ],
238
+ typeArguments: [object.type]
239
+ })
240
+ );
241
+ }
242
+ __privateGet(this, _contract).finalize(txb, { arguments: [bag, proof] });
243
+ if (objectsToTransfer.length > 0) {
244
+ txb.transferObjects(objectsToTransfer, address);
245
+ }
246
+ return txb;
247
+ }
248
+ async createRegenerateTransaction(sender, options = {}) {
249
+ if (!__privateGet(this, _contract) || !__privateGet(this, _bagObjects)) {
250
+ throw new Error("Regenerating non-contract based links is not supported");
251
+ }
252
+ const txb = new import_transactions.TransactionBlock();
253
+ txb.setSender(sender);
254
+ const store = txb.object(__privateGet(this, _contract).ids.bagStoreId);
255
+ const newLinkKp = import_ed25519.Ed25519Keypair.generate();
256
+ const newLink = new import_builder.ZkSendLinkBuilder({
257
+ ...options,
258
+ sender,
259
+ client: __privateGet(this, _client),
260
+ contract: __privateGet(this, _contract).ids,
261
+ host: __privateGet(this, _host),
262
+ path: __privateGet(this, _path),
263
+ keypair: newLinkKp
264
+ });
265
+ const to = txb.pure.address(newLinkKp.toSuiAddress());
266
+ __privateGet(this, _contract).update_receiver(txb, { arguments: [store, this.address, to] });
267
+ return {
268
+ url: newLink.getLink(),
269
+ transactionBlock: txb
270
+ };
271
+ }
272
+ };
273
+ let ZkSendLink = _ZkSendLink;
274
+ _client = new WeakMap();
275
+ _initiallyOwnedObjects = new WeakMap();
276
+ _ownedObjects = new WeakMap();
277
+ _bagObjects = new WeakMap();
278
+ _gasCoin = new WeakMap();
279
+ _hasSui = new WeakMap();
280
+ _contract = new WeakMap();
281
+ _claimApi = new WeakMap();
282
+ _network = new WeakMap();
283
+ _host = new WeakMap();
284
+ _path = new WeakMap();
285
+ _loadBag = new WeakSet();
286
+ loadBag_fn = async function() {
287
+ if (!__privateGet(this, _contract)) {
288
+ return;
289
+ }
290
+ const bagField = await __privateGet(this, _client).getDynamicFieldObject({
291
+ parentId: __privateGet(this, _contract).ids.bagStoreTableId,
292
+ name: {
293
+ type: "address",
294
+ value: this.address
295
+ }
296
+ });
297
+ if (!bagField.data) {
298
+ return;
299
+ }
300
+ const itemIds = bagField.data?.content?.fields?.value?.fields?.item_ids.fields.contents;
301
+ this.creatorAddress = bagField.data?.content?.fields?.value?.fields?.owner;
302
+ if (!itemIds) {
303
+ throw new Error("Invalid bag field");
304
+ }
305
+ const objectsResponse = await __privateGet(this, _client).multiGetObjects({
306
+ ids: itemIds,
307
+ options: {
308
+ showType: true,
309
+ showContent: true
310
+ }
311
+ });
312
+ __privateSet(this, _bagObjects, objectsResponse.map((object, i) => {
313
+ if (!object.data) {
314
+ throw new Error(`Failed to load claimable object ${itemIds[i]}`);
315
+ }
316
+ return {
317
+ objectId: object.data.objectId,
318
+ type: (0, import_utils.normalizeStructTag)(object.data.type),
319
+ version: object.data.version,
320
+ digest: object.data.digest,
321
+ content: object.data.content
322
+ };
323
+ }));
324
+ };
325
+ _createSponsoredTransactionBlock = new WeakSet();
326
+ createSponsoredTransactionBlock_fn = async function(txb, claimer, sender) {
327
+ return __privateMethod(this, _fetch, fetch_fn).call(this, "transaction-blocks/sponsor", {
328
+ method: "POST",
329
+ body: JSON.stringify({
330
+ network: __privateGet(this, _network),
331
+ sender,
332
+ claimer,
333
+ transactionBlockKindBytes: (0, import_utils.toB64)(
334
+ await txb.build({
335
+ onlyTransactionKind: true,
336
+ client: __privateGet(this, _client),
337
+ // Theses limits will get verified during the final transaction construction, so we can safely ignore them here:
338
+ limits: {
339
+ maxGasObjects: Infinity,
340
+ maxPureArgumentSize: Infinity,
341
+ maxTxGas: Infinity,
342
+ maxTxSizeBytes: Infinity
343
+ }
344
+ })
345
+ )
346
+ })
347
+ });
348
+ };
349
+ _executeSponsoredTransactionBlock = new WeakSet();
350
+ executeSponsoredTransactionBlock_fn = async function(input, keypair) {
351
+ return __privateMethod(this, _fetch, fetch_fn).call(this, `transaction-blocks/sponsor/${input.digest}`, {
352
+ method: "POST",
353
+ body: JSON.stringify({
354
+ signature: (await keypair.signTransactionBlock((0, import_utils.fromB64)(input.bytes))).signature
355
+ })
356
+ });
357
+ };
358
+ _fetch = new WeakSet();
359
+ fetch_fn = async function(path, init) {
360
+ const res = await fetch(`${__privateGet(this, _claimApi)}/v1/${path}`, {
361
+ ...init,
362
+ headers: {
363
+ ...init.headers,
364
+ "Content-Type": "application/json"
365
+ }
366
+ });
367
+ if (!res.ok) {
368
+ console.error(await res.text());
369
+ throw new Error(`Request to claim API failed with status code ${res.status}`);
370
+ }
371
+ const { data } = await res.json();
372
+ return data;
373
+ };
374
+ _listNonContractClaimableAssets = new WeakSet();
375
+ listNonContractClaimableAssets_fn = async function(address, options) {
376
+ const normalizedAddress = (0, import_utils.normalizeSuiAddress)(address);
377
+ const txb = this.createClaimTransaction(normalizedAddress, options);
378
+ if (__privateGet(this, _gasCoin) || !__privateGet(this, _hasSui)) {
379
+ txb.setGasPayment([]);
380
+ }
381
+ const dryRun = await __privateGet(this, _client).dryRunTransactionBlock({
382
+ transactionBlock: await txb.build({ client: __privateGet(this, _client) })
383
+ });
384
+ const balances = [];
385
+ const nfts = [];
386
+ const coins = [];
387
+ dryRun.balanceChanges.forEach((balanceChange) => {
388
+ if (BigInt(balanceChange.amount) > 0n && isOwner(balanceChange.owner, normalizedAddress)) {
389
+ balances.push({
390
+ coinType: (0, import_utils.normalizeStructTag)(balanceChange.coinType),
391
+ amount: BigInt(balanceChange.amount)
392
+ });
393
+ }
394
+ });
395
+ dryRun.objectChanges.forEach((objectChange) => {
396
+ if ("objectType" in objectChange) {
397
+ const type = (0, import_utils.parseStructTag)(objectChange.objectType);
398
+ if (type.address === (0, import_utils.normalizeSuiAddress)("0x2") && type.module === "coin" && type.name === "Coin") {
399
+ if (ownedAfterChange(objectChange, normalizedAddress)) {
400
+ coins.push(objectChange);
401
+ }
402
+ return;
403
+ }
404
+ }
405
+ if (ownedAfterChange(objectChange, normalizedAddress)) {
406
+ nfts.push(objectChange);
407
+ }
408
+ });
409
+ return {
410
+ balances,
411
+ nfts,
412
+ coins
413
+ };
414
+ };
415
+ _createNonContractClaimTransaction = new WeakSet();
416
+ createNonContractClaimTransaction_fn = function(address, options) {
417
+ if (!this.keypair) {
418
+ throw new Error("Cannot claim assets without the links keypair");
419
+ }
420
+ const claimAll = !options?.coinTypes && !options?.objects;
421
+ const txb = new import_transactions.TransactionBlock();
422
+ txb.setSender(this.keypair.toSuiAddress());
423
+ const coinTypes = new Set(
424
+ options?.coinTypes?.map((type) => (0, import_utils.normalizeStructTag)(`0x2::coin::Coin<${type}>`)) ?? []
425
+ );
426
+ const objectsToTransfer = __privateGet(this, _ownedObjects).filter((object) => {
427
+ if (__privateGet(this, _gasCoin)) {
428
+ if (object.objectId === __privateGet(this, _gasCoin).coinObjectId) {
429
+ return false;
430
+ }
431
+ } else if (object.type === SUI_COIN_OBJECT_TYPE) {
432
+ return false;
433
+ }
434
+ if (coinTypes?.has(object.type) || options?.objects?.includes(object.objectId)) {
435
+ return true;
436
+ }
437
+ if (!options?.claimObjectsAddedAfterCreation && !__privateGet(this, _initiallyOwnedObjects).has(object.objectId)) {
438
+ return false;
439
+ }
440
+ return claimAll;
441
+ }).map((object) => txb.object(object.objectId));
442
+ if (__privateGet(this, _gasCoin) && this.creatorAddress) {
443
+ txb.transferObjects([txb.gas], this.creatorAddress);
444
+ } else if (claimAll || coinTypes?.has(SUI_COIN_TYPE)) {
445
+ objectsToTransfer.push(txb.gas);
446
+ }
447
+ if (objectsToTransfer.length > 0) {
448
+ txb.transferObjects(objectsToTransfer, address);
449
+ }
450
+ return txb;
451
+ };
452
+ _loadOwnedObjects = new WeakSet();
453
+ loadOwnedObjects_fn = async function() {
454
+ __privateSet(this, _ownedObjects, []);
455
+ let nextCursor;
456
+ do {
457
+ const ownedObjects = await __privateGet(this, _client).getOwnedObjects({
458
+ cursor: nextCursor,
459
+ owner: this.address,
460
+ options: {
461
+ showType: true
462
+ }
463
+ });
464
+ nextCursor = ownedObjects.hasNextPage ? ownedObjects.nextCursor : null;
465
+ for (const object of ownedObjects.data) {
466
+ if (object.data) {
467
+ __privateGet(this, _ownedObjects).push({
468
+ objectId: (0, import_utils.normalizeSuiObjectId)(object.data.objectId),
469
+ version: object.data.version,
470
+ digest: object.data.digest,
471
+ type: (0, import_utils.normalizeStructTag)(object.data.type)
472
+ });
473
+ }
474
+ }
475
+ } while (nextCursor);
476
+ const coins = await __privateGet(this, _client).getCoins({
477
+ coinType: SUI_COIN_TYPE,
478
+ owner: this.address
479
+ });
480
+ __privateSet(this, _hasSui, coins.data.length > 0);
481
+ __privateSet(this, _gasCoin, coins.data.find((coin) => BigInt(coin.balance) % 1000n === 987n));
482
+ };
483
+ _loadInitialTransactionData = new WeakSet();
484
+ loadInitialTransactionData_fn = async function() {
485
+ const result = await __privateGet(this, _client).queryTransactionBlocks({
486
+ limit: 1,
487
+ order: "ascending",
488
+ filter: {
489
+ ToAddress: this.address
490
+ },
491
+ options: {
492
+ showObjectChanges: true,
493
+ showInput: true
494
+ }
495
+ });
496
+ result.data[0]?.objectChanges?.forEach((objectChange) => {
497
+ if (ownedAfterChange(objectChange, this.address)) {
498
+ __privateGet(this, _initiallyOwnedObjects).add((0, import_utils.normalizeSuiObjectId)(objectChange.objectId));
499
+ }
500
+ });
501
+ this.creatorAddress = result.data[0]?.transaction?.data.sender;
502
+ };
503
+ function ownedAfterChange(objectChange, address) {
504
+ if (objectChange.type === "transferred" && isOwner(objectChange.recipient, address)) {
505
+ return true;
506
+ }
507
+ if ((objectChange.type === "created" || objectChange.type === "mutated") && isOwner(objectChange.owner, address)) {
508
+ return true;
509
+ }
510
+ return false;
511
+ }
512
+ function isOwner(owner, address) {
513
+ return owner && typeof owner === "object" && "AddressOwner" in owner && (0, import_utils.normalizeSuiAddress)(owner.AddressOwner) === address;
514
+ }
515
+ //# sourceMappingURL=claim.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/links/claim.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client';\nimport type {\n\tCoinStruct,\n\tObjectOwner,\n\tSuiObjectChange,\n\tSuiParsedData,\n} from '@mysten/sui.js/client';\nimport type { Keypair } from '@mysten/sui.js/cryptography';\nimport { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport {\n\tfromB64,\n\tnormalizeStructTag,\n\tnormalizeSuiAddress,\n\tnormalizeSuiObjectId,\n\tparseStructTag,\n\tSUI_TYPE_ARG,\n\ttoB64,\n} from '@mysten/sui.js/utils';\n\nimport type { ZkSendLinkBuilderOptions } from './builder.js';\nimport { ZkSendLinkBuilder } from './builder.js';\nimport type { ZkBagContractOptions } from './zk-bag.js';\nimport { ZkBag } from './zk-bag.js';\n\nconst DEFAULT_ZK_SEND_LINK_OPTIONS = {\n\thost: 'https://zksend.com',\n\tpath: '/claim',\n\tnetwork: 'mainnet' as const,\n\tclaimApi: 'https://zksend.com/api',\n};\n\nconst SUI_COIN_TYPE = normalizeStructTag(SUI_TYPE_ARG);\nconst SUI_COIN_OBJECT_TYPE = normalizeStructTag('0x2::coin::Coin<0x2::sui::SUI>');\n\nexport type ZkSendLinkOptions = {\n\tclaimApi?: string;\n\tkeypair?: Keypair;\n\tclient?: SuiClient;\n\tnetwork?: 'mainnet' | 'testnet';\n\thost?: string;\n\tpath?: string;\n\taddress?: string;\n} & (\n\t| {\n\t\t\taddress: string;\n\t\t\tkeypair?: never;\n\t }\n\t| {\n\t\t\tkeypair: Keypair;\n\t\t\taddress?: never;\n\t }\n) &\n\t(\n\t\t| {\n\t\t\t\tisContractLink: true;\n\t\t\t\tcontract: ZkBagContractOptions;\n\t\t }\n\t\t| {\n\t\t\t\tisContractLink: false;\n\t\t\t\tcontract?: never;\n\t\t }\n\t);\n\nexport class ZkSendLink {\n\t#client: SuiClient;\n\taddress: string;\n\tkeypair?: Keypair;\n\tcreatorAddress?: string;\n\t#initiallyOwnedObjects = new Set<string>();\n\t#ownedObjects: Array<{\n\t\tobjectId: string;\n\t\tversion: string;\n\t\tdigest: string;\n\t\ttype: string;\n\t}> = [];\n\t#bagObjects: Array<{\n\t\tobjectId: string;\n\t\ttype: string;\n\t\tversion: string;\n\t\tdigest: string;\n\t\tcontent: SuiParsedData;\n\t}> | null = null;\n\t#gasCoin?: CoinStruct;\n\t#hasSui = false;\n\n\t#contract?: ZkBag<ZkBagContractOptions>;\n\t#claimApi: string;\n\t#network: 'mainnet' | 'testnet';\n\t#host?: string;\n\t#path?: string;\n\n\tconstructor({\n\t\tnetwork = DEFAULT_ZK_SEND_LINK_OPTIONS.network,\n\t\tclaimApi = DEFAULT_ZK_SEND_LINK_OPTIONS.claimApi,\n\t\tclient = new SuiClient({ url: getFullnodeUrl(network) }),\n\t\tkeypair,\n\t\tcontract,\n\t\taddress,\n\t\thost,\n\t\tpath,\n\t\tisContractLink,\n\t}: ZkSendLinkOptions) {\n\t\tif (!keypair && !address) {\n\t\t\tthrow new Error('Either keypair or address must be provided');\n\t\t}\n\n\t\tthis.#client = client;\n\t\tthis.keypair = keypair;\n\t\tthis.address = address ?? keypair!.toSuiAddress();\n\t\tthis.#claimApi = claimApi;\n\t\tthis.#network = network;\n\t\tthis.#host = host;\n\t\tthis.#path = path;\n\n\t\tif (isContractLink) {\n\t\t\tif (!contract) {\n\t\t\t\tthrow new Error('Contract options are required for contract based links');\n\t\t\t}\n\n\t\t\tthis.#contract = new ZkBag(contract.packageId, contract);\n\t\t}\n\t}\n\n\tstatic async fromUrl(\n\t\turl: string,\n\t\t{\n\t\t\tcontract,\n\t\t\t...options\n\t\t}: Omit<ZkSendLinkOptions, 'keypair' | 'address' | 'isContractLink'> = {},\n\t) {\n\t\tconst parsed = new URL(url);\n\t\tconst isContractLink = parsed.hash.startsWith('#$');\n\n\t\tlet link: ZkSendLink;\n\t\tif (isContractLink) {\n\t\t\tif (!contract) {\n\t\t\t\tthrow new Error('Contract options are required for contract based links');\n\t\t\t}\n\n\t\t\tconst keypair = Ed25519Keypair.fromSecretKey(fromB64(parsed.hash.slice(2)));\n\t\t\tlink = new ZkSendLink({\n\t\t\t\t...options,\n\t\t\t\tkeypair,\n\t\t\t\thost: `${parsed.protocol}//${parsed.host}`,\n\t\t\t\tpath: parsed.pathname,\n\t\t\t\tisContractLink: true,\n\t\t\t\tcontract,\n\t\t\t});\n\t\t} else {\n\t\t\tconst keypair = Ed25519Keypair.fromSecretKey(\n\t\t\t\tfromB64(isContractLink ? parsed.hash.slice(2) : parsed.hash.slice(1)),\n\t\t\t);\n\n\t\t\tlink = new ZkSendLink({\n\t\t\t\t...options,\n\t\t\t\tkeypair,\n\t\t\t\thost: `${parsed.protocol}//${parsed.host}`,\n\t\t\t\tpath: parsed.pathname,\n\t\t\t\tisContractLink: false,\n\t\t\t});\n\t\t}\n\n\t\tawait link.loadOwnedData();\n\n\t\treturn link;\n\t}\n\n\tstatic async fromAddress(\n\t\taddress: string,\n\t\toptions: Omit<ZkSendLinkOptions, 'keypair' | 'address' | 'isContractLink'> & {\n\t\t\tcontract: ZkBagContractOptions;\n\t\t},\n\t) {\n\t\tconst link = new ZkSendLink({\n\t\t\t...options,\n\t\t\taddress,\n\t\t\tisContractLink: true,\n\t\t});\n\n\t\tawait link.loadOwnedData();\n\n\t\treturn link;\n\t}\n\n\tasync loadOwnedData() {\n\t\tif (this.#contract) {\n\t\t\tawait this.#loadBag();\n\t\t} else {\n\t\t\tawait Promise.all([this.#loadInitialTransactionData(), this.#loadOwnedObjects()]);\n\t\t}\n\t}\n\n\tasync listClaimableAssets(\n\t\taddress: string,\n\t\toptions?: {\n\t\t\tclaimObjectsAddedAfterCreation?: boolean;\n\t\t\tcoinTypes?: string[];\n\t\t\tobjects?: string[];\n\t\t},\n\t) {\n\t\tif (!this.#contract) {\n\t\t\treturn this.#listNonContractClaimableAssets(address, options);\n\t\t}\n\n\t\tconst coins = [];\n\n\t\tconst nfts: {\n\t\t\tobjectId: string;\n\t\t\ttype: string;\n\t\t\tversion: string;\n\t\t\tdigest: string;\n\t\t}[] = [];\n\n\t\tfor (const object of this.#bagObjects ?? []) {\n\t\t\tconst type = parseStructTag(object.type);\n\n\t\t\tif (\n\t\t\t\ttype.address === normalizeSuiAddress('0x2') &&\n\t\t\t\ttype.module === 'coin' &&\n\t\t\t\ttype.name === 'Coin'\n\t\t\t) {\n\t\t\t\tcoins.push(object);\n\t\t\t} else {\n\t\t\t\tnfts.push(object);\n\t\t\t}\n\t\t}\n\n\t\tconst balances = new Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tcoinType: string;\n\t\t\t\tamount: bigint;\n\t\t\t}\n\t\t>();\n\n\t\tcoins.forEach((coin) => {\n\t\t\tif (coin.content?.dataType !== 'moveObject') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst amount = BigInt((coin.content.fields as Record<string, string>).balance);\n\t\t\tconst coinType = normalizeStructTag(parseStructTag(coin.content.type).typeParams[0]);\n\n\t\t\tif (!balances.has(coinType)) {\n\t\t\t\tbalances.set(coinType, { coinType, amount });\n\t\t\t} else {\n\t\t\t\tbalances.get(coinType)!.amount += amount;\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tbalances: [...balances.values()],\n\t\t\tnfts,\n\t\t\tcoins,\n\t\t};\n\t}\n\n\tasync claimAssets(\n\t\taddress: string,\n\t\t/** @deprecated filtering claims is not supported in contract based links */\n\t\toptions?: {\n\t\t\tclaimObjectsAddedAfterCreation?: boolean;\n\t\t\tcoinTypes?: string[];\n\t\t\tobjects?: string[];\n\t\t},\n\t) {\n\t\tif (!this.keypair) {\n\t\t\tthrow new Error('Cannot claim assets without links keypair');\n\t\t}\n\n\t\tconst txb = this.createClaimTransaction(address, options);\n\t\tif (!this.#contract || !this.#bagObjects) {\n\t\t\treturn this.#client.signAndExecuteTransactionBlock({\n\t\t\t\ttransactionBlock: txb,\n\t\t\t\tsigner: this.keypair,\n\t\t\t});\n\t\t}\n\n\t\tconst { digest } = await this.#executeSponsoredTransactionBlock(\n\t\t\tawait this.#createSponsoredTransactionBlock(txb, address, this.keypair.toSuiAddress()),\n\t\t\tthis.keypair,\n\t\t);\n\n\t\treturn this.#client.waitForTransactionBlock({ digest });\n\t}\n\n\tcreateClaimTransaction(\n\t\taddress: string,\n\t\t{\n\t\t\treclaim,\n\t\t\t...options\n\t\t}: {\n\t\t\t/** @deprecated filtering claims is not supported in contract based links */\n\t\t\tclaimObjectsAddedAfterCreation?: boolean;\n\t\t\t/** @deprecated filtering claims is not supported in contract based links */\n\t\t\tcoinTypes?: string[];\n\t\t\t/** @deprecated filtering claims is not supported in contract based links */\n\t\t\tobjects?: string[];\n\t\t\treclaim?: boolean;\n\t\t} = {},\n\t) {\n\t\tif (!this.#contract) {\n\t\t\treturn this.#createNonContractClaimTransaction(address, options);\n\t\t}\n\n\t\tif (Object.keys(options).length > 0) {\n\t\t\tthrow new Error('Filtering claims is not supported for contract based links');\n\t\t}\n\n\t\tif (!this.keypair && !reclaim) {\n\t\t\tthrow new Error('Cannot claim assets without the links keypair');\n\t\t}\n\n\t\tconst txb = new TransactionBlock();\n\t\tconst sender = reclaim ? address : this.keypair!.toSuiAddress();\n\t\ttxb.setSender(sender);\n\n\t\tconst store = txb.object(this.#contract.ids.bagStoreId);\n\n\t\tconst [bag, proof] = reclaim\n\t\t\t? this.#contract.reclaim(txb, { arguments: [store, this.address] })\n\t\t\t: this.#contract.init_claim(txb, { arguments: [store] });\n\n\t\tconst objectsToTransfer = [];\n\n\t\tfor (const object of this.#bagObjects ?? []) {\n\t\t\tobjectsToTransfer.push(\n\t\t\t\tthis.#contract.claim(txb, {\n\t\t\t\t\targuments: [\n\t\t\t\t\t\tbag,\n\t\t\t\t\t\tproof,\n\t\t\t\t\t\ttxb.receivingRef({\n\t\t\t\t\t\t\tobjectId: object.objectId,\n\t\t\t\t\t\t\tversion: object.version,\n\t\t\t\t\t\t\tdigest: object.digest,\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t\ttypeArguments: [object.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tthis.#contract.finalize(txb, { arguments: [bag, proof] });\n\t\tif (objectsToTransfer.length > 0) {\n\t\t\ttxb.transferObjects(objectsToTransfer, address);\n\t\t}\n\n\t\treturn txb;\n\t}\n\n\tasync createRegenerateTransaction(\n\t\tsender: string,\n\t\toptions: Omit<ZkSendLinkBuilderOptions, 'sender'> = {},\n\t) {\n\t\tif (!this.#contract || !this.#bagObjects) {\n\t\t\tthrow new Error('Regenerating non-contract based links is not supported');\n\t\t}\n\n\t\tconst txb = new TransactionBlock();\n\t\ttxb.setSender(sender);\n\n\t\tconst store = txb.object(this.#contract.ids.bagStoreId);\n\n\t\tconst newLinkKp = Ed25519Keypair.generate();\n\n\t\tconst newLink = new ZkSendLinkBuilder({\n\t\t\t...options,\n\t\t\tsender,\n\t\t\tclient: this.#client,\n\t\t\tcontract: this.#contract.ids,\n\t\t\thost: this.#host,\n\t\t\tpath: this.#path,\n\t\t\tkeypair: newLinkKp,\n\t\t});\n\n\t\tconst to = txb.pure.address(newLinkKp.toSuiAddress());\n\n\t\tthis.#contract.update_receiver(txb, { arguments: [store, this.address, to] });\n\n\t\treturn {\n\t\t\turl: newLink.getLink(),\n\t\t\ttransactionBlock: txb,\n\t\t};\n\t}\n\n\tasync #loadBag() {\n\t\tif (!this.#contract) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst bagField = await this.#client.getDynamicFieldObject({\n\t\t\tparentId: this.#contract.ids.bagStoreTableId,\n\t\t\tname: {\n\t\t\t\ttype: 'address',\n\t\t\t\tvalue: this.address,\n\t\t\t},\n\t\t});\n\n\t\tif (!bagField.data) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst itemIds: string[] | undefined = (bagField as any).data?.content?.fields?.value?.fields\n\t\t\t?.item_ids.fields.contents;\n\n\t\tthis.creatorAddress = (bagField as any).data?.content?.fields?.value?.fields?.owner;\n\n\t\tif (!itemIds) {\n\t\t\tthrow new Error('Invalid bag field');\n\t\t}\n\n\t\tconst objectsResponse = await this.#client.multiGetObjects({\n\t\t\tids: itemIds,\n\t\t\toptions: {\n\t\t\t\tshowType: true,\n\t\t\t\tshowContent: true,\n\t\t\t},\n\t\t});\n\n\t\tthis.#bagObjects = objectsResponse.map((object, i) => {\n\t\t\tif (!object.data) {\n\t\t\t\tthrow new Error(`Failed to load claimable object ${itemIds[i]}`);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tobjectId: object.data.objectId,\n\t\t\t\ttype: normalizeStructTag(object.data.type!),\n\t\t\t\tversion: object.data.version,\n\t\t\t\tdigest: object.data.digest,\n\t\t\t\tcontent: object.data.content!,\n\t\t\t};\n\t\t});\n\t}\n\n\tasync #createSponsoredTransactionBlock(txb: TransactionBlock, claimer: string, sender: string) {\n\t\treturn this.#fetch<{ digest: string; bytes: string }>('transaction-blocks/sponsor', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnetwork: this.#network,\n\t\t\t\tsender,\n\t\t\t\tclaimer,\n\t\t\t\ttransactionBlockKindBytes: toB64(\n\t\t\t\t\tawait txb.build({\n\t\t\t\t\t\tonlyTransactionKind: true,\n\t\t\t\t\t\tclient: this.#client,\n\t\t\t\t\t\t// Theses limits will get verified during the final transaction construction, so we can safely ignore them here:\n\t\t\t\t\t\tlimits: {\n\t\t\t\t\t\t\tmaxGasObjects: Infinity,\n\t\t\t\t\t\t\tmaxPureArgumentSize: Infinity,\n\t\t\t\t\t\t\tmaxTxGas: Infinity,\n\t\t\t\t\t\t\tmaxTxSizeBytes: Infinity,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t});\n\t}\n\n\tasync #executeSponsoredTransactionBlock(\n\t\tinput: { digest: string; bytes: string },\n\t\tkeypair: Keypair,\n\t) {\n\t\treturn this.#fetch<{ digest: string }>(`transaction-blocks/sponsor/${input.digest}`, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify({\n\t\t\t\tsignature: (await keypair.signTransactionBlock(fromB64(input.bytes))).signature,\n\t\t\t}),\n\t\t});\n\t}\n\n\tasync #fetch<T = unknown>(path: string, init: RequestInit): Promise<T> {\n\t\tconst res = await fetch(`${this.#claimApi}/v1/${path}`, {\n\t\t\t...init,\n\t\t\theaders: {\n\t\t\t\t...init.headers,\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t},\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tconsole.error(await res.text());\n\t\t\tthrow new Error(`Request to claim API failed with status code ${res.status}`);\n\t\t}\n\n\t\tconst { data } = await res.json();\n\n\t\treturn data as T;\n\t}\n\n\tasync #listNonContractClaimableAssets(\n\t\taddress: string,\n\t\toptions?: {\n\t\t\tclaimObjectsAddedAfterCreation?: boolean;\n\t\t\tcoinTypes?: string[];\n\t\t\tobjects?: string[];\n\t\t},\n\t) {\n\t\tconst normalizedAddress = normalizeSuiAddress(address);\n\t\tconst txb = this.createClaimTransaction(normalizedAddress, options);\n\n\t\tif (this.#gasCoin || !this.#hasSui) {\n\t\t\ttxb.setGasPayment([]);\n\t\t}\n\n\t\tconst dryRun = await this.#client.dryRunTransactionBlock({\n\t\t\ttransactionBlock: await txb.build({ client: this.#client }),\n\t\t});\n\n\t\tconst balances: {\n\t\t\tcoinType: string;\n\t\t\tamount: bigint;\n\t\t}[] = [];\n\n\t\tconst nfts: {\n\t\t\tobjectId: string;\n\t\t\ttype: string;\n\t\t\tversion: string;\n\t\t\tdigest: string;\n\t\t}[] = [];\n\n\t\tconst coins: {\n\t\t\tobjectId: string;\n\t\t\ttype: string;\n\t\t\tversion: string;\n\t\t\tdigest: string;\n\t\t}[] = [];\n\n\t\tdryRun.balanceChanges.forEach((balanceChange) => {\n\t\t\tif (BigInt(balanceChange.amount) > 0n && isOwner(balanceChange.owner, normalizedAddress)) {\n\t\t\t\tbalances.push({\n\t\t\t\t\tcoinType: normalizeStructTag(balanceChange.coinType),\n\t\t\t\t\tamount: BigInt(balanceChange.amount),\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tdryRun.objectChanges.forEach((objectChange) => {\n\t\t\tif ('objectType' in objectChange) {\n\t\t\t\tconst type = parseStructTag(objectChange.objectType);\n\n\t\t\t\tif (\n\t\t\t\t\ttype.address === normalizeSuiAddress('0x2') &&\n\t\t\t\t\ttype.module === 'coin' &&\n\t\t\t\t\ttype.name === 'Coin'\n\t\t\t\t) {\n\t\t\t\t\tif (ownedAfterChange(objectChange, normalizedAddress)) {\n\t\t\t\t\t\tcoins.push(objectChange);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ownedAfterChange(objectChange, normalizedAddress)) {\n\t\t\t\tnfts.push(objectChange);\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tbalances,\n\t\t\tnfts,\n\t\t\tcoins,\n\t\t};\n\t}\n\n\t#createNonContractClaimTransaction(\n\t\taddress: string,\n\t\toptions?: {\n\t\t\tclaimObjectsAddedAfterCreation?: boolean;\n\t\t\tcoinTypes?: string[];\n\t\t\tobjects?: string[];\n\t\t},\n\t) {\n\t\tif (!this.keypair) {\n\t\t\tthrow new Error('Cannot claim assets without the links keypair');\n\t\t}\n\n\t\tconst claimAll = !options?.coinTypes && !options?.objects;\n\t\tconst txb = new TransactionBlock();\n\t\ttxb.setSender(this.keypair.toSuiAddress());\n\t\tconst coinTypes = new Set(\n\t\t\toptions?.coinTypes?.map((type) => normalizeStructTag(`0x2::coin::Coin<${type}>`)) ?? [],\n\t\t);\n\n\t\tconst objectsToTransfer = this.#ownedObjects\n\t\t\t.filter((object) => {\n\t\t\t\tif (this.#gasCoin) {\n\t\t\t\t\tif (object.objectId === this.#gasCoin.coinObjectId) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else if (object.type === SUI_COIN_OBJECT_TYPE) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (coinTypes?.has(object.type) || options?.objects?.includes(object.objectId)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t!options?.claimObjectsAddedAfterCreation &&\n\t\t\t\t\t!this.#initiallyOwnedObjects.has(object.objectId)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn claimAll;\n\t\t\t})\n\t\t\t.map((object) => txb.object(object.objectId));\n\n\t\tif (this.#gasCoin && this.creatorAddress) {\n\t\t\ttxb.transferObjects([txb.gas], this.creatorAddress);\n\t\t} else if (claimAll || coinTypes?.has(SUI_COIN_TYPE)) {\n\t\t\tobjectsToTransfer.push(txb.gas);\n\t\t}\n\n\t\tif (objectsToTransfer.length > 0) {\n\t\t\ttxb.transferObjects(objectsToTransfer, address);\n\t\t}\n\n\t\treturn txb;\n\t}\n\n\tasync #loadOwnedObjects() {\n\t\tthis.#ownedObjects = [];\n\t\tlet nextCursor: string | null | undefined;\n\t\tdo {\n\t\t\tconst ownedObjects = await this.#client.getOwnedObjects({\n\t\t\t\tcursor: nextCursor,\n\t\t\t\towner: this.address,\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\t// RPC response returns cursor even if there are no more pages\n\t\t\tnextCursor = ownedObjects.hasNextPage ? ownedObjects.nextCursor : null;\n\t\t\tfor (const object of ownedObjects.data) {\n\t\t\t\tif (object.data) {\n\t\t\t\t\tthis.#ownedObjects.push({\n\t\t\t\t\t\tobjectId: normalizeSuiObjectId(object.data.objectId),\n\t\t\t\t\t\tversion: object.data.version,\n\t\t\t\t\t\tdigest: object.data.digest,\n\t\t\t\t\t\ttype: normalizeStructTag(object.data.type!),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} while (nextCursor);\n\n\t\tconst coins = await this.#client.getCoins({\n\t\t\tcoinType: SUI_COIN_TYPE,\n\t\t\towner: this.address,\n\t\t});\n\n\t\tthis.#hasSui = coins.data.length > 0;\n\t\tthis.#gasCoin = coins.data.find((coin) => BigInt(coin.balance) % 1000n === 987n);\n\t}\n\n\tasync #loadInitialTransactionData() {\n\t\tconst result = await this.#client.queryTransactionBlocks({\n\t\t\tlimit: 1,\n\t\t\torder: 'ascending',\n\t\t\tfilter: {\n\t\t\t\tToAddress: this.address,\n\t\t\t},\n\t\t\toptions: {\n\t\t\t\tshowObjectChanges: true,\n\t\t\t\tshowInput: true,\n\t\t\t},\n\t\t});\n\n\t\tresult.data[0]?.objectChanges?.forEach((objectChange) => {\n\t\t\tif (ownedAfterChange(objectChange, this.address)) {\n\t\t\t\tthis.#initiallyOwnedObjects.add(normalizeSuiObjectId(objectChange.objectId));\n\t\t\t}\n\t\t});\n\n\t\tthis.creatorAddress = result.data[0]?.transaction?.data.sender;\n\t}\n}\n\nfunction ownedAfterChange(\n\tobjectChange: SuiObjectChange,\n\taddress: string,\n): objectChange is Extract<SuiObjectChange, { type: 'created' | 'transferred' | 'mutated' }> {\n\tif (objectChange.type === 'transferred' && isOwner(objectChange.recipient, address)) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\t(objectChange.type === 'created' || objectChange.type === 'mutated') &&\n\t\tisOwner(objectChange.owner, address)\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction isOwner(owner: ObjectOwner, address: string): owner is { AddressOwner: string } {\n\treturn (\n\t\towner &&\n\t\ttypeof owner === 'object' &&\n\t\t'AddressOwner' in owner &&\n\t\tnormalizeSuiAddress(owner.AddressOwner) === address\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAQ1C,qBAA+B;AAC/B,0BAAiC;AACjC,mBAQO;AAGP,qBAAkC;AAElC,oBAAsB;AA1BtB;AA4BA,MAAM,+BAA+B;AAAA,EACpC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AACX;AAEA,MAAM,oBAAgB,iCAAm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,iBAAiB,cAAc,KAAK,OAAO,GAAG;AACjD,yBAAK,wBAAuB,QAAI,mCAAqB,aAAa,QAAQ,CAAC;AAAA,IAC5E;AAAA,EACD,CAAC;AAED,OAAK,iBAAiB,OAAO,KAAK,CAAC,GAAG,aAAa,KAAK;AACzD;AAGD,SAAS,iBACR,cACA,SAC4F;AAC5F,MAAI,aAAa,SAAS,iBAAiB,QAAQ,aAAa,WAAW,OAAO,GAAG;AACpF,WAAO;AAAA,EACR;AAEA,OACE,aAAa,SAAS,aAAa,aAAa,SAAS,cAC1D,QAAQ,aAAa,OAAO,OAAO,GAClC;AACD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAEA,SAAS,QAAQ,OAAoB,SAAoD;AACxF,SACC,SACA,OAAO,UAAU,YACjB,kBAAkB,aAClB,kCAAoB,MAAM,YAAY,MAAM;AAE9C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,21 @@
1
+ import '@mysten/sui.js/graphql/schemas/2024-01';
2
+ import type { SuiClient } from '@mysten/sui.js/client';
3
+ import type { TransactionBlock } from '@mysten/sui.js/transactions';
4
+ import { ZkSendLink } from './claim.js';
5
+ import type { ZkBagContractOptions } from './zk-bag.js';
6
+ export declare function listCreatedLinks({ address, cursor, network, contract, ...linkOptions }: {
7
+ address: string;
8
+ contract: ZkBagContractOptions;
9
+ cursor?: string;
10
+ network?: 'mainnet' | 'testnet';
11
+ host?: string;
12
+ path?: string;
13
+ client?: SuiClient;
14
+ }): Promise<{
15
+ cursor: string | null;
16
+ hasNextPage: boolean;
17
+ links: ZkSendLink[];
18
+ }>;
19
+ export declare function isClaimTransaction(txb: TransactionBlock, options: {
20
+ packageId: string;
21
+ }): boolean;