Skip to content

Commit

Permalink
Fix bug in summarizeTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Sep 15, 2023
1 parent cfbbbc1 commit 9149be5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radixdlt/radix-engine-toolkit",
"version": "0.4.2",
"version": "0.4.3",
"description": "A TypeScript wrapper for the Radix Engine Toolkit that provides many of the necessary tools to interact with the Radix ledger",
"types": "./dist/index.d.ts",
"main": "./dist/radix-engine-toolkit.umd.js",
Expand Down
22 changes: 7 additions & 15 deletions src/lts/toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,21 +547,13 @@ const resolveTransactionIntent = (
};

const resolveUnknownCompiledIntent = (intent: Uint8Array): Promise<Intent> => {
try {
return RadixEngineToolkit.Intent.decompile(intent);
} catch {}

try {
return RadixEngineToolkit.Intent.decompile(intent).catch(() => {
return RadixEngineToolkit.SignedIntent.decompile(intent).then(
(signedIntent) => signedIntent.intent
);
} catch {}

try {
return RadixEngineToolkit.NotarizedTransaction.decompile(intent).then(
(transaction) => transaction.signedIntent.intent
);
} catch {}

throw new Error("The passed byte array is not a compiled intent.");
).catch(() => {
return RadixEngineToolkit.NotarizedTransaction.decompile(intent).then(
(transaction) => transaction.signedIntent.intent
)
})
})
};
10 changes: 10 additions & 0 deletions tests/lts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
RadixEngineToolkit,
SimpleTransactionBuilder,
TransactionSummary,
Convert, OlympiaNetwork
} from "../src";

describe("Address Class", () => {
Expand Down Expand Up @@ -346,4 +347,13 @@ describe("Address Class", () => {
.staticallyValidate(0x0d)
.then((x) => x.throwIfInvalid());
});

it("Compiled untyped intent can be summarized by the LTS toolkit", async() => {
// Arrange
const transactionHex = "4d220302210221042107070e0a87060000000000000a8906000000000000095f6121312201012007201a5608e86828ea54a3a8c0c7107ebdc7050c1b162a6b7fd2760451a91c04691301010800002022044103800051176a3e1f0bf9684d7aa082ead1e30aa7c93dc2803d717bb08006fd5fcb0c086c6f636b5f6665652101850000e8890423c78a000000000000000000000000000000004103800051176a3e1f0bf9684d7aa082ead1e30aa7c93dc2803d717bb08006fd5fcb0c087769746864726177210280005da66318c6318c61f5a61b4c6318c6318cf794aa8d295f14e6318c6318c685000010632d5ec76b05000000000000000000000000000000000280005da66318c6318c61f5a61b4c6318c6318cf794aa8d295f14e6318c6318c685000010632d5ec76b050000000000000000000000000000004103800051fa22aed309225db4af4bd7b6e1ce1db415f852cb7505f96394cf7adfff0c147472795f6465706f7369745f6f725f61626f7274210281000000002200002020002200002022002201012101200740bf99117633deea71bf2e7a3a704d2f7eb7c5a2edaf1edfd254e4d8a246a973715b763a5df83e1e539b2b9bb0b20b376da5a91db73f87b8cce45f9e25a4858d02";
const transactionBytes = Convert.HexString.toUint8Array(transactionHex);

// Act & Assert
const summarized = await LTSRadixEngineToolkit.Transaction.summarizeTransaction(transactionBytes);
})
});

0 comments on commit 9149be5

Please sign in to comment.