@tari-project/tarijs 0.4.2 → 0.5.1

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 (91) hide show
  1. package/Dockerfile +52 -0
  2. package/README.md +37 -2
  3. package/TODO.md +0 -8
  4. package/docusaurus/tari-docs/docs/index.md +10 -5
  5. package/docusaurus/tari-docs/docs/installation.md +1 -1
  6. package/docusaurus/tari-docs/docs/providers/_category_.json +2 -2
  7. package/docusaurus/tari-docs/docs/providers/indexer-provider.md +32 -0
  8. package/docusaurus/tari-docs/docs/signers/_category_.json +8 -0
  9. package/docusaurus/tari-docs/docs/{providers → signers}/tari-universe.md +5 -5
  10. package/docusaurus/tari-docs/docs/{providers → signers}/wallet-connect.md +6 -7
  11. package/docusaurus/tari-docs/docs/{providers → signers}/wallet-daemon.md +7 -7
  12. package/docusaurus/tari-docs/docs/wallet/_category_.json +1 -1
  13. package/docusaurus/tari-docs/docs/wallet/list-substates.md +2 -3
  14. package/docusaurus/tari-docs/package.json +1 -1
  15. package/docusaurus/tari-docs/tsconfig.json +3 -1
  16. package/package.json +1 -1
  17. package/packages/builders/package.json +4 -5
  18. package/packages/builders/src/helpers/submitTransaction.ts +12 -12
  19. package/packages/builders/src/transaction/TransactionBuilder.ts +6 -7
  20. package/packages/builders/src/transaction/TransactionRequest.ts +10 -20
  21. package/packages/builders/tsconfig.json +2 -4
  22. package/packages/indexer_provider/package.json +31 -0
  23. package/packages/indexer_provider/src/index.ts +2 -0
  24. package/packages/indexer_provider/src/provider.ts +105 -0
  25. package/packages/indexer_provider/src/transports/IndexerProviderClient.ts +144 -0
  26. package/packages/indexer_provider/src/transports/fetch.ts +46 -0
  27. package/packages/indexer_provider/src/transports/index.ts +3 -0
  28. package/packages/indexer_provider/src/transports/rpc.ts +19 -0
  29. package/packages/indexer_provider/tsconfig.json +22 -0
  30. package/packages/metamask_signer/moon.yml +55 -0
  31. package/packages/{metamask_provider → metamask_signer}/package.json +3 -3
  32. package/packages/{metamask_provider → metamask_signer}/src/index.ts +42 -30
  33. package/packages/metamask_signer/tsconfig.json +19 -0
  34. package/packages/tari_permissions/package.json +2 -3
  35. package/packages/tari_permissions/src/helpers.ts +33 -0
  36. package/packages/tari_permissions/src/index.ts +2 -1
  37. package/packages/tari_permissions/src/tari_permissions.ts +59 -42
  38. package/packages/tari_provider/package.json +3 -2
  39. package/packages/tari_provider/src/TariProvider.ts +10 -25
  40. package/packages/tari_provider/src/index.ts +1 -3
  41. package/packages/tari_provider/tsconfig.json +9 -2
  42. package/packages/tari_signer/moon.yml +55 -0
  43. package/packages/tari_signer/package.json +28 -0
  44. package/packages/tari_signer/src/TariSigner.ts +30 -0
  45. package/packages/tari_signer/src/index.ts +1 -0
  46. package/packages/{metamask_provider → tari_signer}/tsconfig.json +0 -3
  47. package/packages/tari_universe/package.json +3 -3
  48. package/packages/tari_universe/src/index.ts +1 -1
  49. package/packages/tari_universe/src/{provider.ts → signer.ts} +45 -36
  50. package/packages/tari_universe/src/types.ts +10 -10
  51. package/packages/tari_universe/src/utils.ts +8 -8
  52. package/packages/tari_universe/tsconfig.json +2 -4
  53. package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +44 -44
  54. package/packages/tarijs/package.json +8 -6
  55. package/packages/tarijs/src/index.ts +39 -28
  56. package/packages/tarijs/tsconfig.json +7 -1
  57. package/packages/tarijs_types/package.json +1 -1
  58. package/packages/tarijs_types/src/ConfidentialOutput.ts +1 -1
  59. package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +1 -1
  60. package/packages/tarijs_types/src/GetTransactionResultResponse.ts +8 -0
  61. package/packages/tarijs_types/src/Instruction.ts +8 -5
  62. package/packages/tarijs_types/src/ListAccountNftFromBalancesRequest.ts +5 -0
  63. package/packages/tarijs_types/src/Transaction.ts +1 -1
  64. package/packages/tarijs_types/src/TransactionArg.ts +2 -0
  65. package/packages/tarijs_types/src/TransactionResult.ts +1 -10
  66. package/packages/tarijs_types/src/TransactionStatus.ts +9 -0
  67. package/packages/tarijs_types/src/UnsignedTransaction.ts +1 -2
  68. package/packages/tarijs_types/src/helpers/index.ts +69 -0
  69. package/packages/tarijs_types/src/index.ts +40 -11
  70. package/packages/{tari_provider/src/types.ts → tarijs_types/src/signer.ts} +17 -28
  71. package/packages/wallet_daemon/package.json +4 -3
  72. package/packages/wallet_daemon/src/index.ts +1 -1
  73. package/packages/wallet_daemon/src/{provider.ts → signer.ts} +59 -60
  74. package/packages/wallet_daemon/tsconfig.json +4 -1
  75. package/packages/walletconnect/package.json +4 -3
  76. package/packages/walletconnect/src/index.ts +56 -57
  77. package/packages/walletconnect/tsconfig.json +4 -1
  78. package/pnpm-workspace.yaml +3 -3
  79. package/tsconfig.json +8 -2
  80. package/packages/tarijs_types/src/Arg.ts +0 -3
  81. package/packages/tarijs_types/src/ComponentAddress.ts +0 -3
  82. package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +0 -10
  83. package/packages/tarijs_types/src/ConfidentialStatement.ts +0 -9
  84. package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +0 -4
  85. package/packages/tarijs_types/src/Epoch.ts +0 -3
  86. package/packages/tarijs_types/src/ResourceAddress.ts +0 -3
  87. package/packages/tarijs_types/src/TemplateAddress.ts +0 -3
  88. package/packages/tarijs_types/src/TransactionId.ts +0 -4
  89. package/packages/tarijs_types/src/ViewableBalanceProof.ts +0 -12
  90. /package/packages/{metamask_provider → indexer_provider}/moon.yml +0 -0
  91. /package/packages/{metamask_provider → metamask_signer}/src/utils.ts +0 -0
