diff --git a/services/horizon/internal/ingest/processors/operations_processor.go b/services/horizon/internal/ingest/processors/operations_processor.go index e99488744e..39d09b1608 100644 --- a/services/horizon/internal/ingest/processors/operations_processor.go +++ b/services/horizon/internal/ingest/processors/operations_processor.go @@ -550,7 +550,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, op := operation.operation.Body.MustClaimClaimableBalanceOp() balanceID, err := xdr.MarshalHex(op.BalanceId) if err != nil { - panic(fmt.Errorf("Invalid balanceId in op: %d", operation.index)) + return nil, fmt.Errorf("Invalid balanceId in op: %d", operation.index) } details["balance_id"] = balanceID addAccountAndMuxedAccountDetails(details, *source, "claimant") @@ -585,7 +585,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, op := operation.operation.Body.MustClawbackClaimableBalanceOp() balanceID, err := xdr.MarshalHex(op.BalanceId) if err != nil { - panic(fmt.Errorf("Invalid balanceId in op: %d", operation.index)) + return nil, fmt.Errorf("Invalid balanceId in op: %d", operation.index) } details["balance_id"] = balanceID case xdr.OperationTypeSetTrustLineFlags: @@ -691,7 +691,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, fromAddress := args.ContractIdPreimage.MustFromAddress() address, err := fromAddress.Address.String() if err != nil { - panic(fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type)) + return nil, fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type) } details["from"] = "address" details["address"] = address @@ -700,7 +700,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, details["from"] = "asset" details["asset"] = args.ContractIdPreimage.MustFromAsset().StringCanonical() default: - panic(fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type)) + return nil, fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type) } case xdr.HostFunctionTypeHostFunctionTypeCreateContractV2: args := op.HostFunction.MustCreateContractV2() @@ -709,7 +709,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, fromAddress := args.ContractIdPreimage.MustFromAddress() address, err := fromAddress.Address.String() if err != nil { - panic(fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type)) + return nil, fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type) } details["from"] = "address" details["address"] = address @@ -718,7 +718,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, details["from"] = "asset" details["asset"] = args.ContractIdPreimage.MustFromAsset().StringCanonical() default: - panic(fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type)) + return nil, fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type) } details["parameters"] = extractFunctionArgs(args.ConstructorArgs) @@ -730,14 +730,14 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, } case xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm: default: - panic(fmt.Errorf("unknown host function type: %s", op.HostFunction.Type)) + return nil, fmt.Errorf("unknown host function type: %s", op.HostFunction.Type) } case xdr.OperationTypeExtendFootprintTtl: op := operation.operation.Body.MustExtendFootprintTtlOp() details["extend_to"] = op.ExtendTo case xdr.OperationTypeRestoreFootprint: default: - panic(fmt.Errorf("unknown operation type: %s", operation.OperationType())) + return nil, fmt.Errorf("unknown operation type: %s", operation.OperationType()) } sponsor, err := operation.getSponsor() diff --git a/services/horizon/internal/integration/contracts/constructor/src/lib.rs b/services/horizon/internal/integration/contracts/constructor/src/lib.rs index 5935ed9162..08be44d001 100644 --- a/services/horizon/internal/integration/contracts/constructor/src/lib.rs +++ b/services/horizon/internal/integration/contracts/constructor/src/lib.rs @@ -15,10 +15,4 @@ impl Contract { env.storage().instance().set(&KEY, &2_u32); env.storage().temporary().set(&KEY, &3_u32); } - - pub fn get_data(env: Env, key: Symbol) -> u32 { - env.storage().persistent().get::<_, u32>(&key).unwrap() - + env.storage().instance().get::<_, u32>(&key).unwrap() - + env.storage().temporary().get::<_, u32>(&key).unwrap() - } } diff --git a/services/horizon/internal/integration/invokehostfunction_test.go b/services/horizon/internal/integration/invokehostfunction_test.go index 04d49626f2..216bc8607c 100644 --- a/services/horizon/internal/integration/invokehostfunction_test.go +++ b/services/horizon/internal/integration/invokehostfunction_test.go @@ -144,16 +144,10 @@ func TestContractInvokeHostFunctionCreateConstructorContract(t *testing.T) { asset := xdr.MustNewCreditAsset(code, issuer) createSAC(itest, asset) - // establish which account will be contract owner, and load it's current seq - sourceAccount, err := itest.Client().AccountDetail(horizonclient.AccountRequest{ - AccountID: itest.Master().Address(), - }) - require.NoError(t, err) - // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), constructor_contract) - preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) + preFlightOp, minFee := itest.PreflightHostFunctions(itest.MasterAccount(), *installContractOp) + itest.MustSubmitOperationsWithFee(itest.MasterAccount(), itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract senderAddressArg := accountAddressParam(itest.Master().Address()) @@ -174,8 +168,8 @@ func TestContractInvokeHostFunctionCreateConstructorContract(t *testing.T) { amount, }, ) - preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) + preFlightOp, minFee = itest.PreflightHostFunctions(itest.MasterAccount(), *createContractOp) + tx, err := itest.SubmitOperationsWithFee(itest.MasterAccount(), itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) contractID := preFlightOp.Ext.SorobanData.Resources.Footprint.ReadWrite[0].MustContractData().Contract.ContractId @@ -202,7 +196,7 @@ func TestContractInvokeHostFunctionCreateConstructorContract(t *testing.T) { invokeHostFunctionOpJson, ok := clientInvokeOp.Embedded.Records[0].(operations.InvokeHostFunction) assert.True(t, ok) assert.Equal(t, invokeHostFunctionOpJson.Function, "HostFunctionTypeHostFunctionTypeCreateContractV2") - assert.Equal(t, invokeHostFunctionOpJson.Address, sourceAccount.AccountID) + assert.Equal(t, invokeHostFunctionOpJson.Address, itest.Master().Address()) assert.Equal(t, invokeHostFunctionOpJson.Salt, "110986164698320180327942133831752629430491002266485370052238869825166557303060") assert.Len(t, invokeHostFunctionOpJson.Parameters, 3) diff --git a/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm b/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm index f0c92476bc..88ff28aa4e 100755 Binary files a/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm and b/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm differ