-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗝️ Fix
opening:create
on the liberated chain (#4383)
* Enable ts aliases in scripts * Make `council:elect` callable from other scripts * Create proposals with new staking accounts Because all wellknown accounts are locked once the council is elected. * Add a `approveProposal` script * Fix `opening:create` on the liberated chain * Document `-d BLOCK_TIME` * Fix `useProposalConstants`
- Loading branch information
Showing
12 changed files
with
206 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
/* eslint-disable no-console */ | ||
import { MembershipMetadata } from '@joystream/metadata-protobuf' | ||
import { ApiPromise } from '@polkadot/api' | ||
|
||
import { metadataToBytes } from '@/common/model/JoystreamNode' | ||
import members from '@/mocks/data/raw/members.json' | ||
|
||
import { metadataToBytes } from '../../../../src/common/model/JoystreamNode' | ||
import members from '../../../../src/mocks/data/raw/members.json' | ||
import { getSudoAccount } from '../../data/addresses' | ||
import { signAndSend, withApi } from '../../lib/api' | ||
|
||
export const createMembersCommand = async () => { | ||
await withApi(async (api) => { | ||
const nextId = await api.query.members.nextMemberId() | ||
|
||
if (Number(nextId) > 0) { | ||
console.log('Some members were already added') | ||
return | ||
} | ||
|
||
const createMembers = members.map((member) => { | ||
return api.tx.members.buyMembership({ | ||
handle: member.handle, | ||
metadata: metadataToBytes(MembershipMetadata, { | ||
name: member.metadata.name, | ||
about: member.metadata.about, | ||
}), | ||
rootAccount: member.rootAccount, | ||
controllerAccount: member.controllerAccount, | ||
}) | ||
export const createMembersCommand = async (api: ApiPromise) => { | ||
const nextId = await api.query.members.nextMemberId() | ||
|
||
if (Number(nextId) > 0) { | ||
console.log('Some members were already added') | ||
return | ||
} | ||
|
||
const createMembers = members.map((member) => { | ||
return api.tx.members.buyMembership({ | ||
handle: member.handle, | ||
metadata: metadataToBytes(MembershipMetadata, { | ||
name: member.metadata.name, | ||
about: member.metadata.about, | ||
}), | ||
rootAccount: member.rootAccount, | ||
controllerAccount: member.controllerAccount, | ||
}) | ||
}) | ||
|
||
const tx = api.tx.utility.batch(createMembers) | ||
const tx = api.tx.utility.batch(createMembers) | ||
|
||
await signAndSend(tx, getSudoAccount()) | ||
await signAndSend(tx, getSudoAccount()) | ||
|
||
await Promise.all( | ||
members.map(async ({ id, boundAccounts, controllerAccount }) => { | ||
for (const boundAccount of boundAccounts) { | ||
// Bind staking account | ||
await signAndSend(api.tx.members.addStakingAccountCandidate(id), boundAccount) | ||
await Promise.all( | ||
members.map(async ({ id, boundAccounts, controllerAccount }) => { | ||
for (const boundAccount of boundAccounts) { | ||
// Bind staking account | ||
await signAndSend(api.tx.members.addStakingAccountCandidate(id), boundAccount) | ||
|
||
// Confirm staking account | ||
await signAndSend(api.tx.members.confirmStakingAccount(id, boundAccount), controllerAccount) | ||
} | ||
}) | ||
) | ||
}) | ||
// Confirm staking account | ||
await signAndSend(api.tx.members.confirmStakingAccount(id, boundAccount), controllerAccount) | ||
} | ||
}) | ||
) | ||
} | ||
|
||
export const createMembersModule = { | ||
command: 'members:create', | ||
describe: 'Create member accounts from mocks', | ||
handler: createMembersCommand, | ||
handler: () => withApi(createMembersCommand), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ApiPromise } from '@polkadot/api' | ||
|
||
import memberData from '@/mocks/data/raw/members.json' | ||
|
||
import { signAndSend } from '../../lib/api' | ||
|
||
export const approveProposal = async (api: ApiPromise, proposalId: number) => { | ||
const councilors = await api.query.council.councilMembers() | ||
await Promise.all( | ||
councilors.map((councilor) => { | ||
const memberId = councilor.membershipId.toString() | ||
const member = memberData.find(({ id }) => id === memberId) | ||
if (!member) throw `Couldn't find the councilor ${memberId} controller account` | ||
|
||
const tx = api.tx.proposalsEngine.vote(councilor.membershipId, proposalId, 'Approve', 'LGTM') | ||
|
||
// Assume councilors stacking account are their controller accounts too | ||
return signAndSend(tx, member.controllerAccount) | ||
}) | ||
) | ||
} |
Oops, something went wrong.
d46fce3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pioneer-2 – ./
pioneer-2-git-dev-joystream.vercel.app
pioneer-2.vercel.app
pioneer-2-joystream.vercel.app
d46fce3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pioneer-2-storybook – ./
pioneer-2-storybook.vercel.app
pioneer-2-storybook-git-dev-joystream.vercel.app
pioneer-2-storybook-joystream.vercel.app