From f729e8286ce314557b7760943fb97c7ff1ae9c02 Mon Sep 17 00:00:00 2001 From: William Hua Date: Mon, 26 Jan 2026 14:27:15 -0500 Subject: [PATCH] finalizer -> ethfinalizer --- README.md | 2 +- {finalizer => ethfinalizer}/README.md | 24 +++++++++---------- {finalizer => ethfinalizer}/chain.go | 2 +- .../ethfinalizer.go | 4 ++-- .../ethfinalizer_test.go | 18 +++++++------- {finalizer => ethfinalizer}/mempool.go | 2 +- {finalizer => ethfinalizer}/utils.go | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) rename {finalizer => ethfinalizer}/README.md (77%) rename {finalizer => ethfinalizer}/chain.go (99%) rename finalizer/finalizer.go => ethfinalizer/ethfinalizer.go (99%) rename finalizer/finalizer_test.go => ethfinalizer/ethfinalizer_test.go (94%) rename {finalizer => ethfinalizer}/mempool.go (99%) rename {finalizer => ethfinalizer}/utils.go (99%) diff --git a/README.md b/README.md index fef8f28e..677b9926 100644 --- a/README.md +++ b/README.md @@ -138,11 +138,11 @@ Packages: - `ethartifacts`: simple pkg to parse Truffle artifact file - `ethcoder`: encoding/decoding libraries for smart contracts and transactions - `ethdeploy`: simple method to deploy contract bytecode to a network +- `ethfinalizer`: a wallet adapter for guaranteeing transaction inclusion - `ethgas`: fetch the latest gas price of a network or track over a period of time - `ethmonitor`: easily monitor block production, transactions and logs of a chain; with re-org support - `ethrpc`: http client for Ethereum json-rpc - `ethwallet`: wallet for Ethereum with support for wallet mnemonics (BIP-39) -- `finalizer`: a wallet adapter for guaranteeing transaction inclusion on a specific chain ## License diff --git a/finalizer/README.md b/ethfinalizer/README.md similarity index 77% rename from finalizer/README.md rename to ethfinalizer/README.md index 71dce528..3d7a84dd 100644 --- a/finalizer/README.md +++ b/ethfinalizer/README.md @@ -1,4 +1,4 @@ -# Finalizer +# ethfinalizer A wallet adapter for guaranteeing transaction inclusion on a specific chain. @@ -11,7 +11,7 @@ This fixes "nonce too low" issues that can happen if reorgs occur or if you trus For demonstration: ```go -mempool := finalizer.NewMemoryMempool[struct{}]() +mempool := ethfinalizer.NewMemoryMempool[struct{}]() ``` Here `struct{}` can be any type for transaction metadata, data that gets persisted with the transaction, but not sent on chain. @@ -23,7 +23,7 @@ For production, implement the `Mempool` interface and persist to a database inst For EIP-1559 chains: ```go -chain, err := finalizer.NewEthkitChain(finalizer.EthkitChainOptions{ +chain, err := ethfinalizer.NewEthkitChain(ethfinalizer.EthkitChainOptions{ ChainID: big.NewInt(1), IsEIP1559: true, Provider: provider, @@ -36,21 +36,21 @@ chain, err := finalizer.NewEthkitChain(finalizer.EthkitChainOptions{ For non-EIP-1559 chains: ```go -chain, err := finalizer.NewEthkitChain(finalizer.EthkitChainOptions{ +chain, err := ethfinalizer.NewEthkitChain(ethfinalizer.EthkitChainOptions{ ChainID: big.NewInt(56), IsEIP1559: false, Provider: provider, - Monitor: monitor, // must be running - GasGauge: gasGauge, // required for non-EIP-1559 chains - GasGaugeSpeed: finalizer.GasGaugeSpeedDefault // default = fast - PriorityFee: nil, // not used for non-EIP-1559 chains + Monitor: monitor, // must be running + GasGauge: gasGauge, // required for non-EIP-1559 chains + GasGaugeSpeed: ethfinalizer.GasGaugeSpeedDefault // default = fast + PriorityFee: nil, // not used for non-EIP-1559 chains }) ``` ### Create a finalizer for a specific wallet on a specific chain ```go -f, err := finalizer.NewFinalizer(finalizer.FinalizerOptions[struct{}]{ +finalizer, err := ethfinalizer.NewFinalizer(ethfinalizer.FinalizerOptions[struct{}]{ Wallet: wallet, Chain: chain, Mempool: mempool, @@ -66,13 +66,13 @@ f, err := finalizer.NewFinalizer(finalizer.FinalizerOptions[struct{}]{ The finalizer has a blocking run loop that must be called for it to work: ```go -err := f.Run(ctx) +err := finalizer.Run(ctx) ``` ### Subscribe to mining and reorg events ```go -for event := range f.Subscribe(ctx) { +for event := range finalizer.Subscribe(ctx) { if event.Added != nil { if event.Removed == nil { fmt.Println( @@ -103,7 +103,7 @@ for event := range f.Subscribe(ctx) { ### Send a transaction ```go -signed, err := f.Send(ctx, unsigned, struct{}{}) +signed, err := finalizer.Send(ctx, unsigned, struct{}{}) ``` The `struct{}{}` argument here is the transaction's metadata. diff --git a/finalizer/chain.go b/ethfinalizer/chain.go similarity index 99% rename from finalizer/chain.go rename to ethfinalizer/chain.go index f6b2a69b..448847c1 100644 --- a/finalizer/chain.go +++ b/ethfinalizer/chain.go @@ -1,4 +1,4 @@ -package finalizer +package ethfinalizer import ( "context" diff --git a/finalizer/finalizer.go b/ethfinalizer/ethfinalizer.go similarity index 99% rename from finalizer/finalizer.go rename to ethfinalizer/ethfinalizer.go index 3fe8f231..ce67e7dd 100644 --- a/finalizer/finalizer.go +++ b/ethfinalizer/ethfinalizer.go @@ -1,7 +1,7 @@ -// Package finalizer implements a wallet adapter for guaranteeing transaction inclusion on a specific chain. +// Package ethfinalizer implements a wallet adapter for guaranteeing transaction inclusion on a specific chain. // // This fixes "nonce too low" issues that can happen if reorgs occur or if you trust your node's reported nonces. -package finalizer +package ethfinalizer import ( "context" diff --git a/finalizer/finalizer_test.go b/ethfinalizer/ethfinalizer_test.go similarity index 94% rename from finalizer/finalizer_test.go rename to ethfinalizer/ethfinalizer_test.go index a1436d4e..8b52ceeb 100644 --- a/finalizer/finalizer_test.go +++ b/ethfinalizer/ethfinalizer_test.go @@ -1,4 +1,4 @@ -package finalizer_test +package ethfinalizer_test import ( "context" @@ -11,8 +11,8 @@ import ( "testing" "time" + "github.com/0xsequence/ethkit/ethfinalizer" "github.com/0xsequence/ethkit/ethwallet" - "github.com/0xsequence/ethkit/finalizer" "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/core/types" "github.com/stretchr/testify/assert" @@ -60,9 +60,9 @@ func test(t *testing.T, isEIP1559 bool) { }) assert.NoError(t, err) - mempool := finalizer.NewMemoryMempool[struct{}]() + mempool := ethfinalizer.NewMemoryMempool[struct{}]() - finalizer, err := finalizer.NewFinalizer(finalizer.FinalizerOptions[struct{}]{ + finalizer, err := ethfinalizer.NewFinalizer(ethfinalizer.FinalizerOptions[struct{}]{ Wallet: wallet, Chain: chain, Mempool: mempool, @@ -228,7 +228,7 @@ type TestChain struct { highestNonce *uint64 mu sync.RWMutex - subscriptions map[chan finalizer.Diff]struct{} + subscriptions map[chan ethfinalizer.Diff]struct{} subscriptionsMu sync.RWMutex } @@ -246,7 +246,7 @@ func NewTestChain(options TestChainOptions) (*TestChain, error) { mempool: map[uint64][]*types.Transaction{}, - subscriptions: map[chan finalizer.Diff]struct{}{}, + subscriptions: map[chan ethfinalizer.Diff]struct{}{}, }, nil } @@ -284,7 +284,7 @@ func (c *TestChain) Publish() { c.subscriptionsMu.RLock() defer c.subscriptionsMu.RUnlock() - diff := finalizer.Diff{ + diff := ethfinalizer.Diff{ Removed: map[common.Hash]struct{}{}, Added: map[common.Hash]struct{}{}, } @@ -367,11 +367,11 @@ func (c *TestChain) PriorityFee(ctx context.Context) (*big.Int, error) { return new(big.Int).SetUint64(uniform(c.MinPriorityFee, c.MaxPriorityFee)), nil } -func (c *TestChain) Subscribe(ctx context.Context) (<-chan finalizer.Diff, error) { +func (c *TestChain) Subscribe(ctx context.Context) (<-chan ethfinalizer.Diff, error) { c.subscriptionsMu.Lock() defer c.subscriptionsMu.Unlock() - subscription := make(chan finalizer.Diff) + subscription := make(chan ethfinalizer.Diff) c.subscriptions[subscription] = struct{}{} go func() { diff --git a/finalizer/mempool.go b/ethfinalizer/mempool.go similarity index 99% rename from finalizer/mempool.go rename to ethfinalizer/mempool.go index fe6b4126..44dfb7e2 100644 --- a/finalizer/mempool.go +++ b/ethfinalizer/mempool.go @@ -1,4 +1,4 @@ -package finalizer +package ethfinalizer import ( "context" diff --git a/finalizer/utils.go b/ethfinalizer/utils.go similarity index 99% rename from finalizer/utils.go rename to ethfinalizer/utils.go index af5ced75..5fedc61b 100644 --- a/finalizer/utils.go +++ b/ethfinalizer/utils.go @@ -1,4 +1,4 @@ -package finalizer +package ethfinalizer import ( "fmt"