@tari-project/tarijs-types 0.12.1 → 0.13.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.
@@ -0,0 +1,3 @@
1
+ export type SubmitTransactionResponse = {
2
+ transaction_id: string;
3
+ };
package/dist/consts.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export const ACCOUNT_TEMPLATE_ADDRESS = "0000000000000000000000000000000000000000000000000000000000000000";
2
2
  export const TARI_RESOURCE = "resource_0101010101010101010101010101010101010101010101010101010101010101";
3
- export const XTR = TARI_RESOURCE;
3
+ export const XTR = "resource_0101010101010101010101010101010101010101010101010101010101010101";
@@ -1,22 +1,23 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  export function toHexString(byteArray) {
2
3
  if (Array.isArray(byteArray)) {
3
4
  return Array.from(byteArray, function (byte) {
4
- return ('0' + (byte & 0xff).toString(16)).slice(-2);
5
- }).join('');
5
+ return ("0" + (byte & 0xff).toString(16)).slice(-2);
6
+ }).join("");
6
7
  }
7
8
  if (byteArray === undefined) {
8
- return 'undefined';
9
+ return "undefined";
9
10
  }
10
11
  // object might be a tagged object
11
- if (byteArray['@@TAGGED@@'] !== undefined) {
12
- return toHexString(byteArray['@@TAGGED@@'][1]);
12
+ if (byteArray["@@TAGGED@@"] !== undefined) {
13
+ return toHexString(byteArray["@@TAGGED@@"][1]);
13
14
  }
14
- return 'Unsupported type';
15
+ return "Unsupported type";
15
16
  }
16
17
  export function fromHexString(hexString) {
17
- let res = [];
18
+ const res = [];
18
19
  for (let i = 0; i < hexString.length; i += 2) {
19
- res.push(Number('0x' + hexString.substring(i, i + 2)));
20
+ res.push(Number("0x" + hexString.substring(i, i + 2)));
20
21
  }
21
22
  return res;
22
23
  }
@@ -81,7 +81,8 @@ export class SimpleTransactionResult {
81
81
  const d = diff.unwrap();
82
82
  const components = [];
83
83
  for (const upSubstate of d.upSubstates()) {
84
- if (upSubstate.type === "Component" && upSubstate.substate.template_address === templateAddress) {
84
+ if (upSubstate.type === "Component" &&
85
+ upSubstate.substate.template_address === templateAddress) {
85
86
  components.push(SimpleComponent.new(upSubstate.id, upSubstate.version, upSubstate.substate));
86
87
  }
87
88
  }
@@ -112,14 +113,14 @@ export class SimpleTransactionResult {
112
113
  return Some(SimpleSubstateDiff.from(accept));
113
114
  }
114
115
  get diff() {
115
- return this.accept.or(this.onlyFeeAccepted.map((x => x[0])));
116
+ return this.accept.or(this.onlyFeeAccepted.map((x) => x[0]));
116
117
  }
117
118
  get onlyFeeAccepted() {
118
119
  const result = this.result;
119
120
  if (!result || !result.result || !("AcceptFeeRejectRest" in result.result)) {
120
121
  return None;
121
122
  }
122
- const [diff, reason] = result?.result.AcceptFeeRejectRest;
123
+ const [diff, reason] = result.result.AcceptFeeRejectRest;
123
124
  return Some([SimpleSubstateDiff.from(diff), reason]);
124
125
  }
125
126
  get rejected() {
@@ -187,9 +188,8 @@ export class SimpleSubstateDiff {
187
188
  };
188
189
  })
189
190
  .filter((x) => x !== null);
190
- this.down_substates = diff.down_substates
191
- .map(([id, version]) => {
192
- const type = (typeof id === "string" ? prefixToSubstateType(splitOnce(id, "_")[0]) : Object.keys(id)[0]);
191
+ this.down_substates = diff.down_substates.map(([id, version]) => {
192
+ const type = typeof id === "string" ? prefixToSubstateType(splitOnce(id, "_")[0]) : Object.keys(id)[0];
193
193
  const idVal = substateIdToString(id);
194
194
  return {
195
195
  type: type,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ComponentAddress, ResourceAddress, PublishedTemplateAddress, Epoch } from "@tari-project/typescript-bindings";
1
+ export { ComponentAddress, ResourceAddress, PublishedTemplateAddress, Epoch, Transaction, TransactionResult, } from "@tari-project/typescript-bindings";
2
2
  export { Amount } from "./Amount";
3
3
  export { BuiltInAccount, VaultSubstate } from "./Account";
4
4
  export { TransactionArg } from "./TransactionArg";
@@ -6,9 +6,9 @@ export { ConfidentialClaim } from "./ConfidentialClaim";
6
6
  export { ConfidentialOutput } from "./ConfidentialOutput";
7
7
  export { ConfidentialWithdrawProof } from "./ConfidentialWithdrawProof";
8
8
  export { GetTransactionResultResponse } from "./GetTransactionResultResponse";
9
+ export { SubmitTransactionResponse } from "./SubmitTransactionResponse";
9
10
  export { DownSubstates, UpSubstates } from "./SubstateDiff";
10
11
  export { SubstateType } from "./SubstateType";
11
- export { SubmitTransactionResponse, } from "./TransactionResult";
12
12
  export { TransactionSignature } from "./TransactionSignature";
13
13
  export { TransactionStatus, transactionStatusFromStr } from "./TransactionStatus";
14
14
  export { WorkspaceArg } from "./Workspace";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-types",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "author": "The Tari Community",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@tari-project/typescript-bindings": ">=1.14.0",
13
+ "@tari-project/typescript-bindings": ">=1.15.0",
14
14
  "@thames/monads": "^0.7.0"
15
15
  },
16
16
  "devDependencies": {
@@ -23,6 +23,7 @@
23
23
  "main": "dist/index.js",
24
24
  "types": "dist/index.d.ts",
25
25
  "scripts": {
26
- "build": "tsc -b"
26
+ "build": "tsc -b",
27
+ "lint": "eslint src/"
27
28
  }
28
29
  }
@@ -1,13 +0,0 @@
1
- import { DownSubstates, UpSubstates } from "./SubstateDiff";
2
- import { ComponentAddress, TransactionResult } from "@tari-project/typescript-bindings";
3
- export type SubmitTransactionResponse = {
4
- transaction_id: string;
5
- };
6
- export interface SubmitTxResult {
7
- response: SubmitTransactionResponse;
8
- result: TransactionResult;
9
- upSubstates: UpSubstates;
10
- downSubstates: DownSubstates;
11
- newComponents: UpSubstates;
12
- getComponentForTemplate(templateAddress: string): ComponentAddress | null;
13
- }