-
Notifications
You must be signed in to change notification settings - Fork 5
feat: track assets with utxos #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
Conversation
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: jkawan <kawanjenita@outlook.com>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Jenita <jkawan@blinklabs.io>
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 ?
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.
*lcommon.MultiAsset[T]
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.
The type that we're getting from d.metadata.GetUtxo()
is a models.Utxo
with an embedded []models.Asset
. We can create a duplicate Asset
type in this package and modify the duplicate Utxo
type accordingly in the short term, but we're eventually going to need to do some conversion to get it back in a lcommon.MultiAsset
. It probably makes sense to just do that here, since this PR already has a conversion function for the other direction.
Signed-off-by: Jenita <jkawan@blinklabs.io>
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
While trying to test this, I ran into an interesting issue.
This only occurs with Asset tracking. Checking the Dingo tip, we're here:
The block after d6b is bf6bdd159d595cac19ebd2b51ff4cb81b6022192372288718e528de26581ac2f which includes Tx 901d297b9c56b2e8efd273c3778c90636d62a304e4f291029dc271e1ce5f00ce which is doing some mad stuff with minting and outputs. |
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
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