Skip to content

Commit

Permalink
separate use of Address interface vs AionAddress implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandraRoatis committed Jan 23, 2019
1 parent dce388b commit d376d56
Show file tree
Hide file tree
Showing 39 changed files with 359 additions and 337 deletions.
10 changes: 5 additions & 5 deletions src/org/aion/api/IAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.List;
import org.aion.api.type.ApiMsg;
import org.aion.base.type.AionAddress;
import org.aion.base.type.Hash256;
import org.aion.vm.api.interfaces.Address;

/**
* This interface dedicate to contact with Aion kernel for certain purpose.
Expand Down Expand Up @@ -134,13 +134,13 @@ public interface IAdmin {
* Get detailed account information, given a string of addresses.
*
* @param addresses list of addresses
* @return the interface {@link java.util.List List} of the class {@link
* AionAddress Address} wrapped into ApiMsg. You can retrieve through the
* method {@link ApiMsg#getObject() getObject}.
* @return the interface {@link java.util.List List} of the class {@link Address Address}
* wrapped into ApiMsg. You can retrieve through the method {@link ApiMsg#getObject()
* getObject}.
* <p>The kernel will only return the first 1000 account details that fit the query
* interval.
*/
ApiMsg getAccountDetailsByAddressList(List<AionAddress> addresses);
ApiMsg getAccountDetailsByAddressList(List<Address> addresses);

/// **
// * Retrieves system information including DB size. CPU & Memory usage
Expand Down
26 changes: 13 additions & 13 deletions src/org/aion/api/IChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.aion.api.type.ApiMsg;
import org.aion.api.type.Block;
import org.aion.api.type.Transaction;
import org.aion.base.type.AionAddress;
import org.aion.base.type.Hash256;
import org.aion.vm.api.interfaces.Address;

/**
* This interface provides methods for fetching blockchain specific details such as blocks and
Expand All @@ -27,34 +27,34 @@ public interface IChain {
* GetBalance returns a BigInteger representing the balance of the account address at latest
* block number.
*
* @param address the class {@link AionAddress Address} of the desired account to get the balance
* @param address the class {@link Address Address} of the desired account to get the balance
* of.
* @return balance of the desired account by the class {@link BigInteger BigInteger} wrapped
* into ApiMsg. You can retrieve through the method {@link ApiMsg#getObject() getObject}.
*/
ApiMsg getBalance(AionAddress address);
ApiMsg getBalance(Address address);

/**
* GetBalance returns a Long value representing the balance of the account address at a certain
* block number.
*
* @param address the class {@link AionAddress Address} of the desired account.
* @param address the class {@link Address Address} of the desired account.
* @param blockNumber the block number by long value at which the balance of the address should
* be retrieved from.
* @return balance of the desired account by the class {@link BigInteger BigInteger} wrapped
* into ApiMsg. You can retrieve through the method {@link ApiMsg#getObject() getObject}.
*/
ApiMsg getBalance(AionAddress address, long blockNumber);
ApiMsg getBalance(Address address, long blockNumber);

/**
* GetNonce returns a BigInteger representing the nonce of the account address at the latest
* block number.
*
* @param address the class {@link AionAddress Address} of the desired account to get the nonce of.
* @param address the class {@link Address Address} of the desired account to get the nonce of.
* @return nonce of the desired account by the class {@link BigInteger BigInteger} wrapped into
* ApiMsg. You can retrieve through the method {@link ApiMsg#getObject() getObject}.
*/
ApiMsg getNonce(AionAddress address);
ApiMsg getNonce(Address address);

/**
* Gets the block corresponding to the block number.
Expand Down Expand Up @@ -121,12 +121,12 @@ public interface IChain {
* Retrieves the total transactions committed by a certain account address at a given block
* number.
*
* @param address the class {@link AionAddress Address} of the desired account.
* @param address the class {@link Address Address} of the desired account.
* @param blockNumber the block number by long value of the desired block.
* @return the transaction number of the block by long value wrapped into ApiMsg. You can
* retrieve through the method {@link ApiMsg#getObject() getObject}.
*/
ApiMsg getTransactionCount(AionAddress address, long blockNumber);
ApiMsg getTransactionCount(Address address, long blockNumber);

