@Test public void voteProducesCorrectScriptAnsSigner() throws IOException { setUpWireMockForCall("invokescript", "invokescript_vote.json"); setUpWireMockForCall("getblockcount", "getblockcount_1000.json"); byte[] pubKeyBytes1 = Numeric.hexStringToByteArray( "02200284598c6c1117f163dd938a4c8014cf2cf1164c4b7197f347109db50eae7c"); byte[] pubKeyBytes2 = Numeric.hexStringToByteArray( "02c0b60c995bc092e866f15a37c176bb59b7ebacf069ba94c0ebf561cb8f956238"); byte[] expectedScript = new ScriptBuilder().contractCall(NEO_TOKEN_SCRIPT_HASH, VOTE, Arrays.asList( ContractParameter.hash160(account1.getScriptHash()), ContractParameter.publicKey(pubKeyBytes1), ContractParameter.publicKey((pubKeyBytes2)))) .toArray(); Wallet w = Wallet.withAccounts(account1); TransactionBuilder b = new NeoToken(neow).vote(account1.getScriptHash(), new ECPublicKey(pubKeyBytes1), new ECPublicKey(pubKeyBytes2)) .signers(Signer.global(account1.getScriptHash())); assertThat(b.getSigners().get(0).getScriptHash(), is(account1.getScriptHash())); assertThat(b.getSigners().get(0).getScopes(), contains(WitnessScope.GLOBAL)); assertThat(b.getScript(), is(expectedScript)); }
public TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators) { List<ContractParameter> validatorParams = Stream.of(validators) .map(v -> ContractParameter.publicKey(v.getEncoded(true))) .collect(Collectors.toList()); ArrayList<ContractParameter> params = new ArrayList<>(); params.add(ContractParameter.hash160(voter)); params.addAll(validatorParams); return invokeFunction(VOTE, params.toArray(new ContractParameter[]{})); }
NeoToken extends Nep5Token { public TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators) { List<ContractParameter> validatorParams = Stream.of(validators) .map(v -> ContractParameter.publicKey(v.getEncoded(true))) .collect(Collectors.toList()); ArrayList<ContractParameter> params = new ArrayList<>(); params.add(ContractParameter.hash160(voter)); params.addAll(validatorParams); return invokeFunction(VOTE, params.toArray(new ContractParameter[]{})); } }
NeoToken extends Nep5Token { public TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators) { List<ContractParameter> validatorParams = Stream.of(validators) .map(v -> ContractParameter.publicKey(v.getEncoded(true))) .collect(Collectors.toList()); ArrayList<ContractParameter> params = new ArrayList<>(); params.add(ContractParameter.hash160(voter)); params.addAll(validatorParams); return invokeFunction(VOTE, params.toArray(new ContractParameter[]{})); } NeoToken(Neow3j neow); }
NeoToken extends Nep5Token { public TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators) { List<ContractParameter> validatorParams = Stream.of(validators) .map(v -> ContractParameter.publicKey(v.getEncoded(true))) .collect(Collectors.toList()); ArrayList<ContractParameter> params = new ArrayList<>(); params.add(ContractParameter.hash160(voter)); params.addAll(validatorParams); return invokeFunction(VOTE, params.toArray(new ContractParameter[]{})); } NeoToken(Neow3j neow); @Override String getName(); @Override String getSymbol(); @Override BigInteger getTotalSupply(); @Override int getDecimals(); BigInteger unclaimedGas(ScriptHash scriptHash, long blockHeight); TransactionBuilder registerCandidate(ECPublicKey candidateKey); TransactionBuilder unregisterCandidate(ECPublicKey candidateKey); List<ECPublicKey> getValidators(); List<ECPublicKey> getCommittee(); Map<ECPublicKey, Integer> getCandidates(); List<ECPublicKey> getNextBlockValidators(); TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators); }
NeoToken extends Nep5Token { public TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators) { List<ContractParameter> validatorParams = Stream.of(validators) .map(v -> ContractParameter.publicKey(v.getEncoded(true))) .collect(Collectors.toList()); ArrayList<ContractParameter> params = new ArrayList<>(); params.add(ContractParameter.hash160(voter)); params.addAll(validatorParams); return invokeFunction(VOTE, params.toArray(new ContractParameter[]{})); } NeoToken(Neow3j neow); @Override String getName(); @Override String getSymbol(); @Override BigInteger getTotalSupply(); @Override int getDecimals(); BigInteger unclaimedGas(ScriptHash scriptHash, long blockHeight); TransactionBuilder registerCandidate(ECPublicKey candidateKey); TransactionBuilder unregisterCandidate(ECPublicKey candidateKey); List<ECPublicKey> getValidators(); List<ECPublicKey> getCommittee(); Map<ECPublicKey, Integer> getCandidates(); List<ECPublicKey> getNextBlockValidators(); TransactionBuilder vote(ScriptHash voter, ECPublicKey... validators); final static int DECIMALS; final static String NAME; final static String SYMBOL; final static BigInteger TOTAL_SUPPLY; static final ScriptHash SCRIPT_HASH; static final String UNCLAIMED_GAS; static final String REGISTER_CANDIDATE; static final String UNREGISTER_CANDIDATE; static final String VOTE; static final String GET_CANDIDATES; static final String GET_VALIDATORS; static final String GET_COMMITTEE; static final String GET_NEXT_BLOCK_VALIDATORS; }