Skip to content

Commit

Permalink
NetworkAddress Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sagars committed Nov 22, 2024
1 parent a00b28c commit 7a326cf
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public BigInteger getDeposit(Address _tokenAddress, Address _user) {

@External(readonly = true)
public BigInteger getDepositV2(Address _tokenAddress, String _user) {
NetworkAddress user = NetworkAddress.valueOf(_user);
NetworkAddress user = NetworkAddress.valueOf(_user, NATIVE_NID);
return deposit.at(_tokenAddress).getOrDefault(user, BigInteger.ZERO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public void xAdd(String from, String _baseToken, String _quoteToken, BigInteger
checkStatus();
isValidPercent(_slippagePercentage.intValue());

addInternal(NetworkAddress.parse(from), Address.fromString(_baseToken), Address.fromString(_quoteToken), _baseValue, _quoteValue,
addInternal(NetworkAddress.valueOf(from), Address.fromString(_baseToken), Address.fromString(_quoteToken), _baseValue, _quoteValue,
_withdraw_unused, _slippagePercentage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public BigInteger balanceOf(Address _owner, BigInteger _id) {

@External(readonly = true)
public BigInteger xBalanceOf(String _owner, BigInteger _id) {
NetworkAddress address = NetworkAddress.valueOf(_owner);
NetworkAddress address = NetworkAddress.valueOf(_owner, NATIVE_NID);
return DexDBVariables.balance.at(_id.intValue()).getOrDefault(address, BigInteger.ZERO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected void xDepositTokenWithoutTo(String depositor, String to, Account token
* */

protected void handleCallMessageWithOutProtocols(String from, byte[] data, String[] protocols ) {
NetworkAddress fromNetworkAddress = NetworkAddress.parse(from);
NetworkAddress fromNetworkAddress = NetworkAddress.valueOf(from);
contextMock.when(() -> Context.call(eq(BalancedAddressManager.getXCallManager()), eq("verifyProtocols"), eq(fromNetworkAddress.net()), eq(protocols))).thenReturn(true);
dexScore.invoke(xcallScore, "handleCallMessage", from, data, protocols);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public BigInteger balanceOf(Address _owner, BigInteger _id) {

@External(readonly = true)
public BigInteger xBalanceOf(String _owner, BigInteger _id) {
NetworkAddress owner = NetworkAddress.valueOf(_owner);
NetworkAddress owner = NetworkAddress.valueOf(_owner, NATIVE_NID);
return poolStakedDetails.at(owner).getOrDefault(_id, BigInteger.ZERO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public class TokenTransfer {

Check warning on line 11 in score-lib/src/main/java/network/balanced/score/lib/utils/TokenTransfer.java

View check run for this annotation

Codecov / codecov/patch

score-lib/src/main/java/network/balanced/score/lib/utils/TokenTransfer.java#L11

Added line #L11 was not covered by tests

public static void transfer(Address token, String to, BigInteger amount, byte[] data){
NetworkAddress toNetworkAddress = NetworkAddress.parse(to);
String NATIVE_NID = (String) Context.call(BalancedAddressManager.getXCall(), "getNetworkId");
NetworkAddress toNetworkAddress = NetworkAddress.valueOf(to, NATIVE_NID);
if(!NATIVE_NID.equals(toNetworkAddress.net())) {
if(canWithdraw(toNetworkAddress.net())) {
String nativeAddress = (String) Context.call(BalancedAddressManager.getAssetManager(), "getNativeAssetAddress", token, toNetworkAddress.net());
Expand Down

0 comments on commit 7a326cf

Please sign in to comment.