Skip to content

Conversation

jkawan
Copy link
Contributor

@jkawan jkawan commented Sep 1, 2025

  1. Create Assets table and related get and set functions
  2. Added Assets to Utxo table

For the fields in Assets table, took reference from this : https://github.com/Andamio-Platform/andamio-indexer/blob/master/database/plugin/metadata/sqlite/models/asset.go

Closes #339

@jkawan jkawan requested a review from a team as a code owner September 1, 2025 22:18
@jkawan jkawan changed the title Added changes to add Assets to Utxo table to track coin amount Added changes to add Assets to Utxo table to track assets Sep 1, 2025
Copy link
Member

@wolf31o2 wolf31o2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the right direction. Since Asset is always connected to Utxo, they should be saved along with Utxo and returned with them.


// GetAssetsByUTxO returns all assets for a given UTxO
func (d *MetadataStoreSqlite) GetAssetsByUTxO(
utxoId uint,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being unclear previously. Getting Assets by UTxO should use the reference, the combination of txId []byte and idx uint32 which we can look up the Utxo using the compound index.

}

// SetAsset saves an asset into the database
func (d *MetadataStoreSqlite) SetAsset(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove write functionality here. The only way to create/update/delete an asset is via a transaction and a UTxO. You should move handling of the assets to the Utxo functions.

payment []byte, // payment
stake []byte, // stake
amount uint64, // amount
asset *lcommon.MultiAsset[lcommon.MultiAssetTypeOutput], // asset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be assets (it's multi-asset, so multiple). Add them to tmpUtxo.Assets before saving tmpUtxo if it's not nil.

return tmpUtxo, err
}
tmpUtxo = Utxo(utxo)
tmpUtxo = Utxo{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add assets to the Utxo struct above so this doesn't need to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wolf31o2 what should be the type for assets in Utxo struct here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Track coin amount and assets for UTxOs
2 participants