-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/bls-public-key-validation' of github.com:ArkEcosys…
…tem/java-crypto into feat/validator-keypair-generation
- Loading branch information
Showing
23 changed files
with
518 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/arkecosystem/crypto/transactions/builder/UsernameRegistrationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.arkecosystem.crypto.transactions.builder; | ||
|
||
import org.arkecosystem.crypto.enums.Fees; | ||
import org.arkecosystem.crypto.transactions.types.Transaction; | ||
import org.arkecosystem.crypto.transactions.types.UsernameRegistration; | ||
|
||
public class UsernameRegistrationBuilder | ||
extends AbstractTransactionBuilder<UsernameRegistrationBuilder> { | ||
public UsernameRegistrationBuilder() { | ||
super(); | ||
this.transaction.fee = Fees.VALIDATOR_REGISTRATION.getValue(); | ||
} | ||
|
||
public UsernameRegistrationBuilder usernameAsset(String username) { | ||
this.transaction.asset.username = username; | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public Transaction getTransactionInstance() { | ||
return new UsernameRegistration(); | ||
} | ||
|
||
@Override | ||
public UsernameRegistrationBuilder instance() { | ||
return this; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/arkecosystem/crypto/transactions/builder/UsernameResignationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.arkecosystem.crypto.transactions.builder; | ||
|
||
import org.arkecosystem.crypto.enums.Fees; | ||
import org.arkecosystem.crypto.transactions.types.Transaction; | ||
import org.arkecosystem.crypto.transactions.types.UsernameResignation; | ||
|
||
public class UsernameResignationBuilder | ||
extends AbstractTransactionBuilder<UsernameResignationBuilder> { | ||
|
||
public UsernameResignationBuilder() { | ||
super(); | ||
this.transaction.fee = Fees.USERNAME_RESIGNATION.getValue(); | ||
} | ||
|
||
@Override | ||
public Transaction getTransactionInstance() { | ||
return new UsernameResignation(); | ||
} | ||
|
||
@Override | ||
public UsernameResignationBuilder instance() { | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/org/arkecosystem/crypto/transactions/types/UsernameRegistration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.arkecosystem.crypto.transactions.types; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
import java.util.HashMap; | ||
import org.arkecosystem.crypto.enums.CoreTransactionTypes; | ||
import org.arkecosystem.crypto.enums.TransactionTypeGroup; | ||
|
||
public class UsernameRegistration extends Transaction { | ||
@Override | ||
public int getTransactionType() { | ||
return CoreTransactionTypes.USERNAME_REGISTRATION.getValue(); | ||
} | ||
|
||
@Override | ||
public int getTransactionTypeGroup() { | ||
return TransactionTypeGroup.CORE.getValue(); | ||
} | ||
|
||
@Override | ||
public HashMap<String, Object> assetToHashMap() { | ||
HashMap<String, Object> asset = new HashMap<>(); | ||
|
||
asset.put("username", this.asset.username); | ||
|
||
return asset; | ||
} | ||
|
||
@Override | ||
public byte[] serialize() { | ||
byte[] username = this.asset.username.getBytes(); | ||
|
||
ByteBuffer buffer = ByteBuffer.allocate(username.length + 1); | ||
|
||
buffer.order(ByteOrder.LITTLE_ENDIAN); | ||
|
||
buffer.put((byte) username.length); | ||
buffer.put(username); | ||
|
||
return buffer.array(); | ||
} | ||
|
||
@Override | ||
public void deserialize(ByteBuffer buffer) { | ||
int usernameLength = buffer.get() & 0xff; | ||
|
||
byte[] username = new byte[usernameLength]; | ||
buffer.get(username); | ||
|
||
String utf8Username = new String(username); | ||
this.asset.username = utf8Username; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/org/arkecosystem/crypto/transactions/types/UsernameResignation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.arkecosystem.crypto.transactions.types; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.HashMap; | ||
import org.arkecosystem.crypto.enums.CoreTransactionTypes; | ||
import org.arkecosystem.crypto.enums.TransactionTypeGroup; | ||
|
||
public class UsernameResignation extends Transaction { | ||
@Override | ||
public int getTransactionType() { | ||
return CoreTransactionTypes.USERNAME_RESIGNATION.getValue(); | ||
} | ||
|
||
@Override | ||
public int getTransactionTypeGroup() { | ||
return TransactionTypeGroup.CORE.getValue(); | ||
} | ||
|
||
@Override | ||
public HashMap<String, Object> assetToHashMap() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public byte[] serialize() { | ||
return new byte[0]; | ||
} | ||
|
||
@Override | ||
public void deserialize(ByteBuffer buffer) {} | ||
} |
File renamed without changes.
Oops, something went wrong.