diff --git a/ts-interfaces/examples/plasa-query.ts b/ts-interfaces/examples/plasa-query.ts new file mode 100644 index 0000000..6f87dd7 --- /dev/null +++ b/ts-interfaces/examples/plasa-query.ts @@ -0,0 +1,86 @@ +import { Plasa } from "../types/plasa" +import { StampType } from "../types/stamps" + +const examplePlasaQuery: Plasa = { + data: { + contractAddress: "0x1234567890123456789012345678901234567890", + chainId: 1, + version: "1.0.0" + }, + user: { + username: "alice" + }, + stamps: [ + { + data: { + contractAddress: "0xabcdef1234567890abcdef1234567890abcdef12", + type: StampType.AccountOwnership, + name: "Twitter Account Ownership", + symbol: "TWO", + platform: "Twitter", + totalSupply: 1000000 + }, + user: { + owns: true, + stampId: "123456", + mintingTimestamp: 1625097600000 + }, + userUsername: "alice_twitter" + }, + { + data: { + contractAddress: "0x9876543210fedcba9876543210fedcba98765432", + type: StampType.FollowerSince, + name: "Early Follower", + symbol: "EF", + platform: "Twitter", + totalSupply: 5000, + followedAccount: "0x1111222233334444555566667777888899990000", + space: "CryptoNews" + }, + user: { + owns: true, + stampId: "789012", + mintingTimestamp: 1625184000000, + followTimestamp: 1625097600000, + timeSinceFollow: 86400000 // 1 day in milliseconds + } + } + ], + spaces: [ + { + data: { + contractAddress: "0x1111222233334444555566667777888899990000", + name: "CryptoNews", + description: "Latest news and updates in the crypto space", + imageUrl: "https://example.com/crypto-news.png", + creationTimestamp: 1625000000000 + }, + user: { + roles: { + superAdmin: false, + admin: true, + mod: true + }, + permissions: { + UpdateSpaceInfo: true, + UpdateSpaceDefaultPoints: true, + UpdateQuestionInfo: true, + UpdateQuestionDeadline: true, + UpdateQuestionPoints: true, + CreateFixedQuestion: true, + CreateOpenQuestion: true, + VetoFixedQuestion: true, + VetoOpenQuestion: true, + VetoOpenQuestionOption: true, + LiftVetoFixedQuestion: true, + LiftVetoOpenQuestion: true, + LiftVetoOpenQuestionOption: true, + AddOpenQuestionOption: true + } + } + } + ] +} + +console.log(JSON.stringify(examplePlasaQuery, null, 2)) diff --git a/ts-interfaces/examples/question-query.ts b/ts-interfaces/examples/question-query.ts new file mode 100644 index 0000000..f8bee57 --- /dev/null +++ b/ts-interfaces/examples/question-query.ts @@ -0,0 +1,62 @@ +import { Question, QuestionType } from "../types/questions" + +const exampleQuestionQuery: Question = { + data: { + contractAddress: "0x1111aaaabbbbccccddddeeeeffffgggg2222hhhh", + type: QuestionType.Fixed, + title: "Should we implement EIP-1559?", + description: "Vote on whether to implement Ethereum Improvement Proposal 1559", + creator: "0x3333444455556666777788889999aaaabbbbcccc", + kickoff: 1625270400000, + deadline: 1625875200000, + isActive: true, + voteCount: 1500 + }, + user: { + canVote: true, + pointsAtDeadline: 950 + }, + options: [ + { + data: { + title: "Yes, implement EIP-1559", + description: "Support the implementation of EIP-1559 to improve gas fee predictability", + proposer: "0x7777888899990000aaaabbbbccccddddeeeefffff", + voteCount: 850, + pointsCurrent: 75000, + pointsAtDeadline: 72000 + }, + user: { + voted: false + } + }, + { + data: { + title: "No, don't implement EIP-1559", + description: "Oppose the implementation of EIP-1559 due to concerns about miner revenue", + proposer: "0xbbbbccccddddeeeefffff00001111222233334444", + voteCount: 600, + pointsCurrent: 55000, + pointsAtDeadline: 53000 + }, + user: { + voted: false + } + }, + { + data: { + title: "Delay implementation for further research", + description: "Postpone the decision on EIP-1559 to allow for more research and discussion", + proposer: "0xddddeeeefffff000011112222333344445555666", + voteCount: 50, + pointsCurrent: 5000, + pointsAtDeadline: 4800 + }, + user: { + voted: false + } + } + ] +} + +console.log(JSON.stringify(exampleQuestionQuery, null, 2)) diff --git a/ts-interfaces/examples/space-query.ts b/ts-interfaces/examples/space-query.ts new file mode 100644 index 0000000..dfdad4c --- /dev/null +++ b/ts-interfaces/examples/space-query.ts @@ -0,0 +1,83 @@ +import { Space } from "../types/spaces" +import { QuestionType } from "../types/questions" + +const exampleSpaceQuery: Space = { + data: { + contractAddress: "0xaaaa1111bbbb2222cccc3333dddd4444eeee5555", + name: "Crypto Governance", + description: "A space for discussing and voting on crypto governance proposals", + imageUrl: "https://example.com/crypto-governance.png", + creationTimestamp: 1620000000000 + }, + user: { + roles: { + superAdmin: false, + admin: true, + mod: true + }, + permissions: { + UpdateSpaceInfo: true, + UpdateSpaceDefaultPoints: true, + UpdateQuestionInfo: true, + UpdateQuestionDeadline: true, + UpdateQuestionPoints: true, + CreateFixedQuestion: true, + CreateOpenQuestion: true, + VetoFixedQuestion: true, + VetoOpenQuestion: true, + VetoOpenQuestionOption: true, + LiftVetoFixedQuestion: true, + LiftVetoOpenQuestion: true, + LiftVetoOpenQuestionOption: true, + AddOpenQuestionOption: true + } + }, + points: { + data: { + contractAddress: "0xffff9999gggg8888hhhh7777iiii6666jjjj5555", + name: "Governance Points", + symbol: "GP" + }, + user: { + currentBalance: 1000 + } + }, + questions: [ + { + data: { + contractAddress: "0x1111aaaabbbbccccddddeeeeffffgggg2222hhhh", + type: QuestionType.Fixed, + title: "Should we implement EIP-1559?", + description: "Vote on whether to implement Ethereum Improvement Proposal 1559", + creator: "0x3333444455556666777788889999aaaabbbbcccc", + kickoff: 1625270400000, + deadline: 1625875200000, + isActive: true, + voteCount: 1500 + }, + user: { + canVote: true, + pointsAtDeadline: 950 + } + }, + { + data: { + contractAddress: "0x4444iiiijjjjkkkkllllmmmmnnnnoooo5555pppp", + type: QuestionType.Open, + title: "What should be our next focus area?", + description: "Propose and vote on the next major focus area for our project", + creator: "0x6666777788889999aaaabbbbccccddddeeeefffff", + kickoff: 1625356800000, + deadline: 1626048000000, + isActive: true, + voteCount: 750 + }, + user: { + canVote: true, + pointsAtDeadline: 1000 + } + } + ] +} + +console.log(JSON.stringify(exampleSpaceQuery, null, 2)) diff --git a/ts-interfaces/types/basic.ts b/ts-interfaces/types/basic.ts new file mode 100644 index 0000000..72c73b4 --- /dev/null +++ b/ts-interfaces/types/basic.ts @@ -0,0 +1,2 @@ +export type AccountAddress = string +export type Timestamp = number diff --git a/ts-interfaces/types/options.ts b/ts-interfaces/types/options.ts new file mode 100644 index 0000000..002e5f2 --- /dev/null +++ b/ts-interfaces/types/options.ts @@ -0,0 +1,19 @@ +import { AccountAddress } from './basic' + +export interface OptionData { + title: string + description: string + proposer: AccountAddress + voteCount: number + pointsCurrent: number + pointsAtDeadline: number +} + +export interface OptionUser { + voted: boolean +} + +export interface Option { + data: OptionData + user: OptionUser +} diff --git a/ts-interfaces/types/plasa.ts b/ts-interfaces/types/plasa.ts new file mode 100644 index 0000000..55ee693 --- /dev/null +++ b/ts-interfaces/types/plasa.ts @@ -0,0 +1,22 @@ +import { AccountAddress } from './basic' +import { SpacePreview } from './spaces' +import { Stamp, FollowerSinceStamp, AccountOwnershipStamp } from './stamps' + +export interface PlasaData { + contractAddress: AccountAddress + chainId: number + version: string +} + +export interface PlasaUser { + username: string +} + +export interface Plasa { + data: PlasaData + user: PlasaUser + stamps: (Stamp | FollowerSinceStamp | AccountOwnershipStamp)[] + spaces: SpacePreview[] +} + +export type ViewReturnType = Plasa diff --git a/ts-interfaces/types/points.ts b/ts-interfaces/types/points.ts new file mode 100644 index 0000000..689923f --- /dev/null +++ b/ts-interfaces/types/points.ts @@ -0,0 +1,16 @@ +import { AccountAddress } from './basic' + +export interface PointsData { + contractAddress: AccountAddress + name: string + symbol: string +} + +export interface PointsUser { + currentBalance: number +} + +export interface Points { + data: PointsData + user: PointsUser +} diff --git a/ts-interfaces/types/questions.ts b/ts-interfaces/types/questions.ts new file mode 100644 index 0000000..899f0e1 --- /dev/null +++ b/ts-interfaces/types/questions.ts @@ -0,0 +1,33 @@ +import { AccountAddress, Timestamp } from './basic' +import { Option } from './options' + +export enum QuestionType { + Open = 'Open', + Fixed = 'Fixed', +} + +export interface QuestionData { + contractAddress: AccountAddress + type: QuestionType + title: string + description: string + creator: AccountAddress + kickoff: Timestamp + deadline: Timestamp + isActive: boolean + voteCount: number +} + +export interface QuestionUser { + canVote: boolean + pointsAtDeadline: number +} + +export interface QuestionPreview { + data: QuestionData + user: QuestionUser +} + +export interface Question extends QuestionPreview { + options: Option[] +} diff --git a/ts-interfaces/types/spaces.ts b/ts-interfaces/types/spaces.ts new file mode 100644 index 0000000..5ad8099 --- /dev/null +++ b/ts-interfaces/types/spaces.ts @@ -0,0 +1,45 @@ +import { AccountAddress, Timestamp } from './basic' +import { Points } from './points' +import { QuestionPreview } from './questions' + +export interface SpaceData { + contractAddress: AccountAddress + name: string + description: string + imageUrl: string + creationTimestamp: Timestamp +} + +export interface SpaceUser { + roles: { + superAdmin: boolean + admin: boolean + mod: boolean + } + permissions: { + UpdateSpaceInfo: boolean + UpdateSpaceDefaultPoints: boolean + UpdateQuestionInfo: boolean + UpdateQuestionDeadline: boolean + UpdateQuestionPoints: boolean + CreateFixedQuestion: boolean + CreateOpenQuestion: boolean + VetoFixedQuestion: boolean + VetoOpenQuestion: boolean + VetoOpenQuestionOption: boolean + LiftVetoFixedQuestion: boolean + LiftVetoOpenQuestion: boolean + LiftVetoOpenQuestionOption: boolean + AddOpenQuestionOption: boolean + } +} + +export interface SpacePreview { + data: SpaceData + user: SpaceUser +} + +export interface Space extends SpacePreview { + points: Points + questions: QuestionPreview[] +} diff --git a/ts-interfaces/types/stamps.ts b/ts-interfaces/types/stamps.ts new file mode 100644 index 0000000..8eb1fe1 --- /dev/null +++ b/ts-interfaces/types/stamps.ts @@ -0,0 +1,45 @@ +import { AccountAddress, Timestamp } from './basic' + +export enum StampType { + AccountOwnership = 'AccountOwnership', + FollowerSince = 'FollowerSince', +} + +export interface StampData { + contractAddress: AccountAddress + type: StampType + name: string + symbol: string + platform: string + totalSupply: number +} + +export interface StampUser { + owns: boolean + stampId?: string + mintingTimestamp?: Timestamp +} + +export interface Stamp { + data: StampData + user: StampUser +} + +export interface FollowerSinceStampData extends StampData { + followedAccount: string + space: string +} + +export interface FollowerSinceStampUser extends StampUser { + followTimestamp: Timestamp + timeSinceFollow: number +} + +export interface FollowerSinceStamp extends Stamp { + data: FollowerSinceStampData + user: FollowerSinceStampUser +} + +export interface AccountOwnershipStamp extends Stamp { + userUsername?: string +}