-
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.
Feat: elrond family integration (#133)
* feat: elrond integration
- Loading branch information
Showing
31 changed files
with
388 additions
and
65 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,6 @@ | ||
--- | ||
"@ledgerhq/wallet-api-core": minor | ||
"wallet-api-website": 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({ | ||
amount, | ||
data, | ||
family, | ||
fees, | ||
gasLimit, | ||
mode, | ||
recipient, | ||
}: ElrondTransaction): RawElrondTransaction { | ||
return { | ||
family, | ||
amount: amount.toString(), | ||
recipient, | ||
mode, | ||
fees: fees ? fees.toString() : undefined, | ||
data, | ||
gasLimit, | ||
}; | ||
} | ||
|
||
export function deserializeElrondTransaction({ | ||
amount, | ||
data, | ||
family, | ||
fees, | ||
gasLimit, | ||
mode, | ||
recipient, | ||
}: RawElrondTransaction): ElrondTransaction { | ||
return { | ||
family, | ||
mode, | ||
amount: new BigNumber(amount), | ||
recipient, | ||
fees: fees ? new BigNumber(fees) : undefined, | ||
data, | ||
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,17 @@ | ||
import type BigNumber from "bignumber.js"; | ||
import type { z } from "zod"; | ||
import type { TransactionCommon } from "../index"; | ||
import type { | ||
schemaRawElrondTransaction, | ||
ElrondOperationMode, | ||
} from "./validation"; | ||
|
||
export interface ElrondTransaction extends TransactionCommon { | ||
readonly family: RawElrondTransaction["family"]; | ||
mode: ElrondOperationMode; | ||
data?: string; | ||
fees?: BigNumber; | ||
gasLimit: number; | ||
} | ||
|
||
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,28 @@ | ||
import { z } from "zod"; | ||
import { schemaFamilies, schemaTransactionCommon } from "../common"; | ||
|
||
export const schemaOperationMode = z.enum([ | ||
"send", | ||
"delegate", | ||
"reDelegateRewards", | ||
"unDelegate", | ||
"claimRewards", | ||
"withdraw", | ||
]); | ||
|
||
export type ElrondOperationMode = z.infer<typeof schemaOperationMode>; | ||
|
||
export const schemaRawElrondTransaction = schemaTransactionCommon.extend({ | ||
family: z.literal(schemaFamilies.enum.elrond), | ||
mode: z.union([ | ||
z.literal("send"), | ||
z.literal("delegate"), | ||
z.literal("reDelegateRewards"), | ||
z.literal("unDelegate"), | ||
z.literal("claimRewards"), | ||
z.literal("withdraw"), | ||
]), | ||
fees: z.string().optional(), | ||
data: z.string().optional(), | ||
gasLimit: z.number(), | ||
}); |
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.
bb79e38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
wallet-api-wallet-api-tools – ./apps/wallet-api-tools
wallet-api-wallet-api-tools-git-main-ledgerhq.vercel.app
wallet-api-wallet-api-tools-ledgerhq.vercel.app
wallet-api-wallet-api-tools.vercel.app