Skip to content

Commit

Permalink
Merge pull request #81 from uniworld-io/PosBridge
Browse files Browse the repository at this point in the history
PoS Bridge
  • Loading branch information
elonkusk committed Jun 18, 2022
2 parents 74c9605 + ed7530b commit 87dfa39
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ public boolean validate() throws ContractValidateException {

if(ctx.hasField(TO_ADDRESS_FIELD_NUMBER)){
var toAddr = ctx.getToAddress().toByteArray();
Assert.isTrue(Wallet.addressValid(toAddr)
&& !Arrays.equals(toAddr, ownerAddr)
&& !Arrays.equals(dbManager.getBurnAddress(), toAddr)
&& (!accStore.has(toAddr) || (accStore.get(toAddr).getType() != Protocol.AccountType.Contract)),
"Bad to address: invalid, is owner|burn| or contract address!");
Assert.isTrue(Wallet.addressValid(toAddr), "To address invalid!");
Assert.isTrue(!Arrays.equals(toAddr, ownerAddr), "Bad to address: is owner!");
Assert.isTrue(!Arrays.equals(dbManager.getBurnAddress(), toAddr), "Bad to address: is burner!");
Assert.isTrue((!accStore.has(toAddr) || (accStore.get(toAddr).getType() != Protocol.AccountType.Contract)), "Bad to address: is contract!");

if(!accStore.has(toAddr)){
fee = Math.addExact(fee, dbManager.getDynamicPropertiesStore().getCreateNewAccountFeeInSystemContract());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public GrpcAPI.NumberMessage balanceOf(Protocol.Urc721BalanceOfQuery query) {
Assert.isTrue(dbManager.getUrc721ContractStore().has(contract), "Unrecognized contract address");

var relationStore = dbManager.getUrc721AccountTokenRelationStore();
var balance = relationStore.has(owner) ? relationStore.get(owner).getTotal(Wallet.encode58Check(contract)) : 0L;
var balance = relationStore.has(owner) ? relationStore.get(owner).getTotal(Wallet.encode58Check(contract)) : 0;

return GrpcAPI.NumberMessage.newBuilder()
.setNum(balance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.unichain.api.GrpcAPI;
import org.unichain.core.services.http.utils.JsonFormat;
import org.unichain.core.services.http.utils.Util;
import org.unichain.core.actuator.urc721.ext.Urc721;
Expand Down Expand Up @@ -40,7 +41,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
if (reply != null) {
response.getWriter().println(JsonFormat.printToString(reply, visible));
} else {
response.getWriter().println("{}");
response.getWriter().println(JsonFormat.printToString(GrpcAPI.NumberMessage.newBuilder().setNum(0).build(), visible));
}
} catch (Exception e) {
logger.debug("Exception: {}", e.getMessage());
Expand Down

0 comments on commit 87dfa39

Please sign in to comment.