diff --git a/ReadMe.md b/ReadMe.md index 461cf9d..d0f6392 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -32,7 +32,7 @@ Pool will be in an active state after registration is complete. **Usage:** -```./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash``` +```./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash value``` `node_address` node address in ip:port format.
`private_key` private key of the pool identity address. Private key should start with `0x`. Both 32 and 64 byte keys are accepted as an input.
@@ -40,6 +40,7 @@ Pool will be in an active state after registration is complete. `commission_rate` the pool commission rate with 4 decimal places of granularity (between [0, 1000000]).
`metadata_url` url hosting the metadata json file.
`metadata_content_hash` Blake2b hash of the json object hosted at the metadata url.
+`value` value in nAmps to pass along the transaction. This will be counted towards the self-bond value and has to be at least 1000 Aions (1000000000000000000000 nAmps).
### delegate.sh diff --git a/Tools.jar b/Tools.jar index 80299a1..7cec734 100644 Binary files a/Tools.jar and b/Tools.jar differ diff --git a/registerPool.sh b/registerPool.sh index 49efb74..151170a 100755 --- a/registerPool.sh +++ b/registerPool.sh @@ -2,7 +2,7 @@ # ----------------------------------------------------------------------------- # This script can be used to register a pool and do self bond. # -# Usage: ./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash +# Usage: ./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash value # ----------------------------------------------------------------------------- POOL_REGISTRY_ADDRESS="0xa01b68fa4f947ea4829bebdac148d1f7f8a0be9a8fd5ce33e1696932bef05356" @@ -73,10 +73,10 @@ function get_coinbase(){ fi } -if [ $# -ne 6 ] +if [ $# -ne 7 ] then echo "Invalid number of parameters." - echo "Usage: ./registerPool.sh node_address(ip:port) private_key signing_address commission_rate metadata_url metadata_content_hash" + echo "Usage: ./registerPool.sh node_address(ip:port) private_key signing_address commission_rate metadata_url metadata_content_hash value" exit 1 fi node_address="$1" @@ -85,6 +85,7 @@ signing_address="$3" commission="$4" metadata_url="$5" metadata_content_hash="$6" +amount="$7" if [ ${#private_key} == 130 ] then @@ -107,7 +108,7 @@ echo "Using nonce $NONCE" echo "Sending registration call..." # registerStaker(Address signingAddress, int commissionRate, byte[] metaDataUrl, byte[] metaDataContentHash) callPayload="$(java -cp $TOOLS_JAR cli.ComposeCallPayload "registerPool" "$signing_address" "$commission" "$metadata_url" "$metadata_content_hash")" -receipt=`./rpc.sh --call "$private_key" "$NONCE" "$POOL_REGISTRY_ADDRESS" "$callPayload" "1000000000000000000000"` +receipt=`./rpc.sh --call "$private_key" "$NONCE" "$POOL_REGISTRY_ADDRESS" "$callPayload" "$amount"` require_success $? echo "Transaction hash: \"$receipt\". Waiting for transaction to complete..." @@ -117,8 +118,9 @@ echo "Transaction completed" echo "Verifying that pool was registered and is active..." # getStake(Address pool, Address staker) callPayload="$(java -cp $TOOLS_JAR cli.ComposeCallPayload "getStake" "$identity_address" "$identity_address")" +amount_hex="$(java -cp $TOOLS_JAR cli.EncodeType "BigInteger" "$amount")" # This result in a BigInteger: 0x23 (byte), length (byte), value (big-endian length bytes) -verify_state "$POOL_REGISTRY_ADDRESS" "$callPayload" "0x23093635c9adc5dea00000" +verify_state "$POOL_REGISTRY_ADDRESS" "$callPayload" "$amount_hex" echo "Current stake = 1000 Aions" callPayload="$(java -cp $TOOLS_JAR cli.ComposeCallPayload "isActive" "$identity_address")" diff --git a/src/cli/EncodeType.java b/src/cli/EncodeType.java new file mode 100644 index 0000000..488803a --- /dev/null +++ b/src/cli/EncodeType.java @@ -0,0 +1,27 @@ +package cli; + +import net.i2p.crypto.eddsa.Utils; +import org.aion.avm.userlib.abi.ABIEncoder; + +import java.math.BigInteger; + +public class EncodeType { + public static void main(String[] args) { + if (0 == args.length) { + System.err.println("Usage: cli.EncodeType Type"); + System.exit(1); + } + + byte[] rawCallData = null; + String type = args[0]; + switch (type) { + case "BigInteger": + rawCallData = ABIEncoder.encodeOneBigInteger(new BigInteger(args[1])); + break; + default: + System.err.println("Type " + type + " is not defined."); + System.exit(1); + } + System.out.println("0x" + Utils.bytesToHex(rawCallData)); + } +}