@@ -26,11 +26,10 @@ export class Tagged {
26
26
  this.value = value;
27
27
  }
28
28
  toJSON() {
29
- return { "@@TAGGED@@": [this.tag, this.value] }
29
+ return { "@@TAGGED@@": [this.tag, this.value] };
30
30
  }
31
31
  }
32
32
 
33
-
34
33
  export class ResourceAddress {
35
34
  private tagged: Tagged;
36
35
  constructor(hash: Hash) {
@@ -72,12 +71,12 @@ export class NonFungibleId {
72
71
  }
73
72
  toJSON() {
74
73
  switch (typeof this.value) {
75
- case 'string':
76
- return { 'string': this.value };
77
- case 'number':
78
- return { 'Uint64': this.value };
74
+ case "string":
75
+ return { string: this.value };
76
+ case "number":
77
+ return { Uint64: this.value };
79
78
  }
80
- return { 'U256': this.value };
79
+ return { U256: this.value };
81
80
  }
82
81
  }
83
82
 
@@ -89,14 +88,14 @@ export class NonFungibleAddressContents {
89
88
  this.id = id;
90
89
  }
91
90
  toJSON() {
92
- return { "resource_address": this.resource_address, "id": this.id }
91
+ return { resource_address: this.resource_address, id: this.id };
93
92
  }
94
93
  }
95
94
 
96
95
  export class NonFungibleAddress {
97
96
  private tagged: Tagged;
98
97
  constructor(value: NonFungibleAddressContents) {
99
- this.tagged = new Tagged(TAG.NonFungibleAddress, value)
98
+ this.tagged = new Tagged(TAG.NonFungibleAddress, value);
100
99
  }
101
100
  toJSON() {
102
101
  return this.tagged.toJSON();
@@ -111,7 +110,7 @@ export class NonFungibleIndexAddress {
111
110
  this.index = index;
112
111
  }
113
112
  toJSON() {
114
- return { "resource_address": this.resource_address, "index": this.index }
113
+ return { resource_address: this.resource_address, index: this.index };
115
114
  }
116
115
  }
117
116
 
@@ -121,7 +120,7 @@ export class ComponentAddress {
121
120
  this.tagged = new Tagged(TAG.ComponentAddress, hash);
122
121
  }
123
122
  toJSON() {
124
- return this.tagged.toJSON()
123
+ return this.tagged.toJSON();
125
124
  }
126
125
  }
