Documentation
¶
Index ¶
- Constants
- func APIResponse(ctx *gin.Context, httpCode int, status string, message string, ...)
- func AbsPercentageDeviation(trueValue, measuredValue decimal.Decimal) decimal.Decimal
- func BigMin(x, y *big.Int) *big.Int
- func Byte32ToString(b [32]byte) string
- func ContainsString(slice []string, item string) bool
- func DecodeOrderCreatedEvent(log types.Log) (map[string]interface{}, error)
- func DecodeOrderRefundedEvent(log types.Log) (map[string]interface{}, error)
- func DecodeOrderSettledEvent(log types.Log) (map[string]interface{}, error)
- func DecodeTransferEvent(log types.Log) (map[string]interface{}, error)
- func Difference(a, b []string) []string
- func FormatTimestampToGMT1(timestamp time.Time) (string, error)
- func FromSubunit(amountInSubunit *big.Int, decimals int8) decimal.Decimal
- func GetErrorData(err error) []types.ErrorData
- func GetErrorMsg(fe validator.FieldError) string
- func GetInstitutionByCode(ctx context.Context, institutionCode string, enabledFiatCurrency bool) (*ent.Institution, error)
- func GetPaymasterAccount(chainId int64) (string, error)
- func GetTokenRateFromQueue(tokenSymbol string, orderAmount decimal.Decimal, fiatCurrency string, ...) (decimal.Decimal, error)
- func GetUserOperationByReceipt(userOpHash string, chainId int64) (map[string]interface{}, error)
- func GetUserOperationStatus(userOpHash string, chainId int64) (bool, error)
- func HexToDecimal(hexStr string) decimal.Decimal
- func InitializeUserOperation(ctx context.Context, client types.RPCClient, rpcUrl, sender, salt string) (*userop.UserOperation, error)
- func IsBase64(s string) bool
- func IsURL(s string) bool
- func IsValidEthereumAddress(address string) bool
- func IsValidFileURL(url string) bool
- func IsValidHttpsUrl(urlStr string) bool
- func IsValidMobileNumber(number string) bool
- func IsValidTronAddress(address string) bool
- func MapToStruct(m map[string]interface{}, s interface{}) error
- func Median(data []decimal.Decimal) decimal.Decimal
- func Paginate(ctx *gin.Context) (page int, offset int, limit int)
- func ParseJSONResponse(res *http.Response) (map[string]interface{}, error)
- func ParseTopicToBigInt(paddedHexString string) *big.Int
- func ParseTopicToByte32(paddedHexString string) [32]byte
- func ParseTopicToTronAddress(paddedHexString string) string
- func PersonalSign(message string, privateKey *ecdsa.PrivateKey) ([]byte, error)
- func ProcessRPCEvents(events []interface{}, eventSignature string) error
- func ProcessRPCEventsBySignature(events []interface{}) error
- func Retry(attempts int, sleep time.Duration, fn func() error) error
- func SendPaymentOrderWebhook(ctx context.Context, paymentOrder *ent.PaymentOrder) error
- func SendUserOperation(userOp *userop.UserOperation, chainId int64) (string, string, int64, error)
- func SignUserOperation(userOperation *userop.UserOperation, chainId int64) error
- func SponsorUserOperation(userOp *userop.UserOperation, mode string, token string, chainId int64) error
- func StringToByte32(s string) [32]byte
- func StructToMap(input interface{}) map[string]interface{}
- func ToSubunit(amount decimal.Decimal, decimals int8) *big.Int
- func UnpackEventData(paddedHexString, contractABI, eventName string) ([]interface{}, error)
Constants ¶
const ( HTTP_RETRY_ATTEMPTS = 3 HTTP_RETRY_INTERVAL = 5 )
const ( TransferEventSignature = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" OrderCreatedEventSignature = "0x40ccd1ceb111a3c186ef9911e1b876dc1f789ed331b86097b3b8851055b6a137" OrderSettledEventSignature = "0x98ece21e01a01cbe1d1c0dad3b053c8fbd368f99be78be958fcf1d1d13fd249a" OrderRefundedEventSignature = "0x0736fe428e1747ca8d387c2e6fa1a31a0cde62d3a167c40a46ade59a3cdc828e" )
Event signatures for Gateway contract events
Variables ¶
This section is empty.
Functions ¶
func APIResponse ¶
APIResponse is a helper function to return an API response
func AbsPercentageDeviation ¶
AbsPercentageDeviation returns the absolute percentage deviation between two values
func Byte32ToString ¶
Byte32ToString converts [32]byte to string
func ContainsString ¶
ContainsString returns true if the slice contains the given string
func DecodeOrderCreatedEvent ¶
DecodeOrderCreatedEvent decodes an OrderCreated event from RPC log
func DecodeOrderRefundedEvent ¶
DecodeOrderRefundedEvent decodes an OrderRefunded event from RPC log
func DecodeOrderSettledEvent ¶
DecodeOrderSettledEvent decodes an OrderSettled event from RPC log
func DecodeTransferEvent ¶
DecodeTransferEvent decodes a Transfer event from RPC log
func Difference ¶
Difference returns the elements in `a` that aren't in `b`.
func FormatTimestampToGMT1 ¶
FormatTimestampToGMT1 formats the timestamp to GMT+1 (Africa/Lagos time zone) and returns a formatted string.
func FromSubunit ¶
FromSubunit converts an amount in subunits represented as a *big.Int back to its decimal representation with the given number of decimal places (decimals). It returns the amount as a decimal.Decimal.
func GetErrorData ¶
GetErrorData returns a list of error data
func GetErrorMsg ¶
func GetErrorMsg(fe validator.FieldError) string
GetErrorMsg returns a list of meaningful error messages from binding tags. Reference: https://blog.logrocket.com/gin-binding-in-go-a-tutorial-with-examples/
func GetInstitutionByCode ¶
func GetInstitutionByCode(ctx context.Context, institutionCode string, enabledFiatCurrency bool) (*ent.Institution, error)
GetInstitutionByCode returns the institution for a given institution code
func GetPaymasterAccount ¶
GetPaymasterAccount returns the paymaster account for the given chain ID
func GetTokenRateFromQueue ¶
func GetTokenRateFromQueue(tokenSymbol string, orderAmount decimal.Decimal, fiatCurrency string, marketRate decimal.Decimal) (decimal.Decimal, error)
GetTokenRateFromQueue gets the rate of a token from the priority queue
func GetUserOperationByReceipt ¶
GetUserOperationByReceipt fetches the user operation by hash
func GetUserOperationStatus ¶
GetUserOperationStatus returns the status of the user operation
func HexToDecimal ¶
HexToDecimal converts a hex string to a decimal.Decimal
func InitializeUserOperation ¶
func InitializeUserOperation(ctx context.Context, client types.RPCClient, rpcUrl, sender, salt string) (*userop.UserOperation, error)
Initialize user operation with defaults
func IsValidEthereumAddress ¶
IsValidEthereumAddress checks if a string is a valid Ethereum address
func IsValidFileURL ¶
IsValidFileURL checks if a URL is a valid file URL
(supports only file urls ending with .jpg, .jpeg, .png, or .pdf)
func IsValidHttpsUrl ¶
Helper function to validate HTTPS URL
func IsValidMobileNumber ¶
IsValidMobileNumber checks if a string is a valid mobile number
func IsValidTronAddress ¶
IsValidTronAddress checks if a string is a valid Tron address
func MapToStruct ¶
func Paginate ¶
Paginate parses the pagination query params and returns the offset(page) and limit(pageSize)
func ParseJSONResponse ¶
ParseJSONResponse parses a JSON response
func ParseTopicToBigInt ¶
ParseTopicToBigInt converts a padded hex string to a big.Int
func ParseTopicToByte32 ¶
ParseTopicToByte32 converts a padded hex string to a [32]byte
func ParseTopicToTronAddress ¶
ParseTopicToTronAddress converts a padded hex string to a Tron address
func PersonalSign ¶
func PersonalSign(message string, privateKey *ecdsa.PrivateKey) ([]byte, error)
PersonalSign is an equivalent of ethers.personal_sign for signing ethereum messages Ref: https://github.com/etaaa/Golang-Ethereum-Personal-Sign/blob/main/main.go
func ProcessRPCEvents ¶
ProcessRPCEvents processes RPC events and converts them to the same format as Thirdweb Insight
func ProcessRPCEventsBySignature ¶
func ProcessRPCEventsBySignature(events []interface{}) error
ProcessRPCEventsBySignature processes RPC events and automatically detects their signature for decoding
func Retry ¶
Retry is a function that attempts to execute a given function multiple times until it succeeds or the maximum number of attempts is reached. It sleeps for a specified duration between each attempt. Parameters: - attempts: The maximum number of attempts to execute the function. - sleep: The duration to sleep between each attempt. - fn: The function to be executed. Returns: - error: The error returned by the function, if any.
func SendPaymentOrderWebhook ¶
func SendPaymentOrderWebhook(ctx context.Context, paymentOrder *ent.PaymentOrder) error
SendPaymentOrderWebhook notifies a sender when the status of a payment order changes
func SendUserOperation ¶
SendUserOperation sends the user operation
func SignUserOperation ¶
func SignUserOperation(userOperation *userop.UserOperation, chainId int64) error
SignUserOperation signs the user operation
func SponsorUserOperation ¶
func SponsorUserOperation(userOp *userop.UserOperation, mode string, token string, chainId int64) error
SponsorUserOperation sponsors the user operation with different AA services
func StringToByte32 ¶
StringToByte32 converts string to [32]byte
func StructToMap ¶
func StructToMap(input interface{}) map[string]interface{}
StructToMap converts a struct to a map[string]interface{}
func ToSubunit ¶
ToSubunit converts a decimal amount to the smallest subunit representation. It takes the amount and the number of decimal places (decimals) and returns the amount in subunits as a *big.Int.
func UnpackEventData ¶
UnpackEventData unpacks the data from a padded hex string using the ABI
Types ¶
This section is empty.