@tari-project/tarijs-builders 0.8.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,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
  }
@@ -9,8 +9,6 @@ export declare class TransactionRequest implements Transaction {
9
9
  getInstructions(): Instruction[];
10
10
  getSignatures(): TransactionSignature[];
11
11
  getInputs(): SubstateRequirement[];
12
- getFilledInputs(): VersionedSubstateId[];
13
- getFilledInputsMut(): VersionedSubstateId[];
14
12
  getMinEpoch(): Epoch | null;
15
13
  getMaxEpoch(): Epoch | null;
16
14
  setId(id: string): void;
@@ -15,10 +15,8 @@ export class TransactionRequest {
15
15
  signature: {
16
16
  public_nonce: "",
17
17
  signature: "",
18
- }
18
+ },
19
19
  },
20
- // Inputs filled by some authority. These are not part of the transaction hash nor the signature
21
- filled_inputs: []
22
20
  };
23
21
  }
24
22
  withFilledInputs(filled_inputs) {
@@ -39,12 +37,6 @@ export class TransactionRequest {
39
37
  getInputs() {
40
38
  return this.V1.body.transaction.inputs;
41
39
  }
42
- getFilledInputs() {
43
- return this.V1.filled_inputs;
44
- }
45
- getFilledInputsMut() {
46
- return this.V1.filled_inputs;
47
- }
48
40
  getMinEpoch() {
49
41
  return this.V1.body.transaction.min_epoch;
50
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/tarijs-builders",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,10 +10,10 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
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"
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"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^22.13.1",