@flapsdk/vault-runtime

中文文档
0.1.42发布于 2026/11/10TypeScriptES Module零依赖近 30 天下载 3182

Shared runtime surface for Flap Vault UI hosts, Workbench preview, and custom Vault components.

原始使用文档
文档目录7 节
  1. Exports
  2. Mini App subroutes
  3. FSI queries
  4. Transaction confirmation
  5. taxed.fun source-checker compatibility
  6. Shared Vault UI and Mini App v2
  7. Dynamic IPFS content

@flapsdk/vault-runtime

Generated from flap-vault-ui-template.

This package is the shared runtime surface that local preview, Artifact Workbench, and flap.sh should agree on.

Package version: 0.1.42. Source commit: 686934578ec40aec418484e7c1dac1f6782d598e.

Exports

  • ./sdk: component-facing SDK hooks, helpers, types, and local oracle reader helper
  • ./ui: shared UI primitives
  • ./host: host-only provider, runtime preflight helpers and the browser-safe same-origin presentation fetcher
  • ./server: server-side presentation, runtime oracle-registry helpers, controlled image/text upload handler, and the Vault V2 NFT metadata/media resolver

See runtime-contract.json for the machine-readable subpath contract.

Mini App subroutes

Standalone Mini Apps use useMiniAppRouter() from ./sdk. It returns App-relative pathname, decoded segments, search, and push(path), replace(path), back(). Paths start with / inside the current App; external URLs, traversal, encoded separators and hashes are rejected. Routing grants no wallet or contract access. MINI_APP_ROUTING_VERSION = 1 and sdkFeatures.miniAppRouting = 1 identify the feature. Hosts inject a router into MiniAppRuntimeProvider; ./host exports parseMiniAppPath, createMiniAppMemoryRouter and createMiniAppBrowserRouter. Old Apps need no adapter. The new hook fails explicitly if the host has not enabled routing. Deploy supporting hosts before accepting new route-dependent artifacts; source-package provenance is unchanged.

FSI queries

Declare the intended FSI root in manifest.endpoints to use sdk.readFsi(relativePath, params). Supported roots, in selection order, are https://fsi.taxed.fun/fsi/v1, https://bsc-debug.butterfly.army/fsi/v1 and BSC Testnet https://bsc-testnet-debug.butterfly.army/fsi/v1. When multiple roots are declared, this order applies regardless of array order or chainId. Testnet packages should declare only the testnet FSI root. Failed requests never fall back to another host. Exact reviewed root declarations, HTTPS origin/path boundaries, GET, credential and redirect restrictions remain. Hosts and Workbench must deploy a release containing the selected endpoint policy and synchronize the Workbench source checker before accepting those packages.

Transaction confirmation

waitForTx(hash) polls the original transaction hash through the public client selected for that operation. It queries immediately, then every 2 seconds after a pending or transient-error response, with an 8-second deadline per query and a 180-second total deadline. It returns the original success/reverted status; applications must check status === "success" before showing success or refreshing as successful. A timeout means the result is unknown: retain the hash and reconcile it before offering another transaction. Polling does not follow sped-up or cancelled replacement transactions; the original hash can time out. The public API and receipt fields remain compatible.

taxed.fun source-checker compatibility

The official template source for stable 0.1.40 adds reviewed native-fetch queries on every valid strict taxed.fun subdomain, including multi-level subdomains. Hosts and paths must stay literal, query values must use the global encodeURIComponent, and manifest endpoint declarations and safe GET options remain required. The apex domain, dynamic hosts/paths and unsafe options do not gain permission. Existing sdk.readFsi routing and the SDK exports are unchanged.

The source checker is not shipped in this npm package. Deploy the matching template and Workbench checker policies separately; upgrading this package alone does not enable the new native-fetch policy or approve an endpoint. See the 0.1.40 release guide and request policy.

Shared Vault UI and Mini App v2

