@tari-project/tarijs 0.5.5 → 0.8.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.
Files changed (37) hide show
  1. package/.github/PULL_REQUEST_TEMPLATE.md +2 -12
  2. package/.github/workflows/check-package-versions.yml +22 -0
  3. package/Dockerfile +2 -2
  4. package/README.md +1 -1
  5. package/docusaurus/tari-docs/docs/provider-vs-signer.md +27 -0
  6. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +0 -1
  7. package/docusaurus/tari-docs/package-lock.json +17964 -0
  8. package/docusaurus/tari-docs/package.json +2 -2
  9. package/package.json +1 -1
  10. package/packages/builders/package.json +3 -2
  11. package/packages/builders/src/helpers/index.ts +1 -1
  12. package/packages/builders/src/helpers/workspace.ts +32 -22
  13. package/packages/builders/src/index.ts +1 -2
  14. package/packages/builders/src/transaction/TransactionBuilder.ts +105 -38
  15. package/packages/builders/src/transaction/TransactionRequest.ts +36 -33
  16. package/packages/indexer_provider/package.json +1 -1
  17. package/packages/metamask_signer/package.json +1 -1
  18. package/packages/metamask_signer/src/index.ts +1 -1
  19. package/packages/tari_permissions/package.json +1 -1
  20. package/packages/tari_permissions/src/tari_permissions.ts +1 -17
  21. package/packages/tari_provider/package.json +1 -1
  22. package/packages/tari_signer/package.json +1 -1
  23. package/packages/tari_universe/package.json +1 -1
  24. package/packages/tarijs/package.json +1 -1
  25. package/packages/tarijs/src/index.ts +0 -4
  26. package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +80 -1
  27. package/packages/tarijs_types/package.json +1 -1
  28. package/packages/tarijs_types/src/Instruction.ts +7 -3
  29. package/packages/tarijs_types/src/SubstateType.ts +1 -1
  30. package/packages/tarijs_types/src/Workspace.ts +1 -1
  31. package/packages/wallet_daemon/package.json +1 -1
  32. package/packages/wallet_daemon/src/signer.ts +1 -0
  33. package/packages/walletconnect/package.json +1 -1
  34. package/packages/walletconnect/src/index.ts +1 -0
  35. package/pnpm-workspace.yaml +2 -2
  36. package/scripts/check_versions.sh +42 -0
  37. package/scripts/set_package_versions.sh +39 -0
@@ -12,7 +12,6 @@ import {
12
12
  waitForTransactionResult,
13
13
  WalletDaemonTariSigner,
14
14
  } from "../../../src";
15
- import { inspect } from "util";
16
15
 
17
16
  function buildSigner(): Promise<WalletDaemonTariSigner> {
18
17
  const permissions = new TariPermissions().addPermission("Admin");
@@ -156,6 +155,50 @@ describe("WalletDaemonTariSigner", () => {
156
155
 
157
156
  expect(txResult.status).toEqual(TransactionStatus.DryRun);
158
157
  });
158
+
159
+ it("submits a transaction, that uses workspaces", async () => {
160
+ const workspaceId = "bucket";
161
+ const signer = await buildSigner();
162
+ const account = await signer.getAccount();
163
+ const xtrAddress = account.resources[0].resource_address;
164
+
165
+ const fee = new Amount(2000);
166
+ const builder = new TransactionBuilder();
167
+ builder.feeTransactionPayFromComponent(account.address, fee.getStringValue());
168
+
169
+ builder.callMethod(
170
+ {
171
+ componentAddress: account.address,
172
+ methodName: "withdraw",
173
+ },
174
+ [xtrAddress, 10],
175
+ );
176
+ builder.saveVar(workspaceId);
177
+ builder.callMethod(
178
+ {
179
+ componentAddress: account.address,
180
+ methodName: "deposit",
181
+ },
182
+ [workspaceId],
183
+ );
184
+ const transaction = builder.build();
185
+
186
+ const isDryRun = false;
187
+ const inputRefs = undefined;
188
+ const network = Network.LocalNet;
189
+ const requiredSubstates = [{ substate_id: account.address }];
190
+ const submitTransactionRequest = buildTransactionRequest(
191
+ transaction,
192
+ account.account_id,
193
+ requiredSubstates,
194
+ inputRefs,
195
+ isDryRun,
196
+ network,
197
+ );
198
+
199
+ const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
200
+ expect(txResult.result.status).toBe(TransactionStatus.Accepted);
201
+ });
159
202
  });
160
203
 
