@mysten/zksend 0.4.4 → 0.5.0
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 +6 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/links/claim.d.ts +8 -2
- package/dist/cjs/links/claim.js +52 -20
- package/dist/cjs/links/claim.js.map +2 -2
- package/dist/cjs/links/get-sent-transaction-blocks.d.ts +21 -0
- package/dist/cjs/links/get-sent-transaction-blocks.js +127 -0
- package/dist/cjs/links/get-sent-transaction-blocks.js.map +7 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/links/claim.d.ts +8 -2
- package/dist/esm/links/claim.js +52 -20
- package/dist/esm/links/claim.js.map +2 -2
- package/dist/esm/links/get-sent-transaction-blocks.d.ts +21 -0
- package/dist/esm/links/get-sent-transaction-blocks.js +107 -0
- package/dist/esm/links/get-sent-transaction-blocks.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { ZkSendLink, type ZkSendLinkOptions } from './links/claim.js';
|
|
|
3
3
|
export { type ZkBagContractOptions, ZkBag } from './links/zk-bag.js';
|
|
4
4
|
export { isClaimTransaction } from './links/utils.js';
|
|
5
5
|
export { listCreatedLinks } from './links/list-created-links.js';
|
|
6
|
+
export { getSentTransactionBlocksWithLinks } from './links/get-sent-transaction-blocks.js';
|
|
6
7
|
export { MAINNET_CONTRACT_IDS } from './links/zk-bag.js';
|
|
7
8
|
export * from './wallet.js';
|
|
8
9
|
export * from './channel/index.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(src_exports, {
|
|
|
23
23
|
ZkBag: () => import_zk_bag.ZkBag,
|
|
24
24
|
ZkSendLink: () => import_claim.ZkSendLink,
|
|
25
25
|
ZkSendLinkBuilder: () => import_builder.ZkSendLinkBuilder,
|
|
26
|
+
getSentTransactionBlocksWithLinks: () => import_get_sent_transaction_blocks.getSentTransactionBlocksWithLinks,
|
|
26
27
|
isClaimTransaction: () => import_utils.isClaimTransaction,
|
|
27
28
|
listCreatedLinks: () => import_list_created_links.listCreatedLinks
|
|
28
29
|
});
|
|
@@ -32,6 +33,7 @@ var import_claim = require("./links/claim.js");
|
|
|
32
33
|
var import_zk_bag = require("./links/zk-bag.js");
|
|
33
34
|
var import_utils = require("./links/utils.js");
|
|
34
35
|
var import_list_created_links = require("./links/list-created-links.js");
|
|
36
|
+
var import_get_sent_transaction_blocks = require("./links/get-sent-transaction-blocks.js");
|
|
35
37
|
var import_zk_bag2 = require("./links/zk-bag.js");
|
|
36
38
|
__reExport(src_exports, require("./wallet.js"), module.exports);
|
|
37
39
|
__reExport(src_exports, require("./channel/index.js"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n\tZkSendLinkBuilder,\n\ttype ZkSendLinkBuilderOptions,\n\ttype CreateZkSendLinkOptions,\n} from './links/builder.js';\nexport { ZkSendLink, type ZkSendLinkOptions } from './links/claim.js';\nexport { type ZkBagContractOptions, ZkBag } from './links/zk-bag.js';\nexport { isClaimTransaction } from './links/utils.js';\nexport { listCreatedLinks } from './links/list-created-links.js';\n\nexport { MAINNET_CONTRACT_IDS } from './links/zk-bag.js';\nexport * from './wallet.js';\nexport * from './channel/index.js';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAIO;AACP,mBAAmD;AACnD,oBAAiD;AACjD,mBAAmC;AACnC,gCAAiC;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n\tZkSendLinkBuilder,\n\ttype ZkSendLinkBuilderOptions,\n\ttype CreateZkSendLinkOptions,\n} from './links/builder.js';\nexport { ZkSendLink, type ZkSendLinkOptions } from './links/claim.js';\nexport { type ZkBagContractOptions, ZkBag } from './links/zk-bag.js';\nexport { isClaimTransaction } from './links/utils.js';\nexport { listCreatedLinks } from './links/list-created-links.js';\nexport { getSentTransactionBlocksWithLinks } from './links/get-sent-transaction-blocks.js';\n\nexport { MAINNET_CONTRACT_IDS } from './links/zk-bag.js';\nexport * from './wallet.js';\nexport * from './channel/index.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAIO;AACP,mBAAmD;AACnD,oBAAiD;AACjD,mBAAmC;AACnC,gCAAiC;AACjC,yCAAkD;AAElD,IAAAA,iBAAqC;AACrC,wBAAc,wBAfd;AAgBA,wBAAc,+BAhBd;",
|
|
6
6
|
"names": ["import_zk_bag"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SuiClient } from '@mysten/sui.js/client';
|
|
2
|
+
import type { SuiObjectData, SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
2
3
|
import type { Keypair } from '@mysten/sui.js/cryptography';
|
|
3
4
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
4
5
|
import type { ZkSendLinkBuilderOptions } from './builder.js';
|
|
@@ -28,11 +29,16 @@ export declare class ZkSendLink {
|
|
|
28
29
|
creatorAddress?: string;
|
|
29
30
|
assets?: LinkAssets;
|
|
30
31
|
claimed?: boolean;
|
|
32
|
+
bagObject?: SuiObjectData | null;
|
|
31
33
|
constructor({ network, claimApi, client, keypair, contract, address, host, path, isContractLink, }: ZkSendLinkOptions);
|
|
32
34
|
static fromUrl(url: string, options?: Omit<ZkSendLinkOptions, 'keypair' | 'address' | 'isContractLink'>): Promise<ZkSendLink>;
|
|
33
35
|
static fromAddress(address: string, options: Omit<ZkSendLinkOptions, 'keypair' | 'address' | 'isContractLink'>): Promise<ZkSendLink>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
loadClaimedStatus(): Promise<void>;
|
|
37
|
+
loadAssets(options?: {
|
|
38
|
+
transactionBlock?: SuiTransactionBlockResponse;
|
|
39
|
+
loadClaimedAssets?: boolean;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
claimAssets(address: string): Promise<SuiTransactionBlockResponse>;
|
|
36
42
|
createClaimTransaction(address: string, { reclaim, }?: {
|
|
37
43
|
reclaim?: boolean;
|
|
38
44
|
}): TransactionBlock;
|
package/dist/cjs/links/claim.js
CHANGED
|
@@ -51,7 +51,7 @@ var import_utils = require("@mysten/sui.js/utils");
|
|
|
51
51
|
var import_builder = require("./builder.js");
|
|
52
52
|
var import_utils2 = require("./utils.js");
|
|
53
53
|
var import_zk_bag = require("./zk-bag.js");
|
|
54
|
-
var _client, _contract, _claimApi, _network, _host, _path, _gasCoin, _hasSui, _ownedObjects, _loadBag, loadBag_fn, _loadClaimedAssets, loadClaimedAssets_fn, _createSponsoredTransactionBlock, createSponsoredTransactionBlock_fn, _executeSponsoredTransactionBlock, executeSponsoredTransactionBlock_fn, _fetch, fetch_fn, _listNonContractClaimableAssets, listNonContractClaimableAssets_fn, _createNonContractClaimTransaction, createNonContractClaimTransaction_fn, _loadOwnedObjects, loadOwnedObjects_fn;
|
|
54
|
+
var _client, _contract, _claimApi, _network, _host, _path, _gasCoin, _hasSui, _ownedObjects, _loadBagObject, loadBagObject_fn, _loadBag, loadBag_fn, _loadClaimedAssets, loadClaimedAssets_fn, _createSponsoredTransactionBlock, createSponsoredTransactionBlock_fn, _executeSponsoredTransactionBlock, executeSponsoredTransactionBlock_fn, _fetch, fetch_fn, _listNonContractClaimableAssets, listNonContractClaimableAssets_fn, _createNonContractClaimTransaction, createNonContractClaimTransaction_fn, _loadOwnedObjects, loadOwnedObjects_fn;
|
|
55
55
|
const DEFAULT_ZK_SEND_LINK_OPTIONS = {
|
|
56
56
|
host: "https://zksend.com",
|
|
57
57
|
path: "/claim",
|
|
@@ -72,6 +72,7 @@ const _ZkSendLink = class {
|
|
|
72
72
|
path,
|
|
73
73
|
isContractLink
|
|
74
74
|
}) {
|
|
75
|
+
__privateAdd(this, _loadBagObject);
|
|
75
76
|
__privateAdd(this, _loadBag);
|
|
76
77
|
__privateAdd(this, _loadClaimedAssets);
|
|
77
78
|
__privateAdd(this, _createSponsoredTransactionBlock);
|
|
@@ -144,11 +145,14 @@ const _ZkSendLink = class {
|
|
|
144
145
|
await link.loadAssets();
|
|
145
146
|
return link;
|
|
146
147
|
}
|
|
147
|
-
async
|
|
148
|
+
async loadClaimedStatus() {
|
|
149
|
+
await __privateMethod(this, _loadBag, loadBag_fn).call(this, { loadAssets: false });
|
|
150
|
+
}
|
|
151
|
+
async loadAssets(options = {}) {
|
|
148
152
|
if (__privateGet(this, _contract)) {
|
|
149
|
-
await __privateMethod(this, _loadBag, loadBag_fn).call(this);
|
|
153
|
+
await __privateMethod(this, _loadBag, loadBag_fn).call(this, options);
|
|
150
154
|
} else {
|
|
151
|
-
await __privateMethod(this, _loadOwnedObjects, loadOwnedObjects_fn).call(this);
|
|
155
|
+
await __privateMethod(this, _loadOwnedObjects, loadOwnedObjects_fn).call(this, options);
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
async claimAssets(address) {
|
|
@@ -250,8 +254,27 @@ _path = new WeakMap();
|
|
|
250
254
|
_gasCoin = new WeakMap();
|
|
251
255
|
_hasSui = new WeakMap();
|
|
252
256
|
_ownedObjects = new WeakMap();
|
|
257
|
+
_loadBagObject = new WeakSet();
|
|
258
|
+
loadBagObject_fn = async function() {
|
|
259
|
+
if (!__privateGet(this, _contract)) {
|
|
260
|
+
throw new Error("Cannot load bag object for non-contract based links");
|
|
261
|
+
}
|
|
262
|
+
const bagField = await __privateGet(this, _client).getDynamicFieldObject({
|
|
263
|
+
parentId: __privateGet(this, _contract).ids.bagStoreTableId,
|
|
264
|
+
name: {
|
|
265
|
+
type: "address",
|
|
266
|
+
value: this.address
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
this.bagObject = bagField.data;
|
|
270
|
+
this.claimed = !bagField.data;
|
|
271
|
+
};
|
|
253
272
|
_loadBag = new WeakSet();
|
|
254
|
-
loadBag_fn = async function(
|
|
273
|
+
loadBag_fn = async function({
|
|
274
|
+
transactionBlock,
|
|
275
|
+
loadAssets = true,
|
|
276
|
+
loadClaimedAssets = loadAssets
|
|
277
|
+
} = {}) {
|
|
255
278
|
if (!__privateGet(this, _contract)) {
|
|
256
279
|
return;
|
|
257
280
|
}
|
|
@@ -260,22 +283,29 @@ loadBag_fn = async function() {
|
|
|
260
283
|
nfts: [],
|
|
261
284
|
coins: []
|
|
262
285
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
286
|
+
if (!this.bagObject || !this.claimed) {
|
|
287
|
+
await __privateMethod(this, _loadBagObject, loadBagObject_fn).call(this);
|
|
288
|
+
}
|
|
289
|
+
if (!loadAssets) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!this.bagObject) {
|
|
293
|
+
if (loadClaimedAssets) {
|
|
294
|
+
await __privateMethod(this, _loadClaimedAssets, loadClaimedAssets_fn).call(this);
|
|
268
295
|
}
|
|
269
|
-
});
|
|
270
|
-
if (!bagField.data) {
|
|
271
|
-
this.claimed = true;
|
|
272
|
-
await __privateMethod(this, _loadClaimedAssets, loadClaimedAssets_fn).call(this);
|
|
273
296
|
return;
|
|
274
|
-
} else {
|
|
275
|
-
this.claimed = false;
|
|
276
297
|
}
|
|
277
|
-
const
|
|
278
|
-
|
|
298
|
+
const bagId = this.bagObject.content.fields.value.fields?.id?.id;
|
|
299
|
+
if (bagId && transactionBlock?.balanceChanges && transactionBlock.objectChanges) {
|
|
300
|
+
this.assets = (0, import_utils2.getAssetsFromTxnBlock)({
|
|
301
|
+
transactionBlock,
|
|
302
|
+
address: bagId,
|
|
303
|
+
isSent: false
|
|
304
|
+
});
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const itemIds = this.bagObject?.content?.fields?.value?.fields?.item_ids.fields.contents;
|
|
308
|
+
this.creatorAddress = this.bagObject?.content?.fields?.value?.fields?.owner;
|
|
279
309
|
if (!itemIds) {
|
|
280
310
|
throw new Error("Invalid bag field");
|
|
281
311
|
}
|
|
@@ -488,7 +518,9 @@ createNonContractClaimTransaction_fn = function(address) {
|
|
|
488
518
|
return txb;
|
|
489
519
|
};
|
|
490
520
|
_loadOwnedObjects = new WeakSet();
|
|
491
|
-
loadOwnedObjects_fn = async function(
|
|
521
|
+
loadOwnedObjects_fn = async function({
|
|
522
|
+
loadClaimedAssets = true
|
|
523
|
+
} = {}) {
|
|
492
524
|
this.assets = {
|
|
493
525
|
nfts: [],
|
|
494
526
|
balances: [],
|
|
@@ -538,7 +570,7 @@ loadOwnedObjects_fn = async function() {
|
|
|
538
570
|
if (__privateGet(this, _hasSui) || __privateGet(this, _ownedObjects).length > 0) {
|
|
539
571
|
this.claimed = false;
|
|
540
572
|
this.assets = await __privateMethod(this, _listNonContractClaimableAssets, listNonContractClaimableAssets_fn).call(this);
|
|
541
|
-
} else if (result.data[0]) {
|
|
573
|
+
} else if (result.data[0] && loadClaimedAssets) {
|
|
542
574
|
this.claimed = true;
|
|
543
575
|
await __privateMethod(this, _loadClaimedAssets, loadClaimedAssets_fn).call(this);
|
|
544
576
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/links/claim.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PureArg } from '@mysten/sui.js/bcs';\nimport { bcs } from '@mysten/sui.js/bcs';\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client';\nimport type { CoinStruct, SuiTransaction } 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 { LinkAssets } from './utils.js';\nimport { getAssetsFromTxnBlock, isOwner, ownedAfterChange } from './utils.js';\nimport type { ZkBagContractOptions } from './zk-bag.js';\nimport { MAINNET_CONTRACT_IDS, 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\tisContractLink: boolean;\n\tcontract?: ZkBagContractOptions | null;\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\nexport class ZkSendLink {\n\taddress: string;\n\tkeypair?: Keypair;\n\tcreatorAddress?: string;\n\tassets?: LinkAssets;\n\tclaimed?: boolean;\n\n\t#client: SuiClient;\n\t#contract?: ZkBag<ZkBagContractOptions>;\n\t#claimApi: string;\n\t#network: 'mainnet' | 'testnet';\n\t#host?: string;\n\t#path?: string;\n\n\t// State for non-contract based links\n\t#gasCoin?: CoinStruct;\n\t#hasSui = false;\n\t#ownedObjects: {\n\t\tobjectId: string;\n\t\tversion: string;\n\t\tdigest: string;\n\t\ttype: string;\n\t}[] = [];\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 = network === 'mainnet' ? MAINNET_CONTRACT_IDS : null,\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\toptions: 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\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});\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.loadAssets();\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) {\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.loadAssets();\n\n\t\treturn link;\n\t}\n\n\tasync loadAssets() {\n\t\tif (this.#contract) {\n\t\t\tawait this.#loadBag();\n\t\t} else {\n\t\t\tawait this.#loadOwnedObjects();\n\t\t}\n\t}\n\n\tasync claimAssets(address: string) {\n\t\tif (!this.keypair) {\n\t\t\tthrow new Error('Cannot claim assets without links keypair');\n\t\t}\n\n\t\tif (this.claimed) {\n\t\t\tthrow new Error('Assets have already been claimed');\n\t\t}\n\n\t\tif (!this.#contract) {\n\t\t\treturn this.#client.signAndExecuteTransactionBlock({\n\t\t\t\ttransactionBlock: this.createClaimTransaction(address),\n\t\t\t\tsigner: this.keypair,\n\t\t\t});\n\t\t}\n\n\t\tif (!this.assets) {\n\t\t\tawait this.#loadBag();\n\t\t}\n\n\t\tconst txb = this.createClaimTransaction(address);\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}: {\n\t\t\treclaim?: boolean;\n\t\t} = {},\n\t) {\n\t\tif (!this.#contract) {\n\t\t\treturn this.#createNonContractClaimTransaction(address);\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\tconst objects = [...(this.assets?.coins ?? []), ...(this.assets?.nfts ?? [])];\n\n\t\tfor (const object of objects) {\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.assets) {\n\t\t\tawait this.#loadBag();\n\t\t}\n\n\t\tif (this.claimed) {\n\t\t\tthrow new Error('Assets have already been claimed');\n\t\t}\n\n\t\tif (!this.#contract) {\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\tthis.assets = {\n\t\t\tbalances: [],\n\t\t\tnfts: [],\n\t\t\tcoins: [],\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\tthis.claimed = true;\n\t\t\tawait this.#loadClaimedAssets();\n\n\t\t\treturn;\n\t\t} else {\n\t\t\tthis.claimed = false;\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\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\tobjectsResponse.forEach((object, i) => {\n\t\t\tif (!object.data || !object.data.type) {\n\t\t\t\tthrow new Error(`Failed to load claimable object ${itemIds[i]}`);\n\t\t\t}\n\n\t\t\tconst type = parseStructTag(normalizeStructTag(object.data.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\tthis.assets!.coins.push({\n\t\t\t\t\tobjectId: object.data.objectId,\n\t\t\t\t\ttype: object.data.type,\n\t\t\t\t\tversion: object.data.version,\n\t\t\t\t\tdigest: object.data.digest,\n\t\t\t\t});\n\n\t\t\t\tif (object.data.content?.dataType === 'moveObject') {\n\t\t\t\t\tconst amount = BigInt((object.data.content.fields as Record<string, string>).balance);\n\t\t\t\t\tconst coinType = normalizeStructTag(\n\t\t\t\t\t\tparseStructTag(object.data.content.type).typeParams[0],\n\t\t\t\t\t);\n\t\t\t\t\tif (!balances.has(coinType)) {\n\t\t\t\t\t\tbalances.set(coinType, { coinType, amount });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbalances.get(coinType)!.amount += amount;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.assets!.nfts.push({\n\t\t\t\t\tobjectId: object.data.objectId,\n\t\t\t\t\ttype: object.data.type,\n\t\t\t\t\tversion: object.data.version,\n\t\t\t\t\tdigest: object.data.digest,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis.assets.balances = [...balances.values()];\n\t}\n\n\tasync #loadClaimedAssets() {\n\t\tconst result = await this.#client.queryTransactionBlocks({\n\t\t\tlimit: 1,\n\t\t\tfilter: {\n\t\t\t\tFromAddress: this.address,\n\t\t\t},\n\t\t\toptions: {\n\t\t\t\tshowObjectChanges: true,\n\t\t\t\tshowBalanceChanges: true,\n\t\t\t\tshowInput: true,\n\t\t\t},\n\t\t});\n\n\t\tif (!result?.data[0]) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [txb] = result.data;\n\n\t\tif (txb.transaction?.data.transaction.kind !== 'ProgrammableTransaction') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transfer = txb.transaction.data.transaction.transactions.findLast(\n\t\t\t(tx): tx is Extract<SuiTransaction, { TransferObjects: unknown }> => 'TransferObjects' in tx,\n\t\t);\n\n\t\tif (!transfer) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst receiverArg = transfer.TransferObjects[1];\n\n\t\tif (!(typeof receiverArg === 'object' && 'Input' in receiverArg)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst input = txb.transaction.data.transaction.inputs[receiverArg.Input];\n\n\t\tif (input.type !== 'pure') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst receiver =\n\t\t\ttypeof input.value === 'string'\n\t\t\t\t? input.value\n\t\t\t\t: bcs.Address.parse(new Uint8Array((input.value as PureArg).Pure));\n\n\t\tthis.assets = getAssetsFromTxnBlock({\n\t\t\ttransactionBlock: txb,\n\t\t\taddress: receiver,\n\t\t\tisSent: false,\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\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\tif (this.#ownedObjects.length === 0 && !this.#hasSui) {\n\t\t\treturn {\n\t\t\t\tbalances,\n\t\t\t\tnfts,\n\t\t\t\tcoins,\n\t\t\t};\n\t\t}\n\n\t\tconst address = new Ed25519Keypair().toSuiAddress();\n\t\tconst normalizedAddress = normalizeSuiAddress(address);\n\n\t\tconst txb = this.createClaimTransaction(normalizedAddress);\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\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(address: string) {\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 txb = new TransactionBlock();\n\t\ttxb.setSender(this.keypair.toSuiAddress());\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\treturn true;\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 {\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.assets = {\n\t\t\tnfts: [],\n\t\t\tbalances: [],\n\t\t\tcoins: [],\n\t\t};\n\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\tshowContent: 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\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\tshowInput: true,\n\t\t\t\tshowBalanceChanges: true,\n\t\t\t\tshowObjectChanges: true,\n\t\t\t},\n\t\t});\n\n\t\tthis.creatorAddress = result.data[0]?.transaction?.data.sender;\n\n\t\tif (this.#hasSui || this.#ownedObjects.length > 0) {\n\t\t\tthis.claimed = false;\n\t\t\tthis.assets = await this.#listNonContractClaimableAssets();\n\t\t} else if (result.data[0]) {\n\t\t\tthis.claimed = true;\n\t\t\tawait this.#loadClaimedAssets();\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAoB;AACpB,oBAA0C;AAG1C,qBAA+B;AAC/B,0BAAiC;AACjC,mBAQO;AAGP,qBAAkC;AAElC,IAAAA,gBAAiE;AAEjE,oBAA4C;AAzB5C;AA2BA,MAAM,+BAA+B;AAAA,EACpC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AACX;AAEA,MAAM,oBAAgB,iCAAmB,yBAAY;AACrD,MAAM,2BAAuB,iCAAmB,gCAAgC;AAuBzE,MAAM,cAAN,MAAiB;AAAA,EAwBvB,YAAY;AAAA,IACX,UAAU,6BAA6B;AAAA,IACvC,WAAW,6BAA6B;AAAA,IACxC,SAAS,IAAI,wBAAU,EAAE,SAAK,8BAAe,OAAO,EAAE,CAAC;AAAA,IACvD;AAAA,IACA,WAAW,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;AAAA,QAC3C,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,SAAS;AAET,QAAM,QAAQ,MAAM,mBAAK,SAAQ,SAAS;AAAA,IACzC,UAAU;AAAA,IACV,OAAO,KAAK;AAAA,EACb,CAAC;AAED,qBAAK,SAAU,MAAM,KAAK,SAAS;AACnC,qBAAK,UAAW,MAAM,KAAK,KAAK,CAAC,SAAS,OAAO,KAAK,OAAO,IAAI,UAAU,IAAI;AAE/E,QAAM,SAAS,MAAM,mBAAK,SAAQ,uBAAuB;AAAA,IACxD,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,MACP,WAAW,KAAK;AAAA,IACjB;AAAA,IACA,SAAS;AAAA,MACR,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,IACpB;AAAA,EACD,CAAC;AAED,OAAK,iBAAiB,OAAO,KAAK,CAAC,GAAG,aAAa,KAAK;AAExD,MAAI,mBAAK,YAAW,mBAAK,eAAc,SAAS,GAAG;AAClD,SAAK,UAAU;AACf,SAAK,SAAS,MAAM,sBAAK,oEAAL;AAAA,EACrB,WAAW,OAAO,KAAK,CAAC,GAAG;AAC1B,SAAK,UAAU;AACf,UAAM,sBAAK,0CAAL;AAAA,EACP;AACD;",
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PureArg } from '@mysten/sui.js/bcs';\nimport { bcs } from '@mysten/sui.js/bcs';\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui.js/client';\nimport type {\n\tCoinStruct,\n\tSuiObjectData,\n\tSuiTransaction,\n\tSuiTransactionBlockResponse,\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 { LinkAssets } from './utils.js';\nimport { getAssetsFromTxnBlock, isOwner, ownedAfterChange } from './utils.js';\nimport type { ZkBagContractOptions } from './zk-bag.js';\nimport { MAINNET_CONTRACT_IDS, 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\tisContractLink: boolean;\n\tcontract?: ZkBagContractOptions | null;\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\nexport class ZkSendLink {\n\taddress: string;\n\tkeypair?: Keypair;\n\tcreatorAddress?: string;\n\tassets?: LinkAssets;\n\tclaimed?: boolean;\n\tbagObject?: SuiObjectData | null;\n\n\t#client: SuiClient;\n\t#contract?: ZkBag<ZkBagContractOptions>;\n\t#claimApi: string;\n\t#network: 'mainnet' | 'testnet';\n\t#host?: string;\n\t#path?: string;\n\n\t// State for non-contract based links\n\t#gasCoin?: CoinStruct;\n\t#hasSui = false;\n\t#ownedObjects: {\n\t\tobjectId: string;\n\t\tversion: string;\n\t\tdigest: string;\n\t\ttype: string;\n\t}[] = [];\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 = network === 'mainnet' ? MAINNET_CONTRACT_IDS : null,\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\toptions: 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\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});\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.loadAssets();\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) {\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.loadAssets();\n\n\t\treturn link;\n\t}\n\n\tasync loadClaimedStatus() {\n\t\tawait this.#loadBag({ loadAssets: false });\n\t}\n\n\tasync loadAssets(\n\t\toptions: {\n\t\t\ttransactionBlock?: SuiTransactionBlockResponse;\n\t\t\tloadClaimedAssets?: boolean;\n\t\t} = {},\n\t) {\n\t\tif (this.#contract) {\n\t\t\tawait this.#loadBag(options);\n\t\t} else {\n\t\t\tawait this.#loadOwnedObjects(options);\n\t\t}\n\t}\n\n\tasync claimAssets(address: string) {\n\t\tif (!this.keypair) {\n\t\t\tthrow new Error('Cannot claim assets without links keypair');\n\t\t}\n\n\t\tif (this.claimed) {\n\t\t\tthrow new Error('Assets have already been claimed');\n\t\t}\n\n\t\tif (!this.#contract) {\n\t\t\treturn this.#client.signAndExecuteTransactionBlock({\n\t\t\t\ttransactionBlock: this.createClaimTransaction(address),\n\t\t\t\tsigner: this.keypair,\n\t\t\t});\n\t\t}\n\n\t\tif (!this.assets) {\n\t\t\tawait this.#loadBag();\n\t\t}\n\n\t\tconst txb = this.createClaimTransaction(address);\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}: {\n\t\t\treclaim?: boolean;\n\t\t} = {},\n\t) {\n\t\tif (!this.#contract) {\n\t\t\treturn this.#createNonContractClaimTransaction(address);\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\tconst objects = [...(this.assets?.coins ?? []), ...(this.assets?.nfts ?? [])];\n\n\t\tfor (const object of objects) {\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.assets) {\n\t\t\tawait this.#loadBag();\n\t\t}\n\n\t\tif (this.claimed) {\n\t\t\tthrow new Error('Assets have already been claimed');\n\t\t}\n\n\t\tif (!this.#contract) {\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 #loadBagObject() {\n\t\tif (!this.#contract) {\n\t\t\tthrow new Error('Cannot load bag object for non-contract based links');\n\t\t}\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\tthis.bagObject = bagField.data;\n\t\tthis.claimed = !bagField.data;\n\t}\n\n\tasync #loadBag({\n\t\ttransactionBlock,\n\t\tloadAssets = true,\n\t\tloadClaimedAssets = loadAssets,\n\t}: {\n\t\ttransactionBlock?: SuiTransactionBlockResponse;\n\t\tloadAssets?: boolean;\n\t\tloadClaimedAssets?: boolean;\n\t} = {}) {\n\t\tif (!this.#contract) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.assets = {\n\t\t\tbalances: [],\n\t\t\tnfts: [],\n\t\t\tcoins: [],\n\t\t};\n\n\t\tif (!this.bagObject || !this.claimed) {\n\t\t\tawait this.#loadBagObject();\n\t\t}\n\n\t\tif (!loadAssets) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.bagObject) {\n\t\t\tif (loadClaimedAssets) {\n\t\t\t\tawait this.#loadClaimedAssets();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst bagId = (this.bagObject as any).content.fields.value.fields?.id?.id;\n\n\t\tif (bagId && transactionBlock?.balanceChanges && transactionBlock.objectChanges) {\n\t\t\tthis.assets = getAssetsFromTxnBlock({\n\t\t\t\ttransactionBlock,\n\t\t\t\taddress: bagId,\n\t\t\t\tisSent: false,\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst itemIds: string[] | undefined = (this.bagObject as any)?.content?.fields?.value?.fields\n\t\t\t?.item_ids.fields.contents;\n\n\t\tthis.creatorAddress = (this.bagObject as any)?.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\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\tobjectsResponse.forEach((object, i) => {\n\t\t\tif (!object.data || !object.data.type) {\n\t\t\t\tthrow new Error(`Failed to load claimable object ${itemIds[i]}`);\n\t\t\t}\n\n\t\t\tconst type = parseStructTag(normalizeStructTag(object.data.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\tthis.assets!.coins.push({\n\t\t\t\t\tobjectId: object.data.objectId,\n\t\t\t\t\ttype: object.data.type,\n\t\t\t\t\tversion: object.data.version,\n\t\t\t\t\tdigest: object.data.digest,\n\t\t\t\t});\n\n\t\t\t\tif (object.data.content?.dataType === 'moveObject') {\n\t\t\t\t\tconst amount = BigInt((object.data.content.fields as Record<string, string>).balance);\n\t\t\t\t\tconst coinType = normalizeStructTag(\n\t\t\t\t\t\tparseStructTag(object.data.content.type).typeParams[0],\n\t\t\t\t\t);\n\t\t\t\t\tif (!balances.has(coinType)) {\n\t\t\t\t\t\tbalances.set(coinType, { coinType, amount });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbalances.get(coinType)!.amount += amount;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.assets!.nfts.push({\n\t\t\t\t\tobjectId: object.data.objectId,\n\t\t\t\t\ttype: object.data.type,\n\t\t\t\t\tversion: object.data.version,\n\t\t\t\t\tdigest: object.data.digest,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis.assets.balances = [...balances.values()];\n\t}\n\n\tasync #loadClaimedAssets() {\n\t\tconst result = await this.#client.queryTransactionBlocks({\n\t\t\tlimit: 1,\n\t\t\tfilter: {\n\t\t\t\tFromAddress: this.address,\n\t\t\t},\n\t\t\toptions: {\n\t\t\t\tshowObjectChanges: true,\n\t\t\t\tshowBalanceChanges: true,\n\t\t\t\tshowInput: true,\n\t\t\t},\n\t\t});\n\n\t\tif (!result?.data[0]) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [txb] = result.data;\n\n\t\tif (txb.transaction?.data.transaction.kind !== 'ProgrammableTransaction') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transfer = txb.transaction.data.transaction.transactions.findLast(\n\t\t\t(tx): tx is Extract<SuiTransaction, { TransferObjects: unknown }> => 'TransferObjects' in tx,\n\t\t);\n\n\t\tif (!transfer) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst receiverArg = transfer.TransferObjects[1];\n\n\t\tif (!(typeof receiverArg === 'object' && 'Input' in receiverArg)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst input = txb.transaction.data.transaction.inputs[receiverArg.Input];\n\n\t\tif (input.type !== 'pure') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst receiver =\n\t\t\ttypeof input.value === 'string'\n\t\t\t\t? input.value\n\t\t\t\t: bcs.Address.parse(new Uint8Array((input.value as PureArg).Pure));\n\n\t\tthis.assets = getAssetsFromTxnBlock({\n\t\t\ttransactionBlock: txb,\n\t\t\taddress: receiver,\n\t\t\tisSent: false,\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\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\tif (this.#ownedObjects.length === 0 && !this.#hasSui) {\n\t\t\treturn {\n\t\t\t\tbalances,\n\t\t\t\tnfts,\n\t\t\t\tcoins,\n\t\t\t};\n\t\t}\n\n\t\tconst address = new Ed25519Keypair().toSuiAddress();\n\t\tconst normalizedAddress = normalizeSuiAddress(address);\n\n\t\tconst txb = this.createClaimTransaction(normalizedAddress);\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\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(address: string) {\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 txb = new TransactionBlock();\n\t\ttxb.setSender(this.keypair.toSuiAddress());\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\treturn true;\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 {\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\tloadClaimedAssets = true,\n\t}: {\n\t\tloadClaimedAssets?: boolean;\n\t} = {}) {\n\t\tthis.assets = {\n\t\t\tnfts: [],\n\t\t\tbalances: [],\n\t\t\tcoins: [],\n\t\t};\n\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\tshowContent: 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\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\tshowInput: true,\n\t\t\t\tshowBalanceChanges: true,\n\t\t\t\tshowObjectChanges: true,\n\t\t\t},\n\t\t});\n\n\t\tthis.creatorAddress = result.data[0]?.transaction?.data.sender;\n\n\t\tif (this.#hasSui || this.#ownedObjects.length > 0) {\n\t\t\tthis.claimed = false;\n\t\t\tthis.assets = await this.#listNonContractClaimableAssets();\n\t\t} else if (result.data[0] && loadClaimedAssets) {\n\t\t\tthis.claimed = true;\n\t\t\tawait this.#loadClaimedAssets();\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAoB;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3C,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,SAAS;AAET,QAAM,QAAQ,MAAM,mBAAK,SAAQ,SAAS;AAAA,IACzC,UAAU;AAAA,IACV,OAAO,KAAK;AAAA,EACb,CAAC;AAED,qBAAK,SAAU,MAAM,KAAK,SAAS;AACnC,qBAAK,UAAW,MAAM,KAAK,KAAK,CAAC,SAAS,OAAO,KAAK,OAAO,IAAI,UAAU,IAAI;AAE/E,QAAM,SAAS,MAAM,mBAAK,SAAQ,uBAAuB;AAAA,IACxD,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,MACP,WAAW,KAAK;AAAA,IACjB;AAAA,IACA,SAAS;AAAA,MACR,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,IACpB;AAAA,EACD,CAAC;AAED,OAAK,iBAAiB,OAAO,KAAK,CAAC,GAAG,aAAa,KAAK;AAExD,MAAI,mBAAK,YAAW,mBAAK,eAAc,SAAS,GAAG;AAClD,SAAK,UAAU;AACf,SAAK,SAAS,MAAM,sBAAK,oEAAL;AAAA,EACrB,WAAW,OAAO,KAAK,CAAC,KAAK,mBAAmB;AAC/C,SAAK,UAAU;AACf,UAAM,sBAAK,0CAAL;AAAA,EACP;AACD;",
|
|
6
6
|
"names": ["import_utils"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SuiClient } from '@mysten/sui.js/client';
|
|
2
|
+
import { ZkSendLink } from './claim.js';
|
|
3
|
+
import type { ZkBagContractOptions } from './zk-bag.js';
|
|
4
|
+
export declare function getSentTransactionBlocksWithLinks({ address, cursor, limit, network, contract, client, loadClaimedAssets, ...linkOptions }: {
|
|
5
|
+
address: string;
|
|
6
|
+
contract?: ZkBagContractOptions;
|
|
7
|
+
cursor?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
network?: 'mainnet' | 'testnet';
|
|
10
|
+
loadClaimedAssets?: boolean;
|
|
11
|
+
host?: string;
|
|
12
|
+
path?: string;
|
|
13
|
+
client?: SuiClient;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
data: {
|
|
16
|
+
transactionBlock: import("@mysten/sui.js/client").SuiTransactionBlockResponse;
|
|
17
|
+
links: ZkSendLink[];
|
|
18
|
+
}[];
|
|
19
|
+
nextCursor: string | null | undefined;
|
|
20
|
+
hasNextPage: boolean;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,127 @@
|
|
|
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 get_sent_transaction_blocks_exports = {};
|
|
20
|
+
__export(get_sent_transaction_blocks_exports, {
|
|
21
|
+
getSentTransactionBlocksWithLinks: () => getSentTransactionBlocksWithLinks
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_sent_transaction_blocks_exports);
|
|
24
|
+
var import_client = require("@mysten/sui.js/client");
|
|
25
|
+
var import_utils = require("@mysten/sui.js/utils");
|
|
26
|
+
var import_claim = require("./claim.js");
|
|
27
|
+
var import_zk_bag = require("./zk-bag.js");
|
|
28
|
+
async function getSentTransactionBlocksWithLinks({
|
|
29
|
+
address,
|
|
30
|
+
cursor,
|
|
31
|
+
limit = 10,
|
|
32
|
+
network = "mainnet",
|
|
33
|
+
contract = import_zk_bag.MAINNET_CONTRACT_IDS,
|
|
34
|
+
client = new import_client.SuiClient({ url: (0, import_client.getFullnodeUrl)(network) }),
|
|
35
|
+
loadClaimedAssets = false,
|
|
36
|
+
...linkOptions
|
|
37
|
+
}) {
|
|
38
|
+
const packageId = (0, import_utils.normalizeSuiAddress)(contract.packageId);
|
|
39
|
+
const page = await client.queryTransactionBlocks({
|
|
40
|
+
filter: {
|
|
41
|
+
FromAddress: address
|
|
42
|
+
},
|
|
43
|
+
order: "descending",
|
|
44
|
+
cursor,
|
|
45
|
+
limit,
|
|
46
|
+
options: {
|
|
47
|
+
showInput: true,
|
|
48
|
+
showObjectChanges: true,
|
|
49
|
+
showBalanceChanges: true
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const data = await Promise.all(
|
|
53
|
+
page.data.map(async (block) => {
|
|
54
|
+
const transactionBlock = block.transaction?.data.transaction;
|
|
55
|
+
if (transactionBlock?.kind !== "ProgrammableTransaction") {
|
|
56
|
+
throw new Error("Invalid transaction block");
|
|
57
|
+
}
|
|
58
|
+
const newLinks = await Promise.all(
|
|
59
|
+
transactionBlock.transactions.filter(
|
|
60
|
+
(tx) => "MoveCall" in tx ? tx.MoveCall.package === packageId && tx.MoveCall.module === "zk_bag" && tx.MoveCall.function === "new" : false
|
|
61
|
+
).map(async (tx) => {
|
|
62
|
+
if (!("MoveCall" in tx)) {
|
|
63
|
+
throw new Error("Expected MoveCall");
|
|
64
|
+
}
|
|
65
|
+
const addressArg = tx.MoveCall.arguments?.[1];
|
|
66
|
+
if (!addressArg || typeof addressArg !== "object" || !("Input" in addressArg)) {
|
|
67
|
+
throw new Error("Invalid address argument");
|
|
68
|
+
}
|
|
69
|
+
const input = transactionBlock.inputs[addressArg.Input];
|
|
70
|
+
if (input.type !== "pure") {
|
|
71
|
+
throw new Error("Expected Address input to be a Pure value");
|
|
72
|
+
}
|
|
73
|
+
const address2 = (0, import_utils.normalizeSuiAddress)(input.value);
|
|
74
|
+
const link = new import_claim.ZkSendLink({
|
|
75
|
+
network,
|
|
76
|
+
address: address2,
|
|
77
|
+
contract,
|
|
78
|
+
isContractLink: true,
|
|
79
|
+
...linkOptions
|
|
80
|
+
});
|
|
81
|
+
await link.loadAssets({
|
|
82
|
+
transactionBlock: block,
|
|
83
|
+
loadClaimedAssets
|
|
84
|
+
});
|
|
85
|
+
return link;
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
const regeneratedLinks = await Promise.all(
|
|
89
|
+
transactionBlock.transactions.filter(
|
|
90
|
+
(tx) => "MoveCall" in tx ? tx.MoveCall.package === packageId && tx.MoveCall.module === "zk_bag" && tx.MoveCall.function === "update_receiver" : false
|
|
91
|
+
).map(async (tx) => {
|
|
92
|
+
if (!("MoveCall" in tx)) {
|
|
93
|
+
throw new Error("Expected MoveCall");
|
|
94
|
+
}
|
|
95
|
+
const addressArg = tx.MoveCall.arguments?.[2];
|
|
96
|
+
if (!addressArg || typeof addressArg !== "object" || !("Input" in addressArg)) {
|
|
97
|
+
throw new Error("Invalid address argument");
|
|
98
|
+
}
|
|
99
|
+
const input = transactionBlock.inputs[addressArg.Input];
|
|
100
|
+
if (input.type !== "pure") {
|
|
101
|
+
throw new Error("Expected Address input to be a Pure value");
|
|
102
|
+
}
|
|
103
|
+
const address2 = (0, import_utils.normalizeSuiAddress)(input.value);
|
|
104
|
+
const link = new import_claim.ZkSendLink({
|
|
105
|
+
network,
|
|
106
|
+
address: address2,
|
|
107
|
+
contract,
|
|
108
|
+
isContractLink: true,
|
|
109
|
+
...linkOptions
|
|
110
|
+
});
|
|
111
|
+
await link.loadAssets({ loadClaimedAssets });
|
|
112
|
+
return link;
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
return {
|
|
116
|
+
transactionBlock: block,
|
|
117
|
+
links: [...newLinks, ...regeneratedLinks]
|
|
118
|
+
};
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
return {
|
|
122
|
+
data,
|
|
123
|
+
nextCursor: page.nextCursor,
|
|
124
|
+
hasNextPage: page.hasNextPage
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=get-sent-transaction-blocks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/links/get-sent-transaction-blocks.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 { normalizeSuiAddress } from '@mysten/sui.js/utils';\n\nimport { ZkSendLink } from './claim.js';\nimport type { ZkBagContractOptions } from './zk-bag.js';\nimport { MAINNET_CONTRACT_IDS } from './zk-bag.js';\n\nexport async function getSentTransactionBlocksWithLinks({\n\taddress,\n\tcursor,\n\tlimit = 10,\n\tnetwork = 'mainnet',\n\tcontract = MAINNET_CONTRACT_IDS,\n\tclient = new SuiClient({ url: getFullnodeUrl(network) }),\n\tloadClaimedAssets = false,\n\t...linkOptions\n}: {\n\taddress: string;\n\tcontract?: ZkBagContractOptions;\n\tcursor?: string;\n\tlimit?: number;\n\tnetwork?: 'mainnet' | 'testnet';\n\tloadClaimedAssets?: boolean;\n\n\t// Link options:\n\thost?: string;\n\tpath?: string;\n\tclient?: SuiClient;\n}) {\n\tconst packageId = normalizeSuiAddress(contract.packageId);\n\n\tconst page = await client.queryTransactionBlocks({\n\t\tfilter: {\n\t\t\tFromAddress: address,\n\t\t},\n\t\torder: 'descending',\n\t\tcursor,\n\t\tlimit,\n\t\toptions: {\n\t\t\tshowInput: true,\n\t\t\tshowObjectChanges: true,\n\t\t\tshowBalanceChanges: true,\n\t\t},\n\t});\n\n\tconst data = await Promise.all(\n\t\tpage.data.map(async (block) => {\n\t\t\tconst transactionBlock = block.transaction?.data.transaction;\n\t\t\tif (transactionBlock?.kind !== 'ProgrammableTransaction') {\n\t\t\t\tthrow new Error('Invalid transaction block');\n\t\t\t}\n\n\t\t\tconst newLinks = await Promise.all(\n\t\t\t\ttransactionBlock.transactions\n\t\t\t\t\t.filter((tx) =>\n\t\t\t\t\t\t'MoveCall' in tx\n\t\t\t\t\t\t\t? tx.MoveCall.package === packageId &&\n\t\t\t\t\t\t\t tx.MoveCall.module === 'zk_bag' &&\n\t\t\t\t\t\t\t tx.MoveCall.function === 'new'\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t)\n\t\t\t\t\t.map(async (tx) => {\n\t\t\t\t\t\tif (!('MoveCall' in tx)) {\n\t\t\t\t\t\t\tthrow new Error('Expected MoveCall');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst addressArg = tx.MoveCall.arguments?.[1];\n\n\t\t\t\t\t\tif (!addressArg || typeof addressArg !== 'object' || !('Input' in addressArg)) {\n\t\t\t\t\t\t\tthrow new Error('Invalid address argument');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst input = transactionBlock.inputs[addressArg.Input];\n\n\t\t\t\t\t\tif (input.type !== 'pure') {\n\t\t\t\t\t\t\tthrow new Error('Expected Address input to be a Pure value');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst address = normalizeSuiAddress(input.value as string);\n\n\t\t\t\t\t\tconst link = new ZkSendLink({\n\t\t\t\t\t\t\tnetwork,\n\t\t\t\t\t\t\taddress,\n\t\t\t\t\t\t\tcontract,\n\t\t\t\t\t\t\tisContractLink: true,\n\t\t\t\t\t\t\t...linkOptions,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tawait link.loadAssets({\n\t\t\t\t\t\t\ttransactionBlock: block,\n\t\t\t\t\t\t\tloadClaimedAssets,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn link;\n\t\t\t\t\t}),\n\t\t\t);\n\n\t\t\tconst regeneratedLinks = await Promise.all(\n\t\t\t\ttransactionBlock.transactions\n\t\t\t\t\t.filter((tx) =>\n\t\t\t\t\t\t'MoveCall' in tx\n\t\t\t\t\t\t\t? tx.MoveCall.package === packageId &&\n\t\t\t\t\t\t\t tx.MoveCall.module === 'zk_bag' &&\n\t\t\t\t\t\t\t tx.MoveCall.function === 'update_receiver'\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t)\n\t\t\t\t\t.map(async (tx) => {\n\t\t\t\t\t\tif (!('MoveCall' in tx)) {\n\t\t\t\t\t\t\tthrow new Error('Expected MoveCall');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst addressArg = tx.MoveCall.arguments?.[2];\n\n\t\t\t\t\t\tif (!addressArg || typeof addressArg !== 'object' || !('Input' in addressArg)) {\n\t\t\t\t\t\t\tthrow new Error('Invalid address argument');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst input = transactionBlock.inputs[addressArg.Input];\n\n\t\t\t\t\t\tif (input.type !== 'pure') {\n\t\t\t\t\t\t\tthrow new Error('Expected Address input to be a Pure value');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst address = normalizeSuiAddress(input.value as string);\n\n\t\t\t\t\t\tconst link = new ZkSendLink({\n\t\t\t\t\t\t\tnetwork,\n\t\t\t\t\t\t\taddress,\n\t\t\t\t\t\t\tcontract,\n\t\t\t\t\t\t\tisContractLink: true,\n\t\t\t\t\t\t\t...linkOptions,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tawait link.loadAssets({ loadClaimedAssets });\n\n\t\t\t\t\t\treturn link;\n\t\t\t\t\t}),\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\ttransactionBlock: block,\n\t\t\t\tlinks: [...newLinks, ...regeneratedLinks],\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn {\n\t\tdata,\n\t\tnextCursor: page.nextCursor,\n\t\thasNextPage: page.hasNextPage,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;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B;AAAA,QAClB,OAAO,CAAC,GAAG,UAAU,GAAG,gBAAgB;AAAA,MACzC;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA,YAAY,KAAK;AAAA,IACjB,aAAa,KAAK;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": ["address"]
|
|
7
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { ZkSendLink, type ZkSendLinkOptions } from './links/claim.js';
|
|
|
3
3
|
export { type ZkBagContractOptions, ZkBag } from './links/zk-bag.js';
|
|
4
4
|
export { isClaimTransaction } from './links/utils.js';
|
|
5
5
|
export { listCreatedLinks } from './links/list-created-links.js';
|
|
6
|
+
export { getSentTransactionBlocksWithLinks } from './links/get-sent-transaction-blocks.js';
|
|
6
7
|
export { MAINNET_CONTRACT_IDS } from './links/zk-bag.js';
|
|
7
8
|
export * from './wallet.js';
|
|
8
9
|
export * from './channel/index.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { ZkSendLink } from "./links/claim.js";
|
|
|
5
5
|
import { ZkBag } from "./links/zk-bag.js";
|
|
6
6
|
import { isClaimTransaction } from "./links/utils.js";
|
|
7
7
|
import { listCreatedLinks } from "./links/list-created-links.js";
|
|
8
|
+
import { getSentTransactionBlocksWithLinks } from "./links/get-sent-transaction-blocks.js";
|
|
8
9
|
import { MAINNET_CONTRACT_IDS } from "./links/zk-bag.js";
|
|
9
10
|
export * from "./wallet.js";
|
|
10
11
|
export * from "./channel/index.js";
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
ZkBag,
|
|
14
15
|
ZkSendLink,
|
|
15
16
|
ZkSendLinkBuilder,
|
|
17
|
+
getSentTransactionBlocksWithLinks,
|
|
16
18
|
isClaimTransaction,
|
|
17
19
|
listCreatedLinks
|
|
18
20
|
};
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n\tZkSendLinkBuilder,\n\ttype ZkSendLinkBuilderOptions,\n\ttype CreateZkSendLinkOptions,\n} from './links/builder.js';\nexport { ZkSendLink, type ZkSendLinkOptions } from './links/claim.js';\nexport { type ZkBagContractOptions, ZkBag } from './links/zk-bag.js';\nexport { isClaimTransaction } from './links/utils.js';\nexport { listCreatedLinks } from './links/list-created-links.js';\n\nexport { MAINNET_CONTRACT_IDS } from './links/zk-bag.js';\nexport * from './wallet.js';\nexport * from './channel/index.js';\n"],
|
|
5
|
-
"mappings": "AAGA;AAAA,EACC;AAAA,OAGM;AACP,SAAS,kBAA0C;AACnD,SAAoC,aAAa;AACjD,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n\tZkSendLinkBuilder,\n\ttype ZkSendLinkBuilderOptions,\n\ttype CreateZkSendLinkOptions,\n} from './links/builder.js';\nexport { ZkSendLink, type ZkSendLinkOptions } from './links/claim.js';\nexport { type ZkBagContractOptions, ZkBag } from './links/zk-bag.js';\nexport { isClaimTransaction } from './links/utils.js';\nexport { listCreatedLinks } from './links/list-created-links.js';\nexport { getSentTransactionBlocksWithLinks } from './links/get-sent-transaction-blocks.js';\n\nexport { MAINNET_CONTRACT_IDS } from './links/zk-bag.js';\nexport * from './wallet.js';\nexport * from './channel/index.js';\n"],
|
|
5
|
+
"mappings": "AAGA;AAAA,EACC;AAAA,OAGM;AACP,SAAS,kBAA0C;AACnD,SAAoC,aAAa;AACjD,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,yCAAyC;AAElD,SAAS,4BAA4B;AACrC,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SuiClient } from '@mysten/sui.js/client';
|
|
2
|
+
import type { SuiObjectData, SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
2
3
|
import type { Keypair } from '@mysten/sui.js/cryptography';
|
|
3
4
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
4
5
|
import type { ZkSendLinkBuilderOptions } from './builder.js';
|
|
@@ -28,11 +29,16 @@ export declare class ZkSendLink {
|
|
|
28
29
|
creatorAddress?: string;
|
|
29
30
|
assets?: LinkAssets;
|
|
30
31
|
claimed?: boolean;
|
|
32
|
+
bagObject?: SuiObjectData | null;
|
|
31
33
|
constructor({ network, claimApi, client, keypair, contract, address, host, path, isContractLink, }: ZkSendLinkOptions);
|
|
32
34
|
static fromUrl(url: string, options?: Omit<ZkSendLinkOptions, 'keypair' | 'address' | 'isContractLink'>): Promise<ZkSendLink>;
|
|
33
35
|
static fromAddress(address: string, options: Omit<ZkSendLinkOptions, 'keypair' | 'address' | 'isContractLink'>): Promise<ZkSendLink>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
loadClaimedStatus(): Promise<void>;
|
|
37
|
+
loadAssets(options?: {
|
|
38
|
+
transactionBlock?: SuiTransactionBlockResponse;
|
|
39
|
+
loadClaimedAssets?: boolean;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
claimAssets(address: string): Promise<SuiTransactionBlockResponse>;
|
|
36
42
|
createClaimTransaction(address: string, { reclaim, }?: {
|
|
37
43
|
reclaim?: boolean;
|
|
38
44
|
}): TransactionBlock;
|