zkcloudworker 0.17.3 → 0.17.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/lib/ts/src/mina/storage/index.d.ts +3 -0
  2. package/lib/ts/src/mina/storage/index.js +19 -0
  3. package/lib/ts/src/mina/storage/pinata.d.ts +6 -0
  4. package/lib/ts/src/mina/storage/pinata.js +36 -0
  5. package/lib/ts/src/mina/storage/storage.d.ts +75 -0
  6. package/lib/ts/src/mina/storage/storage.js +55 -0
  7. package/lib/ts/src/mina/transactions/accont.d.ts +4 -0
  8. package/lib/ts/src/mina/transactions/accont.js +48 -0
  9. package/lib/ts/src/mina/transactions/index.d.ts +1 -0
  10. package/lib/ts/src/mina/transactions/index.js +1 -0
  11. package/lib/ts/src/mina/transactions/nonce.d.ts +7 -0
  12. package/lib/ts/src/mina/transactions/nonce.js +33 -0
  13. package/lib/ts/src/mina/transactions/send.d.ts +17 -0
  14. package/lib/ts/src/mina/transactions/send.js +119 -0
  15. package/lib/ts/src/mina/transactions/txstatus.d.ts +1 -1
  16. package/lib/ts/src/mina/transactions/txstatus.js +2 -2
  17. package/lib/ts/src/mina/utils/index.d.ts +0 -1
  18. package/lib/ts/src/mina/utils/index.js +0 -1
  19. package/lib/ts/src/mina/utils/indexed-map.d.ts +9 -0
  20. package/lib/ts/src/mina/utils/indexed-map.js +13 -0
  21. package/lib/ts/tsconfig.tsbuildinfo +1 -1
  22. package/lib/web/src/mina/storage/index.d.ts +3 -0
  23. package/lib/web/src/mina/storage/index.js +4 -0
  24. package/lib/web/src/mina/storage/index.js.map +1 -0
  25. package/lib/web/src/mina/storage/ipfs.js.map +1 -0
  26. package/lib/web/src/mina/storage/pinata.d.ts +6 -0
  27. package/lib/web/src/mina/storage/pinata.js +34 -0
  28. package/lib/web/src/mina/storage/pinata.js.map +1 -0
  29. package/lib/web/src/mina/storage/storage.d.ts +75 -0
  30. package/lib/web/src/mina/storage/storage.js +52 -0
  31. package/lib/web/src/mina/storage/storage.js.map +1 -0
  32. package/lib/web/src/mina/transactions/accont.d.ts +4 -0
  33. package/lib/web/src/mina/transactions/accont.js +44 -0
  34. package/lib/web/src/mina/transactions/accont.js.map +1 -0
  35. package/lib/web/src/mina/transactions/index.d.ts +1 -0
  36. package/lib/web/src/mina/transactions/index.js +1 -0
  37. package/lib/web/src/mina/transactions/index.js.map +1 -1
  38. package/lib/web/src/mina/transactions/nonce.d.ts +7 -0
  39. package/lib/web/src/mina/transactions/nonce.js +32 -0
  40. package/lib/web/src/mina/transactions/nonce.js.map +1 -1
  41. package/lib/web/src/mina/transactions/send.d.ts +17 -0
  42. package/lib/web/src/mina/transactions/send.js +116 -0
  43. package/lib/web/src/mina/transactions/send.js.map +1 -0
  44. package/lib/web/src/mina/transactions/txstatus.d.ts +1 -1
  45. package/lib/web/src/mina/transactions/txstatus.js +1 -1
  46. package/lib/web/src/mina/transactions/txstatus.js.map +1 -1
  47. package/lib/web/src/mina/utils/index.d.ts +0 -1
  48. package/lib/web/src/mina/utils/index.js +0 -1
  49. package/lib/web/src/mina/utils/index.js.map +1 -1
  50. package/lib/web/src/mina/utils/indexed-map.d.ts +9 -0
  51. package/lib/web/src/mina/utils/indexed-map.js +12 -0
  52. package/lib/web/src/mina/utils/indexed-map.js.map +1 -1
  53. package/lib/web/tsconfig.web.tsbuildinfo +1 -1
  54. package/package.json +1 -1
  55. package/lib/web/src/mina/utils/ipfs.js.map +0 -1
  56. /package/lib/ts/src/mina/{utils → storage}/ipfs.d.ts +0 -0
  57. /package/lib/ts/src/mina/{utils → storage}/ipfs.js +0 -0
  58. /package/lib/web/src/mina/{utils → storage}/ipfs.d.ts +0 -0
  59. /package/lib/web/src/mina/{utils → storage}/ipfs.js +0 -0
