APIs
Store
Settings.tsx
useTheme
Light
or Dark
)useEndpoint
Tezos endpoint URL
useContractAddress
KT1...
)useNetwork
Ghostnet
) for Beacon to useuseIPFSBrowser
IPFS endpoint URL
useGitRepo
Code repository URL
useSetTheme
Taquito.tsx
useTezosToolkit
Beacon.tsx
useWalletAddress
undefined
if not logged in)useWalletName
undefined
if not logged in)useIsConnected
true
if user is logged in, false
otherwiseuseConnect
useDisconnect
Contract.tsx
useContract
Polls.tsx
usePolls
useLoadData
useLoadResponses
get_responses
viewAlerts.tsx
useAlertOpen
useAlertMsg
useAlertSetOpen
useAlertSetMsg
Events.tsx
useEvents
useNbNewEvents
useAddEvent
useClearEvents
UI hierarchy
.
└── App
└── DApp
├── Router
│ ├── AddPage
│ │ ├── AddForm
│ │ └── PollPreview
│ │ └── PollPanel
│ ├── PickPage
│ │ └── [PollCard]
│ └── PollPage
│ └── PollPanel
│ └── [ChoicePanel]
└── TopBar
├── EventNotifications
│ ├── [EventCard]
│ └── NotificationMenu
├── GitHubLink
├── LoginButton
│ └── WalletInfo
├── TezosIcon
└── ThemeSwitch
Contract's binding
Interacting with the poll contract is done via the generated bindings.
The following Completium CLI command generates the contract bindings:
completium-cli generate binding-dapp-ts ./poll_contract/contracts/poll.arl > ./src/binding/poll.ts
The following mockup code presents the generated Poll
TypeScript API:
class Poll {
/*
Contract address is passed to the constructor
*/
constructor Poll(address?: string | undefined): Poll
// utils
get_address(): Address
get_balance(): Promise<Tez>
/*
Entries from Ownership template
*/
declare_ownership(candidate: Address, params: Partial<Parameters>): Promise<any>
claim_ownership(params: Partial<Parameters>): Promise<any>
/*
Entries from Pausable template
*/
pause(params: Partial<Parameters>): Promise<any>
unpause(params: Partial<Parameters>): Promise<any>
/*
Entries from Metadata template
*/
set_metadata(k: string, d: Option<Bytes>, params: Partial<Parameters>): Promise<any>
/*
Poll specific entries
*/
add_poll(h: Bytes, params: Partial<Parameters>): Promise<any>
approve(h: Bytes, params: Partial<Parameters>): Promise<any>
disapprove(h: Bytes, params: Partial<Parameters>): Promise<any>
remove(pk: Nat, params: Partial<Parameters>): Promise<any>
respond(pk: Nat, choice_id: Nat, params: Partial<Parameters>): Promise<any>
/*
Entries' CallParameter makers for batch operations
*/
get_declare_ownership_param(candidate: Address, params: Partial<Parameters>): Promise<CallParameter>
get_claim_ownership_param(params: Partial<Parameters>): Promise<CallParameter>
get_pause_param(params: Partial<Parameters>): Promise<CallParameter>
get_unpause_param(params: Partial<Parameters>): Promise<CallParameter>
get_set_metadata_param(k: string, d: Option<Bytes>, params: Partial<Parameters>): Promise<CallParameter>
get_add_poll_param(h: Bytes, params: Partial<Parameters>): Promise<CallParameter>
get_approve_param(h: Bytes, params: Partial<Parameters>): Promise<CallParameter>
get_disapprove_param(h: Bytes, params: Partial<Parameters>): Promise<CallParameter>
get_remove_param(pk: Nat, params: Partial<Parameters>): Promise<CallParameter>
get_respond_param(pk: Nat, choice_id: Nat, params: Partial<Parameters>): Promise<CallParameter>
/*
Views
*/
view_get_responses(pk: Nat, params: Partial<Parameters>): Promise<Array<[ Nat, Nat ]>>
view_already_responded(pk: Nat, params: Partial<Parameters>): Promise<boolean>
/*
Storage elements getters
*/
get_owner(): Promise<Address>
get_owner_candidate(): Promise<Option<Address>>
get_paused(): Promise<boolean>
get_polls_counter(): Promise<Nat>
get_poll(): Promise<poll_container>
get_poll_to_approve_value(key: poll_to_approve_key): Promise<poll_to_approve_value | undefined>
has_poll_to_approve_value(key: poll_to_approve_key): Promise<boolean>
get_responder_value(key: responder_key): Promise<responder_value | undefined>
has_responder_value(key: responder_key): Promise<boolean>
get_metadata_value(key: string): Promise<Bytes | undefined>
has_metadata_value(key: string): Promise<boolean>
register_Response(ep: el.EventProcessor<Response>): void
/*
Event register utils
*/
register_NewPoll(ep: el.EventProcessor<NewPoll>): void
register_ApprovePoll(ep: el.EventProcessor<ApprovePoll>): void
/*
Errors
*/
(property) Poll.errors: {
f1: Micheline;
r3: Micheline;
r2: Micheline;
INVALID_CALLER: Micheline;
POLL_NOT_FOUND: Micheline;
r1: Micheline;
md_r1: Micheline;
pausable_r2: Micheline;
pausable_r1: Micheline;
ownership_r1: Micheline;
CONTRACT_PAUSED: Micheline;
}
}