-
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: integrate filecoin family (#127)
- Loading branch information
Showing
25 changed files
with
318 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ export const FAMILIES = [ | |
"ripple", | ||
"cosmos", | ||
"hedera", | ||
"filecoin", | ||
"tezos", | ||
"polkadot", | ||
"stellar", | ||
|
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,58 @@ | ||
import BigNumber from "bignumber.js"; | ||
import type { FilecoinTransaction, RawFilecoinTransaction } from "./types"; | ||
|
||
export function serializeFilecoinTransaction({ | ||
amount, | ||
data = undefined, | ||
family, | ||
method, | ||
nonce, | ||
params = undefined, | ||
gasLimit, | ||
gasFeeCap, | ||
gasPremium, | ||
recipient, | ||
version, | ||
}: FilecoinTransaction): RawFilecoinTransaction { | ||
return { | ||
amount: amount.toString(), | ||
data: data ? data.toString("hex") : undefined, | ||
family, | ||
gasLimit: gasLimit.toNumber(), | ||
gasFeeCap: gasFeeCap.toString(), | ||
gasPremium: gasPremium.toString(), | ||
method, | ||
nonce, | ||
params, | ||
recipient, | ||
version, | ||
}; | ||
} | ||
|
||
export function deserializeFilecoinTransaction({ | ||
amount, | ||
data = undefined, | ||
family, | ||
method, | ||
nonce, | ||
params = undefined, | ||
gasLimit, | ||
gasFeeCap, | ||
gasPremium, | ||
recipient, | ||
version, | ||
}: RawFilecoinTransaction): FilecoinTransaction { | ||
return { | ||
amount: new BigNumber(amount), | ||
data: data ? Buffer.from(data, "hex") : undefined, | ||
family, | ||
gasLimit: new BigNumber(gasLimit), | ||
gasFeeCap: new BigNumber(gasFeeCap), | ||
gasPremium: new BigNumber(gasPremium), | ||
nonce, | ||
method, | ||
params, | ||
recipient, | ||
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,20 @@ | ||
import type BigNumber from "bignumber.js"; | ||
import type { z } from "zod"; | ||
import type { TransactionCommon } from "../index"; | ||
import type { schemaRawFilecoinTransaction } from "./validation"; | ||
|
||
export interface FilecoinTransaction extends TransactionCommon { | ||
readonly family: RawFilecoinTransaction["family"]; | ||
nonce: number; | ||
data?: Buffer; | ||
method: number; | ||
version: number; | ||
params?: string; | ||
gasLimit: BigNumber; | ||
gasFeeCap: BigNumber; | ||
gasPremium: BigNumber; | ||
} | ||
|
||
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,14 @@ | ||
import { z } from "zod"; | ||
import { schemaFamilies, schemaTransactionCommon } from "../common"; | ||
|
||
export const schemaRawFilecoinTransaction = schemaTransactionCommon.extend({ | ||
data: z.string().optional(), | ||
family: z.literal(schemaFamilies.enum.filecoin), | ||
gasLimit: z.number(), | ||
gasFeeCap: z.string(), | ||
gasPremium: z.string(), | ||
method: z.number(), | ||
nonce: z.number(), | ||
params: z.string().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
Large diffs are not rendered by default.
Oops, something went wrong.
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
144 changes: 144 additions & 0 deletions
144
website/docs/reference/api/client/interfaces/FilecoinTransaction.md
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,144 @@ | ||
--- | ||
id: "FilecoinTransaction" | ||
title: "Interface: FilecoinTransaction" | ||
sidebar_label: "FilecoinTransaction" | ||
sidebar_position: 0 | ||
custom_edit_url: null | ||
--- | ||
|
||
Common fields for all cryptocurrency transactions | ||
|
||
## Hierarchy | ||
|
||
- [`TransactionCommon`](TransactionCommon.md) | ||
|
||
↳ **`FilecoinTransaction`** | ||
|
||
## Properties | ||
|
||
### amount | ||
|
||
• **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 | ||
|
||
#### Inherited from | ||
|
||
[TransactionCommon](TransactionCommon.md).[amount](TransactionCommon.md#amount) | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/types.d.ts:39 | ||
|
||
___ | ||
|
||
### data | ||
|
||
• `Optional` **data**: `Buffer` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:9 | ||
|
||
___ | ||
|
||
### family | ||
|
||
• `Readonly` **family**: ``"filecoin"`` | ||
|
||
The family of the transaction | ||
|
||
#### Overrides | ||
|
||
[TransactionCommon](TransactionCommon.md).[family](TransactionCommon.md#family) | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:7 | ||
|
||
___ | ||
|
||
### gasFeeCap | ||
|
||
• **gasFeeCap**: `BigNumber` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:14 | ||
|
||
___ | ||
|
||
### gasLimit | ||
|
||
• **gasLimit**: `BigNumber` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:13 | ||
|
||
___ | ||
|
||
### gasPremium | ||
|
||
• **gasPremium**: `BigNumber` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:15 | ||
|
||
___ | ||
|
||
### method | ||
|
||
• **method**: `number` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:10 | ||
|
||
___ | ||
|
||
### nonce | ||
|
||
• **nonce**: `number` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:8 | ||
|
||
___ | ||
|
||
### params | ||
|
||
• `Optional` **params**: `string` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:12 | ||
|
||
___ | ||
|
||
### recipient | ||
|
||
• **recipient**: `string` | ||
|
||
The address of the transaction's recipient | ||
|
||
#### Inherited from | ||
|
||
[TransactionCommon](TransactionCommon.md).[recipient](TransactionCommon.md#recipient) | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/types.d.ts:43 | ||
|
||
___ | ||
|
||
### version | ||
|
||
• **version**: `number` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/filecoin/types.d.ts:11 |
Oops, something went wrong.
67deb45
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.vercel.app
wallet-api-wallet-api-tools-ledgerhq.vercel.app
wallet-api-wallet-api-tools-git-main-ledgerhq.vercel.app