161
204
  describe("getAccountBalances", () => {
@@ -294,4 +337,40 @@ describe("WalletDaemonTariSigner", () => {
294
337
  expect(failure).toEqual("1 dangling address allocations remain after transaction execution");
295
338
  });
296
339
  });
340
+
341
+ describe("assertBucketContains", () => {
342
+ it("fails if bucket does not exist", async () => {
343
+ const signer = await buildSigner();
344
+ const account = await signer.getAccount();
345
+
346
+ const fee = new Amount(2000);
347
+ const builder = new TransactionBuilder();
348
+ builder.feeTransactionPayFromComponent(account.address, fee.getStringValue());
349
+ builder.assertBucketContains("not_exist", "resource_0000000000000000000000000000000000000000000000000000000000000000", Amount.newAmount(1));
350
+ const transaction = builder.build();
351
+
352
+ const isDryRun = false;
353
+ const inputRefs = undefined;
354
+ const network = Network.LocalNet;
355
+ const requiredSubstates = [{ substate_id: account.address }];
356
+ const submitTransactionRequest = buildTransactionRequest(
357
+ transaction,
358
+ account.account_id,
359
+ requiredSubstates,
360
+ inputRefs,
361
+ isDryRun,
362
+ network,
363
+ );
364
+
365
+ const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
366
+
367
+ expect(txResult.result.status).toBe(TransactionStatus.OnlyFeeAccepted);
368
+
369
+ const executionResult = txResult.result.result?.result;
370
+ const reason =
371
+ executionResult && "AcceptFeeRejectRest" in executionResult && executionResult.AcceptFeeRejectRest[1];
372
+ const failure = reason && typeof reason === "object" && "ExecutionFailure" in reason && reason.ExecutionFailure;
373
+ expect(failure).toContain("Item at id 0 does not exist on the workspace");
374
+ });
375
+ });
297
376
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-types",
3
- "version": "0.5.5",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,4 +1,4 @@
1
- import { ComponentAddress, LogLevel, PublishedTemplateAddress, SubstateType } from "@tari-project/typescript-bindings";
1
+ import { ComponentAddress, ResourceAddress, LogLevel, PublishedTemplateAddress, SubstateType, WorkspaceOffsetId } from "@tari-project/typescript-bindings";
2
2
  import { TransactionArg } from "./TransactionArg";
3
3
  import { ConfidentialClaim } from "./ConfidentialClaim";
4
4
  import { Amount } from "./Amount";
@@ -14,7 +14,8 @@ export type Instruction =
14
14
  | ClaimValidatorFees
15
15
  | DropAllProofsInWorkspace
16
16
  | CreateFreeTestCoins
17
- | AllocateAddress;
17
+ | AllocateAddress
18
+ | AssertBucketContains;
18
19
 
19
20
  export type CreateAccount = { CreateAccount: { owner_public_key: string; workspace_bucket: string | null } };
20
21
  export type CallFunction = {
@@ -23,7 +24,7 @@ export type CallFunction = {
23
24
  export type CallMethod = {
24
25
  CallMethod: { component_address: ComponentAddress; method: string; args: Array<TransactionArg> };
25
26
  };
26
- export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key: number[] } };
27
+ export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key: string } };
27
28
  export type EmitLog = { EmitLog: { level: LogLevel; message: string } };
28
29
  export type ClaimBurn = { ClaimBurn: { claim: ConfidentialClaim } };
29
30
  export type ClaimValidatorFees = { ClaimValidatorFees: { epoch: number; validator_public_key: string } };
@@ -34,3 +35,6 @@ export type CreateFreeTestCoins = {
34
35
  export type AllocateAddress = {
35
36
  AllocateAddress: { substate_type: SubstateType; workspace_id: string };
36
37
  };
38
+ export type AssertBucketContains = {
39
+ AssertBucketContains: { key: WorkspaceOffsetId; resource_address: ResourceAddress; min_amount: Amount };
40
+ }
@@ -1 +1 @@
1
- export type SubstateType = "Component" | "Resource" | "Vault" | "UnclaimedConfidentialOutput" | "NonFungible" | "TransactionReceipt" | "NonFungibleIndex" | "ValidatorFeePool" | "Template";
1
+ export type SubstateType = "Component" | "Resource" | "Vault" | "UnclaimedConfidentialOutput" | "NonFungible" | "TransactionReceipt" | "ValidatorFeePool" | "Template";
@@ -1,3 +1,3 @@
1
1
  export interface WorkspaceArg {
2
- Workspace: number[];
2
+ Workspace: string;
3
3
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-daemon-signer",
3
- "version": "0.5.3",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -184,6 +184,7 @@ export class WalletDaemonTariSigner implements TariSigner {
184
184
  })),
