cloud_functions: Fixed ambiguous packages, CoinGeckoID not required for transfers

The CoinGeckoID is overridden in the allowlist.
This commit is contained in:
Kevin Peters 2022-10-19 21:28:31 +00:00 committed by Evan Gray
parent 84507c0a04
commit e2383e257b
7 changed files with 43 additions and 1346 deletions

View File

@ -3,6 +3,7 @@ package p
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
@ -215,6 +216,9 @@ func fetchCoinGeckoCoinId(chainId vaa.ChainID, address, symbol, name string) (co
} }
func fetchCoinGeckoPrice(coinId string, timestamp time.Time) (float64, error) { func fetchCoinGeckoPrice(coinId string, timestamp time.Time) (float64, error) {
if coinId == "" {
return 0, errors.New("coinId is empty")
}
hourAgo := time.Now().Add(-time.Duration(1) * time.Hour) hourAgo := time.Now().Add(-time.Duration(1) * time.Hour)
withinLastHour := timestamp.After(hourAgo) withinLastHour := timestamp.After(hourAgo)
start, end := rangeFromTime(timestamp, 12) start, end := rangeFromTime(timestamp, 12)

View File

@ -14,4 +14,7 @@ require (
github.com/wormhole-foundation/wormhole/sdk v0.0.0-20221018051913-c289bd9f57e0 github.com/wormhole-foundation/wormhole/sdk v0.0.0-20221018051913-c289bd9f57e0
) )
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 replace (
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
)

File diff suppressed because it is too large Load Diff

View File

@ -175,34 +175,15 @@ func ProcessTransfer(ctx context.Context, m PubSubMessage) error {
var result bigtable.Row var result bigtable.Row
chainIDPrefix := fmt.Sprintf("%d", tokenChain) // create a string containing the tokenChain chainID, ie "2" chainIDPrefix := fmt.Sprintf("%d", tokenChain) // create a string containing the tokenChain chainID, ie "2"
queryErr := tbl.ReadRows(ctx, bigtable.PrefixRange(chainIDPrefix), func(row bigtable.Row) bool { queryErr := tbl.ReadRows(ctx, bigtable.PrefixRange(chainIDPrefix), func(row bigtable.Row) bool {
if _, ok := row[metaPayloadFam]; ok { result = row
for _, item := range row[metaPayloadFam] {
switch item.Column {
case "AssetMetaPayload:CoinGeckoCoinId":
CoinGeckoCoinId := string(item.Value)
if CoinGeckoCoinId != "" {
result = row
}
}
}
}
// result = row
return true return true
}, bigtable.RowFilter( }, bigtable.RowFilter(
bigtable.ConditionFilter( bigtable.ChainFilters(
bigtable.ChainFilters( bigtable.FamilyFilter(columnFamilies[3]),
bigtable.FamilyFilter(columnFamilies[3]), bigtable.ColumnFilter("TokenAddress"),
bigtable.ColumnFilter("TokenAddress"), bigtable.ValueFilter(tokenAddress),
bigtable.ValueFilter(tokenAddress), ),
), ))
bigtable.ChainFilters(
bigtable.FamilyFilter(columnFamilies[3]),
bigtable.ColumnFilter("CoinGeckoCoinId"),
bigtable.LatestNFilter(1),
),
bigtable.BlockAllFilter(),
)))
if queryErr != nil { if queryErr != nil {
log.Fatalf("failed to read rows: %v", queryErr) log.Fatalf("failed to read rows: %v", queryErr)

View File

@ -130,7 +130,7 @@ func updateTxTotalsResult(tbl *bigtable.Table, ctx context.Context, numPrevDays
} }
} }
//persistInterfaceToJson(ctx, txTotalsResultPath, &txTotalsMutex, txTotalsResult.DailyTotals) persistInterfaceToJson(ctx, txTotalsResultPath, &txTotalsMutex, txTotalsResult.DailyTotals)
} }
func ComputeTransactionTotals(w http.ResponseWriter, r *http.Request) { func ComputeTransactionTotals(w http.ResponseWriter, r *http.Request) {

View File

@ -10,6 +10,8 @@ require (
github.com/certusone/wormhole/event_database/cloud_functions v0.0.0-20220126152252-d4735fc7c1aa github.com/certusone/wormhole/event_database/cloud_functions v0.0.0-20220126152252-d4735fc7c1aa
) )
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 replace (
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0
replace github.com/certusone/wormhole/event_database/cloud_functions => ../cloud_functions github.com/certusone/wormhole/event_database/cloud_functions => ../cloud_functions
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
)

File diff suppressed because it is too large Load Diff