Skip to main content

APIs

Store

Settings.tsx


useTheme

Theme mode (Light or Dark)


useEndpoint

Tezos endpoint URL


useContractAddress

Poll contract address (KT1...)


useNetwork

Network (for ex. Ghostnet) for Beacon to use


useIPFSBrowser

IPFS endpoint URL


useGitRepo

Code repository URL


useSetTheme

Theme setter


Taquito.tsx


useTezosToolkit

Taquito's Tezos Toolkit


Beacon.tsx


useWalletAddress

Wallet address (or undefined if not logged in)


useWalletName

Wallet name (or undefined if not logged in)


useIsConnected

Function that returns true if user is logged in, false otherwise


useConnect

Beacon's connect service


useDisconnect

Beacon's disconnect service


Contract.tsx


useContract

Returns contract binder


Polls.tsx


usePolls

List of polls


useLoadData

Function to fetch polls' data from contract


useLoadResponses

Function to fetch polls' responses from contract via the get_responses view


Alerts.tsx


useAlertOpen

Alert state (open/close) otherwise


useAlertMsg

Alert message to display


useAlertSetOpen

Function to set alert state


useAlertSetMsg

Function to set alert message


Events.tsx


useEvents

List of events


useNbNewEvents

Number of new events


useAddEvent

Function to add a new event to the notification menu


useClearEvents

Function to remove all events


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;
}
}