185
185
  min_epoch: null,
186
186
  max_epoch: null,
187
+ dry_run: req.is_dry_run,
187
188
  is_seal_signer_authorized: req.is_seal_signer_authorized,
188
189
  },
189
190
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-connect-signer",
3
- "version": "0.5.3",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -207,6 +207,7 @@ export class WalletConnectTariSigner implements TariSigner {
207
207
  })),
208
208
  min_epoch: null,
209
209
  max_epoch: null,
210
+ dry_run: req.is_dry_run,
210
211
  is_seal_signer_authorized: req.is_seal_signer_authorized,
211
212
  },
212
213
  },
@@ -8,8 +8,8 @@ catalog:
8
8
  vitest: ^3.0.4
9
9
  vite: ^6.1.0
10
10
  "@types/node": ^22.13.1
11
- "@tari-project/typescript-bindings": ^1.5.5
12
- "@tari-project/wallet_jrpc_client": ^1.5.4
11
+ "@tari-project/typescript-bindings": ">=1.9.0"
12
+ "@tari-project/wallet_jrpc_client": ^1.6.0
13
13
  "@metamask/providers": ^18.2.0
14
14
  "@walletconnect/universal-provider": ^2.13.3
15
15
  "@walletconnect/modal": ^2.6.2
@@ -0,0 +1,42 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ echo "Finding all package.json files and extracting versions..."
6
+
7
+ declare -a versions
8
+
9
+ # Find all package.json files, excluding node_modules, and extract the version
10
+ while IFS= read -r file; do
11
+ version=$(jq -r '.version' "$file")
12
+ if [[ -z "$version" || "$version" == "null" ]]; then
13
+ echo "::error::Could not find 'version' field in $file"
14
+ exit 1
15
+ fi
16
+ echo "Found version '$version' in $file"
17
+ versions+=("$version")
18
+ done < <(find . -name 'package.json' -not -path '*/node_modules/*')
19
+
20
+ if [ ${#versions[@]} -eq 0 ]; then
21
+ echo "Error: No package.json files with a 'version' field were found."
22
+ exit 1
23
+ fi
24
+
25
+ reference_version=${versions[0]}
26
+ echo "Reference version: $reference_version"
27
+
28
+ all_same=true
29
+ for version in "${versions[@]}"; do
30
+ if [ "$version" != "$reference_version" ]; then
31
+ echo "Error: Mismatched version found! '$version' does not match '$reference_version'."
32
+ all_same=false
33
+ break
34
+ fi
35
+ done
36
+
37
+ if [ "$all_same" = false ]; then
38
+ echo "❌ ::error::All package.json versions are NOT the same. Please unify them."
39
+ exit 1
40
+ else
41
+ echo "✅ All package.json versions are consistent: $reference_version"
42
+ fi
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # This script sets the package versions in all package.json files for the workspace.
5
+
6
+ # Usage: ./scripts/set_package_versions.sh <version>
7
+ if [ "$#" -ne 1 ]; then
8
+ echo "Usage: $0 <version>"
9
+ exit 1
10
+ fi
11
+
12
+ gitroot=$(git rev-parse --show-toplevel)
13
+
14
+ VERSION=$1
15
+ # Find all package.json files in the workspace
16
+ pushd "${gitroot}/packages" > /dev/null
17
+ find . -depth -maxdepth 2 -name 'package.json' | while read -r package_json; do
18
+ # Update the version in the package.json file
19
+ jq --arg version "$VERSION" '.version = $version' "$package_json" > "$package_json.tmp" && mv "$package_json.tmp" "$package_json"
20
+ echo "Updated version in $package_json to $VERSION"
21
+ done
22
+ popd > /dev/null
23
+
24
+ pushd "${gitroot}/docusaurus/tari-docs" > /dev/null
25
+ jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
26
+ echo "Updated docusaurus package.json version to $VERSION"
27
+ popd > /dev/null
28
+
29
+ pushd "${gitroot}" > /dev/null
30
+ # Update the version in the root package.json
31
+ jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
32
+ echo "Updated root package.json version to $VERSION"
33
+
34
+ pnpm install
35
+
36
+ echo "Running check_versions script to verify versions..."
37
+ ./scripts/check_versions.sh
38
+ popd > /dev/null
39
+