-
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
Chelsea Sanders
committed
Mar 17, 2023
1 parent
d924352
commit a44a66a
Showing
26 changed files
with
414 additions
and
54 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 | ||
--- | ||
|
||
Integrate Filecoin 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,7 @@ lib/ | |
lib-es/ | ||
|
||
# eslint cache | ||
.eslintcache | ||
.eslintcache | ||
|
||
# ide | ||
.idea |
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,70 @@ | ||
import BigNumber from "bignumber.js"; | ||
import type { FilecoinTransaction, RawFilecoinTransaction } from "./types"; | ||
|
||
export function serializeFilecoinTransaction({ | ||
amount, | ||
data = undefined, | ||
family, | ||
feesStrategy = null, | ||
method, | ||
nonce, | ||
params = undefined, | ||
gasLimit, | ||
gasFeeCap, | ||
gasPremium, | ||
recipient, | ||
subAccountId = undefined, | ||
useAllAmount = undefined, | ||
version, | ||
}: FilecoinTransaction): RawFilecoinTransaction { | ||
return { | ||
amount: amount.toString(), | ||
data: data ? data.toString("hex") : undefined, | ||
family, | ||
feesStrategy, | ||
gasLimit: gasLimit.toNumber(), | ||
gasFeeCap: gasFeeCap.toString(), | ||
gasPremium: gasPremium.toString(), | ||
method, | ||
nonce, | ||
params, | ||
recipient, | ||
subAccountId, | ||
useAllAmount: useAllAmount || undefined, | ||
version, | ||
}; | ||
} | ||
|
||
export function deserializeFilecoinTransaction({ | ||
amount, | ||
data = undefined, | ||
family, | ||
feesStrategy = null, | ||
method, | ||
nonce, | ||
params = undefined, | ||
gasLimit, | ||
gasFeeCap, | ||
gasPremium, | ||
recipient, | ||
subAccountId = undefined, | ||
useAllAmount = undefined, | ||
version, | ||
}: RawFilecoinTransaction): FilecoinTransaction { | ||
return { | ||
amount: new BigNumber(amount), | ||
data: data ? Buffer.from(data, "hex") : undefined, | ||
family, | ||
feesStrategy, | ||
gasLimit: new BigNumber(gasLimit), | ||
gasFeeCap: new BigNumber(gasFeeCap), | ||
gasPremium: new BigNumber(gasPremium), | ||
nonce, | ||
method, | ||
params, | ||
recipient, | ||
subAccountId, | ||
useAllAmount, | ||
version, | ||
}; | ||
} |
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,23 @@ | ||
import type BigNumber from "bignumber.js"; | ||
import type { z } from "zod"; | ||
import type { FeesStrategy, TransactionCommon } from "../index"; | ||
import type { schemaRawFilecoinTransaction } from "./validation"; | ||
|
||
export interface FilecoinTransaction extends TransactionCommon { | ||
readonly family: RawFilecoinTransaction["family"]; | ||
useAllAmount?: boolean; | ||
nonce: number; | ||
data?: Buffer; | ||
method: number; | ||
version: number; | ||
params?: string; | ||
gasLimit: BigNumber; | ||
gasFeeCap: BigNumber; | ||
gasPremium: BigNumber; | ||
subAccountId?: string | null; | ||
feesStrategy: FeesStrategy; | ||
} | ||
|
||
export type RawFilecoinTransaction = z.infer< | ||
typeof schemaRawFilecoinTransaction | ||
>; |
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,21 @@ | ||
import { z } from "zod"; | ||
import { | ||
schemaFamilies, | ||
schemaFeesStrategy, | ||
schemaTransactionCommon, | ||
} from "../common"; | ||
|
||
export const schemaRawFilecoinTransaction = schemaTransactionCommon.extend({ | ||
data: z.string().optional(), | ||
family: z.literal(schemaFamilies.enum.filecoin), | ||
feesStrategy: schemaFeesStrategy, | ||
gasLimit: z.number(), | ||
gasFeeCap: z.string(), | ||
gasPremium: z.string(), | ||
method: z.number(), | ||
nonce: z.number(), | ||
params: z.string().optional(), | ||
subAccountId: z.string().optional().nullish(), | ||
useAllAmount: z.boolean().optional(), | ||
version: 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
Oops, something went wrong.