127
126
 
@@ -131,12 +130,17 @@ export class VaultId {
131
130
  this.tagged = new Tagged(TAG.VaultId, hash);
132
131
  }
133
132
  toJSON() {
134
- return this.tagged.toJSON()
133
+ return this.tagged.toJSON();
135
134
  }
136
135
  }
137
136
 
138
- export type SubstateAddressType = ResourceAddress | ComponentAddress | VaultId | UnclaimedConfidentialOutputAddress | NonFungibleAddress | NonFungibleIndexAddress;
139
-
137
+ export type SubstateAddressType =
138
+ | ResourceAddress
139
+ | ComponentAddress
140
+ | VaultId
141
+ | UnclaimedConfidentialOutputAddress
142
+ | NonFungibleAddress
143
+ | NonFungibleIndexAddress;
140
144
 
141
145
  export class SubstateAddress {
142
146
  private value: SubstateAddressType;
@@ -145,19 +149,19 @@ export class SubstateAddress {
145
149
  }
146
150
  toJSON() {
147
151
  if (this.value instanceof ComponentAddress) {
148
- return { "Component": this.value }
152
+ return { Component: this.value };
149
153
  } else if (this.value instanceof ResourceAddress) {
150
- return { "Resource": this.value }
154
+ return { Resource: this.value };
151
155
  } else if (this.value instanceof VaultId) {
152
- return { "Vault": this.value }
156
+ return { Vault: this.value };
153
157
  } else if (this.value instanceof UnclaimedConfidentialOutputAddress) {
154
- return { "UnclaimedConfidentialOutput": this.value }
158
+ return { UnclaimedConfidentialOutput: this.value };
155
159
  } else if (this.value instanceof NonFungibleAddress) {
156
- return { "NonFungible": this.value }
160
+ return { NonFungible: this.value };
157
161
  } else if (this.value instanceof NonFungibleIndexAddress) {
158
- return { "NonFungibleIndex": this.value }
162
+ return { NonFungibleIndex: this.value };
159
163
  }
160
- throw "Unknown type"
164
+ throw "Unknown type";
161
165
  }
162
166
  }
163
167
 
@@ -167,15 +171,15 @@ export class TariPermissionAccountBalance {
167
171
  this.value = value;
168
172
  }
169
173
  toJSON() {
170
- console.log("stringify", this.value)
171
- return { "AccountBalance": this.value }
174
+ console.log("stringify", this.value);
175
+ return { AccountBalance: this.value };
172
176
  }
173
177
  }
174
178
 
175
179
  export class TariPermissionAccountInfo {
176
180
  constructor() {}
177
181
  toJSON() {
178
- return "AccountInfo"
182
+ return "AccountInfo";
179
183
  }
180
184
  }
181
185
 
@@ -189,11 +193,11 @@ export class TariPermissionAccountList {
189
193
  }
190
194
  }
191
195
  toJSON() {
192
- console.log('JSON TariPermissionAccountList', this.value)
196
+ console.log("JSON TariPermissionAccountList", this.value);
193
197
  if (this.value === undefined) {
194
- return { "AccountList": null }
198
+ return { AccountList: null };
195
199
  } else {
196
- return { "AccountList": this.value }
200
+ return { AccountList: this.value };
197
201
  }
198
202
  }
199
203
  }
