@tari-project/tarijs 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.github/workflows/ci.yml +2 -1
  2. package/.github/workflows/documentation-deploy.yml +44 -0
  3. package/.github/workflows/documentation-test-deploy.yml +20 -0
  4. package/.moon/workspace.yml +1 -0
  5. package/README.md +19 -0
  6. package/TODO.md +2 -6
  7. package/docusaurus/tari-docs/README.md +41 -0
  8. package/docusaurus/tari-docs/docs/index.md +21 -0
  9. package/docusaurus/tari-docs/docs/installation.md +27 -0
  10. package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
  11. package/docusaurus/tari-docs/docs/providers/indexer-provider.md +32 -0
  12. package/docusaurus/tari-docs/docs/signers/_category_.json +8 -0
  13. package/docusaurus/tari-docs/docs/signers/tari-universe.md +27 -0
  14. package/docusaurus/tari-docs/docs/signers/wallet-connect.md +51 -0
  15. package/docusaurus/tari-docs/docs/signers/wallet-daemon.md +37 -0
  16. package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
  17. package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
  18. package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
  19. package/docusaurus/tari-docs/docs/wallet/list-substates.md +68 -0
  20. package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
  21. package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
  22. package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
  23. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
  24. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
  25. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
  26. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
  27. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
  28. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
  29. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
  30. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
  31. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
  32. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
  33. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
  34. package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
  35. package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
  36. package/docusaurus/tari-docs/moon.yml +41 -0
  37. package/docusaurus/tari-docs/package.json +49 -0
  38. package/docusaurus/tari-docs/sidebars.ts +7 -0
  39. package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
  40. package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
  41. package/docusaurus/tari-docs/src/css/custom.css +30 -0
  42. package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
  43. package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
  44. package/docusaurus/tari-docs/static/.nojekyll +0 -0
  45. package/docusaurus/tari-docs/static/img/favicon.png +0 -0
  46. package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
  47. package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
  48. package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
  49. package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
  50. package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
  51. package/docusaurus/tari-docs/tsconfig.json +10 -0
  52. package/package.json +1 -1
  53. package/packages/builders/package.json +3 -3
  54. package/packages/builders/src/helpers/submitTransaction.ts +8 -8
  55. package/packages/builders/tsconfig.json +2 -4
  56. package/packages/indexer_provider/package.json +31 -0
  57. package/packages/indexer_provider/src/index.ts +2 -0
  58. package/packages/indexer_provider/src/provider.ts +105 -0
  59. package/packages/indexer_provider/src/transports/IndexerProviderClient.ts +144 -0
  60. package/packages/indexer_provider/src/transports/fetch.ts +46 -0
  61. package/packages/indexer_provider/src/transports/index.ts +3 -0
  62. package/packages/indexer_provider/src/transports/rpc.ts +19 -0
  63. package/packages/indexer_provider/tsconfig.json +22 -0
  64. package/packages/metamask_signer/moon.yml +55 -0
  65. package/packages/{metamask_provider → metamask_signer}/package.json +3 -3
  66. package/packages/{metamask_provider → metamask_signer}/src/index.ts +11 -6
  67. package/packages/metamask_signer/tsconfig.json +19 -0
  68. package/packages/tari_permissions/package.json +2 -3
  69. package/packages/tari_permissions/src/helpers.ts +33 -0
  70. package/packages/tari_permissions/src/index.ts +2 -1
  71. package/packages/tari_permissions/src/tari_permissions.ts +59 -42
  72. package/packages/tari_provider/package.json +1 -1
  73. package/packages/tari_provider/src/TariProvider.ts +7 -23
  74. package/packages/tari_provider/src/index.ts +1 -2
  75. package/packages/tari_provider/src/types.ts +38 -24
  76. package/packages/tari_signer/moon.yml +55 -0
  77. package/packages/tari_signer/package.json +28 -0
  78. package/packages/tari_signer/src/TariSigner.ts +35 -0
  79. package/packages/tari_signer/src/index.ts +2 -0
  80. package/packages/tari_signer/src/types.ts +84 -0
  81. package/packages/{metamask_provider → tari_signer}/tsconfig.json +0 -3
  82. package/packages/tari_universe/package.json +3 -3
  83. package/packages/tari_universe/src/index.ts +1 -1
  84. package/packages/tari_universe/src/{provider.ts → signer.ts} +32 -33
  85. package/packages/tari_universe/src/types.ts +15 -10
  86. package/packages/tari_universe/src/utils.ts +8 -8
  87. package/packages/tari_universe/tsconfig.json +2 -4
  88. package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +44 -44
  89. package/packages/tarijs/moon.yml +8 -0
  90. package/packages/tarijs/package.json +9 -6
  91. package/packages/tarijs/src/cbor.spec.ts +259 -0
  92. package/packages/tarijs/src/cbor.ts +114 -0
  93. package/packages/tarijs/src/index.ts +31 -15
  94. package/packages/tarijs/tsconfig.json +7 -1
  95. package/packages/tarijs_types/package.json +1 -1
  96. package/packages/tarijs_types/src/helpers/index.ts +62 -0
  97. package/packages/tarijs_types/src/index.ts +12 -1
  98. package/packages/wallet_daemon/package.json +4 -3
  99. package/packages/wallet_daemon/src/index.ts +1 -1
  100. package/packages/wallet_daemon/src/{provider.ts → signer.ts} +45 -47
  101. package/packages/wallet_daemon/tsconfig.json +4 -1
  102. package/packages/walletconnect/package.json +4 -3
  103. package/packages/walletconnect/src/index.ts +42 -43
  104. package/packages/walletconnect/tsconfig.json +4 -1
  105. package/pnpm-workspace.yaml +4 -3
  106. package/tsconfig.json +11 -2
  107. /package/packages/{metamask_provider → indexer_provider}/moon.yml +0 -0
  108. /package/packages/{metamask_provider → metamask_signer}/src/utils.ts +0 -0
