Skip to content

Commit

Permalink
rename test.sh to localnet.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 16, 2024
1 parent 44f7d72 commit 57ceeb8
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 227 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ jobs:
run: |
cd "${{ matrix.example-dir }}"
yarn
chmod +x ./scripts/test.sh
./scripts/test.sh localnet
chmod +x ./scripts/localnet.sh
./scripts/localnet.sh start
16 changes: 8 additions & 8 deletions examples/call/contracts/Connected.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ contract Connected {
gateway = GatewayEVM(gatewayAddress);
}

function call(
address receiver,
bytes calldata message,
RevertOptions memory revertOptions
) external {
gateway.call(receiver, message, revertOptions);
}

function deposit(
address receiver,
RevertOptions memory revertOptions
Expand Down Expand Up @@ -60,14 +68,6 @@ contract Connected {
gateway.depositAndCall(receiver, amount, asset, message, revertOptions);
}

function call(
address receiver,
bytes calldata message,
RevertOptions memory revertOptions
) external {
gateway.call(receiver, message, revertOptions);
}

function depositAndCall(
address receiver,
bytes calldata message,
Expand Down
32 changes: 16 additions & 16 deletions examples/call/contracts/Universal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ contract Universal is UniversalContract {
gateway = GatewayZEVM(gatewayAddress);
}

function call(
bytes memory receiver,
address zrc20,
bytes calldata message,
CallOptions memory callOptions,
RevertOptions memory revertOptions
) external {
(, uint256 gasFee) = IZRC20(zrc20).withdrawGasFeeWithGasLimit(
callOptions.gasLimit
);
if (!IZRC20(zrc20).transferFrom(msg.sender, address(this), gasFee))
revert TransferFailed();
IZRC20(zrc20).approve(address(gateway), gasFee);
gateway.call(receiver, zrc20, message, callOptions, revertOptions);
}

function withdraw(
bytes memory receiver,
uint256 amount,
Expand All @@ -46,22 +62,6 @@ contract Universal is UniversalContract {
gateway.withdraw(receiver, amount, zrc20, revertOptions);
}

function call(
bytes memory receiver,
address zrc20,
bytes calldata message,
CallOptions memory callOptions,
RevertOptions memory revertOptions
) external {
(, uint256 gasFee) = IZRC20(zrc20).withdrawGasFeeWithGasLimit(
callOptions.gasLimit
);
if (!IZRC20(zrc20).transferFrom(msg.sender, address(this), gasFee))
revert TransferFailed();
IZRC20(zrc20).approve(address(gateway), gasFee);
gateway.call(receiver, zrc20, message, callOptions, revertOptions);
}

function withdrawAndCall(
bytes memory receiver,
uint256 amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

if [ "$1" = "localnet" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi
if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi

echo -e "\n🚀 Compiling contracts..."
npx hardhat compile --force --quiet
Expand Down Expand Up @@ -105,4 +105,4 @@ npx hardhat universal-withdraw-and-call \

npx hardhat localnet-check

if [ "$1" = "localnet" ]; then npx hardhat localnet-stop; fi
if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi
25 changes: 0 additions & 25 deletions examples/hello/scripts/test.sh

This file was deleted.

73 changes: 0 additions & 73 deletions examples/nft/scripts/test.sh

This file was deleted.

26 changes: 0 additions & 26 deletions examples/swap/scripts/test.sh

This file was deleted.

75 changes: 0 additions & 75 deletions examples/token/scripts/test.sh

This file was deleted.

0 comments on commit 57ceeb8

Please sign in to comment.