Skip to content

Commit 9f8cff9

Browse files
authored
Merge pull request #94 from fystack/feat/xrp-stellar
Feat/xrp stellar
2 parents 3ca6d62 + ce4a993 commit 9f8cff9

21 files changed

Lines changed: 5258 additions & 40 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.idea
2+
/.cache
13
data/
24
logs/
35
configs/config.yaml

configs/config.example.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ chains:
9191
- url: "https://bsc.blockrazor.xyz"
9292
- url: "https://bnb.rpc.subquery.network/public"
9393

94+
conflux_mainnet:
95+
network_id: "conflux_mainnet"
96+
internal_code: "CONFLUX_MAINNET"
97+
type: "evm"
98+
start_block: 0
99+
poll_interval: "3s"
100+
nodes:
101+
- url: "https://evm.confluxrpc.com"
102+
- url: "https://conflux-espace-public.unifra.io"
103+
- url: "https://1rpc.io/cfx"
104+
105+
conflux_testnet:
106+
network_id: "conflux_testnet"
107+
internal_code: "CONFLUX_TESTNET"
108+
type: "evm"
109+
start_block: 0
110+
poll_interval: "3s"
111+
nodes:
112+
- url: "https://evmtestnet.confluxrpc.com"
113+
- url: "https://conflux-espace-testnet.public.blastapi.io"
114+
94115
bitcoin_testnet:
95116
network_id: "bitcoin_testnet"
96117
internal_code: "BTC_TESTNET"
@@ -332,6 +353,86 @@ chains:
332353
batch_size: 20
333354
concurrency: 4
334355

356+
xrp_mainnet:
357+
network_id: "xrp_mainnet"
358+
internal_code: "XRP_MAINNET"
359+
type: "xrp"
360+
start_block: 0
361+
poll_interval: "2s"
362+
nodes:
363+
- url: "https://xrplcluster.com"
364+
- url: "https://s1.ripple.com:51234"
365+
client:
366+
timeout: "15s"
367+
max_retries: 3
368+
retry_delay: "1s"
369+
throttle:
370+
rps: 40
371+
burst: 80
372+
batch_size: 20
373+
concurrency: 6
374+
parallel: true
375+
376+
xrp_testnet:
377+
network_id: "xrp_testnet"
378+
internal_code: "XRP_TESTNET"
379+
type: "xrp"
380+
start_block: 0
381+
poll_interval: "2s"
382+
nodes:
383+
- url: "https://s.altnet.rippletest.net:51234"
384+
- url: "https://testnet.xrpl-labs.com"
385+
client:
386+
timeout: "15s"
387+
max_retries: 3
388+
retry_delay: "1s"
389+
throttle:
390+
rps: 40
391+
burst: 80
392+
batch_size: 20
393+
concurrency: 6
394+
parallel: true
395+
396+
stellar_mainnet:
397+
network_id: "stellar_mainnet"
398+
internal_code: "STELLAR_MAINNET"
399+
type: "stellar"
400+
start_block: 0
401+
poll_interval: "2s"
402+
nodes:
403+
- url: "https://horizon.stellar.org"
404+
- url: "https://horizon.publicnode.com"
405+
client:
406+
timeout: "15s"
407+
max_retries: 3
408+
retry_delay: "1s"
409+
throttle:
410+
rps: 40
411+
burst: 80
412+
batch_size: 20
413+
concurrency: 6
414+
parallel: true
415+
416+
stellar_testnet:
417+
network_id: "stellar_testnet"
418+
internal_code: "STELLAR_TESTNET"
419+
type: "stellar"
420+
start_block: 0
421+
poll_interval: "2s"
422+
nodes:
423+
- url: "https://horizon-testnet.stellar.org"
424+
- url: "https://horizon-testnet.publicnode.com"
425+
client:
426+
timeout: "15s"
427+
max_retries: 3
428+
retry_delay: "1s"
429+
throttle:
430+
rps: 40
431+
burst: 80
432+
batch_size: 20
433+
concurrency: 6
434+
parallel: true
435+
335436
ton_mainnet:
336437
network_id: "ton"
337438
internal_code: "TON_MAINNET"

internal/indexer/directional.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package indexer
2+
3+
import (
4+
"github.com/fystack/multichain-indexer/pkg/common/constant"
5+
"github.com/fystack/multichain-indexer/pkg/common/types"
6+
)
7+
8+
const (
9+
metadataKeySourceAmount = "source_amount"
10+
metadataKeySourceAsset = "source_asset_address"
11+
metadataKeySourceTxType = "source_tx_type"
12+
)
13+
14+
func normalizeDirectionalMetadata(tx types.Transaction, direction string) types.Transaction {
15+
if direction != types.DirectionOut {
16+
clearDirectionalMetadata(&tx)
17+
return tx
18+
}
19+
20+
sourceType := tx.GetMetadataString(metadataKeySourceTxType)
21+
if sourceType != "" {
22+
tx.Type = constant.TxType(sourceType)
23+
if tx.Type == constant.TxTypeNativeTransfer {
24+
tx.AssetAddress = ""
25+
}
26+
}
27+
28+
if sourceAmount := tx.GetMetadataString(metadataKeySourceAmount); sourceAmount != "" {
29+
tx.Amount = sourceAmount
30+
}
31+
32+
switch tx.GetMetadataString(metadataKeySourceTxType) {
33+
case string(constant.TxTypeNativeTransfer):
34+
tx.AssetAddress = ""
35+
case string(constant.TxTypeTokenTransfer):
36+
tx.AssetAddress = tx.GetMetadataString(metadataKeySourceAsset)
37+
}
38+
39+
clearDirectionalMetadata(&tx)
40+
return tx
41+
}
42+
43+
func clearDirectionalMetadata(tx *types.Transaction) {
44+
if tx == nil || tx.Metadata == nil {
45+
return
46+
}
47+
48+
delete(tx.Metadata, metadataKeySourceAmount)
49+
delete(tx.Metadata, metadataKeySourceAsset)
50+
delete(tx.Metadata, metadataKeySourceTxType)
51+
if len(tx.Metadata) == 0 {
52+
tx.Metadata = nil
53+
}
54+
}

internal/indexer/indexer.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ type Indexer interface {
1919
GetBlocksByNumbers(ctx context.Context, blockNumbers []uint64) ([]BlockResult, error)
2020
IsHealthy() bool
2121
}
22+
23+
// DirectionalNormalizer is an optional hook for chains whose outgoing wallet
24+
// view differs from the incoming payload of the same routed transfer
25+
// (for example, path/cross-asset payments). It must not change from/to-based
26+
// routing decisions; it only shapes the emitted transaction payload.
27+
type DirectionalNormalizer interface {
28+
NormalizeForDirection(tx types.Transaction, direction string) types.Transaction
29+
}

0 commit comments

Comments
 (0)