mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
38 lines
743 B
Go
38 lines
743 B
Go
package ledger
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
"github.com/formancehq/go-libs/metadata"
|
|
)
|
|
|
|
const (
|
|
formanceNamespace = "com.formance.spec/"
|
|
revertKey = "state/reverts"
|
|
|
|
MetaTargetTypeAccount = "ACCOUNT"
|
|
MetaTargetTypeTransaction = "TRANSACTION"
|
|
)
|
|
|
|
func SpecMetadata(name string) string {
|
|
return formanceNamespace + name
|
|
}
|
|
|
|
func MarkReverts(m metadata.Metadata, txID *big.Int) metadata.Metadata {
|
|
return m.Merge(RevertMetadata(txID))
|
|
}
|
|
|
|
func RevertMetadataSpecKey() string {
|
|
return SpecMetadata(revertKey)
|
|
}
|
|
|
|
func ComputeMetadata(key, value string) metadata.Metadata {
|
|
return metadata.Metadata{
|
|
key: value,
|
|
}
|
|
}
|
|
|
|
func RevertMetadata(tx *big.Int) metadata.Metadata {
|
|
return ComputeMetadata(RevertMetadataSpecKey(), tx.String())
|
|
}
|