@tari-project/tarijs 0.4.0 → 0.4.2

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 (167) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
  2. package/.github/PULL_REQUEST_TEMPLATE.md +27 -0
  3. package/.github/dependabot.yml +8 -0
  4. package/.github/workflows/ci.yml +26 -0
  5. package/.github/workflows/documentation-deploy.yml +44 -0
  6. package/.github/workflows/documentation-test-deploy.yml +20 -0
  7. package/.github/workflows/npm_publish.yml +26 -0
  8. package/.github/workflows/pr_signed_commits_check.yml +19 -0
  9. package/.github/workflows/pr_title.yml +30 -0
  10. package/.moon/toolchain.yml +6 -0
  11. package/.moon/workspace.yml +33 -0
  12. package/.prettierrc +12 -0
  13. package/.prototools +9 -0
  14. package/CODEOWNERS +3 -0
  15. package/README.md +66 -0
  16. package/TODO.md +12 -0
  17. package/docusaurus/tari-docs/README.md +41 -0
  18. package/docusaurus/tari-docs/docs/index.md +16 -0
  19. package/docusaurus/tari-docs/docs/installation.md +27 -0
  20. package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
  21. package/docusaurus/tari-docs/docs/providers/tari-universe.md +27 -0
  22. package/docusaurus/tari-docs/docs/providers/wallet-connect.md +52 -0
  23. package/docusaurus/tari-docs/docs/providers/wallet-daemon.md +37 -0
  24. package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
  25. package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
  26. package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
  27. package/docusaurus/tari-docs/docs/wallet/list-substates.md +69 -0
  28. package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
  29. package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
  30. package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
  31. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
  32. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
  33. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
  34. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
  35. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
  36. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
  37. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
  38. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
  39. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
  40. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
  41. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
  42. package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
  43. package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
  44. package/docusaurus/tari-docs/moon.yml +41 -0
  45. package/docusaurus/tari-docs/package.json +49 -0
  46. package/docusaurus/tari-docs/sidebars.ts +7 -0
  47. package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
  48. package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
  49. package/docusaurus/tari-docs/src/css/custom.css +30 -0
  50. package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
  51. package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
  52. package/docusaurus/tari-docs/static/.nojekyll +0 -0
  53. package/docusaurus/tari-docs/static/img/favicon.png +0 -0
  54. package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
  55. package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
  56. package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
  57. package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
  58. package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
  59. package/docusaurus/tari-docs/tsconfig.json +8 -0
  60. package/package.json +4 -28
  61. package/packages/builders/moon.yml +55 -0
  62. package/packages/builders/package.json +30 -0
  63. package/packages/builders/src/helpers/index.ts +2 -0
  64. package/packages/builders/src/helpers/submitTransaction.ts +97 -0
  65. package/packages/builders/src/helpers/workspace.ts +32 -0
  66. package/packages/builders/src/index.ts +9 -0
  67. package/packages/builders/src/transaction/TransactionBuilder.ts +276 -0
  68. package/packages/builders/src/transaction/TransactionRequest.ts +93 -0
  69. package/packages/builders/src/transaction/index.ts +2 -0
  70. package/packages/builders/tsconfig.json +24 -0
  71. package/packages/metamask_provider/moon.yml +55 -0
  72. package/packages/metamask_provider/package.json +30 -0
  73. package/packages/metamask_provider/src/index.ts +232 -0
  74. package/packages/metamask_provider/src/utils.ts +86 -0
  75. package/packages/metamask_provider/tsconfig.json +21 -0
  76. package/packages/tari_permissions/moon.yml +55 -0
  77. package/packages/tari_permissions/package.json +26 -0
  78. package/packages/tari_permissions/src/index.ts +1 -0
  79. package/packages/tari_permissions/src/tari_permissions.ts +312 -0
  80. package/packages/tari_permissions/tsconfig.json +15 -0
  81. package/packages/tari_provider/moon.yml +55 -0
  82. package/packages/tari_provider/package.json +27 -0
  83. package/packages/tari_provider/src/TariProvider.ts +34 -0
  84. package/packages/tari_provider/src/index.ts +3 -0
  85. package/packages/tari_provider/src/types.ts +84 -0
  86. package/packages/tari_provider/tsconfig.json +11 -0
  87. package/packages/tari_universe/moon.yml +55 -0
  88. package/packages/tari_universe/package.json +31 -0
  89. package/packages/tari_universe/src/index.ts +3 -0
  90. package/packages/tari_universe/src/provider.ts +120 -0
  91. package/packages/tari_universe/src/types.ts +33 -0
  92. package/packages/tari_universe/src/utils.ts +23 -0
  93. package/packages/tari_universe/tsconfig.json +24 -0
  94. package/packages/tarijs/integration-tests/.env +1 -0
  95. package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +191 -0
  96. package/packages/tarijs/moon.yml +71 -0
  97. package/packages/tarijs/package.json +40 -0
  98. package/packages/tarijs/src/cbor.spec.ts +259 -0
  99. package/packages/tarijs/src/cbor.ts +114 -0
  100. package/packages/tarijs/src/index.ts +72 -0
  101. package/packages/tarijs/src/network.ts +8 -0
  102. package/packages/tarijs/src/templates/Account.ts +98 -0
  103. package/packages/tarijs/src/templates/Pool.ts +42 -0
  104. package/packages/tarijs/src/templates/Tariswap.ts +101 -0
  105. package/packages/tarijs/src/templates/TemplateFactory.ts +22 -0
  106. package/packages/tarijs/src/templates/TestFaucet.ts +72 -0
  107. package/{dist/utils.js → packages/tarijs/src/utils.ts} +4 -3
  108. package/packages/tarijs/tsconfig.json +39 -0
  109. package/packages/tarijs/vitest.config.ts +9 -0
  110. package/packages/tarijs_types/moon.yml +55 -0
  111. package/packages/tarijs_types/package.json +27 -0
  112. package/packages/tarijs_types/src/Amount.ts +113 -0
  113. package/packages/tarijs_types/src/Arg.ts +3 -0
  114. package/packages/tarijs_types/src/ComponentAddress.ts +3 -0
  115. package/packages/tarijs_types/src/ConfidentialClaim.ts +9 -0
  116. package/packages/tarijs_types/src/ConfidentialOutput.ts +9 -0
  117. package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +10 -0
  118. package/packages/tarijs_types/src/ConfidentialStatement.ts +9 -0
  119. package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +8 -0
  120. package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +4 -0
  121. package/packages/tarijs_types/src/Epoch.ts +3 -0
  122. package/packages/tarijs_types/src/FinalizeResult.ts +17 -0
  123. package/packages/tarijs_types/src/Instruction.ts +29 -0
  124. package/packages/tarijs_types/src/ResourceAddress.ts +3 -0
  125. package/packages/tarijs_types/src/SubstateDiff.ts +9 -0
  126. package/packages/tarijs_types/src/SubstateRequirement.ts +6 -0
  127. package/packages/tarijs_types/src/TemplateAddress.ts +3 -0
  128. package/packages/tarijs_types/src/Transaction.ts +16 -0
  129. package/packages/tarijs_types/src/TransactionId.ts +4 -0
  130. package/packages/tarijs_types/src/TransactionResult.ts +26 -0
  131. package/packages/tarijs_types/src/TransactionSignature.ts +4 -0
  132. package/packages/tarijs_types/src/UnsignedTransaction.ts +15 -0
  133. package/packages/tarijs_types/src/VersionedSubstateId.ts +6 -0
  134. package/packages/tarijs_types/src/ViewableBalanceProof.ts +12 -0
  135. package/packages/tarijs_types/src/Workspace.ts +3 -0
  136. package/packages/tarijs_types/src/index.ts +25 -0
  137. package/packages/tarijs_types/tsconfig.json +15 -0
  138. package/packages/wallet_daemon/moon.yml +55 -0
  139. package/packages/wallet_daemon/package.json +29 -0
  140. package/packages/wallet_daemon/src/index.ts +5 -0
  141. package/packages/wallet_daemon/src/provider.ts +263 -0
  142. package/packages/wallet_daemon/src/webrtc.ts +229 -0
  143. package/packages/wallet_daemon/src/webrtc_transport.ts +27 -0
  144. package/packages/wallet_daemon/tsconfig.json +21 -0
  145. package/packages/walletconnect/moon.yml +55 -0
  146. package/packages/walletconnect/package.json +32 -0
  147. package/packages/walletconnect/src/index.ts +274 -0
  148. package/packages/walletconnect/tsconfig.json +21 -0
  149. package/pnpm-workspace.yaml +15 -0
  150. package/tsconfig.json +45 -0
  151. package/dist/index.d.ts +0 -14
  152. package/dist/index.js +0 -13
  153. package/dist/network.d.ts +0 -8
  154. package/dist/network.js +0 -9
  155. package/dist/templates/Account.d.ts +0 -65
  156. package/dist/templates/Account.js +0 -31
  157. package/dist/templates/Pool.d.ts +0 -29
  158. package/dist/templates/Pool.js +0 -20
  159. package/dist/templates/Tariswap.d.ts +0 -64
  160. package/dist/templates/Tariswap.js +0 -36
  161. package/dist/templates/TemplateFactory.d.ts +0 -9
  162. package/dist/templates/TemplateFactory.js +0 -18
  163. package/dist/templates/TestFaucet.d.ts +0 -49
  164. package/dist/templates/TestFaucet.js +0 -31
  165. package/dist/templates/index.js +0 -5
  166. package/dist/utils.d.ts +0 -2
  167. /package/{dist/templates/index.d.ts → packages/tarijs/src/templates/index.ts} +0 -0
