-
Notifications
You must be signed in to change notification settings - Fork 15
Add support for SUI, Hedera, and FQ 2.0 #197
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
Open
finleydecker
wants to merge
11
commits into
main
Choose a base branch
from
support-sui-hedera-fq2.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ff3f19a
support sui
finleydecker d8ed8a1
add fq 2.0 abi
finleydecker 1c14a10
fix hedera
finleydecker 2ec6754
fix hedera
finleydecker 4c7122a
add fq 2.0 abi
finleydecker e8a3bca
merge
finleydecker f3275cb
fix linting issues
finleydecker b4e3fc1
default to HBAR not WHBAR
finleydecker bda6deb
add sui and hedera support to readme
finleydecker 712da4f
fix linting issues
finleydecker 647b239
fix linting issues
finleydecker 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 |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ import { | |
| getDataBytes, | ||
| networkInfo, | ||
| } from '@chainlink/ccip-sdk/src/index.ts' | ||
| import { type BytesLike, AbiCoder, formatUnits, toUtf8Bytes } from 'ethers' | ||
| import { type BytesLike, AbiCoder, ZeroAddress, formatUnits, toUtf8Bytes } from 'ethers' | ||
| import type { Argv } from 'yargs' | ||
|
|
||
| import type { GlobalOpts } from '../index.ts' | ||
|
|
@@ -318,7 +318,14 @@ async function sendMessage( | |
| } | ||
|
|
||
| let feeToken, feeTokenInfo | ||
| if (argv.feeToken) { | ||
| const feeTokenArg = (argv.feeToken ?? '').toLowerCase() | ||
| if (feeTokenArg === 'native' || feeTokenArg === 'hbar') { | ||
| // CCIP Directory lists native HBAR as a fee token on Hedera; use ZeroAddress so EVM sends msg.value | ||
| feeToken = ZeroAddress | ||
| const wrappedNative = await source.getNativeTokenForRouter(argv.router) | ||
| feeTokenInfo = await source.getTokenInfo(wrappedNative) | ||
| feeTokenInfo = { ...feeTokenInfo, symbol: feeTokenInfo.symbol.replace(/^W/, '') || 'HBAR' } | ||
| } else if (argv.feeToken) { | ||
| try { | ||
| feeToken = (source.constructor as ChainStatic).getAddress(argv.feeToken) | ||
| feeTokenInfo = await source.getTokenInfo(feeToken) | ||
|
|
@@ -336,6 +343,13 @@ async function sendMessage( | |
| } else { | ||
| const nativeToken = await source.getNativeTokenForRouter(argv.router) | ||
| feeTokenInfo = await source.getTokenInfo(nativeToken) | ||
| if (feeTokenInfo.symbol === 'WHBAR') { | ||
| // On Hedera, default to native HBAR (msg.value) rather than WHBAR approval | ||
| feeToken = ZeroAddress | ||
| feeTokenInfo = { ...feeTokenInfo, symbol: 'HBAR' } | ||
| } else { | ||
| feeToken = nativeToken | ||
| } | ||
| } | ||
|
|
||
| const message: MessageInput = { | ||
|
|
@@ -371,9 +385,11 @@ async function sendMessage( | |
| const balance = await source.getBalance({ holder: walletAddress, token: feeToken }) | ||
| if (balance < fee) { | ||
| const symbol = | ||
| feeTokenInfo.symbol.startsWith('W') && !feeToken | ||
| ? feeTokenInfo.symbol.substring(1) | ||
| : feeTokenInfo.symbol | ||
| feeToken === ZeroAddress | ||
| ? feeTokenInfo.symbol | ||
| : feeTokenInfo.symbol.startsWith('W') | ||
| ? feeTokenInfo.symbol.substring(1) | ||
| : feeTokenInfo.symbol | ||
|
Comment on lines
+388
to
+392
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: These chains of ternaries get pretty difficult to read, I think at this point good old if-elses would read easier. |
||
| throw new CCIPInsufficientBalanceError( | ||
| formatUnits(balance, feeTokenInfo.decimals), | ||
| formatUnits(fee, feeTokenInfo.decimals), | ||
|
|
||
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.
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.
This doesn't seem like the right abstraction level to do. this. Can this logic be moved down to the implementations of
getTokenInfo? I don't know much about Hedera but it seems like we're bleeding pretty chain and token-specific behaviour into a file that's chain-agnostic.