Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.idea
/.cache
data/
logs/
configs/config.yaml
Expand Down
101 changes: 101 additions & 0 deletions configs/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ chains:
- url: "https://bsc.blockrazor.xyz"
- url: "https://bnb.rpc.subquery.network/public"

conflux_mainnet:
network_id: "conflux_mainnet"
internal_code: "CONFLUX_MAINNET"
type: "evm"
start_block: 0
poll_interval: "3s"
nodes:
- url: "https://evm.confluxrpc.com"
- url: "https://conflux-espace-public.unifra.io"
- url: "https://1rpc.io/cfx"

conflux_testnet:
network_id: "conflux_testnet"
internal_code: "CONFLUX_TESTNET"
type: "evm"
start_block: 0
poll_interval: "3s"
nodes:
- url: "https://evmtestnet.confluxrpc.com"
- url: "https://conflux-espace-testnet.public.blastapi.io"

bitcoin_testnet:
network_id: "bitcoin_testnet"
internal_code: "BTC_TESTNET"
Expand Down Expand Up @@ -332,6 +353,86 @@ chains:
batch_size: 20
concurrency: 4

xrp_mainnet:
network_id: "xrp_mainnet"
internal_code: "XRP_MAINNET"
type: "xrp"
start_block: 0
poll_interval: "2s"
nodes:
- url: "https://xrplcluster.com"
- url: "https://s1.ripple.com:51234"
client:
timeout: "15s"
max_retries: 3
retry_delay: "1s"
throttle:
rps: 40
burst: 80
batch_size: 20
concurrency: 6
parallel: true

xrp_testnet:
network_id: "xrp_testnet"
internal_code: "XRP_TESTNET"
type: "xrp"
start_block: 0
poll_interval: "2s"
nodes:
- url: "https://s.altnet.rippletest.net:51234"
- url: "https://testnet.xrpl-labs.com"
client:
timeout: "15s"
max_retries: 3
retry_delay: "1s"
throttle:
rps: 40
burst: 80
batch_size: 20
concurrency: 6
parallel: true

stellar_mainnet:
network_id: "stellar_mainnet"
internal_code: "STELLAR_MAINNET"
type: "stellar"
start_block: 0
poll_interval: "2s"
nodes:
- url: "https://horizon.stellar.org"
- url: "https://horizon.publicnode.com"
client:
timeout: "15s"
max_retries: 3
retry_delay: "1s"
throttle:
rps: 40
burst: 80
batch_size: 20
concurrency: 6
parallel: true

stellar_testnet:
network_id: "stellar_testnet"
internal_code: "STELLAR_TESTNET"
type: "stellar"
start_block: 0
poll_interval: "2s"
nodes:
- url: "https://horizon-testnet.stellar.org"
- url: "https://horizon-testnet.publicnode.com"
client:
timeout: "15s"
max_retries: 3
retry_delay: "1s"
throttle:
rps: 40
burst: 80
batch_size: 20
concurrency: 6
parallel: true

ton_mainnet:
network_id: "ton"
internal_code: "TON_MAINNET"
Expand Down
54 changes: 54 additions & 0 deletions internal/indexer/directional.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package indexer

import (
"github.com/fystack/multichain-indexer/pkg/common/constant"
"github.com/fystack/multichain-indexer/pkg/common/types"
)

const (
metadataKeySourceAmount = "source_amount"
metadataKeySourceAsset = "source_asset_address"
metadataKeySourceTxType = "source_tx_type"
)

func normalizeDirectionalMetadata(tx types.Transaction, direction string) types.Transaction {
if direction != types.DirectionOut {
clearDirectionalMetadata(&tx)
return tx
}

sourceType := tx.GetMetadataString(metadataKeySourceTxType)
if sourceType != "" {
tx.Type = constant.TxType(sourceType)
if tx.Type == constant.TxTypeNativeTransfer {
tx.AssetAddress = ""
}
}

if sourceAmount := tx.GetMetadataString(metadataKeySourceAmount); sourceAmount != "" {
tx.Amount = sourceAmount
}

switch tx.GetMetadataString(metadataKeySourceTxType) {
case string(constant.TxTypeNativeTransfer):
tx.AssetAddress = ""
case string(constant.TxTypeTokenTransfer):
tx.AssetAddress = tx.GetMetadataString(metadataKeySourceAsset)
}

clearDirectionalMetadata(&tx)
return tx
}

func clearDirectionalMetadata(tx *types.Transaction) {
if tx == nil || tx.Metadata == nil {
return
}

delete(tx.Metadata, metadataKeySourceAmount)
delete(tx.Metadata, metadataKeySourceAsset)
delete(tx.Metadata, metadataKeySourceTxType)
if len(tx.Metadata) == 0 {
tx.Metadata = nil
}
}
8 changes: 8 additions & 0 deletions internal/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ type Indexer interface {
GetBlocksByNumbers(ctx context.Context, blockNumbers []uint64) ([]BlockResult, error)
IsHealthy() bool
}

// DirectionalNormalizer is an optional hook for chains whose outgoing wallet
// view differs from the incoming payload of the same routed transfer
// (for example, path/cross-asset payments). It must not change from/to-based
// routing decisions; it only shapes the emitted transaction payload.
type DirectionalNormalizer interface {
NormalizeForDirection(tx types.Transaction, direction string) types.Transaction
}
Loading
Loading