@tari-project/tarijs 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/docusaurus/tari-docs/package.json +4 -4
  2. package/eslint.config.mjs +9 -0
  3. package/examples/vite-typescript-react/src/App.tsx +1 -1
  4. package/package.json +15 -2
  5. package/packages/builders/package.json +1 -1
  6. package/packages/builders/src/helpers/submitTransaction.ts +10 -35
  7. package/packages/builders/src/transaction/TransactionBuilder.ts +223 -17
  8. package/packages/indexer_provider/package.json +1 -1
  9. package/packages/metamask_signer/package.json +1 -1
  10. package/packages/metamask_signer/src/index.ts +1 -1
  11. package/packages/permissions/package.json +1 -1
  12. package/packages/react-mui-connect-button/package.json +1 -1
  13. package/packages/tari_provider/package.json +1 -1
  14. package/packages/tari_provider/src/TariProvider.ts +6 -1
  15. package/packages/tari_signer/package.json +1 -1
  16. package/packages/tari_universe/package.json +1 -1
  17. package/packages/tarijs/package.json +1 -1
  18. package/packages/tarijs/src/index.ts +27 -49
  19. package/packages/tarijs/src/templates/Account.ts +7 -4
  20. package/packages/tarijs/test/integration-tests/.env +1 -1
  21. package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +112 -73
  22. package/packages/tarijs/tsconfig.json +2 -2
  23. package/packages/tarijs/vitest.config.ts +2 -1
  24. package/packages/tarijs_types/package.json +3 -2
  25. package/packages/tarijs_types/src/Account.ts +68 -0
  26. package/packages/tarijs_types/src/Amount.ts +5 -1
  27. package/packages/tarijs_types/src/TransactionResult.ts +1 -8
  28. package/packages/tarijs_types/src/consts.ts +3 -0
  29. package/packages/tarijs_types/src/helpers/index.ts +4 -0
  30. package/packages/tarijs_types/src/helpers/simpleResult.ts +345 -0
  31. package/packages/tarijs_types/src/helpers/txResult.ts +1 -2
  32. package/packages/tarijs_types/src/index.ts +8 -0
  33. package/packages/tarijs_types/src/signer.ts +1 -1
  34. package/packages/wallet_daemon/package.json +1 -1
  35. package/packages/wallet_daemon/src/signer.ts +7 -2
  36. package/packages/walletconnect/package.json +1 -1
  37. package/packages/walletconnect/src/index.ts +2 -2
  38. package/pnpm-workspace.yaml +1 -1
  39. package/typedoc.json +10 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tari-docs",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "docusaurus": "docusaurus",
@@ -15,9 +15,9 @@
15
15
  "typecheck": "tsc"
16
16
  },
