@tari-project/tarijs-builders 0.6.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.
@@ -1,2 +1,2 @@
1
1
  export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult } from "./submitTransaction";
2
- export { fromWorkspace, toWorkspace } from "./workspace";
2
+ export { parseWorkspaceStringKey, NamedArg } from "./workspace";
@@ -1,2 +1,2 @@
1
1
  export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult } from "./submitTransaction";
2
- export { fromWorkspace, toWorkspace } from "./workspace";
2
+ export { parseWorkspaceStringKey } from "./workspace";
@@ -1,7 +1,9 @@
1
1
  import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
2
2
  import { TariSigner } from "@tari-project/tari-signer";
3
- import { Transaction, TransactionResult, DownSubstates, UpSubstates, SubmitTxResult, ReqSubstate, SubmitTransactionRequest } from "@tari-project/tarijs-types";
4
- export declare function buildTransactionRequest(transaction: Transaction, accountId: number, requiredSubstates: ReqSubstate[], inputRefs?: never[], isDryRun?: boolean, network?: number, isSealSignerAuthorized?: boolean, detectInputsUseUnversioned?: boolean): SubmitTransactionRequest;
3
+ import { TransactionResult, UnsignedTransactionV1 } from "@tari-project/typescript-bindings";
4
+ import { DownSubstates, UpSubstates, SubmitTransactionRequest } from "@tari-project/tarijs-types";
5
+ import { SubmitTxResult } from "@tari-project/tarijs-types/dist/TransactionResult";
6
+ export declare function buildTransactionRequest(transaction: UnsignedTransactionV1, accountId: number, detectInputsUseUnversioned?: boolean): SubmitTransactionRequest;
5
7
  export declare function submitAndWaitForTransaction(signer: TariSigner, req: SubmitTransactionRequest): Promise<SubmitTxResult>;
6
8
  export declare function waitForTransactionResult(signer: TariSigner | TariUniverseSigner, transactionId: string): Promise<TransactionResult>;
7
9
  export declare function getAcceptResultSubstates(txResult: TransactionResult): {
@@ -1,18 +1,9 @@
1
- import { TransactionStatus, } from "@tari-project/tarijs-types";
2
- import { getSubstateValueFromUpSubstates, substateIdToString, txResultCheck } from "@tari-project/tarijs-types";
3
- export function buildTransactionRequest(transaction, accountId, requiredSubstates, inputRefs = [], isDryRun = false, network = 0, isSealSignerAuthorized = true, detectInputsUseUnversioned = true) {
1
+ import { substateIdToString, } from "@tari-project/typescript-bindings";
2
+ import { getSubstateValueFromUpSubstates, TransactionStatus, } from "@tari-project/tarijs-types";
3
+ export function buildTransactionRequest(transaction, accountId, detectInputsUseUnversioned = true) {
4
4
  return {
5
- network,
5
+ transaction,
6
6
  account_id: accountId,
7
- instructions: transaction.instructions,
8
- fee_instructions: transaction.feeInstructions,
9
- inputs: transaction.inputs,
10
- input_refs: inputRefs,
11
- required_substates: requiredSubstates,
12
- is_dry_run: isDryRun,
13
- min_epoch: transaction.minEpoch ?? null,
14
- max_epoch: transaction.maxEpoch ?? null,
15
- is_seal_signer_authorized: isSealSignerAuthorized,
16
7
  detect_inputs_use_unversioned: detectInputsUseUnversioned,
17
8
  };
18
9
  }
@@ -62,21 +53,26 @@ export async function waitForTransactionResult(signer, transactionId) {
62
53
  throw new Error(`Transaction rejected: ${JSON.stringify(resp.result)}`);
63
54
  }
64
55
  if (FINALIZED_STATUSES.includes(resp.status)) {
65
- return resp;
56
+ return resp.result?.result;
66
57
  }
67
58
  await new Promise((resolve) => setTimeout(resolve, 1000));
68
59
  }
69
60
  }
