diff --git a/.github/workflows/deploy-dapp-example-web.yml b/.github/workflows/deploy-dapp-example-web.yml index 77ea7f66..3748124b 100644 --- a/.github/workflows/deploy-dapp-example-web.yml +++ b/.github/workflows/deploy-dapp-example-web.yml @@ -25,6 +25,7 @@ jobs: # Next.js environment variables echo "NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > ./packages/example/.env echo "NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=${{ secrets.BLOCKFROST_CARDANO_PROJECT_ID }}" >> ./packages/example/.env + echo "NEXT_PUBLIC_OKLINK_API_KEY=${{ secrets.EXAMPLE_OKLINK_API_KEY }}" >> ./packages/example/.env - name: Install Dependency env: diff --git a/.github/workflows/publish-npm-package.yml b/.github/workflows/publish-npm-package.yml index bc2de42d..f8b98fd4 100644 --- a/.github/workflows/publish-npm-package.yml +++ b/.github/workflows/publish-npm-package.yml @@ -47,6 +47,7 @@ jobs: # Next.js environment variables echo "NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > ./packages/example/.env echo "NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=${{ secrets.BLOCKFROST_CARDANO_PROJECT_ID }}" >> ./packages/example/.env + echo "NEXT_PUBLIC_OKLINK_API_KEY=${{ secrets.OKLINK_API_KEY }}" >> ./packages/example/.env - name: Build Example Web run: | diff --git a/packages/core/src/versionInfo.ts b/packages/core/src/versionInfo.ts index e9a21183..7510fa27 100644 --- a/packages/core/src/versionInfo.ts +++ b/packages/core/src/versionInfo.ts @@ -1,5 +1,5 @@ -const version = '2.1.20'; +const version = '2.1.21'; const versionBuild = '2020-0101-1'; export default { diff --git a/packages/example/.env.simple b/packages/example/.env.simple index da10db09..c5cc2d47 100644 --- a/packages/example/.env.simple +++ b/packages/example/.env.simple @@ -2,4 +2,6 @@ NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxxx NEXT_PUBLIC_WALLET_CONNECT_RELAY_URL=wss://relay.walletconnect.com # block frost project id -NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=xxxx \ No newline at end of file +NEXT_PUBLIC_BLOCKFROST_CARDANO_PROJECT_ID=xxxx +# oklink api key +NEXT_PUBLIC_OKLINK_API_KEY=xxxx diff --git a/packages/example/chains.ts b/packages/example/chains.ts index fe0aff19..56343007 100644 --- a/packages/example/chains.ts +++ b/packages/example/chains.ts @@ -67,6 +67,12 @@ export const registeredChains: IChainInfo[] = [ href: '/aptosMartian', icon: 'https://uni.onekey-asset.com/static/chain/apt.png', }, + { + id: uuid.v4(), + name: 'Benfen', + href: '/benfen', + icon: 'https://uni.onekey-asset.com/static/chain/bfc.png', + }, { id: uuid.v4(), name: 'BTC', diff --git a/packages/example/components/ApiActuator/ApiPayloadProvider.tsx b/packages/example/components/ApiActuator/ApiPayloadProvider.tsx index aeb07701..393e2e2b 100644 --- a/packages/example/components/ApiActuator/ApiPayloadProvider.tsx +++ b/packages/example/components/ApiActuator/ApiPayloadProvider.tsx @@ -18,7 +18,7 @@ type ApiPayloadAction = | { type: 'SET_PRESUPPOSE_PARAMS'; payload: IPresupposeParam[] }; // 优化 JSON 格式化函数 -const tryFormatJson = (json: string) => { +export const tryFormatJson = (json: string) => { try { return JSON.stringify(JSON.parse(json), null, 2); } catch { diff --git a/packages/example/components/ApiForm/ApiAutoTextArea.tsx b/packages/example/components/ApiForm/ApiAutoTextArea.tsx new file mode 100644 index 00000000..b5f18a01 --- /dev/null +++ b/packages/example/components/ApiForm/ApiAutoTextArea.tsx @@ -0,0 +1,69 @@ +import React, { memo, useContext, useEffect } from 'react'; +import { useAtom } from 'jotai'; +import { Label } from '../ui/label'; +import { ApiFormContext } from './ApiForm'; +import { AutoHeightTextarea } from '../ui/textarea'; + + +interface AutoTextAreaProps { + id: string; + placeholder?: string; + label?: string; + required?: boolean; +} + +const TextArea = memo(({ + id, + placeholder, + label, + required +}: AutoTextAreaProps) => { + const context = useContext(ApiFormContext); + if (!context) throw new Error('ApiField must be used within ApiForm'); + + const { store } = context; + const [field, setField] = useAtom(store.fieldsAtom(id)); + + useEffect(() => { + field.name = label; + field.required = required; + }, []); + + return <> + setField({ ...field, value: e.target.value })} + placeholder={placeholder} + disabled={field.disabled} + /> + {field.error && ( +
{field.error}
+ )} + +}); + +export interface ApiAutoTextAreaProps extends AutoTextAreaProps { + id: string; +} + +export const ApiAutoTextArea = memo(({ + id, + label, + placeholder, + required +}: ApiAutoTextAreaProps) => { + return ( +
+ {label && ( + + )} +