@@ -1,5 +1,5 @@
1
- import { TariUniverseProvider } from "@tari-project/tari-universe-provider";
2
- import { TariProvider, SubmitTransactionRequest, SubstateRequirement } from "@tari-project/tari-provider";
1
+ import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
2
+ import { TariSigner, SubmitTransactionRequest, SubstateRequirement } from "@tari-project/tari-signer";
3
3
  import {
4
4
  Transaction,
5
5
  TransactionResult,
@@ -8,7 +8,7 @@ import {
8
8
  UpSubstates,
9
9
  FinalizeResultStatus,
10
10
  TxResultAccept,
11
- SubmitTxResult
11
+ SubmitTxResult,
12
12
  } from "@tari-project/tarijs-types";
13
13
 
14
14
  export function buildTransactionRequest(
@@ -40,12 +40,12 @@ export function buildTransactionRequest(
40
40
  }
41
41
 
42
42
  export async function submitAndWaitForTransaction(
43
- provider: TariProvider,
43
+ signer: TariSigner,
44
44
  req: SubmitTransactionRequest,
45
45
  ): Promise<SubmitTxResult> {
46
46
  try {
47
- const response = await provider.submitTransaction(req);
48
- const result = await waitForTransactionResult(provider, response.transaction_id);
47
+ const response = await signer.submitTransaction(req);
48
+ const result = await waitForTransactionResult(signer, response.transaction_id);
49
49
 
50
50
  return {
51
51
  response,
@@ -57,12 +57,12 @@ export async function submitAndWaitForTransaction(
57
57
  }
58
58
 
59
59
  export async function waitForTransactionResult(
60
- provider: TariProvider | TariUniverseProvider,
60
+ signer: TariSigner | TariUniverseSigner,
61
61
  transactionId: string,
62
62
  ): Promise<TransactionResult> {
63
63
  // eslint-disable-next-line no-constant-condition
64
64
  while (true) {
65
- const resp = await provider.getTransactionResult(transactionId);
65
+ const resp = await signer.getTransactionResult(transactionId);
66
66
  const FINALIZED_STATUSES = [
67
67
  TransactionStatus.Accepted,
68
68
  TransactionStatus.Rejected,
@@ -7,12 +7,10 @@
7
7
  "outDir": "./dist",
8
8
  "rootDir": "./src"
9
9
  },
10
- "include": [
11
- "src/**/*"
12
- ],
10
+ "include": ["src/**/*"],
13
11
  "references": [
14
12
  {
15
- "path": "../tari_provider"
13
+ "path": "../tari_signer"
16
14
  },
17
15
  {
18
16
  "path": "../tari_universe"
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@tari-project/indexer-provider",
3
+ "version": "0.5.0",
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,2 @@
1
+ export { IndexerProvider, IndexerProviderParameters } from "./provider";
2
+ export * from "./transports";
@@ -0,0 +1,105 @@
1
+ import {
2
+ GetSubstateRequest,
3
+ ListSubstatesRequest,
4
+ ListSubstatesResponse,
5
+ Substate,
6
+ TariProvider,
7
+ TransactionResult,
8
+ } from "@tari-project/tari-provider";
9
+ import { TariPermissions } from "@tari-project/tari-permissions";
10
+ import { IndexerProviderClient } from "./transports";
11
+ import {
12
+ GetTemplateDefinitionResponse,
13
+ ListTemplatesResponse,
14
+ stringToSubstateId,
15
+ substateIdToString,
16
+ SubstatesListRequest,
17
+ } from "@tari-project/typescript-bindings";
18
+ import { convertStringToTransactionStatus } from "@tari-project/tarijs-types";
19
+
20
+ export interface IndexerProviderParameters {
21
+ indexerJrpcUrl: string;
22
+ permissions: TariPermissions;
23
+ optionalPermissions?: TariPermissions;
24
+ onConnection?: () => void;
25
+ }
26
+
27
+ export class IndexerProvider implements TariProvider {
28
+ public providerName = "IndexerProvider";
29
+ client: IndexerProviderClient;
30
+ params: IndexerProviderParameters;
31
+
32
+ private constructor(params: IndexerProviderParameters, connection: IndexerProviderClient) {
33
+ this.params = params;
34
+ this.client = connection;
35
+ }
36
+
37
+ static async build(params: IndexerProviderParameters) {
38
+ const client = IndexerProviderClient.usingFetchTransport(params.indexerJrpcUrl);
39
+ await client.getIdentity();
40
+ params.onConnection?.();
41
+ return new IndexerProvider(params, client);
42
+ }
43
+
44
+ public isConnected(): boolean {
45
+ return this.client.isConnected();
46
+ }
47
+
48
+ public async listSubstates({
49
+ filter_by_template,
50
+ filter_by_type,
51
+ limit,
52
+ offset,
53
+ }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
54
+ const resp = await this.client.listSubstates({
55
+ filter_by_template,
56
+ filter_by_type,
57
+ limit,
58
+ offset,
59
+ } as SubstatesListRequest);
60
+
61
+ const substates = resp.substates.map((s) => ({
62
+ substate_id: typeof s.substate_id === "string" ? s.substate_id : substateIdToString(s.substate_id),
63
+ module_name: s.module_name,
64
+ version: s.version,
65
+ template_address: s.template_address,
66
+ }));
67
+
68
+ return { substates };
69
+ }
70
+
71
+ public async getSubstate({ substate_address, version }: GetSubstateRequest): Promise<Substate> {
72
+ const resp = await this.client.getSubstate({
73
+ address: stringToSubstateId(substate_address),
74
+ version: version ?? null,
75
+ local_search_only: false,
76
+ });
77
+ return {
78
+ address: {
79
+ substate_id: substateIdToString(resp.address),
80
+ version: resp.version,
81
+ },
82
+ value: resp.substate,
83
+ };
84
+ }
85
+
86
+ public async listTemplates(limit: number = 0): Promise<ListTemplatesResponse> {
87
+ const resp = await this.client.listTemplates({ limit });
88
+ return resp;
89
+ }
90
+
91
+ public async getTransactionResult(transactionId: string): Promise<TransactionResult> {
92
+ const resp = await this.client.getTransactionResult({ transaction_id: transactionId });
93
+
94
+ return {
95
+ transaction_id: transactionId,
96
+ status: convertStringToTransactionStatus(resp.status),
97
+ result: resp.result,
98
+ };
99
+ }
100
+
101
+ public async getTemplateDefinition(template_address: string): Promise<GetTemplateDefinitionResponse> {
102
+ let resp = await this.client.getTemplateDefinition({ template_address });
103
+ return resp;
104
+ }
105
+ }
@@ -0,0 +1,144 @@
1
+ import {
2
+ GetEpochManagerStatsResponse,
3
+ GetNonFungibleCollectionsResponse,
4
+ GetNonFungibleCountRequest,
5
+ GetNonFungibleCountResponse,
6
+ GetNonFungiblesRequest,
7
+ GetNonFungiblesResponse,
8
+ GetRelatedTransactionsRequest,
9
+ GetRelatedTransactionsResponse,
10
+ GetTemplateDefinitionRequest,
11
+ GetTemplateDefinitionResponse,
12
+ IndexerGetIdentityResponse,
13
+ IndexerGetSubstateRequest,
14
+ IndexerGetSubstateResponse,
15
+ IndexerSubmitTransactionRequest,
16
+ IndexerSubmitTransactionResponse,
17
+ InspectSubstateRequest,
18
+ InspectSubstateResponse,
19
+ ListTemplatesRequest,
20
+ ListTemplatesResponse,
21
+ SubstatesListRequest,
22
+ SubstatesListResponse,
23
+ TransactionGetResultRequest,
24
+ TransactionGetResultResponse,
25
+ TransactionWaitResultRequest,
26
+ TransactionWaitResultResponse,
27
+ } from "@tari-project/typescript-bindings";
28
+ import { FetchRpcTransport, RpcTransport } from "./rpc";
29
+
30
+ export class IndexerProviderClient {
31
+ private token: string | null;
32
+ private transport: RpcTransport;
33
+ private id: number;
34
+ private connected: boolean;
35
+
36
+ constructor(transport: RpcTransport) {
37
+ this.token = null;
38
+ this.transport = transport;
39
+ this.id = 0;
40
+ this.connected = false;
41
+ }
42
+
43
+ public static new(transport: RpcTransport): IndexerProviderClient {
44
+ return new IndexerProviderClient(transport);
45
+ }
46
+
47
+ public static usingFetchTransport(url: string): IndexerProviderClient {
48
+ return IndexerProviderClient.new(FetchRpcTransport.new(url));
49
+ }
50
+
51
+ getTransport() {
52
+ return this.transport;
53
+ }
54
+
55
+ public isAuthenticated() {
56
+ return this.token !== null;
57
+ }
58
+
59
+ public isConnected() {
60
+ return this.connected;
61
+ }
62
+
63
+ public setToken(token: string) {
64
+ this.token = token;
65
+ }
66
+
67
+ public submitTransaction(params: IndexerSubmitTransactionRequest): Promise<IndexerSubmitTransactionResponse> {
68
+ return this.__invokeRpc("submit_transaction", params);
69
+ }
70
+
71
+ public inspectSubstate(params: InspectSubstateRequest): Promise<InspectSubstateResponse> {
72
+ return this.__invokeRpc("inspect_substate", params);
73
+ }
74
+
75
+ public getSubstate(params: IndexerGetSubstateRequest): Promise<IndexerGetSubstateResponse> {
76
+ return this.__invokeRpc("get_substate", params);
77
+ }
78
+
79
+ public listSubstates(params: SubstatesListRequest): Promise<SubstatesListResponse> {
80
+ return this.__invokeRpc("list_substates", params);
81
+ }
82
+
83
+ public listTemplates(params: ListTemplatesRequest): Promise<ListTemplatesResponse> {
84
+ return this.__invokeRpc("list_templates", params);
85
+ }
86
+
87
+ public getTemplateDefinition(params: GetTemplateDefinitionRequest): Promise<GetTemplateDefinitionResponse> {
88
+ return this.__invokeRpc("get_template_definition", params);
89
+ }
90
+
91
+ public getTransactionResult(params: TransactionGetResultRequest): Promise<TransactionGetResultResponse> {
92
+ return this.__invokeRpc("get_transaction_result", params);
93
+ }
94
+
95
+ public getSubstateTransactions(params: GetRelatedTransactionsRequest): Promise<GetRelatedTransactionsResponse> {
96
+ return this.__invokeRpc("get_substate_transactions", params);
97
+ }
98
+
99
+ public getNonFungibles(params: GetNonFungiblesRequest): Promise<GetNonFungiblesResponse> {
100
+ return this.__invokeRpc("get_non_fungibles", params);
101
+ }
102
+
103
+ public getNonFungibleCollections(): Promise<GetNonFungibleCollectionsResponse> {
104
+ return this.__invokeRpc("get_non_fungible_collections");
105
+ }
106
+
107
+ public getNonFungibleCount(params: GetNonFungibleCountRequest): Promise<GetNonFungibleCountResponse> {
108
+ return this.__invokeRpc("get_non_fungible_count", params);
109
+ }
110
+
111
+ public getEpochManagerStats(): Promise<GetEpochManagerStatsResponse> {
112
+ return this.__invokeRpc("get_epoch_manager_stats");
113
+ }
114
+
115
+ public waitForTransactionResult(params: TransactionWaitResultRequest): Promise<TransactionWaitResultResponse> {
116
+ return this.__invokeRpc("transactions.wait_result", params);
117
+ }
118
+
119
+ public async getIdentity(): Promise<IndexerGetIdentityResponse | undefined> {
120
+ try {
121
+ const res: IndexerGetIdentityResponse = await this.__invokeRpc("get_identity");
122
+ this.connected = !!res.public_key;
123
+ return res;
124
+ } catch (e) {
125
+ console.error("Failed to get Indexer identity:", e);
126
+ this.connected = false;
127
+ }
128
+ }
129
+
130
+ async __invokeRpc(method: string, params: object | null = null) {
131
+ const id = this.id++;
132
+ const response = await this.transport.sendRequest<any>(
133
+ {
134
+ method,
135
+ jsonrpc: "2.0",
136
+ id: id,
137
+ params: params || {},
138
+ },
139
+ { token: this.token ?? undefined, timeout_millis: undefined },
140
+ );
141
+
142
+ return response;
143
+ }
144
+ }
@@ -0,0 +1,46 @@
1
+ import { RpcRequest, RpcTransport, RpcTransportOptions } from "./rpc";
2
+
3
+ export default class FetchRpcTransport implements RpcTransport {
4
+ private url: string;
5
+
6
+ constructor(url: string) {
7
+ this.url = url;
8
+ }
9
+
10
+ static new(url: string) {
11
+ return new FetchRpcTransport(url);
12
+ }
13
+
14
+ async sendRequest<T>(data: RpcRequest, options: RpcTransportOptions): Promise<T> {
15
+ const headers: { [key: string]: string } = {
16
+ "Content-Type": "application/json",
17
+ };
18
+ if (options?.token) {
19
+ headers["Authorization"] = `Bearer ${options.token}`;
20
+ }
21
+
22
+ let controller = new AbortController();
23
+ let signal = controller.signal;
24
+
25
+ const timeoutId = options.timeout_millis
26
+ ? setTimeout(() => {
27
+ controller.abort("Timeout");
28
+ }, options.timeout_millis)
29
+ : null;
30
+
31
+ const response = await fetch(this.url, {
32
+ method: "POST",
33
+ body: JSON.stringify(data),
34
+ headers,
35
+ signal,
36
+ });
37
+ if (timeoutId) {
38
+ clearTimeout(timeoutId);
39
+ }
40
+ const json = await response.json();
41
+ if (json.error) {
42
+ throw new Error(`${json.error.code}: ${json.error.message}`);
43
+ }
44
+ return json.result;
45
+ }
46
+ }
@@ -0,0 +1,3 @@
1
+ export { IndexerProviderClient } from "./IndexerProviderClient";
2
+ export * from "./fetch";
3
+ export * from "./rpc";
@@ -0,0 +1,19 @@
1
+ import FetchRpcTransport from "./fetch";
2
+
3
+ export { FetchRpcTransport };
4
+
5
+ export interface RpcTransport {
6
+ sendRequest<T>(request: RpcRequest, options: RpcTransportOptions): Promise<T>;
7
+ }
8
+
9
+ export interface RpcTransportOptions {
10
+ token?: string;
11
+ timeout_millis?: number;
12
+ }
13
+
14
+ export interface RpcRequest {
15
+ id: number;
16
+ jsonrpc: string;
17
+ method: string;
18
+ params: any;
19
+ }
@@ -0,0 +1,22 @@
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
+ "references": [
12
+ {
13
+ "path": "../tari_permissions"
14
+ },
15
+ {
16
+ "path": "../tari_provider"
17
+ },
18
+ {
19
+ "path": "../tarijs_types"
20
+ }
21
+ ]
22
+ }
@@ -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)"
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "@tari-project/metamask-provider",
3
- "version": "0.4.0",
2
+ "name": "@tari-project/metamask-signer",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,7 +14,7 @@
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "@metamask/providers": "catalog:",
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
  },
@@ -1,4 +1,4 @@
1
- import { TariProvider } from "@tari-project/tari-provider";
1
+ import { TariSigner } from "@tari-project/tari-signer";
2
2
  import {
3
3
  SubmitTransactionRequest,
4
4
  TransactionResult,
@@ -8,11 +8,11 @@ import {
8
8
  TemplateDefinition,
9
9
  Substate,
10
10
  ListSubstatesResponse,
11
- Account
12
- } from "@tari-project/tari-provider";
11
+ Account,
12
+ } from "@tari-project/tari-signer";
13
13
  import { MetaMaskInpageProvider } from "@metamask/providers";
14
14
  import { connectSnap, getSnap, isFlask, Snap } from "./utils";
15
- import { SubstateType } from "@tari-project/typescript-bindings";
15
+ import { ListAccountNftRequest, ListAccountNftResponse, SubstateType } from "@tari-project/typescript-bindings";
16
16
 
17
17
  export const MetamaskNotInstalled = "METAMASK_NOT_INSTALLED";
18
18
  export const MetamaskIsNotFlask = "METAMASK_IS_NOT_FLASK";
@@ -20,8 +20,8 @@ export const TariSnapNotInstalled = "TARI_SNAP_NOT_INSTALLED";
20
20
 
21
21
  type Maybe<T> = T | null | undefined;
22
22
 
23
- export class MetamaskTariProvider implements TariProvider {
24
- public providerName = "Metamask";
23
+ export class MetamaskTariSigner implements TariSigner {
24
+ public signerName = "Metamask";
25
25
  snapId: string;
26
26
  snapVersion: string | undefined;
27
27
  metamask: MetaMaskInpageProvider;
@@ -212,6 +212,11 @@ export class MetamaskTariProvider implements TariProvider {
212
212
 
213
213
  return resp as T;
214
214
  }
215
+
216
+ public async getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse> {
217
+ const resp = (await this.metamaskRequest("getNftsList", req)) as ListAccountNftResponse;
218
+ return resp;
219
+ }
215
220
  }
216
221
 
217
222
  function convertToStatus(result: any): TransactionStatus {
@@ -0,0 +1,19 @@
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
+ "references": [
12
+ {
13
+ "path": "../tari_signer"
14
+ },
15
+ {
16
+ "path": "../tarijs_types"
17
+ }
18
+ ]
19
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-permissions",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -12,8 +12,7 @@
12
12
  "keywords": [],
13
13
  "author": "",
14
14
  "license": "ISC",
15
- "dependencies": {
16
- },
15
+ "dependencies": {},
17
16
  "devDependencies": {
18
17
  "@types/node": "catalog:",
19
18
  "typescript": "catalog:"
@@ -0,0 +1,33 @@
1
+ import {
2
+ TariPermission,
3
+ TariPermissionAccountBalance,
4
+ TariPermissionAccountInfo,
5
+ TariPermissionAccountList,
6
+ TariPermissionGetNft,
7
+ TariPermissionKeyList,
8
+ TariPermissionNftGetOwnershipProof,
9
+ TariPermissionTransactionGet,
10
+ TariPermissionTransactionSend,
11
+ } from "./tari_permissions";
12
+
13
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
+ export function createPermissionFromType(permission: any): TariPermission {
15
+ if (Object.prototype.hasOwnProperty.call(permission, "AccountBalance")) {
16
+ return new TariPermissionAccountBalance(permission.AccountBalance);
17
+ } else if (permission === "AccountInfo") {
18
+ return new TariPermissionAccountInfo();
19
+ } else if (Object.prototype.hasOwnProperty.call(permission, "AccountList")) {
20
+ return new TariPermissionAccountList(permission.AccountList);
21
+ } else if (permission == "KeyList") {
22
+ return new TariPermissionKeyList();
23
+ } else if (Object.prototype.hasOwnProperty.call(permission, "TransactionSend")) {
24
+ return new TariPermissionTransactionSend(permission.TransactionSend);
25
+ } else if (permission === "TransactionGet") {
26
+ return new TariPermissionTransactionGet();
27
+ } else if (Object.prototype.hasOwnProperty.call(permission, "GetNft")) {
28
+ return new TariPermissionGetNft(permission.GetNft);
29
+ } else if (Object.prototype.hasOwnProperty.call(permission, "NftGetOwnershipProof")) {
30
+ return new TariPermissionNftGetOwnershipProof(permission.NftGetOwnershipProof);
31
+ }
32
+ return permission;
33
+ }
@@ -1 +1,2 @@
1
- export * from './tari_permissions';
1
+ export * from "./tari_permissions";
2
+ export * from "./helpers";