diff --git a/clients/feeder/testdata/mainnet/transaction/0x5d50b7020f7cf8033fd7d913e489f47edf74fbf3c8ada85be512c7baa6a2eab.json b/clients/feeder/testdata/mainnet/transaction/0x5d50b7020f7cf8033fd7d913e489f47edf74fbf3c8ada85be512c7baa6a2eab.json new file mode 100644 index 0000000000..ce8626f969 --- /dev/null +++ b/clients/feeder/testdata/mainnet/transaction/0x5d50b7020f7cf8033fd7d913e489f47edf74fbf3c8ada85be512c7baa6a2eab.json @@ -0,0 +1 @@ +{"execution_status": "SUCCEEDED", "finality_status": "ACCEPTED_ON_L1", "status": "ACCEPTED_ON_L1", "block_hash": "0x27d1e625a4293d2ed162eb2a1ad031cf71eaa2bab3a3d10fe9bddc51b877ccd", "block_number": 192, "transaction_index": 22, "transaction": {"transaction_hash": "0x5d50b7020f7cf8033fd7d913e489f47edf74fbf3c8ada85be512c7baa6a2eab", "version": "0x0", "contract_address": "0x58b43819bb12aba8ab3fb2e997523e507399a3f48a1e2aa20a5fb7734a0449f", "entry_point_selector": "0xe3f5e9e1456ffa52a3fbc7e8c296631d4cc2120c0be1e2829301c0d8fa026b", "calldata": ["0x5474c49483aa09993090979ade8101ebb4cdce4a", "0xabf8dd8438d1c21e83a8b5e9c1f9b58aaf3ed360", "0x2", "0x4c04fac82913f01a8f01f6e15ff7e834ff2d9a9a1d8e9adffc7bd45692f4f9a"], "type": "L1_HANDLER"}} diff --git a/rpc/handlers.go b/rpc/handlers.go index 6a7249268f..82fd278111 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -352,12 +352,15 @@ func AdaptTransaction(t core.Transaction) *Transaction { case *core.DeployAccountTransaction: txn = adaptDeployAccountTrandaction(v) case *core.L1HandlerTransaction: - // https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L1669 + nonce := v.Nonce + if nonce == nil { + nonce = &felt.Zero + } txn = &Transaction{ Type: TxnL1Handler, Hash: v.Hash(), Version: v.Version.AsFelt(), - Nonce: v.Nonce, + Nonce: nonce, ContractAddress: v.ContractAddress, EntryPointSelector: v.EntryPointSelector, CallData: &v.CallData, diff --git a/rpc/handlers_test.go b/rpc/handlers_test.go index 62ef586c65..27117f80d0 100644 --- a/rpc/handlers_test.go +++ b/rpc/handlers_test.go @@ -566,7 +566,7 @@ func TestTransactionByHash(t *testing.T) { }`, }, - "L1 Handler v0": { + "L1 Handler v0 with nonce": { hash: "0x537eacfd3c49166eec905daff61ff7feef9c133a049ea2135cb94eec840a4a8", network: utils.Mainnet, expected: `{ @@ -585,6 +585,24 @@ func TestTransactionByHash(t *testing.T) { ] }`, }, + "L1 Handler v0 without nonce": { + hash: "0x5d50b7020f7cf8033fd7d913e489f47edf74fbf3c8ada85be512c7baa6a2eab", + network: utils.Mainnet, + expected: `{ + "type": "L1_HANDLER", + "transaction_hash": "0x5d50b7020f7cf8033fd7d913e489f47edf74fbf3c8ada85be512c7baa6a2eab", + "version": "0x0", + "nonce": "0x0", + "contract_address": "0x58b43819bb12aba8ab3fb2e997523e507399a3f48a1e2aa20a5fb7734a0449f", + "entry_point_selector": "0xe3f5e9e1456ffa52a3fbc7e8c296631d4cc2120c0be1e2829301c0d8fa026b", + "calldata": [ + "0x5474c49483aa09993090979ade8101ebb4cdce4a", + "0xabf8dd8438d1c21e83a8b5e9c1f9b58aaf3ed360", + "0x2", + "0x4c04fac82913f01a8f01f6e15ff7e834ff2d9a9a1d8e9adffc7bd45692f4f9a" + ] + }`, + }, "Invoke v1": { hash: "0x2897e3cec3e24e4d341df26b8cf1ab84ea1c01a051021836b36c6639145b497",