Skip to content

Commit

Permalink
fix aptos transfer transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyBuisset committed Sep 2, 2024
1 parent 8223303 commit 30cae3e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ public abstract class HexHash extends Hash {
private static final Pattern HEX_PATTERN = Pattern.compile("[0-9a-fA-F]+");

protected HexHash(final int maxByteCount, final @NonNull String hash) {
super(maxByteCount * 2, sanitize(hash));
this(maxByteCount, hash, true);
}

protected HexHash(final int maxByteCount, final @NonNull String hash, boolean sanitized) {
super(maxByteCount * 2, sanitized ? sanitize(hash) : hash);

if (!HEX_PATTERN.matcher(hash).matches())
throw badRequest("Provided hash is not hexadecimal");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ protected PrefixedHexHash(final int maxByteCount, final @NonNull String hash) {
this(maxByteCount, "0x", hash);
}

protected PrefixedHexHash(final int maxByteCount, final @NonNull String hash, boolean sanitized) {
this(maxByteCount, "0x", hash, sanitized);
}

protected PrefixedHexHash(final int maxByteCount, final @NonNull String prefix, final @NonNull String hash) {
super(maxByteCount, hash.substring(min(hash.length(), prefix.length())));
this(maxByteCount, prefix, hash, true);
}

protected PrefixedHexHash(final int maxByteCount, final @NonNull String prefix, final @NonNull String hash, boolean sanitized) {
super(maxByteCount, hash.substring(min(hash.length(), prefix.length())), sanitized);
this.prefix = prefix;

final var hashPrefix = hash.substring(0, prefix.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AptosCoinType extends PrefixedHexHash {
String coinType;

public AptosCoinType(final @NonNull String coinType) {
super(MAX_BYTE_COUNT, coinType.split(":")[0]);
super(MAX_BYTE_COUNT, coinType.split(":")[0], false);
this.coinType = coinType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public String recipientAddress() {

@Override
public Optional<String> contractAddress() {
return Optional.ofNullable(coinType).map(AptosCoinType::contractAddress);
return Optional.ofNullable(coinType).map(AptosCoinType::toString);
}
}

0 comments on commit 30cae3e

Please sign in to comment.