Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
014dc7d
feat: add producer
Lanttcat Dec 16, 2021
7996dca
feat: add rollup
Lanttcat Dec 16, 2021
5b9088a
feat: ci
Lanttcat Dec 17, 2021
bd1886e
feat: add proxy class
Lanttcat Dec 21, 2021
ed057f5
test: should cache divide data when server push different response
Lanttcat Dec 21, 2021
38858bb
feat: happy pass for get debank asset
Lanttcat Dec 21, 2021
1ad26f8
fix: remove console
Lanttcat Dec 21, 2021
4f1ce8d
chore: use esbuild
Jack-Works Dec 20, 2021
067bec0
chore: extra
Jack-Works Dec 20, 2021
ce32ce2
fix: build
Jack-Works Dec 21, 2021
ed0de87
feat: pack the package
Jack-Works Dec 21, 2021
ff55e32
feat: update deploy ci config
Lanttcat Dec 21, 2021
ea51b50
feat: add zerion fallback for get fungible token asset list
Lanttcat Dec 21, 2021
b483308
fix: update deploy ci
Lanttcat Dec 21, 2021
eb08e76
fix: use dimension dev token action to publish
Lanttcat Dec 22, 2021
f5f977f
feat: update package to publish
Lanttcat Dec 22, 2021
53b5bbd
feat: generate ts type
Lanttcat Dec 22, 2021
a210150
feat: change ci
Lanttcat Dec 22, 2021
05e264d
feat: support dts rollup
Jack-Works Dec 22, 2021
6efeb7d
feat: disable get asset from zerion
Lanttcat Dec 24, 2021
3a14d4b
feat: add fetch non fungible token from opensea
Lanttcat Dec 24, 2021
ac93b20
feat: add fetch non fungible collectible from opensea
Lanttcat Dec 24, 2021
4c9212c
feat: should clear websocket pool data
Lanttcat Dec 24, 2021
00081fa
feat: add opensea data in producer
Lanttcat Dec 24, 2021
364ea7c
feat: use socket to loading nft in web3 tab
Lanttcat Dec 24, 2021
94d5f2f
fix: cspell
Lanttcat Dec 24, 2021
57d2b4c
feat: add async send for websocket
Lanttcat Dec 25, 2021
0edcd9a
feat: send single request when use web socket and close
Lanttcat Dec 25, 2021
39ea8d7
feat: dashboard collection use http restful
Lanttcat Dec 25, 2021
ba94e1f
fix: style
Lanttcat Dec 25, 2021
a8cd42c
feat: add production websocket endpoint
Lanttcat Dec 26, 2021
1ef6710
fix: ci
Lanttcat Dec 26, 2021
003b8ed
chore: move down jest dependencies
Lanttcat Dec 27, 2021
963c210
chore: add comment for provider proxy
Lanttcat Dec 27, 2021
9a5ee7d
refactor: rename use websocket
Lanttcat Dec 27, 2021
33020c6
fix: error
Lanttcat Dec 27, 2021
5184c14
chore: add deploy ci
Lanttcat Dec 27, 2021
6407fb9
feat: add use socket hook
Lanttcat Dec 27, 2021
c6a02f0
fix: test method type
Lanttcat Dec 27, 2021
3b5dde4
fix: ci
Lanttcat Dec 27, 2021
9143656
feat: use single websocket instance
Lanttcat Dec 27, 2021
2f57d6c
feat: improve nft wall
Lanttcat Dec 27, 2021
1a2ad1b
feat: merge develop
Lanttcat Dec 27, 2021
69a4127
feat: support rarible
Lanttcat Dec 28, 2021
c5ab467
fix: try fix deploy provider proxy to gh pkg
septs Dec 28, 2021
e3ad759
feat: support rarible
Lanttcat Dec 28, 2021
d7be488
feat: dashboard nft list use websocket
Lanttcat Dec 28, 2021
46cb0f3
fix: dashboard nft list use websocket alway loading
Lanttcat Dec 28, 2021
89729c3
refactor: remove unused code
Lanttcat Dec 29, 2021
4aa2864
refactor: should show in rarible nft in rarible tab
Lanttcat Dec 30, 2021
9918d8e
fix: disable cors in proxy for web3-proider
Lanttcat Dec 30, 2021
a8fe5a1
fix: opensea nft response type
Lanttcat Dec 30, 2021
7fc73c3
fix: use reconnecting websocket to replace websocket
Lanttcat Dec 30, 2021
a3f559f
fix: if have instance use it
Lanttcat Dec 30, 2021
324d00e
Merge branch 'develop' into feat/api-provider-proxy
Lanttcat Jan 4, 2022
18b61e3
refactor: remove tood
Lanttcat Jan 4, 2022
450301b
fix: test
Lanttcat Jan 4, 2022
e75999f
feat: deploy branch
Lanttcat Jan 4, 2022
3f4385f
fix: test
Lanttcat Jan 4, 2022
ce9f487
Merge branch 'develop' into feat/api-provider-proxy
Lanttcat Jan 5, 2022
1baaa78
fix: pr feedback
Lanttcat Jan 5, 2022
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
42 changes: 42 additions & 0 deletions .github/workflows/deploy-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish Proxy Package

