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
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.24.2
// replace github.com/0xsequence/ethkit => ../ethkit

require (
github.com/0xsequence/ethkit v1.38.6
github.com/0xsequence/ethkit v1.39.0
github.com/0xsequence/go-ethauth v0.14.0
github.com/BurntSushi/toml v1.2.1
github.com/davecgh/go-spew v1.1.1
Expand Down Expand Up @@ -41,7 +41,6 @@ require (
github.com/gorilla/websocket v1.5.3 // indirect
github.com/goware/breaker v0.2.0 // indirect
github.com/goware/cachestore-mem v0.2.2 // indirect
github.com/goware/calc v0.2.0 // indirect
github.com/goware/channel v0.5.0 // indirect
github.com/goware/singleflight v0.3.0 // indirect
github.com/goware/superr v0.0.2 // indirect
Expand All @@ -55,7 +54,6 @@ require (
github.com/supranational/blst v0.3.16 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go.work.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions intent_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/0xsequence/go-sequence/contracts"
v3 "github.com/0xsequence/go-sequence/core/v3"
"github.com/0xsequence/go-sequence/receipts"
"github.com/0xsequence/go-sequence/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -591,7 +592,7 @@ func TestIntentTransactionToGuestModuleDeployAndCall(t *testing.T) {
assert.Equal(t, "2255", ret[0])

// Assert sequence.WaitForMetaTxn is able to find the metaTxnID
result, _, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, sequence.MetaTxnID(opPayload.Digest().Hash.Hex()[2:]))
result, _, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, sequence.MetaTxnID(opPayload.Digest().Hash.Hex()[2:]))
assert.NoError(t, err)
assert.True(t, result.Status == sequence.MetaTxnExecuted)

Expand Down Expand Up @@ -775,7 +776,7 @@ func TestIntentTransactionToGuestModuleDeployAndCallMultiplePayloads(t *testing.
expectedMetaTxnID := sequence.MetaTxnID(opPayload.Digest().Hash.Hex()[2:])
fmt.Printf("Expected MetaTxnID Payload %d: %s\n", i+1, expectedMetaTxnID)

result, _, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, expectedMetaTxnID)
result, _, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, expectedMetaTxnID)
assert.NoError(t, err)
assert.True(t, result.Status == sequence.MetaTxnExecuted)
}
Expand Down
120 changes: 0 additions & 120 deletions receipt_fetcher.go

This file was deleted.

