Members
(constant) CONTRACT_ABI :Object
Contract ABI
Type:
- Object
- Source:
(constant) CONTRACT_ADDRESS :string
Address of the contract on BSC chain
Type:
- string
- Source:
(constant) delay
This function is for delaying the code for a while.
- Source:
Example
delay(3000)
// Code delays for 3 seconds
(constant) MAIN_CONTEXT_ID :string
DOM id of the main holder for all screen components that will be rendered in web-app.
Type:
- string
- Source:
(constant) UPDATE_POST_ID_FETCH_TAG :string
This is the tag for Post id fetch update event
Type:
- string
- Source:
(constant) UPDATE_STATUS_EVENT_TAG :string
This is the tag for Status update event
Type:
- string
- Source:
(constant) UPDATE_STATUS_POST_LOAD_TAG :string
This is the tag for Post loading status update event
Type:
- string
- Source:
Methods
createPostTimeLineInterface(postList) → {Array.<PostCard>}
This function generates and returns the PostCard list for all the posts in the list
Parameters:
| Name | Type | Description |
|---|---|---|
postList |
Array.<Post> | Array of posts |
- Source:
- See:
Returns:
- Array of PostCard elements
- Type
- Array.<PostCard>
Example
let ui = createPostTimeLineInterface(window.postBank);
getLastIntentData() → {*}
This function is to get the last data that was passed in the intent.
- Source:
- See:
Returns:
- Type
- *
Example
let data = getLastIntentData()
(async) getPosts(limit) → {Promise.<string>|Promise.<Array.<Post>>}
This function loads post data from the contract and passes it from the promise
Parameters:
| Name | Type | Description |
|---|---|---|
limit |
number | The number of posts you want to load. 0 or <0 will fetch all the posts. |
- Source:
- See:
Returns:
-
- Type
- Promise.<string>
-
- Type
- Promise.<Array.<Post>>
Example
getPosts(5).then({list}=>{
console.log(e);
})
//returns top 5 latest posts
getPosts().then({list}=>{
console.log(e);
})
//returns all the posts
getPosts(-1).then({list}=>{
console.log(e);
})
//returns all the posts
getPostsFromBlockChain(holder, target, limit)
This function fetches data of all the posts in the limit range and passes to the target via intent.
Parameters:
| Name | Type | Description |
|---|---|---|
holder |
Element | The main holder element |
target |
JSX.Element | The element to render post rendering |
limit |
limit | The number of posts you want to load |
- Source:
Example
getPostsFromBlockChain(document.getElementById(MAIN_CONTEXT_ID), <TimeLine/>);
//Get all the posts in the client and pass it to the intent
or
getPostsFromBlockChain(document.getElementById(MAIN_CONTEXT_ID), <TimeLine/>, 5);
// Get 5 latest posts in the client and pass it to the intent
Intent(target, element, data) → {Promise.<boolean>}
This function is used to load an element in a holder element and also set some data which can be later used.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
Element | The holder i.e. the element in which the new element will be loaded |
element |
JSX.Element | The element that will be loaded |
data |
* | The data that will be loaded for later use |
- Source:
- See:
Returns:
- Type
- Promise.<boolean>
Example
Intent(document.getElementById('root'), <SplashScreen statusUpdateEvent={UpdateStatusEventTag}/>)
.then((r)=>{console.log(r)});
(async) loadContract() → {Promise.<*>}
This function returns the contract after loading it
- Source:
Returns:
- Type
- Promise.<*>
Example
window.contract = await loadContract();
(async) loadPosts(limit) → {Promise.<string>}
This function loads post data from the contract to the global variables.
Parameters:
| Name | Type | Description |
|---|---|---|
limit |
number | The number of posts you want to load. 0 or <0 will fetch all the posts. |
- Source:
- See:
Returns:
- Type
- Promise.<string>
Example
let list = loadPosts(5)
//returns top 5 latest posts
let list2 = loadPosts()
//returns all the posts
let list3 = loadPosts(-1)
//returns all the posts
(async) loadReadOnlyMode() → {Promise.<string>}
This function loads the web-app in read-only mode when the web3 provider is missing from the browser.
- Source:
Returns:
- Type
- Promise.<string>
Example
await loadReadOnlyMode();
(async) LoadWeb3() → {Promise.<string>}
This function loads the web3 provider, asks for connection, connects to the contract and prepares everything before loading the web-app
- Source:
- See:
Returns:
- Type
- Promise.<string>
Example
loadWeb3().then((r)=>{
console.log(r)
}).catch((e)=>{
console.log(e)
})
ShowNotification(alert)
This function displays notification in the web-app.
Parameters:
| Name | Type | Description |
|---|---|---|
alert |
AlertNotification | AlterNotification Object that needs to be displayed. |
- Source:
- See:
Example
ShowNotification(<AlertNotification theme={"danger"} message={msg}/>);
sortByNewTimeStampFirst(list) → {Array.<Post>}
Thus function is used to sort post list according to the timestamp in "descending" order.
Parameters:
| Name | Type | Description |
|---|---|---|
list |
Array.<Post> | List of all the posts |
- Source:
- See:
Returns:
- Type
- Array.<Post>
Example
let sortedList = sortByNewTimeStampFirst(list)
// returns sorted list by timestamp
updateAllPostsFromBlockChain(holder, target, limit)
This function loads all the post data from the contract to the client. Call this function to update all the post data
Parameters:
| Name | Type | Description |
|---|---|---|
holder |
Element | The main holder element |
target |
JSX.Element | The element to render post rendering |
limit |
limit | The number of posts you want to load |
- Source:
Example
updateAllPostsFromBlockChain(document.getElementById(MAIN_CONTEXT_ID), <TimeLine/>);
//updates all the posts in the client
or
updateAllPostsFromBlockChain(document.getElementById(MAIN_CONTEXT_ID), <TimeLine/>, 5);
//updates 5 latest posts in the client.