Skip to content

Commit

Permalink
refactor(ogmios): address mapping; handled byron address transform in…
Browse files Browse the repository at this point in the history
… projection mapper
  • Loading branch information
will-break-it committed Aug 8, 2024
1 parent baf500a commit e7cad32
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions packages/ogmios/src/ogmiosToCore/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,26 +375,8 @@ export const mapValue = (value: Schema.Value): Cardano.Value => ({
coins: value.ada.lovelace
});

const mapTxOutAddress = (address: string): Cardano.PaymentAddress => {
if (Cardano.Address.isValidByron(address)) {
const byronAddress = Cardano.Address.fromBase58(address);
const keyHashBytes = Buffer.from(byronAddress.toBytes(), 'hex');
if (keyHashBytes.length > MAX_BYRON_OUTPUT_ADDRESS_BYTES_LENGTH) {
const byronCredentialHashHex = Crypto.Hash28ByteBase16(Crypto.blake2b(28).update(keyHashBytes).digest('hex'));
return Cardano.ByronAddress.fromCredentials(
byronCredentialHashHex,
byronAddress.getProps().byronAddressContent!.attrs!,
byronAddress.getProps().byronAddressContent!.type!
)
.toAddress()
.toBase58();
}
}
return Cardano.PaymentAddress(address);
};

const mapTxOut = (txOut: Schema.TransactionOutput): Cardano.TxOut => ({
address: mapTxOutAddress(txOut.address),
address: Cardano.PaymentAddress(txOut.address),
// From ogmios v5.5.0 release notes:
// Similarly, Alonzo transaction outputs will now contain a datumHash field, carrying the datum hash digest.
// However, they will also contain a datum field with the exact same value for backward compatibility reason.
Expand Down

0 comments on commit e7cad32

Please sign in to comment.