@tari-project/tari-extension-query-builder 0.0.7 → 0.0.9

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/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.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "main": "dist/tari-extension-query-builder.umd.js",
7
7
  "module": "dist/tari-extension-query-builder.es.js",
@@ -21,8 +21,9 @@
21
21
  "./dist/tari-extension-query-builder.css"
22
22
  ],
23
23
  "peerDependencies": {
24
- "react": ">=17.0.0",
25
- "react-dom": ">=17.0.0"
24
+ "react": ">=19.0.0",
25
+ "react-dom": ">=19.0.0",
26
+ "zustand": ">= 5.0.0"
26
27
  },
27
28
  "dependencies": {
28
29
  "@ladle/react": "^5.0.1",
@@ -36,44 +37,44 @@
36
37
  "@radix-ui/react-separator": "^1.1.2",
37
38
  "@radix-ui/react-slot": "^1.1.2",
38
39
  "@radix-ui/react-tooltip": "^1.1.8",
39
- "@tailwindcss/vite": "^4.0.12",
40
- "@tari-project/tarijs-all": "^0.6.0",
40
+ "@tari-project/tarijs-all": "^0.10.1",
41
41
  "@xyflow/react": "^12.4.4",
42
- "autoprefixer": "^10.4.21",
43
42
  "class-variance-authority": "^0.7.1",
44
43
  "clsx": "^2.1.1",
45
44
  "lucide-react": "^0.479.0",
46
45
  "next-themes": "^0.4.6",
47
- "postcss": "^8.5.3",
48
- "sonner": "^2.0.3",
49
- "tailwind-merge": "^3.0.2",
50
- "tailwindcss": "^4.0.12",
46
+ "sonner": "^2.0.5",
47
+ "tailwind-merge": "^3.3.1",
51
48
  "tailwindcss-animate": "^1.0.7",
52
49
  "uuid": "^11.1.0",
53
- "zod": "^3.24.2",
54
- "zustand": "^5.0.3",
55
- "@tari-project/tari-extension-common": "^0.0.7"
50
+ "zod": "^3.25.67",
51
+ "@tari-project/tari-extension-common": "^0.0.9"
56
52
  },
57
53
  "devDependencies": {
58
54
  "@eslint/js": "^9.21.0",
59
- "@tari-project/typescript-bindings": "^1.5.2",
60
- "@types/node": "^22.13.5",
61
- "@types/react": "^19.0.10",
62
- "@types/react-dom": "^19.0.4",
63
- "@vitejs/plugin-react": "^4.3.4",
55
+ "@tailwindcss/vite": "^4.0.12",
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
+ "autoprefixer": "^10.4.21",
64
62
  "eslint": "^9.21.0",
65
63
  "eslint-plugin-react": "^7.37.4",
66
64
  "eslint-plugin-react-hooks": "^5.1.0",
67
65
  "eslint-plugin-react-refresh": "^0.4.19",
68
- "globals": "^15.15.0",
69
- "prettier": "^3.5.2",
66
+ "globals": "^16.3.0",
67
+ "postcss": "^8.5.3",
68
+ "prettier": "^3.6.2",
70
69
  "react": "^19.0.0",
71
70
  "react-dom": "^19.0.0",
71
+ "tailwindcss": "^4.0.12",
72
72
  "typescript": "^5.7.3",
73
73
  "typescript-eslint": "^8.25.0",
74
- "vite": "^6.2.0",
74
+ "vite": "^7.0.0",
75
75
  "vite-plugin-dts": "^4.5.3",
76
- "vitest": "^3.0.7"
76
+ "vitest": "^3.2.4",
77
+ "zustand": "^5.0.3"
77
78
  },