@@ -201,14 +205,14 @@ export class TariPermissionAccountList {
201
205
  export class TariPermissionKeyList {
202
206
  constructor() {}
203
207
  toJSON() {
204
- return "KeyList"
208
+ return "KeyList";
205
209
  }
206
210
  }
207
211
 
208
212
  export class TariPermissionTransactionGet {
209
213
  constructor() {}
210
214
  toJSON() {
211
- return "TransactionGet"
215
+ return "TransactionGet";
212
216
  }
213
217
  }
214
218
  export class TariPermissionTransactionSend {
@@ -217,11 +221,11 @@ export class TariPermissionTransactionSend {
217
221
  this.value = value;
218
222
  }
219
223
  toJSON() {
220
- console.log('JSON TariPermissionTransactionSend', this.value)
224
+ console.log("JSON TariPermissionTransactionSend", this.value);
221
225
  if (this.value === undefined) {
222
- return { "TransactionSend": null }
226
+ return { TransactionSend: null };
223
227
  } else {
224
- return { "TransactionSend": this.value }
228
+ return { TransactionSend: this.value };
225
229
  }
226
230
  }
227
231
  }
@@ -234,7 +238,7 @@ export class TariPermissionGetNft {
234
238
  this.value1 = value1;
235
239
  }
236
240
  toJSON() {
237
- return { "GetNft": [this.value0, this.value1] }
241
+ return { GetNft: [this.value0, this.value1] };
238
242
  }
239
243
  }
240
244
 
@@ -244,32 +248,44 @@ export class TariPermissionNftGetOwnershipProof {
244
248
  this.value = value;
245
249
  }
246
250
  toJSON() {
247
- return { "NftGetOwnershipProof": this.value }
251
+ return { NftGetOwnershipProof: this.value };
248
252
  }
249
253
  }
250
254
 
251
255
  export class TariPermissionTransactionsGet {
252
256
  constructor() {}
253
257
  toJSON() {
254
- return "TransactionGet"
258
+ return "TransactionGet";
255
259
  }
256
260
  }
257
261
 
258
262
  export class TariPermissionSubstatesRead {
259
263
  constructor() {}
260
264
  toJSON() {
261
- return "SubstatesRead"
265
+ return "SubstatesRead";
262
266
  }
263
267
  }
264
268
 
265
269
  export class TariPermissionTemplatesRead {
266
270
  constructor() {}
267
271
  toJSON() {
268
- return "TemplatesRead"
272
+ return "TemplatesRead";
269
273
  }
270
274
  }
271
275
 
272
- export type TariPermission = TariPermissionNftGetOwnershipProof | TariPermissionAccountBalance | TariPermissionAccountInfo | TariPermissionAccountList | TariPermissionKeyList | TariPermissionTransactionGet | TariPermissionTransactionSend | TariPermissionGetNft | TariPermissionTransactionsGet | TariPermissionSubstatesRead | TariPermissionTemplatesRead | string;
276
+ export type TariPermission =
277
+ | TariPermissionNftGetOwnershipProof
278
+ | TariPermissionAccountBalance
279
+ | TariPermissionAccountInfo
280
+ | TariPermissionAccountList
281
+ | TariPermissionKeyList
282
+ | TariPermissionTransactionGet
283
+ | TariPermissionTransactionSend
284
+ | TariPermissionGetNft
285
+ | TariPermissionTransactionsGet
286
+ | TariPermissionSubstatesRead
287
+ | TariPermissionTemplatesRead
288
+ | string;
273
289
 
274
290
  // export enum TariPermission {
275
291
  // AccountBalance = "AccountBalance",
