Skip to content

Commit

Permalink
swap companion task: handle both EVM and non-EVM addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Feb 2, 2025
1 parent 2504633 commit cc7eeeb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 50 deletions.
2 changes: 2 additions & 0 deletions examples/swap/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ cache_forge
access_token

localnet.json

test-ledger
98 changes: 49 additions & 49 deletions examples/swap/scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,54 +39,54 @@ npx hardhat localnet:solana-deposit-and-call \

npx hardhat localnet-check

# npx hardhat companion-swap \
# --network localhost \
# --contract "$COMPANION" \
# --universal-contract "$CONTRACT_SWAP" \
# --amount 1 \
# --target "$ZRC20_BNB" \
# --recipient "$SENDER"

# npx hardhat localnet-check

# npx hardhat companion-swap \
# --network localhost \
# --contract "$COMPANION" \
# --universal-contract "$CONTRACT_SWAP" \
# --amount 1 \
# --erc20 "$USDC_ETHEREUM" \
# --target "$ZRC20_BNB" \
# --recipient "$SENDER"

# npx hardhat localnet-check

# npx hardhat evm-swap \
# --network localhost \
# --receiver "$CONTRACT_SWAP" \
# --amount 1 \
# --target "$ZRC20_BNB" \
# --recipient "$SENDER"

# npx hardhat localnet-check

# npx hardhat evm-swap \
# --network localhost \
# --receiver "$CONTRACT_SWAP" \
# --amount 1 \
# --target "$ZRC20_BNB" \
# --recipient "$SENDER" \
# --withdraw false

# npx hardhat localnet-check

# npx hardhat zetachain-swap \
# --network localhost \
# --contract "$CONTRACT_SWAP" \
# --amount 1 \
# --zrc20 "$ZRC20_BNB" \
# --target "$ZRC20_ETHEREUM" \
# --recipient "$SENDER"

# npx hardhat localnet-check
npx hardhat companion-swap \
--network localhost \
--contract "$COMPANION" \
--universal-contract "$CONTRACT_SWAP" \
--amount 1 \
--target "$ZRC20_BNB" \
--recipient "$SENDER"

npx hardhat localnet-check

npx hardhat companion-swap \
--network localhost \
--contract "$COMPANION" \
--universal-contract "$CONTRACT_SWAP" \
--amount 1 \
--erc20 "$USDC_ETHEREUM" \
--target "$ZRC20_BNB" \
--recipient "$SENDER"

npx hardhat localnet-check

npx hardhat evm-swap \
--network localhost \
--receiver "$CONTRACT_SWAP" \
--amount 1 \
--target "$ZRC20_BNB" \
--recipient "$SENDER"

npx hardhat localnet-check

npx hardhat evm-swap \
--network localhost \
--receiver "$CONTRACT_SWAP" \
--amount 1 \
--target "$ZRC20_BNB" \
--recipient "$SENDER" \
--withdraw false

npx hardhat localnet-check

npx hardhat zetachain-swap \
--network localhost \
--contract "$CONTRACT_SWAP" \
--amount 1 \
--zrc20 "$ZRC20_BNB" \
--target "$ZRC20_ETHEREUM" \
--recipient "$SENDER"

npx hardhat localnet-check

if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi
4 changes: 3 additions & 1 deletion examples/swap/tasks/companionSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {

const factory = (await hre.ethers.getContractFactory("SwapCompanion")) as any;
const contract = factory.attach(args.contract).connect(signer);
const recipient = hre.ethers.utils.toUtf8Bytes(args.recipient);
const recipient = hre.ethers.utils.isAddress(args.recipient)
? args.recipient
: hre.ethers.utils.toUtf8Bytes(args.recipient);
let tx;
if (args.erc20) {
const erc20Contract = new ethers.Contract(
Expand Down

0 comments on commit cc7eeeb

Please sign in to comment.