This shared runtime supports standalone App wallet operations through useFlapSdk({ chainId }) and the host-owned CopyButton from ./ui. Vault UI keeps useFlapSdk() and its token-bound context. Both use this one package; existing token-bound Mini Apps remain compatible. Stable development uses the official main template and npm latest. The shared CopyButton copies up to 1,048,576 UTF-16 code units without truncation.

Dynamic IPFS content

Stable runtime 0.1.37 introduces sdk.readIpfsText(cid, path?), which returns UTF-8 text or JSON as a string, and IpfsText for escaped plain-text display. IpfsImage accepts dynamic bare CIDs from FSI, contract state, or SDK uploads. The SDK exports IPFS_CONTENT_VERSION = 1; the runtime contract advertises sdkFeatures.ipfsContent = 1. Stable 0.1.36 lacks the text API/component.

Vault source keeps the @/src/sdk and @/src/ui authoring aliases. Obtain sdk with useFlapSdk(), then call the reader from an async effect or event handler. Independent Mini App v2 uses useFlapSdk({ chainId: 56 }); its chain SDK exposes the same reader and reviewed readFsi API. Import IpfsText and IpfsImage from the UI alias for rendering:

const body = await sdk.readIpfsText(textCid);
// Parse JSON only if the application expects JSON content.
const post = JSON.parse(await sdk.readIpfsText(jsonCid));
<IpfsText cid={item.textCid} fallback={i18n.t("contentLoading")} />
<IpfsImage cid={item.imageCid} alt={i18n.t("postImageAlt")} />

Use safe relative path values for directory CIDs, never a gateway URL or ipfs:// URI. The runtime controls gateways and validates every CID/path. Text reads omit credentials/referrers, reject redirects and HTML responses, enforce UTF-8 and a 256 KiB limit, and have an 8-second network/body deadline after acquiring an active slot. Reads are deduplicated, cached and concurrency limited. IpfsText does not interpret HTML or Markdown. Localize loading/error and alt text, and paginate feeds. IpfsBackground remains static CID-only.

Dynamic content sources require human review. Upgrade Workbench and Flap hosts to the published runtime and deploy Workbench's matching static checker before accepting new components. Reads use platform gateways without a new host route; uploads continue through the existing host-owned upload service. Automated upload fixtures are mocked and do not verify live gateway availability.

Source documentation:

版本与发布记录

@flapsdk/vault-runtime 共发布 56 个版本,首次发布于 2026/05/25;过去 12 个月发布了 56 个版本。

版本发布日期距今
0.1.42latest2026/11/105 天前
0.1.412026/11/088 天前
0.1.402026/11/0313 天前
0.1.40-beta.routing.0routing2026/10/2917 天前
0.1.40-next.4next2026/10/2621 天前
0.1.40-next.32026/10/2621 天前

关于 @flapsdk/vault-runtime 的常见问题

@flapsdk/vault-runtime 是什么?

Shared runtime surface for Flap Vault UI hosts, Workbench preview, and custom Vault components.

如何安装 @flapsdk/vault-runtime?

在项目目录运行 npm install @flapsdk/vault-runtime,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:viem(^2.39.3)、react(19.2.8)、wagmi(^2.12.14)、react-dom(19.2.8)、@tanstack/react-query(^5.37.1)、@rainbow-me/rainbowkit(^2.1.7)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@flapsdk/vault-runtime 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flapsdk/vault-runtime 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@flapsdk/vault-runtime 可以商用吗?

@flapsdk/vault-runtime 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@flapsdk/vault-runtime 的下载量有多少?

根据 npm 官方下载统计,@flapsdk/vault-runtime 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,182 次,日均约 106 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flapsdk/vault-runtime 还在维护吗?

最新版本 0.1.42 发布于 2026/11/10(5 天前);至今共发布 56 个版本,其中过去 12 个月发布了 56 个;首次发布于 2026/05/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。