-
Notifications
You must be signed in to change notification settings - Fork 5
Added changes to add Assets to Utxo table to track assets #889
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: jkawan <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
There was a problem hiding this 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, |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
Signed-off-by: Jenita <[email protected]>
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