@tari-project/tarijs 0.10.1 → 0.12.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/README.md +127 -67
- package/TODO.md +91 -3
- package/docusaurus/tari-docs/README.md +200 -17
- package/docusaurus/tari-docs/docs/api-reference.md +665 -0
- package/docusaurus/tari-docs/docs/contributing.md +619 -0
- package/docusaurus/tari-docs/docs/guides/getting-started-tutorial.md +965 -0
- package/docusaurus/tari-docs/docs/guides/production-deployment.md +977 -0
- package/docusaurus/tari-docs/docs/index.md +114 -11
- package/docusaurus/tari-docs/docs/installation.md +142 -1
- package/docusaurus/tari-docs/docs/signers/metamask.md +529 -0
- package/docusaurus/tari-docs/docs/troubleshooting.md +661 -0
- package/docusaurus/tari-docs/package.json +4 -4
- package/eslint.config.mjs +9 -0
- package/examples/vite-typescript-react/README.md +9 -0
- package/examples/vite-typescript-react/eslint.config.js +23 -0
- package/examples/vite-typescript-react/index.html +13 -0
- package/examples/vite-typescript-react/package.json +35 -0
- package/examples/vite-typescript-react/public/vite.svg +1 -0
- package/examples/vite-typescript-react/src/App.css +42 -0
- package/examples/vite-typescript-react/src/App.tsx +50 -0
- package/examples/vite-typescript-react/src/assets/react.svg +1 -0
- package/examples/vite-typescript-react/src/index.css +68 -0
- package/examples/vite-typescript-react/src/main.tsx +10 -0
- package/examples/vite-typescript-react/src/vite-env.d.ts +1 -0
- package/examples/vite-typescript-react/tsconfig.app.json +27 -0
- package/examples/vite-typescript-react/tsconfig.json +7 -0
- package/examples/vite-typescript-react/tsconfig.node.json +25 -0
- package/examples/vite-typescript-react/vite.config.ts +7 -0
- package/package.json +16 -3
- package/packages/builders/package.json +2 -2
- package/packages/builders/src/helpers/submitTransaction.ts +10 -35
- package/packages/builders/src/transaction/TransactionBuilder.ts +227 -29
- package/packages/indexer_provider/package.json +2 -2
- package/packages/indexer_provider/src/provider.ts +5 -5
- package/packages/indexer_provider/tsconfig.json +4 -2
- package/packages/metamask_signer/package.json +2 -2
- package/packages/metamask_signer/src/index.ts +3 -15
- package/packages/{tari_permissions → permissions}/package.json +2 -2
- package/packages/{tari_permissions → permissions}/src/helpers.ts +1 -1
- package/packages/permissions/src/index.ts +2 -0
- package/packages/{tari_permissions/src/tari_permissions.ts → permissions/src/permissions.ts} +56 -6
- package/packages/react-mui-connect-button/moon.yml +71 -0
- package/packages/react-mui-connect-button/package.json +40 -0
- package/packages/react-mui-connect-button/src/Logos.tsx +60 -0
- package/packages/react-mui-connect-button/src/TariConnectButton.tsx +51 -0
- package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +116 -0
- package/packages/react-mui-connect-button/src/content/tari-logo-white.svg +18 -0
- package/packages/react-mui-connect-button/src/content/tari-logo.svg +18 -0
- package/packages/react-mui-connect-button/src/content/walletconnect-logo.svg +13 -0
- package/packages/react-mui-connect-button/src/defaultPermissions.ts +0 -0
- package/packages/react-mui-connect-button/src/index.ts +24 -0
- package/packages/react-mui-connect-button/tsconfig.json +31 -0
- package/packages/tari_provider/package.json +2 -2
- package/packages/tari_provider/src/TariProvider.ts +6 -1
- package/packages/tari_signer/package.json +2 -2
- package/packages/tari_universe/package.json +2 -2
- package/packages/tari_universe/tsconfig.json +4 -2
- package/packages/tarijs/package.json +2 -2
- package/packages/tarijs/src/index.ts +27 -49
- package/packages/tarijs/src/templates/Account.ts +7 -4
- package/packages/tarijs/test/integration-tests/.env +1 -1
- package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +112 -73
- package/packages/tarijs/tsconfig.json +6 -4
- package/packages/tarijs/vitest.config.ts +2 -1
- package/packages/tarijs_types/package.json +4 -3
- package/packages/tarijs_types/src/Account.ts +68 -0
- package/packages/tarijs_types/src/Amount.ts +5 -1
- package/packages/tarijs_types/src/TransactionResult.ts +1 -8
- package/packages/tarijs_types/src/consts.ts +3 -0
- package/packages/tarijs_types/src/helpers/index.ts +4 -0
- package/packages/tarijs_types/src/helpers/simpleResult.ts +345 -0
- package/packages/tarijs_types/src/helpers/txResult.ts +1 -2
- package/packages/tarijs_types/src/index.ts +8 -0
- package/packages/tarijs_types/src/signer.ts +1 -1
- package/packages/wallet_daemon/package.json +2 -2
- package/packages/wallet_daemon/src/provider.ts +8 -6
- package/packages/wallet_daemon/src/signer.ts +18 -8
- package/packages/wallet_daemon/tsconfig.json +1 -1
- package/packages/walletconnect/package.json +3 -2
- package/packages/walletconnect/src/index.ts +54 -28
- package/packages/walletconnect/tsconfig.json +3 -0
- package/pnpm-workspace.yaml +15 -7
- package/scripts/check_versions.sh +4 -0
- package/scripts/clean_everything.sh +38 -0
- package/tsconfig.json +6 -0
- package/typedoc.json +10 -0
- package/packages/tari_permissions/src/index.ts +0 -2
- /package/packages/{tari_permissions → permissions}/moon.yml +0 -0
- /package/packages/{tari_permissions → permissions}/tsconfig.json +0 -0
|
@@ -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
|
-
|
|
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: [
|
|
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
|
-
|
|
50
|
-
wcProvider: UniversalProvider |
|
|
57
|
+
params: WalletConnectParameters;
|
|
58
|
+
wcProvider: UniversalProvider | undefined;
|
|
51
59
|
wcSession: any | null;
|
|
52
60
|
|
|
53
|
-
constructor(
|
|
54
|
-
this.
|
|
55
|
-
this.wcProvider =
|
|
61
|
+
constructor(params: WalletConnectParameters) {
|
|
62
|
+
this.params = params;
|
|
63
|
+
this.wcProvider = undefined;
|
|
56
64
|
this.wcSession = null;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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> {
|
|
@@ -126,7 +152,7 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
126
152
|
address: account.address,
|
|
127
153
|
public_key,
|
|
128
154
|
// TODO: should be vaults not resources
|
|
129
|
-
|
|
155
|
+
vaults: balances.map((b: any) => ({
|
|
130
156
|
type: b.resource_type,
|
|
131
157
|
resource_address: b.resource_address,
|
|
132
158
|
balance: b.balance + b.confidential_balance,
|
|
@@ -187,7 +213,7 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
187
213
|
account_id: res.account.key_index,
|
|
188
214
|
address: (res.account.address as { Component: string }).Component,
|
|
189
215
|
public_key: res.public_key,
|
|
190
|
-
|
|
216
|
+
vaults: [],
|
|
191
217
|
};
|
|
192
218
|
}
|
|
193
219
|
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -2,14 +2,22 @@ packages:
|
|
|
2
2
|
- packages/*
|
|
3
3
|
- apps/*
|
|
4
4
|
- docusaurus/*
|
|
5
|
-
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
'@types/node': ^22.13.1
|
|
13
|
+
'@tari-project/typescript-bindings': '>=1.14.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
package/typedoc.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entryPoints": ["packages/builders/src/index.ts"],
|
|
3
|
+
"out": "tsdocs/api",
|
|
4
|
+
"tsconfig": "./tsconfig.json",
|
|
5
|
+
"excludePrivate": true,
|
|
6
|
+
"excludeInternal": true,
|
|
7
|
+
"excludeExternals": true,
|
|
8
|
+
"plugin": ["typedoc-plugin-markdown"],
|
|
9
|
+
"includeVersion": true
|
|
10
|
+
}
|
|
File without changes
|
|
File without changes
|