@mysten/zksend 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/cjs/channel/events.d.ts +294 -0
- package/dist/cjs/channel/events.js +80 -0
- package/dist/cjs/channel/events.js.map +7 -0
- package/dist/cjs/channel/index.d.ts +38 -0
- package/dist/cjs/channel/index.js +172 -0
- package/dist/cjs/channel/index.js.map +7 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/links.d.ts +80 -0
- package/dist/cjs/links.js +373 -0
- package/dist/cjs/links.js.map +7 -0
- package/dist/cjs/utils/withResolvers.d.ts +6 -0
- package/dist/cjs/utils/withResolvers.js +33 -0
- package/dist/cjs/utils/withResolvers.js.map +7 -0
- package/dist/cjs/wallet.d.ts +24 -0
- package/dist/cjs/wallet.js +227 -0
- package/dist/cjs/wallet.js.map +7 -0
- package/dist/esm/channel/events.d.ts +294 -0
- package/dist/esm/channel/events.js +60 -0
- package/dist/esm/channel/events.js.map +7 -0
- package/dist/esm/channel/index.d.ts +38 -0
- package/dist/esm/channel/index.js +152 -0
- package/dist/esm/channel/index.js.map +7 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/links.d.ts +80 -0
- package/dist/esm/links.js +361 -0
- package/dist/esm/links.js.map +7 -0
- package/dist/esm/utils/withResolvers.d.ts +6 -0
- package/dist/esm/utils/withResolvers.js +13 -0
- package/dist/esm/utils/withResolvers.js.map +7 -0
- package/dist/esm/wallet.d.ts +24 -0
- package/dist/esm/wallet.js +197 -0
- package/dist/esm/wallet.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./links.js"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./wallet.js"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./channel/index.js"), module.exports);
|
|
2
21
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from './links.js';\nexport * from './wallet.js';\nexport * from './channel/index.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAGA,wBAAc,uBAHd;AAIA,wBAAc,wBAJd;AAKA,wBAAc,+BALd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { SuiClient } from '@mysten/sui.js/client';
|
|
2
|
+
import type { Keypair, Signer } from '@mysten/sui.js/cryptography';
|
|
3
|
+
import type { TransactionObjectInput } from '@mysten/sui.js/transactions';
|
|
4
|
+
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
5
|
+
interface ZkSendLinkRedirect {
|
|
6
|
+
url: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ZkSendLinkBuilderOptions {
|
|
10
|
+
host?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
mist?: number;
|
|
13
|
+
keypair?: Keypair;
|
|
14
|
+
client?: SuiClient;
|
|
15
|
+
sender: string;
|
|
16
|
+
redirect?: ZkSendLinkRedirect;
|
|
17
|
+
}
|
|
18
|
+
export interface ZkSendLinkOptions {
|
|
19
|
+
keypair?: Keypair;
|
|
20
|
+
client?: SuiClient;
|
|
21
|
+
}
|
|
22
|
+
interface CreateZkSendLinkOptions {
|
|
23
|
+
transactionBlock?: TransactionBlock;
|
|
24
|
+
calculateGas?: (options: {
|
|
25
|
+
balances: Map<string, bigint>;
|
|
26
|
+
objects: TransactionObjectInput[];
|
|
27
|
+
gasEstimateFromDryRun: bigint;
|
|
28
|
+
}) => Promise<bigint> | bigint;
|
|
29
|
+
}
|
|
30
|
+
export declare class ZkSendLinkBuilder {
|
|
31
|
+
#private;
|
|
32
|
+
constructor({ host, path, keypair, client, sender, redirect, }: ZkSendLinkBuilderOptions);
|
|
33
|
+
addClaimableMist(amount: bigint): void;
|
|
34
|
+
addClaimableBalance(coinType: string, amount: bigint): void;
|
|
35
|
+
addClaimableObject(id: string): void;
|
|
36
|
+
getLink(): string;
|
|
37
|
+
create({ signer, ...options }: CreateZkSendLinkOptions & {
|
|
38
|
+
signer: Signer;
|
|
39
|
+
}): Promise<import("@mysten/sui.js/client").SuiTransactionBlockResponse>;
|
|
40
|
+
createSendTransaction({ transactionBlock: txb, calculateGas, }?: CreateZkSendLinkOptions): Promise<TransactionBlock>;
|
|
41
|
+
}
|
|
42
|
+
export interface ZkSendLinkOptions {
|
|
43
|
+
keypair?: Keypair;
|
|
44
|
+
client?: SuiClient;
|
|
45
|
+
}
|
|
46
|
+
export declare class ZkSendLink {
|
|
47
|
+
#private;
|
|
48
|
+
constructor({ client, keypair, }: ZkSendLinkOptions & {
|
|
49
|
+
linkAddress?: string;
|
|
50
|
+
});
|
|
51
|
+
static fromUrl(url: string, options?: Omit<ZkSendLinkOptions, 'keypair'>): Promise<ZkSendLink>;
|
|
52
|
+
loadOwnedData(): Promise<void>;
|
|
53
|
+
listClaimableAssets(address: string, options?: {
|
|
54
|
+
claimObjectsAddedAfterCreation?: boolean;
|
|
55
|
+
coinTypes?: string[];
|
|
56
|
+
objects?: string[];
|
|
57
|
+
}): Promise<{
|
|
58
|
+
balances: {
|
|
59
|
+
coinType: string;
|
|
60
|
+
amount: bigint;
|
|
61
|
+
}[];
|
|
62
|
+
nfts: {
|
|
63
|
+
objectId: string;
|
|
64
|
+
type: string;
|
|
65
|
+
version: string;
|
|
66
|
+
digest: string;
|
|
67
|
+
}[];
|
|
68
|
+
}>;
|
|
69
|
+
claimAssets(address: string, options?: {
|
|
70
|
+
claimObjectsAddedAfterCreation?: boolean;
|
|
71
|
+
coinTypes?: string[];
|
|
72
|
+
objects?: string[];
|
|
73
|
+
}): Promise<import("@mysten/sui.js/client").SuiTransactionBlockResponse>;
|
|
74
|
+
createClaimTransaction(address: string, options?: {
|
|
75
|
+
claimObjectsAddedAfterCreation?: boolean;
|
|
76
|
+
coinTypes?: string[];
|
|
77
|
+
objects?: string[];
|
|
78
|
+
}): TransactionBlock;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,373 @@
|
|
|
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 links_exports = {};
|
|
42
|
+
__export(links_exports, {
|
|
43
|
+
ZkSendLink: () => ZkSendLink,
|
|
44
|
+
ZkSendLinkBuilder: () => ZkSendLinkBuilder
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(links_exports);
|
|
47
|
+
var import_client = require("@mysten/sui.js/client");
|
|
48
|
+
var import_cryptography = require("@mysten/sui.js/cryptography");
|
|
49
|
+
var import_ed25519 = require("@mysten/sui.js/keypairs/ed25519");
|
|
50
|
+
var import_transactions = require("@mysten/sui.js/transactions");
|
|
51
|
+
var import_utils = require("@mysten/sui.js/utils");
|
|
52
|
+
var _host, _path, _keypair, _client, _redirect, _objects, _balances, _sender, _coinsByType, _estimateClaimGasFee, estimateClaimGasFee_fn, _getCoinsByType, getCoinsByType_fn, _client2, _keypair2, _initiallyOwnedObjects, _ownedObjects, _gasCoin, _hasSui, _creatorAddress, _loadOwnedObjects, loadOwnedObjects_fn, _loadInitialTransactionData, loadInitialTransactionData_fn;
|
|
53
|
+
const DEFAULT_ZK_SEND_LINK_OPTIONS = {
|
|
54
|
+
host: "https://zksend.com",
|
|
55
|
+
path: "/claim",
|
|
56
|
+
client: new import_client.SuiClient({ url: (0, import_client.getFullnodeUrl)("mainnet") })
|
|
57
|
+
};
|
|
58
|
+
const SUI_COIN_TYPE = (0, import_utils.normalizeStructTag)(import_utils.SUI_TYPE_ARG);
|
|
59
|
+
const SUI_COIN_OBJECT_TYPE = (0, import_utils.normalizeStructTag)("0x2::coin::Coin<0x2::sui::SUI>");
|
|
60
|
+
class ZkSendLinkBuilder {
|
|
61
|
+
constructor({
|
|
62
|
+
host = DEFAULT_ZK_SEND_LINK_OPTIONS.host,
|
|
63
|
+
path = DEFAULT_ZK_SEND_LINK_OPTIONS.path,
|
|
64
|
+
keypair = new import_ed25519.Ed25519Keypair(),
|
|
65
|
+
client = DEFAULT_ZK_SEND_LINK_OPTIONS.client,
|
|
66
|
+
sender,
|
|
67
|
+
redirect
|
|
68
|
+
}) {
|
|
69
|
+
__privateAdd(this, _estimateClaimGasFee);
|
|
70
|
+
__privateAdd(this, _getCoinsByType);
|
|
71
|
+
__privateAdd(this, _host, void 0);
|
|
72
|
+
__privateAdd(this, _path, void 0);
|
|
73
|
+
__privateAdd(this, _keypair, void 0);
|
|
74
|
+
__privateAdd(this, _client, void 0);
|
|
75
|
+
__privateAdd(this, _redirect, void 0);
|
|
76
|
+
__privateAdd(this, _objects, /* @__PURE__ */ new Set());
|
|
77
|
+
__privateAdd(this, _balances, /* @__PURE__ */ new Map());
|
|
78
|
+
__privateAdd(this, _sender, void 0);
|
|
79
|
+
__privateAdd(this, _coinsByType, /* @__PURE__ */ new Map());
|
|
80
|
+
__privateSet(this, _host, host);
|
|
81
|
+
__privateSet(this, _path, path);
|
|
82
|
+
__privateSet(this, _redirect, redirect);
|
|
83
|
+
__privateSet(this, _keypair, keypair);
|
|
84
|
+
__privateSet(this, _client, client);
|
|
85
|
+
__privateSet(this, _sender, (0, import_utils.normalizeSuiAddress)(sender));
|
|
86
|
+
}
|
|
87
|
+
addClaimableMist(amount) {
|
|
88
|
+
this.addClaimableBalance(SUI_COIN_TYPE, amount);
|
|
89
|
+
}
|
|
90
|
+
addClaimableBalance(coinType, amount) {
|
|
91
|
+
__privateGet(this, _balances).set((0, import_utils.normalizeStructTag)(coinType), (__privateGet(this, _balances).get(coinType) ?? 0n) + amount);
|
|
92
|
+
}
|
|
93
|
+
addClaimableObject(id) {
|
|
94
|
+
__privateGet(this, _objects).add(id);
|
|
95
|
+
}
|
|
96
|
+
getLink() {
|
|
97
|
+
const link = new URL(__privateGet(this, _host));
|
|
98
|
+
link.pathname = __privateGet(this, _path);
|
|
99
|
+
link.hash = (0, import_utils.toB64)((0, import_cryptography.decodeSuiPrivateKey)(__privateGet(this, _keypair).getSecretKey()).secretKey);
|
|
100
|
+
if (__privateGet(this, _redirect)) {
|
|
101
|
+
link.searchParams.set("redirect_url", __privateGet(this, _redirect).url);
|
|
102
|
+
if (__privateGet(this, _redirect).name) {
|
|
103
|
+
link.searchParams.set("name", __privateGet(this, _redirect).name);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return link.toString();
|
|
107
|
+
}
|
|
108
|
+
async create({
|
|
109
|
+
signer,
|
|
110
|
+
...options
|
|
111
|
+
}) {
|
|
112
|
+
const txb = await this.createSendTransaction(options);
|
|
113
|
+
return __privateGet(this, _client).signAndExecuteTransactionBlock({
|
|
114
|
+
transactionBlock: await txb.build({ client: __privateGet(this, _client) }),
|
|
115
|
+
signer
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async createSendTransaction({
|
|
119
|
+
transactionBlock: txb = new import_transactions.TransactionBlock(),
|
|
120
|
+
calculateGas
|
|
121
|
+
} = {}) {
|
|
122
|
+
const gasEstimateFromDryRun = await __privateMethod(this, _estimateClaimGasFee, estimateClaimGasFee_fn).call(this);
|
|
123
|
+
const baseGasAmount = calculateGas ? await calculateGas({
|
|
124
|
+
balances: __privateGet(this, _balances),
|
|
125
|
+
objects: [...__privateGet(this, _objects)],
|
|
126
|
+
gasEstimateFromDryRun
|
|
127
|
+
}) : gasEstimateFromDryRun * 2n;
|
|
128
|
+
const gasWithBuffer = baseGasAmount + 1013n;
|
|
129
|
+
const roundedGasAmount = gasWithBuffer - gasWithBuffer % 1000n - 13n;
|
|
130
|
+
const address = __privateGet(this, _keypair).toSuiAddress();
|
|
131
|
+
const objectsToTransfer = [...__privateGet(this, _objects)].map((id) => txb.object(id));
|
|
132
|
+
const [gas] = txb.splitCoins(txb.gas, [roundedGasAmount]);
|
|
133
|
+
objectsToTransfer.push(gas);
|
|
134
|
+
txb.setSenderIfNotSet(__privateGet(this, _sender));
|
|
135
|
+
for (const [coinType, amount] of __privateGet(this, _balances)) {
|
|
136
|
+
if (coinType === SUI_COIN_TYPE) {
|
|
137
|
+
const [sui] = txb.splitCoins(txb.gas, [amount]);
|
|
138
|
+
objectsToTransfer.push(sui);
|
|
139
|
+
} else {
|
|
140
|
+
const coins = (await __privateMethod(this, _getCoinsByType, getCoinsByType_fn).call(this, coinType)).map((coin) => coin.coinObjectId);
|
|
141
|
+
if (coins.length > 1) {
|
|
142
|
+
txb.mergeCoins(coins[0], coins.slice(1));
|
|
143
|
+
}
|
|
144
|
+
const [split] = txb.splitCoins(coins[0], [amount]);
|
|
145
|
+
objectsToTransfer.push(split);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
txb.transferObjects(objectsToTransfer, address);
|
|
149
|
+
return txb;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
_host = new WeakMap();
|
|
153
|
+
_path = new WeakMap();
|
|
154
|
+
_keypair = new WeakMap();
|
|
155
|
+
_client = new WeakMap();
|
|
156
|
+
_redirect = new WeakMap();
|
|
157
|
+
_objects = new WeakMap();
|
|
158
|
+
_balances = new WeakMap();
|
|
159
|
+
_sender = new WeakMap();
|
|
160
|
+
_coinsByType = new WeakMap();
|
|
161
|
+
_estimateClaimGasFee = new WeakSet();
|
|
162
|
+
estimateClaimGasFee_fn = async function() {
|
|
163
|
+
const txb = new import_transactions.TransactionBlock();
|
|
164
|
+
txb.setSender(__privateGet(this, _sender));
|
|
165
|
+
txb.setGasPayment([]);
|
|
166
|
+
txb.transferObjects([txb.gas], __privateGet(this, _keypair).toSuiAddress());
|
|
167
|
+
const idsToTransfer = [...__privateGet(this, _objects)];
|
|
168
|
+
for (const [coinType] of __privateGet(this, _balances)) {
|
|
169
|
+
const coins = await __privateMethod(this, _getCoinsByType, getCoinsByType_fn).call(this, coinType);
|
|
170
|
+
if (!coins.length) {
|
|
171
|
+
throw new Error(`Sending account does not contain any coins of type ${coinType}`);
|
|
172
|
+
}
|
|
173
|
+
idsToTransfer.push(coins[0].coinObjectId);
|
|
174
|
+
}
|
|
175
|
+
if (idsToTransfer.length > 0) {
|
|
176
|
+
txb.transferObjects(
|
|
177
|
+
idsToTransfer.map((id) => txb.object(id)),
|
|
178
|
+
__privateGet(this, _keypair).toSuiAddress()
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const result = await __privateGet(this, _client).dryRunTransactionBlock({
|
|
182
|
+
transactionBlock: await txb.build({ client: __privateGet(this, _client) })
|
|
183
|
+
});
|
|
184
|
+
return BigInt(result.effects.gasUsed.computationCost) + BigInt(result.effects.gasUsed.storageCost) - BigInt(result.effects.gasUsed.storageRebate);
|
|
185
|
+
};
|
|
186
|
+
_getCoinsByType = new WeakSet();
|
|
187
|
+
getCoinsByType_fn = async function(coinType) {
|
|
188
|
+
if (__privateGet(this, _coinsByType).has(coinType)) {
|
|
189
|
+
return __privateGet(this, _coinsByType).get(coinType);
|
|
190
|
+
}
|
|
191
|
+
const coins = await __privateGet(this, _client).getCoins({
|
|
192
|
+
coinType,
|
|
193
|
+
owner: __privateGet(this, _sender)
|
|
194
|
+
});
|
|
195
|
+
__privateGet(this, _coinsByType).set(coinType, coins.data);
|
|
196
|
+
return coins.data;
|
|
197
|
+
};
|
|
198
|
+
const _ZkSendLink = class {
|
|
199
|
+
constructor({
|
|
200
|
+
client = DEFAULT_ZK_SEND_LINK_OPTIONS.client,
|
|
201
|
+
keypair = new import_ed25519.Ed25519Keypair()
|
|
202
|
+
}) {
|
|
203
|
+
__privateAdd(this, _loadOwnedObjects);
|
|
204
|
+
__privateAdd(this, _loadInitialTransactionData);
|
|
205
|
+
__privateAdd(this, _client2, void 0);
|
|
206
|
+
__privateAdd(this, _keypair2, void 0);
|
|
207
|
+
__privateAdd(this, _initiallyOwnedObjects, /* @__PURE__ */ new Set());
|
|
208
|
+
__privateAdd(this, _ownedObjects, []);
|
|
209
|
+
__privateAdd(this, _gasCoin, void 0);
|
|
210
|
+
__privateAdd(this, _hasSui, false);
|
|
211
|
+
__privateAdd(this, _creatorAddress, void 0);
|
|
212
|
+
__privateSet(this, _client2, client);
|
|
213
|
+
__privateSet(this, _keypair2, keypair);
|
|
214
|
+
}
|
|
215
|
+
static async fromUrl(url, options) {
|
|
216
|
+
const parsed = new URL(url);
|
|
217
|
+
const keypair = import_ed25519.Ed25519Keypair.fromSecretKey((0, import_utils.fromB64)(parsed.hash.slice(1)));
|
|
218
|
+
const link = new _ZkSendLink({
|
|
219
|
+
...options,
|
|
220
|
+
keypair
|
|
221
|
+
});
|
|
222
|
+
await link.loadOwnedData();
|
|
223
|
+
return link;
|
|
224
|
+
}
|
|
225
|
+
async loadOwnedData() {
|
|
226
|
+
await Promise.all([__privateMethod(this, _loadInitialTransactionData, loadInitialTransactionData_fn).call(this), __privateMethod(this, _loadOwnedObjects, loadOwnedObjects_fn).call(this)]);
|
|
227
|
+
}
|
|
228
|
+
async listClaimableAssets(address, options) {
|
|
229
|
+
const normalizedAddress = (0, import_utils.normalizeSuiAddress)(address);
|
|
230
|
+
const txb = this.createClaimTransaction(normalizedAddress, options);
|
|
231
|
+
if (__privateGet(this, _gasCoin) || !__privateGet(this, _hasSui)) {
|
|
232
|
+
txb.setGasPayment([]);
|
|
233
|
+
}
|
|
234
|
+
const dryRun = await __privateGet(this, _client2).dryRunTransactionBlock({
|
|
235
|
+
transactionBlock: await txb.build({ client: __privateGet(this, _client2) })
|
|
236
|
+
});
|
|
237
|
+
const balances = [];
|
|
238
|
+
const nfts = [];
|
|
239
|
+
dryRun.balanceChanges.forEach((balanceChange) => {
|
|
240
|
+
if (BigInt(balanceChange.amount) > 0n && isOwner(balanceChange.owner, normalizedAddress)) {
|
|
241
|
+
balances.push({ coinType: balanceChange.coinType, amount: BigInt(balanceChange.amount) });
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
dryRun.objectChanges.forEach((objectChange) => {
|
|
245
|
+
if ("objectType" in objectChange) {
|
|
246
|
+
const type = (0, import_utils.parseStructTag)(objectChange.objectType);
|
|
247
|
+
if (type.address === (0, import_utils.normalizeSuiAddress)("0x2") && type.module === "coin" && type.name === "Coin") {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (ownedAfterChange(objectChange, normalizedAddress)) {
|
|
252
|
+
nfts.push(objectChange);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
balances,
|
|
257
|
+
nfts
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async claimAssets(address, options) {
|
|
261
|
+
return __privateGet(this, _client2).signAndExecuteTransactionBlock({
|
|
262
|
+
transactionBlock: await this.createClaimTransaction(address, options),
|
|
263
|
+
signer: __privateGet(this, _keypair2)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
createClaimTransaction(address, options) {
|
|
267
|
+
const claimAll = !options?.coinTypes && !options?.objects;
|
|
268
|
+
const txb = new import_transactions.TransactionBlock();
|
|
269
|
+
txb.setSender(__privateGet(this, _keypair2).toSuiAddress());
|
|
270
|
+
const coinTypes = new Set(
|
|
271
|
+
options?.coinTypes?.map((type) => (0, import_utils.normalizeStructTag)(`0x2::coin::Coin<${type}>`)) ?? []
|
|
272
|
+
);
|
|
273
|
+
const objectsToTransfer = __privateGet(this, _ownedObjects).filter((object) => {
|
|
274
|
+
if (__privateGet(this, _gasCoin)) {
|
|
275
|
+
if (object.objectId === __privateGet(this, _gasCoin).coinObjectId) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
} else if (object.type === SUI_COIN_OBJECT_TYPE) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (coinTypes?.has(object.type) || options?.objects?.includes(object.objectId)) {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
if (!options?.claimObjectsAddedAfterCreation && !__privateGet(this, _initiallyOwnedObjects).has(object.objectId)) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
return claimAll;
|
|
288
|
+
}).map((object) => txb.object(object.objectId));
|
|
289
|
+
if (__privateGet(this, _gasCoin) && __privateGet(this, _creatorAddress)) {
|
|
290
|
+
txb.transferObjects([txb.gas], __privateGet(this, _creatorAddress));
|
|
291
|
+
} else if (claimAll || coinTypes?.has(SUI_COIN_TYPE)) {
|
|
292
|
+
objectsToTransfer.push(txb.gas);
|
|
293
|
+
}
|
|
294
|
+
if (objectsToTransfer.length > 0) {
|
|
295
|
+
txb.transferObjects(objectsToTransfer, address);
|
|
296
|
+
}
|
|
297
|
+
return txb;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
let ZkSendLink = _ZkSendLink;
|
|
301
|
+
_client2 = new WeakMap();
|
|
302
|
+
_keypair2 = new WeakMap();
|
|
303
|
+
_initiallyOwnedObjects = new WeakMap();
|
|
304
|
+
_ownedObjects = new WeakMap();
|
|
305
|
+
_gasCoin = new WeakMap();
|
|
306
|
+
_hasSui = new WeakMap();
|
|
307
|
+
_creatorAddress = new WeakMap();
|
|
308
|
+
_loadOwnedObjects = new WeakSet();
|
|
309
|
+
loadOwnedObjects_fn = async function() {
|
|
310
|
+
__privateSet(this, _ownedObjects, []);
|
|
311
|
+
let nextCursor;
|
|
312
|
+
const owner = __privateGet(this, _keypair2).toSuiAddress();
|
|
313
|
+
do {
|
|
314
|
+
const ownedObjects = await __privateGet(this, _client2).getOwnedObjects({
|
|
315
|
+
cursor: nextCursor,
|
|
316
|
+
owner,
|
|
317
|
+
options: {
|
|
318
|
+
showType: true
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
nextCursor = ownedObjects.hasNextPage ? ownedObjects.nextCursor : null;
|
|
322
|
+
for (const object of ownedObjects.data) {
|
|
323
|
+
if (object.data) {
|
|
324
|
+
__privateGet(this, _ownedObjects).push({
|
|
325
|
+
objectId: (0, import_utils.normalizeSuiObjectId)(object.data.objectId),
|
|
326
|
+
version: object.data.version,
|
|
327
|
+
digest: object.data.digest,
|
|
328
|
+
type: (0, import_utils.normalizeStructTag)(object.data.type)
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} while (nextCursor);
|
|
333
|
+
const coins = await __privateGet(this, _client2).getCoins({
|
|
334
|
+
coinType: SUI_COIN_TYPE,
|
|
335
|
+
owner
|
|
336
|
+
});
|
|
337
|
+
__privateSet(this, _hasSui, coins.data.length > 0);
|
|
338
|
+
__privateSet(this, _gasCoin, coins.data.find((coin) => BigInt(coin.balance) % 1000n === 987n));
|
|
339
|
+
};
|
|
340
|
+
_loadInitialTransactionData = new WeakSet();
|
|
341
|
+
loadInitialTransactionData_fn = async function() {
|
|
342
|
+
const address = __privateGet(this, _keypair2).toSuiAddress();
|
|
343
|
+
const result = await __privateGet(this, _client2).queryTransactionBlocks({
|
|
344
|
+
limit: 1,
|
|
345
|
+
order: "ascending",
|
|
346
|
+
filter: {
|
|
347
|
+
ToAddress: address
|
|
348
|
+
},
|
|
349
|
+
options: {
|
|
350
|
+
showObjectChanges: true,
|
|
351
|
+
showInput: true
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
result.data[0]?.objectChanges?.forEach((objectChange) => {
|
|
355
|
+
if (ownedAfterChange(objectChange, address)) {
|
|
356
|
+
__privateGet(this, _initiallyOwnedObjects).add((0, import_utils.normalizeSuiObjectId)(objectChange.objectId));
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
__privateSet(this, _creatorAddress, result.data[0]?.transaction?.data.sender);
|
|
360
|
+
};
|
|
361
|
+
function ownedAfterChange(objectChange, address) {
|
|
362
|
+
if (objectChange.type === "transferred" && isOwner(objectChange.recipient, address)) {
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
if ((objectChange.type === "created" || objectChange.type === "mutated") && isOwner(objectChange.owner, address)) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
function isOwner(owner, address) {
|
|
371
|
+
return owner && typeof owner === "object" && "AddressOwner" in owner && (0, import_utils.normalizeSuiAddress)(owner.AddressOwner) === address;
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/links.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 { CoinStruct, ObjectOwner, SuiObjectChange } from '@mysten/sui.js/client';\nimport { decodeSuiPrivateKey } from '@mysten/sui.js/cryptography';\nimport type { Keypair, Signer } from '@mysten/sui.js/cryptography';\nimport { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport type { TransactionObjectInput } from '@mysten/sui.js/transactions';\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\ninterface ZkSendLinkRedirect {\n\turl: string;\n\tname?: string;\n}\n\nexport interface ZkSendLinkBuilderOptions {\n\thost?: string;\n\tpath?: string;\n\tmist?: number;\n\tkeypair?: Keypair;\n\tclient?: SuiClient;\n\tsender: string;\n\tredirect?: ZkSendLinkRedirect;\n}\n\nexport interface ZkSendLinkOptions {\n\tkeypair?: Keypair;\n\tclient?: SuiClient;\n}\n\nconst DEFAULT_ZK_SEND_LINK_OPTIONS = {\n\thost: 'https://zksend.com',\n\tpath: '/claim',\n\tclient: new SuiClient({ url: getFullnodeUrl('mainnet') }),\n};\n\nconst SUI_COIN_TYPE = normalizeStructTag(SUI_TYPE_ARG);\nconst SUI_COIN_OBJECT_TYPE = normalizeStructTag('0x2::coin::Coin<0x2::sui::SUI>');\n\ninterface CreateZkSendLinkOptions {\n\ttransactionBlock?: TransactionBlock;\n\tcalculateGas?: (options: {\n\t\tbalances: Map<string, bigint>;\n\t\tobjects: TransactionObjectInput[];\n\t\tgasEstimateFromDryRun: bigint;\n\t}) => Promise<bigint> | bigint;\n}\n\nexport class ZkSendLinkBuilder {\n\t#host: string;\n\t#path: string;\n\t#keypair: Keypair;\n\t#client: SuiClient;\n\t#redirect?: ZkSendLinkRedirect;\n\t#objects = new Set<TransactionObjectInput>();\n\t#balances = new Map<string, bigint>();\n\t#sender: string;\n\n\t#coinsByType = new Map<string, CoinStruct[]>();\n\n\tconstructor({\n\t\thost = DEFAULT_ZK_SEND_LINK_OPTIONS.host,\n\t\tpath = DEFAULT_ZK_SEND_LINK_OPTIONS.path,\n\t\tkeypair = new Ed25519Keypair(),\n\t\tclient = DEFAULT_ZK_SEND_LINK_OPTIONS.client,\n\t\tsender,\n\t\tredirect,\n\t}: ZkSendLinkBuilderOptions) {\n\t\tthis.#host = host;\n\t\tthis.#path = path;\n\t\tthis.#redirect = redirect;\n\t\tthis.#keypair = keypair;\n\t\tthis.#client = client;\n\t\tthis.#sender = normalizeSuiAddress(sender);\n\t}\n\n\taddClaimableMist(amount: bigint) {\n\t\tthis.addClaimableBalance(SUI_COIN_TYPE, amount);\n\t}\n\n\taddClaimableBalance(coinType: string, amount: bigint) {\n\t\tthis.#balances.set(normalizeStructTag(coinType), (this.#balances.get(coinType) ?? 0n) + amount);\n\t}\n\n\taddClaimableObject(id: string) {\n\t\tthis.#objects.add(id);\n\t}\n\n\tgetLink(): string {\n\t\tconst link = new URL(this.#host);\n\t\tlink.pathname = this.#path;\n\t\tlink.hash = toB64(decodeSuiPrivateKey(this.#keypair.getSecretKey()).secretKey);\n\n\t\tif (this.#redirect) {\n\t\t\tlink.searchParams.set('redirect_url', this.#redirect.url);\n\t\t\tif (this.#redirect.name) {\n\t\t\t\tlink.searchParams.set('name', this.#redirect.name);\n\t\t\t}\n\t\t}\n\n\t\treturn link.toString();\n\t}\n\n\tasync create({\n\t\tsigner,\n\t\t...options\n\t}: CreateZkSendLinkOptions & {\n\t\tsigner: Signer;\n\t}) {\n\t\tconst txb = await this.createSendTransaction(options);\n\n\t\treturn this.#client.signAndExecuteTransactionBlock({\n\t\t\ttransactionBlock: await txb.build({ client: this.#client }),\n\t\t\tsigner,\n\t\t});\n\t}\n\tasync createSendTransaction({\n\t\ttransactionBlock: txb = new TransactionBlock(),\n\t\tcalculateGas,\n\t}: CreateZkSendLinkOptions = {}) {\n\t\tconst gasEstimateFromDryRun = await this.#estimateClaimGasFee();\n\t\tconst baseGasAmount = calculateGas\n\t\t\t? await calculateGas({\n\t\t\t\t\tbalances: this.#balances,\n\t\t\t\t\tobjects: [...this.#objects],\n\t\t\t\t\tgasEstimateFromDryRun,\n\t\t\t })\n\t\t\t: gasEstimateFromDryRun * 2n;\n\n\t\t// Ensure that rounded gas is not less than the calculated gas\n\t\tconst gasWithBuffer = baseGasAmount + 1013n;\n\t\t// Ensure that gas amount ends in 987\n\t\tconst roundedGasAmount = gasWithBuffer - (gasWithBuffer % 1000n) - 13n;\n\n\t\tconst address = this.#keypair.toSuiAddress();\n\t\tconst objectsToTransfer = [...this.#objects].map((id) => txb.object(id));\n\t\tconst [gas] = txb.splitCoins(txb.gas, [roundedGasAmount]);\n\t\tobjectsToTransfer.push(gas);\n\n\t\ttxb.setSenderIfNotSet(this.#sender);\n\n\t\tfor (const [coinType, amount] of this.#balances) {\n\t\t\tif (coinType === SUI_COIN_TYPE) {\n\t\t\t\tconst [sui] = txb.splitCoins(txb.gas, [amount]);\n\t\t\t\tobjectsToTransfer.push(sui);\n\t\t\t} else {\n\t\t\t\tconst coins = (await this.#getCoinsByType(coinType)).map((coin) => coin.coinObjectId);\n\n\t\t\t\tif (coins.length > 1) {\n\t\t\t\t\ttxb.mergeCoins(coins[0], coins.slice(1));\n\t\t\t\t}\n\t\t\t\tconst [split] = txb.splitCoins(coins[0], [amount]);\n\t\t\t\tobjectsToTransfer.push(split);\n\t\t\t}\n\t\t}\n\n\t\ttxb.transferObjects(objectsToTransfer, address);\n\n\t\treturn txb;\n\t}\n\n\tasync #estimateClaimGasFee(): Promise<bigint> {\n\t\tconst txb = new TransactionBlock();\n\t\ttxb.setSender(this.#sender);\n\t\ttxb.setGasPayment([]);\n\t\ttxb.transferObjects([txb.gas], this.#keypair.toSuiAddress());\n\n\t\tconst idsToTransfer = [...this.#objects];\n\n\t\tfor (const [coinType] of this.#balances) {\n\t\t\tconst coins = await this.#getCoinsByType(coinType);\n\n\t\t\tif (!coins.length) {\n\t\t\t\tthrow new Error(`Sending account does not contain any coins of type ${coinType}`);\n\t\t\t}\n\n\t\t\tidsToTransfer.push(coins[0].coinObjectId);\n\t\t}\n\n\t\tif (idsToTransfer.length > 0) {\n\t\t\ttxb.transferObjects(\n\t\t\t\tidsToTransfer.map((id) => txb.object(id)),\n\t\t\t\tthis.#keypair.toSuiAddress(),\n\t\t\t);\n\t\t}\n\n\t\tconst result = await this.#client.dryRunTransactionBlock({\n\t\t\ttransactionBlock: await txb.build({ client: this.#client }),\n\t\t});\n\n\t\treturn (\n\t\t\tBigInt(result.effects.gasUsed.computationCost) +\n\t\t\tBigInt(result.effects.gasUsed.storageCost) -\n\t\t\tBigInt(result.effects.gasUsed.storageRebate)\n\t\t);\n\t}\n\n\tasync #getCoinsByType(coinType: string) {\n\t\tif (this.#coinsByType.has(coinType)) {\n\t\t\treturn this.#coinsByType.get(coinType)!;\n\t\t}\n\n\t\tconst coins = await this.#client.getCoins({\n\t\t\tcoinType,\n\t\t\towner: this.#sender,\n\t\t});\n\n\t\tthis.#coinsByType.set(coinType, coins.data);\n\n\t\treturn coins.data;\n\t}\n}\n\nexport interface ZkSendLinkOptions {\n\tkeypair?: Keypair;\n\tclient?: SuiClient;\n}\nexport class ZkSendLink {\n\t#client: SuiClient;\n\t#keypair: Keypair;\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#gasCoin?: CoinStruct;\n\t#hasSui = false;\n\t#creatorAddress?: string;\n\n\tconstructor({\n\t\tclient = DEFAULT_ZK_SEND_LINK_OPTIONS.client,\n\t\tkeypair = new Ed25519Keypair(),\n\t}: ZkSendLinkOptions & { linkAddress?: string }) {\n\t\tthis.#client = client;\n\t\tthis.#keypair = keypair;\n\t}\n\n\tstatic async fromUrl(url: string, options?: Omit<ZkSendLinkOptions, 'keypair'>) {\n\t\tconst parsed = new URL(url);\n\t\tconst keypair = Ed25519Keypair.fromSecretKey(fromB64(parsed.hash.slice(1)));\n\n\t\tconst link = new ZkSendLink({\n\t\t\t...options,\n\t\t\tkeypair,\n\t\t});\n\n\t\tawait link.loadOwnedData();\n\n\t\treturn link;\n\t}\n\n\tasync loadOwnedData() {\n\t\tawait Promise.all([this.#loadInitialTransactionData(), this.#loadOwnedObjects()]);\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\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\tdryRun.balanceChanges.forEach((balanceChange) => {\n\t\t\tif (BigInt(balanceChange.amount) > 0n && isOwner(balanceChange.owner, normalizedAddress)) {\n\t\t\t\tbalances.push({ coinType: balanceChange.coinType, amount: BigInt(balanceChange.amount) });\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\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};\n\t}\n\n\tasync claimAssets(\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\treturn this.#client.signAndExecuteTransactionBlock({\n\t\t\ttransactionBlock: await this.createClaimTransaction(address, options),\n\t\t\tsigner: this.#keypair,\n\t\t});\n\t}\n\n\tcreateClaimTransaction(\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 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\tconst owner = this.#keypair.toSuiAddress();\n\t\tdo {\n\t\t\tconst ownedObjects = await this.#client.getOwnedObjects({\n\t\t\t\tcursor: nextCursor,\n\t\t\t\towner,\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,\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 address = this.#keypair.toSuiAddress();\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: 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, 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;AAAA;AAGA,oBAA0C;AAE1C,0BAAoC;AAEpC,qBAA+B;AAE/B,0BAAiC;AACjC,mBAQO;AAlBP,8KAAAA,UAAAC,WAAA;AAwCA,MAAM,+BAA+B;AAAA,EACpC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ,IAAI,wBAAU,EAAE,SAAK,8BAAe,SAAS,EAAE,CAAC;AACzD;AAEA,MAAM,oBAAgB,iCAAmB,yBAAY;AACrD,MAAM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 -0,0 +1,33 @@
|
|
|
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 withResolvers_exports = {};
|
|
20
|
+
__export(withResolvers_exports, {
|
|
21
|
+
withResolvers: () => withResolvers
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(withResolvers_exports);
|
|
24
|
+
function withResolvers() {
|
|
25
|
+
let resolve;
|
|
26
|
+
let reject;
|
|
27
|
+
const promise = new Promise((res, rej) => {
|
|
28
|
+
resolve = res;
|
|
29
|
+
reject = rej;
|
|
30
|
+
});
|
|
31
|
+
return { promise, reject, resolve };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=withResolvers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/withResolvers.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface Resolvers<T = any> {\n\tpromise: Promise<T>;\n\treject: (error: Error) => void;\n\tresolve: (value: T) => void;\n}\n\nexport function withResolvers<T = any>(): Resolvers<T> {\n\tlet resolve: (value: T) => void;\n\tlet reject: (error: Error) => void;\n\n\tconst promise = new Promise<T>((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\n\treturn { promise, reject: reject!, resolve: resolve! };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,gBAAuC;AACtD,MAAI;AACJ,MAAI;AAEJ,QAAM,UAAU,IAAI,QAAW,CAAC,KAAK,QAAQ;AAC5C,cAAU;AACV,aAAS;AAAA,EACV,CAAC;AAED,SAAO,EAAE,SAAS,QAAiB,QAAkB;AACtD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature, SuiSignPersonalMessageFeature, SuiSignTransactionBlockFeature, Wallet } from '@mysten/wallet-standard';
|
|
2
|
+
import { ReadonlyWalletAccount } from '@mysten/wallet-standard';
|
|
3
|
+
export declare const ZKSEND_WALLET_NAME: "zkSend";
|
|
4
|
+
export declare class ZkSendWallet implements Wallet {
|
|
5
|
+
#private;
|
|
6
|
+
get name(): "zkSend";
|
|
7
|
+
get icon(): "data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjMyIiB2aWV3Qm94PSIwIDAgMzIgMzIiIHdpZHRoPSIzMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGNsaXBQYXRoIGlkPSJhIj48cmVjdCBoZWlnaHQ9IjMyIiByeD0iMiIgd2lkdGg9IjMyIi8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjYSkiPjxyZWN0IGZpbGw9IiNmZmYiIGhlaWdodD0iMzIiIHJ4PSIyIiB3aWR0aD0iMzIiLz48cGF0aCBkPSJtMCAwaDMydjMyaC0zMnoiIGZpbGw9IiNkNDA1NTEiLz48cGF0aCBkPSJtNS42NjgyNSAyNS4yNDkxYy0uNzgyNjMtLjc4MjctLjc4MDgxLTIuMDUyMS4wMDQwNi0yLjgzMjVsMTYuNjA1MjktMTYuNTEwNDdjLjc4MTctLjc3NzIzIDIuMDQ0OS0uNzc1NDMgMi44MjQzLjAwNDA0bC44Mzg3LjgzODYyYy43ODI1Ljc4MjUxLjc4MDggMi4wNTE3NC0uMDAzOCAyLjgzMjE4bC0xNi42MDE4OCAxNi41MTM4M2MtLjc4MTY1Ljc3NzUtMi4wNDUwOC43NzU4LTIuODI0NjYtLjAwMzd6bTUuNDQzMzUtMTUuOTExNjZjLTEuODA5NzIuMDUzNjctMi43NTM3MS0yLjEzMzA5LTEuNDczNDctMy40MTMzM2wuODM4MzctLjgzODMyYy4zNzUtLjM3NTA4Ljg4MzctLjU4NTc5IDEuNDE0Mi0uNTg1NzloMTMuNDc5N2MxLjEwNDYgMCAyIC44OTU0MyAyIDJ2MTMuNDc5N2MwIC41MzA1LS4yMTA3IDEuMDM5Mi0uNTg1OCAxLjQxNDJsLS44MjY5LjgyN2MtMS4yODE4IDEuMjgxOC0zLjQ3MDkuMzMzOS0zLjQxMzItMS40Nzc5bC4zMDY2LTkuNjI5OWMuMDM2Ny0xLjE1MjI3LS45MDU5LTIuMDk2OS0yLjA1ODMtMi4wNjI3M3oiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+";
|
|
8
|
+
get version(): "1.0.0";
|
|
9
|
+
get chains(): readonly ["sui:mainnet"];
|
|
10
|
+
get accounts(): ReadonlyWalletAccount[];
|
|
11
|
+
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SuiSignTransactionBlockFeature & SuiSignPersonalMessageFeature;
|
|
12
|
+
constructor({ name, address, origin, }: {
|
|
13
|
+
origin?: string;
|
|
14
|
+
address?: string | null;
|
|
15
|
+
name: string;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare function registerZkSendWallet(name: string, { origin, }: {
|
|
19
|
+
origin?: string;
|
|
20
|
+
}): {
|
|
21
|
+
wallet: ZkSendWallet;
|
|
22
|
+
unregister: () => void;
|
|
23
|
+
addressFromRedirect: string | null;
|
|
24
|
+
};
|