Skip to content

Commit

Permalink
🚀 Ephesus release (#4335)
Browse files Browse the repository at this point in the history
### Added
- Update Channel Payouts Proposal.
- Self-imposed governance blacklisting support.
  • Loading branch information
thesan authored Apr 12, 2023
2 parents 79ab20c + 50f3351 commit a6318b0
Show file tree
Hide file tree
Showing 89 changed files with 13,442 additions and 6,206 deletions.
25 changes: 6 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"plugin:import/warnings",
"plugin:import/typescript"
],
"plugins": [
"import",
"react-hooks"
],
"plugins": ["import", "react-hooks"],
"ignorePatterns": [".eslintrc.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -32,6 +29,7 @@
"no-console": "error",
"no-redeclare": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"quotes": [
"error",
"single",
Expand All @@ -43,12 +41,7 @@
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"parent",
[ "index", "sibling" ]
],
"groups": ["builtin", "external", "parent", ["index", "sibling"]],
"pathGroups": [
{
"pattern": "@/**",
Expand All @@ -74,26 +67,20 @@
},
"overrides": [
{
"files": [
"test/**/*.{js,ts,tsx}"
],
"files": ["test/**/*.{js,ts,tsx}"],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off",
"no-unused-expressions": "off"
}
},
{
"files": [
"**/__generated__/**/*.{js,ts,tsx}"
],
"files": ["**/__generated__/**/*.{js,ts,tsx}"],
"rules": {
"import/order": "off"
}
},
{
"files": [
"src/common/logger/*.ts"
],
"files": ["src/common/logger/*.ts"],
"rules": {
"no-console": "off"
}
Expand Down
353 changes: 353 additions & 0 deletions .yarn/patches/@joystream-js-npm-1.2.0-a8795e7496.patch

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.4.0 Ephesus][1.4.0] - 2023-04-12

### Added
- Update Channel Payouts Proposal.
- Self-imposed governance blacklisting support.

## [1.3.2] - 2023-04-05

### Fixed

- Incorrect values in the "My Roles" tab.
- Working group history tab crashing.
- Infinite auto scroll to a post after opening a link to this post.
Expand Down Expand Up @@ -108,7 +113,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Proposal view crashing due to high amounts of JOY

## [1.0.0] - 2022-12-16
## [1.0.0 Mainnet][1.0.0] - 2022-12-16

### Added
- Mainnet network in the setting.
Expand Down Expand Up @@ -141,7 +146,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.1.1] - 2022-12-02

[unreleased]: https://github.com/Joystream/pioneer/compare/v1.3.2...HEAD
[unreleased]: https://github.com/Joystream/pioneer/compare/v1.4.0...HEAD
[1.4.0]: https://github.com/Joystream/pioneer/compare/v1.3.2...v1.4.0
[1.3.2]: https://github.com/Joystream/pioneer/compare/v1.3.1...v1.3.2
[1.3.1]: https://github.com/Joystream/pioneer/compare/v1.3.0...v1.3.1
[1.3.0]: https://github.com/Joystream/pioneer/compare/v1.2.0...v1.3.0
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"wsrun": "^5.2.4"
},
"devDependencies": {
"@typescript-eslint/parser": "^5.19.0",
"eslint": "^7.29.0",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"husky": ">=6",
"lint-staged": ">=10"
},
Expand All @@ -43,10 +43,12 @@
"@polkadot/types-known": "8.9.1",
"@polkadot/util": "9.5.1",
"@polkadot/util-crypto": "9.5.1",
"bn.js": "^4.11.9"
"bn.js": "^4.11.9",
"@joystream/js@1.2.0": "patch:@joystream/js@npm%3A1.2.0#./.yarn/patches/@joystream-js-npm-1.2.0-a8795e7496.patch",
"@joystream/types": "./packages/joystream-types-v0.20.6.tgz"
},
"engines": {
"node": ">=14.0.0",
"node": ">=14.18.0",
"yarn": "^1.22.0"
},
"lint-staged": {
Expand Down
1 change: 0 additions & 1 deletion packages/chain-metadata.json

This file was deleted.

Binary file added packages/joystream-types-v0.20.6.tgz
Binary file not shown.
13 changes: 12 additions & 1 deletion packages/ui/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const path = require('path')

const { merge } = require('lodash')

const shared = require('./../dev/webpack.shared')

module.exports = {
Expand All @@ -14,7 +18,14 @@ module.exports = {
}
})

config.resolve = shared.resolve
config.resolve = merge(
{
alias: {
'@/common/utils/crypto/worker$': path.resolve(__dirname, '../src/common/utils/crypto'),
},
},
shared.resolve
)
config.plugins.push(...shared.plugins)
config.module.rules.unshift(...shared.rules)

