Skip to content

Commit 6bd94fa

Browse files
fix: added Hedera to types.md & serializers.spec.ts (#439)
Co-authored-by: Mateusz Domański <[email protected]>
1 parent 2352706 commit 6bd94fa

File tree

2 files changed

+99
-2
lines changed

2 files changed

+99
-2
lines changed

packages/core/tests/serializers.spec.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import {
4444
SolanaTransaction,
4545
VechainTransaction,
4646
RawVechainTransaction,
47+
RawHederaTransaction,
48+
HederaTransaction,
4749
} from "../src";
4850

4951
const date = new Date();
@@ -745,6 +747,43 @@ describe("serializers.ts", () => {
745747
});
746748
});
747749

750+
describe("hedera", () => {
751+
const family = schemaFamilies.enum.hedera;
752+
753+
it("should serialize a Hedera transaction", () => {
754+
const transaction: HederaTransaction = {
755+
family,
756+
amount: new BigNumber(100),
757+
recipient: "recipient",
758+
memo: "test2",
759+
};
760+
const serializedTransaction = serializeTransaction(transaction);
761+
762+
expect(serializedTransaction).toEqual({
763+
family,
764+
amount: "100",
765+
recipient: "recipient",
766+
memo: "test2",
767+
});
768+
});
769+
770+
it("should serialize a Hedera transaction whithout optional params", () => {
771+
const transaction: HederaTransaction = {
772+
family,
773+
amount: new BigNumber(100),
774+
recipient: "recipient",
775+
};
776+
const serializedTransaction = serializeTransaction(transaction);
777+
778+
expect(serializedTransaction).toEqual({
779+
family,
780+
amount: "100",
781+
recipient: "recipient",
782+
memo: undefined,
783+
});
784+
});
785+
});
786+
748787
describe("solana", () => {
749788
const family = schemaFamilies.enum.solana;
750789

@@ -1489,6 +1528,43 @@ describe("serializers.ts", () => {
14891528
});
14901529
});
14911530

