diff --git a/precompiles/assets/decode_helper.go b/precompiles/assets/decode_helper.go index 0f51688db..b65b44ced 100644 --- a/precompiles/assets/decode_helper.go +++ b/precompiles/assets/decode_helper.go @@ -33,7 +33,7 @@ func (ta *TypedArgs) GetUint8(index int) (uint8, error) { } val, ok := ta.args[index].(uint8) if !ok { - return 0, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "uint8", ta.args[index]) + return 0, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "uint8", ta.args[index]) } return val, nil } @@ -44,7 +44,7 @@ func (ta *TypedArgs) GetUint32(index int) (uint32, error) { } val, ok := ta.args[index].(uint32) if !ok { - return 0, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "uint32", ta.args[index]) + return 0, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "uint32", ta.args[index]) } return val, nil } @@ -55,7 +55,7 @@ func (ta *TypedArgs) GetBytes(index int) ([]byte, error) { } val, ok := ta.args[index].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "[]byte", ta.args[index]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "[]byte", ta.args[index]) } return val, nil } @@ -66,7 +66,7 @@ func (ta *TypedArgs) GetString(index int) (string, error) { } val, ok := ta.args[index].(string) if !ok { - return "", fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "string", ta.args[index]) + return "", fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "string", ta.args[index]) } return val, nil } @@ -77,7 +77,7 @@ func (ta *TypedArgs) GetBigInt(index int) (*big.Int, error) { } val, ok := ta.args[index].(*big.Int) if !ok || val == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "*big.Int", ta.args[index]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "*big.Int", ta.args[index]) } return val, nil } @@ -88,7 +88,7 @@ func (ta *TypedArgs) GetEVMAddress(index int) (common.Address, error) { } val, ok := ta.args[index].(common.Address) if !ok { - return common.Address{}, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "address", ta.args[index]) + return common.Address{}, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "address", ta.args[index]) } return val, nil } @@ -99,7 +99,7 @@ func (ta *TypedArgs) GetEVMAddressSlice(index int) ([]common.Address, error) { } val, ok := ta.args[index].([]common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "[]common.Address", ta.args[index]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "[]common.Address", ta.args[index]) } return val, nil } @@ -110,7 +110,7 @@ func (ta *TypedArgs) GetPositiveUint8(index int) (uint8, error) { return 0, err } if val == 0 { - return 0, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "uint8", ta.args[index]) + return 0, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "uint8", ta.args[index]) } return val, nil } @@ -121,7 +121,7 @@ func (ta *TypedArgs) GetPositiveUint32(index int) (uint32, error) { return 0, err } if val == 0 { - return 0, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "uint32", ta.args[index]) + return 0, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "uint32", ta.args[index]) } return val, nil } @@ -132,7 +132,7 @@ func (ta *TypedArgs) GetRequiredBytes(index int) ([]byte, error) { return nil, err } if len(val) == 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "[]byte", ta.args[index]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "[]byte", ta.args[index]) } return val, nil } @@ -143,7 +143,7 @@ func (ta *TypedArgs) GetRequiredString(index int) (string, error) { return "", err } if len(val) == 0 { - return "", fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "string", ta.args[index]) + return "", fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "string", ta.args[index]) } return val, nil } @@ -154,7 +154,7 @@ func (ta *TypedArgs) GetPositiveBigInt(index int) (*big.Int, error) { return nil, err } if val.Sign() <= 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, index, "*big.Int", ta.args[index]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, index, "*big.Int", ta.args[index]) } return val, nil } diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 00cb46213..52b3b0521 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -40,7 +40,7 @@ func (p Precompile) GetRegisteredPubkey( } addr, ok := args[0].(string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "string", addr) } blsPubKeyInfo, err := p.avsKeeper.GetOperatorPubKey(ctx, addr) if err != nil { @@ -64,7 +64,7 @@ func (p Precompile) GetOptedInOperatorAccAddrs( addr, ok := args[0].(common.Address) if !ok || addr == (common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "string", addr) } list, err := p.avsKeeper.GetOperatorKeeper().GetOptedInOperatorListByAVS(ctx, strings.ToLower(addr.String())) @@ -86,7 +86,7 @@ func (p Precompile) GetAVSUSDValue( } addr, ok := args[0].(common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", addr) } amount, err := p.avsKeeper.GetOperatorKeeper().GetAVSUSDValue(ctx, addr.String()) if err != nil { @@ -110,11 +110,11 @@ func (p Precompile) GetOperatorOptedUSDValue( } avsAddr, ok := args[0].(common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", avsAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", avsAddr) } operatorAddr, ok := args[1].(string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", operatorAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "string", operatorAddr) } amount, err := p.avsKeeper.GetOperatorKeeper().GetOperatorOptedUSDValue(ctx, strings.ToLower(avsAddr.String()), operatorAddr) if err != nil { @@ -137,7 +137,7 @@ func (p Precompile) GetAVSEpochIdentifier( } addr, ok := args[0].(common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", addr) } avs, err := p.avsKeeper.GetAVSInfo(ctx, addr.String()) @@ -163,7 +163,7 @@ func (p Precompile) IsOperator( } operatorAddr, ok := args[0].(common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", operatorAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", operatorAddr) } param := operatorAddr[:] @@ -183,11 +183,11 @@ func (p Precompile) GetTaskInfo( } addr, ok := args[0].(common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", addr) } taskID, ok := args[1].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", taskID) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "uint64", taskID) } task, err := p.avsKeeper.GetTaskInfo(ctx, strconv.FormatUint(taskID, 10), addr.String()) @@ -215,7 +215,7 @@ func (p Precompile) GetCurrentEpoch( } epochIdentifier, ok := args[0].(string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", epochIdentifier) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "string", epochIdentifier) } epoch, flag := p.avsKeeper.GetEpochKeeper().GetEpochInfo(ctx, epochIdentifier) if !flag { diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index b712b0831..530233f66 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -84,7 +84,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetOptedInOperatorAccAddrs() { postCheck: func(bz []byte) {}, gas: 100000, expErr: true, - errContains: fmt.Sprintf(exocmn.ErrContractInputParaOrType, 0, "string", "0x0000000000000000000000000000000000000000"), + errContains: fmt.Sprintf(exocmn.ErrContractInputParamOrType, 0, "string", "0x0000000000000000000000000000000000000000"), }, { "success - no operators", diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 94eb5ead4..c899e4862 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -75,12 +75,12 @@ func (p Precompile) DeregisterAVS( avsParams := &avstypes.AVSRegisterOrDeregisterParams{} callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } avsParams.CallerAddress = callerAddress[:] avsName, ok := args[1].(string) if !ok || avsName == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", avsName) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "string", avsName) } avsParams.AvsName = avsName @@ -146,7 +146,7 @@ func (p Precompile) BindOperatorToAVS( } callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } operatorParams := &avstypes.OperatorOptParams{} @@ -176,7 +176,7 @@ func (p Precompile) UnbindOperatorToAVS( } callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } operatorParams := &avstypes.OperatorOptParams{} operatorParams.OperatorAddress = callerAddress[:] @@ -232,31 +232,31 @@ func (p Precompile) Challenge( challengeParams.TaskContractAddress = contract.CallerAddress callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } challengeParams.CallerAddress = callerAddress[:] taskHash, ok := args[1].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", taskHash) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "[]byte", taskHash) } challengeParams.TaskHash = taskHash taskID, ok := args[2].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "uint64", taskID) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "uint64", taskID) } challengeParams.TaskID = taskID taskResponseHash, ok := args[3].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", taskResponseHash) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "[]byte", taskResponseHash) } challengeParams.TaskResponseHash = taskResponseHash operatorAddress, ok := args[4].(string) if !ok || operatorAddress == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "string", operatorAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 4, "string", operatorAddress) } operator, err := sdk.AccAddressFromBech32(operatorAddress) if err != nil { @@ -290,30 +290,30 @@ func (p Precompile) RegisterBLSPublicKey( blsParams := &avstypes.BlsParams{} callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } blsParams.OperatorAddress = callerAddress[:] name, ok := args[1].(string) if !ok || name == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", name) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "string", name) } blsParams.Name = name pubkeyBz, ok := args[2].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", pubkeyBz) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", pubkeyBz) } blsParams.PubKey = pubkeyBz pubkeyRegistrationSignature, ok := args[3].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", pubkeyRegistrationSignature) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "[]byte", pubkeyRegistrationSignature) } blsParams.PubkeyRegistrationSignature = pubkeyRegistrationSignature pubkeyRegistrationMessageHash, ok := args[4].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "[]byte", pubkeyRegistrationMessageHash) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 4, "[]byte", pubkeyRegistrationMessageHash) } blsParams.PubkeyRegistrationMessageHash = pubkeyRegistrationMessageHash @@ -344,19 +344,19 @@ func (p Precompile) OperatorSubmitTask( callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } resultParams.CallerAddress = callerAddress[:] taskID, ok := args[1].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", args[1]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "uint64", args[1]) } resultParams.TaskID = taskID taskResponse, ok := args[2].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", taskResponse) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", taskResponse) } resultParams.TaskResponse = taskResponse @@ -366,13 +366,13 @@ func (p Precompile) OperatorSubmitTask( blsSignature, ok := args[3].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", blsSignature) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "[]byte", blsSignature) } resultParams.BlsSignature = blsSignature taskAddr, ok := args[4].(common.Address) if !ok || (taskAddr == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "common.Address", taskAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 4, "common.Address", taskAddr) } resultParams.TaskContractAddress = taskAddr diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index ad5b277a8..83909372b 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -21,49 +21,49 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* // in a long term: https://docs.soliditylang.org/en/latest/security-considerations.html#tx-origin callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } avsParams.CallerAddress = callerAddress[:] avsName, ok := args[1].(string) if !ok || avsName == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", avsName) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "string", avsName) } avsParams.AvsName = avsName // When creating tasks in AVS, check the minimum requirements,minStakeAmount at least greater than 0 minStakeAmount, ok := args[2].(uint64) if !ok || minStakeAmount == 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "uint64", minStakeAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "uint64", minStakeAmount) } avsParams.MinStakeAmount = minStakeAmount taskAddr, ok := args[3].(common.Address) if !ok || taskAddr == (common.Address{}) { - return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 3, "common.Address", taskAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParamOrType, 3, "common.Address", taskAddr) } avsParams.TaskAddr = taskAddr slashContractAddr, ok := args[4].(common.Address) if !ok || (slashContractAddr == common.Address{}) { - return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 4, "common.Address", slashContractAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParamOrType, 4, "common.Address", slashContractAddr) } avsParams.SlashContractAddr = slashContractAddr rewardContractAddr, ok := args[5].(common.Address) if !ok || (rewardContractAddr == common.Address{}) { - return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 5, "common.Address", rewardContractAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParamOrType, 5, "common.Address", rewardContractAddr) } avsParams.RewardContractAddr = rewardContractAddr // bech32 avsOwnerAddress, ok := args[6].([]string) if !ok || avsOwnerAddress == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 6, "[]string", avsOwnerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 6, "[]string", avsOwnerAddress) } exoAddresses := make([]string, len(avsOwnerAddress)) for i, addr := range avsOwnerAddress { accAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 6, "[]string", avsOwnerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 6, "[]string", avsOwnerAddress) } exoAddresses[i] = accAddr.String() } @@ -71,13 +71,13 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* // bech32 whitelistAddress, ok := args[7].([]string) if !ok || whitelistAddress == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 7, "[]string", whitelistAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 7, "[]string", whitelistAddress) } exoWhiteAddresses := make([]string, len(whitelistAddress)) for i, addr := range whitelistAddress { accAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 7, "[]string", whitelistAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 7, "[]string", whitelistAddress) } exoWhiteAddresses[i] = accAddr.String() } @@ -85,25 +85,25 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* // string, since it is the address_id representation assetID, ok := args[8].([]string) if !ok || len(assetID) == 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 8, "[]string", assetID) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 8, "[]string", assetID) } avsParams.AssetID = assetID unbondingPeriod, ok := args[9].(uint64) if !ok || unbondingPeriod == 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 9, "uint64", unbondingPeriod) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 9, "uint64", unbondingPeriod) } avsParams.UnbondingPeriod = unbondingPeriod minSelfDelegation, ok := args[10].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 10, "uint64", minSelfDelegation) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 10, "uint64", minSelfDelegation) } avsParams.MinSelfDelegation = minSelfDelegation epochIdentifier, ok := args[11].(string) if !ok || epochIdentifier == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 11, "string", epochIdentifier) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 11, "string", epochIdentifier) } avsParams.EpochIdentifier = epochIdentifier @@ -112,7 +112,7 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* taskParam, ok := args[12].([]uint64) if !ok || taskParam == nil || len(taskParam) != 4 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 12, "[]string", taskParam) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 12, "[]string", taskParam) } minOptInOperators := taskParam[0] avsParams.MinOptInOperators = minOptInOperators @@ -136,50 +136,50 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface avsParams := &avstypes.AVSRegisterOrDeregisterParams{} callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } avsParams.CallerAddress = callerAddress[:] avsName, ok := args[1].(string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", avsName) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "string", avsName) } avsParams.AvsName = avsName // When creating tasks in AVS, check the minimum requirements,minStakeAmount at least greater than 0 minStakeAmount, ok := args[2].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "uint64", minStakeAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "uint64", minStakeAmount) } avsParams.MinStakeAmount = minStakeAmount taskAddr, ok := args[3].(common.Address) if !ok || taskAddr == (common.Address{}) { - return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 3, "common.Address", taskAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParamOrType, 3, "common.Address", taskAddr) } avsParams.TaskAddr = taskAddr slashContractAddr, ok := args[4].(common.Address) if !ok { - return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 4, "common.Address", slashContractAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParamOrType, 4, "common.Address", slashContractAddr) } avsParams.SlashContractAddr = slashContractAddr rewardContractAddr, ok := args[5].(common.Address) if !ok { - return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 5, "common.Address", rewardContractAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParamOrType, 5, "common.Address", rewardContractAddr) } avsParams.RewardContractAddr = rewardContractAddr // bech32 avsOwnerAddress, ok := args[6].([]string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 6, "[]string", avsOwnerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 6, "[]string", avsOwnerAddress) } exoAddresses := make([]string, len(avsOwnerAddress)) for i, addr := range avsOwnerAddress { accAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 6, "[]string", avsOwnerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 6, "[]string", avsOwnerAddress) } exoAddresses[i] = accAddr.String() } @@ -187,13 +187,13 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface // bech32 whitelistAddress, ok := args[7].([]string) if !ok || whitelistAddress == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 7, "[]string", whitelistAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 7, "[]string", whitelistAddress) } exoWhiteAddresses := make([]string, len(whitelistAddress)) for i, addr := range whitelistAddress { accAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 7, "[]string", whitelistAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 7, "[]string", whitelistAddress) } exoAddresses[i] = accAddr.String() } @@ -201,25 +201,25 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface // string, since it is the address_id representation assetID, ok := args[8].([]string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 8, "[]string", assetID) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 8, "[]string", assetID) } avsParams.AssetID = assetID unbondingPeriod, ok := args[9].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 9, "uint64", unbondingPeriod) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 9, "uint64", unbondingPeriod) } avsParams.UnbondingPeriod = unbondingPeriod minSelfDelegation, ok := args[10].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 10, "uint64", minSelfDelegation) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 10, "uint64", minSelfDelegation) } avsParams.MinSelfDelegation = minSelfDelegation epochIdentifier, ok := args[11].(string) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 11, "string", epochIdentifier) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 11, "string", epochIdentifier) } avsParams.EpochIdentifier = epochIdentifier @@ -228,7 +228,7 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface taskParam, ok := args[12].([]uint64) if !ok || taskParam == nil || len(taskParam) != 4 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 12, "[]string", taskParam) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 12, "[]string", taskParam) } minOptInOperators := taskParam[0] avsParams.MinOptInOperators = minOptInOperators @@ -252,42 +252,42 @@ func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) ( taskParams := &avstypes.TaskInfoParams{} callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "common.Address", callerAddress) } taskParams.CallerAddress = callerAddress[:] name, ok := args[1].(string) if !ok || name == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", name) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "string", name) } taskParams.TaskName = name hash, ok := args[2].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", hash) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", hash) } taskParams.Hash = hash taskResponsePeriod, ok := args[3].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "uint64", taskResponsePeriod) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "uint64", taskResponsePeriod) } taskParams.TaskResponsePeriod = taskResponsePeriod taskChallengePeriod, ok := args[4].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "uint64", taskChallengePeriod) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 4, "uint64", taskChallengePeriod) } taskParams.TaskChallengePeriod = taskChallengePeriod thresholdPercentage, ok := args[5].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, "uint64", thresholdPercentage) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 5, "uint64", thresholdPercentage) } taskParams.ThresholdPercentage = thresholdPercentage taskStatisticalPeriod, ok := args[6].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 6, "uint64", taskStatisticalPeriod) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 6, "uint64", taskStatisticalPeriod) } taskParams.TaskStatisticalPeriod = taskStatisticalPeriod return taskParams, nil diff --git a/precompiles/delegation/tx.go b/precompiles/delegation/tx.go index f2d399716..0ca524589 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -113,7 +113,7 @@ func (p Precompile) AssociateOperatorWithStaker( } clientChainID, ok := args[0].(uint32) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "uint32", args[0]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "uint32", args[0]) } info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, uint64(clientChainID)) @@ -123,7 +123,7 @@ func (p Precompile) AssociateOperatorWithStaker( clientChainAddrLength := info.AddressLength staker, ok := args[1].([]byte) if !ok || staker == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", args[1]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "[]byte", args[1]) } // #nosec G115 if uint32(len(staker)) < clientChainAddrLength { @@ -133,7 +133,7 @@ func (p Precompile) AssociateOperatorWithStaker( operator, ok := args[2].([]byte) if !ok || operator == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", args[2]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", args[2]) } operatorAccAddr, err := sdk.AccAddressFromBech32(string(operator)) if err != nil { @@ -165,7 +165,7 @@ func (p Precompile) DissociateOperatorFromStaker( } clientChainID, ok := args[0].(uint32) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "uint32", args[0]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "uint32", args[0]) } info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, uint64(clientChainID)) if err != nil { @@ -175,7 +175,7 @@ func (p Precompile) DissociateOperatorFromStaker( staker, ok := args[1].([]byte) if !ok || staker == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", args[1]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "[]byte", args[1]) } // #nosec G115 if uint32(len(staker)) < clientChainAddrLength { diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index 51d094d37..8ccb152dc 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -22,7 +22,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf delegationParams := &delegationtypes.DelegationOrUndelegationParams{} clientChainID, ok := args[0].(uint32) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "uint32", args[0]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "uint32", args[0]) } delegationParams.ClientChainID = uint64(clientChainID) @@ -34,14 +34,14 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf txLzNonce, ok := args[1].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", args[1]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "uint64", args[1]) } delegationParams.LzNonce = txLzNonce // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[2].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", args[2]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", args[2]) } // #nosec G115 if uint32(len(assetAddr)) < clientChainAddrLength { @@ -51,7 +51,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf stakerAddr, ok := args[3].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", args[3]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "[]byte", args[3]) } // #nosec G115 if uint32(len(stakerAddr)) < clientChainAddrLength { @@ -62,7 +62,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf // the input operator address is cosmos accAddress type,so we need to check the length and decode it through Bench32 operatorAddr, ok := args[4].([]byte) if !ok || operatorAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "[]byte", args[4]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 4, "[]byte", args[4]) } if len(operatorAddr) != types.ExoCoreOperatorAddrLength { return nil, fmt.Errorf(exocmn.ErrInputOperatorAddrLength, len(operatorAddr), types.ExoCoreOperatorAddrLength) @@ -76,7 +76,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf opAmount, ok := args[5].(*big.Int) if !ok || opAmount == nil || !(opAmount.Cmp(big.NewInt(0)) == 1) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, "*big.Int", args[5]) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 5, "*big.Int", args[5]) } delegationParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) return delegationParams, nil diff --git a/precompiles/reward/parser.go b/precompiles/reward/parser.go index b161e86d4..187a33674 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -20,7 +20,7 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ rewardParams := &keeper.RewardParams{} clientChainLzID, ok := args[0].(uint32) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "uint32", clientChainLzID) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "uint32", clientChainLzID) } rewardParams.ClientChainLzID = uint64(clientChainLzID) @@ -33,7 +33,7 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[1].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", assetAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "[]byte", assetAddr) } // #nosec G115 if uint32(len(assetAddr)) < clientChainAddrLength { @@ -43,7 +43,7 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ stakerAddr, ok := args[2].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", stakerAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", stakerAddr) } // #nosec G115 if uint32(len(stakerAddr)) < clientChainAddrLength { @@ -53,7 +53,7 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ opAmount, ok := args[3].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "*big.Int", opAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "*big.Int", opAmount) } rewardParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index c110a9481..13d5ab3f5 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -19,7 +19,7 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} slashParams := &keeper.SlashParams{} clientChainLzID, ok := args[0].(uint32) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "uint32", clientChainLzID) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 0, "uint32", clientChainLzID) } slashParams.ClientChainLzID = uint64(clientChainLzID) @@ -32,7 +32,7 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[1].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", assetAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 1, "[]byte", assetAddr) } // #nosec G115 if uint32(len(assetAddr)) < clientChainAddrLength { @@ -42,7 +42,7 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} stakerAddr, ok := args[2].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", stakerAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 2, "[]byte", stakerAddr) } // #nosec G115 if uint32(len(stakerAddr)) < clientChainAddrLength { @@ -52,7 +52,7 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} opAmount, ok := args[3].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "*big.Int", opAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "*big.Int", opAmount) } slashParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount)