@tari-project/tarijs 0.5.0 → 0.5.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 (56) hide show
  1. package/Dockerfile +52 -0
  2. package/README.md +37 -2
  3. package/TODO.md +0 -4
  4. package/docusaurus/tari-docs/docs/providers/indexer-provider.md +3 -3
  5. package/docusaurus/tari-docs/package.json +1 -1
  6. package/package.json +1 -1
  7. package/packages/builders/package.json +2 -3
  8. package/packages/builders/src/helpers/submitTransaction.ts +5 -5
  9. package/packages/builders/src/transaction/TransactionBuilder.ts +6 -7
  10. package/packages/builders/src/transaction/TransactionRequest.ts +10 -20
  11. package/packages/indexer_provider/package.json +1 -1
  12. package/packages/indexer_provider/src/provider.ts +10 -10
  13. package/packages/metamask_signer/package.json +1 -1
  14. package/packages/metamask_signer/src/index.ts +34 -27
  15. package/packages/tari_permissions/package.json +1 -1
  16. package/packages/tari_provider/package.json +3 -2
  17. package/packages/tari_provider/src/TariProvider.ts +5 -5
  18. package/packages/tari_provider/src/index.ts +0 -1
  19. package/packages/tari_provider/tsconfig.json +9 -2
  20. package/packages/tari_signer/package.json +1 -1
  21. package/packages/tari_signer/src/TariSigner.ts +13 -18
  22. package/packages/tari_signer/src/index.ts +0 -1
  23. package/packages/tari_universe/package.json +1 -1
  24. package/packages/tari_universe/src/signer.ts +23 -28
  25. package/packages/tari_universe/src/types.ts +0 -5
  26. package/packages/tarijs/package.json +1 -1
  27. package/packages/tarijs/src/index.ts +12 -14
  28. package/packages/tarijs_types/package.json +1 -1
  29. package/packages/tarijs_types/src/ConfidentialOutput.ts +1 -1
  30. package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +1 -1
  31. package/packages/tarijs_types/src/GetTransactionResultResponse.ts +8 -0
  32. package/packages/tarijs_types/src/Instruction.ts +8 -5
  33. package/packages/tarijs_types/src/ListAccountNftFromBalancesRequest.ts +5 -0
  34. package/packages/tarijs_types/src/Transaction.ts +1 -1
  35. package/packages/tarijs_types/src/TransactionArg.ts +2 -0
  36. package/packages/tarijs_types/src/TransactionResult.ts +1 -10
  37. package/packages/tarijs_types/src/TransactionStatus.ts +9 -0
  38. package/packages/tarijs_types/src/UnsignedTransaction.ts +1 -2
  39. package/packages/tarijs_types/src/helpers/index.ts +11 -4
  40. package/packages/tarijs_types/src/index.ts +28 -10
  41. package/packages/{tari_provider/src/types.ts → tarijs_types/src/signer.ts} +26 -49
  42. package/packages/wallet_daemon/package.json +1 -1
  43. package/packages/wallet_daemon/src/signer.ts +33 -32
  44. package/packages/walletconnect/package.json +1 -1
  45. package/packages/walletconnect/src/index.ts +33 -33
  46. package/packages/tari_signer/src/types.ts +0 -84
  47. package/packages/tarijs_types/src/Arg.ts +0 -3
  48. package/packages/tarijs_types/src/ComponentAddress.ts +0 -3
  49. package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +0 -10
  50. package/packages/tarijs_types/src/ConfidentialStatement.ts +0 -9
  51. package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +0 -4
  52. package/packages/tarijs_types/src/Epoch.ts +0 -3
  53. package/packages/tarijs_types/src/ResourceAddress.ts +0 -3
  54. package/packages/tarijs_types/src/TemplateAddress.ts +0 -3
  55. package/packages/tarijs_types/src/TransactionId.ts +0 -4
  56. package/packages/tarijs_types/src/ViewableBalanceProof.ts +0 -12
@@ -1,27 +1,27 @@
1
- import {
2
- TariSigner,
3
- SubmitTransactionRequest,
4
- TransactionResult,
5
- SubmitTransactionResponse,
6
- VaultBalances,
7
- TemplateDefinition,
8
- Substate,
9
- Account,
10
- ListSubstatesResponse,
11
- } from "@tari-project/tari-signer";
1
+ import { TariSigner } from "@tari-project/tari-signer";
12
2
  import UniversalProvider from "@walletconnect/universal-provider";
13
3
  import { WalletConnectModal } from "@walletconnect/modal";
14
4
  import {
5
+ ConfidentialViewVaultBalanceRequest,
15
6
  Instruction,
16
7
  KeyBranch,
17
8
  ListAccountNftRequest,
18
9
  ListAccountNftResponse,
19
- stringToSubstateId,
20
10
  substateIdToString,
21
- SubstateType,
22
11
  TransactionSubmitRequest,
23
12
  } from "@tari-project/wallet_jrpc_client";
24
- import { convertStringToTransactionStatus } from "@tari-project/tarijs-types";
13
+ import {
14
+ convertStringToTransactionStatus,
15
+ GetTransactionResultResponse,
16
+ SubmitTransactionRequest,
17
+ SubmitTransactionResponse,
18
+ VaultBalances,
19
+ TemplateDefinition,
20
+ Substate,
21
+ AccountData,
22
+ ListSubstatesResponse,
23
+ ListSubstatesRequest,
24
+ } from "@tari-project/tarijs-types";
25
25
 