@@ -0,0 +1,3 @@
1
+ export * from "./ipfs";
2
+ export * from "./pinata";
3
+ export * from "./storage";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ipfs"), exports);
18
+ __exportStar(require("./pinata"), exports);
19
+ __exportStar(require("./storage"), exports);
@@ -0,0 +1,6 @@
1
+ export declare function pinJSON(params: {
2
+ data: string | object;
3
+ name: string;
4
+ keyvalues?: object;
5
+ auth: string;
6
+ }): Promise<string | undefined>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pinJSON = pinJSON;
4
+ async function pinJSON(params) {
5
+ const { data, name, keyvalues, auth } = params;
6
+ try {
7
+ const pinataData = {
8
+ pinataOptions: {
9
+ cidVersion: 1,
10
+ },
11
+ pinataMetadata: {
12
+ name,
13
+ keyvalues,
14
+ },
15
+ pinataContent: data,
16
+ };
17
+ const res = await fetch("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
18
+ method: "POST",
19
+ headers: {
20
+ "Content-Type": "application/json",
21
+ Authorization: "Bearer " + auth,
22
+ },
23
+ body: JSON.stringify(pinataData),
24
+ });
25
+ if (!res.ok) {
26
+ throw new Error(`Pinata error: status: ${res.status} ${res.statusText}`);
27
+ }
28
+ const responseData = await res.json();
29
+ console.log("saveToIPFS result:", responseData);
30
+ return responseData?.IpfsHash;
31
+ }
32
+ catch (error) {
33
+ console.error("saveToIPFS error:", error?.message);
34
+ return undefined;
35
+ }
36
+ }
@@ -0,0 +1,75 @@
1
+ import { Field, Bool } from "o1js";
2
+ declare const Storage_base: (new (value: {
3
+ url: import("o1js/dist/node/lib/provable/field").Field[];
4
+ }) => {
5
+ url: import("o1js/dist/node/lib/provable/field").Field[];
6
+ }) & {
7
+ _isStruct: true;
8
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<{
9
+ url: import("o1js/dist/node/lib/provable/field").Field[];
10
+ }, {
11
+ url: bigint[];
12
+ }>, "fromFields"> & {
13
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => {
14
+ url: import("o1js/dist/node/lib/provable/field").Field[];
15
+ };
16
+ } & {
17
+ fromValue: (value: {
18
+ url: import("o1js/dist/node/lib/provable/field").Field[] | bigint[];
19
+ }) => {
20
+ url: import("o1js/dist/node/lib/provable/field").Field[];
21
+ };
22
+ toInput: (x: {
23
+ url: import("o1js/dist/node/lib/provable/field").Field[];
24
+ }) => {
25
+ fields?: Field[] | undefined;
26
+ packed?: [Field, number][] | undefined;
27
+ };
28
+ toJSON: (x: {
29
+ url: import("o1js/dist/node/lib/provable/field").Field[];
30
+ }) => {
31
+ url: string[];
32
+ };
33
+ fromJSON: (x: {
34
+ url: string[];
35
+ }) => {
36
+ url: import("o1js/dist/node/lib/provable/field").Field[];
37
+ };
38
+ empty: () => {
39
+ url: import("o1js/dist/node/lib/provable/field").Field[];
40
+ };
41
+ };
42
+ /**
43
+ * Represents the off-chain storage information,
44
+ * such as an IPFS hash.
45
+ */
46
+ export declare class Storage extends Storage_base {
47
+ constructor(value: {
48
+ url: [Field, Field];
49
+ });
50
+ /**
51
+ * Asserts that two Storage instances are equal.
52
+ * @param a The first Storage instance.
53
+ * @param b The second Storage instance.
54
+ */
55
+ static assertEquals(a: Storage, b: Storage): void;
56
+ /**
57
+ * Checks if two Storage instances are equal.
58
+ * @param a The first Storage instance.
59
+ * @param b The second Storage instance.
60
+ * @returns A Bool indicating whether the two instances are equal.
61
+ */
62
+ static equals(a: Storage, b: Storage): Bool;
63
+ /**
64
+ * Creates a Storage instance from a string.
65
+ * @param url The string representing the storage URL.
66
+ * @returns A new Storage instance.
67
+ */
68
+ static fromString(url: string): Storage;
69
+ /**
70
+ * Converts the Storage instance to a string.
71
+ * @returns The string representation of the storage URL.
72
+ */
73
+ toString(): string;
74
+ }
75
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Storage = void 0;
4
+ const o1js_1 = require("o1js");
5
+ /**
6
+ * Represents the off-chain storage information,
7
+ * such as an IPFS hash.
8
+ */
9
+ class Storage extends (0, o1js_1.Struct)({
10
+ url: o1js_1.Provable.Array(o1js_1.Field, 2),
11
+ }) {
12
+ constructor(value) {
13
+ super(value);
14
+ }
15
+ /**
16
+ * Asserts that two Storage instances are equal.
17
+ * @param a The first Storage instance.
18
+ * @param b The second Storage instance.
19
+ */
20
+ static assertEquals(a, b) {
21
+ a.url[0].assertEquals(b.url[0]);
22
+ a.url[1].assertEquals(b.url[1]);
23
+ }
24
+ /**
25
+ * Checks if two Storage instances are equal.
26
+ * @param a The first Storage instance.
27
+ * @param b The second Storage instance.
28
+ * @returns A Bool indicating whether the two instances are equal.
29
+ */
30
+ static equals(a, b) {
31
+ return a.url[0].equals(b.url[0]).and(a.url[1].equals(b.url[1]));
32
+ }
33
+ /**
34
+ * Creates a Storage instance from a string.
35
+ * @param url The string representing the storage URL.
36
+ * @returns A new Storage instance.
37
+ */
38
+ static fromString(url) {
39
+ const fields = o1js_1.Encoding.stringToFields(url);
40
+ if (fields.length !== 2)
41
+ throw new Error("Invalid string length");
42
+ return new Storage({ url: [fields[0], fields[1]] });
43
+ }
44
+ /**
45
+ * Converts the Storage instance to a string.
46
+ * @returns The string representation of the storage URL.
47
+ */
48
+ toString() {
49
+ if (this.url[0].toBigInt() === 0n && this.url[1].toBigInt() === 0n) {
50
+ throw new Error("Invalid string");
51
+ }
52
+ return o1js_1.Encoding.stringFromFields([this.url[0], this.url[1]]);
53
+ }
54
+ }
55
+ exports.Storage = Storage;
@@ -0,0 +1,4 @@
1
+ import { PublicKey, Field } from "o1js";
2
+ export declare function accountExists(address: string | PublicKey, tokenId?: Field): Promise<boolean>;
3
+ export declare function accountBalance(address: string | PublicKey, tokenId?: Field): Promise<number | undefined>;
4
+ export declare function checkAddress(address: string | undefined): Promise<boolean>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.accountExists = accountExists;
4
+ exports.accountBalance = accountBalance;
5
+ exports.checkAddress = checkAddress;
6
+ const __1 = require("..");
7
+ const o1js_1 = require("o1js");
8
+ async function accountExists(address, tokenId) {
9
+ try {
10
+ const publicKey = typeof address === "string" ? o1js_1.PublicKey.fromBase58(address) : address;
11
+ await (0, __1.fetchMinaAccount)({ publicKey, tokenId, force: false });
12
+ return o1js_1.Mina.hasAccount(publicKey, tokenId);
13
+ }
14
+ catch (error) {
15
+ return false;
16
+ }
17
+ }
18
+ async function accountBalance(address, tokenId) {
19
+ try {
20
+ const publicKey = typeof address === "string" ? o1js_1.PublicKey.fromBase58(address) : address;
21
+ await (0, __1.fetchMinaAccount)({ publicKey, tokenId, force: false });
22
+ return o1js_1.Mina.hasAccount(publicKey, tokenId)
23
+ ? Number(o1js_1.Mina.getAccount(publicKey, tokenId).balance.toBigInt())
24
+ : undefined;
25
+ }
26
+ catch (error) {
27
+ console.error("Cannot fetch account balance", error);
28
+ return undefined;
29
+ }
30
+ }
31
+ async function checkAddress(address) {
32
+ if (!address || typeof address !== "string") {
33
+ console.error("checkAddress params are invalid:", address);
34
+ return false;
35
+ }
36
+ try {
37
+ const publicKey = o1js_1.PublicKey.fromBase58(address);
38
+ if (address !== publicKey.toBase58()) {
39
+ console.log("checkAddress: address is not valid", address, publicKey.toBase58());
40
+ return false;
41
+ }
42
+ return true;
43
+ }
44
+ catch (error) {
45
+ console.error("checkAddress catch", { address, error });
46
+ return false;
47
+ }
48
+ }
@@ -4,3 +4,4 @@ export * from "./txstatus";
4
4
  export * from "./chain";
5
5
  export * from "./blockberry";
6
6
  export * from "./tiny-contract";
7
+ export * from "./send";
@@ -20,3 +20,4 @@ __exportStar(require("./txstatus"), exports);
20
20
  __exportStar(require("./chain"), exports);
21
21
  __exportStar(require("./blockberry"), exports);
22
22
  __exportStar(require("./tiny-contract"), exports);
23
+ __exportStar(require("./send"), exports);
@@ -1,4 +1,5 @@
1
1
  import { BlockBerryChain } from "./chain";
2
+ import { blockchain } from "../../cloud";
2
3
  export declare function getNonce(params: {
3
4
  account: string;
4
5
  chain: BlockBerryChain;
@@ -8,3 +9,9 @@ export declare function getNonce(params: {
8
9
  nonce: number;
9
10
  message?: string;
10
11
  }>;
12
+ export declare function getAccountNonce(params: {
13
+ account: string;
14
+ chain?: blockchain;
15
+ blockBerryApiKey?: string;
16
+ verbose?: boolean;
17
+ }): Promise<number>;
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNonce = getNonce;
4
+ exports.getAccountNonce = getAccountNonce;
4
5
  const blockberry_1 = require("./blockberry");
6
+ const __1 = require("..");
7
+ const o1js_1 = require("o1js");
5
8
  async function getNonce(params) {
6
9
  const { account, chain, blockBerryApiKey } = params;
7
10
  try {
@@ -58,3 +61,33 @@ async function getNonce(params) {
58
61
  };
59
62
  }
60
63
  }
64
+ async function getAccountNonce(params) {
65
+ const { account, chain = (0, __1.getCurrentNetwork)().network.chainId, blockBerryApiKey, verbose = true, } = params;
66
+ const canUseBlockBerry = blockBerryApiKey !== undefined &&
67
+ (chain === "devnet" || chain === "mainnet");
68
+ if (chain === "zeko") {
69
+ const publicKey = o1js_1.PublicKey.fromBase58(account);
70
+ await (0, __1.fetchMinaAccount)({ publicKey });
71
+ const nonce = Number(o1js_1.Mina.getAccount(publicKey).nonce.toBigint());
72
+ return nonce;
73
+ }
74
+ else {
75
+ const blockberryNoncePromise = canUseBlockBerry
76
+ ? getNonce({
77
+ account,
78
+ blockBerryApiKey,
79
+ chain,
80
+ })
81
+ : undefined;
82
+ const publicKey = o1js_1.PublicKey.fromBase58(account);
83
+ await (0, __1.fetchMinaAccount)({ publicKey });
84
+ const senderNonce = Number(o1js_1.Mina.getAccount(publicKey).nonce.toBigint());
85
+ const blockberryNonce = blockberryNoncePromise
86
+ ? (await blockberryNoncePromise).nonce ?? -1
87
+ : -1;
88
+ const nonce = Math.max(senderNonce, blockberryNonce + 1);
89
+ if (verbose && nonce > senderNonce)
90
+ console.log(`Nonce changed from ${senderNonce} to ${nonce} for ${account}`);
91
+ return nonce;
92
+ }
93
+ }
@@ -0,0 +1,17 @@
1
+ import { Mina } from "o1js";
2
+ import { blockchain } from "../../cloud";
3
+ export declare function sendTx(params: {
4
+ tx: Mina.Transaction<false, true> | Mina.Transaction<true, true>;
5
+ description?: string;
6
+ verbose?: boolean;
7
+ wait?: boolean;
8
+ chain?: blockchain;
9
+ }): Promise<Mina.PendingTransaction | Mina.RejectedTransaction | Mina.IncludedTransaction | undefined>;
10
+ export declare function getTxStatusFast(params: {
11
+ hash: string;
12
+ chain?: blockchain;
13
+ }): Promise<{
14
+ success: boolean;
15
+ result?: boolean;
16
+ error?: string;
17
+ }>;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendTx = sendTx;
4
+ exports.getTxStatusFast = getTxStatusFast;
5
+ const o1js_1 = require("o1js");
6
+ const cloud_1 = require("../../cloud");
7
+ const __1 = require("..");
8
+ async function sendTx(params) {
9
+ const { tx, description = "", verbose = true, wait = true, chain = (0, __1.getCurrentNetwork)().network.chainId, } = params;
10
+ // flatten accountUpdates
11
+ const accountUpdates = JSON.parse(tx.toJSON()).accountUpdates;
12
+ const auCount = [];
13
+ let proofAuthorizationCount = 0;
14
+ // Calculate the number of account updates for each { publicKey, tokenId }
15
+ for (const au of accountUpdates) {
16
+ const { publicKey, tokenId, authorizationKind } = au.body;
17
+ if (au.authorization.proof) {
18
+ proofAuthorizationCount++;
19
+ if (authorizationKind.isProved === false)
20
+ console.error("Proof authorization exists but isProved is false");
21
+ }
22
+ else if (authorizationKind.isProved === true)
23
+ console.error("isProved is true but no proof authorization");
24
+ const index = auCount.findIndex((item) => item.publicKey === publicKey && item.tokenId === tokenId);
25
+ if (index === -1)
26
+ auCount.push({ publicKey, tokenId, count: 1 });
27
+ else
28
+ auCount[index].count++;
29
+ }
30
+ if (verbose)
31
+ console.log(`Account updates for ${description ?? "tx"}: ${auCount.length}, proof authorizations: ${proofAuthorizationCount}`);
32
+ for (const au of auCount) {
33
+ if (au.count > 1)
34
+ if (verbose)
35
+ console.log(`DUPLICATE AU ${description ?? ""}: ${au.publicKey} ${au.tokenId !== "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf"
36
+ ? "tokenId: " + au.tokenId
37
+ : ""} count: ${au.count}`);
38
+ }
39
+ try {
40
+ let txSent;
41
+ let sent = false;
42
+ while (!sent) {
43
+ txSent = await tx.safeSend();
44
+ if (txSent.status == "pending") {
45
+ sent = true;
46
+ if (verbose)
47
+ console.log(`${description ?? ""} tx sent: hash: ${txSent.hash} status: ${txSent.status}`);
48
+ }
49
+ else if (chain === "zeko") {
50
+ if (verbose)
51
+ console.log("Retrying Zeko tx");
52
+ await (0, cloud_1.sleep)(10000);
53
+ }
54
+ else {
55
+ console.error(`${description} tx NOT sent: hash: ${txSent?.hash} status: ${txSent?.status}`, txSent.errors);
56
+ return undefined;
57
+ }
58
+ }
59
+ if (txSent === undefined)
60
+ throw new Error("txSent is undefined");
61
+ if (txSent.errors.length > 0) {
62
+ console.error(`${description ?? ""} tx error: hash: ${txSent.hash} status: ${txSent.status} errors: ${txSent.errors}`);
63
+ }
64
+ if (txSent.status === "pending" && wait !== false && chain !== "zeko") {
65
+ if (verbose)
66
+ console.log(`Waiting for tx inclusion...`);
67
+ const txIncluded = await txSent.safeWait();
68
+ if (txIncluded.status === "included")
69
+ if (verbose)
70
+ console.log(`${description ?? ""} tx included into block: hash: ${txIncluded.hash} status: ${txIncluded.status}`);
71
+ else
72
+ console.error(`${description ?? ""} tx NOT included into block: hash: ${txIncluded.hash} status: ${txIncluded.status}`);
73
+ if (chain !== "local") {
74
+ // we still wait for the tx to be included in the block by checking the nonce
75
+ // even in the case of tx NOT included
76
+ // because the tx might still be included in the block in the case of devnet instability
77
+ const { publicKey, nonce } = tx.transaction.feePayer.body;
78
+ const started = Date.now();
79
+ while (Date.now() - started < 1000 * 60 * 10) {
80
+ const newNonce = (await (0, __1.fetchMinaAccount)({
81
+ publicKey,
82
+ force: true,
83
+ })).account?.nonce;
84
+ if (newNonce &&
85
+ Number(newNonce.toBigint()) > Number(nonce.toBigint()))
86
+ return txIncluded;
87
+ if (verbose)
88
+ console.log(`Waiting for ${chain} to update state for ${Math.floor((Date.now() - started) / 1000)} sec...`);
89
+ await (0, cloud_1.sleep)(10000);
90
+ }
91
+ // finally, if the tx is still not included, show an error
92
+ console.error(`${chain} do not reflect nonce update for tx ${txIncluded.hash} with status ${txIncluded.status}`);
93
+ }
94
+ return txIncluded;
95
+ }
96
+ else
97
+ return txSent;
98
+ }
99
+ catch (error) {
100
+ if (chain !== "zeko")
101
+ console.error("Error sending tx", error);
102
+ }
103
+ }
104
+ async function getTxStatusFast(params) {
105
+ const { hash, chain = (0, __1.getCurrentNetwork)().network.chainId } = params;
106
+ if (chain === "local" || chain === "zeko")
107
+ return { success: true, result: true };
108
+ try {
109
+ const txStatus = await (0, o1js_1.checkZkappTransaction)(hash);
110
+ return {
111
+ success: true,
112
+ result: txStatus?.success ?? false,
113
+ };
114
+ }
115
+ catch (error) {
116
+ console.error("getTxStatusFast error while getting tx status - catch", hash, error);
117
+ return { success: false, error: error?.message ?? "Cannot get tx status" };
118
+ }
119
+ }
@@ -1,5 +1,5 @@
1
1
  import { BlockBerryChain } from "./chain";
2
- export declare function txStatus(params: {
2
+ export declare function txStatusBlockberry(params: {
3
3
  hash: string;
4
4
  time: number;
5
5
  chain: BlockBerryChain;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.txStatus = txStatus;
3
+ exports.txStatusBlockberry = txStatusBlockberry;
4
4
  const blockberry_1 = require("./blockberry");
5
5
  const TIMEOUT = 1000 * 60 * 21;
6
- async function txStatus(params) {
6
+ async function txStatusBlockberry(params) {
7
7
  const { hash, chain, time, blockBerryApiKey } = params;
8
8
  const tx = await (0, blockberry_1.getZkAppTxFromBlockBerry)({ hash, chain, blockBerryApiKey });
9
9
  if (tx?.txStatus)
@@ -3,5 +3,4 @@ export * from "./fetch";
3
3
  export * from "./fields";
4
4
  export * from "./fee";
5
5
  export * from "./mina";
6
- export * from "./ipfs";
7
6
  export * from "./indexed-map";
@@ -19,5 +19,4 @@ __exportStar(require("./fetch"), exports);
19
19
  __exportStar(require("./fields"), exports);
20
20
  __exportStar(require("./fee"), exports);
21
21
  __exportStar(require("./mina"), exports);
22
- __exportStar(require("./ipfs"), exports);
23
22
  __exportStar(require("./indexed-map"), exports);
@@ -12,6 +12,15 @@ export declare function loadIndexedMerkleMap(params: {
12
12
  url: string;
13
13
  type: ReturnType<typeof IndexedMerkleMap>;
14
14
  }): Promise<import("o1js/dist/node/lib/provable/merkle-tree-indexed").IndexedMerkleMapBase>;
15
+ export declare function saveIndexedMerkleMap(params: {
16
+ map: IndexedMerkleMap;
17
+ name?: string;
18
+ keyvalues?: {
19
+ key: string;
20
+ value: string;
21
+ }[];
22
+ auth: string;
23
+ }): Promise<string | undefined>;
15
24
  export declare function serializeIndexedMap(map: IndexedMerkleMap): IndexedMapSerialized;
16
25
  export declare function deserializeIndexedMerkleMap(params: {
17
26
  serializedIndexedMap: IndexedMapSerialized;
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadIndexedMerkleMap = loadIndexedMerkleMap;
4
+ exports.saveIndexedMerkleMap = saveIndexedMerkleMap;
4
5
  exports.serializeIndexedMap = serializeIndexedMap;
5
6
  exports.deserializeIndexedMerkleMap = deserializeIndexedMerkleMap;
6
7
  exports.parseIndexedMapSerialized = parseIndexedMapSerialized;
7
8
  const o1js_1 = require("o1js");
8
9
  const cloud_1 = require("../../cloud");
10
+ const pinata_1 = require("../storage/pinata");
9
11
  const { IndexedMerkleMap } = o1js_1.Experimental;
10
12
  async function loadIndexedMerkleMap(params) {
11
13
  const { url, type } = params;
@@ -23,6 +25,17 @@ async function loadIndexedMerkleMap(params) {
23
25
  }
24
26
  return map;
25
27
  }
28
+ async function saveIndexedMerkleMap(params) {
29
+ const { map, name = "indexed-map", keyvalues, auth } = params;
30
+ const serialized = serializeIndexedMap(map);
31
+ const ipfsHash = await (0, pinata_1.pinJSON)({
32
+ data: serialized,
33
+ name,
34
+ keyvalues,
35
+ auth,
36
+ });
37
+ return ipfsHash;
38
+ }
26
39
  function serializeIndexedMap(map) {
27
40
  return {
28
41
  height: map.height,