@tari-project/tarijs 0.10.1 → 0.11.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 (71) hide show
  1. package/README.md +127 -67
  2. package/TODO.md +91 -3
  3. package/docusaurus/tari-docs/README.md +200 -17
  4. package/docusaurus/tari-docs/docs/api-reference.md +665 -0
  5. package/docusaurus/tari-docs/docs/contributing.md +619 -0
  6. package/docusaurus/tari-docs/docs/guides/getting-started-tutorial.md +965 -0
  7. package/docusaurus/tari-docs/docs/guides/production-deployment.md +977 -0
  8. package/docusaurus/tari-docs/docs/index.md +114 -11
  9. package/docusaurus/tari-docs/docs/installation.md +142 -1
  10. package/docusaurus/tari-docs/docs/signers/metamask.md +529 -0
  11. package/docusaurus/tari-docs/docs/troubleshooting.md +661 -0
  12. package/docusaurus/tari-docs/package.json +1 -1
  13. package/examples/vite-typescript-react/README.md +9 -0
  14. package/examples/vite-typescript-react/eslint.config.js +23 -0
  15. package/examples/vite-typescript-react/index.html +13 -0
  16. package/examples/vite-typescript-react/package.json +35 -0
  17. package/examples/vite-typescript-react/public/vite.svg +1 -0
  18. package/examples/vite-typescript-react/src/App.css +42 -0
  19. package/examples/vite-typescript-react/src/App.tsx +50 -0
  20. package/examples/vite-typescript-react/src/assets/react.svg +1 -0
  21. package/examples/vite-typescript-react/src/index.css +68 -0
  22. package/examples/vite-typescript-react/src/main.tsx +10 -0
  23. package/examples/vite-typescript-react/src/vite-env.d.ts +1 -0
  24. package/examples/vite-typescript-react/tsconfig.app.json +27 -0
  25. package/examples/vite-typescript-react/tsconfig.json +7 -0
  26. package/examples/vite-typescript-react/tsconfig.node.json +25 -0
  27. package/examples/vite-typescript-react/vite.config.ts +7 -0
  28. package/package.json +2 -2
  29. package/packages/builders/package.json +2 -2
  30. package/packages/builders/src/transaction/TransactionBuilder.ts +4 -12
  31. package/packages/indexer_provider/package.json +2 -2
  32. package/packages/indexer_provider/src/provider.ts +5 -5
  33. package/packages/indexer_provider/tsconfig.json +4 -2
  34. package/packages/metamask_signer/package.json +2 -2
  35. package/packages/metamask_signer/src/index.ts +2 -14
  36. package/packages/{tari_permissions → permissions}/package.json +2 -2
  37. package/packages/{tari_permissions → permissions}/src/helpers.ts +1 -1
  38. package/packages/permissions/src/index.ts +2 -0
  39. package/packages/{tari_permissions/src/tari_permissions.ts → permissions/src/permissions.ts} +56 -6
  40. package/packages/react-mui-connect-button/moon.yml +71 -0
  41. package/packages/react-mui-connect-button/package.json +40 -0
  42. package/packages/react-mui-connect-button/src/Logos.tsx +60 -0
  43. package/packages/react-mui-connect-button/src/TariConnectButton.tsx +51 -0
  44. package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +116 -0
  45. package/packages/react-mui-connect-button/src/content/tari-logo-white.svg +18 -0
  46. package/packages/react-mui-connect-button/src/content/tari-logo.svg +18 -0
  47. package/packages/react-mui-connect-button/src/content/walletconnect-logo.svg +13 -0
  48. package/packages/react-mui-connect-button/src/defaultPermissions.ts +0 -0
  49. package/packages/react-mui-connect-button/src/index.ts +24 -0
  50. package/packages/react-mui-connect-button/tsconfig.json +31 -0
  51. package/packages/tari_provider/package.json +2 -2
  52. package/packages/tari_signer/package.json +2 -2
  53. package/packages/tari_universe/package.json +2 -2
  54. package/packages/tari_universe/tsconfig.json +4 -2
  55. package/packages/tarijs/package.json +2 -2
  56. package/packages/tarijs/tsconfig.json +4 -2
  57. package/packages/tarijs_types/package.json +2 -2
  58. package/packages/wallet_daemon/package.json +2 -2
  59. package/packages/wallet_daemon/src/provider.ts +8 -6
  60. package/packages/wallet_daemon/src/signer.ts +11 -6
  61. package/packages/wallet_daemon/tsconfig.json +1 -1
  62. package/packages/walletconnect/package.json +3 -2
  63. package/packages/walletconnect/src/index.ts +52 -26
  64. package/packages/walletconnect/tsconfig.json +3 -0
  65. package/pnpm-workspace.yaml +15 -7
  66. package/scripts/check_versions.sh +4 -0
  67. package/scripts/clean_everything.sh +38 -0
  68. package/tsconfig.json +6 -0
  69. package/packages/tari_permissions/src/index.ts +0 -2
  70. /package/packages/{tari_permissions → permissions}/moon.yml +0 -0
  71. /package/packages/{tari_permissions → permissions}/tsconfig.json +0 -0
