Skip to content

Commit

Permalink
missing crosschain methods added for Dividends
Browse files Browse the repository at this point in the history
  • Loading branch information
sagars committed Dec 17, 2024
1 parent cd99282 commit 891785b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
1 change: 0 additions & 1 deletion core-contracts/Dex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ dependencies {
testImplementation Dependencies.mockitoCore
testImplementation Dependencies.mockitoInline


testImplementation project(':test-lib')
testImplementation Dependencies.junitJupiter
testRuntimeOnly Dependencies.junitJupiterEngine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@

import foundation.icon.xcall.NetworkAddress;
import network.balanced.score.lib.interfaces.Dividends;
import network.balanced.score.lib.interfaces.DividendsXCall;
import network.balanced.score.lib.structs.DistributionPercentage;
import network.balanced.score.lib.structs.PrepDelegations;
import network.balanced.score.lib.utils.Names;
import network.balanced.score.lib.utils.NetworkAddressBranchDictDB;
import network.balanced.score.lib.utils.TokenTransfer;
import network.balanced.score.lib.utils.Versions;
import network.balanced.score.lib.utils.*;
import score.*;
import score.annotation.EventLog;
import score.annotation.External;
import score.annotation.Optional;
import scorex.util.ArrayList;
import scorex.util.HashMap;

import java.lang.Math;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -376,7 +375,18 @@ public Map<String, BigInteger> getUnclaimedDividends(Address user) {
return totalDividends;
}

//todo: add xClaimDividends method
@External
public void handleCallMessage(String _from, byte[] _data, @Optional String[] _protocols) {
Check.checkStatus();
only(getXCall());
XCallUtils.verifyXCallProtocols(_from, _protocols);
DividendsXCall.process(this, _from, _data);
}

public void xClaimDividends(String from){
claimDividendsInternal(from);
}

@External
public void claimDividends() {
Address user = Context.getCaller();
Expand Down Expand Up @@ -409,7 +419,10 @@ private void claimDividendsInternal(String user){
DividendsTracker.setBBalnTotalSupply(getBoostedTotalSupply().add(bbalnBalance).subtract(prevBalance));
}

//todo: add xClaim method
public void xClaim(String from, @Optional Integer _start, @Optional Integer _end){
claimInternal(from, _start, _end);
}

@External
public void claim(@Optional int _start, @Optional int _end) {
Address account = Context.getCaller();
Expand Down Expand Up @@ -455,7 +468,10 @@ private void claimInternal(String account, @Optional int _start, @Optional int _
}
}

//todo: add xAccumulateDividends method
public void xAccumulateDividends(String from, @Optional Integer _start, @Optional Integer _end){
accumulateDividendsInternal(from, _start, _end);
}

@External
public void accumulateDividends(Address user, @Optional int _start, @Optional int _end) {
accumulateDividendsInternal(getStringNetworkAddress(user), _start, _end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import foundation.icon.score.client.ScoreClient;
import foundation.icon.score.client.ScoreInterface;
import network.balanced.score.lib.annotations.XCall;
import network.balanced.score.lib.interfaces.addresses.AddressManager;
import network.balanced.score.lib.interfaces.base.Name;
import network.balanced.score.lib.interfaces.base.TokenFallback;
Expand Down Expand Up @@ -110,12 +111,21 @@ public interface Dividends extends Name, TokenFallback, AddressManager, Version
@External
void claimDividends();

@XCall
void xClaimDividends(String from);

@External
void claim(@Optional int _start, @Optional int _end);

@XCall
void xClaim(String from, @Optional Integer _start, @Optional Integer _end);

@External
void accumulateDividends(Address user, @Optional int _start, @Optional int _end);

@XCall
void xAccumulateDividends(String from, @Optional Integer _start, @Optional Integer _end);

@External(readonly = true)
Map<String, BigInteger> getUserDividends(Address _account, @Optional int _start, @Optional int _end);

Expand Down

0 comments on commit 891785b

Please sign in to comment.