Skip to content

Commit

Permalink
test: serialization methods for Aptos (#430)
Browse files Browse the repository at this point in the history
* fix: add missing export

* test: unit tests for aptos serialization methods

* chore: update changeset
  • Loading branch information
semeano authored Feb 6, 2025
1 parent 8241491 commit 4ed8d9a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-parrots-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/wallet-api-core": minor
---

Add support for Aptos
1 change: 1 addition & 0 deletions packages/core/src/families/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./algorand/types";
export * from "./aptos/types";
export * from "./bitcoin/types";
export * from "./cardano/types";
export * from "./casper/types";
Expand Down
42 changes: 42 additions & 0 deletions packages/core/tests/serializers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
PolkadotTransaction,
RawAccount,
RawAlgorandTransaction,
RawAptosTransaction,
RawBitcoinTransaction,
RawCosmosTransaction,
RawCryptoOrgTransaction,
Expand Down Expand Up @@ -1420,6 +1421,47 @@ describe("serializers.ts", () => {
});
});

describe("aptos", () => {
const family = schemaFamilies.enum.aptos;

it("should deserialize a Cardano transaction", () => {
const transaction: RawAptosTransaction = {
family,
amount: "1000",
mode: "send",
recipient: "recipient",
fees: "100",
};
const serializedTransaction = deserializeTransaction(transaction);

expect(serializedTransaction).toEqual({
family,
amount: new BigNumber(1000),
recipient: "recipient",
mode: "send",
fees: new BigNumber(100),
});
});

it("should deserialize a Cardano transaction without optional params", () => {
const transaction: RawAptosTransaction = {
family,
amount: "2000",
recipient: "recipient",
mode: "send",
};
const serializedTransaction = deserializeTransaction(transaction);

expect(serializedTransaction).toEqual({
family,
amount: new BigNumber(2000),
recipient: "recipient",
mode: "send",
fees: undefined,
});
});
});

describe("solana", () => {
const family = schemaFamilies.enum.solana;

Expand Down

0 comments on commit 4ed8d9a

Please sign in to comment.