70
61
  export function getAcceptResultSubstates(txResult) {
71
- const result = txResult.result?.result;
72
- if (result && txResultCheck.isAcceptFeeRejectRest(result)) {
62
+ if ("Accept" in txResult) {
73
63
  return {
74
- upSubstates: result.AcceptFeeRejectRest[0].up_substates,
75
- downSubstates: result.AcceptFeeRejectRest[0].down_substates,
64
+ upSubstates: txResult.Accept.up_substates,
65
+ downSubstates: txResult.Accept.down_substates,
76
66
  };
77
67
  }
78
- if (result && txResultCheck.isAccept(result)) {
79
- return { upSubstates: result.Accept.up_substates, downSubstates: result.Accept.down_substates };
68
+ if ("Reject" in txResult) {
69
+ throw new Error(`Transaction rejected: ${txResult.Reject}`);
80
70
  }
81
- return { upSubstates: [], downSubstates: [] };
71
+ if ("AcceptFeeRejectRest" in txResult) {
72
+ return {
73
+ upSubstates: txResult.AcceptFeeRejectRest[0].up_substates,
74
+ downSubstates: txResult.AcceptFeeRejectRest[0].down_substates,
75
+ };
76
+ }
77
+ throw new Error(`Unexpected transaction result: ${JSON.stringify(txResult)}`);
82
78
  }
@@ -1,19 +1,29 @@
1
- import { WorkspaceArg } from "@tari-project/tarijs-types";
1
+ import { TransactionArg } from "@tari-project/tarijs-types";
2
2
  /**
3
- *
4
- * @param key workspace name
5
- * @returns encoded hex value
6
- * @example
7
- * key: "bucket" -> "6275636b6574"
8
- * key: "bucket.0" -> "6275636b65742e30"
9
- * key: "bucket.1" -> "6275636b65742e31"
3
+ * A parsed workspace key string into an object with name and optional offset.
4
+ * Examples:
5
+ * "bucket" -> { name: "bucket", offset: undefined }
6
+ * "bucket.0" -> { name: "bucket", offset: 0 }
10
7
  */
11
- export declare function toWorkspace(key: string): string;
8
+ export interface ParsedBuildersWorkspaceKey {
9
+ name: string;
10
+ offset: number | null;
11
+ }
12
12
  /**
13
13
  *
14
- * @param key workspace name
15
- * @returns formatted Workspace data
14
+ * @param key workspace name. Offsets can be specified with a dot notation, e.g. "bucket.0"
15
+ * @returns Parsed workspace key object
16
16
  * @example
17
- * key: "bucket" -> { Workspace: "6275636b6574" }
17
+ * key: "bucket" -> { name: "bucket", offset: undefined }
18
+ * key: "bucket.0" -> { name: "bucket", offset: 0 }
19
+ * key: "bucket.1" -> { name: "bucket", offset: 1 }
20
+ */
21
+ export declare function parseWorkspaceStringKey(key: string): ParsedBuildersWorkspaceKey;
22
+ /**
23
+ * Either a literal Transaction Arg or a named workspace argument.
24
+ * Named workspace arguments are used to refer to a workspace by name,
25
+ * and are converted to numeric IDs by the TransactionBuilder.
18
26
  */
19
- export declare function fromWorkspace(key: string): WorkspaceArg;
27
+ export type NamedArg = {
28
+ Workspace: string;
29
+ } | TransactionArg;
@@ -1,22 +1,21 @@
1
1
  /**
2
2
  *
3
- * @param key workspace name
4
- * @returns encoded hex value
3
+ * @param key workspace name. Offsets can be specified with a dot notation, e.g. "bucket.0"
4
+ * @returns Parsed workspace key object
5
5
  * @example
6
- * key: "bucket" -> "6275636b6574"
7
- * key: "bucket.0" -> "6275636b65742e30"
8
- * key: "bucket.1" -> "6275636b65742e31"
6
+ * key: "bucket" -> { name: "bucket", offset: undefined }
7
+ * key: "bucket.0" -> { name: "bucket", offset: 0 }
8
+ * key: "bucket.1" -> { name: "bucket", offset: 1 }
9
9
  */
10
- export function toWorkspace(key) {
11
- return Buffer.from(key).toString("hex");
12
- }
13
- /**
14
- *
15
- * @param key workspace name
16
- * @returns formatted Workspace data
17
- * @example
18
- * key: "bucket" -> { Workspace: "6275636b6574" }
19
- */
20
- export function fromWorkspace(key) {
21
- return { Workspace: Buffer.from(key).toString("hex") };
10
+ export function parseWorkspaceStringKey(key) {
11
+ const parts = key.split(".");
12
+ if (parts.length > 2) {
13
+ throw new Error("Invalid workspace key format. Only one dot is allowed.");
14
+ }
15
+ const name = parts[0];
16
+ const offset = parts[1] ? parseInt(parts[1], 10) : null;
17
+ return {
18
+ name,
19
+ offset,
20
+ };
22
21
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from "@tari-project/tarijs-types";
2
2
  export { TransactionBuilder, TransactionRequest, TariMethodDefinition, TariFunctionDefinition } from "./transaction";
3
- export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult, fromWorkspace, toWorkspace, } from "./helpers";
3
+ export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult, parseWorkspaceStringKey, } from "./helpers";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from "@tari-project/tarijs-types";
2
2
  export { TransactionBuilder, TransactionRequest } from "./transaction";
3
- export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult, fromWorkspace, toWorkspace, } from "./helpers";
3
+ export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult, parseWorkspaceStringKey, } from "./helpers";
@@ -1,16 +1,19 @@
1
- import { ComponentAddress, ConfidentialClaim, ConfidentialWithdrawProof, Instruction, ResourceAddress, SubstateRequirement, Transaction, TransactionSignature, UnsignedTransaction, PublishedTemplateAddress, SubstateType, TransactionArg } from "@tari-project/tarijs-types";
1
+ import { TransactionArg } from "@tari-project/tarijs-types";
2
+ import { Amount, ComponentAddress, ConfidentialClaim, ConfidentialWithdrawProof, Instruction, ResourceAddress, SubstateRequirement, Transaction, TransactionSignature, UnsignedTransaction, PublishedTemplateAddress, UnsignedTransactionV1, AllocatableAddressType } from "@tari-project/typescript-bindings";
3
+ import { NamedArg } from "../helpers/workspace";
2
4
  export interface TransactionConstructor {
3
5
  new (unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]): Transaction;
