From f75e9c841dfba0af1c405c4724366b7d3ab010ce Mon Sep 17 00:00:00 2001 From: Tore Kasper Frederiksen Date: Fri, 4 Nov 2022 13:37:18 +0100 Subject: [PATCH] fix: setup things for new network --- build.gradle | 3 +-- .../com/alphawallet/ethereum/ERC721Token.java | 5 ++--- .../attestation/demo/SmartContract.java | 17 ++++++----------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 4a8fa181..d9bdd8f7 100644 --- a/build.gradle +++ b/build.gradle @@ -48,8 +48,7 @@ dependencies { intTestImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' intTestRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' - // TODO very obsolete and should be refactored out or updated - implementation 'org.web3j:core:[4,5.0.0)' + implementation 'org.web3j:core:5.0.0' implementation 'com.auth0:java-jwt:4.0.0' implementation 'org.json:json:20220320' // To ensure obsolete trulioo code can compile implementation group: 'com.github.cliftonlabs', name: 'json-simple', version: '[4.0.1, 5)' diff --git a/src/main/java/com/alphawallet/ethereum/ERC721Token.java b/src/main/java/com/alphawallet/ethereum/ERC721Token.java index 5a84dc93..0951c602 100644 --- a/src/main/java/com/alphawallet/ethereum/ERC721Token.java +++ b/src/main/java/com/alphawallet/ethereum/ERC721Token.java @@ -1,17 +1,16 @@ package com.alphawallet.ethereum; import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.DynamicArray; import org.web3j.abi.datatypes.DynamicBytes; -import org.web3j.abi.datatypes.DynamicStruct; import org.web3j.abi.datatypes.Type; import org.web3j.abi.datatypes.generated.Uint256; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -public class ERC721Token extends DynamicStruct +public class ERC721Token extends DynamicArray { public Address address; public Uint256 tokenId; diff --git a/src/main/java/org/tokenscript/attestation/demo/SmartContract.java b/src/main/java/org/tokenscript/attestation/demo/SmartContract.java index 0ae41d47..adc8f7a3 100644 --- a/src/main/java/org/tokenscript/attestation/demo/SmartContract.java +++ b/src/main/java/org/tokenscript/attestation/demo/SmartContract.java @@ -65,7 +65,7 @@ public TicketAttestationReturn callVerifyTicketAttestation(byte[] attestation, S } private TicketAttestationReturn runVerifyTicketAttestationSC(Function function) { - Web3j web3j = getRinkebyWeb3j(); + Web3j web3j = getWeb3j(); String result = callSmartContractFunction(web3j, function, TICKET_VERIFICATION_CONTRACT); List responseValues = FunctionReturnDecoder.decode(result, function.getOutputParameters()); TicketAttestationReturn retVal = new TicketAttestationReturn(); @@ -89,7 +89,7 @@ private TicketAttestationReturn runVerifyTicketAttestationSC(Function function) public AttestationReturn callVerifyNFTAttestation(byte[] att, String sender) { - Web3j web3j = getRinkebyWeb3j(); + Web3j web3j = getWeb3j(); Function function = verifyNFTAttestation(att, sender); String result = callSmartContractFunction(web3j, function, ATTESTATION_VERIFICATION_CONTRACT); List responseValues = FunctionReturnDecoder.decode(result, function.getOutputParameters()); @@ -143,7 +143,7 @@ private boolean callFunction(Function function) private List
callAddrFunction(Function function) { - Web3j web3j = getRinkebyWeb3j(); + Web3j web3j = getWeb3j(); List
addrList = new ArrayList<>(); try @@ -280,14 +280,9 @@ private OkHttpClient buildClient() private Web3j getWeb3j() { //Infura - HttpService nodeService = new HttpService("https://kovan.infura.io/v3/b567f041158a4676898698c2d4c5f478", buildClient(), false); - return Web3j.build(nodeService); - } - - private Web3j getRinkebyWeb3j() - { - //Infura - HttpService nodeService = new HttpService("https://rinkeby.infura.io/v3/b567f041158a4676898698c2d4c5f478", buildClient(), false); + //TODO update network + HttpService nodeService = new HttpService( + "https://goerli.infura.io/v3/b567f041158a4676898698c2d4c5f478", buildClient(), false); return Web3j.build(nodeService); } }