@tari-project/tarijs 0.8.0 → 0.9.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 (35) hide show
  1. package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +0 -2
  2. package/docusaurus/tari-docs/package.json +1 -1
  3. package/package.json +1 -1
  4. package/packages/builders/package.json +1 -1
  5. package/packages/builders/src/helpers/submitTransaction.ts +26 -31
  6. package/packages/builders/src/transaction/TransactionRequest.ts +1 -12
  7. package/packages/indexer_provider/package.json +1 -1
  8. package/packages/metamask_signer/package.json +1 -1
  9. package/packages/metamask_signer/src/index.ts +11 -18
  10. package/packages/tari_permissions/package.json +1 -1
  11. package/packages/tari_provider/package.json +1 -1
  12. package/packages/tari_signer/package.json +1 -1
  13. package/packages/tari_universe/package.json +1 -1
  14. package/packages/tarijs/package.json +1 -1
  15. package/packages/tarijs/src/index.ts +0 -4
  16. package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +37 -42
  17. package/packages/tarijs_types/package.json +1 -1
  18. package/packages/tarijs_types/src/SubstateDiff.ts +0 -4
  19. package/packages/tarijs_types/src/TransactionResult.ts +2 -8
  20. package/packages/tarijs_types/src/TransactionStatus.ts +7 -7
  21. package/packages/tarijs_types/src/helpers/txResult.ts +8 -11
  22. package/packages/tarijs_types/src/index.ts +1 -16
  23. package/packages/tarijs_types/src/signer.ts +6 -11
  24. package/packages/wallet_daemon/package.json +1 -1
  25. package/packages/wallet_daemon/src/signer.ts +12 -26
  26. package/packages/wallet_daemon/src/webrtc.ts +3 -3
  27. package/packages/walletconnect/package.json +1 -1
  28. package/packages/walletconnect/src/index.ts +14 -29
  29. package/pnpm-workspace.yaml +1 -1
  30. package/packages/tarijs_types/src/FinalizeResult.ts +0 -17
  31. package/packages/tarijs_types/src/Instruction.ts +0 -40
  32. package/packages/tarijs_types/src/SubstateRequirement.ts +0 -6
  33. package/packages/tarijs_types/src/Transaction.ts +0 -16
  34. package/packages/tarijs_types/src/UnsignedTransaction.ts +0 -14
  35. package/packages/tarijs_types/src/VersionedSubstateId.ts +0 -6
@@ -20,11 +20,9 @@ The transaction request has additional parameters. Therefore, you build it using
20
20
  const isDryRun = false;
21
21
  const inputRefs = undefined; // Obsolete
22
22
  const network = Network.LocalNet;
23
- const requiredSubstates = []; // Soon to be retired. Use `builder.withInputs()` instead.
24
23
  const submitTransactionRequest = buildTransactionRequest(
25
24
  transaction,
26
25
  account.account_id,
27
- requiredSubstates,
28
26
  inputRefs,
29
27
  isDryRun,
30
28
  network
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tari-docs",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "docusaurus": "docusaurus",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-builders",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,40 +1,28 @@
1
1
  import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
2
2
  import { TariSigner } from "@tari-project/tari-signer";
3
3
  import {
4
- Transaction,
4
+ ComponentAddress,
5
+ substateIdToString,
5
6
  TransactionResult,
6
- TransactionStatus,
7
+ UnsignedTransactionV1,
8
+ } from "@tari-project/typescript-bindings";
9
+ import {
7
10
  DownSubstates,
8
11
  UpSubstates,
9
- SubmitTxResult,
10
- ReqSubstate,
12
+ getSubstateValueFromUpSubstates,
11
13
  SubmitTransactionRequest,
12
- ComponentAddress,
14
+ TransactionStatus,
13
15
  } from "@tari-project/tarijs-types";
14
- import { getSubstateValueFromUpSubstates, substateIdToString, txResultCheck } from "@tari-project/tarijs-types";
16
+ import { SubmitTxResult } from "@tari-project/tarijs-types/dist/TransactionResult";
15
17
 
16
18
  export function buildTransactionRequest(
17
- transaction: Transaction,
19
+ transaction: UnsignedTransactionV1,
18
20
  accountId: number,
19
- requiredSubstates: ReqSubstate[],
20
- inputRefs = [],
21
- isDryRun = false,
22
- network = 0,
23
- isSealSignerAuthorized = true,
24
21
  detectInputsUseUnversioned = true,
25
22
  ): SubmitTransactionRequest {
26
23
  return {
27
- network,
24
+ transaction,
28
25
  account_id: accountId,
29
- instructions: transaction.instructions as object[],
30
- fee_instructions: transaction.feeInstructions as object[],
31
- inputs: transaction.inputs,
32
- input_refs: inputRefs as object[],
33
- required_substates: requiredSubstates,
34
- is_dry_run: isDryRun,
35
- min_epoch: transaction.minEpoch ?? null,
36
- max_epoch: transaction.maxEpoch ?? null,
37
- is_seal_signer_authorized: isSealSignerAuthorized,
38
26
  detect_inputs_use_unversioned: detectInputsUseUnversioned,
39
27
  };
40
28
  }
@@ -95,7 +83,7 @@ export async function waitForTransactionResult(
95
83
  throw new Error(`Transaction rejected: ${JSON.stringify(resp.result)}`);
96
84
  }
97
85
  if (FINALIZED_STATUSES.includes(resp.status)) {
98
- return resp as TransactionResult;
86
+ return resp.result?.result!;
99
87
  }
100
88
  await new Promise((resolve) => setTimeout(resolve, 1000));
101
89
  }
