Highlight.js
Highlight.js is the official Typescript SDK to interact with Highlight.
Installation
Highlight.js is an NPM package that can be installed through the following command:
npm install @snapshot-labs/highlight@beta
Init client
import { Client } from '@snapshot-labs/highlight';
import { Wallet } from '@ethersproject/wallet';
const signer = Wallet.createRandom();
export const client = new Client({
url: 'https://testnet.highlight.red/highlight/relayer',
signer
});
Profiles
Set profile
const receipt = await client.profiles.setProfile({
user: '0xeF8305E140ac520225DAf050e2f71d5fBcC543e7',
name: 'Fabien',
about: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.',
twitter: 'bonustrack87',
discord: 'less#1234',
telegram: 'bonustrack',
github: 'bonustrack'
});
Set statement
const receipt = await client.profiles.setStatement({
user: '0xeF8305E140ac520225DAf050e2f71d5fBcC543e7',
org: 'fabien.eth',
statement: 'Id venenatis a condimentum vitae sapien pellentesque habitant morbi tristique.',
status: 'ACTIVE'
});
Discussions
Add category
const receipt = await client.discussions.addCategory({
name: 'Ut enim ad minim',
about: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.',
parent: 0
});
Edit category
const receipt = await client.discussions.editCategory({
category: 1,
name: 'In eu mi bibendum',
about: 'Id venenatis a condimentum vitae sapien pellentesque habitant morbi tristique.'
});
Remove category
const receipt = await client.discussions.removeCategory({ category: 1 });
Add topic
const receipt = await client.discussions.addTopic({
title: 'Excepteur sint occaecat cupidatat non proident',
content: 'Duis aute irure dolor in reprehenderit in voluptate velit esse.',
author: '0xeF8305E140ac520225DAf050e2f71d5fBcC543e7',
category: 1,
parent: 0
});
Edit topic
const receipt = await client.discussions.editTopic({
topic: 1,
title: 'Amet mattis vulputate enim nulla aliquet porttitor',
content: 'Est ultricies integer quis auctor elit sed vulputate.'
});
Remove topic
const receipt = await client.discussions.removeTopic({ topic: 1 });;
Pin topic
const receipt = await client.discussions.pinTopic({ topic: 1 });
Unpin topic
const receipt = await client.discussions.unpinTopic({ topic: 1 });
Vote
const receipt = await client.discussions.vote({
voter: '0xeF8305E140ac520225DAf050e2f71d5fBcC543e7',
topic: 1,
choice: 1
});
Unvote
const receipt = await client.discussions.unvote({
voter: '0xeF8305E140ac520225DAf050e2f71d5fBcC543e7',
topic: 1
});
Last updated