zkcloudworker 0.17.3 → 0.17.6
Sign up to get free protection for your applications and to get access to all the features.
- 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/index.d.ts +3 -0
- package/lib/ts/src/mina/storage/index.js +19 -0
- package/lib/ts/src/mina/storage/pinata.d.ts +6 -0
- package/lib/ts/src/mina/storage/pinata.js +36 -0
- package/lib/ts/src/mina/storage/storage.d.ts +75 -0
- package/lib/ts/src/mina/storage/storage.js +55 -0
- package/lib/ts/src/mina/transactions/account.d.ts +4 -0
- package/lib/ts/src/mina/transactions/account.js +48 -0
- package/lib/ts/src/mina/transactions/index.d.ts +2 -0
- package/lib/ts/src/mina/transactions/index.js +2 -0
- package/lib/ts/src/mina/transactions/nonce.d.ts +7 -0
- package/lib/ts/src/mina/transactions/nonce.js +33 -0
- package/lib/ts/src/mina/transactions/send.d.ts +29 -0
- package/lib/ts/src/mina/transactions/send.js +131 -0
- package/lib/ts/src/mina/transactions/txstatus.d.ts +1 -1
- package/lib/ts/src/mina/transactions/txstatus.js +2 -2
- package/lib/ts/src/mina/utils/index.d.ts +0 -1
- package/lib/ts/src/mina/utils/index.js +0 -1
- package/lib/ts/src/mina/utils/indexed-map.d.ts +9 -0
- package/lib/ts/src/mina/utils/indexed-map.js +13 -0
- 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/index.d.ts +3 -0
- package/lib/web/src/mina/storage/index.js +4 -0
- package/lib/web/src/mina/storage/index.js.map +1 -0
- package/lib/web/src/mina/storage/ipfs.js.map +1 -0
- package/lib/web/src/mina/storage/pinata.d.ts +6 -0
- package/lib/web/src/mina/storage/pinata.js +34 -0
- package/lib/web/src/mina/storage/pinata.js.map +1 -0
- package/lib/web/src/mina/storage/storage.d.ts +75 -0
- package/lib/web/src/mina/storage/storage.js +52 -0
- package/lib/web/src/mina/storage/storage.js.map +1 -0
- package/lib/web/src/mina/token/FungibleTokenAdmin.js.map +1 -1
- package/lib/web/src/mina/transactions/account.d.ts +4 -0
- package/lib/web/src/mina/transactions/account.js +44 -0
- package/lib/web/src/mina/transactions/account.js.map +1 -0
- package/lib/web/src/mina/transactions/index.d.ts +2 -0
- package/lib/web/src/mina/transactions/index.js +2 -0
- package/lib/web/src/mina/transactions/index.js.map +1 -1
- package/lib/web/src/mina/transactions/nonce.d.ts +7 -0
- package/lib/web/src/mina/transactions/nonce.js +32 -0
- package/lib/web/src/mina/transactions/nonce.js.map +1 -1
- package/lib/web/src/mina/transactions/send.d.ts +29 -0
- package/lib/web/src/mina/transactions/send.js +128 -0
- package/lib/web/src/mina/transactions/send.js.map +1 -0
- package/lib/web/src/mina/transactions/txstatus.d.ts +1 -1
- package/lib/web/src/mina/transactions/txstatus.js +1 -1
- package/lib/web/src/mina/transactions/txstatus.js.map +1 -1
- package/lib/web/src/mina/utils/index.d.ts +0 -1
- package/lib/web/src/mina/utils/index.js +0 -1
- package/lib/web/src/mina/utils/index.js.map +1 -1
- package/lib/web/src/mina/utils/indexed-map.d.ts +9 -0
- package/lib/web/src/mina/utils/indexed-map.js +12 -0
- 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/utils/ipfs.js.map +0 -1
- /package/lib/ts/src/mina/{utils → storage}/ipfs.d.ts +0 -0
- /package/lib/ts/src/mina/{utils → storage}/ipfs.js +0 -0
- /package/lib/web/src/mina/{utils → storage}/ipfs.d.ts +0 -0
- /package/lib/web/src/mina/{utils → storage}/ipfs.js +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FungibleTokenAdmin.js","sourceRoot":"","sources":["../../../../../../src/mina/token/FungibleTokenAdmin.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,MAAM,EACN,IAAI,E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,SAAS,EAAE,kCAAkC,CAAC,CAAC;YAC7D,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAGY,AAAN,KAAK,CAAC,OAAO,CAAC,cAA6B;QAChD,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAGY,AAAN,KAAK,CAAC,cAAc,CAAC,MAAiB;QAC3C,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAGY,AAAN,KAAK,CAAC,QAAQ;QACnB,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAGY,AAAN,KAAK,CAAC,SAAS;QACpB,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;CACF;AAtDS;IADP,KAAK,CAAC,SAAS,CAAC;;0DAC2B;AAiBtC;IADL,MAAM;;qCACyB,eAAe;;+DAE9C;AAaY;IADZ,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;;qCACgB,aAAa;;iDAGjD;AAGY;IADZ,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;;qCACe,SAAS;;wDAG5C;AAGY;IADZ,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;;;;kDAIpB;AAGY;IADZ,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;;;;mDAIpB"}
|
@@ -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 tokenBalance(address: string | PublicKey, tokenId?: Field): Promise<number | undefined>;
|
4
|
+
export declare function checkAddress(address: string | undefined): Promise<boolean>;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { fetchMinaAccount } from "..";
|
2
|
+
import { Mina, PublicKey } from "o1js";
|
3
|
+
export async function accountExists(address, tokenId) {
|
4
|
+
try {
|
5
|
+
const publicKey = typeof address === "string" ? PublicKey.fromBase58(address) : address;
|
6
|
+
await fetchMinaAccount({ publicKey, tokenId, force: false });
|
7
|
+
return Mina.hasAccount(publicKey, tokenId);
|
8
|
+
}
|
9
|
+
catch (error) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
export async function tokenBalance(address, tokenId) {
|
14
|
+
try {
|
15
|
+
const publicKey = typeof address === "string" ? PublicKey.fromBase58(address) : address;
|
16
|
+
await fetchMinaAccount({ publicKey, tokenId, force: false });
|
17
|
+
return Mina.hasAccount(publicKey, tokenId)
|
18
|
+
? Number(Mina.getAccount(publicKey, tokenId).balance.toBigInt())
|
19
|
+
: undefined;
|
20
|
+
}
|
21
|
+
catch (error) {
|
22
|
+
console.error("Cannot fetch account balance", error);
|
23
|
+
return undefined;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
export async function checkAddress(address) {
|
27
|
+
if (!address || typeof address !== "string") {
|
28
|
+
console.error("checkAddress params are invalid:", address);
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
try {
|
32
|
+
const publicKey = PublicKey.fromBase58(address);
|
33
|
+
if (address !== publicKey.toBase58()) {
|
34
|
+
console.log("checkAddress: address is not valid", address, publicKey.toBase58());
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
catch (error) {
|
40
|
+
console.error("checkAddress catch", { address, error });
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
//# sourceMappingURL=account.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","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D,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,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"}
|
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,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,4 +1,6 @@
|
|
1
1
|
import { getZkAppTxsFromBlockBerry, getPaymentTxsFromBlockBerry, } from "./blockberry";
|
2
|
+
import { fetchMinaAccount, getCurrentNetwork } from "..";
|
3
|
+
import { Mina, PublicKey } from "o1js";
|
2
4
|
export async function getNonce(params) {
|
3
5
|
const { account, chain, blockBerryApiKey } = params;
|
4
6
|
try {
|
@@ -55,4 +57,34 @@ export async function getNonce(params) {
|
|
55
57
|
};
|
56
58
|
}
|
57
59
|
}
|
60
|
+
export async function getAccountNonce(params) {
|
61
|
+
const { account, chain = getCurrentNetwork().network.chainId, blockBerryApiKey, verbose = true, } = params;
|
62
|
+
const canUseBlockBerry = blockBerryApiKey !== undefined &&
|
63
|
+
(chain === "devnet" || chain === "mainnet");
|
64
|
+
if (chain === "zeko") {
|
65
|
+
const publicKey = PublicKey.fromBase58(account);
|
66
|
+
await fetchMinaAccount({ publicKey });
|
67
|
+
const nonce = Number(Mina.getAccount(publicKey).nonce.toBigint());
|
68
|
+
return nonce;
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
const blockberryNoncePromise = canUseBlockBerry
|
72
|
+
? getNonce({
|
73
|
+
account,
|
74
|
+
blockBerryApiKey,
|
75
|
+
chain,
|
76
|
+
})
|
77
|
+
: undefined;
|
78
|
+
const publicKey = PublicKey.fromBase58(account);
|
79
|
+
await fetchMinaAccount({ publicKey });
|
80
|
+
const senderNonce = Number(Mina.getAccount(publicKey).nonce.toBigint());
|
81
|
+
const blockberryNonce = blockberryNoncePromise
|
82
|
+
? (await blockberryNoncePromise).nonce ?? -1
|
83
|
+
: -1;
|
84
|
+
const nonce = Math.max(senderNonce, blockberryNonce + 1);
|
85
|
+
if (verbose && nonce > senderNonce)
|
86
|
+
console.log(`Nonce changed from ${senderNonce} to ${nonce} for ${account}`);
|
87
|
+
return nonce;
|
88
|
+
}
|
89
|
+
}
|
58
90
|
//# sourceMappingURL=nonce.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nonce.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/nonce.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"nonce.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/nonce.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGvC,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAI9B;IAKC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC;IACpD,IAAI,CAAC;QACH,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YAChE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,CAAC,CAAC;gBACT,OAAO,EAAE,qBAAqB;aAC/B,CAAC;QACJ,CAAC;QAED,IACE,gBAAgB,KAAK,SAAS;YAC9B,gBAAgB,KAAK,IAAI;YACzB,gBAAgB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G,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,eAAe,GAAG,CAAC,CAAC,CAAC;QACzD,IAAI,OAAO,IAAI,KAAK,GAAG,WAAW;YAChC,OAAO,CAAC,GAAG,CACT,sBAAsB,WAAW,OAAO,KAAK,QAAQ,OAAO,EAAE,CAC/D,CAAC;QACJ,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Mina } from "o1js";
|
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
|
+
*/
|
15
|
+
export declare function sendTx(params: {
|
16
|
+
tx: Mina.Transaction<false, true> | Mina.Transaction<true, true>;
|
17
|
+
description?: string;
|
18
|
+
verbose?: boolean;
|
19
|
+
wait?: boolean;
|
20
|
+
chain?: blockchain;
|
21
|
+
}): Promise<Mina.IncludedTransaction | Mina.PendingTransaction | Mina.RejectedTransaction | undefined>;
|
22
|
+
export declare function getTxStatusFast(params: {
|
23
|
+
hash: string;
|
24
|
+
chain?: blockchain;
|
25
|
+
}): Promise<{
|
26
|
+
success: boolean;
|
27
|
+
result?: boolean;
|
28
|
+
error?: string;
|
29
|
+
}>;
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import { checkZkappTransaction } from "o1js";
|
2
|
+
import { sleep } from "../../cloud";
|
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
|
+
*/
|
16
|
+
export async function sendTx(params) {
|
17
|
+
const { tx, description = "", verbose = true, wait = true, chain = getCurrentNetwork().network.chainId, } = params;
|
18
|
+
// flatten accountUpdates
|
19
|
+
const accountUpdates = JSON.parse(tx.toJSON()).accountUpdates;
|
20
|
+
const auCount = [];
|
21
|
+
let proofAuthorizationCount = 0;
|
22
|
+
// Calculate the number of account updates for each { publicKey, tokenId }
|
23
|
+
for (const au of accountUpdates) {
|
24
|
+
const { publicKey, tokenId, authorizationKind } = au.body;
|
25
|
+
if (au.authorization.proof) {
|
26
|
+
proofAuthorizationCount++;
|
27
|
+
if (authorizationKind.isProved === false)
|
28
|
+
console.error("Proof authorization exists but isProved is false");
|
29
|
+
}
|
30
|
+
else if (authorizationKind.isProved === true)
|
31
|
+
console.error("isProved is true but no proof authorization");
|
32
|
+
const index = auCount.findIndex((item) => item.publicKey === publicKey && item.tokenId === tokenId);
|
33
|
+
if (index === -1)
|
34
|
+
auCount.push({ publicKey, tokenId, count: 1 });
|
35
|
+
else
|
36
|
+
auCount[index].count++;
|
37
|
+
}
|
38
|
+
if (verbose)
|
39
|
+
console.log(`Account updates for ${description ?? "tx"}: ${auCount.length}, proof authorizations: ${proofAuthorizationCount}`);
|
40
|
+
for (const au of auCount) {
|
41
|
+
if (au.count > 1)
|
42
|
+
if (verbose)
|
43
|
+
console.log(`DUPLICATE AU ${description ?? ""}: ${au.publicKey} ${au.tokenId !== "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf"
|
44
|
+
? "tokenId: " + au.tokenId
|
45
|
+
: ""} count: ${au.count}`);
|
46
|
+
}
|
47
|
+
try {
|
48
|
+
let txSent;
|
49
|
+
let sent = false;
|
50
|
+
while (!sent) {
|
51
|
+
txSent = await tx.safeSend();
|
52
|
+
if (txSent.status == "pending") {
|
53
|
+
sent = true;
|
54
|
+
if (verbose)
|
55
|
+
console.log(`${description ?? ""} tx sent: hash: ${txSent.hash} status: ${txSent.status}`);
|
56
|
+
}
|
57
|
+
else if (chain === "zeko") {
|
58
|
+
if (verbose)
|
59
|
+
console.log("Retrying Zeko tx");
|
60
|
+
await sleep(10000);
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
console.error(`${description} tx NOT sent: hash: ${txSent?.hash} status: ${txSent?.status}`, txSent.errors);
|
64
|
+
return txSent;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
if (txSent === undefined)
|
68
|
+
throw new Error("txSent is undefined");
|
69
|
+
if (txSent.errors.length > 0) {
|
70
|
+
console.error(`${description ?? ""} tx error: hash: ${txSent.hash} status: ${txSent.status} errors: ${txSent.errors}`);
|
71
|
+
}
|
72
|
+
if (txSent.status === "pending" && wait !== false && chain !== "zeko") {
|
73
|
+
if (verbose)
|
74
|
+
console.log(`Waiting for tx inclusion...`);
|
75
|
+
const txIncluded = await txSent.safeWait();
|
76
|
+
if (txIncluded.status === "included")
|
77
|
+
if (verbose)
|
78
|
+
console.log(`${description ?? ""} tx included into block: hash: ${txIncluded.hash} status: ${txIncluded.status}`);
|
79
|
+
else
|
80
|
+
console.error(`${description ?? ""} tx NOT included into block: hash: ${txIncluded.hash} status: ${txIncluded.status}`);
|
81
|
+
if (chain !== "local") {
|
82
|
+
// we still wait for the tx to be included in the block by checking the nonce
|
83
|
+
// even in the case of tx NOT included
|
84
|
+
// because the tx might still be included in the block in the case of devnet instability
|
85
|
+
const { publicKey, nonce } = tx.transaction.feePayer.body;
|
86
|
+
const started = Date.now();
|
87
|
+
while (Date.now() - started < 1000 * 60 * 10) {
|
88
|
+
const newNonce = (await fetchMinaAccount({
|
89
|
+
publicKey,
|
90
|
+
force: true,
|
91
|
+
})).account?.nonce;
|
92
|
+
if (newNonce &&
|
93
|
+
Number(newNonce.toBigint()) > Number(nonce.toBigint()))
|
94
|
+
return txIncluded;
|
95
|
+
if (verbose)
|
96
|
+
console.log(`Waiting for ${chain} to update state for ${Math.floor((Date.now() - started) / 1000)} sec...`);
|
97
|
+
await sleep(10000);
|
98
|
+
}
|
99
|
+
// finally, if the tx is still not included, show an error
|
100
|
+
console.error(`${chain} do not reflect nonce update for tx ${txIncluded.hash} with status ${txIncluded.status}`);
|
101
|
+
}
|
102
|
+
return txIncluded;
|
103
|
+
}
|
104
|
+
else
|
105
|
+
return txSent;
|
106
|
+
}
|
107
|
+
catch (error) {
|
108
|
+
if (chain !== "zeko")
|
109
|
+
console.error("Error sending tx", error);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
export async function getTxStatusFast(params) {
|
113
|
+
const { hash, chain = getCurrentNetwork().network.chainId } = params;
|
114
|
+
if (chain === "local" || chain === "zeko")
|
115
|
+
return { success: true, result: true };
|
116
|
+
try {
|
117
|
+
const txStatus = await checkZkappTransaction(hash);
|
118
|
+
return {
|
119
|
+
success: true,
|
120
|
+
result: txStatus?.success ?? false,
|
121
|
+
};
|
122
|
+
}
|
123
|
+
catch (error) {
|
124
|
+
console.error("getTxStatusFast error while getting tx status - catch", hash, error);
|
125
|
+
return { success: false, error: error?.message ?? "Cannot get tx status" };
|
126
|
+
}
|
127
|
+
}
|
128
|
+
//# sourceMappingURL=send.js.map
|
@@ -0,0 +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,KA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;QACH,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACnD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,QAAQ,EAAE,OAAO,IAAI,KAAK;SACnC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CACX,uDAAuD,EACvD,IAAI,EACJ,KAAK,CACN,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,IAAI,sBAAsB,EAAE,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { getZkAppTxFromBlockBerry } from "./blockberry";
|
2
2
|
const TIMEOUT = 1000 * 60 * 21;
|
3
|
-
export async function
|
3
|
+
export async function txStatusBlockberry(params) {
|
4
4
|
const { hash, chain, time, blockBerryApiKey } = params;
|
5
5
|
const tx = await getZkAppTxFromBlockBerry({ hash, chain, blockBerryApiKey });
|
6
6
|
if (tx?.txStatus)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"txstatus.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/txstatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,
|
1
|
+
{"version":3,"file":"txstatus.js","sourceRoot":"","sources":["../../../../../../src/mina/transactions/txstatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAMxC;IACC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAEvD,MAAM,EAAE,GAAG,MAAM,wBAAwB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,EAAE,QAAQ;QAAE,OAAO,EAAE,EAAE,QAAQ,CAAC;IACtC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,KAAK,CACX,qDAAqD,EACrD,KAAK,EACL,IAAI,CACL,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/mina/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/mina/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
|
@@ -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,5 +1,6 @@
|
|
1
1
|
import { Experimental, Field } from "o1js";
|
2
2
|
import { bigintToBase64, bigintFromBase64 } from "../../cloud";
|
3
|
+
import { pinJSON } from "../storage/pinata";
|
3
4
|
const { IndexedMerkleMap } = Experimental;
|
4
5
|
export async function loadIndexedMerkleMap(params) {
|
5
6
|
const { url, type } = params;
|
@@ -17,6 +18,17 @@ export async function loadIndexedMerkleMap(params) {
|
|
17
18
|
}
|
18
19
|
return map;
|
19
20
|
}
|
21
|
+
export async function saveIndexedMerkleMap(params) {
|
22
|
+
const { map, name = "indexed-map", keyvalues, auth } = params;
|
23
|
+
const serialized = serializeIndexedMap(map);
|
24
|
+
const ipfsHash = await pinJSON({
|
25
|
+
data: serialized,
|
26
|
+
name,
|
27
|
+
keyvalues,
|
28
|
+
auth,
|
29
|
+
});
|
30
|
+
return ipfsHash;
|
31
|
+
}
|
20
32
|
export function serializeIndexedMap(map) {
|
21
33
|
return {
|
22
34
|
height: map.height,
|
@@ -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,MAAM,aAAa,C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