@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.
- 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 +1 -1
- 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 +2 -2
- package/packages/builders/package.json +2 -2
- package/packages/builders/src/transaction/TransactionBuilder.ts +4 -12
- 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 +2 -14
- 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_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/tsconfig.json +4 -2
- package/packages/tarijs_types/package.json +2 -2
- package/packages/wallet_daemon/package.json +2 -2
- package/packages/wallet_daemon/src/provider.ts +8 -6
- package/packages/wallet_daemon/src/signer.ts +11 -6
- package/packages/wallet_daemon/tsconfig.json +1 -1
- package/packages/walletconnect/package.json +3 -2
- package/packages/walletconnect/src/index.ts +52 -26
- 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/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
package/packages/{tari_permissions/src/tari_permissions.ts → permissions/src/permissions.ts}
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export class Hash {
|
|
2
2
|
private value: number[];
|
|
3
|
+
|
|
3
4
|
constructor(value: number[]) {
|
|
4
5
|
this.value = value;
|
|
5
6
|
}
|
|
7
|
+
|
|
6
8
|
toJSON() {
|
|
7
9
|
return this.value;
|
|
8
10
|
}
|
|
@@ -21,10 +23,12 @@ export enum TAG {
|
|
|
21
23
|
export class Tagged {
|
|
22
24
|
private value: any;
|
|
23
25
|
private tag: number;
|
|
26
|
+
|
|
24
27
|
constructor(tag: number, value: any) {
|
|
25
28
|
this.tag = tag;
|
|
26
29
|
this.value = value;
|
|
27
30
|
}
|
|
31
|
+
|
|
28
32
|
toJSON() {
|
|
29
33
|
return { "@@TAGGED@@": [this.tag, this.value] };
|
|
30
34
|
}
|
|
@@ -32,9 +36,11 @@ export class Tagged {
|
|
|
32
36
|
|
|
33
37
|
export class ResourceAddress {
|
|
34
38
|
private tagged: Tagged;
|
|
39
|
+
|
|
35
40
|
constructor(hash: Hash) {
|
|
36
41
|
this.tagged = new Tagged(TAG.ResourceAddress, hash);
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
toJSON() {
|
|
39
45
|
return this.tagged.toJSON();
|
|
40
46
|
}
|
|
@@ -42,9 +48,11 @@ export class ResourceAddress {
|
|
|
42
48
|
|
|
43
49
|
export class UnclaimedConfidentialOutputAddress {
|
|
44
50
|
private hash: Hash;
|
|
51
|
+
|
|
45
52
|
constructor(hash: Hash) {
|
|
46
53
|
this.hash = hash;
|
|
47
54
|
}
|
|
55
|
+
|
|
48
56
|
toJSON() {
|
|
49
57
|
return this.hash.toJSON();
|
|
50
58
|
}
|
|
@@ -52,11 +60,14 @@ export class UnclaimedConfidentialOutputAddress {
|
|
|
52
60
|
|
|
53
61
|
export type u64 = number;
|
|
54
62
|
export type u32 = number;
|
|
63
|
+
|
|
55
64
|
export class U256 {
|
|
56
65
|
private value: number[];
|
|
66
|
+
|
|
57
67
|
constructor(value: number[]) {
|
|
58
68
|
this.value = value;
|
|
59
69
|
}
|
|
70
|
+
|
|
60
71
|
toJSON() {
|
|
61
72
|
return this.value;
|
|
62
73
|
}
|
|
@@ -66,9 +77,11 @@ export type NonFungibleIdType = u32 | u64 | string | U256;
|
|
|
66
77
|
|
|
67
78
|
export class NonFungibleId {
|
|
68
79
|
private value: NonFungibleIdType;
|
|
80
|
+
|
|
69
81
|
constructor(value: NonFungibleIdType) {
|
|
70
82
|
this.value = value;
|
|
71
83
|
}
|
|
84
|
+
|
|
72
85
|
toJSON() {
|
|
73
86
|
switch (typeof this.value) {
|
|
74
87
|
case "string":
|
|
@@ -83,10 +96,12 @@ export class NonFungibleId {
|
|
|
83
96
|
export class NonFungibleAddressContents {
|
|
84
97
|
private resource_address: ResourceAddress;
|
|
85
98
|
private id: NonFungibleId;
|
|
99
|
+
|
|
86
100
|
constructor(resource_address: ResourceAddress, id: NonFungibleId) {
|
|
87
101
|
this.resource_address = resource_address;
|
|
88
102
|
this.id = id;
|
|
89
103
|
}
|
|
104
|
+
|
|
90
105
|
toJSON() {
|
|
91
106
|
return { resource_address: this.resource_address, id: this.id };
|
|
92
107
|
}
|
|
@@ -94,9 +109,11 @@ export class NonFungibleAddressContents {
|
|
|
94
109
|
|
|
95
110
|
export class NonFungibleAddress {
|
|
96
111
|
private tagged: Tagged;
|
|
112
|
+
|
|
97
113
|
constructor(value: NonFungibleAddressContents) {
|
|
98
114
|
this.tagged = new Tagged(TAG.NonFungibleAddress, value);
|
|
99
115
|
}
|
|
116
|
+
|
|
100
117
|
toJSON() {
|
|
101
118
|
return this.tagged.toJSON();
|
|
102
119
|
}
|
|
@@ -105,9 +122,11 @@ export class NonFungibleAddress {
|
|
|
105
122
|
|
|
106
123
|
export class ComponentAddress {
|
|
107
124
|
private tagged: Tagged;
|
|
125
|
+
|
|
108
126
|
constructor(hash: Hash) {
|
|
109
127
|
this.tagged = new Tagged(TAG.ComponentAddress, hash);
|
|
110
128
|
}
|
|
129
|
+
|
|
111
130
|
toJSON() {
|
|
112
131
|
return this.tagged.toJSON();
|
|
113
132
|
}
|
|
@@ -115,9 +134,11 @@ export class ComponentAddress {
|
|
|
115
134
|
|
|
116
135
|
export class VaultId {
|
|
117
136
|
private tagged: Tagged;
|
|
137
|
+
|
|
118
138
|
constructor(hash: Hash) {
|
|
119
139
|
this.tagged = new Tagged(TAG.VaultId, hash);
|
|
120
140
|
}
|
|
141
|
+
|
|
121
142
|
toJSON() {
|
|
122
143
|
return this.tagged.toJSON();
|
|
123
144
|
}
|
|
@@ -132,9 +153,11 @@ export type SubstateAddressType =
|
|
|
132
153
|
|
|
133
154
|
export class SubstateAddress {
|
|
134
155
|
private value: SubstateAddressType;
|
|
156
|
+
|
|
135
157
|
constructor(value: SubstateAddressType) {
|
|
136
158
|
this.value = value;
|
|
137
159
|
}
|
|
160
|
+
|
|
138
161
|
toJSON() {
|
|
139
162
|
if (this.value instanceof ComponentAddress) {
|
|
140
163
|
return { Component: this.value };
|
|
@@ -151,9 +174,11 @@ export class SubstateAddress {
|
|
|
151
174
|
|
|
152
175
|
export class TariPermissionAccountBalance {
|
|
153
176
|
private value: SubstateAddress;
|
|
177
|
+
|
|
154
178
|
constructor(value: SubstateAddress) {
|
|
155
179
|
this.value = value;
|
|
156
180
|
}
|
|
181
|
+
|
|
157
182
|
toJSON() {
|
|
158
183
|
console.log("stringify", this.value);
|
|
159
184
|
return { AccountBalance: this.value };
|
|
@@ -161,7 +186,9 @@ export class TariPermissionAccountBalance {
|
|
|
161
186
|
}
|
|
162
187
|
|
|
163
188
|
export class TariPermissionAccountInfo {
|
|
164
|
-
constructor() {
|
|
189
|
+
constructor() {
|
|
190
|
+
}
|
|
191
|
+
|
|
165
192
|
toJSON() {
|
|
166
193
|
return "AccountInfo";
|
|
167
194
|
}
|
|
@@ -169,6 +196,7 @@ export class TariPermissionAccountInfo {
|
|
|
169
196
|
|
|
170
197
|
export class TariPermissionAccountList {
|
|
171
198
|
private value?: ComponentAddress | null;
|
|
199
|
+
|
|
172
200
|
constructor(value?: ComponentAddress) {
|
|
173
201
|
if (value === undefined) {
|
|
174
202
|
this.value = null;
|
|
@@ -176,6 +204,7 @@ export class TariPermissionAccountList {
|
|
|
176
204
|
this.value = value;
|
|
177
205
|
}
|
|
178
206
|
}
|
|
207
|
+
|
|
179
208
|
toJSON() {
|
|
180
209
|
console.log("JSON TariPermissionAccountList", this.value);
|
|
181
210
|
if (this.value === undefined) {
|
|
@@ -187,23 +216,30 @@ export class TariPermissionAccountList {
|
|
|
187
216
|
}
|
|
188
217
|
|
|
189
218
|
export class TariPermissionKeyList {
|
|
190
|
-
constructor() {
|
|
219
|
+
constructor() {
|
|
220
|
+
}
|
|
221
|
+
|
|
191
222
|
toJSON() {
|
|
192
223
|
return "KeyList";
|
|
193
224
|
}
|
|
194
225
|
}
|
|
195
226
|
|
|
196
227
|
export class TariPermissionTransactionGet {
|
|
197
|
-
constructor() {
|
|
228
|
+
constructor() {
|
|
229
|
+
}
|
|
230
|
+
|
|
198
231
|
toJSON() {
|
|
199
232
|
return "TransactionGet";
|
|
200
233
|
}
|
|
201
234
|
}
|
|
235
|
+
|
|
202
236
|
export class TariPermissionTransactionSend {
|
|
203
237
|
private value?: SubstateAddress;
|
|
238
|
+
|
|
204
239
|
constructor(value?: SubstateAddress) {
|
|
205
240
|
this.value = value;
|
|
206
241
|
}
|
|
242
|
+
|
|
207
243
|
toJSON() {
|
|
208
244
|
console.log("JSON TariPermissionTransactionSend", this.value);
|
|
209
245
|
if (this.value === undefined) {
|
|
@@ -217,10 +253,12 @@ export class TariPermissionTransactionSend {
|
|
|
217
253
|
export class TariPermissionGetNft {
|
|
218
254
|
private value0?: SubstateAddress;
|
|
219
255
|
private value1?: ResourceAddress;
|
|
256
|
+
|
|
220
257
|
constructor(value0?: SubstateAddress, value1?: ResourceAddress) {
|
|
221
258
|
this.value0 = value0;
|
|
222
259
|
this.value1 = value1;
|
|
223
260
|
}
|
|
261
|
+
|
|
224
262
|
toJSON() {
|
|
225
263
|
return { GetNft: [this.value0, this.value1] };
|
|
226
264
|
}
|
|
@@ -228,30 +266,38 @@ export class TariPermissionGetNft {
|
|
|
228
266
|
|
|
229
267
|
export class TariPermissionNftGetOwnershipProof {
|
|
230
268
|
private value?: ResourceAddress;
|
|
269
|
+
|
|
231
270
|
constructor(value?: ResourceAddress) {
|
|
232
271
|
this.value = value;
|
|
233
272
|
}
|
|
273
|
+
|
|
234
274
|
toJSON() {
|
|
235
275
|
return { NftGetOwnershipProof: this.value };
|
|
236
276
|
}
|
|
237
277
|
}
|
|
238
278
|
|
|
239
279
|
export class TariPermissionTransactionsGet {
|
|
240
|
-
constructor() {
|
|
280
|
+
constructor() {
|
|
281
|
+
}
|
|
282
|
+
|
|
241
283
|
toJSON() {
|
|
242
284
|
return "TransactionGet";
|
|
243
285
|
}
|
|
244
286
|
}
|
|
245
287
|
|
|
246
288
|
export class TariPermissionSubstatesRead {
|
|
247
|
-
constructor() {
|
|
289
|
+
constructor() {
|
|
290
|
+
}
|
|
291
|
+
|
|
248
292
|
toJSON() {
|
|
249
293
|
return "SubstatesRead";
|
|
250
294
|
}
|
|
251
295
|
}
|
|
252
296
|
|
|
253
297
|
export class TariPermissionTemplatesRead {
|
|
254
|
-
constructor() {
|
|
298
|
+
constructor() {
|
|
299
|
+
}
|
|
300
|
+
|
|
255
301
|
toJSON() {
|
|
256
302
|
return "TemplatesRead";
|
|
257
303
|
}
|
|
@@ -302,6 +348,10 @@ export class TariPermissions {
|
|
|
302
348
|
return this;
|
|
303
349
|
}
|
|
304
350
|
|
|
351
|
+
getPermissions(): TariPermission[] {
|
|
352
|
+
return this.permissions;
|
|
353
|
+
}
|
|
354
|
+
|
|
305
355
|
toJSON() {
|
|
306
356
|
return this.permissions;
|
|
307
357
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
language: "typescript"
|
|
2
|
+
platform: "node"
|
|
3
|
+
type: "library"
|
|
4
|
+
|
|
5
|
+
fileGroups:
|
|
6
|
+
configs:
|
|
7
|
+
- "tsconfig.json"
|
|
8
|
+
- "package.json"
|
|
9
|
+
- "eslint.config.ts"
|
|
10
|
+
sources:
|
|
11
|
+
- "src/**/*"
|
|
12
|
+
tests:
|
|
13
|
+
- "integration-tests/**/*"
|
|
14
|
+
|
|
15
|
+
tasks:
|
|
16
|
+
build:
|
|
17
|
+
command: "pnpm run build"
|
|
18
|
+
inputs:
|
|
19
|
+
- "@files(sources)"
|
|
20
|
+
- "@files(configs)"
|
|
21
|
+
outputs:
|
|
22
|
+
- "dist"
|
|
23
|
+
format:
|
|
24
|
+
command: "pnpm run format"
|
|
25
|
+
inputs:
|
|
26
|
+
- "@files(sources)"
|
|
27
|
+
- "@files(configs)"
|
|
28
|
+
- "@files(tests)"
|
|
29
|
+
options:
|
|
30
|
+
runInCI: false
|
|
31
|
+
lint:
|
|
32
|
+
command: "pnpm run lint:fix"
|
|
33
|
+
inputs:
|
|
34
|
+
- "@files(sources)"
|
|
35
|
+
- "@files(configs)"
|
|
36
|
+
- "@files(tests)"
|
|
37
|
+
options:
|
|
38
|
+
runInCI: false
|
|
39
|
+
deps:
|
|
40
|
+
- "build"
|
|
41
|
+
|
|
42
|
+
lintCheck:
|
|
43
|
+
command: "pnpm run lint"
|
|
44
|
+
inputs:
|
|
45
|
+
- "@files(sources)"
|
|
46
|
+
- "@files(configs)"
|
|
47
|
+
- "@files(tests)"
|
|
48
|
+
deps:
|
|
49
|
+
- "build"
|
|
50
|
+
formatCheck:
|
|
51
|
+
command: "pnpm run format:check"
|
|
52
|
+
inputs:
|
|
53
|
+
- "@files(sources)"
|
|
54
|
+
- "@files(configs)"
|
|
55
|
+
- "@files(tests)"
|
|
56
|
+
test:
|
|
57
|
+
command: "pnpm run test"
|
|
58
|
+
inputs:
|
|
59
|
+
- "@files(sources)"
|
|
60
|
+
- "@files(tests)"
|
|
61
|
+
- "@files(configs)"
|
|
62
|
+
deps:
|
|
63
|
+
- "build"
|
|
64
|
+
integration-test:
|
|
65
|
+
command: "pnpm run integration-tests"
|
|
66
|
+
inputs:
|
|
67
|
+
- "@files(sources)"
|
|
68
|
+
- "@files(tests)"
|
|
69
|
+
- "@files(configs)"
|
|
70
|
+
deps:
|
|
71
|
+
- "build"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tari-project/react-mui-connect-button",
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "React component to connect your website to the Tari Ootle Wallet",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -b",
|
|
11
|
+
"test": "echo 'no tests'",
|
|
12
|
+
"integration-tests": "vitest run integration-tests"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@tari-project/tari-permissions": "workspace:^",
|
|
19
|
+
"@tari-project/tari-signer": "workspace:^",
|
|
20
|
+
"@tari-project/tari-provider": "workspace:^",
|
|
21
|
+
"@tari-project/wallet-connect-signer": "workspace:^",
|
|
22
|
+
"@tari-project/wallet-daemon-signer": "workspace:^"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@mui/icons-material": "^7",
|
|
26
|
+
"@mui/material": "^7",
|
|
27
|
+
"react": "^18 || ^19"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "catalog:",
|
|
31
|
+
"@types/react": "^19.1.8",
|
|
32
|
+
"@types/react-dom": "^19.1.6",
|
|
33
|
+
"typescript": "catalog:"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"/dist"
|
|
37
|
+
],
|
|
38
|
+
"main": "dist/index.js",
|
|
39
|
+
"types": "dist/index.d.ts"
|
|
40
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function TariLogo() {
|
|
2
|
+
return (<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<title>node-icon</title>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient x1="18.2919102%" y1="10.0218476%" x2="75.2362057%" y2="77.3326874%" id="linearGradient-1">
|
|
6
|
+
<stop stopColor="#6239FF" offset="0%"></stop>
|
|
7
|
+
<stop stopColor="#C326D6" offset="100%"></stop>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
<g id="Final-Designs" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
|
11
|
+
<g id="Icons">
|
|
12
|
+
<g id="node-icon">
|
|
13
|
+
<polygon id="Path" points="0 0 25 0 25 25 0 25"></polygon>
|
|
14
|
+
<path
|
|
15
|
+
d="M20.1635307,8.81670631 L20.1635307,11.1649473 L6.39264373,7.6223935 L11.0366915,4.59938041 L20.1635307,8.81670631 Z M11.8116251,18.6587023 L11.8116251,10.9999256 L19.1635161,12.8911326 L11.8116251,18.6587023 Z M9.89076494,17.9185993 L4.8364693,12.2747253 L4.8364693,9.20558518 L9.89076494,10.5058018 L9.89076494,17.9185993 Z M2.91551501,7.5936818 L2.91551501,13.0091801 L10.8424874,21.8606694 L22.084485,13.0410925 L22.084485,7.58822187 L10.8784476,2.41013641 L2.91551501,7.5936818 Z"
|
|
16
|
+
fill="url(#linearGradient-1)"></path>
|
|
17
|
+
</g>
|
|
18
|
+
</g>
|
|
19
|
+
</g>
|
|
20
|
+
</svg>);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function TariLogoWhite() {
|
|
24
|
+
return (<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
25
|
+
<title>node-icon</title>
|
|
26
|
+
<defs>
|
|
27
|
+
<linearGradient x1="18.2919102%" y1="10.0218476%" x2="75.2362057%" y2="77.3326874%" id="linearGradient-1">
|
|
28
|
+
<stop stopColor="#FFFFFF" offset="0%"></stop>
|
|
29
|
+
<stop stopColor="#FFFFFF" offset="100%"></stop>
|
|
30
|
+
</linearGradient>
|
|
31
|
+
</defs>
|
|
32
|
+
<g id="Final-Designs" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
|
33
|
+
<g id="Icons">
|
|
34
|
+
<g id="node-icon">
|
|
35
|
+
<polygon id="Path" points="0 0 25 0 25 25 0 25"></polygon>
|
|
36
|
+
<path
|
|
37
|
+
d="M20.1635307,8.81670631 L20.1635307,11.1649473 L6.39264373,7.6223935 L11.0366915,4.59938041 L20.1635307,8.81670631 Z M11.8116251,18.6587023 L11.8116251,10.9999256 L19.1635161,12.8911326 L11.8116251,18.6587023 Z M9.89076494,17.9185993 L4.8364693,12.2747253 L4.8364693,9.20558518 L9.89076494,10.5058018 L9.89076494,17.9185993 Z M2.91551501,7.5936818 L2.91551501,13.0091801 L10.8424874,21.8606694 L22.084485,13.0410925 L22.084485,7.58822187 L10.8784476,2.41013641 L2.91551501,7.5936818 Z"
|
|
38
|
+
fill="url(#linearGradient-1)"></path>
|
|
39
|
+
</g>
|
|
40
|
+
</g>
|
|
41
|
+
</g>
|
|
42
|
+
</svg>);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function WalletConnectLogo() {
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<svg version="1.1" baseProfile="basic" id="Layer_1"
|
|
49
|
+
xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
|
50
|
+
viewBox="0 0 387.6 237.6">
|
|
51
|
+
<path id="WalletConnect_00000073703063438220642730000002917717552236472496_" fill="#3B99FC" d="M79.4,46.4
|
|
52
|
+
c63.2-61.9,165.7-61.9,228.9,0l7.6,7.4c3.2,3.1,3.2,8.1,0,11.2l-26,25.5c-1.6,1.5-4.1,1.5-5.7,0l-10.5-10.3
|
|
53
|
+
c-44.1-43.2-115.6-43.2-159.7,0l-11.2,11c-1.6,1.5-4.1,1.5-5.7,0L71,65.8c-3.2-3.1-3.2-8.1,0-11.2L79.4,46.4z M362.1,99.1l23.2,22.7
|
|
54
|
+
c3.2,3.1,3.2,8.1,0,11.2L280.8,235.3c-3.2,3.1-8.3,3.1-11.4,0c0,0,0,0,0,0l-74.1-72.6c-0.8-0.8-2.1-0.8-2.9,0c0,0,0,0,0,0
|
|
55
|
+
l-74.1,72.6c-3.2,3.1-8.3,3.1-11.4,0c0,0,0,0,0,0L2.4,133c-3.2-3.1-3.2-8.1,0-11.2l23.2-22.7c3.2-3.1,8.3-3.1,11.4,0l74.1,72.6
|
|
56
|
+
c0.8,0.8,2.1,0.8,2.9,0c0,0,0,0,0,0l74.1-72.6c3.2-3.1,8.3-3.1,11.4,0c0,0,0,0,0,0l74.1,72.6c0.8,0.8,2.1,0.8,2.9,0l74.1-72.6
|
|
57
|
+
C353.8,96,358.9,96,362.1,99.1z" />
|
|
58
|
+
</svg>);
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import Button from "@mui/material/Button";
|
|
4
|
+
import { TariWalletSelectionDialog } from "./TariWalletSelectionDialog";
|
|
5
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
6
|
+
import { TariLogoWhite } from "./Logos";
|
|
7
|
+
import { WalletDaemonFetchParameters } from "@tari-project/wallet-daemon-signer";
|
|
8
|
+
import { WalletConnectParameters } from "@tari-project/wallet-connect-signer";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface TariConnectButtonProps {
|
|
12
|
+
isConnected: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onConnected?: (signer: TariSigner) => void;
|
|
15
|
+
walletConnectParams?: WalletConnectParameters,
|
|
16
|
+
walletDaemonParams?: WalletDaemonFetchParameters;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function TariConnectButton(props: TariConnectButtonProps) {
|
|
20
|
+
const [walletSelectionOpen, setWalletSelectionOpen] = React.useState(false);
|
|
21
|
+
|
|
22
|
+
const handleConnectClick = () => {
|
|
23
|
+
setWalletSelectionOpen(true);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const onWalletSelectionClose = () => {
|
|
27
|
+
setWalletSelectionOpen(false);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{!props.walletDaemonParams && !props.walletConnectParams && (
|
|
33
|
+
<div style={{ color: "red" }}>
|
|
34
|
+
<strong>Warning:</strong> You must provide a WalletConnect project ID and/or Wallet Daemon parameters to use
|
|
35
|
+
the Tari Connect Button.
|
|
36
|
+
</div>
|
|
37
|
+
)}
|
|
38
|
+
<Button variant="contained" onClick={handleConnectClick} disabled={props.disabled || false}>
|
|
39
|
+
<TariLogoWhite />
|
|
40
|
+
<div style={{ paddingLeft: "10px" }}>{props.isConnected ? "Connected" : "Connect"}</div>
|
|
41
|
+
</Button>
|
|
42
|
+
<TariWalletSelectionDialog
|
|
43
|
+
open={walletSelectionOpen}
|
|
44
|
+
onClose={onWalletSelectionClose}
|
|
45
|
+
onConnected={props.onConnected}
|
|
46
|
+
walletConnectParams={props.walletConnectParams}
|
|
47
|
+
walletDaemonParams={props.walletDaemonParams}
|
|
48
|
+
/>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Box, Dialog, Divider, Stack, IconButton, Typography, CircularProgress } from "@mui/material";
|
|
2
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
3
|
+
import Grid from "@mui/material/Grid";
|
|
4
|
+
import Card from "@mui/material/Card";
|
|
5
|
+
import CardContent from "@mui/material/CardContent";
|
|
6
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
7
|
+
import { WalletDaemonTariSigner, WalletDaemonFetchParameters } from "@tari-project/wallet-daemon-signer";
|
|
8
|
+
import { ReactElement, useState } from "react";
|
|
9
|
+
import { WalletConnectTariSigner, WalletConnectParameters } from "@tari-project/wallet-connect-signer";
|
|
10
|
+
import { TariLogo, WalletConnectLogo } from "./Logos";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export interface WalletSelectionProps {
|
|
14
|
+
open: boolean;
|
|
15
|
+
onConnected?: (signer: TariSigner) => void;
|
|
16
|
+
walletConnectParams?: WalletConnectParameters;
|
|
17
|
+
walletDaemonParams?: WalletDaemonFetchParameters;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactElement {
|
|
22
|
+
const { onClose, open, onConnected, walletConnectParams, walletDaemonParams } = props;
|
|
23
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
24
|
+
const [error, setError] = useState<string | null>(null);
|
|
25
|
+
|
|
26
|
+
const handleClose = onClose;
|
|
27
|
+
|
|
28
|
+
const onWalletDaemonClick = async () => {
|
|
29
|
+
if (!walletDaemonParams) {
|
|
30
|
+
throw new Error("Wallet Daemon parameters were not provided.");
|
|
31
|
+
}
|
|
32
|
+
const walletDaemonSigner = await WalletDaemonTariSigner.buildFetchSigner(walletDaemonParams);
|
|
33
|
+
onConnected?.(walletDaemonSigner);
|
|
34
|
+
handleClose();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const onWalletConnectClick = async () => {
|
|
38
|
+
if (!walletConnectParams?.projectId) {
|
|
39
|
+
throw new Error("WalletConnect params was not provided.");
|
|
40
|
+
}
|
|
41
|
+
setIsBusy(true);
|
|
42
|
+
setError(null);
|
|
43
|
+
try {
|
|
44
|
+
const walletConnectSigner = WalletConnectTariSigner.init(walletConnectParams);
|
|
45
|
+
const showDialog = await walletConnectSigner.connect();
|
|
46
|
+
// This must be before the showDialog call to prevent the dialog from appearing on top of the WalletConnect modal.
|
|
47
|
+
handleClose();
|
|
48
|
+
await showDialog();
|
|
49
|
+
onConnected?.(walletConnectSigner);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.error("Error connecting to WalletConnect:", err);
|
|
52
|
+
setError(`Failed to connect to WalletConnect. ${err instanceof Error ? err.message : String(err)}`);
|
|
53
|
+
} finally {
|
|
54
|
+
setIsBusy(false);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Dialog fullWidth={true} onClose={handleClose} open={open}>
|
|
61
|
+
|
|
62
|
+
<Box sx={{ padding: 4, borderRadius: 4 }}>
|
|
63
|
+
<Stack direction="row" justifyContent="space-between" spacing={2}>
|
|
64
|
+
<Typography style={{ fontSize: 24 }}>Connect a wallet</Typography>
|
|
65
|
+
<IconButton aria-label="copy" onClick={handleClose}>
|
|
66
|
+
<CloseIcon style={{ fontSize: 24 }} />
|
|
67
|
+
</IconButton>
|
|
68
|
+
</Stack>
|
|
69
|
+
<Divider sx={{ mt: 3, mb: 3 }} variant="middle" />
|
|
70
|
+
{error && (
|
|
71
|
+
<Box sx={{ padding: 2, backgroundColor: "error.main", color: "white", borderRadius: 1, marginBottom: 2 }}>
|
|
72
|
+
<Typography variant="body2">{error}</Typography>
|
|
73
|
+
</Box>
|
|
74
|
+
)}
|
|
75
|
+
<Grid container spacing={2} justifyContent="center">
|
|
76
|
+
{walletDaemonParams && (
|
|
77
|
+
<Grid size={{ xs: 4 }}>
|
|
78
|
+
<WalletConnectionMethodCard logo={<TariLogo />} text="Tari Wallet Daemon"
|
|
79
|
+
callback={onWalletDaemonClick}></WalletConnectionMethodCard>
|
|
80
|
+
</Grid>
|
|
81
|
+
)}
|
|
82
|
+
{walletConnectParams?.projectId && (
|
|
83
|
+
<Grid size={{ xs: 4 }}>
|
|
84
|
+
{isBusy ? <CircularProgress /> :
|
|
85
|
+
<WalletConnectionMethodCard
|
|
86
|
+
logo={<WalletConnectLogo />}
|
|
87
|
+
text="WalletConnect"
|
|
88
|
+
callback={onWalletConnectClick}
|
|
89
|
+
/>}
|
|
90
|
+
</Grid>
|
|
91
|
+
)}
|
|
92
|
+
</Grid>
|
|
93
|
+
</Box>
|
|
94
|
+
</Dialog>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function WalletConnectionMethodCard({ logo, text, callback }: {
|
|
99
|
+
logo: ReactElement,
|
|
100
|
+
text: string,
|
|
101
|
+
callback: () => void
|
|
102
|
+
}) {
|
|
103
|
+
return (
|
|
104
|
+
<Card variant="outlined" elevation={0}
|
|
105
|
+
sx={{ mty: 4, padding: 4, borderRadius: 4, width: "175px", height: "175px", cursor: "pointer" }}>
|
|
106
|
+
<CardContent onClick={callback}>
|
|
107
|
+
<Stack direction="column" spacing={2} alignItems="center">
|
|
108
|
+
<Box sx={{ textAlign: "center", width: "100%" }}>
|
|
109
|
+
<div style={{ borderRadius: 8, width: "50px", height: "50px" }}>{logo}</div>
|
|
110
|
+
</Box>
|
|
111
|
+
<Typography textAlign="center">{text}</Typography>
|
|
112
|
+
</Stack>
|
|
113
|
+
</CardContent>
|
|
114
|
+
</Card>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>node-icon</title>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient x1="18.2919102%" y1="10.0218476%" x2="75.2362057%" y2="77.3326874%" id="linearGradient-1">
|
|
6
|
+
<stop stop-color="#FFFFFF" offset="0%"></stop>
|
|
7
|
+
<stop stop-color="#FFFFFF" offset="100%"></stop>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
<g id="Final-Designs" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
11
|
+
<g id="Icons">
|
|
12
|
+
<g id="node-icon">
|
|
13
|
+
<polygon id="Path" points="0 0 25 0 25 25 0 25"></polygon>
|
|
14
|
+
<path d="M20.1635307,8.81670631 L20.1635307,11.1649473 L6.39264373,7.6223935 L11.0366915,4.59938041 L20.1635307,8.81670631 Z M11.8116251,18.6587023 L11.8116251,10.9999256 L19.1635161,12.8911326 L11.8116251,18.6587023 Z M9.89076494,17.9185993 L4.8364693,12.2747253 L4.8364693,9.20558518 L9.89076494,10.5058018 L9.89076494,17.9185993 Z M2.91551501,7.5936818 L2.91551501,13.0091801 L10.8424874,21.8606694 L22.084485,13.0410925 L22.084485,7.58822187 L10.8784476,2.41013641 L2.91551501,7.5936818 Z" fill="url(#linearGradient-1)"></path>
|
|
15
|
+
</g>
|
|
16
|
+
</g>
|
|
17
|
+
</g>
|
|
18
|
+
</svg>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>node-icon</title>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient x1="18.2919102%" y1="10.0218476%" x2="75.2362057%" y2="77.3326874%" id="linearGradient-1">
|
|
6
|
+
<stop stop-color="#6239FF" offset="0%"></stop>
|
|
7
|
+
<stop stop-color="#C326D6" offset="100%"></stop>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
<g id="Final-Designs" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
11
|
+
<g id="Icons">
|
|
12
|
+
<g id="node-icon">
|
|
13
|
+
<polygon id="Path" points="0 0 25 0 25 25 0 25"></polygon>
|
|
14
|
+
<path d="M20.1635307,8.81670631 L20.1635307,11.1649473 L6.39264373,7.6223935 L11.0366915,4.59938041 L20.1635307,8.81670631 Z M11.8116251,18.6587023 L11.8116251,10.9999256 L19.1635161,12.8911326 L11.8116251,18.6587023 Z M9.89076494,17.9185993 L4.8364693,12.2747253 L4.8364693,9.20558518 L9.89076494,10.5058018 L9.89076494,17.9185993 Z M2.91551501,7.5936818 L2.91551501,13.0091801 L10.8424874,21.8606694 L22.084485,13.0410925 L22.084485,7.58822187 L10.8784476,2.41013641 L2.91551501,7.5936818 Z" fill="url(#linearGradient-1)"></path>
|
|
15
|
+
</g>
|
|
16
|
+
</g>
|
|
17
|
+
</g>
|
|
18
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 25.4.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" baseProfile="basic" id="Layer_1"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 387.6 237.6"
|
|
5
|
+
xml:space="preserve">
|
|
6
|
+
<path id="WalletConnect_00000073703063438220642730000002917717552236472496_" fill="#3B99FC" d="M79.4,46.4
|
|
7
|
+
c63.2-61.9,165.7-61.9,228.9,0l7.6,7.4c3.2,3.1,3.2,8.1,0,11.2l-26,25.5c-1.6,1.5-4.1,1.5-5.7,0l-10.5-10.3
|
|
8
|
+
c-44.1-43.2-115.6-43.2-159.7,0l-11.2,11c-1.6,1.5-4.1,1.5-5.7,0L71,65.8c-3.2-3.1-3.2-8.1,0-11.2L79.4,46.4z M362.1,99.1l23.2,22.7
|
|
9
|
+
c3.2,3.1,3.2,8.1,0,11.2L280.8,235.3c-3.2,3.1-8.3,3.1-11.4,0c0,0,0,0,0,0l-74.1-72.6c-0.8-0.8-2.1-0.8-2.9,0c0,0,0,0,0,0
|
|
10
|
+
l-74.1,72.6c-3.2,3.1-8.3,3.1-11.4,0c0,0,0,0,0,0L2.4,133c-3.2-3.1-3.2-8.1,0-11.2l23.2-22.7c3.2-3.1,8.3-3.1,11.4,0l74.1,72.6
|
|
11
|
+
c0.8,0.8,2.1,0.8,2.9,0c0,0,0,0,0,0l74.1-72.6c3.2-3.1,8.3-3.1,11.4,0c0,0,0,0,0,0l74.1,72.6c0.8,0.8,2.1,0.8,2.9,0l74.1-72.6
|
|
12
|
+
C353.8,96,358.9,96,362.1,99.1z"/>
|
|
13
|
+
</svg>
|
|
File without changes
|