@@ -105,16 +93,23 @@ export function getAcceptResultSubstates(txResult: TransactionResult): {
105
93
  upSubstates: UpSubstates;
106
94
  downSubstates: DownSubstates;
107
95
  } {
108
- const result = txResult.result?.result;
109
-
110
- if (result && txResultCheck.isAcceptFeeRejectRest(result)) {
96
+ if ("Accept" in txResult) {
111
97
  return {
112
- upSubstates: result.AcceptFeeRejectRest[0].up_substates,
113
- downSubstates: result.AcceptFeeRejectRest[0].down_substates,
98
+ upSubstates: txResult.Accept.up_substates,
99
+ downSubstates: txResult.Accept.down_substates,
114
100
  };
115
101
  }
116
- if (result && txResultCheck.isAccept(result)) {
117
- return { upSubstates: result.Accept.up_substates, downSubstates: result.Accept.down_substates };
102
+
103
+ if ("Reject" in txResult) {
104
+ throw new Error(`Transaction rejected: ${txResult.Reject}`);
105
+ }
106
+
107
+ if ("AcceptFeeRejectRest" in txResult) {
108
+ return {
109
+ upSubstates: txResult.AcceptFeeRejectRest[0].up_substates,
110
+ downSubstates: txResult.AcceptFeeRejectRest[0].down_substates,
111
+ };
118
112
  }
119
- return { upSubstates: [], downSubstates: [] };
113
+
114
+ throw new Error(`Unexpected transaction result: ${JSON.stringify(txResult)}`);
120
115
  }
@@ -10,7 +10,6 @@ import {
10
10
  } from "@tari-project/typescript-bindings";
11
11
 
12
12
 
13
-
14
13
  ///TODO this implementation is not fully done, see:
15
14
  /// https://github.com/tari-project/tari-ootle/blob/development/dan_layer/transaction/src/transaction.rs
16
15
  export class TransactionRequest implements Transaction {
@@ -29,10 +28,8 @@ export class TransactionRequest implements Transaction {
29
28
  signature: {
30
29
  public_nonce: "",
31
30
  signature: "",
32
- }
31
+ },
33
32
  },
34
- // Inputs filled by some authority. These are not part of the transaction hash nor the signature
35
- filled_inputs: []
36
33
  };
37
34
  }
38
35
 
@@ -60,14 +57,6 @@ export class TransactionRequest implements Transaction {
60
57
  return this.V1.body.transaction.inputs;
61
58
  }
62
59
 