78
79
  "scripts": {
79
80
  "dev": "vite",
@@ -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
- buildInputArgs(this.details.context),
75
- factory.createTypeReferenceNode(factory.createIdentifier("Transaction"), undefined),
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("build"),
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
- factory.createParameterDeclaration(
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("SubmitTxResult"), undefined),
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("buildTransaction"),
174
- undefined,
175
- Object.keys(this.details.context.inputParams).map((key) => factory.createIdentifier(key)),
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(factory.createIdentifier("txResult")),
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
- return factory.createCallExpression(factory.createIdentifier("fromWorkspace"), undefined, [
258
- factory.createStringLiteral(arg.value),
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),
@@ -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(): Transaction {
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, fromWorkspace("a2")],
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, fromWorkspace("b3")],
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.build();
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
- requiredSubstates: ReqSubstate[] = [],
45
- isDryRun = false,
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 { CALL_NODE_DRAG_DROP_TYPE, GeneratedCodeType, TransactionProps } from "@tari-project/tari-extension-common";
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, Transaction } from "@tari-project/tarijs-all";
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: Transaction, dryRun: boolean) => Promise<void>;
95
+ executeTransaction?: (transaction: UnsignedTransactionV1) => Promise<void>;
90
96
  showGeneratedCode?: (code: string, type: GeneratedCodeType) => Promise<void>;
91
97
  }
92
98
 
@@ -167,9 +173,9 @@ function Flow({
167
173
  const planner = new ExecutionPlanner(nodes, edges);
168
174
  try {
169
175
  const executionOrder = planner.getExecutionOrder();
170
- const { accountAddress, fee } = await getTransactionProps();
176
+ const { network, accountAddress, fee } = await getTransactionProps();
171
177
  const details = planner.buildTransactionDescription(executionOrder, accountAddress, new Amount(fee));
172
- return { planner, details };
178
+ return { network, planner, details };
173
179
  } catch (e) {
174
180
  let errorMessage = "Failed to determine execution order";
175
181
  if (e instanceof AmbiguousOrderError) {
@@ -205,6 +211,23 @@ function Flow({
205
211
  [nodes, edges, getNodeById],
206
212
  );
207
213
 
214
+ const getNetwork = (network: TariNetwork) => {
215
+ switch (network) {
216
+ case TariNetwork.MainNet:
217
+ return Network.MainNet;
218
+ case TariNetwork.StageNet:
219
+ return Network.StageNet;
220
+ case TariNetwork.NextNet:
221
+ return Network.NextNet;
222
+ case TariNetwork.LocalNet:
223
+ return Network.LocalNet;
224
+ case TariNetwork.Igor:
225
+ return Network.Igor;
226
+ case TariNetwork.Esmeralda:
227
+ return Network.Esmeralda;
228
+ }
229
+ };
230
+
208
231
  const handleExecute = useCallback(
209
232
  async (dryRun: boolean) => {
210
233
  if (!getTransactionProps || !executeTransaction) {
@@ -213,9 +236,9 @@ function Flow({
213
236
 
214
237
  setLoading(true);
215
238
  try {
216
- const { planner, details } = await buildTransactionDescriptions(getTransactionProps);
217
- const transaction = planner.buildTransaction(details);
218
- await executeTransaction(transaction, dryRun);
239
+ const { network, planner, details } = await buildTransactionDescriptions(getTransactionProps);
240
+ const transaction = planner.buildTransaction(getNetwork(network), details, dryRun);
241
+ await executeTransaction(transaction);
219
242
  toast.success("Transaction executed");
220
243
  } catch (e) {
221
244
  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, fromWorkspace, Transaction, TransactionBuilder } from "@tari-project/tarijs-all";
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): Transaction {
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
- return builder.build();
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" ? fromWorkspace(arg.value) : arg.value;
434
+ return arg.type === "workspace" ? { Workspace: arg.value } : arg.value;
433
435
  }
434
436
 
435
437
  function unwrapArgValues(args: ArgValue[]): unknown[] {
package/vite.config.ts CHANGED
@@ -21,12 +21,13 @@ export default defineConfig({
21
21
  fileName: (format) => `tari-extension-query-builder.${format}.js`,
22
22
  },
23
23
  rollupOptions: {
24
- external: ["react", "react-dom", "react-flow-renderer"],
24
+ external: ["react", "react-dom", "react-flow-renderer", "react/jsx-runtime"],
25
25
  output: {
26
26
  globals: {
27
27
  react: "React",
28
28
  "react-dom": "ReactDOM",
29
29
  "react-flow-renderer": "ReactFlowRenderer",
30
+ "react/jsx-runtime": "ReactJsxRuntime",
30
31
  },
31
32
  },
32
33
  },