Expand Down
9 changes: 6 additions & 3 deletions packages/ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ module.exports = {
moduleNameMapper: {
'\\.(svg|css|md)$': '<rootDir>/test/_mocks/imports/fileMock.js',
'^@/(.*)$': '<rootDir>/src/$1',
// since jest doesn't support importing modules by `exports` in package.json
// we are forced to make mapping manually
'^@joystream/js/content': '@joystream/js/lib/mjs/content',
'^@joystream/js/utils': '@joystream/js/lib/mjs/utils',
'^@joystream/metadata-protobuf/utils': '@joystream/metadata-protobuf/lib/utils.js',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
modulePathIgnorePatterns: [
'<rootDir>/test/bounty'
],
modulePathIgnorePatterns: ['<rootDir>/test/bounty'],

// Activates notifications for test results
// notify: false,
Expand Down
12 changes: 9 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@joystream/pioneer",
"version": "1.2.0",
"version": "1.4.0",
"license": "GPL-3.0-only",
"scripts": {
"build": "node --max_old_space_size=4096 ./build.js",
Expand All @@ -25,11 +25,13 @@
"dependencies": {
"@apollo/client": "3.5.7",
"@hcaptcha/react-hcaptcha": "^1.4.4",
"@joystream/js": "1.2.0",
"@joystream/markdown-editor": "^0.1.0",
"@joystream/metadata-protobuf": "^2.0.0",
"@joystream/types": "0.20.5",
"@joystream/types": "0.20.6",
"@nivo/bar": "^0.79.1",
"@nivo/core": "^0.79.0",
"@noble/hashes": "^1.1.5",
"@polkadot/api": "8.9.1",
"@polkadot/extension-dapp": "0.44.2-4",
"@polkadot/keyring": "9.5.1",
Expand Down Expand Up @@ -62,6 +64,7 @@
"jsonpath": "^1.1.1",
"lodash": "^4.17.21",
"mime": "^2.4.4",
"multihashes": "^4.0.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-dropzone": "^11.4.2",
Expand Down Expand Up @@ -105,10 +108,12 @@
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@types/eslint": "^8.4.10",
"@types/faker": "^5.5.8",
"@types/mime": "^2.0.3",
"@types/yargs": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"babel": "^6.23.0",
"babel-jest": "^27.2.5",
"babel-loader": "^8.2.2",
Expand All @@ -117,6 +122,7 @@
"chalk": "^4.1.2",
"clean-webpack-plugin": "^4.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.33.0",
"eslint-plugin-react-hooks": "^4.2.0",
"faker": "^5.5.3",
"fork-ts-checker-webpack-plugin": "^6.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ export const AccountLockTooltip = ({ locks, children, boundaryClassName }: Props
const tooltipTexts = useMemo(() => {
const texts: React.ReactElement[] = []

if (locks?.includes('optOutLock')) {
texts.push(
<li className="tooltipLink" key="optOutLock">
This account has permanently opted out from voting.
<br />
</li>
)
}

if (locks?.includes('boundMembership')) {
texts.push(
<li className="tooltipLink" key="boundMembership">
Expand Down
66 changes: 42 additions & 24 deletions packages/ui/src/accounts/hooks/useStakingAccountsLocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BN from 'bn.js'
import { useEffect, useState } from 'react'

import { useMyMemberships } from '@/memberships/hooks/useMyMemberships'

Expand All @@ -7,7 +8,9 @@ import { AccountOption, LockType, OptionLock } from '../types'

import { useMyAccounts } from './useMyAccounts'
import { useMyBalances } from './useMyBalances'
import { useVotingOptOutAccounts } from './useVotingOptOutAccounts'

type StakingAccount = AccountOption & { optionLocks: OptionLock[] }
interface UseStakingAccountsLocks {
requiredStake: BN
lockType: LockType
Expand All @@ -20,38 +23,53 @@ export const useStakingAccountsLocks = ({
lockType,
recoveryConditions,
filterByBalance,
}: UseStakingAccountsLocks) => {
}: UseStakingAccountsLocks): StakingAccount[] => {
const { allAccounts } = useMyAccounts()
const balances = useMyBalances()
const {
active: activeMember,
helpers: { getMemberIdByBoundAccountAddress },
} = useMyMemberships()

const accountsWithLocks = allAccounts.map((account) => {
const optionLocks: OptionLock[] = []
const accountAddress = account.address
const accountBalances = balances?.[accountAddress]

const boundMembershipId = getMemberIdByBoundAccountAddress(accountAddress)
if (accountBalances && accountBalances.total?.lt(requiredStake) && filterByBalance) {
optionLocks.push('insufficientFunds')
}

if (boundMembershipId && boundMembershipId !== activeMember?.id && lockType !== 'Voting') {
optionLocks.push('boundMembership')
}

if (accountBalances && areLocksConflicting(lockType, accountBalances.locks)) {
if (isRecoverable(lockType, recoveryConditions)) {
optionLocks.push('recoverableLock')
} else {
optionLocks.push('rivalrousLock')
const [accountsWithLocks, setAccountWithLocks] = useState<StakingAccount[]>(
allAccounts.map((account) => {
const optionLocks: OptionLock[] = []
const accountAddress = account.address
const accountBalances = balances?.[accountAddress]

const boundMembershipId = getMemberIdByBoundAccountAddress(accountAddress)
if (accountBalances && accountBalances.total?.lt(requiredStake) && filterByBalance) {
optionLocks.push('insufficientFunds')
}

if (boundMembershipId && boundMembershipId !== activeMember?.id && lockType !== 'Voting') {
optionLocks.push('boundMembership')
}
}

return { ...account, optionLocks }
})
if (accountBalances && areLocksConflicting(lockType, accountBalances.locks)) {
if (isRecoverable(lockType, recoveryConditions)) {
optionLocks.push('recoverableLock')
} else {
optionLocks.push('rivalrousLock')
}
}

return { ...account, optionLocks }
})
)

const isVoting = lockType === 'Voting'
const votingOptOutAccounts = useVotingOptOutAccounts({ skip: !isVoting })
useEffect(() => {
if (!isVoting) return

setAccountWithLocks(
accountsWithLocks.map(({ address, optionLocks, ...account }): StakingAccount => {
const isOptOut = votingOptOutAccounts.includes(address)
return { address, ...account, optionLocks: isOptOut ? [...optionLocks, 'optOutLock'] : optionLocks }
})
)
}, [votingOptOutAccounts])

return accountsWithLocks as AccountOption[]
return accountsWithLocks
}
27 changes: 27 additions & 0 deletions packages/ui/src/accounts/hooks/useVotingOptOutAccounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useEffect, useState } from 'react'
import { firstValueFrom } from 'rxjs'

import { useApi } from '@/api/hooks/useApi'

import { encodeAddress } from '../model/encodeAddress'

interface Props {
skip?: boolean
}

const cache: string[] = []

export const useVotingOptOutAccounts = ({ skip }: Props = {}): string[] => {
const { api } = useApi()
const [addresses, setAddresses] = useState<string[]>(cache)

useEffect(() => {
if (skip || !api || cache.length) return

firstValueFrom(api.query.referendum.accountsOptedOut.keys()).then((result: any) => {
setAddresses(result.map((key: any) => encodeAddress(key.args[0])))
})
}, [api?.isConnected])

return addresses
}
5 changes: 5 additions & 0 deletions packages/ui/src/accounts/model/encodeAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { encodeAddress as encode } from '@polkadot/util-crypto'

const JOYSTREAM_SS58_PREFIX = 126

export const encodeAddress = (key: Parameters<typeof encode>[0]) => encode(key, JOYSTREAM_SS58_PREFIX)
7 changes: 3 additions & 4 deletions packages/ui/src/accounts/providers/accounts/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types'
import { Keyring } from '@polkadot/ui-keyring'
import { decodeAddress, encodeAddress } from '@polkadot/util-crypto'
import { decodeAddress } from '@polkadot/util-crypto'
import { getWalletBySource, Wallet } from 'injectweb3-connect'
import React, { ReactNode, useEffect, useState } from 'react'
import { debounceTime, filter, skip } from 'rxjs/operators'

import { encodeAddress } from '@/accounts/model/encodeAddress'
import { useKeyring } from '@/common/hooks/useKeyring'
import { useLocalStorage } from '@/common/hooks/useLocalStorage'
import { useObservable } from '@/common/hooks/useObservable'
Expand All @@ -24,8 +25,6 @@ export interface UseAccounts {
setWallet?: (wallet: Wallet | undefined) => void
}

const JOYSTREAM_SS58_PREFIX = 126

interface Props {
children: ReactNode
}
Expand Down Expand Up @@ -156,7 +155,7 @@ export const AccountsContextProvider = (props: Props) => {
...Object.values(accounts).map((account) => {
const publicKey = decodeAddress(account.json.address)
return {
address: encodeAddress(publicKey, JOYSTREAM_SS58_PREFIX),
address: encodeAddress(publicKey),
name: account.json.meta.name,
source: account.json.meta.source as string,
}
Expand Down
Loading

1 comment on commit a6318b0

@vercel
Copy link

@vercel vercel bot commented on a6318b0 Apr 12, 2023

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 – ./

dao-git-main-joystream.vercel.app
dao-joystream.vercel.app
dao.joystream.org
pioneerapp.xyz

Please sign in to comment.