on:
push:
branches: [hyper-proxy-deploy]

jobs:
build:
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
steps:
- name: Get cache date
id: get-date
run: echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v2
with:
cache: pnpm
- name: Restore cache
uses: actions/cache@v2
with:
path: packages/mask/node_modules/.cache/
key: ${{ runner.os }}-extension-${{ hashFiles('pnpm-lock.yaml') }}-${{ steps.get-date.outputs.date }}
restore-keys: ${{ runner.os }}-extension-${{ hashFiles('pnpm-lock.yaml') }}
- uses: DimensionDev/github-token-action@latest
with:
registry: true
- run: pnpm install
- run: pnpm build
- run: pnpm build
working-directory: packages/provider-proxy
- run: npm publish
working-directory: packages/provider-proxy/dist
7 changes: 5 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,12 @@
"koda",
"Enjin",
"poap",
"irss",
"CELO",
"flac"
"flac",
"treeshake",
"xtest",
"xdescribe",
"irss"
],
"ignoreRegExpList": ["/@servie/"],
"overrides": [
Expand Down
4 changes: 4 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ const config: InitialOptionsTsJest = {
clearMocks: true,
coverageProvider: 'v8',
testMatch: ['**/tests/**/*.[jt]s?(x)'],
modulePathIgnorePatterns: ['dist'],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
moduleNameMapper: {
'@masknet/shared-base': '<rootDir>/packages/shared-base/src/index.ts',
'jest-websocket-mock': '<rootDir>/packages/web3-shared/base/node_modules/jest-websocket-mock',
'reconnecting-websocket': '<rootDir>/packages/web3-shared/base/node_modules/reconnecting-websocket',
'date-fns/(.*)': '<rootDir>/packages/web3-shared/base/node_modules/date-fns/$1',
},
snapshotSerializers: ['@masknet/serializer'],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, memo, SetStateAction, useCallback, useEffect, useState } from 'react'
import { Dispatch, memo, SetStateAction, useCallback, useEffect, useRef, useState } from 'react'
import { Box, Stack, TablePagination } from '@mui/material'
import { makeStyles } from '@masknet/theme'
import { LoadingPlaceholder } from '../../../../components/LoadingPlaceholder'
Expand Down Expand Up @@ -33,24 +33,37 @@ interface CollectibleListProps {
selectedNetwork: Web3Plugin.NetworkDescriptor | null
}

const ITEM_SIZE = {
width: 150,
height: 250,
}

export const CollectibleList = memo<CollectibleListProps>(({ selectedNetwork }) => {
const [page, setPage] = useState(0)
const navigate = useNavigate()
const account = useAccount()
const { Asset } = useWeb3PluginState()
const network = useNetworkDescriptor()
const [loadingSize, setLoadingSize] = useState<number>()
const [loadingCollectible, setLoadingCollectible] = useState(true)
const [renderData, setRenderData] = useState<Web3Plugin.NonFungibleToken[]>([])

const {
value = { data: [], hasNextPage: false },
loading: collectiblesLoading,
error: collectiblesError,
retry,
} = useAsyncRetry(
async () =>
Asset?.getNonFungibleAssets?.(account, { page: page, size: 20 }, undefined, selectedNetwork ?? undefined),
[account, Asset, network, page, selectedNetwork],
[account, Asset, network, selectedNetwork],
)

useEffect(() => {
if (!loadingSize) return
const render = value.data.slice(page * loadingSize, (page + 1) * loadingSize)
setRenderData(render)
}, [value, loadingSize, page])

const onSend = useCallback(
(detail: Web3Plugin.NonFungibleToken) =>
navigate(DashboardRoutes.WalletsTransfer, {
Expand All @@ -63,24 +76,31 @@ export const CollectibleList = memo<CollectibleListProps>(({ selectedNetwork })
)

useEffect(() => {
PluginMessages.Wallet.events.erc721TokensUpdated.on(() => {
retry()
PluginMessages.Wallet.events.erc721TokensUpdated.on(() => retry())
PluginMessages.Wallet.events.socketMessageUpdated.on((info) => {
if (!info.done) {
retry()
}
setLoadingCollectible(false)
})
}, [retry])

const { data: collectibles = [], hasNextPage } = value
const hasNextPage = (page + 1) * (loadingSize ?? 0) < value.data.length

return (
<CollectibleListUI
isLoading={collectiblesLoading}
isEmpty={!!collectiblesError || collectibles.length === 0}
isLoading={renderData.length === 0 && loadingCollectible}
isEmpty={
(!!collectiblesError || renderData.length === 0) && !(renderData.length === 0 && loadingCollectible)
}
page={page}
onPageChange={setPage}
hasNextPage={hasNextPage}
showPagination={!collectiblesLoading && !(page === 0 && !hasNextPage)}
dataSource={collectibles}
showPagination={!loadingCollectible && !(page === 0 && !hasNextPage)}
dataSource={renderData}
chainId={network?.chainId ?? 1}
onSend={onSend}
setLoadingSize={(size) => setLoadingSize(size)}
/>
)
})
Expand All @@ -95,15 +115,36 @@ export interface CollectibleListUIProps {
chainId: number
dataSource: Web3Plugin.NonFungibleToken[]
onSend(detail: Web3Plugin.NonFungibleToken): void
setLoadingSize(fn: (pre: number | undefined) => number): void
}

export const CollectibleListUI = memo<CollectibleListUIProps>(
({ page, onPageChange, isLoading, isEmpty, hasNextPage, showPagination, chainId, dataSource, onSend }) => {
({
page,
onPageChange,
isLoading,
isEmpty,
hasNextPage,
showPagination,
chainId,
dataSource,
onSend,
setLoadingSize,
}) => {
const t = useDashboardI18N()
const { classes } = useStyles()
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
if (!ref.current) return
const width = ref.current.offsetWidth
const height = ref.current.offsetHeight - 60
const baseSize = Math.floor(width / ITEM_SIZE.width) * Math.floor(height / ITEM_SIZE.height)
setLoadingSize((prev) => prev ?? Math.floor(baseSize * 0.8))
}, [ref.current])

return (
<Stack flexDirection="column" justifyContent="space-between" height="100%">
<Stack flexDirection="column" justifyContent="space-between" height="100%" ref={ref}>
<>
{isLoading ? (
<LoadingPlaceholder />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const FungibleTokenTable = memo<TokenTableProps>(({ selectedChainId }) =>

useEffect(() => {
PluginMessages.Wallet.events.erc20TokensUpdated.on(() =>
setTimeout(() => setTokenUpdateCount(tokenUpdateCount + 1), 100),
setTimeout(() => setTokenUpdateCount((prev) => prev + 1), 100),
)
}, [])

Expand Down
4 changes: 4 additions & 0 deletions packages/dashboard/src/web3/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
isInjectedProvider,
} from '@masknet/web3-shared-evm'
import { Services, Messages, PluginServices, PluginMessages } from '../API'
import { getProxyWebsocketInstance } from '@masknet/web3-shared-base'

const Web3Provider = createExternalProvider()

Expand Down Expand Up @@ -113,6 +114,9 @@ export const Web3Context: Web3ProviderType = {
getAddressNamesList: PluginServices.Wallet.getAddressNames,
getTransactionList: PluginServices.Wallet.getTransactionList,
fetchERC20TokensFromTokenLists: Services.Ethereum.fetchERC20TokensFromTokenLists,
providerSocket: getProxyWebsocketInstance((info) =>
PluginMessages.Wallet.events.socketMessageUpdated.sendToAll(info),
),
}

export function createExternalProvider() {
Expand Down
Loading