Skip to content

Commit

Permalink
fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
trestinlsd committed Jan 4, 2025
1 parent 1358d10 commit 89eff6f
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 98 deletions.
24 changes: 12 additions & 12 deletions precompiles/assets/decode_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
20 changes: 10 additions & 10 deletions precompiles/avs/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()))
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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())
Expand All @@ -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[:]
Expand All @@ -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())
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion precompiles/avs/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
38 changes: 19 additions & 19 deletions precompiles/avs/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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[:]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
Loading

0 comments on commit 89eff6f

Please sign in to comment.