-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
249 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as MetaClasses from '@joystream/metadata-protobuf' | ||
import { AnyMetadataClass } from '@joystream/metadata-protobuf/types' | ||
import { createType } from '@joystream/types' | ||
import chalk from 'chalk' | ||
import yargs from 'yargs' | ||
|
||
import { metadataFromBytes } from '../../src/common/model/JoystreamNode' | ||
|
||
const MetaClassAliases = { | ||
post: 'ForumPostMetadata', | ||
opening: 'OpeningMetadata', | ||
thread: 'ForumThreadMetadata', | ||
bounty: 'BountyMetadata', | ||
candidacy: 'CouncilCandidacyNoteMetadata', | ||
candidate: 'CouncilCandidacyNoteMetadata', | ||
application: 'ApplicationMetadata', | ||
member: 'MembershipMetadata', | ||
membership: 'MembershipMetadata', | ||
} as Record<string, keyof typeof MetaClasses> | ||
|
||
const options = { | ||
type: { type: 'string', alias: 't', example: ['text', 'post', 'ForumPostMetadata'], default: 'text' }, | ||
value: { type: 'string', alias: 'v', demand: true }, | ||
} as const | ||
|
||
type CommandOptions = yargs.InferredOptionTypes<typeof options> | ||
type Args = yargs.Arguments<CommandOptions> | ||
|
||
const decode = (type: string, value: string): string => { | ||
if (type === 'text') { | ||
return createType('Text', value).toHuman() | ||
} else { | ||
const metaType = (MetaClassAliases[type as any] ?? type) as keyof typeof MetaClasses | ||
const metadata = metadataFromBytes(MetaClasses[metaType] as AnyMetadataClass<any>, value) | ||
return `${metaType} ${JSON.stringify(metadata, null, 2)}` | ||
} | ||
} | ||
const handler = ({ type, value }: Args) => { | ||
process.stdout.write(chalk.green(decode(type, value)) + '\n') | ||
} | ||
|
||
export const decodeModule = { | ||
command: 'decode', | ||
describe: 'Decode chain data', | ||
handler, | ||
builder: (argv: yargs.Argv<unknown>) => argv.options(options), | ||
} |
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
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
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,5 +1,6 @@ | ||
export * from './errorEvents' | ||
export * from './getDataFromEvent' | ||
export * from './isModuleEvent' | ||
export * from './metadataFromBytes' | ||
export * from './metadataToBytes' | ||
export * from './types' |
3 changes: 1 addition & 2 deletions
3
packages/ui/src/common/model/JoystreamNode/metadataFromBytes.ts
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
Oops, something went wrong.
0573451
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:
dao – ./
pioneerapp.xyz
dao.joystream.org
dao-joystream.vercel.app
dao-git-main-joystream.vercel.app