Documentation ¶
Index ¶
- Constants
- func CheckRecipient(recipient string) (string, error)
- func FormatPhoneNumber(phone string) (string, error)
- func GetTemporaryVoucherData(ctx context.Context, store DataStore, sessionId string) (*dataserviceapi.TokenHoldings, error)
- func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, index int) (string, error)
- func GetVoucherData(ctx context.Context, db storage.PrefixDb, input string) (*dataserviceapi.TokenHoldings, error)
- func IsSameHex(left string, right string) bool
- func IsValidAddress(address string) bool
- func IsValidAlias(alias string) bool
- func IsValidPhoneNumber(phonenumber string) bool
- func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol, balance, decimal, address string)
- func NormalizeHex(s string) (string, error)
- func PackKey(typ DataTyp, data []byte) []byte
- func ParseAndScaleAmount(storedAmount, activeDecimal string) (string, error)
- func ScaleDownBalance(balance, decimals string) string
- func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId string, ...) error
- func StoreToDb(store *UserDataStore) db.Db
- func StoreToPrefixDb(store *UserDataStore, pfx []byte) storage.PrefixDb
- func ToBytes[T ~uint16 | int](value T) []byte
- func UpdateVoucherData(ctx context.Context, store DataStore, sessionId string, ...) error
- type DataStore
- type DataTyp
- type StorageService
- type StorageServices
- type TransactionData
- type TransferMetadata
- type UserDataStore
- type VoucherMetadata
Constants ¶
const ( // API Tracking id to follow status of account creation DATA_TRACKING_ID = iota // EVM address returned from API on account creation DATA_PUBLIC_KEY // Currently active PIN used to authenticate ussd state change requests DATA_ACCOUNT_PIN // The first name of the user DATA_FIRST_NAME // The last name of the user DATA_FAMILY_NAME // The year-of-birth of the user DATA_YOB // The location of the user DATA_LOCATION // The gender of the user DATA_GENDER // The offerings description of the user DATA_OFFERINGS // The ethereum address of the recipient of an ongoing send request DATA_RECIPIENT // The voucher value amount of an ongoing send request DATA_AMOUNT // A general swap field for temporary values DATA_TEMPORARY_VALUE // Currently active voucher symbol of user DATA_ACTIVE_SYM // Voucher balance of user's currently active voucher DATA_ACTIVE_BAL // String boolean indicating whether use of PIN is blocked DATA_BLOCKED_NUMBER // Reverse mapping of a user's evm address to a session id. DATA_PUBLIC_KEY_REVERSE // Decimal count of the currently active voucher DATA_ACTIVE_DECIMAL // EVM address of the currently active voucher DATA_ACTIVE_ADDRESS )
const ( DATA_TX_SENDERS = 512 + iota // List of recipients for valid transactions in the user context. DATA_TX_RECIPIENTS // List of voucher values for valid transactions in the user context. DATA_TX_VALUES // List of voucher EVM addresses for valid transactions in the user context. DATA_TX_ADDRESSES // List of valid transaction hashes in the user context. DATA_TX_HASHES // List of transaction dates for valid transactions in the user context. DATA_TX_DATES // List of voucher symbols for valid transactions in the user context. DATA_TX_SYMBOLS // List of voucher decimal counts for valid transactions in the user context. DATA_TX_DECIMALS )
Variables ¶
This section is empty.
Functions ¶
func CheckRecipient ¶
CheckRecipient validates the recipient format based on the criteria
func FormatPhoneNumber ¶
FormatPhoneNumber formats a Kenyan phone number to "+254xxxxxxxx".
func GetTemporaryVoucherData ¶
func GetTemporaryVoucherData(ctx context.Context, store DataStore, sessionId string) (*dataserviceapi.TokenHoldings, error)
GetTemporaryVoucherData retrieves temporary voucher metadata from the DataStore.
func GetTransferData ¶
func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, index int) (string, error)
GetTransferData retrieves and matches transfer data returns a formatted string of the full transaction/statement
func GetVoucherData ¶
func GetVoucherData(ctx context.Context, db storage.PrefixDb, input string) (*dataserviceapi.TokenHoldings, error)
GetVoucherData retrieves and matches voucher data
func IsValidAddress ¶
IsValidAddress checks if the given address is a valid Ethereum address
func IsValidAlias ¶
IsValidAlias checks if the alias is a valid alias format
func IsValidPhoneNumber ¶
IsValidPhoneNumber checks if the given number is a valid phone number
func MatchVoucher ¶
func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol, balance, decimal, address string)
MatchVoucher finds the matching voucher symbol, balance, decimals and contract address based on the input.
func NormalizeHex ¶
func ParseAndScaleAmount ¶
func ScaleDownBalance ¶
func StoreTemporaryVoucher ¶
func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error
StoreTemporaryVoucher saves voucher metadata as temporary entries in the DataStore.
func StoreToDb ¶
func StoreToDb(store *UserDataStore) db.Db
func StoreToPrefixDb ¶
func StoreToPrefixDb(store *UserDataStore, pfx []byte) storage.PrefixDb
func UpdateVoucherData ¶
func UpdateVoucherData(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error
UpdateVoucherData updates the active voucher data in the DataStore.
Types ¶
type DataTyp ¶
type DataTyp uint16
DataType is a subprefix value used in association with vise/db.DATATYPE_USERDATA.
All keys are used only within the context of a single account. Unless otherwise specified, the user context is the session id.
* The first byte is vise/db.DATATYPE_USERDATA * The last 2 bytes are the DataTyp value, big-endian. * The intermediate bytes are the id of the user context.
All values are strings
const ( // List of valid voucher symbols in the user context. DATA_VOUCHER_SYMBOLS DataTyp = 256 + iota // List of voucher balances for vouchers valid in the user context. DATA_VOUCHER_BALANCES // List of voucher decimal counts for vouchers valid in the user context. DATA_VOUCHER_DECIMALS // List of voucher EVM addresses for vouchers valid in the user context. DATA_VOUCHER_ADDRESSES )
func StringToDataTyp ¶
type StorageService ¶
type StorageService struct {
// contains filtered or unexported fields
}
func NewStorageService ¶
func NewStorageService(dbDir string) *StorageService
func (*StorageService) EnsureDbDir ¶
func (ss *StorageService) EnsureDbDir() error
func (*StorageService) GetPersister ¶
func (*StorageService) GetResource ¶
func (*StorageService) GetUserdataDb ¶
type StorageServices ¶
type TransactionData ¶
type TransactionData struct { TemporaryValue string ActiveSym string Amount string PublicKey string Recipient string ActiveDecimal string ActiveAddress string }
func ReadTransactionData ¶
type TransferMetadata ¶
type TransferMetadata struct { Senders string Recipients string TransferValues string Addresses string TxHashes string Dates string Symbols string Decimals string }
TransferMetadata helps organize data fields
func ProcessTransfers ¶
func ProcessTransfers(transfers []dataserviceapi.Last10TxResponse) TransferMetadata
ProcessTransfers converts transfers into formatted strings
type UserDataStore ¶
func (*UserDataStore) ReadEntry ¶
func (store *UserDataStore) ReadEntry(ctx context.Context, sessionId string, typ DataTyp) ([]byte, error)
ReadEntry retrieves an entry to the userdata store.
func (*UserDataStore) WriteEntry ¶
func (store *UserDataStore) WriteEntry(ctx context.Context, sessionId string, typ DataTyp, value []byte) error
WriteEntry adds an entry to the userdata store. BUG: this uses sessionId twice
type VoucherMetadata ¶
VoucherMetadata helps organize data fields
func ProcessVouchers ¶
func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata
ProcessVouchers converts holdings into formatted strings