-
Notifications
You must be signed in to change notification settings - Fork 8
Basic TON Chain support for CCIP SDK #69
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
36 commits
Select commit
Hold shift + click to select a range
2ab536e
package json changes
Farber98 eb2e28c
ton hasher
Farber98 3358322
prettier
Farber98 e02ff2d
fix eslint
Farber98 e98b408
hasher and util tests
Farber98 1a15df8
Merge branch 'main' into juan/ton-hasher
Farber98 cb84a79
enable ton leaf hasher
Farber98 dacf34a
push report serialization
Farber98 4f5a327
Merge branch 'main' into juan/ton-hasher
Farber98 25e7a4b
fix
Farber98 50d49e8
add sdk exec
Farber98 4bae2ee
prettier + eslint
Farber98 b6f51c5
ton client + ton wallet for manualExec
Farber98 332c574
remove comment
Farber98 6d76a31
some andre feedback
Farber98 743ec7c
ton provider
Farber98 679a60c
Merge branch 'main' into juan/ton-hasher
Farber98 7f53e09
fix tests
Farber98 ec8cfbf
lint
Farber98 317713a
fix eslint
Farber98 977ac9e
put unref back with new version
Farber98 2acfbf4
lint
Farber98 40fbfbb
package lock
Farber98 1c42b41
change cli imports
Farber98 fdadd8d
fix lint
Farber98 89ac031
fix lint
Farber98 e76ce2d
ton provider remove comm
Farber98 1f218ea
unsigned report impl and provider fix
Farber98 19f3ab1
use EvmExtraArgs instead of generic
Farber98 cfd789f
use evmExtraArgsV2
Farber98 e89612b
remove genericextraargs
Farber98 ffcc0e9
fix dist
Farber98 e811609
adjust selector
andrevmatos e393329
address andre feedback
Farber98 c0290f0
fix hasher leaf domain separator and improve tests
Farber98 de87e6f
remove random hashes tests
Farber98 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { existsSync, readFileSync } from 'node:fs' | ||
| import util from 'node:util' | ||
|
|
||
| import type { TONWallet } from '@chainlink/ccip-sdk/src/ton/types.ts' | ||
| import { keyPairFromSecretKey, mnemonicToPrivateKey } from '@ton/crypto' | ||
| import { WalletContractV4 } from '@ton/ton' | ||
|
|
||
| /** | ||
| * Loads a TON wallet from the provided options. | ||
| * @param wallet - wallet options (as passed from yargs argv) | ||
| * @returns Promise to TONWallet instance | ||
| */ | ||
| export async function loadTonWallet({ | ||
| wallet: walletOpt, | ||
| }: { wallet?: unknown } = {}): Promise<TONWallet> { | ||
| if (!walletOpt) walletOpt = process.env['USER_KEY'] || process.env['OWNER_KEY'] | ||
|
|
||
| if (typeof walletOpt !== 'string') | ||
| throw new Error(`Invalid wallet option: ${util.inspect(walletOpt)}`) | ||
|
|
||
| // Handle mnemonic phrase | ||
| if (walletOpt.includes(' ')) { | ||
| const mnemonic = walletOpt.trim().split(' ') | ||
| const keyPair = await mnemonicToPrivateKey(mnemonic) | ||
| const contract = WalletContractV4.create({ | ||
| workchain: 0, | ||
| publicKey: keyPair.publicKey, | ||
| }) | ||
| return { contract, keyPair } | ||
| } | ||
|
|
||
| // Handle hex private key | ||
| if (walletOpt.startsWith('0x')) { | ||
| const secretKey = Buffer.from(walletOpt.slice(2), 'hex') | ||
| if (secretKey.length === 32) { | ||
| throw new Error( | ||
| 'Invalid private key: 32-byte seeds not supported. Use 64-byte secret key or mnemonic.', | ||
| ) | ||
| } | ||
| if (secretKey.length !== 64) { | ||
| throw new Error('Invalid private key: must be 64 bytes (or use mnemonic)') | ||
| } | ||
| const keyPair = keyPairFromSecretKey(secretKey) | ||
| const contract = WalletContractV4.create({ | ||
| workchain: 0, | ||
| publicKey: keyPair.publicKey, | ||
| }) | ||
| return { contract, keyPair } | ||
| } | ||
|
|
||
| // Handle file path | ||
| if (existsSync(walletOpt)) { | ||
| const content = readFileSync(walletOpt, 'utf8').trim() | ||
| const secretKey = Buffer.from(content.startsWith('0x') ? content.slice(2) : content, 'hex') | ||
| if (secretKey.length !== 64) { | ||
| throw new Error('Invalid private key in file: must be 64 bytes') | ||
| } | ||
| const keyPair = keyPairFromSecretKey(secretKey) | ||
| const contract = WalletContractV4.create({ | ||
| workchain: 0, | ||
| publicKey: keyPair.publicKey, | ||
| }) | ||
| return { contract, keyPair } | ||
| } | ||
|
|
||
| throw new Error('Wallet not specified') | ||
| } |
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 |
|---|---|---|
|
|
@@ -55,6 +55,8 @@ | |
| "@mysten/sui": "^1.45.2", | ||
| "@solana/spl-token": "0.4.14", | ||
| "@solana/web3.js": "^1.98.4", | ||
| "@ton/core": "0.62.0", | ||
| "@ton/ton": "^16.1.0", | ||
| "abitype": "1.2.1", | ||
| "bn.js": "^5.2.2", | ||
| "borsh": "^2.0.0", | ||
|
|
@@ -68,4 +70,4 @@ | |
| "bigint-buffer": "npm:@trufflesuite/[email protected]", | ||
| "axios": "^1.13.2" | ||
| } | ||
| } | ||
| } | ||
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.
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.