Add support for Oasis and Algorand in the `tx-tracker` service (#455)
### Description This pull request adds support for Oasis and Algorand in the `tx-tracker` service. With this change, the sender addresses for those chains will become available in the UI.
This commit is contained in:
parent
35b7d7b46b
commit
eae49e2e9c
|
@ -7,6 +7,9 @@ RESOURCES_LIMITS_CPU=500m
|
|||
RESOURCES_REQUESTS_MEMORY=128Mi
|
||||
RESOURCES_REQUESTS_CPU=250m
|
||||
|
||||
ALGORAND_BASE_URL=
|
||||
ALGORAND_REQUESTS_PER_MINUTE=2
|
||||
|
||||
APTOS_BASE_URL=
|
||||
APTOS_REQUESTS_PER_MINUTE=2
|
||||
|
||||
|
@ -34,6 +37,9 @@ KLAYTN_REQUESTS_PER_MINUTE=2
|
|||
MOONBEAM_BASE_URL=
|
||||
MOONBEAM_REQUESTS_PER_MINUTE=2
|
||||
|
||||
OASIS_BASE_URL=
|
||||
OASIS_REQUESTS_PER_MINUTE=2
|
||||
|
||||
OPTIMISM_BASE_URL=
|
||||
OPTIMISM_REQUESTS_PER_MINUTE=2
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ STRATEGY_NAME=time_range
|
|||
STRATEGY_TIMESTAMP_AFTER=2023-01-01T00:00:00.000Z
|
||||
STRATEGY_TIMESTAMP_BEFORE=2023-04-01T00:00:00.000Z
|
||||
|
||||
ALGORAND_BASE_URL=
|
||||
ALGORAND_REQUESTS_PER_MINUTE=1
|
||||
|
||||
APTOS_BASE_URL=
|
||||
APTOS_REQUESTS_PER_MINUTE=1
|
||||
|
||||
|
@ -38,6 +41,9 @@ KLAYTN_REQUESTS_PER_MINUTE=1
|
|||
MOONBEAM_BASE_URL=
|
||||
MOONBEAM_REQUESTS_PER_MINUTE=1
|
||||
|
||||
OASIS_BASE_URL=
|
||||
OASIS_REQUESTS_PER_MINUTE=1
|
||||
|
||||
OPTIMISM_BASE_URL=
|
||||
OPTIMISM_REQUESTS_PER_MINUTE=1
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ RESOURCES_LIMITS_CPU=200m
|
|||
RESOURCES_REQUESTS_MEMORY=64Mi
|
||||
RESOURCES_REQUESTS_CPU=100m
|
||||
|
||||
ALGORAND_BASE_URL=
|
||||
ALGORAND_REQUESTS_PER_MINUTE=1
|
||||
|
||||
APTOS_BASE_URL=
|
||||
APTOS_REQUESTS_PER_MINUTE=1
|
||||
|
||||
|
@ -34,6 +37,9 @@ KLAYTN_REQUESTS_PER_MINUTE=1
|
|||
MOONBEAM_BASE_URL=
|
||||
MOONBEAM_REQUESTS_PER_MINUTE=1
|
||||
|
||||
OASIS_BASE_URL=
|
||||
OASIS_REQUESTS_PER_MINUTE=1
|
||||
|
||||
OPTIMISM_BASE_URL=
|
||||
OPTIMISM_REQUESTS_PER_MINUTE=1
|
||||
|
||||
|
|
|
@ -31,6 +31,10 @@ spec:
|
|||
configMapKeyRef:
|
||||
name: config
|
||||
key: mongo-database
|
||||
- name: ALGORAND_BASE_URL
|
||||
value: {{ .ALGORAND_BASE_URL }}
|
||||
- name: ALGORAND_REQUESTS_PER_MINUTE
|
||||
value: "{{ .ALGORAND_REQUESTS_PER_MINUTE }}"
|
||||
- name: APTOS_BASE_URL
|
||||
value: {{ .APTOS_BASE_URL }}
|
||||
- name: APTOS_REQUESTS_PER_MINUTE
|
||||
|
@ -67,6 +71,10 @@ spec:
|
|||
value: {{ .MOONBEAM_BASE_URL }}
|
||||
- name: MOONBEAM_REQUESTS_PER_MINUTE
|
||||
value: "{{ .MOONBEAM_REQUESTS_PER_MINUTE }}"
|
||||
- name: OASIS_BASE_URL
|
||||
value: {{ .OASIS_BASE_URL }}
|
||||
- name: OASIS_REQUESTS_PER_MINUTE
|
||||
value: "{{ .OASIS_REQUESTS_PER_MINUTE }}"
|
||||
- name: OPTIMISM_BASE_URL
|
||||
value: {{ .OPTIMISM_BASE_URL }}
|
||||
- name: OPTIMISM_REQUESTS_PER_MINUTE
|
||||
|
|
|
@ -11,6 +11,9 @@ SQS_URL=
|
|||
SQS_AWS_REGION=
|
||||
AWS_IAM_ROLE=
|
||||
|
||||
ALGORAND_BASE_URL=
|
||||
ALGORAND_REQUESTS_PER_MINUTE=8
|
||||
|
||||
APTOS_BASE_URL=
|
||||
APTOS_REQUESTS_PER_MINUTE=8
|
||||
|
||||
|
@ -38,6 +41,9 @@ KLAYTN_REQUESTS_PER_MINUTE=8
|
|||
MOONBEAM_BASE_URL=
|
||||
MOONBEAM_REQUESTS_PER_MINUTE=8
|
||||
|
||||
OASIS_BASE_URL=
|
||||
OASIS_REQUESTS_PER_MINUTE=4
|
||||
|
||||
OPTIMISM_BASE_URL=
|
||||
OPTIMISM_REQUESTS_PER_MINUTE=8
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ SQS_URL=
|
|||
SQS_AWS_REGION=
|
||||
AWS_IAM_ROLE=
|
||||
|
||||
ALGORAND_BASE_URL=
|
||||
ALGORAND_REQUESTS_PER_MINUTE=2
|
||||
|
||||
APTOS_BASE_URL=
|
||||
APTOS_REQUESTS_PER_MINUTE=2
|
||||
|
||||
|
@ -38,6 +41,9 @@ KLAYTN_REQUESTS_PER_MINUTE=2
|
|||
MOONBEAM_BASE_URL=
|
||||
MOONBEAM_REQUESTS_PER_MINUTE=2
|
||||
|
||||
OASIS_BASE_URL=
|
||||
OASIS_REQUESTS_PER_MINUTE=2
|
||||
|
||||
OPTIMISM_BASE_URL=
|
||||
OPTIMISM_REQUESTS_PER_MINUTE=2
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ SQS_URL=
|
|||
SQS_AWS_REGION=
|
||||
AWS_IAM_ROLE=
|
||||
|
||||
ALGORAND_BASE_URL=
|
||||
ALGORAND_REQUESTS_PER_MINUTE=2
|
||||
|
||||
APTOS_BASE_URL=
|
||||
APTOS_REQUESTS_PER_MINUTE=2
|
||||
|
||||
|
@ -38,6 +41,9 @@ KLAYTN_REQUESTS_PER_MINUTE=2
|
|||
MOONBEAM_BASE_URL=
|
||||
MOONBEAM_REQUESTS_PER_MINUTE=2
|
||||
|
||||
OASIS_BASE_URL=
|
||||
OASIS_REQUESTS_PER_MINUTE=2
|
||||
|
||||
OPTIMISM_BASE_URL=
|
||||
OPTIMISM_REQUESTS_PER_MINUTE=2
|
||||
|
||||
|
|
|
@ -57,6 +57,10 @@ spec:
|
|||
value: {{ .SQS_URL }}
|
||||
- name: AWS_REGION
|
||||
value: {{ .SQS_AWS_REGION }}
|
||||
- name: ALGORAND_BASE_URL
|
||||
value: {{ .ALGORAND_BASE_URL }}
|
||||
- name: ALGORAND_REQUESTS_PER_MINUTE
|
||||
value: "{{ .ALGORAND_REQUESTS_PER_MINUTE }}"
|
||||
- name: APTOS_BASE_URL
|
||||
value: {{ .APTOS_BASE_URL }}
|
||||
- name: APTOS_REQUESTS_PER_MINUTE
|
||||
|
@ -93,6 +97,10 @@ spec:
|
|||
value: {{ .MOONBEAM_BASE_URL }}
|
||||
- name: MOONBEAM_REQUESTS_PER_MINUTE
|
||||
value: "{{ .MOONBEAM_REQUESTS_PER_MINUTE }}"
|
||||
- name: OASIS_BASE_URL
|
||||
value: {{ .OASIS_BASE_URL }}
|
||||
- name: OASIS_REQUESTS_PER_MINUTE
|
||||
value: "{{ .OASIS_REQUESTS_PER_MINUTE }}"
|
||||
- name: OPTIMISM_BASE_URL
|
||||
value: {{ .OPTIMISM_BASE_URL }}
|
||||
- name: OPTIMISM_REQUESTS_PER_MINUTE
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package chains
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-explorer/txtracker/config"
|
||||
)
|
||||
|
||||
type algorandTransactionResponse struct {
|
||||
Transaction struct {
|
||||
ID string `json:"id"`
|
||||
Sender string `json:"sender"`
|
||||
RoundTime int `json:"round-time"`
|
||||
} `json:"transaction"`
|
||||
}
|
||||
|
||||
func fetchAlgorandTx(
|
||||
ctx context.Context,
|
||||
cfg *config.RpcProviderSettings,
|
||||
txHash string,
|
||||
) (*TxDetail, error) {
|
||||
|
||||
// Fetch tx data from the Algorand Indexer API
|
||||
url := fmt.Sprintf("%s/v2/transactions/%s", cfg.AlgorandBaseUrl, txHash)
|
||||
fmt.Println(url)
|
||||
body, err := httpGet(ctx, url)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("HTTP request to Algorand transactions endpoint failed: %w", err)
|
||||
}
|
||||
|
||||
// Decode the response
|
||||
var response algorandTransactionResponse
|
||||
if err := json.Unmarshal(body, &response); err != nil {
|
||||
return nil, fmt.Errorf("failed to decode Algorand transactions response as JSON: %w", err)
|
||||
}
|
||||
|
||||
// Populate the result struct and return
|
||||
txDetail := TxDetail{
|
||||
NativeTxHash: response.Transaction.ID,
|
||||
From: response.Transaction.Sender,
|
||||
Timestamp: time.Unix(int64(response.Transaction.RoundTime), 0),
|
||||
}
|
||||
return &txDetail, nil
|
||||
}
|
|
@ -32,6 +32,7 @@ type TxDetail struct {
|
|||
}
|
||||
|
||||
var tickers = struct {
|
||||
algorand *time.Ticker
|
||||
aptos *time.Ticker
|
||||
arbitrum *time.Ticker
|
||||
avalanche *time.Ticker
|
||||
|
@ -41,6 +42,7 @@ var tickers = struct {
|
|||
fantom *time.Ticker
|
||||
klaytn *time.Ticker
|
||||
moonbeam *time.Ticker
|
||||
oasis *time.Ticker
|
||||
optimism *time.Ticker
|
||||
polygon *time.Ticker
|
||||
solana *time.Ticker
|
||||
|
@ -61,6 +63,7 @@ func Initialize(cfg *config.RpcProviderSettings) {
|
|||
}
|
||||
|
||||
// these adapters send 1 request per txHash
|
||||
tickers.algorand = time.NewTicker(f(cfg.AlgorandRequestsPerMinute))
|
||||
tickers.sui = time.NewTicker(f(cfg.SuiRequestsPerMinute))
|
||||
tickers.terra2 = time.NewTicker(f(cfg.Terra2RequestsPerMinute))
|
||||
tickers.xpla = time.NewTicker(f(cfg.XplaRequestsPerMinute))
|
||||
|
@ -75,6 +78,7 @@ func Initialize(cfg *config.RpcProviderSettings) {
|
|||
tickers.fantom = time.NewTicker(f(cfg.FantomRequestsPerMinute / 2))
|
||||
tickers.klaytn = time.NewTicker(f(cfg.KlaytnRequestsPerMinute / 2))
|
||||
tickers.moonbeam = time.NewTicker(f(cfg.MoonbeamRequestsPerMinute / 2))
|
||||
tickers.oasis = time.NewTicker(f(cfg.OasisRequestsPerMinute / 2))
|
||||
tickers.optimism = time.NewTicker(f(cfg.OptimismRequestsPerMinute / 2))
|
||||
tickers.polygon = time.NewTicker(f(cfg.PolygonRequestsPerMinute / 2))
|
||||
tickers.solana = time.NewTicker(f(cfg.SolanaRequestsPerMinute / 2))
|
||||
|
@ -95,6 +99,9 @@ func FetchTx(
|
|||
case vaa.ChainIDSolana:
|
||||
fetchFunc = fetchSolanaTx
|
||||
rateLimiter = *tickers.solana
|
||||
case vaa.ChainIDAlgorand:
|
||||
fetchFunc = fetchAlgorandTx
|
||||
rateLimiter = *tickers.algorand
|
||||
case vaa.ChainIDCelo:
|
||||
fetchFunc = func(ctx context.Context, cfg *config.RpcProviderSettings, txHash string) (*TxDetail, error) {
|
||||
return fetchEthTx(ctx, txHash, cfg.CeloBaseUrl)
|
||||
|
@ -130,6 +137,11 @@ func FetchTx(
|
|||
return fetchEthTx(ctx, txHash, cfg.ArbitrumBaseUrl)
|
||||
}
|
||||
rateLimiter = *tickers.arbitrum
|
||||
case vaa.ChainIDOasis:
|
||||
fetchFunc = func(ctx context.Context, cfg *config.RpcProviderSettings, txHash string) (*TxDetail, error) {
|
||||
return fetchEthTx(ctx, txHash, cfg.OasisBaseUrl)
|
||||
}
|
||||
rateLimiter = *tickers.oasis
|
||||
case vaa.ChainIDOptimism:
|
||||
fetchFunc = func(ctx context.Context, cfg *config.RpcProviderSettings, txHash string) (*TxDetail, error) {
|
||||
return fetchEthTx(ctx, txHash, cfg.OptimismBaseUrl)
|
||||
|
|
|
@ -59,6 +59,8 @@ type MongodbSettings struct {
|
|||
}
|
||||
|
||||
type RpcProviderSettings struct {
|
||||
AlgorandBaseUrl string `split_words:"true" required:"true"`
|
||||
AlgorandRequestsPerMinute uint16 `split_words:"true" required:"true"`
|
||||
AptosBaseUrl string `split_words:"true" required:"true"`
|
||||
AptosRequestsPerMinute uint16 `split_words:"true" required:"true"`
|
||||
ArbitrumBaseUrl string `split_words:"true" required:"true"`
|
||||
|
@ -77,6 +79,8 @@ type RpcProviderSettings struct {
|
|||
KlaytnRequestsPerMinute uint16 `split_words:"true" required:"true"`
|
||||
MoonbeamBaseUrl string `split_words:"true" required:"true"`
|
||||
MoonbeamRequestsPerMinute uint16 `split_words:"true" required:"true"`
|
||||
OasisBaseUrl string `split_words:"true" required:"true"`
|
||||
OasisRequestsPerMinute uint16 `split_words:"true" required:"true"`
|
||||
OptimismBaseUrl string `split_words:"true" required:"true"`
|
||||
OptimismRequestsPerMinute uint16 `split_words:"true" required:"true"`
|
||||
PolygonBaseUrl string `split_words:"true" required:"true"`
|
||||
|
|
Loading…
Reference in New Issue