-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d924352
commit db2b58e
Showing
26 changed files
with
371 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ledgerhq/wallet-api-core": minor | ||
--- | ||
|
||
Support Elrond family |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import BigNumber from "bignumber.js"; | ||
import type { ElrondTransaction, RawElrondTransaction } from "./types"; | ||
|
||
export function serializeElrondTransaction({ | ||
family, | ||
mode, | ||
amount, | ||
recipient, | ||
fees, | ||
data, | ||
gasLimit, | ||
}: ElrondTransaction): RawElrondTransaction { | ||
return { | ||
family, | ||
amount: amount.toString(), | ||
recipient, | ||
mode, | ||
fees: fees ? fees.toString() : undefined, | ||
data: data ? data.toString("hex") : undefined, | ||
gasLimit: gasLimit.toString(), | ||
}; | ||
} | ||
|
||
export function deserializeElrondTransaction({ | ||
family, | ||
mode, | ||
amount, | ||
recipient, | ||
fees, | ||
data, | ||
gasLimit, | ||
}: RawElrondTransaction): ElrondTransaction { | ||
return { | ||
family, | ||
mode, | ||
amount: new BigNumber(amount), | ||
recipient, | ||
fees: fees ? new BigNumber(fees) : undefined, | ||
data: data ? Buffer.from(data, "hex") : undefined, | ||
gasLimit: new BigNumber(gasLimit), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type BigNumber from "bignumber.js"; | ||
import type { z } from "zod"; | ||
import type { TransactionCommon } from "../index"; | ||
import type { schemaRawElrondTransaction } from "./validation"; | ||
|
||
export type ElrondTransactionMode = | ||
| "send" | ||
| "delegate" | ||
| "reDelegateRewards" | ||
| "unDelegate" | ||
| "claimRewards" | ||
| "withdraw"; | ||
|
||
export interface ElrondTransaction extends TransactionCommon { | ||
readonly family: RawElrondTransaction["family"]; | ||
mode: ElrondTransactionMode; | ||
data?: Buffer; | ||
fees: BigNumber | null | undefined; | ||
gasLimit: BigNumber; | ||
} | ||
|
||
export type RawElrondTransaction = z.infer<typeof schemaRawElrondTransaction>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { z } from "zod"; | ||
import { schemaFamilies, schemaTransactionCommon } from "../common"; | ||
|
||
export const schemaElrondTransactionMode = z.enum([ | ||
"send", | ||
"delegate", | ||
"reDelegateRewards", | ||
"unDelegate", | ||
"claimRewards", | ||
"withdraw", | ||
]); | ||
|
||
export const schemaRawElrondTransaction = schemaTransactionCommon.extend({ | ||
family: z.literal(schemaFamilies.enum.elrond), | ||
mode: schemaElrondTransactionMode, | ||
fees: z.string().optional().nullable(), | ||
data: z.string().optional(), | ||
gasLimit: z.string(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.