@@ -0,0 +1,24 @@
1
+ export { TariConnectButton, TariConnectButtonProps } from "./TariConnectButton";
2
+ export { TariWalletSelectionDialog, WalletSelectionProps } from "./TariWalletSelectionDialog";
3
+ import {
4
+ TariPermissionAccountInfo,
5
+ TariPermissionKeyList,
6
+ TariPermissions, TariPermissionSubstatesRead, TariPermissionTemplatesRead, TariPermissionTransactionSend,
7
+ TariPermissionTransactionsGet,
8
+ } from "@tari-project/tari-permissions";
9
+
10
+ export function defaultPermissions() {
11
+ // Minimal permissions for the example site
12
+ // But each application will have different permission needs
13
+ const walletDaemonPermissions = new TariPermissions();
14
+ walletDaemonPermissions
15
+ // Required for createFreeTestCoins
16
+ .addPermission("Admin")
17
+ .addPermission(new TariPermissionKeyList())
18
+ .addPermission(new TariPermissionAccountInfo())
19
+ .addPermission(new TariPermissionTransactionsGet())
20
+ .addPermission(new TariPermissionSubstatesRead())
21
+ .addPermission(new TariPermissionTemplatesRead())
22
+ .addPermission(new TariPermissionTransactionSend());
23
+ return walletDaemonPermissions;
24
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "module": "ES2020",
6
+ "target": "ESNext",
7
+ "moduleResolution": "Bundler",
8
+ "outDir": "./dist",
9
+ "rootDir": "./src"
10
+ },
11
+ "include": [
12
+ "src/**/*"
13
+ ],
14
+ "references": [
15
+ {
16
+ "path": "../permissions"
17
+ },
18
+ {
19
+ "path": "../tari_provider"
20
+ },
21
+ {
22
+ "path": "../tari_signer"
23
+ },
24
+ {
25
+ "path": "../wallet_daemon"
26
+ },
27
+ {
28
+ "path": "../walletconnect"
29
+ }
30
+ ]
31
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-provider",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "keywords": [],
13
- "author": "",
13
+ "author": "The Tari Community",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/typescript-bindings": "catalog:",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-signer",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "keywords": [],
13
- "author": "",
13
+ "author": "The Tari Community",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/tarijs-types": "workspace:^",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-universe-signer",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "keywords": [],
13
- "author": "",
13
+ "author": "The Tari Community",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/tari-permissions": "workspace:^",
@@ -7,10 +7,12 @@
7
7
  "outDir": "./dist",
8
8
  "rootDir": "./src"
9
9
  },
10
- "include": ["src/**/*"],
10
+ "include": [
11
+ "src/**/*"
12
+ ],
11
13
  "references": [
12
14
  {
13
- "path": "../tari_permissions"
15
+ "path": "../permissions"
14
16
  },
15
17
  {
16
18
  "path": "../tari_signer"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-all",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -12,7 +12,7 @@
12
12
  "integration-tests": "vitest run integration-tests"
13
13
  },
14
14
  "keywords": [],
15
- "author": "",
15
+ "author": "The Tari Community",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
18
  "@metamask/providers": "catalog:",
@@ -7,7 +7,9 @@
7
7
  "outDir": "./dist",
8
8
  "rootDir": "./src"
9
9
  },
