@tari-project/tarijs-builders 0.6.0 → 0.8.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.
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/workspace.d.ts +23 -13
- package/dist/helpers/workspace.js +16 -17
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/transaction/TransactionBuilder.d.ts +20 -10
- package/dist/transaction/TransactionBuilder.js +82 -27
- package/dist/transaction/TransactionRequest.d.ts +6 -13
- package/dist/transaction/TransactionRequest.js +26 -26
- package/package.json +5 -4
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult } from "./submitTransaction";
|
|
2
|
-
export {
|
|
2
|
+
export { parseWorkspaceStringKey, NamedArg } from "./workspace";
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult } from "./submitTransaction";
|
|
2
|
-
export {
|
|
2
|
+
export { parseWorkspaceStringKey } from "./workspace";
|
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransactionArg } from "@tari-project/tarijs-types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
|
8
|
+
export interface ParsedBuildersWorkspaceKey {
|
|
9
|
+
name: string;
|
|
10
|
+
offset: number | null;
|
|
11
|
+
}
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
|
-
* @param key workspace name
|
|
15
|
-
* @returns
|
|
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"
|
|
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
|
|
27
|
+
export type NamedArg = {
|
|
28
|
+
Workspace: string;
|
|
29
|
+
} | TransactionArg;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
|
-
* @param key workspace name
|
|
4
|
-
* @returns
|
|
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" -> "
|
|
7
|
-
* key: "bucket.0" -> "
|
|
8
|
-
* key: "bucket.1" -> "
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,
|
|
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,
|
|
3
|
+
export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult, parseWorkspaceStringKey, } from "./helpers";
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
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?:
|
|
9
|
+
args?: NamedArg[];
|
|
8
10
|
templateAddress: PublishedTemplateAddress;
|
|
9
11
|
}
|
|
10
12
|
export interface TariMethodDefinition {
|
|
11
13
|
methodName: string;
|
|
12
14
|
args?: TransactionArg[];
|
|
13
|
-
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:
|
|
42
|
+
withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this;
|
|
40
43
|
feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: string): this;
|
|
41
44
|
feeTransactionPayFromComponentConfidential(componentAddress: ComponentAddress, proof: ConfidentialWithdrawProof): this;
|
|
42
|
-
buildUnsignedTransaction():
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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:
|
|
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():
|
|
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
|
-
|
|
8
|
+
allocatedIds;
|
|
9
|
+
current_id;
|
|
10
|
+
constructor(network) {
|
|
9
11
|
this.unsignedTransaction = {
|
|
10
|
-
|
|
12
|
+
network,
|
|
13
|
+
fee_instructions: [],
|
|
11
14
|
instructions: [],
|
|
12
15
|
inputs: [],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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(
|
|
78
|
+
allocateAddress(allocatableType, workspaceId) {
|
|
79
|
+
const workspace_id = this.addNamedId(workspaceId);
|
|
62
80
|
return this.addInstruction({
|
|
63
81
|
AllocateAddress: {
|
|
64
|
-
|
|
65
|
-
workspace_id
|
|
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(
|
|
102
|
+
saveVar(name) {
|
|
103
|
+
let key = this.addNamedId(name);
|
|
75
104
|
return this.addInstruction({
|
|
76
105
|
PutLastInstructionOutputOnWorkspace: {
|
|
77
|
-
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,18 @@
|
|
|
1
|
-
import { Epoch, Instruction, SubstateRequirement, Transaction,
|
|
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
|
-
|
|
5
|
-
|
|
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():
|
|
7
|
+
getUnsignedTransaction(): UnsignedTransactionV1;
|
|
15
8
|
getFeeInstructions(): Instruction[];
|
|
16
9
|
getInstructions(): Instruction[];
|
|
17
10
|
getSignatures(): TransactionSignature[];
|
|
18
11
|
getInputs(): SubstateRequirement[];
|
|
19
12
|
getFilledInputs(): VersionedSubstateId[];
|
|
20
13
|
getFilledInputsMut(): VersionedSubstateId[];
|
|
21
|
-
getMinEpoch(): Epoch |
|
|
22
|
-
getMaxEpoch(): Epoch |
|
|
14
|
+
getMinEpoch(): Epoch | null;
|
|
15
|
+
getMaxEpoch(): Epoch | null;
|
|
23
16
|
setId(id: string): void;
|
|
24
17
|
getId(): string;
|
|
25
18
|
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
///TODO this implementation is not fully done, see:
|
|
2
|
-
/// https://github.com/tari-project/tari-
|
|
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
|
-
|
|
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.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
// Inputs filled by some authority. These are not part of the transaction hash nor the signature
|
|
21
|
+
filled_inputs: []
|
|
22
|
+
};
|
|
23
23
|
}
|
|
24
24
|
withFilledInputs(filled_inputs) {
|
|
25
25
|
return { ...this, filled_inputs };
|
|
26
26
|
}
|
|
27
27
|
getUnsignedTransaction() {
|
|
28
|
-
return this.
|
|
28
|
+
return this.V1.body.transaction;
|
|
29
29
|
}
|
|
30
30
|
getFeeInstructions() {
|
|
31
|
-
return this.
|
|
31
|
+
return this.V1.body.transaction.fee_instructions;
|
|
32
32
|
}
|
|
33
33
|
getInstructions() {
|
|
34
|
-
return this.instructions;
|
|
34
|
+
return this.V1.body.transaction.instructions;
|
|
35
35
|
}
|
|
36
36
|
getSignatures() {
|
|
37
|
-
return this.signatures;
|
|
37
|
+
return this.V1.body.signatures;
|
|
38
38
|
}
|
|
39
39
|
getInputs() {
|
|
40
|
-
return this.inputs;
|
|
40
|
+
return this.V1.body.transaction.inputs;
|
|
41
41
|
}
|
|
42
42
|
getFilledInputs() {
|
|
43
|
-
return this.
|
|
43
|
+
return this.V1.filled_inputs;
|
|
44
44
|
}
|
|
45
45
|
getFilledInputsMut() {
|
|
46
|
-
return this.
|
|
46
|
+
return this.V1.filled_inputs;
|
|
47
47
|
}
|
|
48
48
|
getMinEpoch() {
|
|
49
|
-
return this.
|
|
49
|
+
return this.V1.body.transaction.min_epoch;
|
|
50
50
|
}
|
|
51
51
|
getMaxEpoch() {
|
|
52
|
-
return this.
|
|
52
|
+
return this.V1.body.transaction.max_epoch;
|
|
53
53
|
}
|
|
54
54
|
setId(id) {
|
|
55
55
|
this.id = id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs-builders",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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/
|
|
14
|
-
"@tari-project/tari-
|
|
15
|
-
"@tari-project/
|
|
13
|
+
"@tari-project/typescript-bindings": ">=1.9.0",
|
|
14
|
+
"@tari-project/tari-signer": "^0.8.0",
|
|
15
|
+
"@tari-project/tari-universe-signer": "^0.8.0",
|
|
16
|
+
"@tari-project/tarijs-types": "^0.8.0"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@types/node": "^22.13.1",
|