BigTable: include TransferDetails in summary
Change-Id: I40cb428ad64fada511fe6eebe001d69392cd392f commit-id:0134b970
This commit is contained in:
parent
ccb7f04ac2
commit
df8c291db5
|
@ -84,13 +84,14 @@ var chainDetailsFam = columnFamilies[6]
|
||||||
type (
|
type (
|
||||||
// Summary is MessagePublication data & QuorumState data
|
// Summary is MessagePublication data & QuorumState data
|
||||||
Summary struct {
|
Summary struct {
|
||||||
EmitterChain string
|
EmitterChain string
|
||||||
EmitterAddress string
|
EmitterAddress string
|
||||||
Sequence string
|
Sequence string
|
||||||
InitiatingTxID string
|
InitiatingTxID string
|
||||||
Payload []byte
|
Payload []byte
|
||||||
SignedVAABytes []byte
|
SignedVAABytes []byte
|
||||||
QuorumTime string
|
QuorumTime string
|
||||||
|
TransferDetails *TransferDetails
|
||||||
}
|
}
|
||||||
// Details is a Summary extended with all the post-processing ColumnFamilies
|
// Details is a Summary extended with all the post-processing ColumnFamilies
|
||||||
Details struct {
|
Details struct {
|
||||||
|
@ -99,7 +100,6 @@ type (
|
||||||
TokenTransferPayload *TokenTransferPayload
|
TokenTransferPayload *TokenTransferPayload
|
||||||
AssetMetaPayload *AssetMetaPayload
|
AssetMetaPayload *AssetMetaPayload
|
||||||
NFTTransferPayload *NFTTransferPayload
|
NFTTransferPayload *NFTTransferPayload
|
||||||
TransferDetails *TransferDetails
|
|
||||||
ChainDetails *ChainDetails
|
ChainDetails *ChainDetails
|
||||||
}
|
}
|
||||||
// The following structs match the ColumnFamiles they are named after
|
// The following structs match the ColumnFamiles they are named after
|
||||||
|
@ -111,11 +111,13 @@ type (
|
||||||
TargetChain string
|
TargetChain string
|
||||||
}
|
}
|
||||||
AssetMetaPayload struct {
|
AssetMetaPayload struct {
|
||||||
TokenAddress string
|
TokenAddress string
|
||||||
TokenChain string
|
TokenChain string
|
||||||
Decimals string
|
Decimals string
|
||||||
Symbol string
|
Symbol string
|
||||||
Name string
|
Name string
|
||||||
|
CoinGeckoCoinId string
|
||||||
|
NativeAddress string
|
||||||
}
|
}
|
||||||
NFTTransferPayload struct {
|
NFTTransferPayload struct {
|
||||||
OriginAddress string
|
OriginAddress string
|
||||||
|
@ -198,6 +200,30 @@ func makeSummary(row bigtable.Row) *Summary {
|
||||||
summary.SignedVAABytes = item.Value
|
summary.SignedVAABytes = item.Value
|
||||||
summary.QuorumTime = item.Timestamp.Time().String()
|
summary.QuorumTime = item.Timestamp.Time().String()
|
||||||
}
|
}
|
||||||
|
if _, ok := row[transferDetailsFam]; ok {
|
||||||
|
transferDetails := &TransferDetails{}
|
||||||
|
for _, item := range row[transferDetailsFam] {
|
||||||
|
switch item.Column {
|
||||||
|
case "TokenTransferDetails:Amount":
|
||||||
|
transferDetails.Amount = string(item.Value)
|
||||||
|
case "TokenTransferDetails:Decimals":
|
||||||
|
transferDetails.Decimals = string(item.Value)
|
||||||
|
case "TokenTransferDetails:NotionalUSDStr":
|
||||||
|
transferDetails.NotionalUSDStr = string(item.Value)
|
||||||
|
case "TokenTransferDetails:TokenPriceUSDStr":
|
||||||
|
transferDetails.TokenPriceUSDStr = string(item.Value)
|
||||||
|
case "TokenTransferDetails:TransferTimestamp":
|
||||||
|
transferDetails.TransferTimestamp = string(item.Value)
|
||||||
|
case "TokenTransferDetails:OriginSymbol":
|
||||||
|
transferDetails.OriginSymbol = string(item.Value)
|
||||||
|
case "TokenTransferDetails:OriginName":
|
||||||
|
transferDetails.OriginName = string(item.Value)
|
||||||
|
case "TokenTransferDetails:OriginTokenAddress":
|
||||||
|
transferDetails.OriginTokenAddress = string(item.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
summary.TransferDetails = transferDetails
|
||||||
|
}
|
||||||
return summary
|
return summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +276,10 @@ func makeDetails(row bigtable.Row) *Details {
|
||||||
assetMetaPayload.Symbol = string(item.Value)
|
assetMetaPayload.Symbol = string(item.Value)
|
||||||
case "AssetMetaPayload:Name":
|
case "AssetMetaPayload:Name":
|
||||||
assetMetaPayload.Name = string(item.Value)
|
assetMetaPayload.Name = string(item.Value)
|
||||||
|
case "AssetMetaPayload:CoinGeckoCoinId":
|
||||||
|
assetMetaPayload.CoinGeckoCoinId = string(item.Value)
|
||||||
|
case "AssetMetaPayload:NativeAddress":
|
||||||
|
assetMetaPayload.NativeAddress = string(item.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deets.AssetMetaPayload = assetMetaPayload
|
deets.AssetMetaPayload = assetMetaPayload
|
||||||
|
@ -278,50 +308,29 @@ func makeDetails(row bigtable.Row) *Details {
|
||||||
}
|
}
|
||||||
deets.NFTTransferPayload = nftTransferPayload
|
deets.NFTTransferPayload = nftTransferPayload
|
||||||
}
|
}
|
||||||
if _, ok := row[transferDetailsFam]; ok {
|
// NotionalUSD and TokenPriceUSD are more percise than the string versions returned,
|
||||||
transferDetails := &TransferDetails{}
|
// however the precision is not required, so leaving this commented out for now.
|
||||||
for _, item := range row[transferDetailsFam] {
|
// if _, ok := row[transferDetailsFam]; ok {
|
||||||
switch item.Column {
|
// for _, item := range row[transferDetailsFam] {
|
||||||
case "TokenTransferDetails:Amount":
|
// switch item.Column {
|
||||||
transferDetails.Amount = string(item.Value)
|
// case "TokenTransferDetails:NotionalUSD":
|
||||||
case "TokenTransferDetails:Decimals":
|
// reader := bytes.NewReader(item.Value)
|
||||||
transferDetails.Decimals = string(item.Value)
|
// var notionalUSD uint64
|
||||||
case "TokenTransferDetails:NotionalUSDStr":
|
// if err := binary.Read(reader, binary.BigEndian, ¬ionalUSD); err != nil {
|
||||||
transferDetails.NotionalUSDStr = string(item.Value)
|
// log.Fatalf("failed to read NotionalUSD of row: %v. err %v ", row.Key(), err)
|
||||||
case "TokenTransferDetails:TokenPriceUSDStr":
|
// }
|
||||||
transferDetails.TokenPriceUSDStr = string(item.Value)
|
// deets.TransferDetails.NotionalUSD = notionalUSD
|
||||||
case "TokenTransferDetails:TransferTimestamp":
|
|
||||||
transferDetails.TransferTimestamp = string(item.Value)
|
|
||||||
case "TokenTransferDetails:OriginSymbol":
|
|
||||||
transferDetails.OriginSymbol = string(item.Value)
|
|
||||||
case "TokenTransferDetails:OriginName":
|
|
||||||
transferDetails.OriginName = string(item.Value)
|
|
||||||
case "TokenTransferDetails:OriginTokenAddress":
|
|
||||||
transferDetails.OriginTokenAddress = string(item.Value)
|
|
||||||
|
|
||||||
// NotionalUSD and TokenPriceUSD are more percise than the string versions returned,
|
// case "TokenTransferDetails:TokenPriceUSD":
|
||||||
// however the precision is not required, so leaving this commented out for now.
|
// reader := bytes.NewReader(item.Value)
|
||||||
|
// var tokenPriceUSD uint64
|
||||||
// case "TokenTransferDetails:NotionalUSD":
|
// if err := binary.Read(reader, binary.BigEndian, &tokenPriceUSD); err != nil {
|
||||||
// reader := bytes.NewReader(item.Value)
|
// log.Fatalf("failed to read TokenPriceUSD of row: %v. err %v", row.Key(), err)
|
||||||
// var notionalUSD uint64
|
// }
|
||||||
// if err := binary.Read(reader, binary.BigEndian, ¬ionalUSD); err != nil {
|
// deets.TransferDetails.TokenPriceUSD = tokenPriceUSD
|
||||||
// log.Fatalf("failed to read NotionalUSD of row: %v. err %v ", row.Key(), err)
|
// }
|
||||||
// }
|
// }
|
||||||
// transferDetails.NotionalUSD = notionalUSD
|
// }
|
||||||
|
|
||||||
// case "TokenTransferDetails:TokenPriceUSD":
|
|
||||||
// reader := bytes.NewReader(item.Value)
|
|
||||||
// var tokenPriceUSD uint64
|
|
||||||
// if err := binary.Read(reader, binary.BigEndian, &tokenPriceUSD); err != nil {
|
|
||||||
// log.Fatalf("failed to read TokenPriceUSD of row: %v. err %v", row.Key(), err)
|
|
||||||
// }
|
|
||||||
// transferDetails.NotionalUSD = tokenPriceUSD
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deets.TransferDetails = transferDetails
|
|
||||||
}
|
|
||||||
if _, ok := row[chainDetailsFam]; ok {
|
if _, ok := row[chainDetailsFam]; ok {
|
||||||
chainDetails := &ChainDetails{}
|
chainDetails := &ChainDetails{}
|
||||||
for _, item := range row[chainDetailsFam] {
|
for _, item := range row[chainDetailsFam] {
|
||||||
|
|
Loading…
Reference in New Issue