zkcloudworker 0.12.2 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/lib/ts/src/mina/index.d.ts +2 -0
  2. package/lib/ts/src/mina/index.js +2 -0
  3. package/lib/ts/src/mina/token/FungibleToken.d.ts +338 -0
  4. package/lib/ts/src/mina/token/FungibleToken.js +290 -0
  5. package/lib/ts/src/mina/token/FungibleTokenAdmin.d.ts +31 -0
  6. package/lib/ts/src/mina/token/FungibleTokenAdmin.js +102 -0
  7. package/lib/ts/src/mina/token/index.d.ts +2 -0
  8. package/lib/ts/src/mina/token/index.js +18 -0
  9. package/lib/ts/src/mina/transactions/blockberry.d.ts +16 -0
  10. package/lib/ts/src/mina/transactions/blockberry.js +80 -0
  11. package/lib/ts/src/mina/transactions/chain.d.ts +1 -0
  12. package/lib/ts/src/mina/transactions/chain.js +2 -0
  13. package/lib/ts/src/mina/transactions/index.d.ts +6 -0
  14. package/lib/ts/src/mina/transactions/index.js +22 -0
  15. package/lib/ts/src/mina/transactions/nonce.d.ts +10 -0
  16. package/lib/ts/src/mina/transactions/nonce.js +60 -0
  17. package/lib/ts/src/mina/transactions/tiny-contract.d.ts +5 -0
  18. package/lib/ts/src/mina/transactions/tiny-contract.js +33 -0
  19. package/lib/ts/src/mina/transactions/transaction.d.ts +9 -0
  20. package/lib/ts/src/mina/transactions/transaction.js +69 -0
  21. package/lib/ts/src/mina/transactions/txstatus.d.ts +8 -0
  22. package/lib/ts/src/mina/transactions/txstatus.js +18 -0
  23. package/lib/ts/src/mina/utils/fetch.js +1 -1
  24. package/lib/ts/tsconfig.tsbuildinfo +1 -1
  25. package/lib/web/src/mina/index.d.ts +2 -0
  26. package/lib/web/src/mina/index.js +2 -0
  27. package/lib/web/src/mina/index.js.map +1 -1
  28. package/lib/web/src/mina/token/FungibleToken.d.ts +338 -0
  29. package/lib/web/src/mina/token/FungibleToken.js +274 -0
  30. package/lib/web/src/mina/token/FungibleToken.js.map +1 -0
  31. package/lib/web/src/mina/token/FungibleTokenAdmin.d.ts +31 -0
  32. package/lib/web/src/mina/token/FungibleTokenAdmin.js +91 -0
  33. package/lib/web/src/mina/token/FungibleTokenAdmin.js.map +1 -0
  34. package/lib/web/src/mina/token/index.d.ts +2 -0
  35. package/lib/web/src/mina/token/index.js +3 -0
  36. package/lib/web/src/mina/token/index.js.map +1 -0
  37. package/lib/web/src/mina/transactions/blockberry.d.ts +16 -0
  38. package/lib/web/src/mina/transactions/blockberry.js +76 -0
  39. package/lib/web/src/mina/transactions/blockberry.js.map +1 -0
  40. package/lib/web/src/mina/transactions/chain.d.ts +1 -0
  41. package/lib/web/src/mina/transactions/chain.js +2 -0
  42. package/lib/web/src/mina/transactions/chain.js.map +1 -0
  43. package/lib/web/src/mina/transactions/index.d.ts +6 -0
  44. package/lib/web/src/mina/transactions/index.js +7 -0
  45. package/lib/web/src/mina/transactions/index.js.map +1 -0
  46. package/lib/web/src/mina/transactions/nonce.d.ts +10 -0
  47. package/lib/web/src/mina/transactions/nonce.js +58 -0
  48. package/lib/web/src/mina/transactions/nonce.js.map +1 -0
  49. package/lib/web/src/mina/transactions/tiny-contract.d.ts +5 -0
  50. package/lib/web/src/mina/transactions/tiny-contract.js +22 -0
  51. package/lib/web/src/mina/transactions/tiny-contract.js.map +1 -0
  52. package/lib/web/src/mina/transactions/transaction.d.ts +9 -0
  53. package/lib/web/src/mina/transactions/transaction.js +65 -0
  54. package/lib/web/src/mina/transactions/transaction.js.map +1 -0
  55. package/lib/web/src/mina/transactions/txstatus.d.ts +8 -0
  56. package/lib/web/src/mina/transactions/txstatus.js +16 -0
  57. package/lib/web/src/mina/transactions/txstatus.js.map +1 -0
  58. package/lib/web/src/mina/utils/fetch.js +1 -1
  59. package/lib/web/tsconfig.web.tsbuildinfo +1 -1
  60. package/package.json +5 -5
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FungibleTokenAdmin = void 0;
13
+ const o1js_1 = require("o1js");
14
+ /** A contract that grants permissions for administrative actions on a token.
15
+ *
16
+ * We separate this out into a dedicated contract. That way, when issuing a token, a user can
17
+ * specify their own rules for administrative actions, without changing the token contract itself.
18
+ *
19
+ * The advantage is that third party applications that only use the token in a non-privileged way
20
+ * can integrate against the unchanged token contract.
21
+ */
22
+ class FungibleTokenAdmin extends o1js_1.SmartContract {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.adminPublicKey = (0, o1js_1.State)();
26
+ }
27
+ async deploy(props) {
28
+ await super.deploy(props);
29
+ this.adminPublicKey.set(props.adminPublicKey);
30
+ this.account.permissions.set({
31
+ ...o1js_1.Permissions.default(),
32
+ setVerificationKey: o1js_1.Permissions.VerificationKey.impossibleDuringCurrentVersion(),
33
+ setPermissions: o1js_1.Permissions.impossible(),
34
+ });
35
+ }
36
+ /** Update the verification key.
37
+ * Note that because we have set the permissions for setting the verification key to `impossibleDuringCurrentVersion()`, this will only be possible in case of a protocol update that requires an update.
38
+ */
39
+ async updateVerificationKey(vk) {
40
+ this.account.verificationKey.set(vk);
41
+ }
42
+ async ensureAdminSignature() {
43
+ const admin = await o1js_1.Provable.witnessAsync(o1js_1.PublicKey, async () => {
44
+ let pk = await this.adminPublicKey.fetch();
45
+ (0, o1js_1.assert)(pk !== undefined, "could not fetch admin public key");
46
+ return pk;
47
+ });
48
+ this.adminPublicKey.requireEquals(admin);
49
+ return o1js_1.AccountUpdate.createSigned(admin);
50
+ }
51
+ async canMint(_accountUpdate) {
52
+ await this.ensureAdminSignature();
53
+ return (0, o1js_1.Bool)(true);
54
+ }
55
+ async canChangeAdmin(_admin) {
56
+ await this.ensureAdminSignature();
57
+ return (0, o1js_1.Bool)(true);
58
+ }
59
+ async canPause() {
60
+ await this.ensureAdminSignature();
61
+ return (0, o1js_1.Bool)(true);
62
+ }
63
+ async canResume() {
64
+ await this.ensureAdminSignature();
65
+ return (0, o1js_1.Bool)(true);
66
+ }
67
+ }
68
+ exports.FungibleTokenAdmin = FungibleTokenAdmin;
69
+ __decorate([
70
+ (0, o1js_1.state)(o1js_1.PublicKey),
71
+ __metadata("design:type", Object)
72
+ ], FungibleTokenAdmin.prototype, "adminPublicKey", void 0);
73
+ __decorate([
74
+ o1js_1.method,
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", [o1js_1.VerificationKey]),
77
+ __metadata("design:returntype", Promise)
78
+ ], FungibleTokenAdmin.prototype, "updateVerificationKey", null);
79
+ __decorate([
80
+ o1js_1.method.returns(o1js_1.Bool),
81
+ __metadata("design:type", Function),
82
+ __metadata("design:paramtypes", [o1js_1.AccountUpdate]),
83
+ __metadata("design:returntype", Promise)
84
+ ], FungibleTokenAdmin.prototype, "canMint", null);
85
+ __decorate([
86
+ o1js_1.method.returns(o1js_1.Bool),
87
+ __metadata("design:type", Function),
88
+ __metadata("design:paramtypes", [o1js_1.PublicKey]),
89
+ __metadata("design:returntype", Promise)
90
+ ], FungibleTokenAdmin.prototype, "canChangeAdmin", null);
91
+ __decorate([
92
+ o1js_1.method.returns(o1js_1.Bool),
93
+ __metadata("design:type", Function),
94
+ __metadata("design:paramtypes", []),
95
+ __metadata("design:returntype", Promise)
96
+ ], FungibleTokenAdmin.prototype, "canPause", null);
97
+ __decorate([
98
+ o1js_1.method.returns(o1js_1.Bool),
99
+ __metadata("design:type", Function),
100
+ __metadata("design:paramtypes", []),
101
+ __metadata("design:returntype", Promise)
102
+ ], FungibleTokenAdmin.prototype, "canResume", null);
@@ -0,0 +1,2 @@
1
+ export * from "./FungibleToken";
2
+ export * from "./FungibleTokenAdmin";
@@ -0,0 +1,18 @@
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("./FungibleToken"), exports);
18
+ __exportStar(require("./FungibleTokenAdmin"), exports);
@@ -0,0 +1,16 @@
1
+ import { BlockBerryChain } from "./chain";
2
+ export declare function getZkAppTxsFromBlockBerry(params: {
3
+ account: string;
4
+ chain: BlockBerryChain;
5
+ blockBerryApiKey: string;
6
+ }): Promise<any>;
7
+ export declare function getPaymentTxsFromBlockBerry(params: {
8
+ account: string;
9
+ chain: BlockBerryChain;
10
+ blockBerryApiKey: string;
11
+ }): Promise<any>;
12
+ export declare function getZkAppTxFromBlockBerry(params: {
13
+ hash: string;
14
+ chain: BlockBerryChain;
15
+ blockBerryApiKey: string;
16
+ }): Promise<any>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getZkAppTxsFromBlockBerry = getZkAppTxsFromBlockBerry;
4
+ exports.getPaymentTxsFromBlockBerry = getPaymentTxsFromBlockBerry;
5
+ exports.getZkAppTxFromBlockBerry = getZkAppTxFromBlockBerry;
6
+ async function getZkAppTxsFromBlockBerry(params) {
7
+ const { account, chain, blockBerryApiKey } = params;
8
+ const options = {
9
+ method: "GET",
10
+ headers: {
11
+ accept: "application/json",
12
+ "x-api-key": blockBerryApiKey,
13
+ },
14
+ };
15
+ try {
16
+ const response = await fetch(`https://api.blockberry.one/mina-${chain}/v1/zkapps/accounts/${account}/txs?size=10&orderBy=DESC&sortBy=AGE`, options);
17
+ if (!response.ok) {
18
+ console.error("Cannot fetch zkApp txs for account:", account, chain, response.statusText);
19
+ return undefined;
20
+ }
21
+ const result = await response.json();
22
+ //console.log("zkAppTxs", result);
23
+ return result;
24
+ }
25
+ catch (err) {
26
+ console.error("Cannot fetch zkApp txs for account - catch:", account, chain, err);
27
+ return undefined;
28
+ }
29
+ }
30
+ async function getPaymentTxsFromBlockBerry(params) {
31
+ const { account, chain, blockBerryApiKey } = params;
32
+ const options = {
33
+ method: "GET",
34
+ headers: {
35
+ accept: "application/json",
36
+ "x-api-key": blockBerryApiKey,
37
+ },
38
+ };
39
+ try {
40
+ const response = await fetch(`https://api.blockberry.one/mina-${chain}/v1/accounts/` +
41
+ account +
42
+ "/txs?page=0&size=1&orderBy=DESC&sortBy=AGE&direction=OUT", options);
43
+ if (!response.ok) {
44
+ console.error("Cannot fetch payment txs for account:", account, chain, response.statusText);
45
+ return undefined;
46
+ }
47
+ const result = await response.json();
48
+ //console.log("paymentTxs", result);
49
+ return result;
50
+ }
51
+ catch (err) {
52
+ console.error("Cannot fetch payment txs for account - catch:", account, chain, err);
53
+ return undefined;
54
+ }
55
+ }
56
+ async function getZkAppTxFromBlockBerry(params) {
57
+ const { hash, chain, blockBerryApiKey } = params;
58
+ const options = {
59
+ method: "GET",
60
+ headers: {
61
+ accept: "application/json",
62
+ "x-api-key": blockBerryApiKey,
63
+ },
64
+ };
65
+ try {
66
+ const response = await fetch(`https://api.blockberry.one/mina-${chain}/v1/zkapps/txs/${hash}`, options);
67
+ if (response.ok) {
68
+ const result = await response.json();
69
+ return result;
70
+ }
71
+ else {
72
+ console.error("getZkAppTxFromBlockBerry error while getting hash - not ok", { hash, chain, text: response.statusText, status: response.status });
73
+ return undefined;
74
+ }
75
+ }
76
+ catch (err) {
77
+ console.error("getZkAppTxFromBlockBerry error while getting mainnet hash - catch", hash, chain, err);
78
+ return undefined;
79
+ }
80
+ }
@@ -0,0 +1 @@
1
+ export type BlockBerryChain = "mainnet" | "devnet";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export * from "./nonce";
2
+ export * from "./transaction";
3
+ export * from "./txstatus";
4
+ export * from "./chain";
5
+ export * from "./blockberry";
6
+ export * from "./tiny-contract";
@@ -0,0 +1,22 @@
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("./nonce"), exports);
18
+ __exportStar(require("./transaction"), exports);
19
+ __exportStar(require("./txstatus"), exports);
20
+ __exportStar(require("./chain"), exports);
21
+ __exportStar(require("./blockberry"), exports);
22
+ __exportStar(require("./tiny-contract"), exports);
@@ -0,0 +1,10 @@
1
+ import { BlockBerryChain } from "./chain";
2
+ export declare function getNonce(params: {
3
+ account: string;
4
+ chain: BlockBerryChain;
5
+ blockBerryApiKey: string;
6
+ }): Promise<{
7
+ success: boolean;
8
+ nonce: number;
9
+ message?: string;
10
+ }>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNonce = getNonce;
4
+ const blockberry_1 = require("./blockberry");
5
+ async function getNonce(params) {
6
+ const { account, chain, blockBerryApiKey } = params;
7
+ try {
8
+ if (account === undefined || account === null || account === "") {
9
+ return {
10
+ success: false,
11
+ nonce: -1,
12
+ message: "Account is required",
13
+ };
14
+ }
15
+ if (blockBerryApiKey === undefined ||
16
+ blockBerryApiKey === null ||
17
+ blockBerryApiKey === "") {
18
+ return {
19
+ success: false,
20
+ nonce: -1,
21
+ message: "blockBerryApiKey is required",
22
+ };
23
+ }
24
+ const zkAppTxsPromise = (0, blockberry_1.getZkAppTxsFromBlockBerry)({
25
+ account,
26
+ chain,
27
+ blockBerryApiKey,
28
+ });
29
+ const paymentTxs = (0, blockberry_1.getPaymentTxsFromBlockBerry)({
30
+ account,
31
+ chain,
32
+ blockBerryApiKey,
33
+ });
34
+ const paymentNonce = (await paymentTxs)?.data[0]?.nonce ?? -1;
35
+ let zkNonce = -1;
36
+ let found = false;
37
+ const zkAppTxs = await zkAppTxsPromise;
38
+ const size = zkAppTxs?.data?.length ?? 0;
39
+ let i = 0;
40
+ while (!found && i < size) {
41
+ if (zkAppTxs?.data[i]?.proverAddress === account) {
42
+ zkNonce = zkAppTxs?.data[i]?.nonce;
43
+ found = true;
44
+ }
45
+ i++;
46
+ }
47
+ const nonce = Math.max(zkNonce, paymentNonce);
48
+ return {
49
+ success: true,
50
+ nonce,
51
+ };
52
+ }
53
+ catch (error) {
54
+ return {
55
+ success: false,
56
+ nonce: -1,
57
+ message: String(error),
58
+ };
59
+ }
60
+ }
@@ -0,0 +1,5 @@
1
+ import { Field, SmartContract, State } from "o1js";
2
+ export declare class TinyContract extends SmartContract {
3
+ value: State<import("o1js/dist/node/lib/provable/field").Field>;
4
+ setValue(value: Field): Promise<void>;
5
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TinyContract = void 0;
13
+ const o1js_1 = require("o1js");
14
+ class TinyContract extends o1js_1.SmartContract {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.value = (0, o1js_1.State)();
18
+ }
19
+ async setValue(value) {
20
+ this.value.set(value);
21
+ }
22
+ }
23
+ exports.TinyContract = TinyContract;
24
+ __decorate([
25
+ (0, o1js_1.state)(o1js_1.Field),
26
+ __metadata("design:type", Object)
27
+ ], TinyContract.prototype, "value", void 0);
28
+ __decorate([
29
+ o1js_1.method,
30
+ __metadata("design:type", Function),
31
+ __metadata("design:paramtypes", [o1js_1.Field]),
32
+ __metadata("design:returntype", Promise)
33
+ ], TinyContract.prototype, "setValue", null);
@@ -0,0 +1,9 @@
1
+ import { PublicKey, Transaction, Mina, UInt64 } from "o1js";
2
+ export declare function transactionParams(serializedTransaction: string, signedJson: any): {
3
+ fee: UInt64;
4
+ sender: PublicKey;
5
+ nonce: number;
6
+ memo: string;
7
+ };
8
+ export declare function deserializeTransaction(serializedTransaction: string, txNew: Mina.Transaction<false, false>, signedJson: any): Transaction<false, true>;
9
+ export declare function serializeTransaction(tx: Mina.Transaction<false, false>): string;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transactionParams = transactionParams;
4
+ exports.deserializeTransaction = deserializeTransaction;
5
+ exports.serializeTransaction = serializeTransaction;
6
+ const o1js_1 = require("o1js");
7
+ function transactionParams(serializedTransaction, signedJson) {
8
+ const { sender, nonce, tx } = JSON.parse(serializedTransaction);
9
+ const transaction = o1js_1.Mina.Transaction.fromJSON(JSON.parse(tx));
10
+ const memo = transaction.transaction.memo;
11
+ return {
12
+ fee: o1js_1.UInt64.from(signedJson.zkappCommand.feePayer.body.fee),
13
+ sender: o1js_1.PublicKey.fromBase58(sender),
14
+ nonce: Number(signedJson.zkappCommand.feePayer.body.nonce),
15
+ memo,
16
+ };
17
+ }
18
+ function deserializeTransaction(serializedTransaction, txNew, signedJson) {
19
+ //console.log("new transaction", txNew);
20
+ const { tx, blindingValues, length } = JSON.parse(serializedTransaction);
21
+ const transaction = o1js_1.Mina.Transaction.fromJSON(JSON.parse(tx));
22
+ //console.log("transaction", transaction);
23
+ if (length !== txNew.transaction.accountUpdates.length) {
24
+ throw new Error("New Transaction length mismatch");
25
+ }
26
+ if (length !== transaction.transaction.accountUpdates.length) {
27
+ throw new Error("Serialized Transaction length mismatch");
28
+ }
29
+ for (let i = 0; i < length; i++) {
30
+ transaction.transaction.accountUpdates[i].lazyAuthorization =
31
+ txNew.transaction.accountUpdates[i].lazyAuthorization;
32
+ if (blindingValues[i] !== "")
33
+ transaction.transaction.accountUpdates[i].lazyAuthorization.blindingValue = o1js_1.Field.fromJSON(blindingValues[i]);
34
+ }
35
+ transaction.transaction.feePayer.authorization =
36
+ signedJson.zkappCommand.feePayer.authorization;
37
+ transaction.transaction.feePayer.body.fee = o1js_1.UInt64.from(signedJson.zkappCommand.feePayer.body.fee);
38
+ for (let i = 0; i < length; i++) {
39
+ const signature = signedJson.zkappCommand.accountUpdates[i].authorization.signature;
40
+ if (signature !== undefined && signature !== null) {
41
+ transaction.transaction.accountUpdates[i].authorization.signature =
42
+ signedJson.zkappCommand.accountUpdates[i].authorization.signature;
43
+ }
44
+ }
45
+ return transaction;
46
+ }
47
+ function serializeTransaction(tx) {
48
+ const length = tx.transaction.accountUpdates.length;
49
+ let i;
50
+ let blindingValues = [];
51
+ for (i = 0; i < length; i++) {
52
+ const la = tx.transaction.accountUpdates[i].lazyAuthorization;
53
+ if (la !== undefined &&
54
+ la.blindingValue !== undefined &&
55
+ la.kind === "lazy-proof")
56
+ blindingValues.push(la.blindingValue.toJSON());
57
+ else
58
+ blindingValues.push("");
59
+ }
60
+ const serializedTransaction = JSON.stringify({
61
+ tx: tx.toJSON(),
62
+ blindingValues,
63
+ length,
64
+ fee: tx.transaction.feePayer.body.fee.toJSON(),
65
+ sender: tx.transaction.feePayer.body.publicKey.toBase58(),
66
+ nonce: tx.transaction.feePayer.body.nonce.toBigint().toString(),
67
+ }, null, 2);
68
+ return serializedTransaction;
69
+ }
@@ -0,0 +1,8 @@
1
+ import { BlockBerryChain } from "./chain";
2
+ export declare function txStatus(params: {
3
+ hash: string;
4
+ time: number;
5
+ chain: BlockBerryChain;
6
+ blockBerryApiKey: string;
7
+ timeout?: number;
8
+ }): Promise<string>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.txStatus = txStatus;
4
+ const blockberry_1 = require("./blockberry");
5
+ const TIMEOUT = 1000 * 60 * 21;
6
+ async function txStatus(params) {
7
+ const { hash, chain, time, blockBerryApiKey } = params;
8
+ const tx = await (0, blockberry_1.getZkAppTxFromBlockBerry)({ hash, chain, blockBerryApiKey });
9
+ if (tx?.txStatus)
10
+ return tx?.txStatus;
11
+ if (Date.now() - time > (params.timeout ?? TIMEOUT)) {
12
+ console.error("txStatus: Timeout while checking tx with blockberry", chain, hash);
13
+ return "replaced";
14
+ }
15
+ else {
16
+ return "pending";
17
+ }
18
+ }
@@ -44,7 +44,7 @@ async function fetchMinaAccount(params) {
44
44
  return result;
45
45
  }
46
46
  }
47
- await (0, cloud_1.sleep)(1000 * 5);
47
+ await (0, cloud_1.sleep)(1000 * 6);
48
48
  }
49
49
  if (force === true)
50
50
  throw new Error(`fetchMinaAccount timeout