-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Near family #130
Merged
Merged
Support Near family #130
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 Near 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
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,34 @@ | ||
import BigNumber from "bignumber.js"; | ||
import type { RawNearTransaction, NearTransaction } from "./types"; | ||
|
||
export function serialize({ | ||
amount, | ||
recipient, | ||
family, | ||
mode, | ||
fees, | ||
}: NearTransaction): RawNearTransaction { | ||
return { | ||
amount: amount.toString(), | ||
recipient, | ||
family, | ||
mode, | ||
fees: fees?.toString(), | ||
}; | ||
} | ||
|
||
export function deserialize({ | ||
amount, | ||
recipient, | ||
family, | ||
mode, | ||
fees, | ||
}: RawNearTransaction): NearTransaction { | ||
return { | ||
amount: new BigNumber(amount), | ||
recipient, | ||
family, | ||
mode, | ||
fees: fees ? new BigNumber(fees) : undefined, | ||
}; | ||
} |
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,12 @@ | ||
import type BigNumber from "bignumber.js"; | ||
import type { z } from "zod"; | ||
import type { TransactionCommon } from "../index"; | ||
import type { schemaRawNearTransaction } from "./validation"; | ||
|
||
export interface NearTransaction extends TransactionCommon { | ||
readonly family: RawNearTransaction["family"]; | ||
mode: string; | ||
fees?: BigNumber; | ||
} | ||
|
||
export type RawNearTransaction = z.infer<typeof schemaRawNearTransaction>; |
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,8 @@ | ||
import { z } from "zod"; | ||
import { schemaFamilies, schemaTransactionCommon } from "../common"; | ||
|
||
export const schemaRawNearTransaction = schemaTransactionCommon.extend({ | ||
family: z.literal(schemaFamilies.enum.near), | ||
mode: z.string(), | ||
fees: z.string().optional(), | ||
}); |
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
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
84 changes: 84 additions & 0 deletions
84
website/docs/reference/api/client/interfaces/NearTransaction.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,84 @@ | ||
--- | ||
id: "NearTransaction" | ||
title: "Interface: NearTransaction" | ||
sidebar_label: "NearTransaction" | ||
sidebar_position: 0 | ||
custom_edit_url: null | ||
--- | ||
|
||
Common fields for all cryptocurrency transactions | ||
|
||
## Hierarchy | ||
|
||
- [`TransactionCommon`](TransactionCommon.md) | ||
|
||
↳ **`NearTransaction`** | ||
|
||
## 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:41 | ||
|
||
___ | ||
|
||
### family | ||
|
||
• `Readonly` **family**: ``"near"`` | ||
|
||
The family of the transaction | ||
|
||
#### Overrides | ||
|
||
[TransactionCommon](TransactionCommon.md).[family](TransactionCommon.md#family) | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/near/types.d.ts:6 | ||
|
||
___ | ||
|
||
### fees | ||
|
||
• `Optional` **fees**: `BigNumber` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/near/types.d.ts:8 | ||
|
||
___ | ||
|
||
### mode | ||
|
||
• **mode**: `string` | ||
|
||
#### Defined in | ||
|
||
packages/core/lib/families/near/types.d.ts:7 | ||
|
||
___ | ||
|
||
### 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:45 |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Think we can remove this file as seems there are no other files in this folder?
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.
@cksanders Not sure what you mean. Can you elaborate on this?