From 42097150ba92acee81a612d698884c7eb4703a54 Mon Sep 17 00:00:00 2001 From: Franco Barpp Gomes Date: Wed, 22 Jan 2025 14:42:46 +0900 Subject: [PATCH 1/2] fix: Fix function call calldata possibly nil --- rpc/call.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpc/call.go b/rpc/call.go index 4d29cf1d..0ac4a344 100644 --- a/rpc/call.go +++ b/rpc/call.go @@ -6,6 +6,8 @@ import ( "github.com/NethermindEth/juno/core/felt" ) +var emptyCalldata = []*felt.Felt{} + // Call calls the Starknet Provider's function with the given (Starknet) request and block ID. // // Parameters: @@ -16,6 +18,10 @@ import ( // - []*felt.Felt: the result of the function call // - error: an error if any occurred during the execution func (provider *Provider) Call(ctx context.Context, request FunctionCall, blockID BlockID) ([]*felt.Felt, error) { + if request.Calldata == nil { + request.Calldata = emptyCalldata + } + var result []*felt.Felt if err := do(ctx, provider.c, "starknet_call", &result, request, blockID); err != nil { return nil, tryUnwrapToRPCErr(err, ErrContractNotFound, ErrContractError, ErrBlockNotFound) From cf24819f97f63dbcf264f5c25e2b624fb8422389 Mon Sep 17 00:00:00 2001 From: Franco Barpp Gomes Date: Thu, 23 Jan 2025 00:31:16 +0900 Subject: [PATCH 2/2] refactor: Remove empty calldata package var --- rpc/call.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rpc/call.go b/rpc/call.go index 0ac4a344..651edd94 100644 --- a/rpc/call.go +++ b/rpc/call.go @@ -6,8 +6,6 @@ import ( "github.com/NethermindEth/juno/core/felt" ) -var emptyCalldata = []*felt.Felt{} - // Call calls the Starknet Provider's function with the given (Starknet) request and block ID. // // Parameters: @@ -19,7 +17,7 @@ var emptyCalldata = []*felt.Felt{} // - error: an error if any occurred during the execution func (provider *Provider) Call(ctx context.Context, request FunctionCall, blockID BlockID) ([]*felt.Felt, error) { if request.Calldata == nil { - request.Calldata = emptyCalldata + request.Calldata = []*felt.Felt{} } var result []*felt.Felt