Skip to content

Commit

Permalink
Simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
spoto committed Nov 24, 2023
1 parent b6973cd commit 7540fc0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@ public StorageReference tendermintValidatorPaidByFaucet(PublicKey publicKey,
var gamete = (StorageReference) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
(manifest, _100_000, takamakaCode, CodeSignature.GET_GAMETE, manifest));

BigInteger gas = gasForCreatingAccountWithSignature(SignatureAlgorithms.ed25519());
var ed25519 = SignatureAlgorithms.ed25519();
BigInteger gas = gasForCreatingAccountWithSignature(ed25519);

// we use an empty signature algorithm and an arbitrary key, since the faucet is unsigned
SignatureAlgorithm signatureForFaucet = SignatureAlgorithms.empty();
KeyPair keyPair = signatureForFaucet.getKeyPair();
var signer = signatureForFaucet.getSigner(keyPair.getPrivate(), SignedTransactionRequest::toByteArrayWithoutSignature);
String publicKeyEncoded = Base64.getEncoder().encodeToString(SignatureAlgorithms.ed25519().encodingOf(publicKey)); // TODO: why ed25519?
String publicKeyEncoded = Base64.getEncoder().encodeToString(ed25519.encodingOf(publicKey)); // Tendermint uses ed25519 only
var request = new InstanceMethodCallTransactionRequest
(signer, gamete, nonceHelper.getNonceOf(gamete),
chainId, gas, gasHelper.getGasPrice(), takamakaCode,
Expand All @@ -236,14 +237,15 @@ public StorageReference tendermintValidatorPaidBy(StorageReference payer, KeyPai

var signatureForPayer = SignatureHelpers.of(node).signatureAlgorithmFor(payer);

BigInteger gas1 = gasForCreatingAccountWithSignature(SignatureAlgorithms.ed25519());
var ed25519 = SignatureAlgorithms.ed25519();
BigInteger gas1 = gasForCreatingAccountWithSignature(ed25519);
BigInteger gas2 = gasForTransactionWhosePayerHasSignature(signatureForPayer.getName());
BigInteger totalGas = balanceRed.signum() > 0 ? gas1.add(gas2).add(gas2) : gas1.add(gas2);

gasHandler.accept(totalGas);

var signer = signatureForPayer.getSigner(keysOfPayer.getPrivate(), SignedTransactionRequest::toByteArrayWithoutSignature);
String publicKeyEncoded = Base64.getEncoder().encodeToString(SignatureAlgorithms.ed25519().encodingOf(publicKey)); // TODO: why ed25519?
String publicKeyEncoded = Base64.getEncoder().encodeToString(ed25519.encodingOf(publicKey)); // Tendermint uses ed25519 only
var request1 = new ConstructorCallTransactionRequest
(signer, payer, nonceHelper.getNonceOf(payer),
chainId, gas1.add(gas2), gasHelper.getGasPrice(), takamakaCode,
Expand Down

0 comments on commit 7540fc0

Please sign in to comment.