63
- getFilledInputs(): VersionedSubstateId[] {
64
- return this.V1.filled_inputs;
65
- }
66
-
67
- getFilledInputsMut(): VersionedSubstateId[] {
68
- return this.V1.filled_inputs;
69
- }
70
-
71
60
  getMinEpoch(): Epoch | null {
72
61
  return this.V1.body.transaction.min_epoch;
73
62
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/indexer-provider",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/metamask-signer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,7 +1,6 @@
1
1
  import { TariSigner } from "@tari-project/tari-signer";
2
2
  import {
3
3
  SubmitTransactionRequest,
4
- TransactionResult,
5
4
  TransactionStatus,
6
5
  SubmitTransactionResponse,
7
6
  VaultBalances,
@@ -99,11 +98,11 @@ export class MetamaskTariSigner implements TariSigner {
99
98
  }
100
99
 
101
100
  async listSubstates({
102
- filter_by_template,
103
- filter_by_type,
104
- limit,
105
- offset,
106
- }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
101
+ filter_by_template,
102
+ filter_by_type,
103
+ limit,
104
+ offset,
105
+ }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
107
106
  const res = (await this.metamaskRequest("listSubstates", {
108
107
  filter_by_template,
109
108
  filter_by_type,
@@ -115,13 +114,7 @@ export class MetamaskTariSigner implements TariSigner {
115
114
  }
116
115
 
117
116
  async submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse> {
118
- const params = {
119
- instructions: req.instructions,
120
- fee_instructions: req.fee_instructions,
121
- input_refs: req.input_refs,
122
- required_substates: req.required_substates || [],
123
- is_dry_run: req.is_dry_run,
124
- };
117
+ const params = req.transaction;
125
118
 
126
119
  const resp = await this.metamaskRequest<any>("sendTransaction", params);
127
120
  if (!resp) {
@@ -173,11 +166,11 @@ export class MetamaskTariSigner implements TariSigner {
173
166
  }
174
167
 
175
168
  public async getConfidentialVaultBalances({
176
- vault_id,
177
- maximum_expected_value,
178
- minimum_expected_value,
179
- view_key_id,
180
- }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
169
+ vault_id,
170
+ maximum_expected_value,
171
+ minimum_expected_value,
172
+ view_key_id,
173
+ }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
181
174
  const resp = await this.metamaskRequest("getConfidentialVaultBalances", {
182
175
  view_key_id,
183
176
  vault_id,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-permissions",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-provider",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-signer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-universe-signer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-all",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -21,12 +21,10 @@ import {
21
21
  TransactionStatus,
22
22
  GetTransactionResultResponse,
23
23
  AccountData,
24
- SubmitTransactionResponse,
25
24
  SubmitTransactionRequest,
26
25
  VaultBalances,
27
26
  VaultData,
28
27
  TemplateDefinition,
29
- SubstateRequirement,
30
28
  Substate,
31
29
  Network,
32
30
  fromHexString,
@@ -48,12 +46,10 @@ export {
48
46
  AccountData,
49
47
  TransactionStatus,
50
48
  GetTransactionResultResponse,
51
- SubmitTransactionResponse,
52
49
  SubmitTransactionRequest,
53
50
  VaultBalances,
54
51
  VaultData,
55
52
  TemplateDefinition,
56
- SubstateRequirement,
57
53
  MetamaskTariSigner,
58
54
  WalletDaemonTariSigner,
59
55
  WalletDaemonParameters,
@@ -12,6 +12,7 @@ import {
12
12
  waitForTransactionResult,
13
13
  WalletDaemonTariSigner,
14
14
  } from "../../../src";
15
+ import { Instruction, SubstateId } from "@tari-project/typescript-bindings";
15
16
 
16
17
  function buildSigner(): Promise<WalletDaemonTariSigner> {
17
18
  const permissions = new TariPermissions().addPermission("Admin");
@@ -102,21 +103,21 @@ describe("WalletDaemonTariSigner", () => {
102
103
  args: [`Amount(${fee})`],
103
104
  },
104
105
  },
105
- ];
106
+ ] as Instruction[];
106
107
 
107
108
  const request: SubmitTransactionRequest = {
108
- network: Network.LocalNet,
109
- account_id: account.account_id,
110
- fee_instructions,
111
- instructions: [],
112
- inputs: [],
113
- input_refs: [],
114
- required_substates: [],
115
- is_dry_run: false,
116
- min_epoch: null,
117
- max_epoch: null,
118
- is_seal_signer_authorized: true,
109
+ transaction: {
110
+ network: Network.LocalNet,
111
+ fee_instructions,
112
+ instructions: [],
113
+ inputs: [],
114
+ dry_run: false,
115
+ min_epoch: null,
116
+ max_epoch: null,
117
+ is_seal_signer_authorized: true,
118
+ },
119
119
  detect_inputs_use_unversioned: true,
120
+ account_id: account.account_id,
120
121
  };
121
122
  const result = await signer.submitTransaction(request);
122
123
 
@@ -130,24 +131,24 @@ describe("WalletDaemonTariSigner", () => {
130
131
  const account = await signer.getAccount();
131
132
 
132
133
  const request: SubmitTransactionRequest = {
133
- network: Network.LocalNet,
134
- account_id: account.account_id,
135
- fee_instructions: [],
136
- instructions: [
137
- {
138
- EmitLog: {
139
- level: "Info",
140
- message: "From Integration Test",
134
+ transaction: {
135
+ network: Network.LocalNet,
136
+ fee_instructions: [],
137
+ instructions: [
138
+ {
139
+ EmitLog: {
140
+ level: "Info",
141
+ message: "From Integration Test",
142
+ },
141
143
  },
142
- },
143
- ],
144
- inputs: [],
145
- input_refs: [],
146
- required_substates: [],
147
- is_dry_run: true,
148
- min_epoch: null,
149
- max_epoch: null,
150
- is_seal_signer_authorized: true,
144
+ ],
145
+ inputs: [],
146
+ dry_run: true,
147
+ min_epoch: null,
148
+ max_epoch: null,
149
+ is_seal_signer_authorized: true,
150
+ },
151
+ account_id: account.account_id,
151
152
  detect_inputs_use_unversioned: true,
152
153
  };
153
154
  const result = await signer.submitTransaction(request);
@@ -163,7 +164,8 @@ describe("WalletDaemonTariSigner", () => {
163
164
  const xtrAddress = account.resources[0].resource_address;
164
165
 
165
166
  const fee = new Amount(2000);
166
- const builder = new TransactionBuilder();
167
+ const network = Network.LocalNet;
168
+ const builder = new TransactionBuilder(network);
167
169
  builder.feeTransactionPayFromComponent(account.address, fee.getStringValue());
168
170
 
169
171
  builder.callMethod(
@@ -181,19 +183,12 @@ describe("WalletDaemonTariSigner", () => {
181
183
  },
182
184
  [workspaceId],
183
185
  );
184
- const transaction = builder.build();
186
+ builder.addInput({ substate_id: { Component: account.address }, version: null });
187
+ const transaction = builder.buildUnsignedTransaction();
185
188
 
186
- const isDryRun = false;
187
- const inputRefs = undefined;
188
- const network = Network.LocalNet;
189
- const requiredSubstates = [{ substate_id: account.address }];
190
189
  const submitTransactionRequest = buildTransactionRequest(
191
190
  transaction,
192
191
  account.account_id,
193
- requiredSubstates,
194
- inputRefs,
195
- isDryRun,
196
- network,
197
192
  );
198
193
 
199
194
  const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
@@ -212,9 +207,9 @@ describe("WalletDaemonTariSigner", () => {
212
207
 
213
208
  assert(
214
209
  accountBalances &&
215
- typeof accountBalances === "object" &&
216
- "balances" in accountBalances &&
217
- accountBalances.balances,
210
+ typeof accountBalances === "object" &&
211
+ "balances" in accountBalances &&
212
+ accountBalances.balances,
218
213
  "accountBalances is not an object",
219
214
  );
220
215
  assert(Array.isArray(accountBalances.balances), "accountBalances.balances is not an array");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-types",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -3,7 +3,3 @@ import { Substate, SubstateId } from "@tari-project/typescript-bindings";
3
3
  export type UpSubstates = Array<[SubstateId, Substate]>;
4
4
  export type DownSubstates = Array<[SubstateId, number]>;
5
5
 
6
- export interface SubstateDiff {
7
- up_substates: UpSubstates;
8
- down_substates: DownSubstates;
9
- }
@@ -1,7 +1,6 @@
1
1
  import { TransactionStatus } from "./TransactionStatus";
2
- import { FinalizeResult } from "./FinalizeResult";
3
2
  import { DownSubstates, UpSubstates } from "./SubstateDiff";
4
- import { ComponentAddress } from "@tari-project/typescript-bindings";
3
+ import { ComponentAddress, FinalizeResult, TransactionResult } from "@tari-project/typescript-bindings";
5
4
 
6
5
  export type SubmitTransactionResponse = {
7
6
  transaction_id: string;
@@ -13,15 +12,10 @@ export interface SubmitTxResult {
13
12
  upSubstates: UpSubstates;
14
13
  downSubstates: DownSubstates;
15
14
  newComponents: UpSubstates;
15
+
16
16
  getComponentForTemplate(templateAddress: string): ComponentAddress | null;
17
17
  }
18
18
 
19
- export type TransactionResult = {
20
- transaction_id: string;
21
- status: TransactionStatus;
22
- result: FinalizeResult | null;
23
- };
24
-
25
19
  export type TransactionResultResponse = {
26
20
  transaction_id: string;
27
21
  status: TransactionStatus;
@@ -1,9 +1,9 @@
1
1
  export enum TransactionStatus {
2
- New,
3
- DryRun,
4
- Pending,
5
- Accepted,
6
- Rejected,
7
- InvalidTransaction,
8
- OnlyFeeAccepted,
2
+ New = "New",
3
+ DryRun = "DryRun",
4
+ Pending = "Pending",
5
+ Accepted = "Accepted",
6
+ Rejected = "Rejected",
7
+ InvalidTransaction = "InvalidTransaction",
8
+ OnlyFeeAccepted = "OnlyFeeAccepted",
9
9
  }
@@ -1,5 +1,4 @@
1
1
  import {
2
- SubstateDiff,
3
2
  VaultId,
4
3
  Vault,
5
4
  SubstateId,
@@ -7,11 +6,9 @@ import {
7
6
  ResourceContainer,
8
7
  ResourceAddress,
9
8
  Amount,
10
- RejectReason,
11
9
  substateIdToString,
12
- ComponentAddress,
10
+ ComponentAddress, FinalizeResult,
13
11
  } from "@tari-project/typescript-bindings";
14
- import { FinalizeResultStatus } from "../FinalizeResult";
15
12
  import { UpSubstates } from "../SubstateDiff";
16
13
 
17
14
  function isOfType<T extends object>(obj: T, key: keyof T): boolean {
@@ -19,8 +16,8 @@ function isOfType<T extends object>(obj: T, key: keyof T): boolean {
19
16
  }
20
17
 
21
18
  export const txResultCheck = {
22
- isAccept: (result: FinalizeResultStatus): result is { Accept: SubstateDiff } => {
23
- return "Accept" in result;
19
+ isAccept: (result: FinalizeResult) => {
20
+ return "Accept" in result.result;
24
21
  },
25
22
 
26
23
  isVaultId: (substateId: SubstateId): substateId is { Vault: VaultId } => {
@@ -37,13 +34,13 @@ export const txResultCheck = {
37
34
  return "Fungible" in resourceContainer;
38
35
  },
39
36
 
40
- isReject: (result: FinalizeResultStatus): result is { Reject: RejectReason } => {
41
- return "Reject" in result;
37
+ isReject: (result: FinalizeResult): boolean => {
38
+ return "Reject" in result.result;
42
39
  },
43
40
  isAcceptFeeRejectRest: (
44
- result: FinalizeResultStatus,
45
- ): result is { AcceptFeeRejectRest: [SubstateDiff, RejectReason] } => {
46
- return "AcceptFeeRejectRest" in result;
41
+ result: FinalizeResult,
42
+ ): boolean => {
43
+ return "AcceptFeeRejectRest" in result.result;
47
44
  },
48
45
  };
49
46
 
@@ -4,29 +4,14 @@ export { TransactionArg } from "./TransactionArg";
4
4
  export { ConfidentialClaim } from "./ConfidentialClaim";
5
5
  export { ConfidentialOutput } from "./ConfidentialOutput";
6
6
  export { ConfidentialWithdrawProof } from "./ConfidentialWithdrawProof";
7
- export {
8
- FinalizeResult,
9
- FinalizeResultStatus,
10
- TxResultAccept,
11
- TxResultAcceptFeeRejectRest,
12
- TxResultReject,
13
- } from "./FinalizeResult";
14
7
  export { GetTransactionResultResponse } from "./GetTransactionResultResponse";
15
- export { Instruction } from "./Instruction";
16
- export { Transaction } from "./Transaction";
17
- export { SubstateDiff, DownSubstates, UpSubstates } from "./SubstateDiff";
18
- export { SubstateRequirement } from "./SubstateRequirement";
8
+ export { DownSubstates, UpSubstates } from "./SubstateDiff";
19
9
  export { SubstateType } from "./SubstateType";
20
10
  export {
21
- TransactionResult,
22
- SubmitTxResult,
23
11
  SubmitTransactionResponse,
24
- TransactionResultResponse,
25
12
  } from "./TransactionResult";
26
13
  export { TransactionSignature } from "./TransactionSignature";
27
14
  export { TransactionStatus } from "./TransactionStatus";
28
- export { UnsignedTransaction } from "./UnsignedTransaction";
29
- export { VersionedSubstateId } from "./VersionedSubstateId";
30
15
  export { WorkspaceArg } from "./Workspace";
31
16
  export { ListAccountNftFromBalancesRequest } from "./ListAccountNftFromBalancesRequest";
32
17
  export { Network } from "./network";
@@ -1,4 +1,8 @@
1
- import { SubstateType, TemplateDef } from "@tari-project/typescript-bindings";
1
+ import {
2
+ SubstateType,
3
+ TemplateDef,
4
+ UnsignedTransactionV1,
5
+ } from "@tari-project/typescript-bindings";
2
6
 
3
7
  export type SubstateMetadata = {
4
8
  substate_id: string;
@@ -13,17 +17,8 @@ export type ReqSubstate = {
13
17
  };
14
18
 
15
19
  export type SubmitTransactionRequest = {
16
- network: number;
20
+ transaction: UnsignedTransactionV1,
17
21
  account_id: number;
18
- instructions: object[];
19
- fee_instructions: object[];
20
- inputs: object[];
21
- input_refs: object[];
22
- required_substates: ReqSubstate[];
23
- is_dry_run: boolean;
24
- min_epoch: number | null;
25
- max_epoch: number | null;
26
- is_seal_signer_authorized: boolean;
27
22
  detect_inputs_use_unversioned: boolean;
28
23
  };
29
24
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-daemon-signer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -173,29 +173,15 @@ export class WalletDaemonTariSigner implements TariSigner {
173
173
  public async submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse> {
174
174
  const params = {
175
175
  transaction: {
176
- V1: {
177
- network: req.network,
178
- instructions: req.instructions as Instruction[],
179
- fee_instructions: req.fee_instructions as Instruction[],
180
- inputs: req.required_substates.map((s) => ({
181
- // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
182
- substate_id: s.substate_id as any,
183
- version: s.version ?? null,
184
- })),
185
- min_epoch: null,
186
- max_epoch: null,
187
- dry_run: req.is_dry_run,
188
- is_seal_signer_authorized: req.is_seal_signer_authorized,
189
- },
176
+ V1: req.transaction,
190
177
  },
191
178
  signing_key_index: req.account_id,
192
- autofill_inputs: [],
193
179
  detect_inputs: true,
194
180
  proof_ids: [],
195
181
  detect_inputs_use_unversioned: req.detect_inputs_use_unversioned,
196
182
  };
197
183
 
198
- const res = req.is_dry_run
184
+ const res = req.transaction.dry_run
199
185
  ? await this.client.submitTransactionDryRun(params)
200
186
  : await this.client.submitTransaction(params);
201
187
  return { transaction_id: res.transaction_id };
@@ -222,11 +208,11 @@ export class WalletDaemonTariSigner implements TariSigner {
222
208
  }
223
209
 
224
210
  public async getConfidentialVaultBalances({
225
- vault_id,
226
- view_key_id,
227
- maximum_expected_value = null,
228
- minimum_expected_value = null,
229
- }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
211
+ vault_id,
212
+ view_key_id,
213
+ maximum_expected_value = null,
214
+ minimum_expected_value = null,
215
+ }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
230
216
  const res = await this.client.viewVaultBalance({
231
217
  view_key_id,
232
218
  vault_id,
@@ -237,11 +223,11 @@ export class WalletDaemonTariSigner implements TariSigner {
237
223
  }
238
224
 
239
225
  public async listSubstates({
240
- filter_by_template,
241
- filter_by_type,
242
- limit,
243
- offset,
244
- }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
226
+ filter_by_template,
227
+ filter_by_type,
228
+ limit,
229
+ offset,
230
+ }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
245
231
  const resp = await this.client.substatesList({
246
232
  filter_by_template,
247
233
  filter_by_type,
@@ -1,7 +1,7 @@
1
1
  import { TariPermissions } from "@tari-project/tari-permissions";
2
2
  import { transports } from "@tari-project/wallet_jrpc_client";
3
3
 
4
- class SignaligServer {
4
+ class SignalingServer {
5
5
  private _token?: string;
6
6
  private _server_url: string;
7
7
 
@@ -72,7 +72,7 @@ class SignaligServer {
72
72
  export class TariConnection {
73
73
  private _peerConnection: RTCPeerConnection;
74
74
  private _dataChannel: RTCDataChannel;
75
- private _signalingServer: SignaligServer;
75
+ private _signalingServer: SignalingServer;
76
76
  private _callbacks: { [key: string]: any[] };
77
77
  private _offer?: RTCSessionDescriptionInit;
78
78
  private _walletToken: string | undefined;
@@ -83,7 +83,7 @@ export class TariConnection {
83
83
  constructor(signalig_server_url?: string, config?: RTCConfiguration) {
84
84
  this._peerConnection = new RTCPeerConnection(config || this.config());
85
85
  this._dataChannel = this._peerConnection.createDataChannel("tari-data");
86
- this._signalingServer = new SignaligServer(signalig_server_url);
86
+ this._signalingServer = new SignalingServer(signalig_server_url);
87
87
  this._callbacks = {};
88
88
  }
89
89
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-connect-signer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -5,17 +5,16 @@ import {
5
5
  convertStringToTransactionStatus,
6
6
  GetTransactionResultResponse,
7
7
  SubmitTransactionRequest,
8
- SubmitTransactionResponse,
9
8
  VaultBalances,
10
9
  TemplateDefinition,
11
10
  Substate,
12
11
  AccountData,
13
12
  ListSubstatesResponse,
14
13
  ListSubstatesRequest,
14
+ SubmitTransactionResponse,
15
15
  } from "@tari-project/tarijs-types";
16
16
  import {
17
17
  ConfidentialViewVaultBalanceRequest,
18
- Instruction,
19
18
  KeyBranch,
20
19
  ListAccountNftRequest,
21
20
  ListAccountNftResponse,
@@ -40,7 +39,7 @@ const walletConnectParams = {
40
39
  "tari_getNftsList",
41
40
  ],
42
41
  chains: ["tari:devnet"],
43
- events: ['chainChanged", "accountsChanged'],
42
+ events: ["chainChanged\", \"accountsChanged"],
44
43
  },
45
44
  },
46
45
  };
@@ -152,11 +151,11 @@ export class WalletConnectTariSigner implements TariSigner {
152
151
  }
153
152
 
154
153
  public async listSubstates({
155
- filter_by_template,
156
- filter_by_type,
157
- limit,
158
- offset,
159
- }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
154
+ filter_by_template,
155
+ filter_by_type,
156
+ limit,
157
+ offset,
158
+ }: ListSubstatesRequest): Promise<ListSubstatesResponse> {
160
159
  const method = "tari_listSubstates";
161
160
  const params = {
162
161
  filter_by_template,
@@ -193,26 +192,12 @@ export class WalletConnectTariSigner implements TariSigner {
193
192
  }
194
193
 
195
194
  async submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse> {
196
- const method = req.is_dry_run ? "tari_submitTransactionDryRun" : "tari_submitTransaction";
195
+ const method = req.transaction.dry_run ? "tari_submitTransactionDryRun" : "tari_submitTransaction";
197
196
  const params: TransactionSubmitRequest = {
198
197
  transaction: {
199
- V1: {
200
- network: req.network,
201
- fee_instructions: req.fee_instructions as Instruction[],
202
- instructions: req.instructions as Instruction[],
203
- inputs: req.required_substates.map((s) => ({
204
- // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
205
- substate_id: s.substate_id as any,
206
- version: s.version ?? null,
207
- })),
208
- min_epoch: null,
209
- max_epoch: null,
210
- dry_run: req.is_dry_run,
211
- is_seal_signer_authorized: req.is_seal_signer_authorized,
212
- },
198
+ V1: req.transaction,
213
199
  },
214
200
  signing_key_index: req.account_id,
215
- autofill_inputs: [],
216
201
  detect_inputs: true,
217
202
  proof_ids: [],
218
203
  detect_inputs_use_unversioned: req.detect_inputs_use_unversioned,
@@ -244,11 +229,11 @@ export class WalletConnectTariSigner implements TariSigner {
244
229
  }
245
230
 
246
231
  async getConfidentialVaultBalances({
247
- vault_id,
248
- view_key_id,
249
- maximum_expected_value = null,
250
- minimum_expected_value = null,
251
- }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
232
+ vault_id,
233
+ view_key_id,
234
+ maximum_expected_value = null,
235
+ minimum_expected_value = null,
236
+ }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
252
237
  const method = "tari_viewConfidentialVaultBalance";
253
238
  const params = {
254
239
  view_key_id,
@@ -8,7 +8,7 @@ catalog:
8
8
  vitest: ^3.0.4
9
9
  vite: ^6.1.0
10
10
  "@types/node": ^22.13.1
11
- "@tari-project/typescript-bindings": ">=1.9.0"
11
+ "@tari-project/typescript-bindings": ">=1.9.1"
12
12
  "@tari-project/wallet_jrpc_client": ^1.6.0
13
13
  "@metamask/providers": ^18.2.0
14
14
  "@walletconnect/universal-provider": ^2.13.3
@@ -1,17 +0,0 @@
1
- import { FeeReceipt, InstructionResult, LogEntry, RejectReason } from "@tari-project/typescript-bindings";
2
- import { SubstateDiff } from "./SubstateDiff";
3
-
4
- export type TxResultAccept = { Accept: SubstateDiff };
5
- export type TxResultAcceptFeeRejectRest = { AcceptFeeRejectRest: [SubstateDiff, RejectReason] };
6
- export type TxResultReject = { Reject: RejectReason };
7
-
8
- export type FinalizeResultStatus = TxResultAccept | TxResultAcceptFeeRejectRest | TxResultReject;
9
-
10
- export interface FinalizeResult {
11
- transaction_hash: Uint8Array;
12
- events: Array<Event>;
13
- logs: Array<LogEntry>;
14
- execution_results: Array<InstructionResult>;
15
- result: FinalizeResultStatus;
16
- fee_receipt: FeeReceipt;
17
- }
@@ -1,40 +0,0 @@
1
- import { ComponentAddress, ResourceAddress, LogLevel, PublishedTemplateAddress, SubstateType, WorkspaceOffsetId } from "@tari-project/typescript-bindings";
2
- import { TransactionArg } from "./TransactionArg";
3
- import { ConfidentialClaim } from "./ConfidentialClaim";
4
- import { Amount } from "./Amount";
5
- import { ConfidentialOutput } from "./ConfidentialOutput";
6
-
7
- export type Instruction =
8
- | CreateAccount
9
- | CallFunction
10
- | CallMethod
11
- | PutLastInstructionOutputOnWorkspace
12
- | EmitLog
13
- | ClaimBurn
14
- | ClaimValidatorFees
15
- | DropAllProofsInWorkspace
16
- | CreateFreeTestCoins
17
- | AllocateAddress
18
- | AssertBucketContains;
19
-
20
- export type CreateAccount = { CreateAccount: { owner_public_key: string; workspace_bucket: string | null } };
21
- export type CallFunction = {
22
- CallFunction: { template_address: PublishedTemplateAddress; function: string; args: Array<TransactionArg> };
23
- };
24
- export type CallMethod = {
25
- CallMethod: { component_address: ComponentAddress; method: string; args: Array<TransactionArg> };
26
- };
27
- export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key: string } };
28
- export type EmitLog = { EmitLog: { level: LogLevel; message: string } };
29
- export type ClaimBurn = { ClaimBurn: { claim: ConfidentialClaim } };
30
- export type ClaimValidatorFees = { ClaimValidatorFees: { epoch: number; validator_public_key: string } };
31
- export type DropAllProofsInWorkspace = "DropAllProofsInWorkspace";
32
- export type CreateFreeTestCoins = {
33
- CreateFreeTestCoins: { revealed_amount: Amount; output: ConfidentialOutput | null };
34
- };
35
- export type AllocateAddress = {
36
- AllocateAddress: { substate_type: SubstateType; workspace_id: string };
37
- };
38
- export type AssertBucketContains = {
39
- AssertBucketContains: { key: WorkspaceOffsetId; resource_address: ResourceAddress; min_amount: Amount };
40
- }
@@ -1,6 +0,0 @@
1
- import { SubstateId } from "@tari-project/typescript-bindings";
2
-
3
- export interface SubstateRequirement {
4
- substateId: SubstateId;
5
- version?: number;
6
- }
@@ -1,16 +0,0 @@
1
- import { Instruction } from "./Instruction";
2
- import { SubstateRequirement } from "./SubstateRequirement";
3
- import { VersionedSubstateId } from "./VersionedSubstateId";
4
- import { TransactionSignature } from "./TransactionSignature";
5
- import { Epoch } from "@tari-project/typescript-bindings";
6
-
7
- export interface Transaction {
8
- id: string;
9
- feeInstructions: Array<Instruction>;
10
- instructions: Array<Instruction>;
11
- inputs: Array<SubstateRequirement>;
12
- minEpoch?: Epoch;
13
- maxEpoch?: Epoch;
14
- signatures: Array<TransactionSignature>;
15
- filledInputs: Array<VersionedSubstateId>;
16
- }
@@ -1,14 +0,0 @@
1
- import { Epoch } from "@tari-project/typescript-bindings";
2
- import { Instruction } from "./Instruction";
3
- import { SubstateRequirement } from "./SubstateRequirement";
4
- import { VersionedSubstateId } from "./VersionedSubstateId";
5
-
6
- // differs from bindings implementation because of 'Instruction'
7
- export interface UnsignedTransaction {
8
- feeInstructions: Instruction[];
9
- instructions: Instruction[];
10
- inputs: SubstateRequirement[];
11
- filledInputs: VersionedSubstateId[];
12
- minEpoch?: Epoch;
13
- maxEpoch?: Epoch;
14
- }
@@ -1,6 +0,0 @@
1
- import { SubstateId } from "@tari-project/typescript-bindings";
2
-
3
- export interface VersionedSubstateId {
4
- substateId: SubstateId;
5
- version: number;
6
- }