@tari-project/tarijs 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/.github/PULL_REQUEST_TEMPLATE.md +2 -12
- package/Dockerfile +2 -2
- package/README.md +1 -1
- package/docusaurus/tari-docs/docs/provider-vs-signer.md +27 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +0 -1
- package/docusaurus/tari-docs/package-lock.json +17964 -0
- package/docusaurus/tari-docs/package.json +2 -2
- package/package.json +1 -1
- package/packages/builders/package.json +3 -2
- package/packages/builders/src/helpers/index.ts +1 -1
- package/packages/builders/src/helpers/workspace.ts +32 -15
- package/packages/builders/src/index.ts +1 -2
- package/packages/builders/src/transaction/TransactionBuilder.ts +105 -38
- package/packages/builders/src/transaction/TransactionRequest.ts +36 -33
- package/packages/indexer_provider/package.json +1 -1
- package/packages/metamask_signer/package.json +1 -1
- package/packages/metamask_signer/src/index.ts +1 -1
- package/packages/tari_permissions/package.json +1 -1
- package/packages/tari_permissions/src/tari_permissions.ts +1 -17
- package/packages/tari_provider/package.json +1 -1
- package/packages/tari_signer/package.json +1 -1
- package/packages/tari_universe/package.json +1 -1
- package/packages/tarijs/package.json +1 -1
- package/packages/tarijs/src/index.ts +0 -4
- package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +37 -2
- package/packages/tarijs_types/package.json +1 -1
- package/packages/tarijs_types/src/Instruction.ts +6 -2
- package/packages/tarijs_types/src/SubstateType.ts +1 -1
- package/packages/wallet_daemon/package.json +1 -1
- package/packages/wallet_daemon/src/signer.ts +1 -0
- package/packages/walletconnect/package.json +1 -1
- package/packages/walletconnect/src/index.ts +1 -0
- package/pnpm-workspace.yaml +2 -2
- package/scripts/check_versions.sh +2 -2
- package/scripts/set_package_versions.sh +39 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tari-docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docusaurus": "docusaurus",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"typecheck": "tsc"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@docusaurus/core": "3.7.0",
|
|
18
|
+
"@docusaurus/core": "^3.7.0",
|
|
19
19
|
"@docusaurus/preset-classic": "3.7.0",
|
|
20
20
|
"@docusaurus/remark-plugin-npm2yarn": "^3.7.0",
|
|
21
21
|
"@mdx-js/react": "^3.0.0",
|
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": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@tari-project/tari-signer": "workspace:^",
|
|
17
17
|
"@tari-project/tari-universe-signer": "workspace:^",
|
|
18
|
-
"@tari-project/tarijs-types": "workspace:^"
|
|
18
|
+
"@tari-project/tarijs-types": "workspace:^",
|
|
19
|
+
"@tari-project/typescript-bindings": "catalog:"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@types/node": "catalog:",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { buildTransactionRequest, submitAndWaitForTransaction, waitForTransactionResult } from "./submitTransaction";
|
|
2
|
-
export {
|
|
2
|
+
export { parseWorkspaceStringKey, NamedArg } from "./workspace";
|
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
import { WorkspaceArg } from "@tari-project/tarijs-types";
|
|
1
|
+
import { TransactionArg, WorkspaceArg } from "@tari-project/tarijs-types";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* key: "bucket" -> "6275636b6574"
|
|
9
|
-
* key: "bucket.0" -> "6275636b65742e30"
|
|
10
|
-
* key: "bucket.1" -> "6275636b65742e31"
|
|
4
|
+
* A parsed workspace key string into an object with name and optional offset.
|
|
5
|
+
* Examples:
|
|
6
|
+
* "bucket" -> { name: "bucket", offset: undefined }
|
|
7
|
+
* "bucket.0" -> { name: "bucket", offset: 0 }
|
|
11
8
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
9
|
+
export interface ParsedBuildersWorkspaceKey {
|
|
10
|
+
name: string;
|
|
11
|
+
offset: number | null;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
*
|
|
18
|
-
* @param key workspace name
|
|
19
|
-
* @returns
|
|
16
|
+
* @param key workspace name. Offsets can be specified with a dot notation, e.g. "bucket.0"
|
|
17
|
+
* @returns Parsed workspace key object
|
|
20
18
|
* @example
|
|
21
|
-
* key: "bucket"
|
|
19
|
+
* key: "bucket" -> { name: "bucket", offset: undefined }
|
|
20
|
+
* key: "bucket.0" -> { name: "bucket", offset: 0 }
|
|
21
|
+
* key: "bucket.1" -> { name: "bucket", offset: 1 }
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
24
|
-
|
|
23
|
+
export function parseWorkspaceStringKey(key: string): ParsedBuildersWorkspaceKey {
|
|
24
|
+
const parts = key.split(".");
|
|
25
|
+
if (parts.length > 2) {
|
|
26
|
+
throw new Error("Invalid workspace key format. Only one dot is allowed.");
|
|
27
|
+
}
|
|
28
|
+
const name = parts[0];
|
|
29
|
+
const offset = parts[1] ? parseInt(parts[1], 10) : null;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
name,
|
|
33
|
+
offset,
|
|
34
|
+
};
|
|
25
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Either a literal Transaction Arg or a named workspace argument.
|
|
39
|
+
* Named workspace arguments are used to refer to a workspace by name,
|
|
40
|
+
* and are converted to numeric IDs by the TransactionBuilder.
|
|
41
|
+
*/
|
|
42
|
+
export type NamedArg = { Workspace: string } | TransactionArg;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright 2024 The Tari Project
|
|
2
2
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
-
import { toWorkspace } from "../helpers";
|
|
4
3
|
|
|
5
4
|
import { TransactionRequest } from "./TransactionRequest";
|
|
5
|
+
import { TransactionArg } from "@tari-project/tarijs-types";
|
|
6
6
|
import {
|
|
7
|
+
Amount,
|
|
7
8
|
ComponentAddress,
|
|
8
9
|
ConfidentialClaim,
|
|
9
10
|
ConfidentialWithdrawProof,
|
|
@@ -14,24 +15,28 @@ import {
|
|
|
14
15
|
TransactionSignature,
|
|
15
16
|
UnsignedTransaction,
|
|
16
17
|
PublishedTemplateAddress,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "@tari-project/
|
|
18
|
+
WorkspaceOffsetId,
|
|
19
|
+
UnsignedTransactionV1, AllocatableAddressType,
|
|
20
|
+
} from "@tari-project/typescript-bindings";
|
|
21
|
+
import { parseWorkspaceStringKey } from "../helpers";
|
|
22
|
+
import { NamedArg } from "../helpers/workspace";
|
|
20
23
|
|
|
21
24
|
export interface TransactionConstructor {
|
|
22
|
-
new
|
|
25
|
+
new(unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]): Transaction;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export interface TariFunctionDefinition {
|
|
26
29
|
functionName: string;
|
|
27
|
-
args?:
|
|
30
|
+
args?: NamedArg[];
|
|
28
31
|
templateAddress: PublishedTemplateAddress;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export interface TariMethodDefinition {
|
|
32
35
|
methodName: string;
|
|
33
36
|
args?: TransactionArg[];
|
|
34
|
-
componentAddress:
|
|
37
|
+
// These are mutually exclusive i.e. either componentAddress or fromWorkspace (TODO: define this properly in typescript)
|
|
38
|
+
componentAddress?: ComponentAddress;
|
|
39
|
+
fromWorkspace?: string,
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
export interface TariCreateAccountDefinition {
|
|
@@ -75,7 +80,7 @@ export interface Builder {
|
|
|
75
80
|
|
|
76
81
|
withFeeInstructionsBuilder(builder: (builder: TransactionBuilder) => this): this;
|
|
77
82
|
|
|
78
|
-
withUnsignedTransaction(unsignedTransaction:
|
|
83
|
+
withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this;
|
|
79
84
|
|
|
80
85
|
feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: string): this;
|
|
81
86
|
|
|
@@ -84,52 +89,70 @@ export interface Builder {
|
|
|
84
89
|
proof: ConfidentialWithdrawProof,
|
|
85
90
|
): this;
|
|
86
91
|
|
|
87
|
-
buildUnsignedTransaction():
|
|
92
|
+
buildUnsignedTransaction(): UnsignedTransactionV1;
|
|
88
93
|
|
|
89
94
|
build(): Transaction;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
export class TransactionBuilder implements Builder {
|
|
93
|
-
private unsignedTransaction:
|
|
98
|
+
private unsignedTransaction: UnsignedTransactionV1;
|
|
94
99
|
private signatures: TransactionSignature[];
|
|
100
|
+
private allocatedIds: Map<string, number>;
|
|
101
|
+
private current_id: number;
|
|
95
102
|
|
|
96
|
-
constructor() {
|
|
103
|
+
constructor(network: number) {
|
|
97
104
|
this.unsignedTransaction = {
|
|
98
|
-
|
|
105
|
+
network,
|
|
106
|
+
fee_instructions: [],
|
|
99
107
|
instructions: [],
|
|
100
108
|
inputs: [],
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
min_epoch: null,
|
|
110
|
+
max_epoch: null,
|
|
111
|
+
dry_run: false,
|
|
112
|
+
is_seal_signer_authorized: false
|
|
104
113
|
};
|
|
105
114
|
this.signatures = [];
|
|
115
|
+
this.allocatedIds = new Map();
|
|
116
|
+
this.current_id = 0;
|
|
106
117
|
}
|
|
107
118
|
|
|
108
119
|
public callFunction<T extends TariFunctionDefinition>(func: T, args: Exclude<T["args"], undefined>): this {
|
|
120
|
+
const resolvedArgs = this.resolveArgs(args);
|
|
109
121
|
return this.addInstruction({
|
|
110
122
|
CallFunction: {
|
|
111
|
-
|
|
123
|
+
address: func.templateAddress,
|
|
112
124
|
function: func.functionName,
|
|
113
|
-
args,
|
|
125
|
+
args: resolvedArgs,
|
|
114
126
|
},
|
|
115
127
|
});
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
public callMethod<T extends TariMethodDefinition>(method: T, args: Exclude<T["args"], undefined>): this {
|
|
131
|
+
const call = method.componentAddress ?
|
|
132
|
+
{ Address: method.componentAddress } :
|
|
133
|
+
// NOTE: offset IDs are not supported for method calls
|
|
134
|
+
{ Workspace: this.getNamedId(method.fromWorkspace!)! };
|
|
135
|
+
const resolvedArgs = this.resolveArgs(args);
|
|
119
136
|
return this.addInstruction({
|
|
120
137
|
CallMethod: {
|
|
121
|
-
|
|
138
|
+
call,
|
|
122
139
|
method: method.methodName,
|
|
123
|
-
args,
|
|
140
|
+
args: resolvedArgs,
|
|
124
141
|
},
|
|
125
142
|
});
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
public createAccount(ownerPublicKey: string, workspaceBucket?: string): this {
|
|
146
|
+
const workspace_id = workspaceBucket ?
|
|
147
|
+
this.getOffsetIdFromWorkspaceName(workspaceBucket) :
|
|
148
|
+
null;
|
|
149
|
+
|
|
129
150
|
return this.addInstruction({
|
|
130
151
|
CreateAccount: {
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
public_key_address: ownerPublicKey,
|
|
153
|
+
owner_rule: null, // Custom owner rule is not set by default
|
|
154
|
+
access_rules: null, // Custom access rules are not set by default
|
|
155
|
+
workspace_id,
|
|
133
156
|
},
|
|
134
157
|
});
|
|
135
158
|
}
|
|
@@ -137,7 +160,7 @@ export class TransactionBuilder implements Builder {
|
|
|
137
160
|
public createProof(account: ComponentAddress, resourceAddress: ResourceAddress): this {
|
|
138
161
|
return this.addInstruction({
|
|
139
162
|
CallMethod: {
|
|
140
|
-
|
|
163
|
+
call: {Address: account},
|
|
141
164
|
method: "create_proof_for_resource",
|
|
142
165
|
args: [resourceAddress],
|
|
143
166
|
},
|
|
@@ -152,11 +175,23 @@ export class TransactionBuilder implements Builder {
|
|
|
152
175
|
});
|
|
153
176
|
}
|
|
154
177
|
|
|
155
|
-
public allocateAddress(
|
|
178
|
+
public allocateAddress(allocatableType: AllocatableAddressType, workspaceId: string): this {
|
|
179
|
+
const workspace_id = this.addNamedId(workspaceId);
|
|
156
180
|
return this.addInstruction({
|
|
157
181
|
AllocateAddress: {
|
|
158
|
-
|
|
159
|
-
workspace_id
|
|
182
|
+
allocatable_type: allocatableType,
|
|
183
|
+
workspace_id,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public assertBucketContains(workspaceName: string, resource_address: ResourceAddress, min_amount: Amount): this {
|
|
189
|
+
const key = this.getOffsetIdFromWorkspaceName(workspaceName);
|
|
190
|
+
return this.addInstruction({
|
|
191
|
+
AssertBucketContains: {
|
|
192
|
+
key,
|
|
193
|
+
resource_address,
|
|
194
|
+
min_amount,
|
|
160
195
|
},
|
|
161
196
|
});
|
|
162
197
|
}
|
|
@@ -166,10 +201,11 @@ export class TransactionBuilder implements Builder {
|
|
|
166
201
|
* `PutLastInstructionOutputOnWorkspace: { key: Array<number> }`
|
|
167
202
|
* to make saving variables easier.
|
|
168
203
|
*/
|
|
169
|
-
public saveVar(
|
|
204
|
+
public saveVar(name: string): this {
|
|
205
|
+
let key = this.addNamedId(name);
|
|
170
206
|
return this.addInstruction({
|
|
171
207
|
PutLastInstructionOutputOnWorkspace: {
|
|
172
|
-
key
|
|
208
|
+
key,
|
|
173
209
|
},
|
|
174
210
|
});
|
|
175
211
|
}
|
|
@@ -183,7 +219,7 @@ export class TransactionBuilder implements Builder {
|
|
|
183
219
|
public feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: string): this {
|
|
184
220
|
return this.addFeeInstruction({
|
|
185
221
|
CallMethod: {
|
|
186
|
-
|
|
222
|
+
call: {Address: componentAddress},
|
|
187
223
|
method: "pay_fee",
|
|
188
224
|
args: [maxFee],
|
|
189
225
|
},
|
|
@@ -201,7 +237,7 @@ export class TransactionBuilder implements Builder {
|
|
|
201
237
|
): this {
|
|
202
238
|
return this.addFeeInstruction({
|
|
203
239
|
CallMethod: {
|
|
204
|
-
|
|
240
|
+
call: { Address: componentAddress },
|
|
205
241
|
method: "pay_fee_confidential",
|
|
206
242
|
args: [proof],
|
|
207
243
|
},
|
|
@@ -212,21 +248,21 @@ export class TransactionBuilder implements Builder {
|
|
|
212
248
|
return this.addInstruction("DropAllProofsInWorkspace");
|
|
213
249
|
}
|
|
214
250
|
|
|
215
|
-
public withUnsignedTransaction(unsignedTransaction:
|
|
251
|
+
public withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this {
|
|
216
252
|
this.unsignedTransaction = unsignedTransaction;
|
|
217
253
|
this.signatures = [];
|
|
218
254
|
return this;
|
|
219
255
|
}
|
|
220
256
|
|
|
221
257
|
public withFeeInstructions(instructions: Instruction[]): this {
|
|
222
|
-
this.unsignedTransaction.
|
|
258
|
+
this.unsignedTransaction.fee_instructions = instructions;
|
|
223
259
|
this.signatures = [];
|
|
224
260
|
return this;
|
|
225
261
|
}
|
|
226
262
|
|
|
227
263
|
public withFeeInstructionsBuilder(builder: (builder: TransactionBuilder) => TransactionBuilder): this {
|
|
228
|
-
const newBuilder = builder(new TransactionBuilder());
|
|
229
|
-
this.unsignedTransaction.
|
|
264
|
+
const newBuilder = builder(new TransactionBuilder(this.unsignedTransaction.network));
|
|
265
|
+
this.unsignedTransaction.fee_instructions = newBuilder.unsignedTransaction.instructions;
|
|
230
266
|
this.signatures = [];
|
|
231
267
|
return this;
|
|
232
268
|
}
|
|
@@ -238,7 +274,7 @@ export class TransactionBuilder implements Builder {
|
|
|
238
274
|
}
|
|
239
275
|
|
|
240
276
|
public addFeeInstruction(instruction: Instruction): this {
|
|
241
|
-
this.unsignedTransaction.
|
|
277
|
+
this.unsignedTransaction.fee_instructions.push(instruction);
|
|
242
278
|
this.signatures = [];
|
|
243
279
|
return this;
|
|
244
280
|
}
|
|
@@ -262,24 +298,55 @@ export class TransactionBuilder implements Builder {
|
|
|
262
298
|
}
|
|
263
299
|
|
|
264
300
|
public withMinEpoch(minEpoch: number): this {
|
|
265
|
-
this.unsignedTransaction.
|
|
301
|
+
this.unsignedTransaction.min_epoch = minEpoch;
|
|
266
302
|
// Reset the signatures as they are no longer valid
|
|
267
303
|
this.signatures = [];
|
|
268
304
|
return this;
|
|
269
305
|
}
|
|
270
306
|
|
|
271
307
|
public withMaxEpoch(maxEpoch: number): this {
|
|
272
|
-
this.unsignedTransaction.
|
|
308
|
+
this.unsignedTransaction.max_epoch = maxEpoch;
|
|
273
309
|
// Reset the signatures as they are no longer valid
|
|
274
310
|
this.signatures = [];
|
|
275
311
|
return this;
|
|
276
312
|
}
|
|
277
313
|
|
|
278
|
-
public buildUnsignedTransaction():
|
|
314
|
+
public buildUnsignedTransaction(): UnsignedTransactionV1 {
|
|
279
315
|
return this.unsignedTransaction;
|
|
280
316
|
}
|
|
281
317
|
|
|
282
318
|
public build(): Transaction {
|
|
283
|
-
return new TransactionRequest(this.
|
|
319
|
+
return new TransactionRequest(this.buildUnsignedTransaction(), this.signatures);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private addNamedId(name: string): number {
|
|
323
|
+
const id = this.current_id;
|
|
324
|
+
this.allocatedIds.set(name, id);
|
|
325
|
+
this.current_id += 1;
|
|
326
|
+
return id;
|
|
284
327
|
}
|
|
328
|
+
|
|
329
|
+
private getNamedId(name: string): number | undefined {
|
|
330
|
+
return this.allocatedIds.get(name);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
private getOffsetIdFromWorkspaceName(name: string): WorkspaceOffsetId {
|
|
334
|
+
const parsed = parseWorkspaceStringKey(name);
|
|
335
|
+
const id = this.getNamedId(parsed.name);
|
|
336
|
+
if (id === undefined) {
|
|
337
|
+
throw new Error(`No workspace with name ${parsed.name} found`);
|
|
338
|
+
}
|
|
339
|
+
return { id, offset: parsed.offset };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private resolveArgs(args: NamedArg[]): TransactionArg[] {
|
|
343
|
+
return args.map((arg) => {
|
|
344
|
+
if (typeof arg === "object" && "Workspace" in arg) {
|
|
345
|
+
const workspaceId = this.getOffsetIdFromWorkspaceName(arg.Workspace);
|
|
346
|
+
return { Workspace: workspaceId };
|
|
347
|
+
}
|
|
348
|
+
return arg;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
285
352
|
}
|
|
@@ -3,74 +3,77 @@ import {
|
|
|
3
3
|
Instruction,
|
|
4
4
|
SubstateRequirement,
|
|
5
5
|
Transaction,
|
|
6
|
+
UnsignedTransactionV1,
|
|
6
7
|
TransactionSignature,
|
|
7
|
-
UnsignedTransaction,
|
|
8
8
|
VersionedSubstateId,
|
|
9
|
-
|
|
9
|
+
TransactionV1,
|
|
10
|
+
} from "@tari-project/typescript-bindings";
|
|
11
|
+
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
///TODO this implementation is not fully done, see:
|
|
12
|
-
/// https://github.com/tari-project/tari-
|
|
15
|
+
/// https://github.com/tari-project/tari-ootle/blob/development/dan_layer/transaction/src/transaction.rs
|
|
13
16
|
export class TransactionRequest implements Transaction {
|
|
14
17
|
id: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
signatures: Array<TransactionSignature>;
|
|
19
|
-
unsignedTransaction: UnsignedTransaction;
|
|
20
|
-
minEpoch?: Epoch;
|
|
21
|
-
maxEpoch?: Epoch;
|
|
22
|
-
filledInputs: VersionedSubstateId[];
|
|
23
|
-
|
|
24
|
-
constructor(unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]) {
|
|
18
|
+
V1: TransactionV1;
|
|
19
|
+
|
|
20
|
+
constructor(unsignedTransaction: UnsignedTransactionV1, signatures: TransactionSignature[]) {
|
|
25
21
|
this.id = "";
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
this.V1 = {
|
|
23
|
+
body: {
|
|
24
|
+
transaction: unsignedTransaction,
|
|
25
|
+
signatures,
|
|
26
|
+
},
|
|
27
|
+
seal_signature: {
|
|
28
|
+
public_key: "",
|
|
29
|
+
signature: {
|
|
30
|
+
public_nonce: "",
|
|
31
|
+
signature: "",
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
// Inputs filled by some authority. These are not part of the transaction hash nor the signature
|
|
35
|
+
filled_inputs: []
|
|
36
|
+
};
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
withFilledInputs(filled_inputs: Array<VersionedSubstateId>): this {
|
|
37
40
|
return { ...this, filled_inputs };
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
getUnsignedTransaction():
|
|
41
|
-
return this.
|
|
43
|
+
getUnsignedTransaction(): UnsignedTransactionV1 {
|
|
44
|
+
return this.V1.body.transaction;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
getFeeInstructions(): Instruction[] {
|
|
45
|
-
return this.
|
|
48
|
+
return this.V1.body.transaction.fee_instructions;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
getInstructions(): Instruction[] {
|
|
49
|
-
return this.instructions;
|
|
52
|
+
return this.V1.body.transaction.instructions;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
getSignatures(): TransactionSignature[] {
|
|
53
|
-
return this.signatures;
|
|
56
|
+
return this.V1.body.signatures;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
getInputs(): SubstateRequirement[] {
|
|
57
|
-
return this.inputs;
|
|
60
|
+
return this.V1.body.transaction.inputs;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
getFilledInputs(): VersionedSubstateId[] {
|
|
61
|
-
return this.
|
|
64
|
+
return this.V1.filled_inputs;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
getFilledInputsMut(): VersionedSubstateId[] {
|
|
65
|
-
return this.
|
|
68
|
+
return this.V1.filled_inputs;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
getMinEpoch(): Epoch |
|
|
69
|
-
return this.
|
|
71
|
+
getMinEpoch(): Epoch | null {
|
|
72
|
+
return this.V1.body.transaction.min_epoch;
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
getMaxEpoch(): Epoch |
|
|
73
|
-
return this.
|
|
75
|
+
getMaxEpoch(): Epoch | null {
|
|
76
|
+
return this.V1.body.transaction.max_epoch;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
setId(id: string): void {
|
|
@@ -227,7 +227,7 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
function convertToStatus(result: any): TransactionStatus {
|
|
230
|
-
// Ref: https://github.com/tari-project/tari-
|
|
230
|
+
// Ref: https://github.com/tari-project/tari-ootle/blob/bb0b31139b770aacd7bb49af865543aa4a9e2de4/dan_layer/wallet/sdk/src/apis/transaction.rs
|
|
231
231
|
if (result.final_decision !== "Commit") {
|
|
232
232
|
return TransactionStatus.Rejected;
|
|
233
233
|
}
|
|
@@ -102,17 +102,6 @@ export class NonFungibleAddress {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
export class NonFungibleIndexAddress {
|
|
106
|
-
private resource_address: ResourceAddress;
|
|
107
|
-
private index: number;
|
|
108
|
-
constructor(resource_address: ResourceAddress, index: number) {
|
|
109
|
-
this.resource_address = resource_address;
|
|
110
|
-
this.index = index;
|
|
111
|
-
}
|
|
112
|
-
toJSON() {
|
|
113
|
-
return { resource_address: this.resource_address, index: this.index };
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
105
|
|
|
117
106
|
export class ComponentAddress {
|
|
118
107
|
private tagged: Tagged;
|
|
@@ -139,8 +128,7 @@ export type SubstateAddressType =
|
|
|
139
128
|
| ComponentAddress
|
|
140
129
|
| VaultId
|
|
141
130
|
| UnclaimedConfidentialOutputAddress
|
|
142
|
-
| NonFungibleAddress
|
|
143
|
-
| NonFungibleIndexAddress;
|
|
131
|
+
| NonFungibleAddress;
|
|
144
132
|
|
|
145
133
|
export class SubstateAddress {
|
|
146
134
|
private value: SubstateAddressType;
|
|
@@ -156,10 +144,6 @@ export class SubstateAddress {
|
|
|
156
144
|
return { Vault: this.value };
|
|
157
145
|
} else if (this.value instanceof UnclaimedConfidentialOutputAddress) {
|
|
158
146
|
return { UnclaimedConfidentialOutput: this.value };
|
|
159
|
-
} else if (this.value instanceof NonFungibleAddress) {
|
|
160
|
-
return { NonFungible: this.value };
|
|
161
|
-
} else if (this.value instanceof NonFungibleIndexAddress) {
|
|
162
|
-
return { NonFungibleIndex: this.value };
|
|
163
147
|
}
|
|
164
148
|
throw "Unknown type";
|
|
165
149
|
}
|
|
@@ -11,8 +11,6 @@ import {
|
|
|
11
11
|
buildTransactionRequest,
|
|
12
12
|
submitAndWaitForTransaction,
|
|
13
13
|
waitForTransactionResult,
|
|
14
|
-
fromWorkspace,
|
|
15
|
-
toWorkspace,
|
|
16
14
|
} from "@tari-project/tarijs-builders";
|
|
17
15
|
import {
|
|
18
16
|
convertStringToTransactionStatus,
|
|
@@ -73,8 +71,6 @@ export {
|
|
|
73
71
|
buildTransactionRequest,
|
|
74
72
|
submitAndWaitForTransaction,
|
|
75
73
|
waitForTransactionResult,
|
|
76
|
-
fromWorkspace,
|
|
77
|
-
toWorkspace,
|
|
78
74
|
convertHexStringToU256Array,
|
|
79
75
|
convertU256ToHexString,
|
|
80
76
|
createNftAddressFromResource,
|