Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong column size for pub key, remove generation type IDENTITY #125

Merged
merged 7 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions applications/all/src/main/resources/sql/create-index.sql
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,17 @@ CREATE INDEX if not exists idx_stake_addr_balance_policy_asset

CREATE INDEX if not exists idx_transaction_witness_tx_hash
ON transaction_witness(tx_hash);

-- metadata

CREATE INDEX if not exists idx_txn_metadata_tx_hash
ON transaction_metadata(tx_hash);

CREATE INDEX if not exists idx_txn_metadata_label
ON transaction_metadata(label);

-- scripts

CREATE INDEX if not exists idx_txn_scripts_tx_hash
ON transaction_scripts (tx_hash);

6 changes: 6 additions & 0 deletions applications/all/src/main/resources/sql/drop-index.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ drop index idx_stake_addr_balance_policy_asset;
-- transaction_witness
drop index idx_transaction_witness_tx_hash;

-- metadata
drop index idx_txn_metadata_tx_hash;
drop index idx_txn_metadata_label;

-- scripts
drop index idx_txn_scripts_tx_hash;
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ private List<Amount> sanitizeAmounts(List<Amount> amounts) {
.unit(amount.getUnit() != null ? amount.getUnit().replace(".", "") : null)
.policyId(amount.getPolicyId())
.assetName(amount.getAssetName().replace('\u0000', ' '))
.assetNameBytes(amount.getAssetNameBytes())
.quantity(amount.getQuantity())
.build()).collect(Collectors.toList());
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[libraries]
yaci = "com.bloxbean.cardano:yaci:0.3.0-beta4"
yaci = "com.bloxbean.cardano:yaci:0.3.0-beta5"
cardano-client-lib = "com.bloxbean.cardano:cardano-client-lib:0.5.0"
cardano-client-backend = "com.bloxbean.cardano:cardano-client-backend:0.5.0"
cardano-client-backend-ogmios = "com.bloxbean.cardano:cardano-client-backend-ogmios:0.5.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.bloxbean.cardano.yaci.store.assets.processor;

import com.bloxbean.cardano.client.api.util.AssetUtil;
import com.bloxbean.cardano.client.transaction.spec.Asset;
import com.bloxbean.cardano.client.util.HexUtil;
import com.bloxbean.cardano.yaci.store.assets.domain.MintType;
import com.bloxbean.cardano.yaci.store.assets.domain.TxAsset;
import com.bloxbean.cardano.yaci.store.assets.domain.TxAssetEvent;
Expand Down Expand Up @@ -41,7 +41,7 @@ public void handleAssetMintBurn(MintBurnEvent mintBurnEvent) {
.policy(amount.getPolicyId())
.assetName(amount.getAssetName())
.unit(amount.getUnit())
.fingerprint(getFingerprint(amount.getPolicyId(), amount.getAssetName()))
.fingerprint(getFingerprint(amount.getPolicyId(), amount.getAssetNameBytes()))
.quantity(amount.getQuantity())
.mintType(amount.getQuantity().compareTo(BigInteger.ZERO) == 1? MintType.MINT : MintType.BURN)
.blockNumber(eventMetadata.getBlock())
Expand All @@ -59,11 +59,11 @@ public void handleAssetMintBurn(MintBurnEvent mintBurnEvent) {
}
}

private String getFingerprint(String policyId, String assetName) {
private String getFingerprint(String policyId, byte[] assetNameBytes) {
try {
return AssetUtil.calculateFingerPrint(policyId, new Asset(assetName, BigInteger.ZERO).getNameAsHex());
return AssetUtil.calculateFingerPrint(policyId, HexUtil.encodeHexString(assetNameBytes));
} catch (Exception e) {
log.error("Error calculating fingerprint for policy: " + policyId + ", asset: " + assetName, e);
log.error("Error calculating fingerprint for policy: " + policyId + ", asset (hex): " + HexUtil.encodeHexString(assetNameBytes), e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.experimental.SuperBuilder;

import java.math.BigInteger;
import java.util.UUID;

@Data
@NoArgsConstructor
Expand All @@ -17,10 +18,10 @@
@Entity
@Table(name = "assets")
public class TxAssetEntity extends BlockAwareEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id")
private Long id;
@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "id", updatable = false, nullable = false)
private UUID id;

@Column(name = "slot")
private Long slot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
drop table if exists assets;
create table assets
(
id bigint not null auto_increment
primary key,
id uuid not null primary key,
slot bigint,
tx_hash varchar(64) not null,
policy varchar(56),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
drop table if exists assets;
create table assets
(
id bigint not null auto_increment
primary key,
id binary(16) not null primary key,
slot bigint,
tx_hash varchar(64) not null,
policy varchar(56),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
drop table if exists assets;
create table assets
(
id bigint not null
primary key generated ALWAYS AS IDENTITY,
id uuid not null primary key,
slot bigint,
tx_hash varchar(64) not null,
policy varchar(56),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private List<TxMintBurn> txMintBurns() {
.unit("34250edd1e9836f5378702fbf9416b709bc140e04f668cc3552085184154414441636f696e")
.policyId("34250edd1e9836f5378702fbf9416b709bc140e04f668cc355208518")
.assetName("ATADAcoin")
.assetNameBytes("ATADAcoin".getBytes())
.quantity(BigInteger.valueOf(1))
.build()))
.build();
Expand All @@ -150,6 +151,7 @@ private List<TxMintBurn> txMintBurns() {
.unit("3bc07438218b280dc651d825bd0e3276fc01e9faf73f0bda13c083276474734e4654")
.policyId("3bc07438218b280dc651d825bd0e3276fc01e9faf73f0bda13c08327")
.assetName("dtsNFT")
.assetNameBytes("dtsNFT".getBytes())
.quantity(BigInteger.valueOf(0))
.build()))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class AssetRollbackProcessorIT {
})
void givenRollbackEvent_shouldDeleteAssets() throws Exception {
RollbackEvent rollbackEvent = RollbackEvent.builder()
.rollbackTo(new Point(10725319, "5068285d5eccc63bbfe0caa446fde9c28d77e45b6f34d37c29bbae8d47c30b9b"))
.currentPoint(new Point(10725426, "5ca2e98fe743c4dc92b323a6cd244825e663aa1e35fd3123487c8c0a170196e2"))
.rollbackTo(new Point(10702061, "5068285d5eccc63bbfe0caa446fde9c28d77e45b6f34d37c29bbae8d47c30b9b"))
.currentPoint(new Point(10707861, "5ca2e98fe743c4dc92b323a6cd244825e663aa1e35fd3123487c8c0a170196e2"))
.build();

assetRollbackProcessor.handleRollbackEvent(rollbackEvent);

int count = txAssetRepository.findAll().size();
assertThat(count).isEqualTo(14);
assertThat(count).isEqualTo(4);
}
}
Loading