3 changes: 2 additions & 1 deletion receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (r *Receipt) setNativeReceipt(receipt *types.Receipt) {

// This method is duplicated code from: `compressor/contract.go`
// can't be used directly, because it would create a circular dependency
func DecompressCalldata(ctx context.Context, to *common.Address, data []byte, provider *ethrpc.Provider) (common.Address, []byte, error) {
func DecompressCalldata(ctx context.Context, to *common.Address, data []byte, provider ethrpc.Interface) (common.Address, []byte, error) {
if len(data) == 0 {
return common.Address{}, nil, fmt.Errorf("empty transaction data")
}
Expand Down Expand Up @@ -213,6 +213,7 @@ func V3DecodeCallSucceededEvent(log *types.Log) (common.Hash, *big.Int, error) {

switch len(log.Topics) {
case 1:
// TODO: we can remove this as its the old v3-rc.4 and earlier format
legacyInputs := make(abi.Arguments, len(event.Inputs))
copy(legacyInputs, event.Inputs)
legacyInputs[0].Indexed = false
Expand Down
40 changes: 17 additions & 23 deletions receipts/fetch.go → receipts/eth_getlogs_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (
sequence "github.com/0xsequence/go-sequence"
)

const MaxFilterBlockRange = 10_000
const MaxFilterBlockRange = 7500

// FetchReceipts looks up the transaction that emitted Call* events for the given
// digest and returns all decoded Sequence receipts along with the native receipt.
// FetchMetaTransactionReceiptByETHGetLogs looks up the transaction that emitted Call*
// events for the given digest and returns all decoded Sequence receipts along with
// the native receipt.
//
// The `opHash` is also known as the "MetaTxnID"
// The `opHash` is also known as the "MetaTxnID" but please make sure
// it has the "0x" prefix when passing as a common.Hash, even though
// sometimes we represent a MetaTxnID without the 0x prefix as a string.
//
// NOTE: toBlock can also be nil, in which case the latest block is used.
//
Expand All @@ -27,9 +30,9 @@ const MaxFilterBlockRange = 10_000
// receipt directly. However, this is not to be confused with where a "Call" inside
// of the native transaction fails, but the native transaction itself succeeds which
// is more common and works fine.
func FetchReceipts(ctx context.Context, opHash common.Hash, provider *ethrpc.Provider, fromBlock, toBlock *big.Int) (Receipts, *types.Receipt, error) {
func FetchMetaTransactionReceiptByETHGetLogs(ctx context.Context, opHash common.Hash, provider ethrpc.Interface, fromBlock, toBlock *big.Int) (Receipts, *types.Receipt, error) {
if provider == nil {
return Receipts{}, nil, fmt.Errorf("no provider")
return Receipts{}, nil, fmt.Errorf("receipts: no provider")
}

fromBlock_ := fromBlock
Expand All @@ -54,25 +57,22 @@ func FetchReceipts(ctx context.Context, opHash common.Hash, provider *ethrpc.Pro
FromBlock: fromBlock,
ToBlock: toBlock,
Topics: [][]common.Hash{
{sequence.V3CallSucceeded, sequence.V3CallFailed, sequence.V3CallAborted, sequence.V3CallSkipped},
{sequence.V3CallSucceeded, sequence.V3CallFailed}, //, sequence.V3CallAborted, sequence.V3CallSkipped},
{opHash},
},
}

// TODO: what if there is a node failure here, we should retry a few times
// and also check the type of error from the node to see how we should behave/handle.
logs, err := provider.FilterLogs(ctx, query)
if err != nil {
return Receipts{}, nil, fmt.Errorf("unable to filter logs: %w", err)
}
if len(logs) == 0 {
// Fallback for legacy events where the digest is not indexed.
query.Topics = [][]common.Hash{{sequence.V3CallSucceeded, sequence.V3CallFailed, sequence.V3CallAborted, sequence.V3CallSkipped}}
logs, err = provider.FilterLogs(ctx, query)
if err != nil {
return Receipts{}, nil, fmt.Errorf("unable to filter logs without digest topic: %w", err)
}
return Receipts{}, nil, ethereum.NotFound
}

log, err := findDigestLog(logs, opHash)
log, err := findV3CallsDigestLog(logs, opHash)
if err != nil {
return Receipts{}, nil, err
}
Expand All @@ -91,33 +91,27 @@ func FetchReceipts(ctx context.Context, opHash common.Hash, provider *ethrpc.Pro
if receipts == nil {
return Receipts{}, receipt, fmt.Errorf("decoded receipts do not include digest %v", opHash)
}

return *receipts, receipt, nil
}

func findDigestLog(logs []types.Log, digest common.Hash) (*types.Log, error) {
func findV3CallsDigestLog(logs []types.Log, digest common.Hash) (*types.Log, error) {
var selected *types.Log

for i := range logs {
log := &logs[i]

if !matchesDigest(log, digest) {
if !matchesV3CallsDigest(log, digest) {
continue
}

if selected == nil || isNewerLog(log, selected) {
selected = log
}
}

if selected == nil {
return nil, fmt.Errorf("no Call* events found for digest %v", digest)
}

return selected, nil
}

func matchesDigest(log *types.Log, digest common.Hash) bool {
func matchesV3CallsDigest(log *types.Log, digest common.Hash) bool {
if hash, _, err := sequence.V3DecodeCallSucceededEvent(log); err == nil && hash == digest {
return true
}
Expand Down
Loading
Loading