4
6
  }
5
7
  export interface TariFunctionDefinition {
6
8
  functionName: string;
7
- args?: TransactionArg[];
9
+ args?: NamedArg[];
8
10
  templateAddress: PublishedTemplateAddress;
9
11
  }
10
12
  export interface TariMethodDefinition {
11
13
  methodName: string;
12
14
  args?: TransactionArg[];
13
- componentAddress: ComponentAddress;
15
+ componentAddress?: ComponentAddress;
16
+ fromWorkspace?: string;
14
17
  }
15
18
  export interface TariCreateAccountDefinition {
16
19
  methodName: string;
@@ -36,28 +39,31 @@ export interface Builder {
36
39
  withInstructions(instructions: Instruction[]): this;
37
40
  withFeeInstructions(instructions: Instruction[]): this;
38
41
  withFeeInstructionsBuilder(builder: (builder: TransactionBuilder) => this): this;
39
- withUnsignedTransaction(unsignedTransaction: UnsignedTransaction): this;
42
+ withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this;
40
43
  feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: string): this;
41
44
  feeTransactionPayFromComponentConfidential(componentAddress: ComponentAddress, proof: ConfidentialWithdrawProof): this;
42
- buildUnsignedTransaction(): UnsignedTransaction;
45
+ buildUnsignedTransaction(): UnsignedTransactionV1;
43
46
  build(): Transaction;
44
47
  }
