Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .github/workflows/joystream-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ jobs:
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/cli checks
- name: npm pack test
- name: yarn pack test
run: |
cd cli
npm pack | tail -1 | xargs tar xzf
cd package && npm link
joystream-cli help
yarn workspace @joystream/cli pack --filename cli-pack-test.tgz
tar zxvf ./cli/cli-pack-test.tgz -C cli
cd ./cli/package && yarn link

cli_build_osx:
name: MacOS Checks
Expand All @@ -41,9 +40,8 @@ jobs:
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/cli checks
- name: npm pack test
- name: yarn pack test
run: |
cd cli
npm pack | tail -1 | xargs tar xzf
cd package && npm link
joystream-cli help
yarn workspace @joystream/cli pack --filename cli-pack-test.tgz
tar zxvf ./cli/cli-pack-test.tgz -C cli
cd ./cli/package && yarn link
6 changes: 3 additions & 3 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ EXAMPLES
$ api:inspect
$ api:inspect -t=query
$ api:inspect -t=query -M=members
$ api:inspect -t=query -M=members -m=memberProfile
$ api:inspect -t=query -M=members -m=memberProfile -e
$ api:inspect -t=query -M=members -m=memberProfile -e -a=1
$ api:inspect -t=query -M=members -m=membershipById
$ api:inspect -t=query -M=members -m=membershipById -e
$ api:inspect -t=query -M=members -m=membershipById -e -a=1
```

_See code: [src/commands/api/inspect.ts](https://github.com/Joystream/substrate-runtime-joystream/blob/master/cli/src/commands/api/inspect.ts)_
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"bugs": "https://github.com/Joystream/joystream/issues",
"dependencies": {
"@joystream/types": "^0.12.0",
"@joystream/types": "^0.13.0",
"@oclif/command": "^1.5.19",
"@oclif/config": "^1.14.0",
"@oclif/plugin-autocomplete": "^0.2.0",
Expand Down
13 changes: 7 additions & 6 deletions cli/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
OpeningId,
StakingPolicy,
} from '@joystream/types/hiring'
import { MemberId, Profile } from '@joystream/types/members'
import { MemberId, Membership } from '@joystream/types/members'
import { RewardRelationship, RewardRelationshipId } from '@joystream/types/recurring-rewards'
import { Stake, StakeId } from '@joystream/types/stake'
import { LinkageResult } from '@polkadot/types/codec/Linkage'
Expand Down Expand Up @@ -193,10 +193,11 @@ export default class Api {
return this._api.query[module]
}

protected async memberProfileById(memberId: MemberId): Promise<Profile | null> {
const profile = (await this._api.query.members.memberProfile(memberId)) as Option<Profile>
protected async membershipById(memberId: MemberId): Promise<Membership | null> {
const profile = (await this._api.query.members.membershipById(memberId)) as Membership

return profile.unwrapOr(null)
// Can't just use profile.isEmpty because profile.suspended is Bool (which isEmpty method always returns false)
return profile.handle.isEmpty ? null : profile
}

async groupLead(group: WorkingGroups): Promise<GroupMember | null> {
Expand Down Expand Up @@ -238,7 +239,7 @@ export default class Api {
const roleAccount = worker.role_account_id
const memberId = worker.member_id

const profile = await this.memberProfileById(memberId)
const profile = await this.membershipById(memberId)

if (!profile) {
throw new Error(`Group member profile not found! (member id: ${memberId.toNumber()})`)
Expand Down Expand Up @@ -358,7 +359,7 @@ export default class Api {
wgApplicationId,
applicationId: appId.toNumber(),
wgOpeningId: wgApplication.opening_id.toNumber(),
member: await this.memberProfileById(wgApplication.member_id),
member: await this.membershipById(wgApplication.member_id),
roleAccout: wgApplication.role_account_id,
stakes: {
application: appStakingId.isSome ? (await this.stakeValue(appStakingId.unwrap())).toNumber() : 0,
Expand Down
6 changes: 3 additions & 3 deletions cli/src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BlockNumber, Balance, AccountId } from '@polkadot/types/interfaces'
import { DerivedBalances } from '@polkadot/api-derive/types'
import { KeyringPair } from '@polkadot/keyring/types'
import { WorkerId, OpeningType } from '@joystream/types/working-group'
import { Profile, MemberId } from '@joystream/types/members'
import { Membership, MemberId } from '@joystream/types/members'
import {
GenericJoyStreamRoleSchema,
JobSpecifics,
Expand Down Expand Up @@ -103,7 +103,7 @@ export type GroupMember = {
workerId: WorkerId
memberId: MemberId
roleAccount: AccountId
profile: Profile
profile: Membership
stake?: Balance
reward?: Reward
}
Expand All @@ -112,7 +112,7 @@ export type GroupApplication = {
wgApplicationId: number
applicationId: number
wgOpeningId: number
member: Profile | null
member: Membership | null
roleAccout: AccountId
stakes: {
application: number
Expand Down
6 changes: 3 additions & 3 deletions cli/src/commands/api/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default class ApiInspect extends ApiCommandBase {
'$ api:inspect',
'$ api:inspect -t=query',
'$ api:inspect -t=query -M=members',
'$ api:inspect -t=query -M=members -m=memberProfile',
'$ api:inspect -t=query -M=members -m=memberProfile -e',
'$ api:inspect -t=query -M=members -m=memberProfile -e -a=1',
'$ api:inspect -t=query -M=members -m=membershipById',
'$ api:inspect -t=query -M=members -m=membershipById -e',
'$ api:inspect -t=query -M=members -m=membershipById -e -a=1',
]

static flags = {
Expand Down
2 changes: 1 addition & 1 deletion pioneer/packages/apps-routing/src/joy-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default [
{
Component: Members,
display: {
needsApi: ['query.members.membersCreated']
needsApi: ['query.members.nextMemberId']
},
i18n: {
defaultValue: 'Membership'
Expand Down
6 changes: 3 additions & 3 deletions pioneer/packages/joy-members/src/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { FIRST_MEMBER_ID } from './constants';

type Props = ApiProps & I18nProps & {
newMembershipsAllowed?: Bool;
membersCreated?: BN;
nextMemberId?: BN;
minHandleLength?: BN;
maxHandleLength?: BN;
maxAvatarUriLength?: BN;
Expand All @@ -36,7 +36,7 @@ class Dashboard extends React.PureComponent<Props> {
{isAllowed && (isAllowed.eq(true) ? 'Yes' : 'No')}
</Bubble>
<Bubble label='Next member ID'>
{formatNumber(p.membersCreated)}
{formatNumber(p.nextMemberId)}
</Bubble>
<Bubble label='First member ID'>
{formatNumber(FIRST_MEMBER_ID)}
Expand Down Expand Up @@ -75,7 +75,7 @@ class Dashboard extends React.PureComponent<Props> {
export default translate(
withCalls<Props>(
queryMembershipToProp('newMembershipsAllowed'),
queryMembershipToProp('membersCreated'),
queryMembershipToProp('nextMemberId'),
queryMembershipToProp('minHandleLength'),
queryMembershipToProp('maxHandleLength'),
queryMembershipToProp('maxAvatarUriLength'),
Expand Down
26 changes: 12 additions & 14 deletions pioneer/packages/joy-members/src/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import AddressMini from '@polkadot/react-components/AddressMiniJoy';
import { formatNumber } from '@polkadot/util';

import translate from './translate';
import { MemberId, Profile, EntryMethod, Paid, Screening, Genesis, SubscriptionId } from '@joystream/types/members';
import { MemberId, Membership, EntryMethod, Paid, Screening, Genesis, SubscriptionId } from '@joystream/types/members';
import { queryMembershipToProp } from './utils';
import { Seat } from '@joystream/types/council';
import { nonEmptyStr, queryToProp } from '@polkadot/joy-utils/index';
Expand All @@ -21,25 +21,23 @@ import { MyAccountProps, withMyAccount } from '@polkadot/joy-utils/MyAccount';
type Props = ApiProps & I18nProps & MyAccountProps & {
preview?: boolean;
memberId: MemberId;
// This cannot be named just "memberProfile", since it will conflict with "withAccount's" memberProfile
// (which holds member profile associated with currently selected account)
detailsMemberProfile?: Option<any>; // TODO refactor to Option<Profile>
membership?: Membership;
activeCouncil?: Seat[];
};

class Component extends React.PureComponent<Props> {
render () {
const { detailsMemberProfile } = this.props;
return detailsMemberProfile
? this.renderProfile(detailsMemberProfile.unwrap() as Profile)
const { membership } = this.props;
return membership && !membership.handle.isEmpty
? this.renderProfile(membership)
: (
<div className={'item ProfileDetails'}>
<Loader active inline/>
</div>
);
}

private renderProfile (memberProfile: Profile) {
private renderProfile (membership: Membership) {
const {
preview = false,
myAddress,
Expand All @@ -51,7 +49,7 @@ class Component extends React.PureComponent<Props> {
avatar_uri,
root_account,
controller_account
} = memberProfile;
} = membership;

const hasAvatar = avatar_uri && nonEmptyStr(avatar_uri.toString());
const isMyProfile = myAddress && (myAddress === root_account.toString() || myAddress === controller_account.toString());
Expand Down Expand Up @@ -83,12 +81,12 @@ class Component extends React.PureComponent<Props> {
</div>
</div>
</div>
{!preview && this.renderDetails(memberProfile, isCouncilor)}
{!preview && this.renderDetails(membership, isCouncilor)}
</>
);
}

private renderDetails (memberProfile: Profile, isCouncilor: boolean) {
private renderDetails (membership: Membership, isCouncilor: boolean) {
const {
about,
registered_at_block,
Expand All @@ -99,7 +97,7 @@ class Component extends React.PureComponent<Props> {
root_account,
controller_account

} = memberProfile;
} = membership;

const { memberId } = this.props;

Expand Down Expand Up @@ -173,8 +171,8 @@ export default translate(withMyAccount(
withCalls<Props>(
queryToProp('query.council.activeCouncil'),
queryMembershipToProp(
'memberProfile',
{ paramName: 'memberId', propName: 'detailsMemberProfile' }
'membershipById',
{ paramName: 'memberId', propName: 'membership' }
)
)(Component)
));
6 changes: 3 additions & 3 deletions pioneer/packages/joy-members/src/DetailsByHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { queryMembershipToProp } from './utils';

type DetailsByHandleProps = {
handle: string;
handles?: MemberId;
memberIdByHandle?: MemberId;
};

function DetailsByHandleInner (p: DetailsByHandleProps) {
const { handles: memberId } = p;
const { memberIdByHandle: memberId } = p;
return memberId !== undefined // here we can't make distinction value existing and loading
? <div className='ui massive relaxed middle aligned list FullProfile'>
<Details memberId={memberId} />
Expand All @@ -24,7 +24,7 @@ function DetailsByHandleInner (p: DetailsByHandleProps) {
}

const DetailsByHandle = withCalls<DetailsByHandleProps>(
queryMembershipToProp('handles', 'handle')
queryMembershipToProp('memberIdByHandle', 'handle')
)(DetailsByHandleInner);

type Props = I18nProps & {
Expand Down
Loading