26
26
  const walletConnectParams = {
27
27
  requiredNamespaces: {
@@ -115,7 +115,7 @@ export class WalletConnectTariSigner implements TariSigner {
115
115
  return this.wcSession !== null;
116
116
  }
117
117
 
118
- async getAccount(): Promise<Account> {
118
+ async getAccount(): Promise<AccountData> {
119
119
  const { account, public_key } = await this.sendRequest("tari_getDefaultAccount", {});
120
120
  const { balances } = await this.sendRequest("tari_getAccountBalances", {
121
121
  account: { ComponentAddress: account.address },
@@ -151,12 +151,12 @@ export class WalletConnectTariSigner implements TariSigner {
151
151
  };
152
152
  }
153
153
 
154
- public async listSubstates(
155
- filter_by_template: string | null,
156
- filter_by_type: SubstateType | null,
157
- limit: number | null,
158
- offset: number | null,
159
- ): Promise<ListSubstatesResponse> {
154
+ public async listSubstates({
155
+ filter_by_template,
156
+ filter_by_type,
157
+ limit,
158
+ offset,
159
+ }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
160
160
  const method = "tari_listSubstates";
161
161
  const params = {
162
162
  filter_by_template,
@@ -175,7 +175,7 @@ export class WalletConnectTariSigner implements TariSigner {
175
175
  return { substates };
176
176
  }
177
177
 
178
- public async createFreeTestCoins(): Promise<Account> {
178
+ public async createFreeTestCoins(): Promise<AccountData> {
179
179
  const method = "tari_createFreeTestCoins";
180
180
  const params = {
181
181
  account: { Name: "template_web" },
@@ -222,7 +222,7 @@ export class WalletConnectTariSigner implements TariSigner {
222
222
  return { transaction_id: res.transaction_id };
223
223
  }
224
224
 
225
- async getTransactionResult(transactionId: string): Promise<TransactionResult> {
225
+ async getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse> {
226
226
  const res = await this.sendRequest("tari_getTransactionResult", { transaction_id: transactionId });
227
227
 
228
228
  return {
@@ -242,18 +242,18 @@ export class WalletConnectTariSigner implements TariSigner {
242
242
  return res.public_key;
243
243
  }
244
244
 
245
- async getConfidentialVaultBalances(
246
- viewKeyId: number,
247
- vaultId: string,
248
- min: number | null,
249
- max: number | null,
250
- ): Promise<VaultBalances> {
245
+ async getConfidentialVaultBalances({
246
+ vault_id,
247
+ view_key_id,
248
+ maximum_expected_value = null,
249
+ minimum_expected_value = null,
250
+ }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
251
251
  const method = "tari_viewConfidentialVaultBalance";
252
252
  const params = {
253
- view_key_id: viewKeyId,
254
- vault_id: vaultId,
255
- minimum_expected_value: min,
256
- maximum_expected_value: max,
253
+ view_key_id,
254
+ vault_id,
255
+ minimum_expected_value,
256
+ maximum_expected_value,
257
257
  };
258
258
 
259
259
  const res = await this.sendRequest(method, params);
@@ -1,84 +0,0 @@
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
- };
@@ -1,3 +0,0 @@
1
- //TODO refactor Arg type (https://github.com/tari-project/tari.js/issues/29)
2
- // take a look at typescript-bindings first
3
- export type Arg = any;
@@ -1,3 +0,0 @@
1
- // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
- //TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
3
- export type ComponentAddress = string;
@@ -1,10 +0,0 @@
1
- import type { Amount } from "./Amount";
2
- import type { ConfidentialStatement } from "./ConfidentialStatement";
3
-
4
- export interface ConfidentialOutputStatement {
5
- outputStatement?: ConfidentialStatement;
6
- changeStatement?: ConfidentialStatement;
7
- rangeProof: Array<number>;
8
- outputRevealedAmount: Amount;
9
- changeRevealedAmount: Amount;
10
- }
@@ -1,9 +0,0 @@
1
- import type { ViewableBalanceProof } from "./ViewableBalanceProof";
2
-
3
- export interface ConfidentialStatement {
4
- commitment: Array<number>;
5
- senderPublicNonce: Array<number>;
6
- encryptedData: Array<number>;
7
- minimumValuePromise: number;
8
- viewableBalanceProof?: ViewableBalanceProof;
9
- }
@@ -1,4 +0,0 @@
1
- export interface ElgamalVerifiableBalance {
2
- encrypted: string;
3
- public_nonce: string;
4
- }
@@ -1,3 +0,0 @@
1
- // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
- // TODO https://github.com/tari-project/tari.js/issues/29
3
- export type Epoch = number;
@@ -1,3 +0,0 @@
1
- //TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
2
-
3
- export type ResourceAddress = string;
@@ -1,3 +0,0 @@
1
- //TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
2
-
3
- export type TemplateAddress = string;
@@ -1,4 +0,0 @@
1
- //TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
2
- // for now ts type is string, but rust is different
3
- // dan_layer/transaction/src/transaction.rs
4
- export type TransactionId = string;
@@ -1,12 +0,0 @@
1
- //TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
2
-
3
- export interface ViewableBalanceProof {
4
- elgamal_encrypted: Uint8Array;
5
- elgamal_public_nonce: Uint8Array;
6
- c_prime: Uint8Array;
7
- e_prime: Uint8Array;
8
- r_prime: Uint8Array;
9
- s_v: Uint8Array;
10
- s_m: Uint8Array;
11
- s_r: Uint8Array;
12
- }