@tari-project/tari-extension-query-builder 0.0.8 → 0.0.10
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/README.md +210 -1
- package/dist/codegen/BuilderCodegen.d.ts.map +1 -1
- package/dist/codegen/sample.d.ts +3 -2
- package/dist/codegen/sample.d.ts.map +1 -1
- package/dist/components/query-builder/query-builder.d.ts +2 -2
- package/dist/components/query-builder/query-builder.d.ts.map +1 -1
- package/dist/execute/ExecutionPlanner.d.ts +3 -2
- package/dist/execute/ExecutionPlanner.d.ts.map +1 -1
- package/dist/tari-extension-query-builder.css +1 -1
- package/dist/tari-extension-query-builder.es.js +75914 -76109
- package/dist/tari-extension-query-builder.umd.js +149 -149
- package/package.json +15 -15
- package/src/codegen/BuilderCodegen.ts +51 -40
- package/src/codegen/sample.ts +9 -21
- package/src/components/query-builder/query-builder.tsx +34 -10
- package/src/execute/ExecutionPlanner.ts +8 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tari-extension-query-builder",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/tari-extension-query-builder.umd.js",
|
|
7
7
|
"module": "dist/tari-extension-query-builder.es.js",
|
|
@@ -37,43 +37,43 @@
|
|
|
37
37
|
"@radix-ui/react-separator": "^1.1.2",
|
|
38
38
|
"@radix-ui/react-slot": "^1.1.2",
|
|
39
39
|
"@radix-ui/react-tooltip": "^1.1.8",
|
|
40
|
-
"@tari-project/tarijs-all": "^0.
|
|
40
|
+
"@tari-project/tarijs-all": "^0.10.1",
|
|
41
41
|
"@xyflow/react": "^12.4.4",
|
|
42
42
|
"class-variance-authority": "^0.7.1",
|
|
43
43
|
"clsx": "^2.1.1",
|
|
44
44
|
"lucide-react": "^0.479.0",
|
|
45
45
|
"next-themes": "^0.4.6",
|
|
46
|
-
"sonner": "^2.0.
|
|
47
|
-
"tailwind-merge": "^3.
|
|
46
|
+
"sonner": "^2.0.5",
|
|
47
|
+
"tailwind-merge": "^3.3.1",
|
|
48
48
|
"tailwindcss-animate": "^1.0.7",
|
|
49
49
|
"uuid": "^11.1.0",
|
|
50
|
-
"zod": "^3.
|
|
51
|
-
"@tari-project/tari-extension-common": "^0.0.
|
|
50
|
+
"zod": "^3.25.67",
|
|
51
|
+
"@tari-project/tari-extension-common": "^0.0.10"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@eslint/js": "^9.21.0",
|
|
55
55
|
"@tailwindcss/vite": "^4.0.12",
|
|
56
|
-
"@tari-project/typescript-bindings": "^1.
|
|
57
|
-
"@types/node": "^
|
|
58
|
-
"@types/react": "^19.
|
|
59
|
-
"@types/react-dom": "^19.
|
|
60
|
-
"@vitejs/plugin-react": "^4.
|
|
56
|
+
"@tari-project/typescript-bindings": "^1.11.1",
|
|
57
|
+
"@types/node": "^24.0.8",
|
|
58
|
+
"@types/react": "^19.1.8",
|
|
59
|
+
"@types/react-dom": "^19.1.6",
|
|
60
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
61
61
|
"autoprefixer": "^10.4.21",
|
|
62
62
|
"eslint": "^9.21.0",
|
|
63
63
|
"eslint-plugin-react": "^7.37.4",
|
|
64
64
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
65
65
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
66
|
-
"globals": "^
|
|
66
|
+
"globals": "^16.3.0",
|
|
67
67
|
"postcss": "^8.5.3",
|
|
68
|
-
"prettier": "^3.
|
|
68
|
+
"prettier": "^3.6.2",
|
|
69
69
|
"react": "^19.0.0",
|
|
70
70
|
"react-dom": "^19.0.0",
|
|
71
71
|
"tailwindcss": "^4.0.12",
|
|
72
72
|
"typescript": "^5.7.3",
|
|
73
73
|
"typescript-eslint": "^8.25.0",
|
|
74
|
-
"vite": "^
|
|
74
|
+
"vite": "^7.0.0",
|
|
75
75
|
"vite-plugin-dts": "^4.5.3",
|
|
76
|
-
"vitest": "^3.
|
|
76
|
+
"vitest": "^3.2.4",
|
|
77
77
|
"zustand": "^5.0.3"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
@@ -50,19 +50,28 @@ export class BuilderCodegen {
|
|
|
50
50
|
undefined,
|
|
51
51
|
factory.createNamedImports([
|
|
52
52
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("buildTransactionRequest")),
|
|
53
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier("fromWorkspace")),
|
|
54
53
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("Network")),
|
|
55
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ReqSubstate")),
|
|
56
54
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("submitAndWaitForTransaction")),
|
|
57
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier("SubmitTxResult")),
|
|
58
55
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("TariSigner")),
|
|
59
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier("Transaction")),
|
|
60
56
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("TransactionBuilder")),
|
|
61
57
|
]),
|
|
62
58
|
),
|
|
63
59
|
factory.createStringLiteral("@tari-project/tarijs-all"),
|
|
64
60
|
undefined,
|
|
65
61
|
),
|
|
62
|
+
factory.createImportDeclaration(
|
|
63
|
+
undefined,
|
|
64
|
+
factory.createImportClause(
|
|
65
|
+
false,
|
|
66
|
+
undefined,
|
|
67
|
+
factory.createNamedImports([
|
|
68
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier("TransactionResult")),
|
|
69
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier("UnsignedTransactionV1")),
|
|
70
|
+
]),
|
|
71
|
+
),
|
|
72
|
+
factory.createStringLiteral("@tari-project/typescript-bindings"),
|
|
73
|
+
undefined,
|
|
74
|
+
),
|
|
66
75
|
...addEmptyCommentToFirstNode(buildInterfaces(this.details.context)),
|
|
67
76
|
...addEmptyCommentToFirstNode(buildInputVariables(this.details.context)),
|
|
68
77
|
addEmptyComment(
|
|
@@ -71,8 +80,18 @@ export class BuilderCodegen {
|
|
|
71
80
|
undefined,
|
|
72
81
|
factory.createIdentifier("buildTransaction"),
|
|
73
82
|
undefined,
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
[
|
|
84
|
+
factory.createParameterDeclaration(
|
|
85
|
+
undefined,
|
|
86
|
+
undefined,
|
|
87
|
+
factory.createIdentifier("network"),
|
|
88
|
+
undefined,
|
|
89
|
+
factory.createTypeReferenceNode(factory.createIdentifier("Network"), undefined),
|
|
90
|
+
undefined,
|
|
91
|
+
),
|
|
92
|
+
...buildInputArgs(this.details.context),
|
|
93
|
+
],
|
|
94
|
+
factory.createTypeReferenceNode(factory.createIdentifier("UnsignedTransactionV1"), undefined),
|
|
76
95
|
factory.createBlock(
|
|
77
96
|
[
|
|
78
97
|
factory.createVariableStatement(
|
|
@@ -83,7 +102,9 @@ export class BuilderCodegen {
|
|
|
83
102
|
factory.createIdentifier("builder"),
|
|
84
103
|
undefined,
|
|
85
104
|
undefined,
|
|
86
|
-
factory.createNewExpression(factory.createIdentifier("TransactionBuilder"), undefined, [
|
|
105
|
+
factory.createNewExpression(factory.createIdentifier("TransactionBuilder"), undefined, [
|
|
106
|
+
factory.createIdentifier("network"),
|
|
107
|
+
]),
|
|
87
108
|
),
|
|
88
109
|
],
|
|
89
110
|
ts.NodeFlags.Const,
|
|
@@ -94,7 +115,7 @@ export class BuilderCodegen {
|
|
|
94
115
|
factory.createCallExpression(
|
|
95
116
|
factory.createPropertyAccessExpression(
|
|
96
117
|
factory.createIdentifier("builder"),
|
|
97
|
-
factory.createIdentifier("
|
|
118
|
+
factory.createIdentifier("buildUnsignedTransaction"),
|
|
98
119
|
),
|
|
99
120
|
undefined,
|
|
100
121
|
[],
|
|
@@ -136,27 +157,10 @@ export class BuilderCodegen {
|
|
|
136
157
|
factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
|
|
137
158
|
undefined,
|
|
138
159
|
),
|
|
139
|
-
|
|
140
|
-
undefined,
|
|
141
|
-
undefined,
|
|
142
|
-
factory.createIdentifier("requiredSubstates"),
|
|
143
|
-
undefined,
|
|
144
|
-
factory.createArrayTypeNode(
|
|
145
|
-
factory.createTypeReferenceNode(factory.createIdentifier("ReqSubstate"), undefined),
|
|
146
|
-
),
|
|
147
|
-
factory.createArrayLiteralExpression([], false),
|
|
148
|
-
),
|
|
149
|
-
factory.createParameterDeclaration(
|
|
150
|
-
undefined,
|
|
151
|
-
undefined,
|
|
152
|
-
factory.createIdentifier("isDryRun"),
|
|
153
|
-
undefined,
|
|
154
|
-
undefined,
|
|
155
|
-
factory.createFalse(),
|
|
156
|
-
),
|
|
160
|
+
...buildInputArgs(this.details.context),
|
|
157
161
|
],
|
|
158
162
|
factory.createTypeReferenceNode(factory.createIdentifier("Promise"), [
|
|
159
|
-
factory.createTypeReferenceNode(factory.createIdentifier("
|
|
163
|
+
factory.createTypeReferenceNode(factory.createIdentifier("TransactionResult"), undefined),
|
|
160
164
|
]),
|
|
161
165
|
factory.createBlock(
|
|
162
166
|
[
|
|
@@ -169,16 +173,11 @@ export class BuilderCodegen {
|
|
|
169
173
|
undefined,
|
|
170
174
|
undefined,
|
|
171
175
|
factory.createCallExpression(factory.createIdentifier("buildTransactionRequest"), undefined, [
|
|
172
|
-
factory.createCallExpression(
|
|
173
|
-
factory.createIdentifier("
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
),
|
|
176
|
+
factory.createCallExpression(factory.createIdentifier("buildTransaction"), undefined, [
|
|
177
|
+
factory.createIdentifier("network"),
|
|
178
|
+
...Object.keys(this.details.context.inputParams).map((key) => factory.createIdentifier(key)),
|
|
179
|
+
]),
|
|
177
180
|
factory.createIdentifier("accountId"),
|
|
178
|
-
factory.createIdentifier("requiredSubstates"),
|
|
179
|
-
factory.createIdentifier("undefined"),
|
|
180
|
-
factory.createIdentifier("isDryRun"),
|
|
181
|
-
factory.createIdentifier("network"),
|
|
182
181
|
]),
|
|
183
182
|
),
|
|
184
183
|
],
|
|
@@ -205,7 +204,12 @@ export class BuilderCodegen {
|
|
|
205
204
|
ts.NodeFlags.Const,
|
|
206
205
|
),
|
|
207
206
|
),
|
|
208
|
-
factory.createReturnStatement(
|
|
207
|
+
factory.createReturnStatement(
|
|
208
|
+
factory.createPropertyAccessExpression(
|
|
209
|
+
factory.createIdentifier("txResult"),
|
|
210
|
+
factory.createIdentifier("result"),
|
|
211
|
+
),
|
|
212
|
+
),
|
|
209
213
|
],
|
|
210
214
|
true,
|
|
211
215
|
),
|
|
@@ -254,9 +258,16 @@ export class BuilderCodegen {
|
|
|
254
258
|
private createArgValueAst(arg: ArgValue): ts.Expression {
|
|
255
259
|
switch (arg.type) {
|
|
256
260
|
case "workspace":
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
// Use { Workspace: "name" } instead of fromWorkspace()
|
|
262
|
+
return factory.createObjectLiteralExpression(
|
|
263
|
+
[
|
|
264
|
+
factory.createPropertyAssignment(
|
|
265
|
+
factory.createIdentifier("Workspace"),
|
|
266
|
+
factory.createStringLiteral(arg.value),
|
|
267
|
+
),
|
|
268
|
+
],
|
|
269
|
+
false,
|
|
270
|
+
);
|
|
260
271
|
case "input":
|
|
261
272
|
return factory.createPropertyAccessExpression(
|
|
262
273
|
factory.createIdentifier(arg.reference.name),
|
package/src/codegen/sample.ts
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildTransactionRequest,
|
|
3
|
-
fromWorkspace,
|
|
4
3
|
Network,
|
|
5
|
-
ReqSubstate,
|
|
6
4
|
submitAndWaitForTransaction,
|
|
7
|
-
SubmitTxResult,
|
|
8
5
|
TariSigner,
|
|
9
|
-
Transaction,
|
|
10
6
|
TransactionBuilder,
|
|
11
7
|
} from "@tari-project/tarijs-all";
|
|
8
|
+
import { TransactionResult, UnsignedTransactionV1 } from "@tari-project/typescript-bindings";
|
|
12
9
|
|
|
13
|
-
function buildTransaction():
|
|
14
|
-
const builder = new TransactionBuilder();
|
|
10
|
+
function buildTransaction(network: Network): UnsignedTransactionV1 {
|
|
11
|
+
const builder = new TransactionBuilder(network);
|
|
15
12
|
builder.feeTransactionPayFromComponent("ACCOUNT_ADDRESS", "12345");
|
|
16
13
|
builder.callMethod(
|
|
17
14
|
{
|
|
18
15
|
componentAddress: "COMPONENT_ADDRESS",
|
|
19
16
|
methodName: "method_name",
|
|
20
17
|
},
|
|
21
|
-
["a1", 2,
|
|
18
|
+
["a1", 2, { Workspace: "a2" }],
|
|
22
19
|
);
|
|
23
20
|
builder.saveVar("b3");
|
|
24
21
|
builder.callFunction(
|
|
@@ -26,7 +23,7 @@ function buildTransaction(): Transaction {
|
|
|
26
23
|
templateAddress: "TEMPLATE_ADDRESS",
|
|
27
24
|
functionName: "function_name",
|
|
28
25
|
},
|
|
29
|
-
["b2", 3,
|
|
26
|
+
["b2", 3, { Workspace: "b3" }],
|
|
30
27
|
);
|
|
31
28
|
builder.addInstruction({
|
|
32
29
|
EmitLog: {
|
|
@@ -34,25 +31,16 @@ function buildTransaction(): Transaction {
|
|
|
34
31
|
message: "Hello, world!",
|
|
35
32
|
},
|
|
36
33
|
});
|
|
37
|
-
return builder.
|
|
34
|
+
return builder.buildUnsignedTransaction();
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
export async function executeTransaction(
|
|
41
38
|
signer: TariSigner,
|
|
42
39
|
network: Network,
|
|
43
40
|
accountId: number,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
): Promise<SubmitTxResult> {
|
|
47
|
-
const submitTransactionRequest = buildTransactionRequest(
|
|
48
|
-
buildTransaction(),
|
|
49
|
-
accountId,
|
|
50
|
-
requiredSubstates,
|
|
51
|
-
undefined,
|
|
52
|
-
isDryRun,
|
|
53
|
-
network,
|
|
54
|
-
);
|
|
41
|
+
): Promise<TransactionResult> {
|
|
42
|
+
const submitTransactionRequest = buildTransactionRequest(buildTransaction(network), accountId);
|
|
55
43
|
|
|
56
44
|
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
57
|
-
return txResult;
|
|
45
|
+
return txResult.result;
|
|
58
46
|
}
|
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
Panel,
|
|
9
9
|
MiniMap,
|
|
10
10
|
} from "@xyflow/react";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
CALL_NODE_DRAG_DROP_TYPE,
|
|
13
|
+
GeneratedCodeType,
|
|
14
|
+
TariNetwork,
|
|
15
|
+
TransactionProps,
|
|
16
|
+
} from "@tari-project/tari-extension-common";
|
|
12
17
|
import useStore from "../../store/store";
|
|
13
18
|
import { useShallow } from "zustand/shallow";
|
|
14
19
|
import { InputConnectionType, GenericNodeType, NodeType, QueryBuilderState } from "@/store/types";
|
|
@@ -57,13 +62,14 @@ import {
|
|
|
57
62
|
AlertDialogHeader,
|
|
58
63
|
AlertDialogTitle,
|
|
59
64
|
} from "../ui/alert-dialog";
|
|
60
|
-
import { Amount,
|
|
65
|
+
import { Amount, Network } from "@tari-project/tarijs-all";
|
|
61
66
|
import { MissingDataError } from "@/execute/MissingDataError";
|
|
62
67
|
import { toast } from "sonner";
|
|
63
68
|
import { LoadingSpinner } from "../ui/loading-spinner";
|
|
64
69
|
import { BuilderCodegen } from "@/codegen/BuilderCodegen";
|
|
65
70
|
import { getNextAvailable } from "@/lib/get-next-available";
|
|
66
71
|
import { ALLOCATE_COMPONENT_ADDRESS_RESULT, ALLOCATE_RESOURCE_ADDRESS_RESULT } from "./nodes/generic-node.types";
|
|
72
|
+
import { UnsignedTransactionV1 } from "@tari-project/typescript-bindings";
|
|
67
73
|
|
|
68
74
|
export type Theme = "dark" | "light";
|
|
69
75
|
|
|
@@ -86,7 +92,7 @@ export interface QueryBuilderProps {
|
|
|
86
92
|
theme: Theme;
|
|
87
93
|
readOnly?: boolean;
|
|
88
94
|
getTransactionProps?: () => Promise<TransactionProps>;
|
|
89
|
-
executeTransaction?: (transaction:
|
|
95
|
+
executeTransaction?: (transaction: UnsignedTransactionV1) => Promise<void>;
|
|
90
96
|
showGeneratedCode?: (code: string, type: GeneratedCodeType) => Promise<void>;
|
|
91
97
|
}
|
|
92
98
|
|
|
@@ -150,8 +156,9 @@ function Flow({
|
|
|
150
156
|
const json = JSON.parse(data) as TariFlowNodeDetails;
|
|
151
157
|
const reader = new TemplateReader(json.template, json.templateAddress);
|
|
152
158
|
|
|
153
|
-
const
|
|
154
|
-
const
|
|
159
|
+
const reactflowBounds = reactflowRef.current?.getBoundingClientRect();
|
|
160
|
+
const flowX = (event.clientX - (reactflowBounds?.left ?? 0) - viewport.x) / viewport.zoom;
|
|
161
|
+
const flowY = (event.clientY - (reactflowBounds?.top ?? 0) - viewport.y) / viewport.zoom;
|
|
155
162
|
|
|
156
163
|
const nodeData = reader.getGenericNode(json.functionName);
|
|
157
164
|
if (nodeData) {
|
|
@@ -167,9 +174,9 @@ function Flow({
|
|
|
167
174
|
const planner = new ExecutionPlanner(nodes, edges);
|
|
168
175
|
try {
|
|
169
176
|
const executionOrder = planner.getExecutionOrder();
|
|
170
|
-
const { accountAddress, fee } = await getTransactionProps();
|
|
177
|
+
const { network, accountAddress, fee } = await getTransactionProps();
|
|
171
178
|
const details = planner.buildTransactionDescription(executionOrder, accountAddress, new Amount(fee));
|
|
172
|
-
return { planner, details };
|
|
179
|
+
return { network, planner, details };
|
|
173
180
|
} catch (e) {
|
|
174
181
|
let errorMessage = "Failed to determine execution order";
|
|
175
182
|
if (e instanceof AmbiguousOrderError) {
|
|
@@ -205,6 +212,23 @@ function Flow({
|
|
|
205
212
|
[nodes, edges, getNodeById],
|
|
206
213
|
);
|
|
207
214
|
|
|
215
|
+
const getNetwork = (network: TariNetwork) => {
|
|
216
|
+
switch (network) {
|
|
217
|
+
case TariNetwork.MainNet:
|
|
218
|
+
return Network.MainNet;
|
|
219
|
+
case TariNetwork.StageNet:
|
|
220
|
+
return Network.StageNet;
|
|
221
|
+
case TariNetwork.NextNet:
|
|
222
|
+
return Network.NextNet;
|
|
223
|
+
case TariNetwork.LocalNet:
|
|
224
|
+
return Network.LocalNet;
|
|
225
|
+
case TariNetwork.Igor:
|
|
226
|
+
return Network.Igor;
|
|
227
|
+
case TariNetwork.Esmeralda:
|
|
228
|
+
return Network.Esmeralda;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
208
232
|
const handleExecute = useCallback(
|
|
209
233
|
async (dryRun: boolean) => {
|
|
210
234
|
if (!getTransactionProps || !executeTransaction) {
|
|
@@ -213,9 +237,9 @@ function Flow({
|
|
|
213
237
|
|
|
214
238
|
setLoading(true);
|
|
215
239
|
try {
|
|
216
|
-
const { planner, details } = await buildTransactionDescriptions(getTransactionProps);
|
|
217
|
-
const transaction = planner.buildTransaction(details);
|
|
218
|
-
await executeTransaction(transaction
|
|
240
|
+
const { network, planner, details } = await buildTransactionDescriptions(getTransactionProps);
|
|
241
|
+
const transaction = planner.buildTransaction(getNetwork(network), details, dryRun);
|
|
242
|
+
await executeTransaction(transaction);
|
|
219
243
|
toast.success("Transaction executed");
|
|
220
244
|
} catch (e) {
|
|
221
245
|
if (e instanceof Error) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NODE_ENTRY, NODE_EXIT } from "@/components/query-builder/nodes/generic-node.types";
|
|
2
2
|
import { CustomNode, GenericNode, GenericNodeType, InputParamsNode, NodeType } from "@/store/types";
|
|
3
|
-
import { LogLevel, Type } from "@tari-project/typescript-bindings";
|
|
3
|
+
import { LogLevel, Type, UnsignedTransactionV1 } from "@tari-project/typescript-bindings";
|
|
4
4
|
import { Edge } from "@xyflow/react";
|
|
5
5
|
import { CycleDetectedError } from "./CycleDetectedError";
|
|
6
6
|
import { AmbiguousOrderError } from "./AmbiguousOrderError";
|
|
7
7
|
import { MissingDataError } from "./MissingDataError";
|
|
8
|
-
import { Amount,
|
|
8
|
+
import { Amount, Network, TransactionBuilder } from "@tari-project/tarijs-all";
|
|
9
9
|
import { COMPONENT_ADDRESS_NAME } from "@/query-builder/template-reader";
|
|
10
10
|
import {
|
|
11
11
|
ArgValue,
|
|
@@ -382,8 +382,8 @@ export class ExecutionPlanner {
|
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
public buildTransaction(details: TransactionDetails):
|
|
386
|
-
const builder = new TransactionBuilder();
|
|
385
|
+
public buildTransaction(network: Network, details: TransactionDetails, dryRun: boolean): UnsignedTransactionV1 {
|
|
386
|
+
const builder = new TransactionBuilder(network);
|
|
387
387
|
for (const description of details.descriptions) {
|
|
388
388
|
switch (description.type) {
|
|
389
389
|
case "feeTransactionPayFromComponent":
|
|
@@ -424,12 +424,14 @@ export class ExecutionPlanner {
|
|
|
424
424
|
break;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
|
|
427
|
+
const result = builder.buildUnsignedTransaction();
|
|
428
|
+
result.dry_run = dryRun;
|
|
429
|
+
return result;
|
|
428
430
|
}
|
|
429
431
|
}
|
|
430
432
|
|
|
431
433
|
function unwrapArgValue(arg: ArgValue): unknown {
|
|
432
|
-
return arg.type === "workspace" ?
|
|
434
|
+
return arg.type === "workspace" ? { Workspace: arg.value } : arg.value;
|
|
433
435
|
}
|
|
434
436
|
|
|
435
437
|
function unwrapArgValues(args: ArgValue[]): unknown[] {
|