Skip to content

Commit

Permalink
Merge branch 'hancheng/split-application-wallet-entry' into feat-user…
Browse files Browse the repository at this point in the history
…-guide

* hancheng/split-application-wallet-entry: (63 commits)
  chore: ui style
  fix: ui style
  chore: add comment
  fix: style
  fix: dialog title text center
  feat: add new theme color (#6094)
  refactor: move queryPersonaByProfile
  refactor: rename a field
  fix: little fix
  chore: persona connect
  chore: cleanup usage of toText
  chore: better type of signWithPersona
  refactor: post db types (#6172)
  fix: import make styles path in theme package (#6174)
  [Release] New release 2.7.0 (minor) (#6142)
  chore: update event
  chore(eslint): prefer object-shorthand (#6171)
  feat: recommend feature app
  fix: typo (#6173)
  refactor: xdai features EIP1559 (#6170)
  ...
  • Loading branch information
yanzhihong23 committed Apr 29, 2022
2 parents 993a4e1 + 321f852 commit e69ad12
Show file tree
Hide file tree
Showing 457 changed files with 8,002 additions and 5,271 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"constructor-super": "error",
"dot-notation": "error",
"eqeqeq": "error",
"object-shorthand": "warn",
"no-var": "error",
"no-bitwise": "error",
"no-debugger": "error",
Expand Down
12 changes: 12 additions & 0 deletions .i18n-codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@
"trans": "Translate",
"sourceMap": "inline"
}
},
{
"input": "./packages/mask/src/plugins/Tips/locales/en-US.json",
"output": "./packages/mask/src/plugins/Tips/locales/i18n_generated",
"parser": "i18next",
"generator": {
"type": "i18next/react-hooks",
"hooks": "useI18N",
"namespace": "com.maskbook.tip",
"trans": "Translate",
"sourceMap": "inline"
}
}
]
}
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"titlebar",
"tokelau",
"tokenid",
"topbar",
"traderjoe",
"transak",
"trisolaris",
Expand Down
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.6.0",
"version": "2.7.0",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"build-ios": "build --preset iOS",
"lint": "eslint -c packages/.eslintrc.json packages --ext .ts,.tsx,.js --cache --fix",
"lint:ci": "eslint -c packages/.eslintrc.json packages --ext .ts,.tsx,.js --cache",
"lint:ci-report": "pnpm lint:ci -- --format=junit --output-file=reports/junit/eslint-results.xml",
"lint:ci-report": "pnpm lint:ci -- --format=junit --output-file=reports/junit/eslint-results.xml --max-warnings=0",
"postinstall": "patch-package",
"prepare": "husky install",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
Expand All @@ -34,22 +34,23 @@
"@emotion/serialize": "^1.0.3",
"@emotion/styled": "^11.8.1",
"@emotion/utils": "^1.1.0",
"@mui/icons-material": "5.6.1",
"@mui/lab": "5.0.0-alpha.77",
"@mui/material": "5.6.1",
"@mui/system": "5.6.1",
"@mui/icons-material": "5.6.2",
"@mui/lab": "5.0.0-alpha.78",
"@mui/material": "5.6.2",
"@mui/system": "5.6.2",
"@solana/web3.js": "1.39.1",
"@types/masknet__global-types": "workspace:*",
"@types/react": "18.0.2",
"@types/react-dom": "^18.0.0",
"@types/react": "18.0.6",
"@types/react-dom": "^18.0.2",
"@types/web": "^0.0.61",
"immer": "9.0.12",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"lodash-unified": "1.0.2",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-i18next": "^11.16.5",
"ses": "0.15.12",
"react-i18next": "^11.16.7",
"ses": "0.15.15",
"ts-results": "3.3.0",
"web3-core": "1.7.3",
"web3-core-method": "1.7.3"
Expand All @@ -66,9 +67,9 @@
"@nice-labs/git-rev": "^3.5.0",
"@swc/core": "^1.2.165",
"@types/lodash-es": "^4.17.6",
"@typescript-eslint/experimental-utils": "^5.18.0",
"@typescript-eslint/experimental-utils": "^5.20.0",
"cspell": "^5.19.7",
"eslint": "8.13.0",
"eslint": "8.14.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.4.0",
Expand All @@ -77,7 +78,7 @@
"gulp": "^4.0.2",
"husky": "^7.0.4",
"jest": "^28.0.0-alpha.8",
"lint-staged": "^12.3.7",
"lint-staged": "^12.4.0",
"prettier": "^2.6.2",
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
Expand All @@ -86,7 +87,8 @@
"pnpm": {
"overrides": {
"@types/node": "^17.0.23",
"@types/react": "18.0.2"
"@types/react": "18.0.2",
"@solana/web3.js": "1.39.1"
},
"onlyBuiltDependencies": []
}
Expand Down
4 changes: 3 additions & 1 deletion packages/backup-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"type": "module",
"dependencies": {
"@masknet/shared-base": "workspace:*",
"@msgpack/msgpack": "^2.7.2"
"@msgpack/msgpack": "^2.7.2",
"elliptic": "^6.5.3",
"pvtsutils": "^1.2.2"
}
}
7 changes: 3 additions & 4 deletions packages/backup-format/src/normalize/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ECKeyIdentifier, IdentifierMap, PostIVIdentifier, ProfileIdentifier } from '@masknet/shared-base'
import { None } from 'ts-results'
import { BackupErrors } from '../BackupErrors'
import { isBackupVersion0, normalizeBackupVersion0 } from '../version-0'
Expand Down Expand Up @@ -33,9 +32,9 @@ export function generateBackupRAW(data: NormalizedBackup.Data): unknown {
export function createEmptyNormalizedBackup(): NormalizedBackup.Data {
return {
meta: { version: 2, createdAt: None, maskVersion: None },
personas: new IdentifierMap(new Map(), ECKeyIdentifier),
profiles: new IdentifierMap(new Map(), ProfileIdentifier),
posts: new IdentifierMap(new Map(), PostIVIdentifier),
personas: new Map(),
profiles: new Map(),
posts: new Map(),
relations: [],
settings: { grantedHostPermissions: [] },
wallets: [],
Expand Down
13 changes: 6 additions & 7 deletions packages/backup-format/src/normalize/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
ProfileIdentifier,
RelationFavor,
PostIVIdentifier,
IdentifierMap,
} from '@masknet/shared-base'
import type { Option } from 'ts-results'

Expand All @@ -15,10 +14,10 @@ export namespace NormalizedBackup {
export interface Data {
/** Meta about this backup */
meta: Meta
personas: IdentifierMap<PersonaIdentifier, PersonaBackup>
profiles: IdentifierMap<ProfileIdentifier, ProfileBackup>
personas: Map<PersonaIdentifier, PersonaBackup>
profiles: Map<ProfileIdentifier, ProfileBackup>
relations: RelationBackup[]
posts: IdentifierMap<PostIVIdentifier, PostBackup>
posts: Map<PostIVIdentifier, PostBackup>
wallets: WalletBackup[]
settings: SettingsBackup
plugins: Record<string, unknown>
Expand All @@ -36,7 +35,7 @@ export namespace NormalizedBackup {
publicKey: EC_Public_JsonWebKey
privateKey: Option<EC_Private_JsonWebKey>
localKey: Option<AESJsonWebKey>
linkedProfiles: IdentifierMap<ProfileIdentifier, unknown>
linkedProfiles: Map<ProfileIdentifier, unknown>
nickname: Option<string>
createdAt: Option<Date>
updatedAt: Option<Date>
Expand All @@ -61,7 +60,7 @@ export namespace NormalizedBackup {
}
export interface PostBackup {
identifier: PostIVIdentifier
postBy: ProfileIdentifier
postBy?: ProfileIdentifier
postCryptoKey: Option<AESJsonWebKey>
recipients: Option<PostReceiverPublic | PostReceiverE2E>
foundAt: Date
Expand All @@ -75,7 +74,7 @@ export namespace NormalizedBackup {
}
export interface PostReceiverE2E {
type: 'e2e'
receivers: IdentifierMap<ProfileIdentifier, RecipientReason[]>
receivers: Map<ProfileIdentifier, RecipientReason[]>
}
export interface RecipientReason {
type: 'auto-share' | 'direct' | 'group'
Expand Down
36 changes: 36 additions & 0 deletions packages/backup-format/src/utils/hex2buffer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** @internal */
export function hex2buffer(hexString: string, padded?: boolean) {
if (hexString.length % 2) {
hexString = '0' + hexString
}
let res = new Uint8Array(hexString.length / 2)
// eslint-disable-next-line no-plusplus
for (let i = 0; i < hexString.length; i++) {
// eslint-disable-next-line no-plusplus
const c = hexString.slice(i, ++i + 1)
res[(i - 1) / 2] = Number.parseInt(c, 16)
}
// BN padding
if (padded) {
let len = res.length
len = len > 32 ? (len > 48 ? 66 : 48) : 32
if (res.length < len) {
res = concat(new Uint8Array(len - res.length), res)
}
}
return res
}

/** @internal */
function concat(...buf: (Uint8Array | number[])[]) {
const res = new Uint8Array(buf.map((item) => item.length).reduce((prev, cur) => prev + cur))
let offset = 0
buf.forEach((item, index) => {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < item.length; i++) {
res[offset + i] = item[i]
}
offset += item.length
})
return res
}
5 changes: 2 additions & 3 deletions packages/backup-format/src/version-0/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ECKeyIdentifierFromJsonWebKey,
EC_Private_JsonWebKey,
EC_Public_JsonWebKey,
IdentifierMap,
isAESJsonWebKey,
isEC_Private_JsonWebKey,
isEC_Public_JsonWebKey,
Expand Down Expand Up @@ -39,7 +38,7 @@ export function normalizeBackupVersion0(file: BackupJSONFileVersion0): Normalize
const persona: NormalizedBackup.PersonaBackup = {
identifier: ECKeyIdentifierFromJsonWebKey(publicKey),
publicKey,
linkedProfiles: new IdentifierMap<ProfileIdentifier, any>(new Map(), ProfileIdentifier),
linkedProfiles: new Map(),
localKey: isAESJsonWebKey(local) ? Some(local) : None,
privateKey: isEC_Private_JsonWebKey(privateKey) ? Some(privateKey) : None,
mnemonic: None,
Expand All @@ -51,7 +50,7 @@ export function normalizeBackupVersion0(file: BackupJSONFileVersion0): Normalize

if (username && username !== '$unknown' && username !== '$local') {
const profile: NormalizedBackup.ProfileBackup = {
identifier: new ProfileIdentifier('facebook.com', username),
identifier: ProfileIdentifier.of('facebook.com', username).unwrap(),
linkedPersona: Some(persona.identifier),
createdAt: None,
updatedAt: None,
Expand Down
6 changes: 3 additions & 3 deletions packages/backup-format/src/version-1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
isEC_Public_JsonWebKey,
isAESJsonWebKey,
ProfileIdentifier,
IdentifierMap,
} from '@masknet/shared-base'
import { isObjectLike } from 'lodash-unified'
import { None, Some } from 'ts-results'
Expand Down Expand Up @@ -39,8 +38,9 @@ export function normalizeBackupVersion1(file: BackupJSONFileVersion1): Normalize

const { whoami, people } = file
for (const { network, publicKey, userId, nickname, localKey, privateKey } of [...whoami, ...(people || [])]) {
const identifier = ProfileIdentifier.of(network, userId).unwrap()
const profile: NormalizedBackup.ProfileBackup = {
identifier: new ProfileIdentifier(network, userId),
identifier,
nickname: nickname ? Some(nickname) : None,
createdAt: None,
updatedAt: None,
Expand All @@ -53,7 +53,7 @@ export function normalizeBackupVersion1(file: BackupJSONFileVersion1): Normalize
const persona: NormalizedBackup.PersonaBackup = backup.personas.get(personaID) || {
identifier: personaID,
nickname: None,
linkedProfiles: new IdentifierMap(new Map(), ProfileIdentifier),
linkedProfiles: new Map(),
publicKey,
privateKey: None,
localKey: None,
Expand Down
Loading

0 comments on commit e69ad12

Please sign in to comment.