1531+
describe("hedera", () => {
1532+
const family = schemaFamilies.enum.hedera;
1533+
1534+
it("should deserialize a Hedera transaction", () => {
1535+
const transaction: RawHederaTransaction = {
1536+
family,
1537+
amount: "100",
1538+
recipient: "recipient",
1539+
memo: "test2",
1540+
};
1541+
const serializedTransaction = deserializeTransaction(transaction);
1542+
1543+
expect(serializedTransaction).toEqual({
1544+
family,
1545+
amount: new BigNumber(100),
1546+
recipient: "recipient",
1547+
memo: "test2",
1548+
});
1549+
});
1550+
1551+
it("should deserialize a Hedera transaction without optional params", () => {
1552+
const transaction: RawHederaTransaction = {
1553+
family,
1554+
amount: "100",
1555+
recipient: "recipient",
1556+
};
1557+
const serializedTransaction = deserializeTransaction(transaction);
1558+
1559+
expect(serializedTransaction).toEqual({
1560+
family,
1561+
amount: new BigNumber(100),
1562+
recipient: "recipient",
1563+
memo: undefined,
1564+
});
1565+
});
1566+
});
1567+
14921568
describe("aptos", () => {
14931569
const family = schemaFamilies.enum.aptos;
14941570

spec/core/types.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Some types are defined as _raw_, usually in the form `Raw[TYPE-NAME]`. These typ
3131
- [RawCryptoOrgTransaction](#rawcryptoorgtransaction)
3232
- [EthereumTransaction](#ethereumtransaction)
3333
- [RawEthereumTransaction](#rawethereumtransaction)
34+
- [HederaTransaction](#hederatransaction)
35+
- [RawHederaTransaction](#rawhederatransaction)
3436
- [PolkadotTransaction](#polkadottransaction)
3537
- [RawPolkadotTransaction](#rawpolkadottransaction)
3638
- [RippleTransaction](#rippletransaction)
@@ -78,13 +80,13 @@ Some types are defined as _raw_, usually in the form `Raw[TYPE-NAME]`. These typ
7880
Description of an unsigned transaction. This type is used to build transactions and then sign them with a Ledger device and finally broadcast them to the network upon user validation.
7981

8082
[`EthereumTransaction`](/spec/core/types.md#ethereumtransaction) \| [`BitcoinTransaction`](/spec/core/types.md#bitcointransaction) \| [`AlgorandTransaction`](/spec/core/types.md#algorandtransaction) \|
81-
[`AptosTransaction`](/spec/core/types.md#aptostransaction) \| [`CryptoOrgTransaction`](/spec/core/types.md#cryptoorgtransaction) \| [`RippleTransaction`](/spec/core/types.md#rippletransaction) \| [`CosmosTransaction`](/spec/core/types.md#cosmostransaction) \| [`TezosTransaction`](/spec/core/types.md#tezostransaction) \| [`PolkadotTransaction`](/spec/core/types.md#polkadottransaction) \| [`StellarTransaction`](/spec/core/types.md#stellartransaction) \| [`TronTransaction`](/spec/core/types.md#trontransaction)
83+
[`AptosTransaction`](/spec/core/types.md#aptostransaction) \| [`CryptoOrgTransaction`](/spec/core/types.md#cryptoorgtransaction) \| [`RippleTransaction`](/spec/core/types.md#rippletransaction) \| [`CosmosTransaction`](/spec/core/types.md#cosmostransaction) \| [`TezosTransaction`](/spec/core/types.md#tezostransaction) \| [`PolkadotTransaction`](/spec/core/types.md#polkadottransaction) \| [`StellarTransaction`](/spec/core/types.md#stellartransaction) \| [`TronTransaction`](/spec/core/types.md#trontransaction) \| [`HederaTransaction`](/spec/core/types.md#hederatransaction)
8284

8385
### RawTransaction
8486

8587
The raw representation of the generic [Transaction](/spec/core/types.md#transaction) type.
8688

87-
[`RawEthereumTransaction`](/spec/core/types.md#rawethereumtransaction) \| [`RawBitcoinTransaction`](/spec/core/types.md#rawbitcointransaction) \| [`RawAlgorandTransaction`](/spec/core/types.md#rawalgorandtransaction) \| [`RawAptosTransaction`](/spec/core/types.md#rawaptostransaction) \| [`RawCryptoOrgTransaction`](/spec/core/types.md#rawcryptoorgtransaction) \| [`RawRippleTransaction`](/spec/core/types.md#rawrippletransaction) \| [`RawCosmosTransaction`](/spec/core/types.md#rawcosmostransaction) \| [`RawTezosTransaction`](/spec/core/types.md#rawtezostransaction) \| [`RawPolkadotTransaction`](/spec/core/types.md#rawpolkadottransaction) \| [`RawStellarTransaction`](/spec/core/types.md#rawstellartransaction) \| [`RawTronTransaction`](/spec/core/types.md#rawtrontransaction)
89+
[`RawEthereumTransaction`](/spec/core/types.md#rawethereumtransaction) \| [`RawBitcoinTransaction`](/spec/core/types.md#rawbitcointransaction) \| [`RawAlgorandTransaction`](/spec/core/types.md#rawalgorandtransaction) \| [`RawAptosTransaction`](/spec/core/types.md#rawaptostransaction) \| [`RawCryptoOrgTransaction`](/spec/core/types.md#rawcryptoorgtransaction) \| [`RawRippleTransaction`](/spec/core/types.md#rawrippletransaction) \| [`RawCosmosTransaction`](/spec/core/types.md#rawcosmostransaction) \| [`RawTezosTransaction`](/spec/core/types.md#rawtezostransaction) \| [`RawPolkadotTransaction`](/spec/core/types.md#rawpolkadottransaction) \| [`RawStellarTransaction`](/spec/core/types.md#rawstellartransaction) \| [`RawTronTransaction`](/spec/core/types.md#rawtrontransaction) \| [`RawHederaTransaction`](/spec/core/types.md#rawhederatransaction)
8890

8991
### TransactionCommon
9092

@@ -236,6 +238,24 @@ The raw representation of the common transaction fields found in [TransactionCom
236238
| `nonce?` | `number` | |
237239
| `recipient` | `string` | The address of the transaction's recipient |
238240

241+
### HederaTransaction
242+
243+
| Name | Type | Description |
244+
| ----------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
245+
| `amount` | `BigNumber` | The amount of token to send in the transaction, denoted in the smallest cryptocurrency's magnitude For example in BTC, a tx with an 'amount' field of 1 will correspond to a tx corresponding to 0.00000001 BTC |
246+
| `family` | [`HEDERA`](/spec/core/types.md#families) | |
247+
| `memo?` | `string` | |
248+
| `recipient` | `string` | The address of the transaction's recipient |
249+
250+
### RawHederaTransaction
251+
252+
| Name | Type | Description |
253+
| ----------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
254+
| `amount` | `string` | The amount of token to send in the transaction, denoted in the smallest cryptocurrency's magnitude For example in BTC, a tx with an 'amount' field of 1 will correspond to a tx corresponding to 0.00000001 BTC |
255+
| `family` | [`HEDERA`](/spec/core/types.md#families) | |
256+
| `memo?` | `string` | |
257+
| `recipient` | `string` | The address of the transaction's recipient
258+
239259
### PolkadotTransaction
240260

241261
| Name | Type | Description |
@@ -376,6 +396,7 @@ Supported coin families
376396
| COSMOS | `cosmos` |
377397
| CRYPTO_ORG | `crypto_org` |
378398
| ETHEREUM | `ethereum` |
399+
| HEDERA | `hedera` |
379400
| POLKADOT | `polkadot` |
380401
| RIPPLE | `ripple` |
381402
| STELLAR | `stellar` |

0 commit comments

Comments
 (0)