zkcloudworker 0.17.5 → 0.17.7
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/lib/ts/src/mina/index.d.ts +1 -0
- package/lib/ts/src/mina/index.js +1 -0
- package/lib/ts/src/mina/storage/ipfs.js +8 -0
- package/lib/ts/src/mina/storage/pinata.d.ts +2 -2
- package/lib/ts/src/mina/storage/pinata.js +5 -1
- package/lib/ts/src/mina/token/index.d.ts +1 -0
- package/lib/ts/src/mina/token/index.js +1 -0
- package/lib/ts/src/mina/token/whitelist.d.ts +305 -0
- package/lib/ts/src/mina/token/whitelist.js +139 -0
- package/lib/ts/src/mina/transactions/{accont.d.ts → account.d.ts} +1 -1
- package/lib/ts/src/mina/transactions/{accont.js → account.js} +2 -2
- package/lib/ts/src/mina/transactions/index.d.ts +1 -0
- package/lib/ts/src/mina/transactions/index.js +1 -0
- package/lib/ts/src/mina/transactions/send.d.ts +13 -1
- package/lib/ts/src/mina/transactions/send.js +13 -1
- package/lib/ts/src/mina/utils/indexed-map.d.ts +2 -0
- package/lib/ts/src/mina/utils/indexed-map.js +14 -4
- package/lib/ts/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/mina/index.d.ts +1 -0
- package/lib/web/src/mina/index.js +1 -0
- package/lib/web/src/mina/index.js.map +1 -1
- package/lib/web/src/mina/storage/ipfs.js +8 -0
- package/lib/web/src/mina/storage/ipfs.js.map +1 -1
- package/lib/web/src/mina/storage/pinata.d.ts +2 -2
- package/lib/web/src/mina/storage/pinata.js +5 -1
- package/lib/web/src/mina/storage/pinata.js.map +1 -1
- package/lib/web/src/mina/token/FungibleTokenAdmin.js.map +1 -1
- package/lib/web/src/mina/token/index.d.ts +1 -0
- package/lib/web/src/mina/token/index.js +1 -0
- package/lib/web/src/mina/token/index.js.map +1 -1
- package/lib/web/src/mina/token/whitelist.d.ts +305 -0
- package/lib/web/src/mina/token/whitelist.js +132 -0
- package/lib/web/src/mina/token/whitelist.js.map +1 -0
- package/lib/web/src/mina/transactions/{accont.d.ts → account.d.ts} +1 -1
- package/lib/web/src/mina/transactions/{accont.js → account.js} +2 -2
- package/lib/web/src/mina/transactions/account.js.map +1 -0
- package/lib/web/src/mina/transactions/index.d.ts +1 -0
- package/lib/web/src/mina/transactions/index.js +1 -0
- package/lib/web/src/mina/transactions/index.js.map +1 -1
- package/lib/web/src/mina/transactions/send.d.ts +13 -1
- package/lib/web/src/mina/transactions/send.js +13 -1
- package/lib/web/src/mina/transactions/send.js.map +1 -1
- package/lib/web/src/mina/utils/indexed-map.d.ts +2 -0
- package/lib/web/src/mina/utils/indexed-map.js +15 -5
- package/lib/web/src/mina/utils/indexed-map.js.map +1 -1
- package/lib/web/tsconfig.web.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/lib/web/src/mina/transactions/accont.js.map +0 -1
@@ -0,0 +1,305 @@
|
|
1
|
+
import { Field, Option, PublicKey, UInt64, Bool } from "o1js";
|
2
|
+
import { Storage } from "../..";
|
3
|
+
declare const WhitelistMap_base: typeof import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase;
|
4
|
+
/** Represents the whitelist using an Indexed Merkle Map. */
|
5
|
+
export declare class WhitelistMap extends WhitelistMap_base {
|
6
|
+
}
|
7
|
+
declare const WhitelistMapOption_base: import("o1js/dist/node/lib/provable/types/provable-intf").Provable<Option<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase, {
|
8
|
+
root: bigint;
|
9
|
+
length: bigint;
|
10
|
+
data: {
|
11
|
+
nodes: (bigint | undefined)[][];
|
12
|
+
sortedLeaves: {
|
13
|
+
readonly value: bigint;
|
14
|
+
readonly key: bigint;
|
15
|
+
readonly nextKey: bigint;
|
16
|
+
readonly index: number;
|
17
|
+
}[];
|
18
|
+
};
|
19
|
+
}>, {
|
20
|
+
root: bigint;
|
21
|
+
length: bigint;
|
22
|
+
data: {
|
23
|
+
nodes: (bigint | undefined)[][];
|
24
|
+
sortedLeaves: {
|
25
|
+
readonly value: bigint;
|
26
|
+
readonly key: bigint;
|
27
|
+
readonly nextKey: bigint;
|
28
|
+
readonly index: number;
|
29
|
+
}[];
|
30
|
+
};
|
31
|
+
} | undefined> & (new (option: {
|
32
|
+
isSome: Bool;
|
33
|
+
value: import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase;
|
34
|
+
}) => Option<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase, {
|
35
|
+
root: bigint;
|
36
|
+
length: bigint;
|
37
|
+
data: {
|
38
|
+
nodes: (bigint | undefined)[][];
|
39
|
+
sortedLeaves: {
|
40
|
+
readonly value: bigint;
|
41
|
+
readonly key: bigint;
|
42
|
+
readonly nextKey: bigint;
|
43
|
+
readonly index: number;
|
44
|
+
}[];
|
45
|
+
};
|
46
|
+
}>) & {
|
47
|
+
fromValue(value: import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase | {
|
48
|
+
root: bigint;
|
49
|
+
length: bigint;
|
50
|
+
data: {
|
51
|
+
nodes: (bigint | undefined)[][];
|
52
|
+
sortedLeaves: {
|
53
|
+
readonly value: bigint;
|
54
|
+
readonly key: bigint;
|
55
|
+
readonly nextKey: bigint;
|
56
|
+
readonly index: number;
|
57
|
+
}[];
|
58
|
+
};
|
59
|
+
} | {
|
60
|
+
isSome: boolean | Bool;
|
61
|
+
value: import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase | {
|
62
|
+
root: bigint;
|
63
|
+
length: bigint;
|
64
|
+
data: {
|
65
|
+
nodes: (bigint | undefined)[][];
|
66
|
+
sortedLeaves: {
|
67
|
+
readonly value: bigint;
|
68
|
+
readonly key: bigint;
|
69
|
+
readonly nextKey: bigint;
|
70
|
+
readonly index: number;
|
71
|
+
}[];
|
72
|
+
};
|
73
|
+
};
|
74
|
+
} | undefined): Option<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase, {
|
75
|
+
root: bigint;
|
76
|
+
length: bigint;
|
77
|
+
data: {
|
78
|
+
nodes: (bigint | undefined)[][];
|
79
|
+
sortedLeaves: {
|
80
|
+
readonly value: bigint;
|
81
|
+
readonly key: bigint;
|
82
|
+
readonly nextKey: bigint;
|
83
|
+
readonly index: number;
|
84
|
+
}[];
|
85
|
+
};
|
86
|
+
}>;
|
87
|
+
from(value?: import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase | {
|
88
|
+
root: bigint;
|
89
|
+
length: bigint;
|
90
|
+
data: {
|
91
|
+
nodes: (bigint | undefined)[][];
|
92
|
+
sortedLeaves: {
|
93
|
+
readonly value: bigint;
|
94
|
+
readonly key: bigint;
|
95
|
+
readonly nextKey: bigint;
|
96
|
+
readonly index: number;
|
97
|
+
}[];
|
98
|
+
};
|
99
|
+
} | undefined): Option<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase, {
|
100
|
+
root: bigint;
|
101
|
+
length: bigint;
|
102
|
+
data: {
|
103
|
+
nodes: (bigint | undefined)[][];
|
104
|
+
sortedLeaves: {
|
105
|
+
readonly value: bigint;
|
106
|
+
readonly key: bigint;
|
107
|
+
readonly nextKey: bigint;
|
108
|
+
readonly index: number;
|
109
|
+
}[];
|
110
|
+
};
|
111
|
+
}>;
|
112
|
+
none(): Option<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase, {
|
113
|
+
root: bigint;
|
114
|
+
length: bigint;
|
115
|
+
data: {
|
116
|
+
nodes: (bigint | undefined)[][];
|
117
|
+
sortedLeaves: {
|
118
|
+
readonly value: bigint;
|
119
|
+
readonly key: bigint;
|
120
|
+
readonly nextKey: bigint;
|
121
|
+
readonly index: number;
|
122
|
+
}[];
|
123
|
+
};
|
124
|
+
}>;
|
125
|
+
};
|
126
|
+
export declare class WhitelistMapOption extends WhitelistMapOption_base {
|
127
|
+
}
|
128
|
+
declare const UInt64Option_base: Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<Option<UInt64, bigint>, bigint | undefined>, "fromFields"> & {
|
129
|
+
fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => Option<UInt64, bigint>;
|
130
|
+
} & (new (option: {
|
131
|
+
isSome: Bool;
|
132
|
+
value: UInt64;
|
133
|
+
}) => Option<UInt64, bigint>) & {
|
134
|
+
fromValue(value: bigint | UInt64 | {
|
135
|
+
isSome: boolean | Bool;
|
136
|
+
value: bigint | UInt64;
|
137
|
+
} | undefined): Option<UInt64, bigint>;
|
138
|
+
from(value?: bigint | UInt64 | undefined): Option<UInt64, bigint>;
|
139
|
+
none(): Option<UInt64, bigint>;
|
140
|
+
};
|
141
|
+
export declare class UInt64Option extends UInt64Option_base {
|
142
|
+
}
|
143
|
+
declare const WhitelistedAddress_base: (new (value: {
|
144
|
+
address: PublicKey;
|
145
|
+
amount: UInt64;
|
146
|
+
}) => {
|
147
|
+
address: PublicKey;
|
148
|
+
amount: UInt64;
|
149
|
+
}) & {
|
150
|
+
_isStruct: true;
|
151
|
+
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<{
|
152
|
+
address: PublicKey;
|
153
|
+
amount: UInt64;
|
154
|
+
}, {
|
155
|
+
address: {
|
156
|
+
x: bigint;
|
157
|
+
isOdd: boolean;
|
158
|
+
};
|
159
|
+
amount: bigint;
|
160
|
+
}>, "fromFields"> & {
|
161
|
+
fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => {
|
162
|
+
address: PublicKey;
|
163
|
+
amount: UInt64;
|
164
|
+
};
|
165
|
+
} & {
|
166
|
+
fromValue: (value: {
|
167
|
+
address: PublicKey | {
|
168
|
+
x: Field | bigint;
|
169
|
+
isOdd: Bool | boolean;
|
170
|
+
};
|
171
|
+
amount: bigint | UInt64;
|
172
|
+
}) => {
|
173
|
+
address: PublicKey;
|
174
|
+
amount: UInt64;
|
175
|
+
};
|
176
|
+
toInput: (x: {
|
177
|
+
address: PublicKey;
|
178
|
+
amount: UInt64;
|
179
|
+
}) => {
|
180
|
+
fields?: Field[] | undefined;
|
181
|
+
packed?: [Field, number][] | undefined;
|
182
|
+
};
|
183
|
+
toJSON: (x: {
|
184
|
+
address: PublicKey;
|
185
|
+
amount: UInt64;
|
186
|
+
}) => {
|
187
|
+
address: string;
|
188
|
+
amount: string;
|
189
|
+
};
|
190
|
+
fromJSON: (x: {
|
191
|
+
address: string;
|
192
|
+
amount: string;
|
193
|
+
}) => {
|
194
|
+
address: PublicKey;
|
195
|
+
amount: UInt64;
|
196
|
+
};
|
197
|
+
empty: () => {
|
198
|
+
address: PublicKey;
|
199
|
+
amount: UInt64;
|
200
|
+
};
|
201
|
+
};
|
202
|
+
export declare class WhitelistedAddress extends WhitelistedAddress_base {
|
203
|
+
}
|
204
|
+
declare const Whitelist_base: (new (value: {
|
205
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
206
|
+
storage: Storage;
|
207
|
+
}) => {
|
208
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
209
|
+
storage: Storage;
|
210
|
+
}) & {
|
211
|
+
_isStruct: true;
|
212
|
+
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<{
|
213
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
214
|
+
storage: Storage;
|
215
|
+
}, {
|
216
|
+
root: bigint;
|
217
|
+
storage: {
|
218
|
+
url: bigint[];
|
219
|
+
};
|
220
|
+
}>, "fromFields"> & {
|
221
|
+
fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => {
|
222
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
223
|
+
storage: Storage;
|
224
|
+
};
|
225
|
+
} & {
|
226
|
+
fromValue: (value: {
|
227
|
+
root: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
228
|
+
storage: Storage | {
|
229
|
+
url: import("o1js/dist/node/lib/provable/field").Field[] | bigint[];
|
230
|
+
};
|
231
|
+
}) => {
|
232
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
233
|
+
storage: Storage;
|
234
|
+
};
|
235
|
+
toInput: (x: {
|
236
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
237
|
+
storage: Storage;
|
238
|
+
}) => {
|
239
|
+
fields?: Field[] | undefined;
|
240
|
+
packed?: [Field, number][] | undefined;
|
241
|
+
};
|
242
|
+
toJSON: (x: {
|
243
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
244
|
+
storage: Storage;
|
245
|
+
}) => {
|
246
|
+
root: string;
|
247
|
+
storage: {
|
248
|
+
url: string[];
|
249
|
+
};
|
250
|
+
};
|
251
|
+
fromJSON: (x: {
|
252
|
+
root: string;
|
253
|
+
storage: {
|
254
|
+
url: string[];
|
255
|
+
};
|
256
|
+
}) => {
|
257
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
258
|
+
storage: Storage;
|
259
|
+
};
|
260
|
+
empty: () => {
|
261
|
+
root: import("o1js/dist/node/lib/provable/field").Field;
|
262
|
+
storage: Storage;
|
263
|
+
};
|
264
|
+
};
|
265
|
+
export declare class Whitelist extends Whitelist_base {
|
266
|
+
isNone(): Bool;
|
267
|
+
isSome(): Bool;
|
268
|
+
load(): Promise<WhitelistMapOption>;
|
269
|
+
/**
|
270
|
+
* The function fetches a whitelisted amount associated with a given address using a map and returns it
|
271
|
+
* as a UInt64Option.
|
272
|
+
* @param {PublicKey} address - The `address` parameter is of type `PublicKey`, which represents a
|
273
|
+
* public key used in cryptography for various purposes such as encryption, digital signatures, and
|
274
|
+
* authentication. In the context of the `fetchWhitelistedAmount` function, the `address` parameter is
|
275
|
+
* used to retrieve a whitelisted amount
|
276
|
+
* @returns The `fetchWhitelistedAmount` function returns a `Promise` that resolves to a `UInt64Option`
|
277
|
+
* object. This object contains a `value` property representing the amount retrieved from a map based
|
278
|
+
* on the provided address. The `isSome` property indicates whether the value is present or not.
|
279
|
+
* The value is not present if the whitelist is NOT empty and the address is NOT whitelisted.
|
280
|
+
* The value is present if the whitelist is NOT empty or the address IS whitelisted.
|
281
|
+
* The value is present and equals to UInt64.MAXINT() if the whitelist IS empty.
|
282
|
+
*/
|
283
|
+
getWhitelistedAmount(address: PublicKey): Promise<UInt64Option>;
|
284
|
+
static empty(): Whitelist;
|
285
|
+
/**
|
286
|
+
* Creates a new whitelist and pins it to IPFS.
|
287
|
+
* @param params - The parameters for creating the whitelist.
|
288
|
+
* @returns A new `Whitelist` instance.
|
289
|
+
*/
|
290
|
+
static create(params: {
|
291
|
+
list: WhitelistedAddress[] | {
|
292
|
+
address: string;
|
293
|
+
amount?: number;
|
294
|
+
}[];
|
295
|
+
name?: string;
|
296
|
+
keyvalues?: {
|
297
|
+
key: string;
|
298
|
+
value: string;
|
299
|
+
}[];
|
300
|
+
timeout?: number;
|
301
|
+
attempts?: number;
|
302
|
+
auth?: string;
|
303
|
+
}): Promise<Whitelist>;
|
304
|
+
}
|
305
|
+
export {};
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import { Experimental, Struct, Field, Option, Provable, PublicKey, UInt64, Poseidon, } from "o1js";
|
2
|
+
import { serializeIndexedMap, createIpfsURL, pinJSON, Storage, sleep, loadIndexedMerkleMap, } from "../..";
|
3
|
+
const { IndexedMerkleMap } = Experimental;
|
4
|
+
const WHITELIST_HEIGHT = 20;
|
5
|
+
/** Represents the whitelist using an Indexed Merkle Map. */
|
6
|
+
export class WhitelistMap extends IndexedMerkleMap(WHITELIST_HEIGHT) {
|
7
|
+
}
|
8
|
+
export class WhitelistMapOption extends Option(WhitelistMap) {
|
9
|
+
}
|
10
|
+
export class UInt64Option extends Option(UInt64) {
|
11
|
+
}
|
12
|
+
export class WhitelistedAddress extends Struct({
|
13
|
+
address: PublicKey,
|
14
|
+
amount: UInt64, // Maximum permitted amount of the transaction
|
15
|
+
}) {
|
16
|
+
}
|
17
|
+
export class Whitelist extends Struct({
|
18
|
+
/** The root hash of the Merkle tree representing the whitelist. */
|
19
|
+
root: Field,
|
20
|
+
/** Off-chain storage information, typically an IPFS hash pointing to the whitelist data. */
|
21
|
+
storage: Storage,
|
22
|
+
}) {
|
23
|
+
isNone() {
|
24
|
+
return this.root
|
25
|
+
.equals(Field(0))
|
26
|
+
.or(Storage.equals(this.storage, Storage.empty()));
|
27
|
+
}
|
28
|
+
isSome() {
|
29
|
+
return this.isNone().not();
|
30
|
+
}
|
31
|
+
async load() {
|
32
|
+
const isNone = this.isNone();
|
33
|
+
const map = await Provable.witnessAsync(WhitelistMapOption, async () => {
|
34
|
+
if (isNone.toBoolean())
|
35
|
+
return WhitelistMapOption.none();
|
36
|
+
else
|
37
|
+
return WhitelistMapOption.fromValue(await loadIndexedMerkleMap({
|
38
|
+
url: createIpfsURL({ hash: this.storage.toString() }),
|
39
|
+
type: WhitelistMap,
|
40
|
+
}));
|
41
|
+
});
|
42
|
+
isNone.assertEquals(map.isSome.not());
|
43
|
+
const root = Provable.if(map.isSome, map.orElse(new WhitelistMap()).root, Field(0));
|
44
|
+
root.equals(this.root);
|
45
|
+
return map;
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* The function fetches a whitelisted amount associated with a given address using a map and returns it
|
49
|
+
* as a UInt64Option.
|
50
|
+
* @param {PublicKey} address - The `address` parameter is of type `PublicKey`, which represents a
|
51
|
+
* public key used in cryptography for various purposes such as encryption, digital signatures, and
|
52
|
+
* authentication. In the context of the `fetchWhitelistedAmount` function, the `address` parameter is
|
53
|
+
* used to retrieve a whitelisted amount
|
54
|
+
* @returns The `fetchWhitelistedAmount` function returns a `Promise` that resolves to a `UInt64Option`
|
55
|
+
* object. This object contains a `value` property representing the amount retrieved from a map based
|
56
|
+
* on the provided address. The `isSome` property indicates whether the value is present or not.
|
57
|
+
* The value is not present if the whitelist is NOT empty and the address is NOT whitelisted.
|
58
|
+
* The value is present if the whitelist is NOT empty or the address IS whitelisted.
|
59
|
+
* The value is present and equals to UInt64.MAXINT() if the whitelist IS empty.
|
60
|
+
*/
|
61
|
+
async getWhitelistedAmount(address) {
|
62
|
+
const map = await this.load();
|
63
|
+
const key = Poseidon.hashPacked(PublicKey, address);
|
64
|
+
const value = map.orElse(new WhitelistMap()).getOption(key);
|
65
|
+
const valueField = value.orElse(UInt64.MAXINT().value);
|
66
|
+
valueField.assertLessThanOrEqual(UInt64.MAXINT().value);
|
67
|
+
const amount = UInt64.Unsafe.fromField(valueField);
|
68
|
+
return new UInt64Option({
|
69
|
+
value: amount,
|
70
|
+
isSome: value.isSome.or(this.isNone()),
|
71
|
+
});
|
72
|
+
}
|
73
|
+
static empty() {
|
74
|
+
return new Whitelist({
|
75
|
+
root: Field(0),
|
76
|
+
storage: Storage.empty(),
|
77
|
+
});
|
78
|
+
}
|
79
|
+
/**
|
80
|
+
* Creates a new whitelist and pins it to IPFS.
|
81
|
+
* @param params - The parameters for creating the whitelist.
|
82
|
+
* @returns A new `Whitelist` instance.
|
83
|
+
*/
|
84
|
+
static async create(params) {
|
85
|
+
const { name = "whitelist.json", keyvalues = [{ key: "library", value: "zkcloudworker" }], timeout = 60 * 1000, attempts = 5, auth, } = params;
|
86
|
+
const list = typeof params.list[0].address === "string"
|
87
|
+
? params.list.map((item) => new WhitelistedAddress({
|
88
|
+
address: PublicKey.fromBase58(item.address),
|
89
|
+
amount: item.amount
|
90
|
+
? UInt64.from(item.amount)
|
91
|
+
: UInt64.MAXINT(),
|
92
|
+
}))
|
93
|
+
: params.list;
|
94
|
+
const map = new WhitelistMap();
|
95
|
+
for (const item of list) {
|
96
|
+
map.insert(Poseidon.hashPacked(PublicKey, item.address), item.amount.toBigInt());
|
97
|
+
}
|
98
|
+
const serializedMap = serializeIndexedMap(map);
|
99
|
+
const json = {
|
100
|
+
map: serializedMap,
|
101
|
+
whitelist: list.map((item) => ({
|
102
|
+
address: item.address.toBase58(),
|
103
|
+
amount: Number(item.amount.toBigInt()),
|
104
|
+
})),
|
105
|
+
};
|
106
|
+
let attempt = 0;
|
107
|
+
const start = Date.now();
|
108
|
+
let hash = await pinJSON({
|
109
|
+
data: json,
|
110
|
+
name,
|
111
|
+
keyvalues,
|
112
|
+
auth,
|
113
|
+
});
|
114
|
+
while (!hash && attempt < attempts && Date.now() - start < timeout) {
|
115
|
+
attempt++;
|
116
|
+
await sleep(5000 * attempt); // handle rate-limits
|
117
|
+
hash = await pinJSON({
|
118
|
+
data: json,
|
119
|
+
name,
|
120
|
+
keyvalues,
|
121
|
+
auth,
|
122
|
+
});
|
123
|
+
}
|
124
|
+
if (!hash)
|
125
|
+
throw new Error("Failed to pin whitelist");
|
126
|
+
return new Whitelist({
|
127
|
+
root: map.root,
|
128
|
+
storage: Storage.fromString(hash),
|
129
|
+
});
|
130
|
+
}
|
131
|
+
}
|
132
|
+
//# sourceMappingURL=whitelist.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"whitelist.js","sourceRoot":"","sources":["../../../../../../src/mina/token/whitelist.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,MAAM,EACN,QAAQ,GAET,MAAM,MAAM,CAAC;AACd,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,OAAO,EACP,KAAK,EACL,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAEf,MAAM,EAAE,gBAAgB,EAAE,GAAG,YAAY,CAAC;AAE1C,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,4DAA4D;AAC5D,MAAM,OAAO,YAAa,SAAQ,gBAAgB,CAAC,gBAAgB,CAAC;CAAG;AACvE,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,YAAY,CAAC;CAAG;AAC/D,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,MAAM,CAAC;CAAG;AACnD,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC;IAC7C,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,MAAM,EAAE,8CAA8C;CAC/D,CAAC;CAAG;AAEL,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC;IACpC,mEA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AAQ,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,EAAE,CAAC;YACnE,OAAO,EAAE,CAAC;YACV,MAAM,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,qBAAqB;YAClD,IAAI,GAAG,MAAM,OAAO,CAAC;gBACnB,IAAI,EAAE,IAAI;gBACV,IAAI;gBACJ,SAAS;gBACT,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEtD,OAAO,IAAI,SAAS,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;CACF"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { PublicKey, Field } from "o1js";
|
2
2
|
export declare function accountExists(address: string | PublicKey, tokenId?: Field): Promise<boolean>;
|
3
|
-
export declare function
|
3
|
+
export declare function tokenBalance(address: string | PublicKey, tokenId?: Field): Promise<number | undefined>;
|
4
4
|
export declare function checkAddress(address: string | undefined): Promise<boolean>;
|
@@ -10,7 +10,7 @@ export async function accountExists(address, tokenId) {
|
|
10
10
|
return false;
|
11
11
|
}
|
12
12
|
}
|
13
|
-
export async function
|
13
|
+
export async function tokenBalance(address, tokenId) {
|
14
14
|
try {
|
15
15
|
const publicKey = typeof address === "string" ? PublicKey.fromBase58(address) : address;
|
16
16
|
await fetchMinaAccount({ publicKey, tokenId, force: false });
|
@@ -41,4 +41,4 @@ export async function checkAddress(address) {
|
|
41
41
|
return false;
|
42
42
|
}
|
43
43
|
}
|
44
|
-
//# sourceMappingURL=
|
44
|
+
//# sourceMappingURL=account.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/account.ts"],"names":[],"mappings":"AAAA,OAAO,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AAC,KAAK,UAAU,YAAY,CAChC,OAA2B;IAE3B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,OAAO,KAAK,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG,CACT,oCAAoC,EACpC,OAAO,EACP,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
|
@@ -1,12 +1,24 @@
|
|
1
1
|
import { Mina } from "o1js";
|
2
2
|
import { blockchain } from "../../cloud";
|
3
|
+
/**
|
4
|
+
* The function `sendTx` sends a transaction, checks account updates, and waits for
|
5
|
+
* confirmation on the blockchain.
|
6
|
+
* @param params The parameters object
|
7
|
+
* @param params.tx The transaction to send
|
8
|
+
* @param params.description A description of the transaction
|
9
|
+
* @param params.verbose Whether to log verbose information
|
10
|
+
* @param params.wait Whether to wait for the transaction to be included in a block
|
11
|
+
* @param params.chain The blockchain to send the transaction on
|
12
|
+
* @returns The `sendTx` function returns a `Mina.IncludedTransaction`, `Mina.PendingTransaction`,
|
13
|
+
* `Mina.RejectedTransaction`, or `undefined` if there was an error during the process.
|
14
|
+
*/
|
3
15
|
export declare function sendTx(params: {
|
4
16
|
tx: Mina.Transaction<false, true> | Mina.Transaction<true, true>;
|
5
17
|
description?: string;
|
6
18
|
verbose?: boolean;
|
7
19
|
wait?: boolean;
|
8
20
|
chain?: blockchain;
|
9
|
-
}): Promise<Mina.
|
21
|
+
}): Promise<Mina.IncludedTransaction | Mina.PendingTransaction | Mina.RejectedTransaction | undefined>;
|
10
22
|
export declare function getTxStatusFast(params: {
|
11
23
|
hash: string;
|
12
24
|
chain?: blockchain;
|
@@ -1,6 +1,18 @@
|
|
1
1
|
import { checkZkappTransaction } from "o1js";
|
2
2
|
import { sleep } from "../../cloud";
|
3
3
|
import { fetchMinaAccount, getCurrentNetwork } from "..";
|
4
|
+
/**
|
5
|
+
* The function `sendTx` sends a transaction, checks account updates, and waits for
|
6
|
+
* confirmation on the blockchain.
|
7
|
+
* @param params The parameters object
|
8
|
+
* @param params.tx The transaction to send
|
9
|
+
* @param params.description A description of the transaction
|
10
|
+
* @param params.verbose Whether to log verbose information
|
11
|
+
* @param params.wait Whether to wait for the transaction to be included in a block
|
12
|
+
* @param params.chain The blockchain to send the transaction on
|
13
|
+
* @returns The `sendTx` function returns a `Mina.IncludedTransaction`, `Mina.PendingTransaction`,
|
14
|
+
* `Mina.RejectedTransaction`, or `undefined` if there was an error during the process.
|
15
|
+
*/
|
4
16
|
export async function sendTx(params) {
|
5
17
|
const { tx, description = "", verbose = true, wait = true, chain = getCurrentNetwork().network.chainId, } = params;
|
6
18
|
// flatten accountUpdates
|
@@ -49,7 +61,7 @@ export async function sendTx(params) {
|
|
49
61
|
}
|
50
62
|
else {
|
51
63
|
console.error(`${description} tx NOT sent: hash: ${txSent?.hash} status: ${txSent?.status}`, txSent.errors);
|
52
|
-
return
|
64
|
+
return txSent;
|
53
65
|
}
|
54
66
|
}
|
55
67
|
if (txSent === undefined)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAc,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAM5B;
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAc,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAM5B;IAMC,MAAM,EACJ,EAAE,EACF,WAAW,GAAG,EAAE,EAChB,OAAO,GAAG,IAAI,EACd,IAAI,GAAG,IAAI,EACX,KAAK,GAAG,iBAAiB,EAAE,CAAC,OAAO,CAAC,OAAO,GAC5C,GAAG,MAAM,CAAC;IACX,yBAAyB;IACzB,MAAM,cAAc,GAAG,IAAI,CAA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,CAAC"}
|
@@ -11,6 +11,8 @@ export interface IndexedMapSerialized {
|
|
11
11
|
export declare function loadIndexedMerkleMap(params: {
|
12
12
|
url: string;
|
13
13
|
type: ReturnType<typeof IndexedMerkleMap>;
|
14
|
+
timeout?: number;
|
15
|
+
attempts?: number;
|
14
16
|
}): Promise<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase>;
|
15
17
|
export declare function saveIndexedMerkleMap(params: {
|
16
18
|
map: IndexedMerkleMap;
|
@@ -1,14 +1,24 @@
|
|
1
1
|
import { Experimental, Field } from "o1js";
|
2
|
-
import { bigintToBase64, bigintFromBase64 } from "../../cloud";
|
2
|
+
import { bigintToBase64, bigintFromBase64, sleep } from "../../cloud";
|
3
3
|
import { pinJSON } from "../storage/pinata";
|
4
4
|
const { IndexedMerkleMap } = Experimental;
|
5
5
|
export async function loadIndexedMerkleMap(params) {
|
6
|
-
const { url, type } = params;
|
7
|
-
|
6
|
+
const { url, type, timeout = 60000, attempts = 5 } = params;
|
7
|
+
let attempt = 0;
|
8
|
+
const start = Date.now();
|
9
|
+
let response = await fetch(url);
|
10
|
+
while (!response.ok && attempt < attempts && Date.now() - start < timeout) {
|
11
|
+
attempt++;
|
12
|
+
await sleep(5000 * attempt); // handle rate limiting
|
13
|
+
response = await fetch(url);
|
14
|
+
}
|
8
15
|
if (!response.ok) {
|
9
16
|
throw new Error("Failed to fetch IndexedMerkleMap");
|
10
17
|
}
|
11
|
-
const
|
18
|
+
const json = await response.json();
|
19
|
+
const serializedIndexedMap = json.map;
|
20
|
+
if (!serializedIndexedMap)
|
21
|
+
throw new Error("wrong IndexedMerkleMap json format");
|
12
22
|
const map = deserializeIndexedMerkleMapInternal({
|
13
23
|
serializedIndexedMap,
|
14
24
|
type,
|
@@ -22,7 +32,7 @@ export async function saveIndexedMerkleMap(params) {
|
|
22
32
|
const { map, name = "indexed-map", keyvalues, auth } = params;
|
23
33
|
const serialized = serializeIndexedMap(map);
|
24
34
|
const ipfsHash = await pinJSON({
|
25
|
-
data: serialized,
|
35
|
+
data: { map: serialized },
|
26
36
|
name,
|
27
37
|
keyvalues,
|
28
38
|
auth,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"indexed-map.js","sourceRoot":"","sources":["../../../../../../src/mina/utils/indexed-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"indexed-map.js","sourceRoot":"","sources":["../../../../../../src/mina/utils/indexed-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,EAAE,gBAAgB,EAAE,GAAG,YAAY,CAAC;AAW1C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAK1C;IACC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC;IAC5D,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,EAAE,CAAC;QAC1E,OAAO,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,uBAAuB;QACpD,QAAQ,GAAG,MAAM,KAAK,CAAC,G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