diff --git a/package.json b/package.json index 05581d12..4925c68e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unisat-extension", - "version": "1.7.2", + "version": "1.7.3", "private": true, "homepage": "https://github.com/unisat-wallet/extension#readme", "bugs": { diff --git a/release-notes.md b/release-notes.md index 972d1764..c5b2d3eb 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,5 +1,11 @@ # UniSat Wallet Release Notes +## v1.7.3 + +New Features + +- Added support for BRC 2.0 + ## v1.7.2 New Features diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index b48bb999..96e59b79 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -2867,5 +2867,18 @@ export class WalletController extends BaseController { getBRC20RecentHistory(address: string, ticker: string): Promise { return openapiService.getBRC20RecentHistory(address, ticker); } + + getBRC20ProgList = async (address: string, currentPage: number, pageSize: number) => { + const cursor = (currentPage - 1) * pageSize; + const size = pageSize; + const { total, list } = await openapiService.getBRC20ProgList(address, cursor, size); + + return { + currentPage, + pageSize, + total, + list + }; + }; } export default new WalletController(); diff --git a/src/background/service/openapi.ts b/src/background/service/openapi.ts index 6aee676b..6ff8cb9b 100644 --- a/src/background/service/openapi.ts +++ b/src/background/service/openapi.ts @@ -967,6 +967,14 @@ export class OpenApiService { feeRate }); } + + async getBRC20ProgList( + address: string, + cursor: number, + size: number + ): Promise<{ list: TokenBalance[]; total: number }> { + return this.httpGet('/v5/brc20-prog/list', { address, cursor, size, type: 5 }); + } } export default new OpenApiService(); diff --git a/src/shared/constant/index.ts b/src/shared/constant/index.ts index e5bb7cdf..20cf6895 100644 --- a/src/shared/constant/index.ts +++ b/src/shared/constant/index.ts @@ -247,6 +247,7 @@ export type TypeChain = { showPrice: boolean; defaultExplorer: 'mempool-space' | 'unisat-explorer'; enableBrc20SingleStep?: boolean; + enableBrc20Prog?: boolean; }; export const CHAINS_MAP: { [key: string]: TypeChain } = { @@ -264,7 +265,8 @@ export const CHAINS_MAP: { [key: string]: TypeChain } = { unisatExplorerUrl: 'https://uniscan.cc', okxExplorerUrl: '', showPrice: true, - defaultExplorer: 'unisat-explorer' + defaultExplorer: 'unisat-explorer', + enableBrc20Prog: true }, [ChainType.BITCOIN_TESTNET]: { enum: ChainType.BITCOIN_TESTNET, @@ -312,7 +314,8 @@ export const CHAINS_MAP: { [key: string]: TypeChain } = { unisatExplorerUrl: 'https://uniscan.cc/signet', okxExplorerUrl: '', showPrice: false, - defaultExplorer: 'unisat-explorer' + defaultExplorer: 'unisat-explorer', + enableBrc20Prog: true }, [ChainType.FRACTAL_BITCOIN_MAINNET]: { enum: ChainType.FRACTAL_BITCOIN_MAINNET, diff --git a/src/shared/types.ts b/src/shared/types.ts index 41299458..641054cf 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -442,6 +442,7 @@ export interface AddressSummary { atomicalsCount: number; brc20Count: number; brc20Count5Byte: number; + brc20Count6Byte: number; arc20Count: number; runesCount: number; loading?: boolean; diff --git a/src/ui/pages/BRC20/BRC20TokenScreen.tsx b/src/ui/pages/BRC20/BRC20TokenScreen.tsx index dd4930c2..ecd50a4c 100644 --- a/src/ui/pages/BRC20/BRC20TokenScreen.tsx +++ b/src/ui/pages/BRC20/BRC20TokenScreen.tsx @@ -292,13 +292,27 @@ export default function BRC20TokenScreen() { const chainType = useChainType(); const chain = useChain(); + const isBrc20Prog = useMemo(() => { + if (chainType === ChainType.BITCOIN_MAINNET || chainType === ChainType.BITCOIN_SIGNET) { + if (ticker.length == 6) { + return true; + } + } + return false; + }, [ticker, chainType]); + const enableTrade = useMemo(() => { + if (isBrc20Prog) { + return false; + } if (chainType === ChainType.BITCOIN_MAINNET || chainType === ChainType.FRACTAL_BITCOIN_MAINNET) { return true; } else { return false; } - }, [chainType]); + }, [chainType, isBrc20Prog]); + + const enableHistory = isBrc20Prog ? false : true; const shouldUseTwoRowLayout = useMemo(() => { return enableTrade && chain.enableBrc20SingleStep; @@ -306,22 +320,38 @@ export default function BRC20TokenScreen() { const marketPlaceUrl = useBRC20MarketPlaceWebsite(ticker); + const inscribePlaceUrl = useMemo(() => { + if (isBrc20Prog) { + return `${unisatWebsite}/inscribe?tab=brc20-prog&tick=${encodeURIComponent(ticker)}`; + } + return `${unisatWebsite}/inscribe?tick=${encodeURIComponent(ticker)}`; + }, [isBrc20Prog, ticker, unisatWebsite]); + const tabItems = useMemo(() => { - const items = [ - { - key: TabKey.HISTORY, - label: t('history') - }, - { - key: TabKey.DETAILS, - label: t('details') - } - ]; - return items; - }, [t]); + if (enableHistory) { + const items = [ + { + key: TabKey.HISTORY, + label: t('history') + }, + { + key: TabKey.DETAILS, + label: t('details') + } + ]; + return items; + } else { + return [ + { + key: TabKey.DETAILS, + label: t('details') + } + ]; + } + }, [t, enableHistory]); const renderTabChildren = useMemo(() => { - if (activeTab === TabKey.HISTORY) { + if (activeTab === TabKey.HISTORY && enableHistory) { return ; } @@ -375,7 +405,7 @@ export default function BRC20TokenScreen() { ); } - }, [activeTab, deployInscription]); + }, [activeTab, deployInscription, enableHistory, tokenSummary]); return ( @@ -399,7 +429,11 @@ export default function BRC20TokenScreen() { color={'ticker_color2'} /> - + {isBrc20Prog ? ( + + ) : ( + + )} @@ -420,7 +454,7 @@ export default function BRC20TokenScreen() { disabled={!enableMint} icon="pencil" onClick={(e) => { - window.open(`${unisatWebsite}/inscribe?tick=${encodeURIComponent(ticker)}`); + window.open(inscribePlaceUrl); }} full /> @@ -489,7 +523,7 @@ export default function BRC20TokenScreen() { disabled={!enableMint} icon="pencil" onClick={(e) => { - window.open(`${unisatWebsite}/brc20/${encodeURIComponent(ticker)}`); + window.open(inscribePlaceUrl); }} style={{ ...(!enableMint ? { backgroundColor: 'rgba(255,255,255,0.15)' } : {}), @@ -536,11 +570,12 @@ export default function BRC20TokenScreen() { }); }} /> - ) : enableTrade ? ( + ) : (