/**
* Retrieves the transaction given the transaction hash. Function will throw if transaction is
Expand All @@ -143,27 +143,27 @@ public interface IChain {
/**
* Get the storage at a specific position of an address by current blockchain database status.
*
* @param address the class {@link AionAddress Address} of the desired address to get the storage
* @param address the class {@link Address Address} of the desired address to get the storage
* from.
* @param position the index position of the storage.
* @return the class {@link java.lang.String String} represent the hexString of the byte array
* wrapped into ApiMsg.
*/
ApiMsg getStorageAt(AionAddress address, int position);
ApiMsg getStorageAt(Address address, int position);

/**
* Get the storage at a specific position of an address by giving blockNumber; Current kernel
* version doesn't support the query status by giving blockNumber. please use
* getStorageAt(Address address, int position) or giving the blockNumber = -1L.
*
* @param address the class {@link AionAddress Address} of the desired address to get the storage
* @param address the class {@link Address Address} of the desired address to get the storage
* from.
* @param position the index position of the storage.
* @param blockNumber the block number by long value of the desired block.
* @return the class {@link java.lang.String String} represent the hexString of the byte array
* wrapped into ApiMsg.
*/
ApiMsg getStorageAt(AionAddress address, int position, long blockNumber);
ApiMsg getStorageAt(Address address, int position, long blockNumber);

/// **
// * Returns the current miner hashrate.
Expand Down
14 changes: 7 additions & 7 deletions src/org/aion/api/IContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.aion.api.type.ContractResponse;
import org.aion.api.type.JsonFmt;
import org.aion.api.type.TxArgs;
import org.aion.base.type.AionAddress;
import org.aion.base.type.Hash256;
import org.aion.base.util.ByteArrayWrapper;
import org.aion.vm.api.interfaces.Address;

/**
* A Contract class that sits above the Aion Java API layer that provides the user with convenient
Expand Down Expand Up @@ -120,10 +120,10 @@ public interface IContract {
/**
* Sets the message sender address for function be executed.
*
* @param address the class {@link AionAddress Address} represent the desired sender account.
* @param address the class {@link Address Address} represent the desired sender account.
* @return the contract interface {@link IContract IContract}.
*/
IContract setFrom(AionAddress address);
IContract setFrom(Address address);

/**
* Sets the transaction value for certain functions.
Expand Down Expand Up @@ -169,16 +169,16 @@ public interface IContract {
/**
* Retrieve the current sender's account address of the contract.
*
* @return the class {@link AionAddress Address} represent the sender's account address.
* @return the class {@link Address Address} represent the sender's account address.
*/
AionAddress getFrom();
Address getFrom();

/**
* Retrieve the address of the deployed contract.
*
* @return the class {@link AionAddress Address} represent the contractaddress.
* @return the class {@link Address Address} represent the contractaddress.
*/
AionAddress getContractAddress();
Address getContractAddress();

/**
* Retrieve the transaction hash of the deployed contract.
Expand Down
40 changes: 20 additions & 20 deletions src/org/aion/api/IContractController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Map;
import org.aion.api.sol.ISolidityArg;
import org.aion.api.type.ApiMsg;
import org.aion.base.type.AionAddress;
import org.aion.vm.api.interfaces.Address;

/**
* This interface provides methods for deploy the contract to the Aion blockchain network, store the
Expand All @@ -20,7 +20,7 @@ public interface IContractController {
*
* @param source the class {@link String String} represent the contract source code. It could be
* multiple contracts.
* @param from the class {@link AionAddress Address} represent the sender or the contract owner whom
* @param from the class {@link Address Address} represent the sender or the contract owner whom
* deploy the contract.
* @param nrgLimit the long value represent the maximum energy consume during this contract
* deploy been allowed. if the contract consume energy more than this number. the deploy
Expand All @@ -35,14 +35,14 @@ public interface IContractController {
* <p>A multi-contract source, set key value pair when you want to deploy the contract "key"
* with initial parameters "value"
*/
ApiMsg createFromSource(String source, AionAddress from, long nrgLimit, long nrgPrice);
ApiMsg createFromSource(String source, Address from, long nrgLimit, long nrgPrice);

