Skip to content

Commit

Permalink
Debugging examples tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Aug 3, 2024
1 parent adb1472 commit 6a42d05
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private FlowTransactionResult waitForSeal(FlowId txID) {

private FlowAddress getAccountCreatedAddress(FlowTransactionResult txResult) {
String addressHex = (String) txResult.getEvents().get(0).getEvent().getValue().getFields()[0].getValue().getValue();
return new FlowAddress(addressHex.substring(2));
return new FlowAddress(addressHex.split("\\.")[1]);
}

private byte[] loadScript(String name) {
Expand All @@ -96,24 +96,8 @@ private byte[] loadScript(String name) {

public FlowAddress createAccount(FlowAddress payerAddress, String publicKeyHex) {

if (publicKeyHex.length() != 128) {
throw new IllegalArgumentException("Invalid ECDSA_P256 public key size: " + publicKeyHex.length() + " hex characters");
}

System.out.println("Public Key: " + publicKeyHex);

FlowAccountKey payerAccountKey = getAccountKey(payerAddress, 0);

FlowAccountKey newAccountPublicKey = new FlowAccountKey(
-1,
new FlowPublicKey(publicKeyHex),
SignatureAlgorithm.ECDSA_P256,
HashAlgorithm.SHA3_256,
1000,
-1,
false
);

FlowScript script = new FlowScript(loadScript("cadence/create_account.cdc"));

FlowTransaction tx = new FlowTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,14 @@ internal class AccessAPIConnector(privateKeyHex: String, accessApiConnection: Fl
.fields[0]
.value
.value as String
return FlowAddress(addressHex.substring(2))
return FlowAddress(addressHex.substring(2).split(".")[0])
}

private fun loadScript(name: String): ByteArray = javaClass.classLoader.getResourceAsStream(name)!!.use { it.readAllBytes() }

fun createAccount(payerAddress: FlowAddress, publicKeyHex: String): FlowAddress {
val payerAccountKey = getAccountKey(payerAddress, 0)

// val newAccountPublicKey = FlowAccountKey(
// publicKey = FlowPublicKey(publicKeyHex),
// signAlgo = SignatureAlgorithm.ECDSA_P256,
// hashAlgo = HashAlgorithm.SHA3_256,
// weight = 1000
// )

var tx = FlowTransaction(
script = FlowScript(loadScript("cadence/create_account.cdc")),
arguments = listOf(
Expand Down

0 comments on commit 6a42d05

Please sign in to comment.