feat: update UIUX PKL to utilize optional fields

This commit is contained in:
Prad Nukala
2024-10-05 12:41:47 -04:00
parent 8e1359f126
commit b1e5464843
7 changed files with 7 additions and 250 deletions
-97
View File
@@ -1,97 +0,0 @@
@go.Package { name = "github.com/onsonr/sonr/pkg/dwn" }
module dwn
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
typealias JSON = String
class JsonField extends go.Field {
structTags {
["json"] = "%{name},omitempty"
}
}
class Config {
@JsonField
ipfs: IPFS
@JsonField
sonr: Sonr
@JsonField
motr: Motr
@JsonField
schema: Schema
@JsonField
proxyUrl: String
}
class IPFS {
@JsonField
apiUrl: String
@JsonField
gatewayUrl: String
}
class Motr {
@JsonField
keyshare: JSON
@JsonField
address: String
@JsonField
origin: String
}
class Schema {
version: Int
@JsonField
account: String
@JsonField
asset: String
@JsonField
chain: String
@JsonField
credential: String
@JsonField
jwk: String
@JsonField
grant: String
@JsonField
keyshare: String
@JsonField
profile: String
}
class Sonr {
@JsonField
apiUrl: String
@JsonField
grpcUrl: String
@JsonField
rpcUrl: String
@JsonField
webSocketUrl: String
@JsonField
chainId: String
}
-273
View File
@@ -1,273 +0,0 @@
@go.Package { name = "github.com/onsonr/sonr/pkg/orm" }
module orm
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
typealias Base58 = String
typealias Base64 = String
typealias Bech32 = String
typealias Keccak = String
typealias ChainCode = UInt
typealias Scope = String
typealias Hex = String
class PrimaryKey extends go.Field {
structTags {
["json"] = "%{name},omitempty"
["query"] = "%{name}"
}
}
class JsonField extends go.Field {
structTags {
["json"] = "%{name},omitempty"
}
}
// Enums
typealias AssetType = "native"|"wrapped"|"staking"|"pool"|"ibc"|"cw20"
typealias DIDMethod = "ipfs"|"sonr"|"bitcoin"|"ethereum"|"ibc"|"webauthn"|"dwn"|"service"
typealias KeyAlgorithm = "es256"|"es384"|"es512"|"eddsa"|"es256k"|"ecdsa"
typealias KeyCurve = "p256"|"p384"|"p521"|"x25519"|"x448"|"ed25519"|"ed448"|"secp256k1"|"bls12381"|"keccak256"
typealias KeyEncoding = "raw"|"hex"|"multibase"
typealias KeyRole = "authentication"|"assertion"|"delegation"|"invocation"
typealias KeyType = "octet"|"elliptic"|"rsa"|"symmetric"|"hmac"|"mpc"|"zk"|"webauthn"|"bip32"
typealias KeyShareRole = "user"|"validator"
typealias PermissionGrant = "none"|"read"|"write"|"verify"|"broadcast"|"admin"
typealias PermissionScope = "profile"|"metadata"|"permissions"|"wallets"|"transactions"|"user"|"validator"
class Account {
@PrimaryKey
id: String
@JsonField
name: String
@JsonField
address: Bech32|Keccak|String
@JsonField
publicKey: Base58
@JsonField
chainCode: ChainCode
@JsonField
index: Int
@JsonField
controller: Bech32
@JsonField
createdAt: String?
}
class Asset {
@PrimaryKey
id: String
@JsonField
name: String
@JsonField
symbol: String
@JsonField
decimals: Int
@JsonField
chainCode: ChainCode
@JsonField
createdAt: String?
}
class Chain {
@PrimaryKey
id: String
@JsonField
name: String
@JsonField
networkId: String
@JsonField
chainCode: ChainCode
@JsonField
createdAt: String?
}
class Credential {
@PrimaryKey
id: String
@JsonField
subject: String
@JsonField
controller: Bech32
@JsonField
attestationType: String
@JsonField
origin: String
@JsonField
label: String?
@JsonField
deviceId: String?
@JsonField
credentialId: Base64
@JsonField
publicKey: Base64
@JsonField
transport: List<String>
@JsonField
signCount: UInt
@JsonField
userPresent: Boolean
@JsonField
userVerified: Boolean
@JsonField
backupEligible: Boolean
@JsonField
backupState: Boolean
@JsonField
cloneWarning: Boolean
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
class DID {
@PrimaryKey
id: String
role: KeyRole
algorithm: KeyAlgorithm
encoding: KeyEncoding
curve: KeyCurve
key_type: KeyType
raw: Base64
jwk: JWK
}
class JWK {
@JsonField
kty: String
@JsonField
crv: String
@JsonField
x: String
@JsonField
y: String
@JsonField
n: String
@JsonField
e: String
}
class Grant {
@PrimaryKey
id: UInt
@JsonField
subject: String
@JsonField
controller: Bech32
@JsonField
origin: String
@JsonField
token: String
@JsonField
scopes: List<String>
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
class Keyshare {
@PrimaryKey
id: String
@JsonField
data: Base64
@JsonField
role: Int
@JsonField
createdAt: String?
@JsonField
lastRefreshed: String?
}
class Profile {
@PrimaryKey
id: String
@JsonField
subject: String
@JsonField
controller: Bech32
@JsonField
originUri: String?
@JsonField
publicMetadata: String?
@JsonField
privateMetadata: String?
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
db_name: String = "vault"
db_version: Int = 1
-174
View File
@@ -1,174 +0,0 @@
@go.Package { name = "github.com/onsonr/sonr/pkg/orm/transactions" }
module transactions
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
/// Common Cosmos SDK types
typealias Coin = Dynamic
typealias AccAddress = String
typealias ValAddress = String
typealias Timestamp = String
/// Base class for all messages
abstract class Msg {
/// The type URL for the message
typeUrl: String
}
/// Base class for all proposals
class Proposal {
/// The title of the proposal
title: String
/// The description of the proposal
description: String
}
/// Gov module messages
class MsgGovSubmitProposal extends Msg {
typeUrl = "/cosmos.gov.v1beta1.MsgSubmitProposal"
content: Proposal
initialDeposit: List<Coin>
proposer: AccAddress
}
class MsgGovVote extends Msg {
typeUrl = "/cosmos.gov.v1beta1.MsgVote"
proposalId: Int
voter: AccAddress
option: Int
}
class MsgGovDeposit extends Msg {
typeUrl = "/cosmos.gov.v1beta1.MsgDeposit"
proposalId: Int
depositor: AccAddress
amount: List<Coin>
}
/// Group module messages
class MsgGroupCreateGroup extends Msg {
typeUrl = "/cosmos.group.v1.MsgCreateGroup"
admin: AccAddress
members: List<Dynamic>
metadata: String
}
class MsgGroupSubmitProposal extends Msg {
typeUrl = "/cosmos.group.v1.MsgSubmitProposal"
groupPolicyAddress: AccAddress
proposers: List<AccAddress>
metadata: String
messages: List<Dynamic>
exec: Int
}
class MsgGroupVote extends Msg {
typeUrl = "/cosmos.group.v1.MsgVote"
proposalId: Int
voter: AccAddress
option: Int
metadata: String
exec: Int
}
/// Staking module messages
class MsgStakingCreateValidator extends Msg {
typeUrl = "/cosmos.staking.v1beta1.MsgCreateValidator"
description: Dynamic
commission: Dynamic
minSelfDelegation: String
delegatorAddress: AccAddress
validatorAddress: ValAddress
pubkey: Dynamic
value: Coin
}
class MsgStakingDelegate extends Msg {
typeUrl = "/cosmos.staking.v1beta1.MsgDelegate"
delegatorAddress: AccAddress
validatorAddress: ValAddress
amount: Coin
}
class MsgStakingUndelegate extends Msg {
typeUrl = "/cosmos.staking.v1beta1.MsgUndelegate"
delegatorAddress: AccAddress
validatorAddress: ValAddress
amount: Coin
}
class MsgStakingBeginRedelegate extends Msg {
typeUrl = "/cosmos.staking.v1beta1.MsgBeginRedelegate"
delegatorAddress: AccAddress
validatorSrcAddress: ValAddress
validatorDstAddress: ValAddress
amount: Coin
}
class MsgDidUpdateParams extends Msg {
typeUrl = "/sonr.did.v1.MsgUpdateParams"
authority: AccAddress
params: Dynamic
token: Dynamic
}
class MsgDidAllocateVault extends Msg {
typeUrl = "/sonr.did.v1.MsgAllocateVault"
authority: AccAddress
subject: String
token: Dynamic
}
class MsgDidProveWitness extends Msg {
typeUrl = "/sonr.did.v1.MsgProveWitness"
authority: AccAddress
property: String
witness: Listing<Int>
token: Dynamic
}
class MsgDidSyncVault extends Msg {
typeUrl = "/sonr.did.v1.MsgSyncVault"
controller: AccAddress
token: Dynamic
}
class MsgDidRegisterController extends Msg {
typeUrl = "/sonr.did.v1.MsgRegisterController"
authority: AccAddress
cid: String
origin: String
authentication: List<Dynamic>
token: Dynamic
}
class MsgDidAuthorize extends Msg {
typeUrl = "/sonr.did.v1.MsgAuthorize"
authority: AccAddress
controller: AccAddress
address: AccAddress
origin: String
token: Dynamic
}
class MsgDidRegisterService extends Msg {
typeUrl = "/sonr.did.v1.MsgRegisterService"
controller: AccAddress
originUri: String
scopes: Dynamic
description: String
serviceEndpoints: Map<String, String>
metadata: Dynamic
token: Dynamic
}
/// Represents a transaction body
class TxBody {
messages: List<Msg>
memo: String?
timeoutHeight: Int?
extensionOptions: List<Dynamic>?
nonCriticalExtensionOptions: List<Dynamic>?
}
-140
View File
@@ -1,140 +0,0 @@
@go.Package { name = "github.com/onsonr/sonr/pkg/nebula/models" }
module models
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
// ╭───────────────────────────────────────────────────────────╮
// │ General State │
// ╰───────────────────────────────────────────────────────────╯
typealias InputType = "text" | "password" | "email" | "credential" | "file"
class Button {
text: String
href: String
}
abstract class Form {
title: String
description: String
inputs: List<Input>
}
class Image {
src: String
width: String
height: String
}
class Input {
label: String
type: InputType
placeholder: String
value: String?
error: String?
help: String?
required: Boolean?
}
class Link {
text: String
href: String
}
class SocialLink {
link: Link
icon: String
}
// ╭───────────────────────────────────────────────────────────╮
// │ Data Models │
// ╰───────────────────────────────────────────────────────────╯
class Feature {
title: String
description: String
icon: String
image: Image
}
class Highlight {
title: String
description: String
image: Image
}
class Stat {
value: String
label: String
}
// ╭───────────────────────────────────────────────────────────╮
// │ Homepage View Model │
// ╰───────────────────────────────────────────────────────────╯
class Hero {
titleFirst: String
titleEmphasis: String
titleSecond: String
subtitle: String
primaryButton: Button
secondaryButton: Button
image: Image
stats: Listing<Stat>
}
class Highlights {
heading: String
subheading: String
highlights: Listing<Highlight>
}
class Features {
title: String
description: String
image: Image
}
class Bento {
title: String
description: String
primaryButton: Button
secondaryButton: Button
}
class Lowlights {
title: String
description: String
image: Image
}
class CallToAction {
title: String
description: String
primaryButton: Button
secondaryButton: Button
}
class Footer {
logo: Image
mediumLink: SocialLink
twitterLink: SocialLink
discordLink: SocialLink
githubLink: SocialLink
companyLinks: Listing<Link>
resourcesLinks: Listing<Link>
}
class Home {
hero: Hero
highlights: Listing<Highlight>
features: Listing<Features>
bento: Bento
lowlights: Listing<Lowlights>
callToAction: CallToAction
footer: Footer
}
home : Home