-
Notifications
You must be signed in to change notification settings - Fork 90
feat: add TON blockchain support #782
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
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
1d05ec9
feat: add TON blockchain support
NeOMakinG 04b8246
chore: version packages to 1.62.39-ton-chain.0
NeOMakinG 1dd1af1
chore: version packages to 1.62.39-ton-chain.1
NeOMakinG bc76c37
chore: version packages to 1.62.39-ton-chain.2
NeOMakinG d380fef
fix: add isMnemonicInterface check for TON in loadDevice
NeOMakinG 727b41b
fix: add toTonSeed to core BIP39 interface and properly check before …
NeOMakinG a0cada9
fix: use typeof check for toTonSeed method
NeOMakinG 9b7d75b
fix: remove toTonSeed check, just call it
NeOMakinG a56079f
debug: add TON loadDevice logging
NeOMakinG 6e8816e
fix: make TON initialization graceful - don't block wallet connection…
NeOMakinG 7c3f34c
fix: simplify revocable proxy to properly forward prototype methods l…
NeOMakinG 7870d70
chore: version packages to 1.62.39-ton-chain.10
NeOMakinG 30ec48c
fix: use standard BIP39+SLIP-10 for TON (like Solana) and fix StateIn…
NeOMakinG fb7842c
fix: add depth to cell repr for correct TON address derivation
NeOMakinG bb74251
fix(ton): correct V4R2 code cell depth from 1 to 7
NeOMakinG 9e7dde5
chore: version packages to 1.62.39-ton-chain.14
NeOMakinG 4fe7eff
chore: version packages to 1.62.39-ton-chain.15
NeOMakinG c0058da
chore: version packages to 1.62.39-ton-chain.16 and fix BOC serializa…
NeOMakinG d9fa99f
fix: BOC deserializer sizeBytes should not add 1
NeOMakinG 805f824
fix: use correct wallet V4R2 code BOC from ton-core
NeOMakinG d70eb22
feat: use @ton/ton signer interface for proper signing without exposi…
NeOMakinG 351ebee
chore: version packages to 1.62.39-ton-chain.20
NeOMakinG 52c2f8a
fix(ton): use storeMessage for correct external message format
NeOMakinG 6a7a36d
debug: add TON transaction logging
NeOMakinG a2ef893
fix(ton): set bounce=false, add more debug logging
NeOMakinG 51f1525
fix(ton): use storeMessage for external messages, set bounce=false
NeOMakinG 556c7be
chore: version packages to 1.62.39-ton-chain.25
NeOMakinG 7b5118a
fix: remove unused import and add eslint-disable for ProxyHandler params
NeOMakinG 6778dac
chore: reset package versions to 1.62.38 (remove verdaccio test versi…
NeOMakinG b1c7805
chore: merge origin/master and update versions to 1.62.39
NeOMakinG 3c97ebe
fix: reset yarn.lock to remove verdaccio references
NeOMakinG f8747e6
fix: add jest mock for @ton/ton to fix ESM import issues in tests
NeOMakinG 081af70
chore: version packages to 1.62.40-ton-chain.0
NeOMakinG 0252ea6
fix: Apply CodeRabbit feedback for TON chain integration
NeOMakinG e37daf1
chore: version packages to 1.62.40-coderabbit-fix.0
NeOMakinG e52367b
feat: revert versions
NeOMakinG e2c70b8
fix: use TON-specific key derivation for wallet compatibility
NeOMakinG 6669291
revert: restore original revocable.ts proxy implementation
NeOMakinG 853444f
docs: explain why signature field is empty in TON signed transactions
NeOMakinG 9312d92
fix: address CodeRabbit feedback on TON key derivation
NeOMakinG 7a2a5e4
docs: document Trust Wallet compatibility for TON derivation path
NeOMakinG 69ed1dd
chore: version packages to 1.62.40-ton-chain.0
NeOMakinG fd4d20a
chore: version packages to 1.62.40-ton-chain.1
NeOMakinG ef9db95
chore: version packages to 1.62.40-ton-chain.2
NeOMakinG 7c29d90
fix: make tonMasterKey optional in LoadDevice type for backward compa…
NeOMakinG a388523
chore: version packages to 1.62.40-ton-chain.3
NeOMakinG 7acdf46
chore: version packages to 1.62.40-ton-chain.4
NeOMakinG 99ee46a
fix: remove toTonSeed existence check - call directly with non-null a…
NeOMakinG 9c737f6
fix: remove toTonSeed non-null assertion to work with proxy - version…
NeOMakinG 157d57a
fix: use proper error handling for toTonSeed proxy access
NeOMakinG dd3c7db
fix: use non-null assertion for toTonSeed - proxy exposes method but …
NeOMakinG 4999088
chore: bump version to 1.62.40-ton-chain.6
NeOMakinG 6909a46
chore: version packages to 1.62.40-ton-chain.7 - fix proxy receiver f…
NeOMakinG a0666c4
chore: version packages to 1.62.40-ton-chain.8 - revert to straightfo…
NeOMakinG a9cd331
chore: version packages to 1.62.40-ton-chain.9
NeOMakinG 4b1aebb
fix: use standard BIP-39 derivation for TON addresses
NeOMakinG 96493b9
chore: revert version bumps to 1.62.39
NeOMakinG 90bc0fc
chore: remove gitHead fields from package.json files
NeOMakinG 592e2cd
chore: reset yarn.lock to master
NeOMakinG 382e08f
chore(release): publish 1.62.40
NeOMakinG 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
Some comments aren't visible on the classic Files Changed page.
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
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,101 @@ | ||
| import { addressNListToBIP32, slip44ByCoin } from "./utils"; | ||
| import { BIP32Path, HDWallet, HDWalletInfo, PathDescription } from "./wallet"; | ||
|
|
||
| export interface TonGetAddress { | ||
| addressNList: BIP32Path; | ||
| showDisplay?: boolean; | ||
| } | ||
|
|
||
| export interface TonRawMessage { | ||
| targetAddress: string; | ||
| sendAmount: string; | ||
| payload: string; | ||
| stateInit?: string; | ||
| } | ||
|
|
||
| export interface TonSignTx { | ||
| addressNList: BIP32Path; | ||
| /** Raw message bytes to sign (BOC serialized) - used for simple transfers */ | ||
| message?: Uint8Array; | ||
| /** Raw messages from external protocols like Stonfi - used for complex swaps */ | ||
| rawMessages?: TonRawMessage[]; | ||
| /** Sequence number for the wallet */ | ||
| seqno?: number; | ||
| /** Transaction expiration timestamp */ | ||
| expireAt?: number; | ||
| } | ||
|
|
||
| export interface TonSignedTx { | ||
| signature: string; | ||
| serialized: string; | ||
| } | ||
|
|
||
| export interface TonGetAccountPaths { | ||
| accountIdx: number; | ||
| } | ||
|
|
||
| export interface TonAccountPath { | ||
| addressNList: BIP32Path; | ||
| } | ||
|
|
||
| export interface TonWalletInfo extends HDWalletInfo { | ||
| readonly _supportsTonInfo: boolean; | ||
|
|
||
| /** | ||
| * Returns a list of bip32 paths for a given account index in preferred order | ||
| * from most to least preferred. | ||
| */ | ||
| tonGetAccountPaths(msg: TonGetAccountPaths): Array<TonAccountPath>; | ||
|
|
||
| /** | ||
| * Returns the "next" account path, if any. | ||
| */ | ||
| tonNextAccountPath(msg: TonAccountPath): TonAccountPath | undefined; | ||
| } | ||
|
|
||
| export interface TonWallet extends TonWalletInfo, HDWallet { | ||
| readonly _supportsTon: boolean; | ||
|
|
||
| tonGetAddress(msg: TonGetAddress): Promise<string | null>; | ||
| tonSignTx(msg: TonSignTx): Promise<TonSignedTx | null>; | ||
| } | ||
|
|
||
| export function tonDescribePath(path: BIP32Path): PathDescription { | ||
| const pathStr = addressNListToBIP32(path); | ||
| const unknown: PathDescription = { | ||
| verbose: pathStr, | ||
| coin: "Ton", | ||
| isKnown: false, | ||
| }; | ||
|
|
||
| // TON uses m/44'/607'/<account>' - a 3-level path compatible with Trust Wallet. | ||
| // This differs from some wallets that use m/44'/607'/0' fixed path. | ||
| const slip44 = slip44ByCoin("Ton"); | ||
| if (slip44 === undefined) return unknown; | ||
| if (path.length != 3) return unknown; | ||
| if (path[0] != 0x80000000 + 44) return unknown; | ||
| if (path[1] != 0x80000000 + slip44) return unknown; | ||
| if ((path[2] & 0x80000000) >>> 0 !== 0x80000000) return unknown; | ||
|
|
||
| const index = path[2] & 0x7fffffff; | ||
| return { | ||
| verbose: `TON Account #${index}`, | ||
| accountIdx: index, | ||
| wholeAccount: true, | ||
| coin: "Ton", | ||
| isKnown: true, | ||
| }; | ||
| } | ||
|
|
||
| // TON uses a 3-level hardened derivation path: m/44'/607'/<account>' | ||
| // This follows the same pattern as Stellar (SEP-0005) since TON uses Ed25519 | ||
| // https://github.com/satoshilabs/slips/blob/master/slip-0044.md (607 = TON) | ||
| export function tonGetAccountPaths(msg: TonGetAccountPaths): Array<TonAccountPath> { | ||
| const slip44 = slip44ByCoin("Ton"); | ||
| if (slip44 === undefined) return []; | ||
| return [ | ||
| { | ||
| addressNList: [0x80000000 + 44, 0x80000000 + slip44, 0x80000000 + msg.accountIdx], | ||
| }, | ||
| ]; | ||
| } | ||
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.