github.com/ethersphere/bee/v2@v2.2.0/pkg/util/abiutil/abiutil.go (about)

     1  // Copyright 2022 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package abiutil
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  
    11  	"github.com/ethereum/go-ethereum/accounts/abi"
    12  )
    13  
    14  // MustParseABI parses is the same as calling abi.JSON
    15  // but panics on error (if the given ABI is invalid).
    16  func MustParseABI(json string) abi.ABI {
    17  	val, err := abi.JSON(strings.NewReader(json))
    18  	if err != nil {
    19  		panic(fmt.Errorf("unable to parse ABI: %w", err))
    20  	}
    21  	return val
    22  }