Skip to content
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

Add revert handling to the Swap example #219

Merged
merged 70 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2b827bc
Update hello to auth calls
fadeev Nov 8, 2024
afa11f1
remove omnichain examples
fadeev Nov 8, 2024
b6a444d
wip
fadeev Nov 8, 2024
a5e15a1
swap works
fadeev Nov 8, 2024
50e7217
swap
fadeev Nov 9, 2024
f8357ad
deps and remove omnichain swap
fadeev Nov 11, 2024
b0f3d1b
nft: update toolkit
fadeev Nov 11, 2024
3150e9c
nft: sender and update localnet
fadeev Nov 11, 2024
d687d9c
hello: rename contracts to universal and connected
fadeev Nov 11, 2024
ff28b85
rename hello to calls
fadeev Nov 11, 2024
e5f6c5f
Merge branch 'main' into auth-call-hello-swap
fadeev Nov 11, 2024
b6886bf
rename to call
fadeev Nov 11, 2024
d420ab7
rename to call
fadeev Nov 11, 2024
936d399
call: depositAndCall
fadeev Nov 11, 2024
7476874
call: add deposit function
fadeev Nov 11, 2024
c2410f0
call: universal withdraw
fadeev Nov 11, 2024
ed3e800
call: withdraw and call arbitrary
fadeev Nov 11, 2024
68217a5
call: fix withdraw and call
fadeev Nov 12, 2024
c5e2348
onCall: remove return
fadeev Nov 12, 2024
5e05fb0
call: deposit/depositAndCall ERC-20s
fadeev Nov 12, 2024
deffb4d
returns bytes 4
fadeev Nov 12, 2024
382e08c
slither
fadeev Nov 12, 2024
f05a97c
call: reverts
fadeev Nov 12, 2024
f7b583a
hello example
fadeev Nov 13, 2024
5eb0da9
remove unused improts
fadeev Nov 13, 2024
1d72aee
slither
fadeev Nov 13, 2024
5b6234f
wip
fadeev Nov 15, 2024
44f7d72
nft: fix localnet
fadeev Nov 15, 2024
57ceeb8
rename test.sh to localnet.sh
fadeev Nov 16, 2024
6513b52
rename test.sh to localnet.sh
fadeev Nov 16, 2024
c1ab35e
rename test.sh to localnet.sh
fadeev Nov 16, 2024
8331f22
token: consistency
fadeev Nov 17, 2024
01700ef
wip
fadeev Nov 17, 2024
29bb170
fix
fadeev Nov 17, 2024
0b7ac4c
immutable
fadeev Nov 17, 2024
34e87b4
import types
fadeev Nov 17, 2024
822cb23
fix revert
fadeev Nov 17, 2024
85f91be
nft: rename sender to receiver
fadeev Nov 18, 2024
1495357
replace system contract with uniswap router
fadeev Nov 18, 2024
1df6664
token: deploy task
fadeev Nov 18, 2024
f5ad522
token: replace system contract with uniswap router
fadeev Nov 18, 2024
051ee41
default addresses
fadeev Nov 18, 2024
cfaf6fb
default addresses
fadeev Nov 18, 2024
9985dc7
add localnet to gitignore
fadeev Nov 18, 2024
757c438
remove default uniswap address
fadeev Nov 18, 2024
0cbaa24
nft: withdrawAndCall
fadeev Nov 18, 2024
13f3299
nft: return extra tokens to sender, handle a case where receiver is n…
fadeev Nov 18, 2024
75438c3
token: return to sender
fadeev Nov 18, 2024
aa55fa3
nft/token: handle revert on zetachain
fadeev Nov 18, 2024
fd03f00
fix
fadeev Nov 18, 2024
91b8121
remove placeholder event
fadeev Nov 18, 2024
1bda9b7
token: zero address validation
fadeev Nov 19, 2024
84beed4
swap: zero address validation
fadeev Nov 19, 2024
4cfaa55
immutable gas limit
fadeev Nov 19, 2024
16d8c13
rename counterparty
fadeev Nov 20, 2024
5013b00
rename counterparty
fadeev Nov 20, 2024
6a15652
rename counterparty
fadeev Nov 20, 2024
c89c6da
gateway revert
fadeev Nov 20, 2024
786d629
gateway revert
fadeev Nov 20, 2024
a6d9809
safeTransferFrom
fadeev Nov 20, 2024
83ab10b
revert
fadeev Nov 20, 2024
acd8da7
fix: Swap handle reverts
fadeev Nov 22, 2024
f425a77
Swap to any
fadeev Nov 22, 2024
581f201
remove extra approve
fadeev Nov 22, 2024
2d82f6c
Refactor
fadeev Nov 22, 2024
e815844
gas limit
fadeev Nov 22, 2024
5dfba30
gas immutable and deploy fix
fadeev Nov 22, 2024
a279ac1
handle errors
fadeev Nov 22, 2024
e111f44
throw error
fadeev Nov 22, 2024
77418a8
merge main
fadeev Nov 28, 2024
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
Prev Previous commit
Next Next commit
remove extra approve
fadeev committed Nov 22, 2024
commit 581f2012b580f0b43ef121b5db4d3746d369dec9
7 changes: 0 additions & 7 deletions examples/swap/contracts/Swap.sol
Original file line number Diff line number Diff line change
@@ -104,13 +104,6 @@ contract Swap is UniversalContract {
targetToken,
0
);

if (gasZRC20 == targetToken) {
IZRC20(gasZRC20).approve(address(gateway), outputAmount + gasFee);
} else {
IZRC20(gasZRC20).approve(address(gateway), gasFee);
IZRC20(targetToken).approve(address(gateway), outputAmount);
}
return outputAmount;
}


Unchanged files with check annotations Beta

return (outputAmount, gasZRC20, gasFee);
}
function withdraw(
Params memory params,
address sender,
uint256 gasFee,
address gasZRC20,
uint256 outputAmount,
address inputToken
) public {
if (params.withdraw) {
if (gasZRC20 == params.target) {
IZRC20(gasZRC20).approve(
address(gateway),

Check failure

Code scanning / Slither

Unchecked transfer High

outputAmount + gasFee
);
} else {
IZRC20(gasZRC20).approve(address(gateway), gasFee);
IZRC20(params.target).approve(address(gateway), outputAmount);
}
gateway.withdraw(
abi.encodePacked(params.to),
outputAmount,
params.target,
RevertOptions({
revertAddress: address(this),
callOnRevert: true,
abortAddress: address(0),
revertMessage: abi.encode(sender, inputToken),
onRevertGasLimit: 0
})
);
} else {
IWETH9(params.target).transfer(
address(uint160(bytes20(params.to))),
outputAmount
);
}
}
function onRevert(RevertContext calldata context) external onlyGateway {
(address sender, address zrc20) = abi.decode(