10
- "include": ["src/**/*"],
10
+ "include": [
11
+ "src/**/*"
12
+ ],
11
13
  "references": [
12
14
  {
13
15
  "path": "../builders"
@@ -19,7 +21,7 @@
19
21
  "path": "../metamask_signer"
20
22
  },
21
23
  {
22
- "path": "../tari_permissions"
24
+ "path": "../permissions"
23
25
  },
24
26
  {
25
27
  "path": "../tari_provider"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-types",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "keywords": [],
13
- "author": "",
13
+ "author": "The Tari Community",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/typescript-bindings": "catalog:"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-daemon-signer",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "keywords": [],
13
- "author": "",
13
+ "author": "The Tari Community",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/tari-permissions": "workspace:^",
@@ -76,15 +76,17 @@ export class WalletDaemonTariProvider implements TariProvider {
76
76
  async getSubstate(req: GetSubstateRequest): Promise<Substate> {
77
77
  // TODO: Substate address cannot be converted to SubstateId directly - Perhaps we need to change the provider interface
78
78
  const {
79
- record,
80
- value,
81
- } = await this.client.substatesGet({ substate_id: req.substate_address as unknown as SubstateId });
79
+ substate,
80
+ } = await this.client.substatesGet({ substate_id: req.substate_address });
81
+ if (!substate) {
82
+ throw new Error(`Substate not found for address: ${req.substate_address}`);
83
+ }
82
84
 
83
85
  return {
84
- value,
86
+ value: substate?.substate,
85
87
  address: {
86
- substate_id: substateIdToString(record.substate_id),
87
- version: record.version,
88
+ substate_id: req.substate_address,
89
+ version: substate?.version || 0,
88
90
  },
89
91
  };
90
92
  }
@@ -20,7 +20,6 @@ import {
20
20
  KeyBranch,
21
21
  ListAccountNftRequest,
22
22
  ListAccountNftResponse,
23
- SubstateId,
24
23
  substateIdToString,
25
24
  SubstatesListRequest,
26
25
  } from "@tari-project/typescript-bindings";
@@ -44,6 +43,7 @@ export interface WalletDaemonFetchParameters extends WalletDaemonBaseParameters
44
43
  serverUrl: string;
45
44
  }
46
45
 
46
+
47
47
  export class WalletDaemonTariSigner implements TariSigner {
48
48
  public signerName = "WalletDaemon";
49
49
  params: WalletDaemonParameters;
@@ -158,13 +158,18 @@ export class WalletDaemonTariSigner implements TariSigner {
158
158
  }
159
159
 
160
160
  public async getSubstate(substateId: string): Promise<Substate> {
161
- // Wallet daemon expects a SubstateId as a string
162
- const { value, record } = await this.client.substatesGet({ substate_id: substateId as unknown as SubstateId });
161
+ const {
162
+ substate,
163
+ } = await this.client.substatesGet({ substate_id: substateId });
164
+ if (!substate) {
165
+ throw new Error(`Substate not found for address: ${substateId}`);
166
+ }
167
+
163
168
  return {
164
- value,
169
+ value: substate?.substate,
165
170
  address: {
166
- substate_id: substateIdToString(record.substate_id),
167
- version: record.version,
171
+ substate_id: substateId,
172
+ version: substate?.version || 0,
168
173
  },
169
174
  };
170
175
  }
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "references": [
14
14
  {
15
- "path": "../tari_permissions"
15
+ "path": "../permissions"
16
16
  },
17
17
  {
18
18
  "path": "../tari_provider"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-connect-signer",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "keywords": [],
13
- "author": "",
13
+ "author": "The Tari Community",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/tari-signer": "workspace:^",
@@ -18,6 +18,7 @@
18
18
  "@tari-project/tarijs-types": "workspace:^",
19
19
  "@tari-project/typescript-bindings": "catalog:",
20
20
  "@tari-project/wallet_jrpc_client": "catalog:",
21
+ "@tari-project/tari-permissions": "workspace:",
21
22
  "@walletconnect/modal": "catalog:",
22
23
  "@walletconnect/universal-provider": "catalog:"
23
24
  },
@@ -21,9 +21,10 @@ import {
21
21
  substateIdToString,
22
22
  TransactionSubmitRequest,
23
23
  } from "@tari-project/typescript-bindings";
24
+ import { TariPermission } from "@tari-project/tari-permissions";
24
25
 
25
26
  const walletConnectParams = {
26
- requiredNamespaces: {
27
+ optionalNamespaces: {
27
28
  tari: {
28
29
  methods: [
29
30
  "tari_getSubstate",
@@ -39,51 +40,76 @@ const walletConnectParams = {
39
40
  "tari_getNftsList",
40
41
  ],
41
42
  chains: ["tari:devnet"],
42
- events: ["chainChanged\", \"accountsChanged"],
43
+ events: [],
44
+ // events: ["chainChanged", "accountsChanged"],
43
45
  },
44
46
  },
45
47
  };
46
48
 
49
+ export interface WalletConnectParameters {
50
+ requiredPermissions?: TariPermission[];
51
+ optionalPermissions?: TariPermission[];
52
+ projectId: string;
53
+ }
54
+
47
55
  export class WalletConnectTariSigner implements TariSigner {
48
56
  public signerName = "WalletConnect";
49
- projectId: string;
50
- wcProvider: UniversalProvider | null;
57
+ params: WalletConnectParameters;
58
+ wcProvider: UniversalProvider | undefined;
51
59
  wcSession: any | null;
52
60
 
53
- constructor(projectId: string) {
54
- this.projectId = projectId;
55
- this.wcProvider = null;
61
+ constructor(params: WalletConnectParameters) {
62
+ this.params = params;
63
+ this.wcProvider = undefined;
56
64
  this.wcSession = null;
57
65
  }
58
66
 
59
- async connect(): Promise<void> {
60
- if (this.wcProvider && this.wcSession) return;
67
+ static init(params: WalletConnectParameters): WalletConnectTariSigner {
68
+ return new WalletConnectTariSigner(params);
69
+ }
70
+
71
+ async connect(): Promise<() => Promise<void>> {
72
+ if (this.wcProvider && this.wcSession) return async () => {
73
+ // No-op if already connected
74
+ };
61
75
 
62
76
  // initialize WalletConnect
63
- const projectId = this.projectId;
64
- this.wcProvider = await UniversalProvider.init({
77
+ const projectId = this.params.projectId;
78
+ const provider = await UniversalProvider.init({
65
79
  projectId,
66
80
  // TODO: parameterize the relay URL
67
- relayUrl: "wss://relay.walletconnect.com",
81
+ // relayUrl: "wss://relay.walletconnect.com",
68
82
  });
69
83
 
84
+ const sessionProperties = {
85
+ "required_permissions": JSON.stringify(this.params.requiredPermissions) || "[]",
86
+ "optional_permissions": JSON.stringify(this.params.optionalPermissions) || "[]",
87
+ };
88
+ const connectParams = {
89
+ ...walletConnectParams,
90
+ sessionProperties,
91
+ };
92
+
70
93
  // open UI modal with the connection URI
71
- const { uri, approval } = await this.wcProvider.client.connect(walletConnectParams);
72
- const walletConnectModal = new WalletConnectModal({
73
- projectId,
74
- });
75
- if (uri) {
76
- walletConnectModal.openModal({ uri });
77
- }
94
+ const { uri, approval } = await provider.client.connect(connectParams);
95
+ return async () => {
96
+ const walletConnectModal = new WalletConnectModal({
97
+ projectId,
98
+ });
99
+ if (uri) {
100
+ await walletConnectModal.openModal({ uri });
101
+ }
78
102
 
79
- // wait for the wallet to approve the connection
80
- console.log("waiting for session approval from the wallet app");
81
- const session = await approval();
82
- walletConnectModal.closeModal();
103
+ // wait for the wallet to approve the connection
104
+ console.log("waiting for session approval from the wallet app");
105
+ const session = await approval();
106
+ walletConnectModal.closeModal();
83
107
 
84
- // at this point session is open
85
- console.log("session approved by the wallet");
86
- this.wcSession = session;
108
+ // at this point session is open
109
+ console.log("session approved by the wallet");
110
+ this.wcProvider = provider;
111
+ this.wcSession = session;
112
+ };
87
113
  }
88
114
 
89
115
  private async sendRequest(method: string, params: object): Promise<any> {
@@ -14,6 +14,9 @@
14
14
  {
15
15
  "path": "../builders"
16
16
  },
17
+ {
18
+ "path": "../permissions"
19
+ },
17
20
  {
18
21
  "path": "../tari_signer"
19
22
  },
@@ -2,14 +2,22 @@ packages:
2
2
  - packages/*
3
3
  - apps/*
4
4
  - docusaurus/*
5
- - "!**/test/**"
5
+ - examples/*
6
+ - '!**/test/**'
7
+
6
8
  catalog:
7
9
  typescript: ^5.0.4
8
10
  vitest: ^3.0.4
9
11
  vite: ^6.1.0
10
- "@types/node": ^22.13.1
11
- "@tari-project/typescript-bindings": ">=1.10.2"
12
- "@tari-project/wallet_jrpc_client": ^1.6.2
13
- "@metamask/providers": ^18.2.0
14
- "@walletconnect/universal-provider": ^2.13.3
15
- "@walletconnect/modal": ^2.6.2
12
+ '@types/node': ^22.13.1
13
+ '@tari-project/typescript-bindings': '>=1.13.0'
14
+ '@tari-project/wallet_jrpc_client': ^1.7.2
15
+ '@metamask/providers': ^18.2.0
16
+ '@walletconnect/universal-provider': ^2.13.3
17
+ '@walletconnect/modal': ^2.6.2
18
+
19
+ onlyBuiltDependencies:
20
+ - '@moonrepo/cli'
21
+ - core-js
22
+ - core-js-pure
23
+ - esbuild
@@ -6,6 +6,8 @@ echo "Finding all package.json files and extracting versions..."
6
6
 
7
7
  declare -a versions
8
8
 
9
+ gitroot=$(git rev-parse --show-toplevel)
10
+ pushd "${gitroot}/packages" > /dev/null
9
11
  # Find all package.json files, excluding node_modules, and extract the version
10
12
  while IFS= read -r file; do
11
13
  version=$(jq -r '.version' "$file")
@@ -40,3 +42,5 @@ if [ "$all_same" = false ]; then
40
42
  else
41
43
  echo "✅ All package.json versions are consistent: $reference_version"
42
44
  fi
45
+
46
+ popd > /dev/null
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ # This script cleans up the dist and node_modules directories in all packages
6
+
7
+ gitroot=$(git rev-parse --show-toplevel)
8
+ pushd "${gitroot}" > /dev/null
9
+ echo "Cleaning up the root node_modules"
10
+ rm -fr node_modules
11
+ popd > /dev/null
12
+
13
+ pushd "${gitroot}/packages" > /dev/null
14
+
15
+ # Loop through all subdirectories
16
+ for dir in */; do
17
+ if [ -d "$dir" ]; then
18
+ echo "Cleaning up $dir"
19
+ # Remove dist directory if it exists
20
+ if [ -d "${dir}dist" ]; then
21
+ echo "Removing ${dir}dist"
22
+ rm -rf "${dir}dist"
23
+ fi
24
+ # Remove node_modules directory if it exists
25
+ if [ -d "${dir}node_modules" ]; then
26
+ echo "Removing ${dir}node_modules"
27
+ rm -rf "${dir}node_modules"
28
+ fi
29
+ # Remove tsconfig.tsbuildinfo file if it exists
30
+ if [ -f "${dir}tsconfig.tsbuildinfo" ]; then
31
+ echo "Removing ${dir}tsconfig.tsbuildinfo"
32
+ rm -f "${dir}tsconfig.tsbuildinfo"
33
+ fi
34
+ fi
35
+ done
36
+
37
+ echo "Cleanup complete."
38
+ popd > /dev/null
package/tsconfig.json CHANGED
@@ -20,6 +20,12 @@
20
20
  {
21
21
  "path": "packages/metamask_signer"
22
22
  },
23
+ {
24
+ "path": "packages/permissions"
25
+ },
26
+ {
27
+ "path": "packages/react-mui-connect-button"
28
+ },
23
29
  {
24
30
  "path": "packages/tari_permissions"
25
31
  },
@@ -1,2 +0,0 @@
1
- export * from "./tari_permissions";
2
- export * from "./helpers";