NeoToken extends Nep5Token { public TransactionBuilder registerCandidate(ECPublicKey candidateKey) { return invokeFunction(REGISTER_CANDIDATE, ContractParameter.publicKey(candidateKey.getEncoded(true))); } 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; }
@Test public void registerCandidate() throws IOException { setUpWireMockForCall("invokescript", "invokescript_registercandidate.json"); setUpWireMockForCall("getblockcount", "getblockcount_1000.json"); byte[] pubKeyBytes = account1.getECKeyPair().getPublicKey().getEncoded(true); byte[] expectedScript = new ScriptBuilder().contractCall(NEO_TOKEN_SCRIPT_HASH, REGISTER_CANDIDATE, Arrays.asList(ContractParameter.publicKey(pubKeyBytes))) .toArray(); Wallet w = Wallet.withAccounts(account1); TransactionBuilder b = new NeoToken(neow).registerCandidate(account1.getECKeyPair().getPublicKey()) .wallet(w) .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)); }