@@ -0,0 +1,312 @@
1
+ export class Hash {
2
+ private value: number[];
3
+ constructor(value: number[]) {
4
+ this.value = value;
5
+ }
6
+ toJSON() {
7
+ return this.value;
8
+ }
9
+ }
10
+
11
+ export enum TAG {
12
+ ComponentAddress = 128,
13
+ Metadata = 129,
14
+ NonFungibleAddress = 130,
15
+ ResourceAddress = 131,
16
+ VaultId = 132,
17
+ TransactionReceipt = 134,
18
+ FeeClaim = 135,
19
+ }
20
+
21
+ export class Tagged {
22
+ private value: any;
23
+ private tag: number;
24
+ constructor(tag: number, value: any) {
25
+ this.tag = tag;
26
+ this.value = value;
27
+ }
28
+ toJSON() {
29
+ return { "@@TAGGED@@": [this.tag, this.value] }
30
+ }
31
+ }
32
+
33
+
34
+ export class ResourceAddress {
35
+ private tagged: Tagged;
36
+ constructor(hash: Hash) {
37
+ this.tagged = new Tagged(TAG.ResourceAddress, hash);
38
+ }
39
+ toJSON() {
40
+ return this.tagged.toJSON();
41
+ }
42
+ }
43
+
44
+ export class UnclaimedConfidentialOutputAddress {
45
+ private hash: Hash;
46
+ constructor(hash: Hash) {
47
+ this.hash = hash;
48
+ }
49
+ toJSON() {
50
+ return this.hash.toJSON();
51
+ }
52
+ }
53
+
54
+ export type u64 = number;
55
+ export type u32 = number;
56
+ export class U256 {
57
+ private value: number[];
58
+ constructor(value: number[]) {
59
+ this.value = value;
60
+ }
61
+ toJSON() {
62
+ return this.value;
63
+ }
64
+ }
65
+
66
+ export type NonFungibleIdType = u32 | u64 | string | U256;
67
+
68
+ export class NonFungibleId {
69
+ private value: NonFungibleIdType;
70
+ constructor(value: NonFungibleIdType) {
71
+ this.value = value;
72
+ }
73
+ toJSON() {
74
+ switch (typeof this.value) {
75
+ case 'string':
76
+ return { 'string': this.value };
77
+ case 'number':
78
+ return { 'Uint64': this.value };
79
+ }
80
+ return { 'U256': this.value };
81
+ }
82
+ }
83
+
84
+ export class NonFungibleAddressContents {
85
+ private resource_address: ResourceAddress;
86
+ private id: NonFungibleId;
87
+ constructor(resource_address: ResourceAddress, id: NonFungibleId) {
88
+ this.resource_address = resource_address;
89
+ this.id = id;
90
+ }
91
+ toJSON() {
92
+ return { "resource_address": this.resource_address, "id": this.id }
93
+ }
94
+ }
95
+
96
+ export class NonFungibleAddress {
97
+ private tagged: Tagged;
98
+ constructor(value: NonFungibleAddressContents) {
99
+ this.tagged = new Tagged(TAG.NonFungibleAddress, value)
100
+ }
101
+ toJSON() {
102
+ return this.tagged.toJSON();
103
+ }
104
+ }
105
+
106
+ export class NonFungibleIndexAddress {
107
+ private resource_address: ResourceAddress;
108
+ private index: number;
109
+ constructor(resource_address: ResourceAddress, index: number) {
110
+ this.resource_address = resource_address;
111
+ this.index = index;
112
+ }
113
+ toJSON() {
114
+ return { "resource_address": this.resource_address, "index": this.index }
115
+ }
116
+ }
117
+
118
+ export class ComponentAddress {
119
+ private tagged: Tagged;
120
+ constructor(hash: Hash) {
121
+ this.tagged = new Tagged(TAG.ComponentAddress, hash);
122
+ }
123
+ toJSON() {
124
+ return this.tagged.toJSON()
125
+ }
126
+ }
127
+
128
+ export class VaultId {
129
+ private tagged: Tagged;
130
+ constructor(hash: Hash) {
131
+ this.tagged = new Tagged(TAG.VaultId, hash);
132
+ }
133
+ toJSON() {
134
+ return this.tagged.toJSON()
135
+ }
136
+ }
137
+
138
+ export type SubstateAddressType = ResourceAddress | ComponentAddress | VaultId | UnclaimedConfidentialOutputAddress | NonFungibleAddress | NonFungibleIndexAddress;
139
+
140
+
141
+ export class SubstateAddress {
142
+ private value: SubstateAddressType;
143
+ constructor(value: SubstateAddressType) {
144
+ this.value = value;
145
+ }
146
+ toJSON() {
147
+ if (this.value instanceof ComponentAddress) {
148
+ return { "Component": this.value }
149
+ } else if (this.value instanceof ResourceAddress) {
150
+ return { "Resource": this.value }
151
+ } else if (this.value instanceof VaultId) {
152
+ return { "Vault": this.value }
153
+ } else if (this.value instanceof UnclaimedConfidentialOutputAddress) {
154
+ return { "UnclaimedConfidentialOutput": this.value }
155
+ } else if (this.value instanceof NonFungibleAddress) {
156
+ return { "NonFungible": this.value }
157
+ } else if (this.value instanceof NonFungibleIndexAddress) {
158
+ return { "NonFungibleIndex": this.value }
159
+ }
160
+ throw "Unknown type"
161
+ }
162
+ }
163
+
164
+ export class TariPermissionAccountBalance {
165
+ private value: SubstateAddress;
166
+ constructor(value: SubstateAddress) {
167
+ this.value = value;
168
+ }
169
+ toJSON() {
170
+ console.log("stringify", this.value)
171
+ return { "AccountBalance": this.value }
172
+ }
173
+ }
174
+
175
+ export class TariPermissionAccountInfo {
176
+ constructor() {}
177
+ toJSON() {
178
+ return "AccountInfo"
179
+ }
180
+ }
181
+
182
+ export class TariPermissionAccountList {
183
+ private value?: ComponentAddress | null;
184
+ constructor(value?: ComponentAddress) {
185
+ if (value === undefined) {
186
+ this.value = null;
187
+ } else {
188
+ this.value = value;
189
+ }
190
+ }
191
+ toJSON() {
192
+ console.log('JSON TariPermissionAccountList', this.value)
193
+ if (this.value === undefined) {
194
+ return { "AccountList": null }
195
+ } else {
196
+ return { "AccountList": this.value }
197
+ }
198
+ }
199
+ }
200
+
201
+ export class TariPermissionKeyList {
202
+ constructor() {}
203
+ toJSON() {
204
+ return "KeyList"
205
+ }
206
+ }
207
+
208
+ export class TariPermissionTransactionGet {
209
+ constructor() {}
210
+ toJSON() {
211
+ return "TransactionGet"
212
+ }
213
+ }
214
+ export class TariPermissionTransactionSend {
215
+ private value?: SubstateAddress;
216
+ constructor(value?: SubstateAddress) {
217
+ this.value = value;
218
+ }
219
+ toJSON() {
220
+ console.log('JSON TariPermissionTransactionSend', this.value)
221
+ if (this.value === undefined) {
222
+ return { "TransactionSend": null }
223
+ } else {
224
+ return { "TransactionSend": this.value }
225
+ }
226
+ }
227
+ }
228
+
229
+ export class TariPermissionGetNft {
230
+ private value0?: SubstateAddress;
231
+ private value1?: ResourceAddress;
232
+ constructor(value0?: SubstateAddress, value1?: ResourceAddress) {
233
+ this.value0 = value0;
234
+ this.value1 = value1;
235
+ }
236
+ toJSON() {
237
+ return { "GetNft": [this.value0, this.value1] }
238
+ }
239
+ }
240
+
241
+ export class TariPermissionNftGetOwnershipProof {
242
+ private value?: ResourceAddress;
243
+ constructor(value?: ResourceAddress) {
244
+ this.value = value;
245
+ }
246
+ toJSON() {
247
+ return { "NftGetOwnershipProof": this.value }
248
+ }
249
+ }
250
+
251
+ export class TariPermissionTransactionsGet {
252
+ constructor() {}
253
+ toJSON() {
254
+ return "TransactionGet"
255
+ }
256
+ }
257
+
258
+ export class TariPermissionSubstatesRead {
259
+ constructor() {}
260
+ toJSON() {
261
+ return "SubstatesRead"
262
+ }
263
+ }
264
+
265
+ export class TariPermissionTemplatesRead {
266
+ constructor() {}
267
+ toJSON() {
268
+ return "TemplatesRead"
269
+ }
270
+ }
271
+
272
+ export type TariPermission = TariPermissionNftGetOwnershipProof | TariPermissionAccountBalance | TariPermissionAccountInfo | TariPermissionAccountList | TariPermissionKeyList | TariPermissionTransactionGet | TariPermissionTransactionSend | TariPermissionGetNft | TariPermissionTransactionsGet | TariPermissionSubstatesRead | TariPermissionTemplatesRead | string;
273
+
274
+ // export enum TariPermission {
275
+ // AccountBalance = "AccountBalance",
276
+ // AccountInfo = "AccountInfo",
277
+ // AccountList = "AccountList",
278
+ // KeyList = "KeyList",
279
+ // TransactionGet = "TransactionGet",
280
+ // TransactionSend = "TransactionSend",
281
+ // GetNft = "GetNft",
282
+ // NftGetOwnershipProof = "NftGetOwnershipProof",
283
+ // TransactionsGet = "TransactionsGet",
284
+ // SubstatesRead = "SubstatesRead",
285
+ // TemplatesRead = "TemplatesRead",
286
+ // }
287
+
288
+ export class TariPermissions {
289
+ private permissions: TariPermission[];
290
+
291
+ constructor() {
292
+ this.permissions = []
293
+ }
294
+
295
+ addPermission(permission: TariPermission): this {
296
+ this.permissions.push(permission);
297
+ return this;
298
+ }
299
+
300
+ addPermissions(other: TariPermissions): this {
301
+ this.permissions.push(...other.permissions);
302
+ return this;
303
+ }
304
+
305
+ toJSON() {
306
+ return this.permissions;
307
+ }
308
+ }
309
+
310
+ // TariPermissionType.prototype.toString = function () {
311
+ // return "wtf"
312
+ // }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ES2020",
5
+ "target": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "outDir": "./dist",
8
+ "rootDir": "./src"
9
+ },
10
+ "include": [
11
+ "src/**/*"
12
+ ],
13
+ "references": [
14
+ ]
15
+ }
@@ -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,27 @@
1
+ {
2
+ "name": "@tari-project/tari-provider",
3
+ "version": "0.4.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/typescript-bindings": "catalog:"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "catalog:",
20
+ "typescript": "catalog:"
21
+ },
22
+ "files": [
23
+ "/dist"
24
+ ],
25
+ "main": "dist/index.js",
26
+ "types": "dist/index.d.ts"
27
+ }
@@ -0,0 +1,34 @@
1
+ import type { SubstateType } from "@tari-project/typescript-bindings";
2
+ import {
3
+ Account,
4
+ SubmitTransactionRequest,
5
+ TransactionResult,
6
+ SubmitTransactionResponse,
7
+ VaultBalances,
8
+ TemplateDefinition,
9
+ Substate,
10
+ ListSubstatesResponse,
11
+ } from "./types";
12
+
13
+ export interface TariProvider {
14
+ providerName: string;
15
+ 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>;
34
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+
3
+ export { TariProvider } from "./TariProvider";
@@ -0,0 +1,84 @@
1
+ import { FinalizeResult } from "@tari-project/typescript-bindings";
2
+
3
+ export type SubstateMetadata = {
4
+ substate_id: string;
5
+ module_name: string | null;
6
+ version: number;
7
+ template_address: string | null;
8
+ };
9
+
10
+ export type SubstateRequirement = {
11
+ substate_id: string;
12
+ version?: number | null;
13
+ };
14
+
15
+ export type SubmitTransactionRequest = {
16
+ network: number;
17
+ account_id: number;
18
+ instructions: object[];
19
+ fee_instructions: object[];
20
+ inputs: object[];
21
+ input_refs: object[];
22
+ required_substates: SubstateRequirement[];
23
+ is_dry_run: boolean;
24
+ min_epoch: number | null;
25
+ max_epoch: number | null;
26
+ is_seal_signer_authorized: boolean;
27
+ detect_inputs_use_unversioned: boolean;
28
+ };
29
+
30
+ export type SubmitTransactionResponse = {
31
+ transaction_id: string;
32
+ };
33
+
34
+ export type TransactionResult = {
35
+ transaction_id: string;
36
+ status: TransactionStatus;
37
+ result: FinalizeResult | null;
38
+ };
39
+
40
+ export enum TransactionStatus {
41
+ New,
42
+ DryRun,
43
+ Pending,
44
+ Accepted,
45
+ Rejected,
46
+ InvalidTransaction,
47
+ OnlyFeeAccepted,
48
+ }
49
+
50
+ export interface Account {
51
+ account_id: number;
52
+ address: string;
53
+ public_key: string;
54
+ resources: VaultData[];
55
+ }
56
+
57
+ export interface VaultData {
58
+ type: string;
59
+ balance: number;
60
+ resource_address: string;
61
+ token_symbol: string;
62
+ vault_id: string;
63
+ }
64
+
65
+ export interface VaultBalances {
66
+ balances: Map<string, number | null>;
67
+ }
68
+
69
+ export interface TemplateDefinition {
70
+ // TODO: Define this type
71
+ [key: string]: any;
72
+ }
73
+
74
+ export interface Substate {
75
+ value: any;
76
+ address: {
77
+ substate_id: string;
78
+ version: number;
79
+ };
80
+ }
81
+
82
+ export type ListSubstatesResponse = {
83
+ substates: Array<SubstateMetadata>;
84
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ES2020",
5
+ "target": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "outDir": "./dist",
8
+ "rootDir": "./src"
9
+ },
10
+ "include": ["src/**/*"]
11
+ }
@@ -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,31 @@
1
+ {
2
+ "name": "@tari-project/tari-universe-provider",
3
+ "version": "0.4.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/tari-permissions": "workspace:^",
17
+ "@tari-project/tari-provider": "workspace:^",
18
+ "@tari-project/tarijs-types": "workspace:^",
19
+ "@tari-project/typescript-bindings": "catalog:",
20
+ "@tari-project/wallet_jrpc_client": "catalog:"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "catalog:",
24
+ "typescript": "catalog:"
25
+ },
26
+ "files": [
27
+ "/dist"
28
+ ],
29
+ "main": "dist/index.js",
30
+ "types": "dist/index.d.ts"
31
+ }
@@ -0,0 +1,3 @@
1
+ export * from "@tari-project/tari-permissions";
2
+ export * from "./provider";
3
+ export * from "./types";