-
Notifications
You must be signed in to change notification settings - Fork 89
feat: support tron with native wallet #750
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
21477bf
chore: version packages to 1.62.12-tron-support.0
NeOMakinG 6b22beb
chore: temporarily skip build for publish
NeOMakinG 5b368ce
chore: version packages to 1.62.12-tron-alpha.0
NeOMakinG b7fa895
chore: version packages to 1.62.12-tron-alpha.1
NeOMakinG 6624af5
fix: rename adapter to tronAdapter to avoid property collision with S…
NeOMakinG 844e640
chore: version packages to 1.62.14-tron-adapter-fix.0
NeOMakinG 4536ed9
fix: resolve TypeScript error in GridPlus ethereum transaction data
NeOMakinG 8dec9a0
fix: restore proper build scripts in package.json files
NeOMakinG 6fc3d0b
chore: version packages to 1.62.14-tron-adapter-fix.1
NeOMakinG 0791b70
chore: fix clean scripts and version to 1.62.14-tron-adapter-fix.2
NeOMakinG 2011f88
chore: update gitHead in package.json files
NeOMakinG 516d886
fix: convert Uint8Array to Buffer before toString in TRON address der…
NeOMakinG b1bf1e9
fix: use slice(1) instead of slice(2) for TRON public key
NeOMakinG cdfb59c
chore: bump version to 1.62.14-tron-adapter-fix.4
NeOMakinG 4119922
fix: lint
NeOMakinG d71a3fe
fix: reset packages
NeOMakinG f441d6e
fix: reset gridplus
NeOMakinG 99f5a85
fix: reset yarn
NeOMakinG 822f49a
chore: bump version to 1.62.15-tron.1
gomesalexandre 5cd6b3e
chore: reset package.json and lerna.json to origin/master
gomesalexandre 6ff6cda
Merge remote-tracking branch 'origin/master' into tron-support-native
gomesalexandre caa3b9d
chore(release): publish 1.62.14
gomesalexandre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
| import { addressNListToBIP32, slip44ByCoin } from "./utils"; | ||
| import { BIP32Path, HDWallet, HDWalletInfo, PathDescription } from "./wallet"; | ||
|
|
||
| export interface TronGetAddress { | ||
| addressNList: BIP32Path; | ||
| showDisplay?: boolean; | ||
| pubKey?: string; | ||
| } | ||
|
|
||
| export interface TronSignTx { | ||
| addressNList: BIP32Path; | ||
| /** Raw transaction data in hex format */ | ||
| rawDataHex: string; | ||
| } | ||
|
|
||
| export interface TronSignedTx { | ||
| serialized: string; | ||
| signature: string; | ||
| } | ||
|
|
||
| export interface TronTxSignature { | ||
| signature: string; | ||
| } | ||
|
|
||
| export interface TronGetAccountPaths { | ||
| accountIdx: number; | ||
| } | ||
|
|
||
| export interface TronAccountPath { | ||
| addressNList: BIP32Path; | ||
| } | ||
|
|
||
| export interface TronWalletInfo extends HDWalletInfo { | ||
| readonly _supportsTronInfo: boolean; | ||
|
|
||
| /** | ||
| * Returns a list of bip32 paths for a given account index in preferred order | ||
| * from most to least preferred. | ||
| */ | ||
| tronGetAccountPaths(msg: TronGetAccountPaths): Array<TronAccountPath>; | ||
|
|
||
| /** | ||
| * Returns the "next" account path, if any. | ||
| */ | ||
| tronNextAccountPath(msg: TronAccountPath): TronAccountPath | undefined; | ||
| } | ||
|
|
||
| export interface TronWallet extends TronWalletInfo, HDWallet { | ||
| readonly _supportsTron: boolean; | ||
|
|
||
| tronGetAddress(msg: TronGetAddress): Promise<string | null>; | ||
| tronGetAddresses?(msgs: TronGetAddress[]): Promise<string[]>; | ||
| tronSignTx(msg: TronSignTx): Promise<TronSignedTx | null>; | ||
| tronSendTx?(msg: TronSignTx): Promise<TronTxSignature | null>; | ||
| } | ||
|
|
||
| export function tronDescribePath(path: BIP32Path): PathDescription { | ||
| const pathStr = addressNListToBIP32(path); | ||
| const unknown: PathDescription = { | ||
| verbose: pathStr, | ||
| coin: "Tron", | ||
| isKnown: false, | ||
| }; | ||
|
|
||
| if (path.length != 5) return unknown; | ||
| if (path[0] != 0x80000000 + 44) return unknown; | ||
| if (path[1] != 0x80000000 + slip44ByCoin("Tron")) return unknown; | ||
| if ((path[2] & 0x80000000) >>> 0 !== 0x80000000) return unknown; | ||
| if (path[3] !== 0) return unknown; | ||
| if (path[4] !== 0) return unknown; | ||
|
|
||
| const index = path[2] & 0x7fffffff; | ||
| return { | ||
| verbose: `Tron Account #${index}`, | ||
| accountIdx: index, | ||
| wholeAccount: true, | ||
| coin: "Tron", | ||
| isKnown: true, | ||
| }; | ||
| } | ||
|
|
||
| // The standard BIP44 derivation path for Tron is: m/44'/195'/<account>'/0/0 | ||
| // https://github.com/tronprotocol/tips/issues/102 | ||
| export function tronGetAccountPaths(msg: TronGetAccountPaths): Array<TronAccountPath> { | ||
| const slip44 = slip44ByCoin("Tron"); | ||
| return [{ addressNList: [0x80000000 + 44, 0x80000000 + slip44, 0x80000000 + msg.accountIdx, 0, 0] }]; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.