Add Topic & Description to post (polkassembly) for OpenGov proposal
Closed this issue · 1 comments
Refer to https://kusama.polkassembly.io/referenda/197#6465fb6092f78fe5a46bfc5d
It's really hard to get the reason, because on polkassembly, for example, it doesn't show the details of the remark https://kusama.polkassembly.io/referenda/196
On Subscan it does https://kusama.subscan.io/referenda_v2/196
The subscan though also takes some info from polkassembly, like this topic
So the proposed solution is to use polkassembly api, in order to update the referenda/ topic and description adding a link to PR and proper explanation to whom this tip will be applied and based on what contribution
Here's api description which i got from polkassembly team
You can send a POST request to '[api.polkassembly.io/api/v1/auth/actions/editPost](http://api.polkassembly.io/api/v1/auth/actions/editPost)'
with headers 'authorization' and 'x-network'
Authorization header is of format:
Authorization: Bearer $asdnkjadj32j23kj@#adslkads
and a request body containing
{ content, postId, proposalType, title, tags }
Proposal Type can be :
"democracy_proposals", "tech_committee_proposals", "treasury_proposals", "referendums", "fellowship_referendums", "council_motions", "bounties", "tips", "child_bounties", "referendums_v2", "referendums_v2"
{content, postId, proposalType, title} are mandatory fields in the request body.
The auth header is basically a JWT.
There's two ways to get it.
Username and Password (registered Polkassembly user):
Make a post request to '[api.polkassembly.io/api/v1/auth/actions/login](http://api.polkassembly.io/api/v1/auth/actions/login)'
with a request body { username, password }
and it'll return the token { token }
Web3 address:
When a user makes a post request to '[api.polkassembly.io/api/v1/auth/actions/addressLoginStart](http://api.polkassembly.io/api/v1/auth/actions/addressLoginStart)'
with address in request body. We return a sign message : { signMessage }
When this sign message is signed with a web-3 wallet, you have to send the signature to :
'[api.polkassembly.io/api/v1/auth/actions/addressLogin](http://api.polkassembly.io/api/v1/auth/actions/addressLogin)'
It should be a post request containing { address, signature, wallet }
wallet can be
enum Wallet {
TALISMAN = 'talisman',
POLKADOT = 'polkadot-js',
SUBWALLET = 'subwallet-js',
METAMASK = 'metamask',
WALLETCONNECT = 'walletconnect',
NOVAWALLET = 'polkadot-js',
POLYWALLET = 'polywallet'
}
It'll return { token }
To test you can use 'http://test.polkassembly.io/api/v1/.....'
Here's how "SignMessage" could be signed
const keyring = new Keyring({ type: 'sr25519' });
const pair = keyring.addFromUri('<bot seed>');
const signMessage = '<the sign message you get from api.polkassembly.io/api/v1/auth/actions/addressLoginStart>';
const messageInUint8Array = stringToU8a(signMessage);
const signedMessage = pair.sign(messageInUint8Array);
// convert it to a hex string
const signature = '0x' + Buffer.from(signedMessage).toString('hex');
They don't have any way to test it locally, so the only way is testing along with real tips, probably through making it resilient and fail tolerant
Currently only tips through kusama should attempt to update topic/description. Polkadot doesn't have opengov, and they don't support Rococo there