17
17
  "dependencies": {
18
- "@docusaurus/core": "^3.7.0",
19
- "@docusaurus/preset-classic": "3.7.0",
20
- "@docusaurus/remark-plugin-npm2yarn": "^3.7.0",
18
+ "@docusaurus/core": "=3.8.1",
19
+ "@docusaurus/preset-classic": "=3.8.1",
20
+ "@docusaurus/remark-plugin-npm2yarn": "=3.8.1",
21
21
  "@mdx-js/react": "^3.0.0",
22
22
  "clsx": "^2.0.0",
23
23
  "prism-react-renderer": "^2.3.0",
@@ -0,0 +1,9 @@
1
+ // @ts-check
2
+
3
+ import eslint from '@eslint/js';
4
+ import tseslint from 'typescript-eslint';
5
+
6
+ export default tseslint.config(
7
+ eslint.configs.recommended,
8
+ tseslint.configs.recommended,
9
+ );
@@ -35,7 +35,7 @@ function App() {
35
35
  <p>Public Key: {account.public_key}</p>
36
36
  <h3>Resources:</h3>
37
37
  <ul>
38
- {account.resources.map((resource, index) => (
38
+ {account.vaults.map((resource, index) => (
39
39
  <li key={index}>
40
40
  {resource.type} - {resource.balance} {resource.token_symbol}
41
41
  </li>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -10,6 +10,19 @@
10
10
  "node": "22.13.1"
11
11
  },
12
12
  "devDependencies": {
13
- "@moonrepo/cli": "^1.32.1"
13
+ "@eslint/js": "^9.30.0",
14
+ "@moonrepo/cli": "^1.32.1",
15
+ "eslint": "^9.30.0",
16
+ "eslint-plugin-tsdoc": "^0.4.0",
17
+ "globals": "^16.2.0",
18
+ "typedoc-plugin-markdown": "^4.7.0",
19
+ "typescript": "^5.8.3",
20
+ "typescript-eslint": "^8.35.0"
21
+ },
22
+ "dependencies": {
23
+ "@tari-project/tarijs-types": "^0.12.1"
24
+ },
25
+ "scripts": {
26
+ "docs": "typedoc"
14
27
  }
15
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-builders",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,19 +1,15 @@
1
1
  import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
2
2
  import { TariSigner } from "@tari-project/tari-signer";
3
3
  import {
4
- ComponentAddress,
5
- substateIdToString,
6
4
  TransactionResult,
7
5
  UnsignedTransactionV1,
8
6
  } from "@tari-project/typescript-bindings";
9
7
  import {
10
8
  DownSubstates,
11
9
  UpSubstates,
12
- getSubstateValueFromUpSubstates,
13
10
  SubmitTransactionRequest,
14
- TransactionStatus,
11
+ TransactionStatus, SimpleTransactionResult,
15
12
  } from "@tari-project/tarijs-types";
16
- import { SubmitTxResult } from "@tari-project/tarijs-types/dist/TransactionResult";
17
13
 
18
14
  export function buildTransactionRequest(
19
15
  transaction: UnsignedTransactionV1,
@@ -30,35 +26,10 @@ export function buildTransactionRequest(
30
26
  export async function submitAndWaitForTransaction(
31
27
  signer: TariSigner,
32
28
  req: SubmitTransactionRequest,
33
- ): Promise<SubmitTxResult> {
29
+ ): Promise<SimpleTransactionResult> {
34
30
  try {
35
31
  const response = await signer.submitTransaction(req);
36
- const result = await waitForTransactionResult(signer, response.transaction_id);
37
- const { upSubstates, downSubstates } = getAcceptResultSubstates(result);
38
- const newComponents = getSubstateValueFromUpSubstates("Component", upSubstates);
39
-
40
- function getComponentForTemplate(templateAddress: string): ComponentAddress | null {
41
- for (const [substateId, substate] of upSubstates) {
42
- if ("Component" in substate.substate) {
43
- const templateAddr = substate.substate.Component.template_address;
44
- const templateString =
45
- typeof templateAddr === "string" ? templateAddr : new TextDecoder().decode(templateAddr);
46
- if (templateAddress === templateString) {
47
- return substateIdToString(substateId);
48
- }
49
- }
50
- }
51
- return null;
52
- }
53
-
54
- return {
55
- response,
56
- result,
57
- upSubstates,
58
- downSubstates,
59
- newComponents,
60
- getComponentForTemplate,
61
- };
32
+ return await waitForTransactionResult(signer, response.transaction_id);
62
33
  } catch (e) {
63
34
  throw new Error(`Transaction failed: ${e}`);
64
35
  }
@@ -67,7 +38,7 @@ export async function submitAndWaitForTransaction(
67
38
  export async function waitForTransactionResult(
68
39
  signer: TariSigner | TariUniverseSigner,
69
40
  transactionId: string,
70
- ): Promise<TransactionResult> {
41
+ ): Promise<SimpleTransactionResult> {
71
42
  // eslint-disable-next-line no-constant-condition
72
43
  while (true) {
73
44
  const resp = await signer.getTransactionResult(transactionId);
@@ -83,9 +54,13 @@ export async function waitForTransactionResult(
83
54
  throw new Error(`Transaction rejected: ${JSON.stringify(resp.result)}`);
84
55
  }
85
56
  if (FINALIZED_STATUSES.includes(resp.status)) {
86
- return resp.result?.result!;
57
+ if (!resp.result) {
58
+ throw new Error(`BUG: Transaction result is empty for transaction ID: ${transactionId}`);
59
+ }
60
+
61
+ return SimpleTransactionResult.fromResponse(resp);
87
62
  }
88
- await new Promise((resolve) => setTimeout(resolve, 1000));
63
+ await new Promise((resolve) => setTimeout(resolve, 500));
89
64
  }
90
65
  }
91
66
 
@@ -2,9 +2,8 @@
2
2
  // SPDX-License-Identifier: BSD-3-Clause
3
3
 
4
4
  import { TransactionRequest } from "./TransactionRequest";
5
- import { TransactionArg } from "@tari-project/tarijs-types";
5
+ import { Amount, Network, TransactionArg } from "@tari-project/tarijs-types";
6
6
  import {
7
- Amount,
8
7
  ComponentAddress,
9
8
  ConfidentialClaim,
10
9
  ConfidentialWithdrawProof,
@@ -18,64 +17,266 @@ import {
18
17
  WorkspaceOffsetId,
19
18
  UnsignedTransactionV1, AllocatableAddressType,
20
19
  } from "@tari-project/typescript-bindings";
21
- import { parseWorkspaceStringKey } from "../helpers";
22
- import { NamedArg } from "../helpers/workspace";
20
+ import { parseWorkspaceStringKey, NamedArg } from "../helpers";
23
21
 
22
+ /**
23
+ * This interface defines the constructor for a Transaction object.
24
+ * It is used to create a new signed Transaction instance from an UnsignedTransaction and an array of TransactionSignatures.
25
+ * The constructor takes an UnsignedTransaction and an array of TransactionSignatures as parameters.
26
+ */
24
27
  export interface TransactionConstructor {
28
+ /**
29
+ * Creates a new {@link Transaction} instance.
30
+ *
31
+ * @param unsignedTransaction - The UnsignedTransaction to create the Transaction from.
32
+ * @param signatures - An array of {@link TransactionSignature} objects, each containing:
33
+ * - `public_key`: A string representing a valid 32-byte Ristretto255 public key.
34
+ * - `signature`: An object containing:
35
+ * - `public_nonce`: A string representing the public nonce part of the Schnorr signature.
36
+ * - **NOTE:** Must be a valid 32-byte Ristretto255 public key, serialized as a hex string.
37
+ * - `signature`: A string representing the actual Schnorr signature scalar.
38
+ * - **NOTE:** Must be a valid 32-byte Schnorr signature scalar, serialized as a hex string.
39
+ *
40
+ * All fields must be validly encoded, canonical Ristretto255 public keys or Schnorr signature components in the correct format and length.
41
+ * Any deviation (e.g., wrong length, invalid encoding) will result in errors or failed signature verification.
42
+ *
43
+ * @returns A new Transaction instance.
44
+ */
25
45
  new(unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]): Transaction;
26
46
  }
27
47
 
48
+ /**
49
+ * Defines a function that can be invoked on a published template in the Tari network.
50
+ *
51
+ */
28
52
  export interface TariFunctionDefinition {
53
+ /**
54
+ * The name of the function to call. Should match the function defined in the published template.
55
+ */
29
56
  functionName: string;
57
+ /**
58
+ * The arguments to pass to the function. Optional.
59
+ *
60
+ * Each argument is a {@link NamedArg}, which represents either a literal value or a reference to a workspace variable.
61
+ *
62
+ * @see NamedArg for full structure and usage.
63
+ */
30
64
  args?: NamedArg[];
65
+ /**
66
+ * The unique address ({@link PublishedTemplateAddress}) of the published template (as a 64-character hexadecimal string, optionally prefixed by "template_").
67
+ */
31
68
  templateAddress: PublishedTemplateAddress;
32
69
  }
33
70
 
71
+ /**
72
+ * Defines a method that can be invoked on a component in the Tari network.
73
+ */
34
74
  export interface TariMethodDefinition {
75
+ /**
76
+ * The name of the method to call on the component.
77
+ */
35
78
  methodName: string;
79
+ /**
80
+ * Array of {@link TransactionArg} representing the arguments to pass to the method.
81
+ * These can be either literal values or references to workspace variables.
82
+ */
36
83
  args?: TransactionArg[];
37
- // These are mutually exclusive i.e. either componentAddress or fromWorkspace (TODO: define this properly in typescript)
84
+ /**
85
+ * The address of the component to call the method on.
86
+ *
87
+ * @remarks
88
+ * - Format: a 64-character hexadecimal string (representing 32 bytes), optionally prefixed by `"component_"`.
89
+ * - Must correspond to a valid, existing component on the Tari network.
90
+ * - Mutually exclusive with {@link TariMethodDefinition.fromWorkspace}.
91
+ * - If not provided, the method will be called on the component in the current workspace.
92
+ *
93
+ * @example
94
+ * "component_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
95
+ */
38
96
  componentAddress?: ComponentAddress;
97
+ /**
98
+ * The workspace from which to call the method.
99
+ *
100
+ * @remarks
101
+ * - Mutually exclusive with {@link TariMethodDefinition.componentAddress}.
102
+ * - If provided, the method will be called on the component in the specified workspace.
103
+ * - The workspace must be defined in the current transaction context.
104
+ *
105
+ * @example
106
+ * "my_workspace"
107
+ */
39
108
  fromWorkspace?: string,
40
109
  }
41
110
 
111
+ /**
112
+ * Defines the interface for a Transaction Builder that allows constructing and signing transactions in the Tari network.
113
+ * This interface provides methods to add instructions, inputs, and other components to a transaction and then build a signed or unsigned transaction.
114
+ * The methods are chained together to allow for a fluent API style of transaction construction.
115
+ * The Builder interface is implemented by the {@link TransactionBuilder} class.
116
+ *
117
+ * @example
118
+ * // Usage:
119
+ * const builder: Builder = new TransactionBuilder();
120
+ * builder
121
+ * .createAccount(ownerPublicKey)
122
+ * .addInput(input)
123
+ * .withMinEpoch(5)
124
+ * .buildUnsignedTransaction();
125
+ */
42
126
  export interface Builder {
127
+ /**
128
+ * Adds a function call to the transaction, allowing the developer to invoke a function on a published template. This implements {@link TariFunctionDefinition}
129
+ * @param func - The function definition to call, which includes the function name, arguments, and template address.
130
+ * @param args - The arguments to pass to the function. These should be provided as an array of {@link NamedArg} objects. Optional.
131
+ * @returns The current instance of the Builder, allowing for method chaining.
132
+ */
43
133
  callFunction<T extends TariFunctionDefinition>(func: T, args: Exclude<T["args"], undefined>): this;
44
134
 
135
+ /**
136
+ * Adds a method call to the transaction, allowing the developer to invoke a method on a component. This implements {@link TariMethodDefinition}
137
+ * @param method - The method definition to call, which includes the method name, arguments, and component address.
138
+ * @param args - The arguments to pass to the method. These should be provided as an array of {@link TransactionArg} objects. Optional.
139
+ * @returns The current instance of the Builder, allowing for method chaining.
140
+ */
45
141
  callMethod<T extends TariMethodDefinition>(method: T, args: Exclude<T["args"], undefined>): this;
46
142
 
143
+ /**
144
+ * Adds an instruction to create a new account in the Tari Network to the transaction.
145
+ * @param ownerPublicKey - The public key of the account owner, represented as a 64-character hexadecimal string.
146
+ * @param workspaceBucket - An optional workspace bucket name to associate with the account. If provided, it will be used to create a workspace for the account. Allows for referencing the account elsewhere in the transaction without requiring it's address.
147
+ * @returns The current instance of the Builder, allowing for method chaining.
148
+ * @example
149
+ */
47
150
  createAccount(ownerPublicKey: string, workspaceBucket?: string): this;
48
151
 
152
+ /**
153
+ * Creates an internal proof that can be used to prove ownership of a resource in a component's account.
154
+ * @param account - The address of the component account that owns the resource. represented as a 64-character hexadecimal string, prepended with "component_".
155
+ * @param resourceAddress - The address of the resource to create a proof for, represented as a 64-character hexadecimal string, prepended with "resource_".
156
+ * @returns The current instance of the Builder, allowing for method chaining.
157
+ */
49
158
  createProof(account: ComponentAddress, resourceAddress: ResourceAddress): this;
50
159
 
160
+ /**
161
+ * Creates a variable in the workspace to store the output of the last instruction, which can be used later in the transaction.
162
+ * @param key - The name of the variable to save the last instruction's output to.
163
+ * @returns The current instance of the Builder, allowing for method chaining.
164
+ * @remarks
165
+ * Must be used after an instruction that produces an output, such as a function call or method call, and before any subsequent instructions that may use the saved variable.
166
+ */
51
167
  saveVar(key: string): this;
52
168
 
169
+ /**
170
+ * Calls a method to remove all proofs in the current workspace.
171
+ * @returns The current instance of the Builder, allowing for method chaining.
172
+ * @remarks
173
+ * Any proof references saved in the workspace via saveVar will be removed, invalidating any subsequent instructions that call on the variable.
174
+ */
53
175
  dropAllProofsInWorkspace(): this;
54
176
 
177
+ /**
178
+ * Adds a `ClaimBurn` instruction to the transaction, allowing the user to claim a previously burned confidential output.
179
+ *
180
+ * @param claim - A {@link ConfidentialClaim} object containing cryptographic proofs that authorize the claim. This includes the burn output address, ownership proof, range proof, and optional withdraw proof.
181
+ * @returns The current instance of the Builder, enabling method chaining.
182
+ * @remarks
183
+ * - The `ConfidentialClaim` must be constructed off-chain using valid cryptographic data.
184
+ * - If `withdraw_proof` is required by the burn process, it must be included.
185
+ * - This method should be used only when recovering burned confidential resources.
186
+ */
55
187
  claimBurn(claim: ConfidentialClaim): this;
56
188
 
189
+
57
190
  addInput(inputObject: SubstateRequirement): this;
58
191
 
192
+ /** Adds a raw instruction to the transaction.
193
+ *
194
+ * @param instruction - A fully-formed {@link Instruction} object, such as `CreateAccount`, `CallMethod`, `ClaimBurn`, etc.
195
+ *
196
+ * @returns The current instance of the Builder for method chaining.
197
+ *
198
+ * @remarks
199
+ * This method allows advanced or low-level access to the instruction set used in the Tari transaction engine.
200
+ * It should typically be used when:
201
+ * - A specific instruction is not exposed via a dedicated builder method (e.g. `EmitLog`, `ClaimValidatorFees`)
202
+ * - You need to construct instructions dynamically at runtime (e.g. from config files or user input)
203
+ * - You require more control over optional fields not exposed in convenience methods (e.g. custom `owner_rule`)
204
+ * - You are working with experimental or less-common instructions
205
+ *
206
+ * For common operations like creating accounts or calling methods, prefer high-level builder methods
207
+ * such as `createAccount()` or `callMethod()` for better readability and type safety.
208
+ */
59
209
  addInstruction(instruction: Instruction): this;
60
210
 
61
211
  addFeeInstruction(instruction: Instruction): this;
62
212
 
213
+ /**
214
+ * Allows for the addition of a condition to the transaction that requires the minimum epoch in which the transaction can be executed. Transaction fails if executed before this epoch.
215
+ * @param minEpoch - The minimum epoch in which the transaction can be executed. If not set, the transaction can be executed in any epoch.
216
+ * @returns The current instance of the Builder, allowing for method chaining.
217
+ */
63
218
  withMinEpoch(minEpoch: number): this;
64
219
 
220
+ /**
221
+ * Allows for the addition of a condition to the transaction that requires the maximum epoch in which the transaction can be executed. Transaction fails if executed after this epoch.
222
+ * @param maxEpoch - The maximum epoch in which the transaction can be executed. If not set, the transaction can be executed in any epoch.
223
+ * @returns The current instance of the Builder, allowing for method chaining.
224
+ */
65
225
  withMaxEpoch(maxEpoch: number): this;
66
226
 
227
+ /**
228
+ * Adds a substate requirement to the transaction, which is used to specify the inputs required for the transaction.
229
+ * @param inputs - An array of {@link SubstateRequirement} objects that define the inputs required for the transaction, consisting of substate IDs and optional versions. Typically, null version is used to indicate that any version of the substate is acceptable.
230
+ * @returns The current instance of the Builder, allowing for method
231
+ */
232
+
67
233
  withInputs(inputs: SubstateRequirement[]): this;
68
234
 
235
+ /**
236
+ * Similar to {@link addInstruction}, but allows for adding multiple instructions at once.
237
+ * @param instructions - An array of {@link Instruction} objects to add to the transaction. These instructions will be executed in the order they are added.
238
+ * @returns The current instance of the Builder, allowing for method chaining.
239
+ */
240
+
69
241
  withInstructions(instructions: Instruction[]): this;
70
242
 
243
+ /**
244
+ * Similar to {@link addFeeInstruction}, but allows for adding multiple fee instructions at once.
245
+ * This is useful for complex transactions that require multiple fee instructions.
246
+ * @param instructions - An array of {@link Instruction} objects to add as fee instructions. These instructions will be executed in the order they are added.
247
+ * @returns The current instance of the Builder, allowing for method chaining.
248
+ */
71
249
  withFeeInstructions(instructions: Instruction[]): this;
72
250
 
73
251
  withFeeInstructionsBuilder(builder: (builder: TransactionBuilder) => this): this;
74
252
 
253
+ /**
254
+ * Allows for setting an existing unsigned transaction to build upon. This is useful for modifying or extending an existing unsigned transaction.
255
+ * @param unsignedTransaction - An {@link UnsignedTransactionV1} object representing the base transaction to build upon.
256
+ * @returns The current instance of the Builder, allowing for method chaining.
257
+ * @remarks
258
+ * Using withUnsignedTransaction() overwrites the builder’s current unsigned transaction state with the provided one.
259
+ * Useful in cases where the unsigned transaction has been (partially) constructed already.
260
+ */
75
261
  withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this;
76
262
 
77
- feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: string): this;
263
+ /**
264
+ * Adds a method for specifying the component (typically an Account) that pays the transaction fee.
265
+ *
266
+ * @param componentAddress
267
+ * @param maxFee
268
+ * @remarks
269
+ * - The component must have a method `pay_fee` that calls `vault.pay_fee` with enough revealed confidential XTR.
270
+ * - Calls to vault.pay_fee lock up the `maxFee` amount for the duration of the transaction.
271
+ */
272
+ feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: Amount): this;
78
273
 
274
+ /**
275
+ * Similar to {@link feeTransactionPayFromComponent}, but allows for paying the transaction fee using a confidential withdraw proof.
276
+ *
277
+ * @param componentAddress - The address of the component from which to pay the fee, represented as a 64-character hexadecimal string, optionally prefixed by "component_".
278
+ * @param proof - A {@link ConfidentialWithdrawProof} object containing the necessary cryptographic proofs to authorize the fee payment.
279
+ */
79
280
  feeTransactionPayFromComponentConfidential(
80
281
  componentAddress: ComponentAddress,
81
282
  proof: ConfidentialWithdrawProof,
@@ -92,7 +293,7 @@ export class TransactionBuilder implements Builder {
92
293
  private allocatedIds: Map<string, number>;
93
294
  private current_id: number;
94
295
 
95
- constructor(network: number) {
296
+ constructor(network: Network | number) {
96
297
  this.unsignedTransaction = {
97
298
  network,
98
299
  fee_instructions: [],
@@ -108,6 +309,10 @@ export class TransactionBuilder implements Builder {
108
309
  this.current_id = 0;
109
310
  }
110
311
 
312
+ public static new(network: Network | number): TransactionBuilder {
313
+ return new TransactionBuilder(network);
314
+ }
315
+
111
316
  public callFunction<T extends TariFunctionDefinition>(func: T, args: Exclude<T["args"], undefined>): this {
112
317
  const resolvedArgs = this.resolveArgs(args);
113
318
  return this.addInstruction({
@@ -183,15 +388,15 @@ export class TransactionBuilder implements Builder {
183
388
  AssertBucketContains: {
184
389
  key,
185
390
  resource_address,
186
- min_amount,
391
+ min_amount: min_amount.getValue(),
187
392
  },
188
393
  });
189
394
  }
190
395
 
191
396
  /**
192
- * The `SaveVar` method replaces
397
+ * Puts the last instruction output into the workspace. These can be used as arguments subsequent instructions using `{Workspace: "my_name"}`.
398
+ * Alias to the `PutLastInstructionOutputOnWorkspace` instruction.
193
399
  * `PutLastInstructionOutputOnWorkspace: { key: Array<number> }`
194
- * to make saving variables easier.
195
400
  */
196
401
  public saveVar(name: string): this {
197
402
  let key = this.addNamedId(name);
@@ -203,23 +408,24 @@ export class TransactionBuilder implements Builder {
203
408
  }
204
409
 
205
410
  /**
206
- * Adds a fee instruction that calls the `take_fee` method on a component.
207
- * This method must exist and return a Bucket with containing revealed confidential XTR resource.
208
- * This allows the fee to originate from sources other than the transaction sender's account.
209
- * The fee instruction will lock up the `max_fee` amount for the duration of the transaction.
411
+ * Adds a fee instruction that calls the `pay_fee` method on a component (usually an Account).
412
+ * This method must call `vault.pay_fee` with a revealed confidential XTR resource.
413
+ * Calls to pay_fee lock up the `max_fee` amount for the duration of the transaction. Any remaining amount is
414
+ * returned to the component's vault.
210
415
  */
211
- public feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: string): this {
416
+ public feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: Amount): this {
212
417
  return this.addFeeInstruction({
213
418
  CallMethod: {
214
419
  call: { Address: componentAddress },
215
420
  method: "pay_fee",
216
- args: [maxFee],
421
+ // @ts-ignore TODO: once bindings are updated, remove ts-ignore
422
+ args: [maxFee.getValue()],
217
423
  },
218
424
  });
219
425
  }
220
426
 
221
427
  /**
222
- * Adds a fee instruction that calls the `take_fee_confidential` method on a component.
428
+ * Adds a fee instruction that calls the `pay_fee_confidential` method on a component.
223
429
  * This method must exist and return a Bucket with containing revealed confidential XTR resource.
224
430
  * This allows the fee to originate from sources other than the transaction sender's account.
225
431
  */
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/indexer-provider",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
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.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -80,7 +80,7 @@ export class MetamaskTariSigner implements TariSigner {
80
80
  account_id,
81
81
  address: res.address,
82
82
  public_key: res.public_key,
83
- resources: [],
83
+ vaults: [],
84
84
  };
85
85
  }
86
86
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-permissions",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/react-mui-connect-button",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "React component to connect your website to the Tari Ootle Wallet",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-provider",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,7 +1,6 @@
1
1
  import type { GetTemplateDefinitionResponse, ListTemplatesResponse } from "@tari-project/typescript-bindings";
2
2
  import {
3
3
  GetTransactionResultResponse,
4
- TemplateDefinition,
5
4
  Substate,
6
5
  ListSubstatesResponse,
7
6
  GetSubstateRequest,
@@ -10,10 +9,16 @@ import {
10
9
 
11
10
  export interface TariProvider {
12
11
  providerName: string;
12
+
13
13
  isConnected(): boolean;
14
+
14
15
  getSubstate(req: GetSubstateRequest): Promise<Substate>;
16
+
15
17
  getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
18
+
16
19
  getTemplateDefinition(template_address: string): Promise<GetTemplateDefinitionResponse>;
20
+
17
21
  listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
22
+
18
23
  listTemplates(limit?: number): Promise<ListTemplatesResponse>;
19
24
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tari-signer",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
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.11.0",
3
+ "version": "0.12.1",
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.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {