Documentation
¶
Index ¶
- Constants
- Variables
- func Add0x(address string) string
- func CheckBasicURLValidation(rawURL string) error
- func CheckIfURLIsValid(rawURL string) error
- func CheckIfValidTwitterURL(twitterURL string) error
- func EcdsaPrivateKeyToAddress(privateKey *ecdsa.PrivateKey) (gethcommon.Address, error)
- func IsImageURL(urlString string) error
- func IsValidEthereumAddress(address string) bool
- func ReadFile(path string) ([]byte, error)
- func ReadJSONConfig(path string, o interface{}) error
- func ReadPublicURL(url string) ([]byte, error)
- func ReadYamlConfig(path string, o interface{}) error
- func RoundUpDivideBig(a, b *big.Int) *big.Int
- func Trim0x(address string) string
- func TypedErr(e interface{}) error
- func ValidateRawGithubURL(url string) error
- func ValidateText(text string) error
- func WrapError(mainErr interface{}, subErr interface{}) error
Constants ¶
View Source
const ( PngMimeType = "image/png" TextRegex = `^[a-zA-Z0-9 +.,;:?!'’"\-_/()\[\]~&#$—%]+$` )
Variables ¶
View Source
var ( ErrInvalidURL = errors.New("invalid url") ErrInvalidGithubRawURL = errors.New("invalid github raw url") ErrInvalidText = fmt.Errorf("invalid text format, doesn't conform to regex %s", TextRegex) ErrTextTooLong = errors.New("text should be less than 500 characters") ErrEmptyText = errors.New("text is empty") ErrInvalidImageExtension = errors.New( "invalid image extension. only " + strings.Join(ImageExtensions, ",") + " is supported", ) ErrInvalidImageMimeType = errors.New("invalid image mime-type. only png is supported") ErrInvalidURLLength = errors.New("url length should be no larger than 1024 character") ErrURLPointingToLocalServer = errors.New("url should not point to local server") ErrEmptyURL = errors.New("url is empty") ErrInvalidTwitterURLRegex = errors.New( "invalid twitter url, it should be of the format https://twitter.com/<username> or https://x.com/<username>", ) ErrResponseTooLarge = errors.New("response too large, allowed size is 1 MB") )
View Source
var ( // ImageExtensions List of common image file extensions // Only support PNG for now to reduce surface area of image validation // We do NOT want to support formats like SVG since they can be used for javascript injection // If we get pushback on only supporting png, we can support jpg, jpeg, gif, etc. later ImageExtensions = []string{".png"} )
Functions ¶
func CheckBasicURLValidation ¶
func CheckIfURLIsValid ¶
func CheckIfValidTwitterURL ¶
func EcdsaPrivateKeyToAddress ¶
func EcdsaPrivateKeyToAddress(privateKey *ecdsa.PrivateKey) (gethcommon.Address, error)
func IsImageURL ¶
func IsValidEthereumAddress ¶
func ReadJSONConfig ¶
func ReadPublicURL ¶
func ReadYamlConfig ¶
func ValidateRawGithubURL ¶
func ValidateText ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.