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

fix: disable methods and add withdraw method #873

Merged
merged 1 commit into from
Feb 3, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public Map<String, BigInteger> getAccumulatedFees() {
*/
@External
public void tokenFallback(Address _from, BigInteger _value, byte[] _data) {
Context.revert("Not supported");
require(_value.compareTo(BigInteger.ZERO) >= 0, "value should be positive");
checkUintLimit(_value);
String _coinName = coinAddressName.get(Context.getCaller());
Expand Down Expand Up @@ -526,6 +527,7 @@ public void tokenFallback(Address _from, BigInteger _value, byte[] _data) {
*/
@External
public void reclaim(String _coinName, BigInteger _value) {
Context.revert("Not supported");
require(_value.compareTo(BigInteger.ZERO) > 0, "_value must be positive");
checkUintLimit(_value);

Expand Down Expand Up @@ -555,6 +557,34 @@ public void reclaim(String _coinName, BigInteger _value) {
}
}

@External
public void withdrawAllTokens() {
requireOwnerAccess();
Address _to = Context.getCaller();
for (String coinName : coinNames()) {
if (name.equals(coinName)) {
Context.transfer(_to, Context.getBalance(Context.getAddress()));
} else {
BigInteger balance = Context.call(BigInteger.class, this.getCoinAddress(coinName), "balanceOf", Context.getAddress());
if(balance.compareTo(BigInteger.ZERO) == 0) continue;
transfer(_to, coinName, balance);
}
}
}

@External
public void withdrawToken(String _coinName) {
requireOwnerAccess();
Address _to = Context.getCaller();
if(name.equals(_coinName)) {
Context.transfer(_to, Context.getBalance(Context.getAddress()));
return;
}
BigInteger balance = Context.call(BigInteger.class, this.getCoinAddress(_coinName), "balanceOf", Context.getAddress());
if(balance.compareTo(BigInteger.ZERO) == 0) return;
transfer(_to, _coinName, balance);
}

/**
* To transfer nativecoin |ICX| to destination chains
* Checks for blacklist and token limit
Expand Down Expand Up @@ -598,6 +628,7 @@ public void transferNativeCoin(String _to) {
*/
@External
public void transfer(String _coinName, BigInteger _value, String _to) {
Context.revert("Not supported");
require(!_coinName.equals(name), "Only for IRC2 Token");
require(_value != null && _value.compareTo(BigInteger.ZERO) > 0, "Invalid amount");
checkUintLimit(_value);
Expand Down Expand Up @@ -631,6 +662,7 @@ public void transfer(String _coinName, BigInteger _value, String _to) {
@Payable
@External
public void transferBatch(String[] _coinNames, BigInteger[] _values, String _to) {
Context.revert("Not supported");
Context.require(_to.length() < 100, "Length Check");
int len = _coinNames.length;
require(len > 0, "Zero length arguments");
Expand Down
Loading
Loading