diff --git a/go.mod b/go.mod index ac5cbc54..b05eb36d 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 7f6c462e..93c3aee7 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/0xsequence/ethkit v1.38.6 h1:Pit5ylbsFRsyp5AX3Pe61HjudnRvdzecl6MQgSoVvZc= -github.com/0xsequence/ethkit v1.38.6/go.mod h1:YUKyA/fXsjxqAdYgpbDfkbWtFfBm4luDfvUJ1/SyeJ4= +github.com/0xsequence/ethkit v1.39.0 h1:mUsBhrmuaefOueiZvBNjpomIC4DdzsqVEq8VA2vIQic= +github.com/0xsequence/ethkit v1.39.0/go.mod h1:2iTawl9i1GqBhJschoaY4rofsuRn5p/lT05hhDlm5kI= github.com/0xsequence/go-ethauth v0.14.0 h1:0TQKu/bFpTZ0hNtedqfHuRn/fa2wI8qlLJE0rDgJ0Dw= github.com/0xsequence/go-ethauth v0.14.0/go.mod h1:AX6zc0LNxzRHXW+i+IPyuLLgj+AdLl7KjLNRXB/10r0= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= @@ -98,8 +98,6 @@ github.com/goware/cachestore-mem v0.2.2 h1:toE6/1QMQQcQLJQpTIiTDAIHWLN4zvihoqZHq github.com/goware/cachestore-mem v0.2.2/go.mod h1:KpXr+yVajbeN0s+CX/08hdSww2WhjtAL1pmNy69S03w= github.com/goware/cachestore2 v0.12.3 h1:V4VODChSAV29p8htHj8Lb36Hvv28CLrJsw49gx0h+ks= github.com/goware/cachestore2 v0.12.3/go.mod h1:PR+lXK8UXa/wjKB7mpIj6HtRhC7vbcRXx4b5F1Av/ik= -github.com/goware/calc v0.2.0 h1:3B9qjXYpE0kgS4LhyklbM6X/0cOvZLdUZG7sdAuVCb4= -github.com/goware/calc v0.2.0/go.mod h1:BSQUbfS6ICW9RvSV9SikDY+t6/HQKI+CUxIpjE3VD28= github.com/goware/channel v0.5.0 h1:cOllKceCH5Xhibs0v8jtPJ81ez3L7WpYri/OU+9IBfg= github.com/goware/channel v0.5.0/go.mod h1:Eai0KCjphDZ44M/qT7G1ZE6lZfywiTFvwV3Xc6cDPdo= github.com/goware/logger v0.3.0 h1:pdgnsqj2rSDXtfdu+UuAFuBuOapxeDYNETY39227LMM= diff --git a/go.work.sum b/go.work.sum index 749c8139..1f3c2225 100644 --- a/go.work.sum +++ b/go.work.sum @@ -56,6 +56,8 @@ github.com/0xsequence/ethkit v1.29.5/go.mod h1:rv0FAIyEyN0hhwGefbduAz4ujmyjyJXhC github.com/0xsequence/ethkit v1.32.0/go.mod h1:IT2jUmscz4DXIpLdXkFbrVkR4+UZdlzFw3AoY3QbahE= github.com/0xsequence/ethkit v1.38.1 h1:aCLKEk143HhmI2GWEg311a2i+a9JF/I+4gHi/Ol9pVI= github.com/0xsequence/ethkit v1.38.1/go.mod h1:8OJ6MUtw3gCiUHIsp4yhRsCnwHj9whkWMX23408FhRg= +github.com/0xsequence/ethkit v1.38.6 h1:Pit5ylbsFRsyp5AX3Pe61HjudnRvdzecl6MQgSoVvZc= +github.com/0xsequence/ethkit v1.38.6/go.mod h1:YUKyA/fXsjxqAdYgpbDfkbWtFfBm4luDfvUJ1/SyeJ4= github.com/0xsequence/go-ethauth v0.13.0 h1:ZaqFEEqy574A2b1P7vjpcy5tb4W/izn+A3swwOYi9wA= github.com/0xsequence/go-ethauth v0.13.0/go.mod h1:f3kx39S9F+W+qvZEB6bkKKbpUstmyB7goUntO3wvlhg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -115,6 +117,7 @@ github.com/consensys/bavard v0.2.1/go.mod h1:k/zVjHHC4B+PQy1Pg7fgvG3ALicQw540Cra github.com/consensys/gnark-crypto v0.13.0/go.mod h1:wKqwsieaKPThcFkHe0d0zMsbHEUWFmZcG7KBCse210o= github.com/consensys/gnark-crypto v0.16.0/go.mod h1:Ke3j06ndtPTVvo++PhGNgvm+lgpLvzbcE2MqljY7diU= github.com/consensys/gnark-crypto v0.19.0/go.mod h1:rT23F0XSZqE0mUA0+pRtnL56IbPxs6gp4CeRsBk4XS0= +github.com/consensys/gnark-crypto v0.19.1/go.mod h1:rT23F0XSZqE0mUA0+pRtnL56IbPxs6gp4CeRsBk4XS0= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -235,6 +238,8 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= github.com/goware/cachestore v0.8.1/go.mod h1:ikiO2RmxIt4cVqEBII6yR+V4Z7pH+y8bMQHpd1MvG1Y= github.com/goware/cachestore-redis v0.2.1/go.mod h1:+8rOAfL1qNLNiXHe8+WACPk+I9kaLOAfArj2Z7FDiWg= +github.com/goware/calc v0.2.0 h1:3B9qjXYpE0kgS4LhyklbM6X/0cOvZLdUZG7sdAuVCb4= +github.com/goware/calc v0.2.0/go.mod h1:BSQUbfS6ICW9RvSV9SikDY+t6/HQKI+CUxIpjE3VD28= github.com/goware/pp v0.0.3/go.mod h1:shID9y83CUGdg/BfO0SrVhchPpIAcT3ArfLVkq3x7tQ= github.com/goware/pubsub v0.6.1/go.mod h1:DXI6mIJ52E5dqwFHPz12MrFr7CxQlXc97Vh9ZltYGE0= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= diff --git a/intent_config_test.go b/intent_config_test.go index dece515b..8ed7babe 100644 --- a/intent_config_test.go +++ b/intent_config_test.go @@ -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" @@ -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) @@ -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) } diff --git a/receipt_fetcher.go b/receipt_fetcher.go deleted file mode 100644 index f635220e..00000000 --- a/receipt_fetcher.go +++ /dev/null @@ -1,120 +0,0 @@ -package sequence - -import ( - "context" - "fmt" - "time" - - "github.com/0xsequence/ethkit" - "github.com/0xsequence/ethkit/ethreceipts" - "github.com/0xsequence/ethkit/go-ethereum/common" - "github.com/0xsequence/ethkit/go-ethereum/core/types" -) - -type MetaTxnResult struct { - MetaTxnID MetaTxnID - Status MetaTxnStatus - Reason string -} - -func FetchMetaTransactionReceipt(ctx context.Context, receiptListener *ethreceipts.ReceiptsListener, metaTxnID MetaTxnID, optTimeout ...time.Duration) (*MetaTxnResult, *ethreceipts.Receipt, ethreceipts.WaitReceiptFinalityFunc, error) { - // Use optional timeout if passed, otherwise use deadline on the provided ctx, or finally, - // set a default timeout of 200 seconds. - var cancel context.CancelFunc - if len(optTimeout) > 0 { - ctx, cancel = context.WithTimeout(ctx, optTimeout[0]) - defer cancel() - } else { - if _, ok := ctx.Deadline(); !ok { - ctx, cancel = context.WithTimeout(ctx, 200*time.Second) - defer cancel() - } - } - - var result *MetaTxnResult - - metaTxnHash := common.HexToHash(string(metaTxnID)) - receipt, waitFinality, err := receiptListener.FetchTransactionReceiptWithFilter(ctx, FilterMetaTransactionID(metaTxnHash).LimitOne(true).SearchCache(true).MaxWait(0)) - if err != nil { - return nil, nil, nil, err - } - - result = &MetaTxnResult{ - MetaTxnID: metaTxnID, - } - - logs := receipt.Logs() -done: - for i := len(logs) - 1; i >= 0; i-- { - log := logs[i] - switch { - case V1IsTxExecutedEvent(log, metaTxnHash): - result.Status = MetaTxnExecuted - break done - case V2IsTxExecutedEvent(log, metaTxnHash): - result.Status = MetaTxnExecuted - break done - case V3IsCallSucceededEvent(log, metaTxnHash): - result.Status = MetaTxnExecuted - break done - case V1IsTxFailedEvent(log, metaTxnHash): - result.Status = MetaTxnFailed - _, result.Reason, _ = V1DecodeTxFailedEvent(log) - break done - case V2IsTxFailedEvent(log, metaTxnHash): - result.Status = MetaTxnFailed - _, result.Reason, _, _ = V2DecodeTxFailedEvent(log) - break done - case V3IsCallFailedEvent(log, metaTxnHash): - result.Status = MetaTxnFailed - _, _, reason, _ := V3DecodeCallFailedEvent(log) - result.Reason = fmt.Sprint(reason) - break done - case V3IsCallAbortedEvent(log, metaTxnHash): - result.Status = MetaTxnFailed - _, _, reason, _ := V3DecodeCallAbortedEvent(log) - result.Reason = fmt.Sprint(reason) - break done - } - } - - return result, receipt, waitFinality, nil -} - -func FilterMetaTransactionID(metaTxnID ethkit.Hash) ethreceipts.FilterQuery { - return ethreceipts.FilterLogs(func(logs []*types.Log) bool { - for _, log := range logs { - switch { - case V1IsTxExecutedEvent(log, metaTxnID): - fallthrough - case V1IsTxFailedEvent(log, metaTxnID): - fallthrough - case V2IsTxExecutedEvent(log, metaTxnID): - fallthrough - case V2IsTxFailedEvent(log, metaTxnID): - fallthrough - case V3IsCallSucceededEvent(log, metaTxnID): - fallthrough - case V3IsCallFailedEvent(log, metaTxnID): - fallthrough - case V3IsCallAbortedEvent(log, metaTxnID): - fallthrough - case V3IsCallSkippedEvent(log, metaTxnID): - return true - } - } - return false - }) -} - -// Find any Sequence meta txns -func FilterMetaTransactionAny() ethreceipts.FilterQuery { - return ethreceipts.FilterLogs(func(logs []*types.Log) bool { - for _, log := range logs { - if len(log.Topics) == 1 && log.Topics[0] == NonceChangeEventSig { - return true - } - } - return false - }) -} diff --git a/receipts.go b/receipts.go index fa37f798..70608c1e 100644 --- a/receipts.go +++ b/receipts.go @@ -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") } @@ -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 diff --git a/receipts/fetch.go b/receipts/eth_getlogs_fetch.go similarity index 72% rename from receipts/fetch.go rename to receipts/eth_getlogs_fetch.go index b9beadb4..11e10751 100644 --- a/receipts/fetch.go +++ b/receipts/eth_getlogs_fetch.go @@ -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. // @@ -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 @@ -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 } @@ -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 } diff --git a/receipts/listener_fetch.go b/receipts/listener_fetch.go new file mode 100644 index 00000000..e8cc5b71 --- /dev/null +++ b/receipts/listener_fetch.go @@ -0,0 +1,154 @@ +package receipts + +import ( + "context" + "fmt" + "math/big" + "time" + + "github.com/0xsequence/ethkit" + "github.com/0xsequence/ethkit/ethreceipts" + "github.com/0xsequence/ethkit/go-ethereum/common" + "github.com/0xsequence/ethkit/go-ethereum/core/types" + sequence "github.com/0xsequence/go-sequence" +) + +type MetaTxnResult struct { + MetaTxnID sequence.MetaTxnID + Status sequence.MetaTxnStatus + Reason string +} + +func FetchMetaTransactionReceipt(ctx context.Context, receiptListener *ethreceipts.ReceiptsListener, metaTxnID sequence.MetaTxnID, optTimeout ...time.Duration) (*MetaTxnResult, *ethreceipts.Receipt, ethreceipts.WaitReceiptFinalityFunc, error) { + // Use optional timeout if passed, otherwise use deadline on the provided ctx, or finally, + // set a default timeout of 200 seconds. + var cancel context.CancelFunc + if len(optTimeout) > 0 { + ctx, cancel = context.WithTimeout(ctx, optTimeout[0]) + defer cancel() + } else { + if _, ok := ctx.Deadline(); !ok { + ctx, cancel = context.WithTimeout(ctx, 200*time.Second) + defer cancel() + } + } + + var result *MetaTxnResult + + metaTxnHash := common.HexToHash(string(metaTxnID)) + + // Build the filter request for the receipt listener. Once the request is processing + // it will immediately try the "QueryOnChain" function to see if the receipt is already + // available on-chain before waiting for new blocks to be mined. + filter := FilterMetaTransactionID(metaTxnHash). + LimitOne(true). + MaxWait(0). + SearchCache(true). + QueryOnChainTxnHash(false). + QueryOnChain(func(ctx context.Context) (*types.Receipt, error) { + // QueryOnChain function is called at the beginning of the subscriber filter + // process, so we can quickly query the chain for the receipt without waiting + // to check historical blocks up front. + // + // NOTE: this only works on v3 sequence transactions because only v3 + // has properly set indexed events. + toBlock := receiptListener.LatestBlockNum() + if toBlock == nil || toBlock.Cmp(big.NewInt(0)) == 0 { + return nil, fmt.Errorf("receipts: no latest block number available from monitor") + } + fromBlock := new(big.Int).Sub(toBlock, big.NewInt(MaxFilterBlockRange)) + if fromBlock.Cmp(big.NewInt(0)) < 0 { + fromBlock = big.NewInt(0) + } + // TODO: consider if there is a node failure to fetch, and we fail to get this + // but the window has past, so we need to do better on retrying, to ensure + // we actually get a valid response (even if our metatxnid isn't found). + _, receipt, err := FetchMetaTransactionReceiptByETHGetLogs(ctx, metaTxnHash, receiptListener.RPCProvider(), fromBlock, toBlock) + return receipt, err + }) + + // Query the receipt listener + receipt, waitFinality, err := receiptListener.FetchTransactionReceiptWithFilter(ctx, filter) + if err != nil { + return nil, nil, nil, err + } + + result = &MetaTxnResult{ + MetaTxnID: metaTxnID, + } + + logs := receipt.Logs() +done: + for i := len(logs) - 1; i >= 0; i-- { + log := logs[i] + switch { + case sequence.V3IsCallSucceededEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnExecuted + break done + case sequence.V3IsCallFailedEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnFailed + _, _, reason, _ := sequence.V3DecodeCallFailedEvent(log) + result.Reason = fmt.Sprint(reason) + break done + case sequence.V3IsCallAbortedEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnFailed + _, _, reason, _ := sequence.V3DecodeCallAbortedEvent(log) + result.Reason = fmt.Sprint(reason) + break done + case sequence.V2IsTxExecutedEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnExecuted + break done + case sequence.V2IsTxFailedEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnFailed + _, result.Reason, _, _ = sequence.V2DecodeTxFailedEvent(log) + break done + case sequence.V1IsTxExecutedEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnExecuted + break done + case sequence.V1IsTxFailedEvent(log, metaTxnHash): + result.Status = sequence.MetaTxnFailed + _, result.Reason, _ = sequence.V1DecodeTxFailedEvent(log) + break done + } + } + + return result, receipt, waitFinality, nil +} + +func FilterMetaTransactionID(metaTxnID ethkit.Hash) ethreceipts.FilterQuery { + return ethreceipts.FilterLogs(func(logs []*types.Log) bool { + for _, log := range logs { + switch { + case sequence.V3IsCallSucceededEvent(log, metaTxnID): + return true + case sequence.V3IsCallFailedEvent(log, metaTxnID): + return true + case sequence.V3IsCallAbortedEvent(log, metaTxnID): + return true + case sequence.V3IsCallSkippedEvent(log, metaTxnID): + return true + case sequence.V2IsTxExecutedEvent(log, metaTxnID): + return true + case sequence.V2IsTxFailedEvent(log, metaTxnID): + return true + case sequence.V1IsTxExecutedEvent(log, metaTxnID): + return true + case sequence.V1IsTxFailedEvent(log, metaTxnID): + return true + } + } + return false + }) +} + +// Find any Sequence meta txns +func FilterMetaTransactionAny() ethreceipts.FilterQuery { + return ethreceipts.FilterLogs(func(logs []*types.Log) bool { + for _, log := range logs { + if len(log.Topics) == 1 && log.Topics[0] == sequence.NonceChangeEventSig { + return true + } + } + return false + }) +} diff --git a/receipts/receipts.go b/receipts/receipts.go index 5eb9184b..79465774 100644 --- a/receipts/receipts.go +++ b/receipts/receipts.go @@ -84,7 +84,7 @@ func TransactionReceipts(ctx context.Context, transaction common.Hash, provider return TransactionReceiptsForReceipt(ctx, receipt, provider, chainID...) } -func TransactionReceiptsForReceipt(ctx context.Context, receipt *types.Receipt, provider *ethrpc.Provider, chainID ...*big.Int) (Receipts, error) { +func TransactionReceiptsForReceipt(ctx context.Context, receipt *types.Receipt, provider ethrpc.Interface, chainID ...*big.Int) (Receipts, error) { if provider == nil { return Receipts{}, fmt.Errorf("no provider") } @@ -111,7 +111,7 @@ func TransactionReceiptsForReceipt(ctx context.Context, receipt *types.Receipt, return decodeLogs(ctx, *to, transaction_.Data(), receipt.Logs, chainID[0], provider) } -func decodeLogs(ctx context.Context, to common.Address, data []byte, logs []*types.Log, chainID *big.Int, provider *ethrpc.Provider) (Receipts, error) { +func decodeLogs(ctx context.Context, to common.Address, data []byte, logs []*types.Log, chainID *big.Int, provider ethrpc.Interface) (Receipts, error) { if execute := contracts.V3.WalletStage1Module.ABI.Methods["execute"]; bytes.HasPrefix(data, execute.ID) { args, err := execute.Inputs.Unpack(data[4:]) if err != nil { diff --git a/receipts/receipts_test.go b/receipts/receipts_test.go index 1266ed3c..fe50556b 100644 --- a/receipts/receipts_test.go +++ b/receipts/receipts_test.go @@ -85,6 +85,8 @@ func TestReceiptsV3(t *testing.T) { } func TestReceiptsZKSync(t *testing.T) { + t.Skip("skipping this test as appears nodes are unhealthy and unavailable") + test(t, Test{ Network: "sandbox-testnet", Transaction: "0x6ddb43ddf29ed48f302c6b7b6dc9bb47b33dd5099540fb0793f239edb406fa5d", diff --git a/receipts_test.go b/receipts_test.go index 35f53c5b..933464f7 100644 --- a/receipts_test.go +++ b/receipts_test.go @@ -13,6 +13,7 @@ import ( "github.com/0xsequence/go-sequence" "github.com/0xsequence/go-sequence/testutil" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestReceiptDecoding(t *testing.T) { @@ -29,7 +30,7 @@ func TestReceiptDecoding(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) var send [][]byte @@ -248,16 +249,19 @@ func areIsomorphic(receipt *sequence.Receipt, transaction *sequence.Transaction) } func TestZKSyncReceipts(t *testing.T) { + t.Skip("skipping this test as appears nodes are unhealthy and unavailable") + ctx := context.Background() provider, err := ethrpc.NewProvider("https://nodes.sequence.app/sandbox-testnet") - assert.NoError(t, err) + require.NoError(t, err) hash := common.HexToHash("0x6ddb43ddf29ed48f302c6b7b6dc9bb47b33dd5099540fb0793f239edb406fa5d") receipt, err := provider.TransactionReceipt(ctx, hash) - assert.NoError(t, err) + require.NoError(t, err) + require.NotNil(t, receipt) _, _, err = sequence.DecodeReceipt(ctx, receipt, provider) - assert.NoError(t, err) + require.NoError(t, err) } diff --git a/relayer/local_relayer.go b/relayer/local_relayer.go index 764cc476..3c870ddf 100644 --- a/relayer/local_relayer.go +++ b/relayer/local_relayer.go @@ -20,6 +20,7 @@ import ( v2 "github.com/0xsequence/go-sequence/core/v2" v3 "github.com/0xsequence/go-sequence/core/v3" "github.com/0xsequence/go-sequence/lib/simulator" + "github.com/0xsequence/go-sequence/receipts" "github.com/0xsequence/go-sequence/relayer/proto" ) @@ -234,7 +235,7 @@ func (r *LocalRelayer) Wait(ctx context.Context, metaTxnID sequence.MetaTxnID, o if r.receiptListener == nil { return 0, nil, fmt.Errorf("relayer: failed to wait for metaTxnID as receiptListener is not set") } - result, receipt, _, err := sequence.FetchMetaTransactionReceipt(ctx, r.receiptListener, metaTxnID, optTimeout...) + result, receipt, _, err := receipts.FetchMetaTransactionReceipt(ctx, r.receiptListener, metaTxnID, optTimeout...) if err != nil { return 0, nil, err } diff --git a/relayer/relayer.go b/relayer/relayer.go index 52609021..723b8832 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -24,6 +24,7 @@ import ( v2 "github.com/0xsequence/go-sequence/core/v2" v3 "github.com/0xsequence/go-sequence/core/v3" "github.com/0xsequence/go-sequence/lib/simulator" + "github.com/0xsequence/go-sequence/receipts" "github.com/0xsequence/go-sequence/relayer/proto" ) @@ -303,7 +304,7 @@ func (r *Client) Wait(ctx context.Context, metaTxnID sequence.MetaTxnID, optTime } // Fetch the meta transaction receipt from the receipt listener - result, receipt, _, err := sequence.FetchMetaTransactionReceipt(ctx, r.receiptListener, metaTxnID, optTimeout...) + result, receipt, _, err := receipts.FetchMetaTransactionReceipt(ctx, r.receiptListener, metaTxnID, optTimeout...) if err != nil { return 0, nil, err } diff --git a/relayer_test.go b/relayer_test.go index d2969987..083e60f9 100644 --- a/relayer_test.go +++ b/relayer_test.go @@ -4,27 +4,31 @@ import ( "context" "math/big" "testing" + "time" "github.com/0xsequence/ethkit/ethcoder" + "github.com/0xsequence/ethkit/go-ethereum/common" "github.com/0xsequence/ethkit/go-ethereum/core/types" "github.com/0xsequence/go-sequence" + "github.com/0xsequence/go-sequence/receipts" "github.com/0xsequence/go-sequence/testutil" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestGetReceiptOfTransaction(t *testing.T) { // Ensure dummy sequence wallet from seed 1 is deployed - wallet, err := testChain.V1DummySequenceWallet(1) - assert.NoError(t, err) - assert.NotNil(t, wallet) + wallet, err := testChain.V3DummySequenceWallet(1) + require.NoError(t, err) + require.NotNil(t, wallet) // Create normal txn of: callmockContract.testCall(55, 0x112255) callmockContract := testChain.UniDeploy(t, "WALLET_CALL_RECV_MOCK", 0) calldata, err := callmockContract.Encode("testCall", big.NewInt(55), ethcoder.MustHexDecode("0x112255")) - assert.NoError(t, err) + require.NoError(t, err) nonce, err := wallet.GetNonce() - assert.NoError(t, err) + require.NoError(t, err) stx := &sequence.Transaction{ To: callmockContract.Address, @@ -36,20 +40,64 @@ func TestGetReceiptOfTransaction(t *testing.T) { Nonce: nonce, } - err = testutil.SignAndSendRawTransaction(t, wallet, stx) - assert.NoError(t, err) + origReceipt, err := testutil.SignAndSendRawTransaction(t, wallet, stx) + require.NoError(t, err) + require.NotNil(t, origReceipt) + t.Logf("original receipt txn hash: %v", origReceipt.TxHash.Hex()) // Get transactions digest - metaTxnID, _, err := sequence.ComputeMetaTxnID(testChain.ChainID(), wallet.Address(), stx.Bundle(), nonce, 0) - assert.NoError(t, err) - assert.NotEmpty(t, metaTxnID) + // Build V3 CallsPayload to compute the exact V3 metaTxnID + // payload := v3.NewCallsPayload( + // wallet.Address(), + // testChain.ChainID(), + // []v3.Call{{ + // To: callmockContract.Address, + // Value: big.NewInt(0), + // Data: calldata, + // GasLimit: big.NewInt(190000), + // DelegateCall: false, + // OnlyFallback: false, + // BehaviorOnError: v3.BehaviorOnErrorIgnore, + // }}, + // big.NewInt(0), // space + // nonce, // v3 nonce + // ) + payload, err := stx.Bundle().Payload(wallet.Address(), testChain.ChainID(), big.NewInt(0), nonce) + require.NoError(t, err) + + metaTxnID, _, err := sequence.ComputeMetaTxnIDFromCallsPayload(&payload) + require.NoError(t, err) + require.NotEmpty(t, metaTxnID) + t.Logf("metaTxnID: 0x%s", string(metaTxnID)) + + // NOTE: we can delay here by uncommenting, which will make it so we don't find the + // receipt in the cache, and we depend on the QueryOnChain function to find it. + time.Sleep(3 * time.Second) // Find receipt // status, receipt, err := sequence.WaitForMetaTxn(context.Background(), testChain.Provider, metaTxnId) - result, receipt, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) - assert.NoError(t, err) - assert.NotNil(t, receipt) - assert.Equal(t, sequence.MetaTxnExecuted, result.Status) + result, receipt, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) + require.NoError(t, err) + require.NotNil(t, receipt) + require.Equal(t, sequence.MetaTxnExecuted, result.Status) + t.Logf("listener found receipt of txn hash: %v", receipt.TransactionHash().Hex()) + + // Find receipt again via eth_getLogs method directly + latestBlock := testChain.ReceiptsListener.LatestBlockNum() + fromBlock := new(big.Int).Sub(latestBlock, big.NewInt(5000)) + if fromBlock.Cmp(big.NewInt(0)) < 0 { + fromBlock = big.NewInt(0) + } + var toBlock *big.Int = nil + + metaTxnHash := common.HexToHash(string(metaTxnID)) + _, receipt2, err := receipts.FetchMetaTransactionReceiptByETHGetLogs(context.Background(), metaTxnHash, testChain.ReceiptsListener.RPCProvider(), fromBlock, toBlock) + require.NoError(t, err) + require.NotNil(t, receipt2) + require.Equal(t, types.ReceiptStatusSuccessful, receipt2.Status) + require.Equal(t, receipt.Status(), receipt2.Status) + require.Equal(t, receipt.TransactionHash(), receipt2.TxHash) + t.Logf("fetch via eth_getLogs found receipt of txn hash: %v", receipt2.TxHash.Hex()) } func TestGetReceiptOfErrorTransaction(t *testing.T) { @@ -63,7 +111,7 @@ func TestGetReceiptOfErrorTransaction(t *testing.T) { calldata, err := callmockContract.Encode("setRevertFlag", true) assert.NoError(t, err) - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) // Call callmock, this should revert and fail the transaction @@ -83,7 +131,7 @@ func TestGetReceiptOfErrorTransaction(t *testing.T) { Nonce: nonce, } - err = testutil.SignAndSendRawTransaction(t, wallet, stx) + _, err = testutil.SignAndSendRawTransaction(t, wallet, stx) assert.NoError(t, err) // Get transactions digest @@ -93,7 +141,7 @@ func TestGetReceiptOfErrorTransaction(t *testing.T) { // Find receipt // status, receipt, err := sequence.WaitForMetaTxn(context.Background(), testChain.Provider, metaTxnId) - result, receipt, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) + result, receipt, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) assert.NoError(t, err) assert.NotNil(t, receipt) assert.Equal(t, sequence.MetaTxnFailed, result.Status) @@ -116,14 +164,14 @@ func TestGetReceiptOfFailedTransactionBetweenTransactions(t *testing.T) { for i := 1; i <= 3; i++ { calldata, err := callmockContract.Encode("testCall", big.NewInt(int64(i)), ethcoder.MustHexDecode("0x112255")) assert.NoError(t, err) - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) } calldata, err := callmockContract.Encode("setRevertFlag", true) assert.NoError(t, err) - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) for i := 1; i <= 3; i++ { @@ -135,7 +183,7 @@ func TestGetReceiptOfFailedTransactionBetweenTransactions(t *testing.T) { GasLimit: big.NewInt(190000), RevertOnError: false, } - err = testutil.SignAndSendRawTransaction(t, wallet, stx) + _, err = testutil.SignAndSendRawTransaction(t, wallet, stx) assert.NoError(t, err) } @@ -155,7 +203,7 @@ func TestGetReceiptOfFailedTransactionBetweenTransactions(t *testing.T) { Nonce: nonce, } - err = testutil.SignAndSendRawTransaction(t, wallet, stx) + _, err = testutil.SignAndSendRawTransaction(t, wallet, stx) assert.NoError(t, err) for i := 1; i <= 3; i++ { @@ -167,7 +215,7 @@ func TestGetReceiptOfFailedTransactionBetweenTransactions(t *testing.T) { GasLimit: big.NewInt(190000), RevertOnError: false, } - err = testutil.SignAndSendRawTransaction(t, wallet, stx) + _, err = testutil.SignAndSendRawTransaction(t, wallet, stx) assert.NoError(t, err) } @@ -178,7 +226,7 @@ func TestGetReceiptOfFailedTransactionBetweenTransactions(t *testing.T) { // Find receipt // status, receipt, err := sequence.WaitForMetaTxn(context.Background(), testChain.Provider, metaTxnId) - result, receipt, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) + result, receipt, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) assert.NoError(t, err) assert.NotNil(t, receipt) assert.Equal(t, types.ReceiptStatusSuccessful, receipt.Status()) // native txn was successful @@ -201,7 +249,7 @@ func TestGetReceiptOfTransactionBetweenTransactions(t *testing.T) { for i := 1; i <= 3; i++ { calldata, err := callmockContract.Encode("testCall", big.NewInt(int64(i)), ethcoder.MustHexDecode("0x112255")) assert.NoError(t, err) - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) } @@ -221,13 +269,13 @@ func TestGetReceiptOfTransactionBetweenTransactions(t *testing.T) { Nonce: nonce, } - err = testutil.SignAndSendRawTransaction(t, wallet, stx) + _, err = testutil.SignAndSendRawTransaction(t, wallet, stx) assert.NoError(t, err) for i := 1; i <= 3; i++ { calldata, err = callmockContract.Encode("testCall", big.NewInt(int64(i)), ethcoder.MustHexDecode("0x112255")) assert.NoError(t, err) - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) } @@ -238,7 +286,7 @@ func TestGetReceiptOfTransactionBetweenTransactions(t *testing.T) { // Find receipt // status, receipt, err := sequence.WaitForMetaTxn(context.Background(), testChain.Provider, metaTxnId) - result, receipt, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) + result, receipt, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) assert.NoError(t, err) assert.NotNil(t, receipt) assert.Equal(t, sequence.MetaTxnExecuted, result.Status) diff --git a/testutil/helpers.go b/testutil/helpers.go index 9fc9bc75..8c90fb3f 100644 --- a/testutil/helpers.go +++ b/testutil/helpers.go @@ -20,6 +20,7 @@ import ( "github.com/0xsequence/go-sequence/contracts" "github.com/0xsequence/go-sequence/core" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) var sequenceContext = sequence.WalletContext{ @@ -42,8 +43,8 @@ var sequenceContextV2 = sequence.WalletContext{ var sequenceContextV3 = sequence.WalletContext{ FactoryAddress: common.HexToAddress("0x00000000000018A77519fcCCa060c2537c9D6d3F"), - MainModuleAddress: common.HexToAddress("0x0000000000001f3C39d61698ab21131a12134454"), - MainModuleUpgradableAddress: common.HexToAddress("0xD0ae8eF93b7DA4eabb32Ec4d81b7a501DCa04D4C"), + MainModuleAddress: common.HexToAddress("0x0000000000001f3C39d61698ab21131a12134454"), // stage 1 + MainModuleUpgradableAddress: common.HexToAddress("0xD0ae8eF93b7DA4eabb32Ec4d81b7a501DCa04D4C"), // stage 2 GuestModuleAddress: common.HexToAddress("0x0000000000006Ac72ed1d192fa28f0058D3F8806"), CreationCode: hexutil.Encode(contracts.V3.CreationCode), } @@ -114,7 +115,7 @@ func DummyPrivateKey(seed uint64) string { return fmt.Sprintf("%064x", seed) } -func SignAndSend[C core.WalletConfig](t *testing.T, wallet *sequence.Wallet[C], to common.Address, data []byte) error { +func SignAndSend[C core.WalletConfig](t *testing.T, wallet *sequence.Wallet[C], to common.Address, data []byte) (*types.Receipt, error) { stx := &sequence.Transaction{ // DelegateCall: false, // RevertOnError: false, @@ -123,28 +124,27 @@ func SignAndSend[C core.WalletConfig](t *testing.T, wallet *sequence.Wallet[C], To: to, Data: data, } - return SignAndSendRawTransaction(t, wallet, stx) } -func SignAndSendRawTransaction[C core.WalletConfig](t *testing.T, wallet *sequence.Wallet[C], stx *sequence.Transaction) error { +func SignAndSendRawTransaction[C core.WalletConfig](t *testing.T, wallet *sequence.Wallet[C], stx *sequence.Transaction) (*types.Receipt, error) { // Now, we must sign the meta txn signedTx, err := wallet.SignTransaction(context.Background(), stx) - assert.NoError(t, err) + require.NoError(t, err) metaTxnID, _, waitReceipt, err := wallet.SendTransaction(context.Background(), signedTx) - assert.NoError(t, err) - assert.NotEmpty(t, metaTxnID) + require.NoError(t, err) + require.NotEmpty(t, metaTxnID) receipt, err := waitReceipt(context.Background()) - assert.NoError(t, err) - assert.True(t, receipt.Status == types.ReceiptStatusSuccessful) + require.NoError(t, err) + require.True(t, receipt.Status == types.ReceiptStatusSuccessful) // TODO: decode the receipt, and lets confirm we have the metaTxnID event in there.. // NOTE: if you start test chain with `make start-testchain-verbose`, you will see the metaTxnID above // correctly logged.. - return err + return receipt, err } func BatchSignAndSend[C core.WalletConfig](t *testing.T, wallet *sequence.Wallet[C], to common.Address, data [][]byte) error { diff --git a/transactions_test.go b/transactions_test.go index 4b2a560d..7fce21bc 100644 --- a/transactions_test.go +++ b/transactions_test.go @@ -16,6 +16,7 @@ import ( v1 "github.com/0xsequence/go-sequence/core/v1" v2 "github.com/0xsequence/go-sequence/core/v2" 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" ) @@ -33,7 +34,7 @@ func TestTransaction(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) // Check the value @@ -55,7 +56,7 @@ func TestTransaction(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) // Check the value @@ -77,7 +78,7 @@ func TestTransaction(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallet, callmockContract.Address, calldata) assert.NoError(t, err) // Check the value @@ -280,7 +281,7 @@ func TestTransactionBundling(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallets[0], callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallets[0], callmockContract.Address, calldata) assert.NoError(t, err) // Check the value @@ -366,7 +367,7 @@ func TestTransactionBundling(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallets[0], callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallets[0], callmockContract.Address, calldata) assert.NoError(t, err) // Check the value @@ -452,7 +453,7 @@ func TestTransactionBundling(t *testing.T) { assert.NoError(t, err) // Sign and send the transaction - err = testutil.SignAndSend(t, wallets[0], callmockContract.Address, calldata) + _, err = testutil.SignAndSend(t, wallets[0], callmockContract.Address, calldata) assert.NoError(t, err) // Check the value @@ -790,7 +791,7 @@ func TestTransactionToGuestModuleDeployAndCall(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, metaTxnID) + result, _, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) // metaStatus, _, err := sequence.WaitForMetaTxn(context.Background(), testChain.Provider, metaTxnID) assert.NoError(t, err) assert.True(t, result.Status == sequence.MetaTxnExecuted) @@ -897,7 +898,7 @@ func TestTransactionToGuestModuleDeployAndCall(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, metaTxnID) + result, _, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) // metaStatus, _, err := sequence.WaitForMetaTxn(context.Background(), testChain.Provider, metaTxnID) assert.NoError(t, err) assert.True(t, result.Status == sequence.MetaTxnExecuted) @@ -995,7 +996,7 @@ func TestTransactionToGuestModuleDeployAndCall(t *testing.T) { // Assert sequence.WaitForMetaTxn is able to find the metaTxnID metaTxnID, _, _ := sequence.ComputeMetaTxnIDFromCallsPayload(&payload) - result, _, _, err := sequence.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) + result, _, _, err := receipts.FetchMetaTransactionReceipt(context.Background(), testChain.ReceiptsListener, metaTxnID) assert.NoError(t, err) assert.True(t, result.Status == sequence.MetaTxnExecuted) diff --git a/utils.go b/utils.go index f8aac132..10764201 100644 --- a/utils.go +++ b/utils.go @@ -43,7 +43,7 @@ func DeploySequenceWallet(sender *ethwallet.Wallet, walletConfig core.WalletConf return common.Address{}, nil, nil, err } - signedDeployTx, err := sender.SignTx(deployTx, chainID) + signedDeployTx, err := sender.SignTransaction(deployTx, chainID) if err != nil { return common.Address{}, nil, nil, err }