zkcloudworker 0.20.3 → 0.21.0
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/dist/node/index.cjs +21 -36
- package/dist/node/mina/token/api.d.ts +13 -6
- package/dist/node/mina/token/api.js +29 -36
- package/dist/node/mina/token/api.js.map +1 -1
- package/dist/web/mina/token/api.d.ts +13 -6
- package/dist/web/mina/token/api.js +29 -36
- package/dist/web/mina/token/api.js.map +1 -1
- package/package.json +2 -2
- package/src/mina/token/api.ts +38 -43
package/dist/node/index.cjs
CHANGED
@@ -1888,32 +1888,20 @@ var TokenAPI = class {
|
|
1888
1888
|
zkcloudworker
|
1889
1889
|
});
|
1890
1890
|
}
|
1891
|
-
async
|
1892
|
-
const
|
1893
|
-
const
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
task: "deploy",
|
1899
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
1900
|
-
metadata: `deploy token ${symbol}`
|
1901
|
-
});
|
1902
|
-
const jobId = answer.jobId;
|
1903
|
-
if (jobId === void 0)
|
1904
|
-
console.error("Deploy Job ID is undefined", { answer, symbol });
|
1905
|
-
return jobId;
|
1906
|
-
}
|
1907
|
-
async sendTransaction(params) {
|
1908
|
-
const { txType, symbol } = params;
|
1909
|
-
const transaction = JSON.stringify(params, null, 2);
|
1891
|
+
async proveTransactions(params) {
|
1892
|
+
const transactions = [];
|
1893
|
+
for (const tx of params) {
|
1894
|
+
const transaction = JSON.stringify(tx, null, 2);
|
1895
|
+
transactions.push(transaction);
|
1896
|
+
}
|
1897
|
+
const { txType, symbol } = params[0];
|
1910
1898
|
const answer = await this.client.execute({
|
1911
1899
|
developer: "DFST",
|
1912
1900
|
repo: "token-launchpad",
|
1913
|
-
transactions
|
1914
|
-
task:
|
1915
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
1916
|
-
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}`
|
1901
|
+
transactions,
|
1902
|
+
task: "prove",
|
1903
|
+
args: JSON.stringify({ tokenAddress: params[0].tokenAddress }),
|
1904
|
+
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}${params.length > 1 ? ` (${params.length} txs)` : ""}`
|
1917
1905
|
});
|
1918
1906
|
const jobId = answer.jobId;
|
1919
1907
|
if (jobId === void 0)
|
@@ -1921,13 +1909,13 @@ var TokenAPI = class {
|
|
1921
1909
|
return jobId;
|
1922
1910
|
}
|
1923
1911
|
// Warning: this function will block the thread until the job is done and will print logs to the console
|
1924
|
-
// Do not use it in "use server" functions, use
|
1925
|
-
async
|
1912
|
+
// Do not use it in "use server" functions, use getResults instead
|
1913
|
+
async waitForJobResults(params) {
|
1926
1914
|
const deployResult = await this.client.waitForJobResult(params);
|
1927
1915
|
console.log("waitForJobResult result:", deployResult?.result?.result?.slice(0, 50));
|
1928
1916
|
return deployResult?.result?.result ?? "error";
|
1929
1917
|
}
|
1930
|
-
async
|
1918
|
+
async getResults(jobId) {
|
1931
1919
|
try {
|
1932
1920
|
const callResult = await this.client.jobResult({ jobId });
|
1933
1921
|
const jobStatus = typeof callResult?.result === "string" ? void 0 : callResult?.result?.jobStatus;
|
@@ -1954,16 +1942,13 @@ var TokenAPI = class {
|
|
1954
1942
|
jobStatus
|
1955
1943
|
};
|
1956
1944
|
try {
|
1957
|
-
const {
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
jobStatus
|
1965
|
-
};
|
1966
|
-
return { success, tx, hash, error, jobStatus };
|
1945
|
+
const { proofs } = JSON.parse(jobResult);
|
1946
|
+
const results = [];
|
1947
|
+
for (const proof of proofs) {
|
1948
|
+
const { success, tx, hash, error } = JSON.parse(jobResult);
|
1949
|
+
results.push({ success, tx, hash, error, jobStatus });
|
1950
|
+
}
|
1951
|
+
return { success: true, results, jobStatus };
|
1967
1952
|
} catch (e) {
|
1968
1953
|
return {
|
1969
1954
|
success: false,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { blockchain, Cloud } from "../../cloud/index.js";
|
1
|
+
import { blockchain, Cloud, JobStatus } from "../../cloud/index.js";
|
2
2
|
import { zkCloudWorkerClient } from "../api/api.js";
|
3
3
|
import { zkCloudWorker } from "../../cloud/worker/index.js";
|
4
4
|
import { TokenTransaction, DeployTransaction, JobResult } from "@minatokens/api";
|
@@ -9,14 +9,21 @@ export declare class TokenAPI {
|
|
9
9
|
zkcloudworker?: (cloud: Cloud) => Promise<zkCloudWorker>;
|
10
10
|
chain: blockchain;
|
11
11
|
});
|
12
|
-
|
13
|
-
|
14
|
-
waitForJobResult(params: {
|
12
|
+
proveTransactions(params: (TokenTransaction | DeployTransaction)[]): Promise<string | undefined>;
|
13
|
+
waitForJobResults(params: {
|
15
14
|
jobId: string;
|
16
15
|
maxAttempts?: number;
|
17
16
|
interval?: number;
|
18
17
|
maxErrors?: number;
|
19
18
|
printLogs?: boolean;
|
20
|
-
}): Promise<string | undefined>;
|
21
|
-
|
19
|
+
}): Promise<(string | undefined)[]>;
|
20
|
+
getResults(jobId: string): Promise<{
|
21
|
+
success: true;
|
22
|
+
results?: JobResult[];
|
23
|
+
jobStatus?: JobStatus;
|
24
|
+
} | {
|
25
|
+
success: false;
|
26
|
+
error?: string;
|
27
|
+
jobStatus?: JobStatus;
|
28
|
+
}>;
|
22
29
|
}
|
@@ -10,32 +10,20 @@ export class TokenAPI {
|
|
10
10
|
zkcloudworker,
|
11
11
|
});
|
12
12
|
}
|
13
|
-
async
|
14
|
-
const
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
task: "deploy",
|
21
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
22
|
-
metadata: `deploy token ${symbol}`,
|
23
|
-
});
|
24
|
-
const jobId = answer.jobId;
|
25
|
-
if (jobId === undefined)
|
26
|
-
console.error("Deploy Job ID is undefined", { answer, symbol });
|
27
|
-
return jobId;
|
28
|
-
}
|
29
|
-
async sendTransaction(params) {
|
30
|
-
const { txType, symbol } = params;
|
31
|
-
const transaction = JSON.stringify(params, null, 2);
|
13
|
+
async proveTransactions(params) {
|
14
|
+
const transactions = [];
|
15
|
+
for (const tx of params) {
|
16
|
+
const transaction = JSON.stringify(tx, null, 2);
|
17
|
+
transactions.push(transaction);
|
18
|
+
}
|
19
|
+
const { txType, symbol } = params[0];
|
32
20
|
const answer = await this.client.execute({
|
33
21
|
developer: "DFST",
|
34
22
|
repo: "token-launchpad",
|
35
|
-
transactions
|
36
|
-
task:
|
37
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
38
|
-
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}`,
|
23
|
+
transactions,
|
24
|
+
task: "prove",
|
25
|
+
args: JSON.stringify({ tokenAddress: params[0].tokenAddress }),
|
26
|
+
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}${params.length > 1 ? ` (${params.length} txs)` : ""}`,
|
39
27
|
});
|
40
28
|
const jobId = answer.jobId;
|
41
29
|
if (jobId === undefined)
|
@@ -43,13 +31,13 @@ export class TokenAPI {
|
|
43
31
|
return jobId;
|
44
32
|
}
|
45
33
|
// Warning: this function will block the thread until the job is done and will print logs to the console
|
46
|
-
// Do not use it in "use server" functions, use
|
47
|
-
async
|
34
|
+
// Do not use it in "use server" functions, use getResults instead
|
35
|
+
async waitForJobResults(params) {
|
48
36
|
const deployResult = await this.client.waitForJobResult(params);
|
49
37
|
console.log("waitForJobResult result:", deployResult?.result?.result?.slice(0, 50));
|
50
38
|
return deployResult?.result?.result ?? "error";
|
51
39
|
}
|
52
|
-
async
|
40
|
+
async getResults(jobId) {
|
53
41
|
try {
|
54
42
|
const callResult = await this.client.jobResult({ jobId });
|
55
43
|
// TODO: filter the repo and developer
|
@@ -79,16 +67,21 @@ export class TokenAPI {
|
|
79
67
|
jobStatus,
|
80
68
|
};
|
81
69
|
try {
|
82
|
-
const {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
70
|
+
const { proofs } = JSON.parse(jobResult);
|
71
|
+
const results = [];
|
72
|
+
for (const proof of proofs) {
|
73
|
+
const { success, tx, hash, error } = JSON.parse(jobResult);
|
74
|
+
// if (success === undefined)
|
75
|
+
// return {
|
76
|
+
// success: false,
|
77
|
+
// tx,
|
78
|
+
// hash,
|
79
|
+
// error,
|
80
|
+
// jobStatus,
|
81
|
+
// };
|
82
|
+
results.push({ success, tx, hash, error, jobStatus });
|
83
|
+
}
|
84
|
+
return { success: true, results, jobStatus };
|
92
85
|
}
|
93
86
|
catch (e) {
|
94
87
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/mina/token/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQpD,MAAM,OAAO,QAAQ;IAGnB,YAAY,MAIX;QACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAC7C,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE3D,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,CAAC;YACpC,GAAG;YACH,KAAK;YACL,aAAa;SACd,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/mina/token/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQpD,MAAM,OAAO,QAAQ;IAGnB,YAAY,MAIX;QACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAC7C,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE3D,IAA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I,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBACzC,MAAM,OAAO,GAAgB,EAAE,CAAC;gBAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;oBAC3D,6BAA6B;oBAC7B,aAAa;oBACb,sBAAsB;oBACtB,UAAU;oBACV,YAAY;oBACZ,aAAa;oBACb,iBAAiB;oBACjB,SAAS;oBACT,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;gBACxD,CAAC;gBACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;YAC/C,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,6BAA6B,SAAS,IAAI,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE;oBACnE,SAAS;iBACV,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,6BAA6B,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE;gBACtD,SAAS,EAAE,SAAS;aACrB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { blockchain, Cloud } from "../../cloud/index.js";
|
1
|
+
import { blockchain, Cloud, JobStatus } from "../../cloud/index.js";
|
2
2
|
import { zkCloudWorkerClient } from "../api/api.js";
|
3
3
|
import { zkCloudWorker } from "../../cloud/worker/index.js";
|
4
4
|
import { TokenTransaction, DeployTransaction, JobResult } from "@minatokens/api";
|
@@ -9,14 +9,21 @@ export declare class TokenAPI {
|
|
9
9
|
zkcloudworker?: (cloud: Cloud) => Promise<zkCloudWorker>;
|
10
10
|
chain: blockchain;
|
11
11
|
});
|
12
|
-
|
13
|
-
|
14
|
-
waitForJobResult(params: {
|
12
|
+
proveTransactions(params: (TokenTransaction | DeployTransaction)[]): Promise<string | undefined>;
|
13
|
+
waitForJobResults(params: {
|
15
14
|
jobId: string;
|
16
15
|
maxAttempts?: number;
|
17
16
|
interval?: number;
|
18
17
|
maxErrors?: number;
|
19
18
|
printLogs?: boolean;
|
20
|
-
}): Promise<string | undefined>;
|
21
|
-
|
19
|
+
}): Promise<(string | undefined)[]>;
|
20
|
+
getResults(jobId: string): Promise<{
|
21
|
+
success: true;
|
22
|
+
results?: JobResult[];
|
23
|
+
jobStatus?: JobStatus;
|
24
|
+
} | {
|
25
|
+
success: false;
|
26
|
+
error?: string;
|
27
|
+
jobStatus?: JobStatus;
|
28
|
+
}>;
|
22
29
|
}
|
@@ -10,32 +10,20 @@ export class TokenAPI {
|
|
10
10
|
zkcloudworker,
|
11
11
|
});
|
12
12
|
}
|
13
|
-
async
|
14
|
-
const
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
task: "deploy",
|
21
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
22
|
-
metadata: `deploy token ${symbol}`,
|
23
|
-
});
|
24
|
-
const jobId = answer.jobId;
|
25
|
-
if (jobId === undefined)
|
26
|
-
console.error("Deploy Job ID is undefined", { answer, symbol });
|
27
|
-
return jobId;
|
28
|
-
}
|
29
|
-
async sendTransaction(params) {
|
30
|
-
const { txType, symbol } = params;
|
31
|
-
const transaction = JSON.stringify(params, null, 2);
|
13
|
+
async proveTransactions(params) {
|
14
|
+
const transactions = [];
|
15
|
+
for (const tx of params) {
|
16
|
+
const transaction = JSON.stringify(tx, null, 2);
|
17
|
+
transactions.push(transaction);
|
18
|
+
}
|
19
|
+
const { txType, symbol } = params[0];
|
32
20
|
const answer = await this.client.execute({
|
33
21
|
developer: "DFST",
|
34
22
|
repo: "token-launchpad",
|
35
|
-
transactions
|
36
|
-
task:
|
37
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
38
|
-
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}`,
|
23
|
+
transactions,
|
24
|
+
task: "prove",
|
25
|
+
args: JSON.stringify({ tokenAddress: params[0].tokenAddress }),
|
26
|
+
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}${params.length > 1 ? ` (${params.length} txs)` : ""}`,
|
39
27
|
});
|
40
28
|
const jobId = answer.jobId;
|
41
29
|
if (jobId === undefined)
|
@@ -43,13 +31,13 @@ export class TokenAPI {
|
|
43
31
|
return jobId;
|
44
32
|
}
|
45
33
|
// Warning: this function will block the thread until the job is done and will print logs to the console
|
46
|
-
// Do not use it in "use server" functions, use
|
47
|
-
async
|
34
|
+
// Do not use it in "use server" functions, use getResults instead
|
35
|
+
async waitForJobResults(params) {
|
48
36
|
const deployResult = await this.client.waitForJobResult(params);
|
49
37
|
console.log("waitForJobResult result:", deployResult?.result?.result?.slice(0, 50));
|
50
38
|
return deployResult?.result?.result ?? "error";
|
51
39
|
}
|
52
|
-
async
|
40
|
+
async getResults(jobId) {
|
53
41
|
try {
|
54
42
|
const callResult = await this.client.jobResult({ jobId });
|
55
43
|
// TODO: filter the repo and developer
|
@@ -79,16 +67,21 @@ export class TokenAPI {
|
|
79
67
|
jobStatus,
|
80
68
|
};
|
81
69
|
try {
|
82
|
-
const {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
70
|
+
const { proofs } = JSON.parse(jobResult);
|
71
|
+
const results = [];
|
72
|
+
for (const proof of proofs) {
|
73
|
+
const { success, tx, hash, error } = JSON.parse(jobResult);
|
74
|
+
// if (success === undefined)
|
75
|
+
// return {
|
76
|
+
// success: false,
|
77
|
+
// tx,
|
78
|
+
// hash,
|
79
|
+
// error,
|
80
|
+
// jobStatus,
|
81
|
+
// };
|
82
|
+
results.push({ success, tx, hash, error, jobStatus });
|
83
|
+
}
|
84
|
+
return { success: true, results, jobStatus };
|
92
85
|
}
|
93
86
|
catch (e) {
|
94
87
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/mina/token/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQpD,MAAM,OAAO,QAAQ;IAGnB,YAAY,MAIX;QACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAC7C,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE3D,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,CAAC;YACpC,GAAG;YACH,KAAK;YACL,aAAa;SACd,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/mina/token/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQpD,MAAM,OAAO,QAAQ;IAGnB,YAAY,MAIX;QACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAC7C,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE3D,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,CAAC;YACpC,GAAG;YACH,KAAK;YACL,aAAa;SACd,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,MAAgD;QAEhD,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;YACxB,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,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B;oBACtB,UAAU;oBACV,YAAY;oBACZ,aAAa;oBACb,iBAAiB;oBACjB,SAAS;oBACT,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;gBACxD,CAAC;gBACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;YAC/C,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,6BAA6B,SAAS,IAAI,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE;oBACnE,SAAS;iBACV,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,6BAA6B,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE;gBACtD,SAAS,EAAE,SAAS;aACrB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "zkcloudworker",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.21.0",
|
4
4
|
"type": "module",
|
5
5
|
"description": "zkCloudWorker library",
|
6
6
|
"author": "zkCloudWorker",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"node": ">=20.0.0"
|
50
50
|
},
|
51
51
|
"dependencies": {
|
52
|
-
"@minatokens/api": "^0.
|
52
|
+
"@minatokens/api": "^0.3.3",
|
53
53
|
"chalk": "^4.1.2"
|
54
54
|
},
|
55
55
|
"peerDependencies": {
|
package/src/mina/token/api.ts
CHANGED
@@ -25,40 +25,25 @@ export class TokenAPI {
|
|
25
25
|
});
|
26
26
|
}
|
27
27
|
|
28
|
-
async
|
29
|
-
params: DeployTransaction
|
28
|
+
async proveTransactions(
|
29
|
+
params: (TokenTransaction | DeployTransaction)[]
|
30
30
|
): Promise<string | undefined> {
|
31
|
-
const
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
repo: "token-launchpad",
|
38
|
-
transactions: [transaction],
|
39
|
-
task: "deploy",
|
40
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
41
|
-
metadata: `deploy token ${symbol}`,
|
42
|
-
});
|
43
|
-
|
44
|
-
const jobId = answer.jobId;
|
45
|
-
if (jobId === undefined)
|
46
|
-
console.error("Deploy Job ID is undefined", { answer, symbol });
|
47
|
-
return jobId;
|
48
|
-
}
|
49
|
-
|
50
|
-
async sendTransaction(params: TokenTransaction): Promise<string | undefined> {
|
51
|
-
const { txType, symbol } = params;
|
52
|
-
|
53
|
-
const transaction = JSON.stringify(params, null, 2);
|
31
|
+
const transactions: string[] = [];
|
32
|
+
for (const tx of params) {
|
33
|
+
const transaction = JSON.stringify(tx, null, 2);
|
34
|
+
transactions.push(transaction);
|
35
|
+
}
|
36
|
+
const { txType, symbol } = params[0];
|
54
37
|
|
55
38
|
const answer = await this.client.execute({
|
56
39
|
developer: "DFST",
|
57
40
|
repo: "token-launchpad",
|
58
|
-
transactions
|
59
|
-
task:
|
60
|
-
args: JSON.stringify({ tokenAddress: params.tokenAddress }),
|
61
|
-
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}
|
41
|
+
transactions,
|
42
|
+
task: "prove",
|
43
|
+
args: JSON.stringify({ tokenAddress: params[0].tokenAddress }),
|
44
|
+
metadata: `${txType} token${symbol ? ` ${symbol}` : ""}${
|
45
|
+
params.length > 1 ? ` (${params.length} txs)` : ""
|
46
|
+
}`,
|
62
47
|
});
|
63
48
|
const jobId = answer.jobId;
|
64
49
|
if (jobId === undefined)
|
@@ -67,14 +52,14 @@ export class TokenAPI {
|
|
67
52
|
}
|
68
53
|
|
69
54
|
// Warning: this function will block the thread until the job is done and will print logs to the console
|
70
|
-
// Do not use it in "use server" functions, use
|
71
|
-
async
|
55
|
+
// Do not use it in "use server" functions, use getResults instead
|
56
|
+
async waitForJobResults(params: {
|
72
57
|
jobId: string;
|
73
58
|
maxAttempts?: number;
|
74
59
|
interval?: number;
|
75
60
|
maxErrors?: number;
|
76
61
|
printLogs?: boolean;
|
77
|
-
}): Promise<string | undefined> {
|
62
|
+
}): Promise<(string | undefined)[]> {
|
78
63
|
const deployResult = await this.client.waitForJobResult(params);
|
79
64
|
console.log(
|
80
65
|
"waitForJobResult result:",
|
@@ -83,7 +68,12 @@ export class TokenAPI {
|
|
83
68
|
return deployResult?.result?.result ?? "error";
|
84
69
|
}
|
85
70
|
|
86
|
-
async
|
71
|
+
async getResults(
|
72
|
+
jobId: string
|
73
|
+
): Promise<
|
74
|
+
| { success: true; results?: JobResult[]; jobStatus?: JobStatus }
|
75
|
+
| { success: false; error?: string; jobStatus?: JobStatus }
|
76
|
+
> {
|
87
77
|
try {
|
88
78
|
const callResult = await this.client.jobResult({ jobId });
|
89
79
|
|
@@ -116,16 +106,21 @@ export class TokenAPI {
|
|
116
106
|
};
|
117
107
|
|
118
108
|
try {
|
119
|
-
const {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
109
|
+
const { proofs } = JSON.parse(jobResult);
|
110
|
+
const results: JobResult[] = [];
|
111
|
+
for (const proof of proofs) {
|
112
|
+
const { success, tx, hash, error } = JSON.parse(jobResult);
|
113
|
+
// if (success === undefined)
|
114
|
+
// return {
|
115
|
+
// success: false,
|
116
|
+
// tx,
|
117
|
+
// hash,
|
118
|
+
// error,
|
119
|
+
// jobStatus,
|
120
|
+
// };
|
121
|
+
results.push({ success, tx, hash, error, jobStatus });
|
122
|
+
}
|
123
|
+
return { success: true, results, jobStatus };
|
129
124
|
} catch (e: any) {
|
130
125
|
return {
|
131
126
|
success: false,
|