45
48
  export declare class TransactionBuilder implements Builder {
46
49
  private unsignedTransaction;
47
50
  private signatures;
48
- constructor();
51
+ private allocatedIds;
52
+ private current_id;
53
+ constructor(network: number);
49
54
  callFunction<T extends TariFunctionDefinition>(func: T, args: Exclude<T["args"], undefined>): this;
50
55
  callMethod<T extends TariMethodDefinition>(method: T, args: Exclude<T["args"], undefined>): this;
51
56
  createAccount(ownerPublicKey: string, workspaceBucket?: string): this;
52
57
  createProof(account: ComponentAddress, resourceAddress: ResourceAddress): this;
53
58
  claimBurn(claim: ConfidentialClaim): this;
54
- allocateAddress(substateType: SubstateType, workspaceId: string): this;
59
+ allocateAddress(allocatableType: AllocatableAddressType, workspaceId: string): this;
60
+ assertBucketContains(workspaceName: string, resource_address: ResourceAddress, min_amount: Amount): this;
55
61
  /**
56
62
  * The `SaveVar` method replaces
57
63
  * `PutLastInstructionOutputOnWorkspace: { key: Array<number> }`
58
64
  * to make saving variables easier.
59
65
  */
60
- saveVar(key: string): this;
66
+ saveVar(name: string): this;
61
67
  /**
62
68
  * Adds a fee instruction that calls the `take_fee` method on a component.
63
69
  * This method must exist and return a Bucket with containing revealed confidential XTR resource.
@@ -72,7 +78,7 @@ export declare class TransactionBuilder implements Builder {
72
78
  */
73
79
  feeTransactionPayFromComponentConfidential(componentAddress: ComponentAddress, proof: ConfidentialWithdrawProof): this;
74
80
  dropAllProofsInWorkspace(): this;
75
- withUnsignedTransaction(unsignedTransaction: UnsignedTransaction): this;
81
+ withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this;
76
82
  withFeeInstructions(instructions: Instruction[]): this;
77
83
  withFeeInstructionsBuilder(builder: (builder: TransactionBuilder) => TransactionBuilder): this;
78
84
  addInstruction(instruction: Instruction): this;
@@ -82,6 +88,10 @@ export declare class TransactionBuilder implements Builder {
82
88
  withInputs(inputs: SubstateRequirement[]): this;
83
89
  withMinEpoch(minEpoch: number): this;
84
90
  withMaxEpoch(maxEpoch: number): this;
85
- buildUnsignedTransaction(): UnsignedTransaction;
91
+ buildUnsignedTransaction(): UnsignedTransactionV1;
86
92
  build(): Transaction;
93
+ private addNamedId;
94
+ private getNamedId;
95
+ private getOffsetIdFromWorkspaceName;
96
+ private resolveArgs;
87
97
  }
@@ -1,51 +1,68 @@
1
1
  // Copyright 2024 The Tari Project
2
2
  // SPDX-License-Identifier: BSD-3-Clause
3
- import { toWorkspace } from "../helpers";
4
3
  import { TransactionRequest } from "./TransactionRequest";
4
+ import { parseWorkspaceStringKey } from "../helpers";
5
5
  export class TransactionBuilder {
6
6
  unsignedTransaction;
7
7
  signatures;
8
- constructor() {
8
+ allocatedIds;
9
+ current_id;
10
+ constructor(network) {
9
11
  this.unsignedTransaction = {
10
- feeInstructions: [],
12
+ network,
13
+ fee_instructions: [],
11
14
  instructions: [],
12
15
  inputs: [],
13
- filledInputs: [],
14
- minEpoch: undefined,
15
- maxEpoch: undefined,
16
+ min_epoch: null,
17
+ max_epoch: null,
18
+ dry_run: false,
19
+ is_seal_signer_authorized: false
16
20
  };
17
21
  this.signatures = [];
22
+ this.allocatedIds = new Map();
23
+ this.current_id = 0;
18
24
  }
19
25
  callFunction(func, args) {
26
+ const resolvedArgs = this.resolveArgs(args);
20
27
  return this.addInstruction({
21
28
  CallFunction: {
22
- template_address: func.templateAddress,
29
+ address: func.templateAddress,
23
30
  function: func.functionName,
24
- args,
31
+ args: resolvedArgs,
25
32
  },
26
33
  });
27
34
  }
28
35
  callMethod(method, args) {
36
+ const call = method.componentAddress ?
37
+ { Address: method.componentAddress } :
38
+ // NOTE: offset IDs are not supported for method calls
39
+ { Workspace: this.getNamedId(method.fromWorkspace) };
40
+ const resolvedArgs = this.resolveArgs(args);
29
41
  return this.addInstruction({
30
42
  CallMethod: {
31
- component_address: method.componentAddress,
43
+ call,
32
44
  method: method.methodName,
33
- args,
45
+ args: resolvedArgs,
34
46
  },
35
47
  });
36
48
  }
37
49
  createAccount(ownerPublicKey, workspaceBucket) {
50
+ const workspace_id = workspaceBucket ?
51
+ this.getOffsetIdFromWorkspaceName(workspaceBucket) :
52
+ null;
38
53
  return this.addInstruction({
39
54
  CreateAccount: {
40
- owner_public_key: ownerPublicKey,
41
- workspace_bucket: workspaceBucket ?? null,
55
+ public_key_address: ownerPublicKey,
56
+ owner_rule: null, // Custom owner rule is not set by default
57
+ access_rules: null, // Custom access rules are not set by default
58
+ workspace_id,
42
59
  },
43
60
  });
44
61
  }
45
62
  createProof(account, resourceAddress) {
46
63
  return this.addInstruction({
47
64
  CallMethod: {
48
- component_address: account,
65
+ call: { Address: account },
49
66
  method: "create_proof_for_resource",
50
67
  args: [resourceAddress],
51
68
  },
@@ -58,11 +75,22 @@ export class TransactionBuilder {
58
75
  },
59
76
  });
60
77
  }
61
- allocateAddress(substateType, workspaceId) {
78
+ allocateAddress(allocatableType, workspaceId) {
79
+ const workspace_id = this.addNamedId(workspaceId);
62
80
  return this.addInstruction({
63
81
  AllocateAddress: {
64
- substate_type: substateType,
65
- workspace_id: workspaceId,
82
+ allocatable_type: allocatableType,
83
+ workspace_id,
84
+ },
85
+ });
86
+ }
87
+ assertBucketContains(workspaceName, resource_address, min_amount) {
88
+ const key = this.getOffsetIdFromWorkspaceName(workspaceName);
89
+ return this.addInstruction({
90
+ AssertBucketContains: {
91
+ key,
92
+ resource_address,
93
+ min_amount,
66
94
  },
67
95
  });
68
96
  }
@@ -71,10 +99,11 @@ export class TransactionBuilder {
71
99
  * `PutLastInstructionOutputOnWorkspace: { key: Array<number> }`
72
100
  * to make saving variables easier.
73
101
  */
74
- saveVar(key) {
102
+ saveVar(name) {
103
+ let key = this.addNamedId(name);
75
104
  return this.addInstruction({
76
105
  PutLastInstructionOutputOnWorkspace: {
77
- key: toWorkspace(key),
106
+ key,
78
107
  },
79
108
  });
80
109
  }
@@ -87,7 +116,7 @@ export class TransactionBuilder {
87
116
  feeTransactionPayFromComponent(componentAddress, maxFee) {
88
117
  return this.addFeeInstruction({
89
118
  CallMethod: {
90
- component_address: componentAddress,
119
+ call: { Address: componentAddress },
91
120
  method: "pay_fee",
92
121
  args: [maxFee],
93
122
  },
@@ -101,7 +130,7 @@ export class TransactionBuilder {
101
130
  feeTransactionPayFromComponentConfidential(componentAddress, proof) {
102
131
  return this.addFeeInstruction({
103
132
  CallMethod: {
104
- component_address: componentAddress,
133
+ call: { Address: componentAddress },
105
134
  method: "pay_fee_confidential",
106
135
  args: [proof],
107
136
  },
@@ -116,13 +145,13 @@ export class TransactionBuilder {
116
145
  return this;
117
146
  }
118
147
  withFeeInstructions(instructions) {
119
- this.unsignedTransaction.feeInstructions = instructions;
148
+ this.unsignedTransaction.fee_instructions = instructions;
120
149
  this.signatures = [];
121
150
  return this;
122
151
  }
123
152
  withFeeInstructionsBuilder(builder) {
124
- const newBuilder = builder(new TransactionBuilder());
125
- this.unsignedTransaction.feeInstructions = newBuilder.unsignedTransaction.instructions;
153
+ const newBuilder = builder(new TransactionBuilder(this.unsignedTransaction.network));
154
+ this.unsignedTransaction.fee_instructions = newBuilder.unsignedTransaction.instructions;
126
155
  this.signatures = [];
127
156
  return this;
128
157
  }
@@ -132,7 +161,7 @@ export class TransactionBuilder {
132
161
  return this;
133
162
  }
134
163
  addFeeInstruction(instruction) {
135
- this.unsignedTransaction.feeInstructions.push(instruction);
164
+ this.unsignedTransaction.fee_instructions.push(instruction);
136
165
  this.signatures = [];
137
166
  return this;
138
167
  }
@@ -152,13 +181,13 @@ export class TransactionBuilder {
152
181
  return this;
153
182
  }
154
183
  withMinEpoch(minEpoch) {
155
- this.unsignedTransaction.minEpoch = minEpoch;
184
+ this.unsignedTransaction.min_epoch = minEpoch;
156
185
  // Reset the signatures as they are no longer valid
157
186
  this.signatures = [];
158
187
  return this;
159
188
  }
160
189
  withMaxEpoch(maxEpoch) {
161
- this.unsignedTransaction.maxEpoch = maxEpoch;
190
+ this.unsignedTransaction.max_epoch = maxEpoch;
162
191
  // Reset the signatures as they are no longer valid
163
192
  this.signatures = [];
164
193
  return this;
@@ -167,6 +196,32 @@ export class TransactionBuilder {
167
196
  return this.unsignedTransaction;
168
197
  }
169
198
  build() {
170
- return new TransactionRequest(this.unsignedTransaction, this.signatures);
199
+ return new TransactionRequest(this.buildUnsignedTransaction(), this.signatures);
200
+ }
201
+ addNamedId(name) {
202
+ const id = this.current_id;
203
+ this.allocatedIds.set(name, id);
204
+ this.current_id += 1;
205
+ return id;
206
+ }
207
+ getNamedId(name) {
208
+ return this.allocatedIds.get(name);
209
+ }
210
+ getOffsetIdFromWorkspaceName(name) {
211
+ const parsed = parseWorkspaceStringKey(name);
212
+ const id = this.getNamedId(parsed.name);
213
+ if (id === undefined) {
214
+ throw new Error(`No workspace with name ${parsed.name} found`);
215
+ }
216
+ return { id, offset: parsed.offset };
217
+ }
218
+ resolveArgs(args) {
219
+ return args.map((arg) => {
220
+ if (typeof arg === "object" && "Workspace" in arg) {
221
+ const workspaceId = this.getOffsetIdFromWorkspaceName(arg.Workspace);
222
+ return { Workspace: workspaceId };
223
+ }
224
+ return arg;
225
+ });
171
226
  }
172
227
  }
@@ -1,25 +1,16 @@
1
- import { Epoch, Instruction, SubstateRequirement, Transaction, TransactionSignature, UnsignedTransaction, VersionedSubstateId } from "@tari-project/tarijs-types";
1
+ import { Epoch, Instruction, SubstateRequirement, Transaction, UnsignedTransactionV1, TransactionSignature, VersionedSubstateId, TransactionV1 } from "@tari-project/typescript-bindings";
2
2
  export declare class TransactionRequest implements Transaction {
3
3
  id: string;
4
- feeInstructions: Array<Instruction>;
5
- instructions: Array<Instruction>;
6
- inputs: Array<SubstateRequirement>;
7
- signatures: Array<TransactionSignature>;
8
- unsignedTransaction: UnsignedTransaction;
9
- minEpoch?: Epoch;
10
- maxEpoch?: Epoch;
11
- filledInputs: VersionedSubstateId[];
12
- constructor(unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]);
4
+ V1: TransactionV1;
5
+ constructor(unsignedTransaction: UnsignedTransactionV1, signatures: TransactionSignature[]);
13
6
  withFilledInputs(filled_inputs: Array<VersionedSubstateId>): this;
14
- getUnsignedTransaction(): UnsignedTransaction;
7
+ getUnsignedTransaction(): UnsignedTransactionV1;
15
8
  getFeeInstructions(): Instruction[];
16
9
  getInstructions(): Instruction[];
17
10
  getSignatures(): TransactionSignature[];
18
11
  getInputs(): SubstateRequirement[];
19
- getFilledInputs(): VersionedSubstateId[];
20
- getFilledInputsMut(): VersionedSubstateId[];
21
- getMinEpoch(): Epoch | undefined;
22
- getMaxEpoch(): Epoch | undefined;
12
+ getMinEpoch(): Epoch | null;
13
+ getMaxEpoch(): Epoch | null;
23
14
  setId(id: string): void;
24
15
  getId(): string;
25
16
  }
@@ -1,55 +1,47 @@
1
1
  ///TODO this implementation is not fully done, see:
2
- /// https://github.com/tari-project/tari-dan/blob/development/dan_layer/transaction/src/transaction.rs
2
+ /// https://github.com/tari-project/tari-ootle/blob/development/dan_layer/transaction/src/transaction.rs
3
3
  export class TransactionRequest {
4
4
  id;
5
- feeInstructions;
6
- instructions;
7
- inputs;
8
- signatures;
9
- unsignedTransaction;
10
- minEpoch;
11
- maxEpoch;
12
- filledInputs;
5
+ V1;
13
6
  constructor(unsignedTransaction, signatures) {
14
7
  this.id = "";
15
- this.feeInstructions = unsignedTransaction.feeInstructions;
16
- this.instructions = unsignedTransaction.instructions;
17
- this.inputs = unsignedTransaction.inputs;
18
- this.signatures = signatures;
19
- this.minEpoch = unsignedTransaction.minEpoch;
20
- this.maxEpoch = unsignedTransaction.maxEpoch;
21
- // Inputs filled by some authority. These are not part of the transaction hash nor the signature
22
- this.filledInputs = [];
8
+ this.V1 = {
9
+ body: {
10
+ transaction: unsignedTransaction,
11
+ signatures,
12
+ },
13
+ seal_signature: {
14
+ public_key: "",
15
+ signature: {
16
+ public_nonce: "",
17
+ signature: "",
18
+ },
19
+ },
20
+ };
23
21
  }
24
22
  withFilledInputs(filled_inputs) {
25
23
  return { ...this, filled_inputs };
26
24
  }
27
25
  getUnsignedTransaction() {
28
- return this.unsignedTransaction;
26
+ return this.V1.body.transaction;
29
27
  }
30
28
  getFeeInstructions() {
31
- return this.feeInstructions;
29
+ return this.V1.body.transaction.fee_instructions;
32
30
  }
33
31
  getInstructions() {
34
- return this.instructions;
32
+ return this.V1.body.transaction.instructions;
35
33
  }
36
34
  getSignatures() {
37
- return this.signatures;
35
+ return this.V1.body.signatures;
38
36
  }
39
37
  getInputs() {
40
- return this.inputs;
41
- }
42
- getFilledInputs() {
43
- return this.filledInputs;
44
- }
45
- getFilledInputsMut() {
46
- return this.filledInputs;
38
+ return this.V1.body.transaction.inputs;
47
39
  }
48
40
  getMinEpoch() {
49
- return this.minEpoch;
41
+ return this.V1.body.transaction.min_epoch;
50
42
  }
51
43
  getMaxEpoch() {
52
- return this.maxEpoch;
44
+ return this.V1.body.transaction.max_epoch;
53
45
  }
54
46
  setId(id) {
55
47
  this.id = id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-builders",
3
- "version": "0.6.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,9 +10,10 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@tari-project/tari-signer": "^0.6.0",
14
- "@tari-project/tari-universe-signer": "^0.6.0",
15
- "@tari-project/tarijs-types": "^0.6.0"
13
+ "@tari-project/typescript-bindings": ">=1.9.1",
14
+ "@tari-project/tari-universe-signer": "^0.9.0",
15
+ "@tari-project/tarijs-types": "^0.9.0",
16
+ "@tari-project/tari-signer": "^0.9.0"
16
17
  },
17
18
  "devDependencies": {
18
19
  "@types/node": "^22.13.1",