@@ -289,7 +305,7 @@ export class TariPermissions {
289
305
  private permissions: TariPermission[];
290
306
 
291
307
  constructor() {
292
- this.permissions = []
308
+ this.permissions = [];
293
309
  }
294
310
 
295
311
  addPermission(permission: TariPermission): this {
@@ -307,6 +323,7 @@ export class TariPermissions {
307
323
  }
308
324
  }
309
325
 
310
- // TariPermissionType.prototype.toString = function () {
311
- // return "wtf"
312
- // }
326
+ export type TappletPermissions = {
327
+ requiredPermissions: TariPermission[];
328
+ optionalPermissions: TariPermission[];
329
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-provider",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -13,7 +13,8 @@
13
13
  "author": "",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
- "@tari-project/typescript-bindings": "catalog:"
16
+ "@tari-project/typescript-bindings": "catalog:",
17
+ "@tari-project/tarijs-types": "workspace:^"
17
18
  },
18
19
  "devDependencies": {
19
20
  "@types/node": "catalog:",
@@ -1,34 +1,19 @@
1
- import type { SubstateType } from "@tari-project/typescript-bindings";
1
+ import type { GetTemplateDefinitionResponse, ListTemplatesResponse } from "@tari-project/typescript-bindings";
2
2
  import {
3
- Account,
4
- SubmitTransactionRequest,
5
- TransactionResult,
6
- SubmitTransactionResponse,
7
- VaultBalances,
3
+ GetTransactionResultResponse,
8
4
  TemplateDefinition,
9
5
  Substate,
10
6
  ListSubstatesResponse,
11
- } from "./types";
7
+ GetSubstateRequest,
8
+ ListSubstatesRequest,
9
+ } from "@tari-project/tarijs-types";
12
10
 
13
11
  export interface TariProvider {
14
12
  providerName: string;
15
13
  isConnected(): boolean;
16
- getAccount(): Promise<Account>;
17
- getSubstate(substate_address: string): Promise<Substate>;
18
- submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
19
- getTransactionResult(transactionId: string): Promise<TransactionResult>;
20
- getTemplateDefinition(template_address: string): Promise<TemplateDefinition>;
21
- getPublicKey(branch: string, index: number): Promise<string>;
22
- getConfidentialVaultBalances(
23
- viewKeyId: number,
24
- vaultId: string,
25
- min: number | null,
26
- max: number | null,
27
- ): Promise<VaultBalances>;
28
- listSubstates(
29
- filter_by_template: string | null,
30
- filter_by_type: SubstateType | null,
31
- limit: number | null,
32
- offset: number | null,
33
- ): Promise<ListSubstatesResponse>;
14
+ getSubstate(req: GetSubstateRequest): Promise<Substate>;
15
+ getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
16
+ getTemplateDefinition(template_address: string): Promise<GetTemplateDefinitionResponse>;
17
+ listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
18
+ listTemplates(limit?: number): Promise<ListTemplatesResponse>;
34
19
  }
@@ -1,3 +1 @@
1
- export * from "./types";
2
-
3
- export { TariProvider } from "./TariProvider";
1
+ export { TariProvider } from "./TariProvider";
@@ -7,5 +7,12 @@
7
7
  "outDir": "./dist",
8
8
  "rootDir": "./src"
9
9
  },
10
- "include": ["src/**/*"]
11
- }
10
+ "include": [
11
+ "src/**/*"
12
+ ],
13
+ "references": [
14
+ {
15
+ "path": "../tarijs_types"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,55 @@
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)"
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@tari-project/tari-signer",
3
+ "version": "0.5.1",
4
+ "description": "",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc -b"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "@tari-project/tarijs-types": "workspace:^",
17
+ "@tari-project/typescript-bindings": "catalog:"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "catalog:",
21
+ "typescript": "catalog:"
22
+ },
23
+ "files": [
24
+ "/dist"
25
+ ],
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts"
28
+ }
@@ -0,0 +1,30 @@
1
+ import type {
2
+ ConfidentialViewVaultBalanceRequest,
3
+ ListAccountNftRequest,
4
+ ListAccountNftResponse,
5
+ } from "@tari-project/typescript-bindings";
6
+ import {
7
+ GetTransactionResultResponse,
8
+ AccountData,
9
+ SubmitTransactionRequest,
10
+ SubmitTransactionResponse,
11
+ VaultBalances,
12
+ TemplateDefinition,
13
+ Substate,
14
+ ListSubstatesResponse,
15
+ ListSubstatesRequest,
16
+ } from "@tari-project/tarijs-types";
17
+
18
+ export interface TariSigner {
19
+ signerName: string;
20
+ isConnected(): boolean;
21
+ getAccount(): Promise<AccountData>;
22
+ getSubstate(substate_address: string): Promise<Substate>;
23
+ submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
24
+ getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
25
+ getTemplateDefinition(template_address: string): Promise<TemplateDefinition>;
26
+ getPublicKey(branch: string, index: number): Promise<string>;
27
+ getConfidentialVaultBalances(req: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances>;
28
+ listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
29
+ getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse>;
30
+ }
@@ -0,0 +1 @@
1
+ export { TariSigner } from "./TariSigner";
@@ -11,9 +11,6 @@
11
11
  "src/**/*"
12
12
  ],