/**
* Multiple contract create methods for deploy contracts on the Aion network.
*
* @param source the class {@link String String} represent the contract source code. It could be
* multiple contracts.
* @param from the class {@link AionAddress Address} represent the sender or the contract owner whom
* @param from the class {@link Address Address} represent the sender or the contract owner whom
* deploy the contract.
* @param nrgLimit the long value represent the maximum energy consume during this contract
* deploy been allowed. if the contract consume energy more than this number. the deploy
Expand All @@ -60,14 +60,14 @@ public interface IContractController {
* with initial parameters "value"
*/
ApiMsg createFromSource(
String source, AionAddress from, long nrgLimit, long nrgPrice, BigInteger value);
String source, Address from, long nrgLimit, long nrgPrice, BigInteger value);

/**
* contract create method for deploy a contract with initial arguments on the Aion network.
*
* @param source the class {@link String String} represent the contract source code. It could be
* multiple contracts.
* @param from the class {@link AionAddress Address} represent the sender or the contract owner whom
* @param from the class {@link Address Address} represent the sender or the contract owner whom
* deploy the contract.
* @param nrgLimit the long value represent the maximum energy consume during this contract
* deploy been allowed. if the contract consume energy more than this number. the deploy
Expand All @@ -86,14 +86,14 @@ ApiMsg createFromSource(
* with initial parameters "value"
*/
ApiMsg createFromSource(
String source, AionAddress from, long nrgLimit, long nrgPrice, List<ISolidityArg> params);
String source, Address from, long nrgLimit, long nrgPrice, List<ISolidityArg> params);

