Files
nebula/models/auth.go

104 lines
2.2 KiB
Go

package models
// AppInfo represents an application requesting authorization
type AppInfo struct {
Name string
Domain string
LogoIcon string
Verified bool
}
// WalletInfo represents a user's wallet details
type WalletInfo struct {
Name string
Address string
Balance string
}
// TokenAmount represents a token amount with its value
type TokenAmount struct {
Symbol string
Amount string
USD string
Initials string
}
// TxDetails represents transaction details for authorization
type TxDetails struct {
Type string
FromToken TokenAmount
ToToken TokenAmount
Network string
NetworkFee string
MaxFee string
Slippage string
Contract string
Function string
RawData string
}
// AuthRequest represents an authorization request from an app
type AuthRequest struct {
Type string
App AppInfo
Wallet WalletInfo
Message string
MessageHex string
Transaction *TxDetails
}
// DefaultAuthRequest returns a sample authorization request for testing
func DefaultAuthRequest(reqType string) AuthRequest {
if reqType == "" {
reqType = "connect"
}
return AuthRequest{
Type: reqType,
App: AppInfo{
Name: "Uniswap",
Domain: "app.uniswap.org",
LogoIcon: "cube",
Verified: true,
},
Wallet: WalletInfo{
Name: "Main Wallet",
Address: "sonr1x9f...7k2m",
Balance: "1,234.56 SNR",
},
Message: `Welcome to Uniswap!
Click to sign in and accept the Uniswap Terms of Service.
This request will not trigger a blockchain transaction or cost any gas fees.
Wallet address:
sonr1x9f4h2k8m3n5p7q2r4s6t8v0w3x5y7z9a1b3c5d7k2m
Nonce: 8f4a2b1c`,
MessageHex: "0x57656c636f6d6520746f20556e697377617021...",
Transaction: &TxDetails{
Type: "Swap",
FromToken: TokenAmount{
Symbol: "ETH",
Amount: "100.00",
USD: "$234,567.00",
Initials: "E",
},
ToToken: TokenAmount{
Symbol: "USDC",
Amount: "125,000",
USD: "$125,000.00",
Initials: "U",
},
Network: "Sonr Mainnet",
NetworkFee: "~$0.12",
MaxFee: "$0.26",
Slippage: "0.5%",
Contract: "0x7a25...3f8b",
Function: "swapExactTokensForTokens()",
RawData: "0x38ed1739\n0000000000000000000000000000000000000056bc75e2d63100000...",
},
}
}