Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ccip-cli/src/commands/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
getDataBytes,
networkInfo,
} from '@chainlink/ccip-sdk/src/index.ts'
import { type BytesLike, formatUnits, toUtf8Bytes } from 'ethers'
import { type BytesLike, ZeroAddress, formatUnits, toUtf8Bytes } from 'ethers'
import type { Argv } from 'yargs'

import type { GlobalOpts } from '../index.ts'
Expand Down Expand Up @@ -262,7 +262,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)
Expand All @@ -279,6 +286,7 @@ async function sendMessage(
}
} else {
const nativeToken = await source.getNativeTokenForRouter(argv.router)
feeToken = nativeToken
feeTokenInfo = await source.getTokenInfo(nativeToken)
}

Expand Down Expand Up @@ -315,9 +323,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
throw new CCIPInsufficientBalanceError(
formatUnits(balance, feeTokenInfo.decimals),
formatUnits(fee, feeTokenInfo.decimals),
Expand Down
6 changes: 6 additions & 0 deletions ccip-cli/src/providers/sui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CCIPArgumentInvalidError, bytesToBuffer } from '@chainlink/ccip-sdk/src/index.ts'
import { decodeSuiPrivateKey } from '@mysten/sui/cryptography'
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'

/**
Expand All @@ -9,6 +10,11 @@ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'
export function loadSuiWallet({ wallet: walletOpt }: { wallet?: unknown }) {
if (typeof walletOpt !== 'string') throw new CCIPArgumentInvalidError('wallet', String(walletOpt))

if (walletOpt.startsWith('suiprivkey')) {
const { secretKey } = decodeSuiPrivateKey(walletOpt)
return Ed25519Keypair.fromSecretKey(secretKey)
}

const keyBytes = bytesToBuffer(walletOpt)
return Ed25519Keypair.fromSecretKey(keyBytes)
}
3 changes: 2 additions & 1 deletion ccip-sdk/src/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { getOffchainTokenData } from './offchain.ts'
import { getMessagesInTx } from './requests.ts'
import { DEFAULT_GAS_LIMIT } from './shared/constants.ts'
import type { UnsignedSolanaTx } from './solana/types.ts'
import type { UnsignedSuiTx } from './sui/types.ts'
import type { UnsignedTONTx } from './ton/types.ts'
import {
type AnyMessage,
Expand Down Expand Up @@ -282,7 +283,7 @@ export type UnsignedTx = {
[ChainFamily.Solana]: UnsignedSolanaTx
[ChainFamily.Aptos]: UnsignedAptosTx
[ChainFamily.TON]: UnsignedTONTx
[ChainFamily.Sui]: never // TODO
[ChainFamily.Sui]: UnsignedSuiTx
[ChainFamily.Unknown]: never
}

Expand Down
Loading
Loading