/**
* contract create method for deploy contracts with initial arguments on the Aion network.
*
* @param source the class {@link String String} represent the contract source code. It could be
* multiple contracts.
* @param from the class {@link AionAddress Address} represent the sender or the contract owner whom
* @param from the class {@link Address Address} represent the sender or the contract owner whom
* deploy the contract.
* @param nrgLimit the long value represent the maximum energy consume during this contract
* deploy been allowed. if the contract consume energy more than this number. the deploy
Expand All @@ -111,7 +111,7 @@ ApiMsg createFromSource(
*/
ApiMsg createFromSource(
String source,
AionAddress from,
Address from,
long nrgLimit,
long nrgPrice,
Map<String, List<ISolidityArg>> params);
Expand All @@ -121,7 +121,7 @@ ApiMsg createFromSource(
*
* @param source the class {@link String String} represent the contract source code. It could be
* multiple contracts.
* @param from the class {@link AionAddress Address} represent the sender or the contract owner whom
* @param from the class {@link Address Address} represent the sender or the contract owner whom
* deploy the contract.
* @param nrgLimit the long value represent the maximum energy consume during this contract
* deploy been allowed. if the contract consume energy more than this number. the deploy
Expand All @@ -143,7 +143,7 @@ ApiMsg createFromSource(
*/
ApiMsg createFromSource(
String source,
AionAddress from,
Address from,
long nrgLimit,
long nrgPrice,
BigInteger value,
Expand All @@ -154,7 +154,7 @@ ApiMsg createFromSource(
*
* @param source the class {@link String String} represent the contract source code. It could be
* multiple contracts.
* @param from the class {@link AionAddress Address} represent the sender or the contract owner whom
* @param from the class {@link Address Address} represent the sender or the contract owner whom
* deploy the contract.
* @param nrgLimit the long value represent the maximum energy consume during this contract
* deploy been allowed. if the contract consume energy more than this number. the deploy
Expand All @@ -176,7 +176,7 @@ ApiMsg createFromSource(
*/
ApiMsg createFromSource(
String source,
AionAddress from,
Address from,
long nrgLimit,
long nrgPrice,
BigInteger value,
Expand All @@ -186,26 +186,26 @@ ApiMsg createFromSource(
* create a contract object by given the sender, the deployed contract address on the Aion
* network, and the solidity abi definition for the contract. And store into the controller.
*
* @param from the class {@link AionAddress Address} represent the sender whom want to interact with
* @param from the class {@link Address Address} represent the sender whom want to interact with
* the contract.
* @param contract the class {@link AionAddress Address} represent the contract address.
* @param contract the class {@link Address Address} represent the contract address.
* @param abi the class {@link String String} represent the contract Abi definition.
* @return the class {@link IContract IContract} represent the contract been created in the
* contractController. The created contract object will been store inside the Controller and
* user can retrieve it by given the contract address.
* @see IContractController#getContract
*/
IContract getContractAt(AionAddress from, AionAddress contract, String abi);
IContract getContractAt(Address from, Address contract, String abi);

/**
* retrieve the contract by given the contract address.
*
* @param contractAddr the class {@link AionAddress Address} represent the contract address.
* @param contractAddr the class {@link Address Address} represent the contract address.
* @return the class {@link IContract IContract} represent the contract been stored inside the
* contractController.
* @see IContractController#getContract
*/
IContract getContract(AionAddress contractAddr);
IContract getContract(Address contractAddr);

/**
* retrieve the contractList by given the contract name.
Expand All @@ -232,11 +232,11 @@ ApiMsg createFromSource(
* retrieve all of the pair of the contract address and the contract name inside the
* ContractController.
*
* @return the interface {@link Map Map} of the key of the Class {@link AionAddress Address} and the
* @return the interface {@link Map Map} of the key of the Class {@link Address Address} and the
* value of the class {@link String String} represent the contract address and the contract
* name.
*/
Map<AionAddress, String> getContractMap();
Map<Address, String> getContractMap();

/**
* remove contract by given the contract object from ContractController.
Expand Down
18 changes: 9 additions & 9 deletions src/org/aion/api/ITx.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import org.aion.api.type.MsgRsp;
import org.aion.api.type.TxArgs;
import org.aion.api.type.TxReceipt;
import org.aion.base.type.AionAddress;
import org.aion.base.type.Hash256;
import org.aion.base.util.ByteArrayWrapper;
import org.aion.vm.api.interfaces.Address;

/**
* ITx is an interface of the class Transaction. ITx assists in providing methods for transaction
Expand Down Expand Up @@ -148,22 +148,22 @@ public interface ITx {
/**
* Retrieves the compiled code for a given contract with checking latest block.
*
* @param address the class {@link AionAddress Address} represent the deployed contract address.
* @param address the class {@link Address Address} represent the deployed contract address.
* @return the variable bytes array of the compiled code wrapped into ApiMsg. You can retrieve
* through {@link ApiMsg#getObject() getObject}.
*/
ApiMsg getCode(AionAddress address);
ApiMsg getCode(Address address);

/**
* Retrieves the compiled code for a given contract.
*
* @param address the class {@link AionAddress Address} represent the deployed contract address.
* @param address the class {@link Address Address} represent the deployed contract address.
* @param blockNumber block number of which the contract by long value was committed on.
* Indicate -1L to check for the latest block.
* @return the variable bytes array of the compiled code wrapped into ApiMsg. You can retrieve
* through {@link ApiMsg#getObject() getObject}.
*/
ApiMsg getCode(AionAddress address, long blockNumber);
ApiMsg getCode(Address address, long blockNumber);

/**
* Pre-build {@link TxArgs TxArgs} for increasing sendTransaction speeds if these transaction
Expand Down Expand Up @@ -235,10 +235,10 @@ public interface ITx {
*
* @param evt the interface {@link List List} of the class {@link String String} represent the
* events the user want to listen.
* @param address the class {@link AionAddress Address} represent the deployed contract address.
* @param address the class {@link Address Address} represent the deployed contract address.
* @return the boolean value represent the register success or failed.
*/
ApiMsg eventDeregister(List<String> evt, AionAddress address);
ApiMsg eventDeregister(List<String> evt, Address address);

/**
* register the events the user want to listen by given the event name, event filter and the
Expand All @@ -248,10 +248,10 @@ public interface ITx {
* events the user want to listen.
* @param ef the class {@link ContractEventFilter ContractEventFilter} represent the event query
* conditions.
* @param address the class {@link AionAddress Address} represent the deployed contract address.
* @param address the class {@link Address Address} represent the deployed contract address.
* @return the boolean value represent the register success or failed.
*/
ApiMsg eventRegister(List<String> evt, ContractEventFilter ef, AionAddress address);
ApiMsg eventRegister(List<String> evt, ContractEventFilter ef, Address address);

/**
* getNrgPrice returns a Long value representing the recommended energy price.
Expand Down
Loading

0 comments on commit d376d56

Please sign in to comment.