13
13
  "references": [
14
- {
15
- "path": "../tari_provider"
16
- },
17
14
  {
18
15
  "path": "../tarijs_types"
19
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "@tari-project/tari-universe-provider",
3
- "version": "0.4.1",
2
+ "name": "@tari-project/tari-universe-signer",
3
+ "version": "0.5.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,7 +14,7 @@
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@tari-project/tari-permissions": "workspace:^",
17
- "@tari-project/tari-provider": "workspace:^",
17
+ "@tari-project/tari-signer": "workspace:^",
18
18
  "@tari-project/tarijs-types": "workspace:^",
19
19
  "@tari-project/typescript-bindings": "catalog:",
20
20
  "@tari-project/wallet_jrpc_client": "catalog:"
@@ -1,3 +1,3 @@
1
1
  export * from "@tari-project/tari-permissions";
2
- export * from "./provider";
2
+ export * from "./signer";
3
3
  export * from "./types";
@@ -1,29 +1,30 @@
1
1
  import {
2
2
  SubmitTransactionResponse,
3
- Account,
3
+ AccountData,
4
4
  Substate,
5
5
  TemplateDefinition,
6
6
  VaultBalances,
7
7
  ListSubstatesResponse,
8
8
  SubmitTransactionRequest,
9
- TariProvider,
10
- TransactionResult,
11
- } from "@tari-project/tari-provider";
9
+ ListSubstatesRequest,
10
+ GetTransactionResultResponse,
11
+ ListAccountNftFromBalancesRequest,
12
+ } from "@tari-project/tarijs-types";
13
+ import { SignerRequest, SignerMethodNames, SignerReturnType, TariUniverseSignerParameters, WindowSize } from "./types";
12
14
  import {
13
- ProviderRequest,
14
- ProviderMethodNames,
15
- ProviderReturnType,
16
- TariUniverseProviderParameters,
17
- WindowSize,
18
- } from "./types";
19
- import { AccountsGetBalancesResponse, SubstateType } from "@tari-project/wallet_jrpc_client";
20
- import { sendProviderCall } from "./utils";
21
-
22
- export class TariUniverseProvider implements TariProvider {
23
- public providerName = "TariUniverse";
15
+ AccountsGetBalancesResponse,
16
+ ConfidentialViewVaultBalanceRequest,
17
+ ListAccountNftRequest,
18
+ ListAccountNftResponse,
19
+ } from "@tari-project/wallet_jrpc_client";
20
+ import { sendSignerCall } from "./utils";
21
+ import { TariSigner } from "@tari-project/tari-signer";
22
+
23
+ export class TariUniverseSigner implements TariSigner {
24
+ public signerName = "TariUniverse";
24
25
  private __id = 0;
25
26
 
26
- public constructor(public params: TariUniverseProviderParameters) {
27
+ public constructor(public params: TariUniverseSignerParameters) {
27
28
  const filterResizeEvent = function (event: MessageEvent) {
28
29
  if (event.data && event.data.type === "resize") {
29
30
  const resizeEvent = new CustomEvent("resize", {
@@ -35,11 +36,11 @@ export class TariUniverseProvider implements TariProvider {
35
36
  window.addEventListener("message", (event) => filterResizeEvent(event), false);
36
37
  }
37
38
 
38
- private async sendRequest<MethodName extends ProviderMethodNames>(
39
- req: Omit<ProviderRequest<MethodName>, "id">,
40
- ): Promise<ProviderReturnType<MethodName>> {
39
+ private async sendRequest<MethodName extends SignerMethodNames>(
40
+ req: Omit<SignerRequest<MethodName>, "id">,
41
+ ): Promise<SignerReturnType<MethodName>> {
41
42
  const id = ++this.__id;
42
- return sendProviderCall(req, id);
43
+ return sendSignerCall(req, id);
43
44
  }
44
45
 
45
46
  public isConnected(): boolean {
@@ -50,27 +51,27 @@ export class TariUniverseProvider implements TariProvider {
50
51
  return this.sendRequest<"getPublicKey">({ methodName: "getPublicKey", args: [] });
51
52
  }
52
53
 
53
- public async listSubstates(
54
- filter_by_template: string | null,
55
- filter_by_type: SubstateType | null,
56
- limit: number | null,
57
- offset: number | null,
58
- ): Promise<ListSubstatesResponse> {
54
+ public async listSubstates({
55
+ filter_by_template,
56
+ filter_by_type,
57
+ limit,
58
+ offset,
59
+ }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
59
60
  return this.sendRequest<"listSubstates">({
60
61
  methodName: "listSubstates",
61
- args: [filter_by_template, filter_by_type, limit, offset],
62
+ args: [{ filter_by_template, filter_by_type, limit, offset }],
62
63
  });
63
64
  }
64
65
 
65
- public getConfidentialVaultBalances(
66
- viewKeyId: number,
67
- vaultId: string,
68
- min: number | null,
69
- max: number | null,
70
- ): Promise<VaultBalances> {
66
+ public getConfidentialVaultBalances({
67
+ vault_id,
68
+ maximum_expected_value,
69
+ minimum_expected_value,
70
+ view_key_id,
71
+ }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
71
72
  return this.sendRequest({
72
73
  methodName: "getConfidentialVaultBalances",
73
- args: [viewKeyId, vaultId, min, max],
74
+ args: [{ view_key_id, vault_id, minimum_expected_value, maximum_expected_value }],
74
75
  });
75
76
  }
76
77
 
@@ -82,7 +83,7 @@ export class TariUniverseProvider implements TariProvider {
82
83
  return this.sendRequest({ methodName: "requestParentSize", args: [] });
83
84
  }
84
85
 
85
- public async getAccount(): Promise<Account> {
86
+ public async getAccount(): Promise<AccountData> {
86
87
  return this.sendRequest({ methodName: "getAccount", args: [] });
87
88
  }
88
89
 
@@ -107,7 +108,7 @@ export class TariUniverseProvider implements TariProvider {
107
108
  });
108
109
  }
109
110
 
110
- public async getTransactionResult(transactionId: string): Promise<TransactionResult> {
111
+ public async getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse> {
111
112
  return this.sendRequest({
112
113
  methodName: "getTransactionResult",
113
114
  args: [transactionId],
@@ -117,4 +118,12 @@ export class TariUniverseProvider implements TariProvider {
117
118
  public async getTemplateDefinition(template_address: string): Promise<TemplateDefinition> {
118
119
  return this.sendRequest({ methodName: "getTemplateDefinition", args: [template_address] });
119
120
  }
121
+
122
+ public async getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse> {
123
+ return this.sendRequest({ methodName: "getNftsList", args: [req] });
124
+ }
125
+
126
+ public async getNftsFromAccountBalances(req: ListAccountNftFromBalancesRequest): Promise<ListAccountNftResponse> {
127
+ return this.sendRequest({ methodName: "getNftsFromAccountBalances", args: [req] });
128
+ }
120
129
  }
@@ -1,7 +1,7 @@
1
1
  import { TariPermissions } from "@tari-project/tari-permissions";
2
- import { TariUniverseProvider } from "./provider";
2
+ import { TariUniverseSigner } from "./signer";
3
3
 
4
- export type TariUniverseProviderParameters = {
4
+ export type TariUniverseSignerParameters = {
5
5
  permissions: TariPermissions;
6
6
  optionalPermissions: TariPermissions;
7
7
  name?: string;
@@ -15,19 +15,19 @@ export type WindowSize = {
15
15
 
16
16
  export type PickMatching<T, V> = { [K in keyof T as T[K] extends V ? K : never]: T[K] };
17
17
  export type ExtractMethods<T> = PickMatching<T, Function>;
18
- export type ProviderMethods = ExtractMethods<TariUniverseProvider>;
19
- export type ProviderMethodNames = keyof ProviderMethods;
20
- export type ProviderReturnType<T extends ProviderMethodNames> = Awaited<ReturnType<ProviderMethods[T]>>;
18
+ export type SignerMethods = ExtractMethods<TariUniverseSigner>;
19
+ export type SignerMethodNames = keyof SignerMethods;
20
+ export type SignerReturnType<T extends SignerMethodNames> = Awaited<ReturnType<SignerMethods[T]>>;
21
21
 
22
- export type ProviderRequest<T extends ProviderMethodNames> = {
22
+ export type SignerRequest<T extends SignerMethodNames> = {
23
23
  id: number;
24
24
  methodName: T;
25
- args: Parameters<ProviderMethods[T]>;
25
+ args: Parameters<SignerMethods[T]>;
26
26
  };
27
27
 
28
- export type ProviderResponse<T extends ProviderMethodNames> = {
28
+ export type SignerResponse<T extends SignerMethodNames> = {
29
29
  id: number;
30
- type: "provider-call";
31
- result: ProviderReturnType<T>;
30
+ type: "signer-call";
31
+ result: SignerReturnType<T>;
32
32
  resultError?: string;
33
33
  };