@tari-project/tarijs-builders 0.5.4 → 0.6.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.
@@ -2,22 +2,18 @@ import { WorkspaceArg } from "@tari-project/tarijs-types";
2
2
  /**
3
3
  *
4
4
  * @param key workspace name
5
- * @returns encoded Uint8Array value
5
+ * @returns encoded hex value
6
6
  * @example
7
- * key: "0" -> [ 48 ]
8
- * key: "0.0" -> [ 48, 46, 48 ]
9
- * key: "0.1" -> [ 48, 46, 49 ]
10
- *
11
- * key: "bucket" -> [ 98, 117, 99, 107, 101, 116 ]
12
- * key: "bucket.0" -> [ 98, 117, 99, 107, 101, 116, 46, 48 ]
13
- * key: "bucket.1" -> [ 98, 117, 99, 107, 101, 116, 46, 49 ]
7
+ * key: "bucket" -> "6275636b6574"
8
+ * key: "bucket.0" -> "6275636b65742e30"
9
+ * key: "bucket.1" -> "6275636b65742e31"
14
10
  */
15
- export declare function toWorkspace(key: string): number[];
11
+ export declare function toWorkspace(key: string): string;
16
12
  /**
17
13
  *
18
14
  * @param key workspace name
19
15
  * @returns formatted Workspace data
20
16
  * @example
21
- * key: "bucket" -> { Workspace: [ 98, 117, 99, 107, 101, 116 ] }
17
+ * key: "bucket" -> { Workspace: "6275636b6574" }
22
18
  */
23
19
  export declare function fromWorkspace(key: string): WorkspaceArg;
@@ -1,29 +1,22 @@
1
1
  /**
2
2
  *
3
3
  * @param key workspace name
4
- * @returns encoded Uint8Array value
4
+ * @returns encoded hex value
5
5
  * @example
6
- * key: "0" -> [ 48 ]
7
- * key: "0.0" -> [ 48, 46, 48 ]
8
- * key: "0.1" -> [ 48, 46, 49 ]
9
- *
10
- * key: "bucket" -> [ 98, 117, 99, 107, 101, 116 ]
11
- * key: "bucket.0" -> [ 98, 117, 99, 107, 101, 116, 46, 48 ]
12
- * key: "bucket.1" -> [ 98, 117, 99, 107, 101, 116, 46, 49 ]
6
+ * key: "bucket" -> "6275636b6574"
7
+ * key: "bucket.0" -> "6275636b65742e30"
8
+ * key: "bucket.1" -> "6275636b65742e31"
13
9
  */
14
10
  export function toWorkspace(key) {
15
- const encoder = new TextEncoder();
16
- return Array.from(encoder.encode(key));
11
+ return Buffer.from(key).toString("hex");
17
12
  }
18
13
  /**
19
14
  *
20
15
  * @param key workspace name
21
16
  * @returns formatted Workspace data
22
17
  * @example
23
- * key: "bucket" -> { Workspace: [ 98, 117, 99, 107, 101, 116 ] }
18
+ * key: "bucket" -> { Workspace: "6275636b6574" }
24
19
  */
25
20
  export function fromWorkspace(key) {
26
- const encoder = new TextEncoder();
27
- const encodedKey = encoder.encode(key);
28
- return { Workspace: Array.from(encodedKey) };
21
+ return { Workspace: Buffer.from(key).toString("hex") };
29
22
  }
@@ -1,4 +1,4 @@
1
- import { ComponentAddress, ConfidentialClaim, ConfidentialWithdrawProof, Instruction, ResourceAddress, SubstateRequirement, Transaction, TransactionSignature, UnsignedTransaction, PublishedTemplateAddress, TransactionArg } from "@tari-project/tarijs-types";
1
+ import { ComponentAddress, ConfidentialClaim, ConfidentialWithdrawProof, Instruction, ResourceAddress, SubstateRequirement, Transaction, TransactionSignature, UnsignedTransaction, PublishedTemplateAddress, SubstateType, TransactionArg } from "@tari-project/tarijs-types";
2
2
  export interface TransactionConstructor {
3
3
  new (unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]): Transaction;
4
4
  }
@@ -51,6 +51,7 @@ export declare class TransactionBuilder implements Builder {
51
51
  createAccount(ownerPublicKey: string, workspaceBucket?: string): this;
52
52
  createProof(account: ComponentAddress, resourceAddress: ResourceAddress): this;
53
53
  claimBurn(claim: ConfidentialClaim): this;
54
+ allocateAddress(substateType: SubstateType, workspaceId: string): this;
54
55
  /**
55
56
  * The `SaveVar` method replaces
56
57
  * `PutLastInstructionOutputOnWorkspace: { key: Array<number> }`
@@ -58,6 +58,14 @@ export class TransactionBuilder {
58
58
  },
59
59
  });
60
60
  }
61
+ allocateAddress(substateType, workspaceId) {
62
+ return this.addInstruction({
63
+ AllocateAddress: {
64
+ substate_type: substateType,
65
+ workspace_id: workspaceId,
66
+ },
67
+ });
68
+ }
61
69
  /**
62
70
  * The `SaveVar` method replaces
63
71
  * `PutLastInstructionOutputOnWorkspace: { key: Array<number> }`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-builders",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,9 +10,9 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@tari-project/tari-signer": "^0.5.3",
14
- "@tari-project/tarijs-types": "^0.5.4",
15
- "@tari-project/tari-universe-signer": "^0.5.4"
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"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.13.1",