@ic-reactor/mcp 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +108 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +77 -0
- package/.github/actions/setup-rust-wasm/action.yml +25 -0
- package/.github/dependabot.yml +107 -0
- package/.github/workflows/auth-latest.yml +67 -0
- package/.github/workflows/b3pay-site.yml +49 -0
- package/.github/workflows/ci.yml +430 -0
- package/.github/workflows/codeql.yml +41 -0
- package/.github/workflows/dependency-review.yml +68 -0
- package/.github/workflows/docs-check.yml +98 -0
- package/.github/workflows/docs.yml +265 -0
- package/.github/workflows/e2e.yml +90 -0
- package/.github/workflows/examples-published.yml +97 -0
- package/.github/workflows/release.yml +326 -0
- package/.husky/pre-commit +12 -0
- package/.prettierignore +109 -0
- package/.prettierrc +6 -0
- package/AGENTS.md +103 -0
- package/CHANGELOG.md +3268 -0
- package/CLAUDE.md +93 -0
- package/CNAME +1 -0
- package/CODE_OF_CONDUCT.md +7 -0
- package/CONTRIBUTING.md +433 -0
- package/LICENSE +21 -0
- package/README.md +2 -2
- package/SECURITY.md +74 -0
- package/b3pay-module.json +194 -0
- package/docs/.remarkrc.json +10 -0
- package/docs/README.md +64 -0
- package/docs/astro.config.mjs +205 -0
- package/docs/favicon.svg +15 -0
- package/docs/package.json +39 -0
- package/docs/public/favicon.svg +15 -0
- package/docs/public/ic-reactor-social-card.png +0 -0
- package/docs/scripts/b3pay-static.mjs +22 -0
- package/docs/scripts/check-example-docs.mjs +214 -0
- package/docs/scripts/check-links.mjs +212 -0
- package/docs/scripts/fix-dist-links.js +125 -0
- package/docs/scripts/fix-frontmatter.js +71 -0
- package/docs/scripts/remove-redundant-h1.cjs +48 -0
- package/docs/scripts/rewrite-typedoc-links.js +110 -0
- package/docs/scripts/split-index.js +69 -0
- package/docs/src/assets/ic-reactor-hero-dark.svg +23 -0
- package/docs/src/assets/ic-reactor-hero-light.svg +23 -0
- package/docs/src/assets/ic-reactor-lockup-dark.svg +15 -0
- package/docs/src/assets/ic-reactor-lockup-light.svg +15 -0
- package/docs/src/assets/ic-reactor-mark-dark.svg +14 -0
- package/docs/src/assets/ic-reactor-mark-light.svg +14 -0
- package/docs/src/assets/layers/candid-core-layer-icon-dark.svg +4 -0
- package/docs/src/assets/layers/candid-core-layer-icon-light.svg +4 -0
- package/docs/src/assets/layers/candid-profile-layer-icon-dark.svg +4 -0
- package/docs/src/assets/layers/candid-profile-layer-icon-light.svg +4 -0
- package/docs/src/assets/layers/ic-reactor-layer-icon-dark.svg +4 -0
- package/docs/src/assets/layers/ic-reactor-layer-icon-light.svg +4 -0
- package/docs/src/components/LibraryCards.astro +172 -0
- package/docs/src/components/LibraryIcon.astro +28 -0
- package/docs/src/components/SiteTitle.astro +241 -0
- package/docs/src/content/docs/404.mdx +19 -0
- package/docs/src/content/docs/build/agent-tools.mdx +593 -0
- package/docs/src/content/docs/build/icrc1-wallet.mdx +619 -0
- package/docs/src/content/docs/build/ssr-per-user.mdx +552 -0
- package/docs/src/content/docs/examples/canister-studio.mdx +95 -0
- package/docs/src/content/docs/examples/icrc-ledger.mdx +45 -0
- package/docs/src/content/docs/examples/index.mdx +38 -0
- package/docs/src/content/docs/examples/next-ssr.mdx +73 -0
- package/docs/src/content/docs/examples/node-agent-tool.mdx +80 -0
- package/docs/src/content/docs/examples/vite-wallet.mdx +71 -0
- package/docs/src/content/docs/guides/auth.mdx +1181 -0
- package/docs/src/content/docs/guides/client.mdx +551 -0
- package/docs/src/content/docs/guides/deploy.mdx +180 -0
- package/docs/src/content/docs/guides/errors.mdx +475 -0
- package/docs/src/content/docs/guides/getting-started.mdx +620 -0
- package/docs/src/content/docs/guides/reads.mdx +586 -0
- package/docs/src/content/docs/guides/ssr.mdx +529 -0
- package/docs/src/content/docs/guides/testing.mdx +401 -0
- package/docs/src/content/docs/guides/values.mdx +261 -0
- package/docs/src/content/docs/guides/vite-plugin.mdx +690 -0
- package/docs/src/content/docs/guides/writes.mdx +572 -0
- package/docs/src/content/docs/ic-reactor/index.mdx +167 -0
- package/docs/src/content/docs/index.mdx +65 -0
- package/docs/src/content/docs/migrating-from-3.mdx +535 -0
- package/docs/src/content/docs/packages/core.mdx +186 -0
- package/docs/src/content/docs/packages/mcp.mdx +163 -0
- package/docs/src/content/docs/packages/react.mdx +207 -0
- package/docs/src/content/docs/packages/vite-plugin.mdx +73 -0
- package/docs/src/content/docs/versioning.mdx +104 -0
- package/docs/src/content.config.ts +7 -0
- package/docs/src/styles/custom.css +189 -0
- package/docs/tsconfig.typedoc.json +26 -0
- package/docs/typedoc-entry.ts +17 -0
- package/docs/typedoc.json +37 -0
- package/e2e/Cargo.lock +646 -0
- package/e2e/Cargo.toml +3 -0
- package/e2e/README.md +101 -0
- package/e2e/frontends/build.mjs +94 -0
- package/e2e/frontends/index.html +10 -0
- package/e2e/global-setup.ts +65 -0
- package/e2e/icp.yaml +38 -0
- package/e2e/package.json +40 -0
- package/e2e/setup.ts +6 -0
- package/e2e/src/actor/Cargo.toml +14 -0
- package/e2e/src/actor/hello_actor.did +10 -0
- package/e2e/src/actor/src/lib.rs +73 -0
- package/e2e/src/calls.test.ts +132 -0
- package/e2e/src/declarations/hello_actor.envelope.json +175 -0
- package/e2e/src/declarations/hello_actor.ts +15 -0
- package/e2e/src/errors.test.ts +107 -0
- package/e2e/src/frontend-headers.test.ts +253 -0
- package/e2e/src/identity.test.ts +61 -0
- package/e2e/src/react.test.tsx +59 -0
- package/e2e/src/replica.ts +70 -0
- package/e2e/src/vite-env.test.ts +108 -0
- package/e2e/test.sh +47 -0
- package/e2e/tsconfig.json +20 -0
- package/e2e/tsconfig.typecheck.json +9 -0
- package/e2e/vitest.config.ts +22 -0
- package/eslint.config.mjs +100 -0
- package/evals/PREREGISTRATION.md +1346 -0
- package/evals/README.md +756 -0
- package/evals/conditions/thin/condition.json +8 -0
- package/evals/conditions/thin/docs/candid-core-cli.README.md +90 -0
- package/evals/conditions/thin/docs/candid-core-schema.README.md +339 -0
- package/evals/conditions/thin/package.json +25 -0
- package/evals/conditions/thin/starter/src/generated/icrc1.ts +57 -0
- package/evals/conditions/thin-guide/condition.json +10 -0
- package/evals/conditions/thin-guide/docs/llms.txt +292 -0
- package/evals/conditions/v3/condition.json +9 -0
- package/evals/conditions/v3/docs/ic-reactor-core.llms.txt +232 -0
- package/evals/conditions/v3/docs/ic-reactor-react.llms.txt +280 -0
- package/evals/conditions/v3/docs/llms-full.txt +1053 -0
- package/evals/conditions/v3/package.json +26 -0
- package/evals/conditions/v3/starter/src/declarations/icrc1.did.d.ts +95 -0
- package/evals/conditions/v3/starter/src/declarations/icrc1.did.js +140 -0
- package/evals/conditions/v4/PORTING.md +384 -0
- package/evals/conditions/v4/README.md +106 -0
- package/evals/conditions/v4/condition.json +5 -0
- package/evals/conditions/v4/docs/llms.txt +323 -0
- package/evals/conditions/v4/package.json +27 -0
- package/evals/conditions/v4/starter/src/generated/icrc1.ts +78 -0
- package/evals/conditions/v4-proto/condition.json +6 -0
- package/evals/conditions/v4-proto/docs/llms.txt +291 -0
- package/evals/conditions/v4-proto/lib/SHIM-NOTES.md +20 -0
- package/evals/conditions/v4-proto/lib/package.json +27 -0
- package/evals/conditions/v4-proto/lib/src/client.ts +471 -0
- package/evals/conditions/v4-proto/lib/src/errors.ts +214 -0
- package/evals/conditions/v4-proto/lib/src/index.ts +36 -0
- package/evals/conditions/v4-proto/lib/src/principal.ts +175 -0
- package/evals/conditions/v4-proto/lib/src/service.ts +69 -0
- package/evals/conditions/v4-proto/lib/src/types.ts +174 -0
- package/evals/conditions/v4-proto/lib/test/runtime.test.ts +170 -0
- package/evals/conditions/v4-proto/lib/test/tsconfig.json +10 -0
- package/evals/conditions/v4-proto/lib/test/types.test-d.ts +145 -0
- package/evals/conditions/v4-proto/lib/test/vitest.config.mjs +8 -0
- package/evals/conditions/v4-proto/lib/tsconfig.json +17 -0
- package/evals/conditions/v4-proto/package.json +26 -0
- package/evals/conditions/v4-proto/starter/src/generated/icrc1.service.ts +19 -0
- package/evals/conditions/v4-proto/starter/src/generated/icrc1.ts +57 -0
- package/evals/drive.mjs +1221 -0
- package/evals/gate.mjs +161 -0
- package/evals/harness/aggregate.mjs +534 -0
- package/evals/harness/aggregate.test.mjs +344 -0
- package/evals/harness/assemble.mjs +216 -0
- package/evals/harness/assemble.test.mjs +143 -0
- package/evals/harness/auth.mjs +91 -0
- package/evals/harness/check-docs.mjs +157 -0
- package/evals/harness/declarations/icrc1.did.d.ts +95 -0
- package/evals/harness/declarations/icrc1.did.js +140 -0
- package/evals/harness/drive-auth.test.mjs +584 -0
- package/evals/harness/drive.test.mjs +509 -0
- package/evals/harness/fake-auth.ts +67 -0
- package/evals/harness/fake-ledger.ts +178 -0
- package/evals/harness/gate-plan.mjs +104 -0
- package/evals/harness/gate-plan.test.mjs +243 -0
- package/evals/harness/icrc1.did +88 -0
- package/evals/harness/judge.mjs +63 -0
- package/evals/harness/judge.test.mjs +81 -0
- package/evals/harness/leak-scan.mjs +1373 -0
- package/evals/harness/leak-scan.test.mjs +1300 -0
- package/evals/harness/probes/amounts.ts +14 -0
- package/evals/harness/probes/node-tool.probe.ts +48 -0
- package/evals/harness/probes/probe.mjs +149 -0
- package/evals/harness/probes/react-wallet.probe.ts +96 -0
- package/evals/harness/public/support/auth.ts +38 -0
- package/evals/harness/public/support/fake-replica.d.ts +28 -0
- package/evals/harness/public/support/fake-replica.js +434 -0
- package/evals/harness/public/support/ledger.idl.d.ts +95 -0
- package/evals/harness/public/support/ledger.idl.js +140 -0
- package/evals/harness/public/support/world.ts +179 -0
- package/evals/harness/runs.mjs +139 -0
- package/evals/harness/sandbox.mjs +88 -0
- package/evals/harness/sandbox.test.mjs +134 -0
- package/evals/harness/ship.mjs +264 -0
- package/evals/harness/ship.test.mjs +552 -0
- package/evals/harness/world.ts +291 -0
- package/evals/package.json +26 -0
- package/evals/pnpm-lock.yaml +1537 -0
- package/evals/pnpm-workspace.yaml +12 -0
- package/evals/results/2026-09-30T14-22-05-924Z/pilot.json +384 -0
- package/evals/results/2026-09-30T14-22-05-924Z/pilot.rescanned.json +404 -0
- package/evals/results/2026-09-30T14-22-05-924Z/pilot.rescanned.rescored.json +404 -0
- package/evals/results/2026-09-30T14-22-05-924Z/plan.json +240 -0
- package/evals/results/2026-09-30T14-22-05-924Z/summary.json +1800 -0
- package/evals/results/2026-09-30T14-22-05-924Z/summary.rescanned.json +1843 -0
- package/evals/results/2026-09-30T14-22-05-924Z/summary.rescanned.rescored.json +2100 -0
- package/evals/results/2026-09-30T15-48-23-343Z/pilot.json +404 -0
- package/evals/results/2026-09-30T15-48-23-343Z/pilot.rescored.json +404 -0
- package/evals/results/2026-09-30T15-48-23-343Z/plan.json +242 -0
- package/evals/results/2026-09-30T15-48-23-343Z/summary.json +1843 -0
- package/evals/results/2026-09-30T15-48-23-343Z/summary.rescored.json +2195 -0
- package/evals/results/2026-10-03-beta1-gate/pilot.json +162 -0
- package/evals/results/2026-10-03-beta1-gate/plan.json +141 -0
- package/evals/results/2026-10-03-beta1-gate/summary.json +983 -0
- package/evals/results/2026-10-05-ga-gate/contaminated-run.json +55 -0
- package/evals/results/2026-10-05-ga-gate/pilot.json +162 -0
- package/evals/results/2026-10-05-ga-gate/plan.json +457 -0
- package/evals/results/2026-10-05-ga-gate/summary.json +1037 -0
- package/evals/results/2026-10-05-ga-gate/summary.rescanned.json +1037 -0
- package/evals/results/README.md +31 -0
- package/evals/runs-pilot.log +150 -0
- package/evals/runs-pilot2.log +150 -0
- package/evals/score.mjs +256 -0
- package/evals/setup.mjs +547 -0
- package/evals/tasks/node-tool/faulty/thin-accepts-exponent/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/thin-accepts-exponent/src/index.ts +121 -0
- package/evals/tasks/node-tool/faulty/thin-anonymous-transfer/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/thin-anonymous-transfer/src/index.ts +116 -0
- package/evals/tasks/node-tool/faulty/thin-every-reject-may-have-executed/meta.json +9 -0
- package/evals/tasks/node-tool/faulty/thin-every-reject-may-have-executed/src/index.ts +118 -0
- package/evals/tasks/node-tool/faulty/thin-fetches-root-key-off-local/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/thin-fetches-root-key-off-local/src/index.ts +118 -0
- package/evals/tasks/node-tool/faulty/thin-ignores-root-key/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/thin-ignores-root-key/src/index.ts +117 -0
- package/evals/tasks/node-tool/faulty/thin-misclassifies-reject-codes/meta.json +9 -0
- package/evals/tasks/node-tool/faulty/thin-misclassifies-reject-codes/src/index.ts +119 -0
- package/evals/tasks/node-tool/faulty/thin-no-nat64-cap/meta.json +9 -0
- package/evals/tasks/node-tool/faulty/thin-no-nat64-cap/src/index.ts +118 -0
- package/evals/tasks/node-tool/faulty/thin-number-amount/meta.json +10 -0
- package/evals/tasks/node-tool/faulty/thin-number-amount/src/index.ts +117 -0
- package/evals/tasks/node-tool/faulty/thin-truncates-fraction-digits/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/thin-truncates-fraction-digits/src/index.ts +120 -0
- package/evals/tasks/node-tool/faulty/thin-unvalidated-recipient/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/thin-unvalidated-recipient/src/index.ts +118 -0
- package/evals/tasks/node-tool/faulty/v3-retry-call-errors/meta.json +11 -0
- package/evals/tasks/node-tool/faulty/v3-retry-call-errors/src/index.ts +149 -0
- package/evals/tasks/node-tool/faulty/v4-anonymous-identity-sent/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/v4-anonymous-identity-sent/src/index.ts +71 -0
- package/evals/tasks/node-tool/faulty/v4-never-may-have-executed/meta.json +9 -0
- package/evals/tasks/node-tool/faulty/v4-never-may-have-executed/src/index.ts +84 -0
- package/evals/tasks/node-tool/faulty/v4-proto-never-may-have-executed/meta.json +9 -0
- package/evals/tasks/node-tool/faulty/v4-proto-never-may-have-executed/src/index.ts +72 -0
- package/evals/tasks/node-tool/faulty/v4-proto-refuses-nat64-max/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/v4-proto-refuses-nat64-max/src/index.ts +72 -0
- package/evals/tasks/node-tool/faulty/v4-refuses-nat64-max/meta.json +5 -0
- package/evals/tasks/node-tool/faulty/v4-refuses-nat64-max/src/index.ts +84 -0
- package/evals/tasks/node-tool/hidden/node-tool.test.ts +312 -0
- package/evals/tasks/node-tool/prompt.md +55 -0
- package/evals/tasks/node-tool/prompt.minimal.md +30 -0
- package/evals/tasks/node-tool/solutions/thin/reference/src/index.ts +118 -0
- package/evals/tasks/node-tool/solutions/thin/reference-module-scope/src/index.ts +145 -0
- package/evals/tasks/node-tool/solutions/thin-guide/reference/src/index.ts +118 -0
- package/evals/tasks/node-tool/solutions/thin-guide/reference-module-scope/src/index.ts +145 -0
- package/evals/tasks/node-tool/solutions/v3/reference/src/index.ts +140 -0
- package/evals/tasks/node-tool/solutions/v3/reference-module-scope/src/index.ts +153 -0
- package/evals/tasks/node-tool/solutions/v4/reference/src/index.ts +84 -0
- package/evals/tasks/node-tool/solutions/v4/reference-module-scope/src/index.ts +105 -0
- package/evals/tasks/node-tool/solutions/v4-proto/reference/src/index.ts +72 -0
- package/evals/tasks/node-tool/solutions/v4-proto/reference-module-scope/src/index.ts +87 -0
- package/evals/tasks/node-tool/starter/src/contract.ts +31 -0
- package/evals/tasks/node-tool/starter/src/index.ts +7 -0
- package/evals/tasks/node-tool/starter/test/smoke.test.ts +22 -0
- package/evals/tasks/node-tool/starter/tsconfig.json +17 -0
- package/evals/tasks/node-tool/task.json +63 -0
- package/evals/tasks/react-wallet/faulty/thin-accepts-exponent/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-accepts-exponent/src/Wallet.tsx +216 -0
- package/evals/tasks/react-wallet/faulty/thin-anonymous-transfer/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-anonymous-transfer/src/Wallet.tsx +212 -0
- package/evals/tasks/react-wallet/faulty/thin-both-auth-buttons/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-both-auth-buttons/src/Wallet.tsx +210 -0
- package/evals/tasks/react-wallet/faulty/thin-constant-balance-key/meta.json +8 -0
- package/evals/tasks/react-wallet/faulty/thin-constant-balance-key/src/Wallet.tsx +213 -0
- package/evals/tasks/react-wallet/faulty/thin-no-nat64-cap/meta.json +9 -0
- package/evals/tasks/react-wallet/faulty/thin-no-nat64-cap/src/Wallet.tsx +213 -0
- package/evals/tasks/react-wallet/faulty/thin-number-balance/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-number-balance/src/Wallet.tsx +213 -0
- package/evals/tasks/react-wallet/faulty/thin-transfer-as-query/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-transfer-as-query/src/Wallet.tsx +254 -0
- package/evals/tasks/react-wallet/faulty/thin-truncates-fraction-digits/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-truncates-fraction-digits/src/Wallet.tsx +215 -0
- package/evals/tasks/react-wallet/faulty/thin-unguarded-balance-effect/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/thin-unguarded-balance-effect/src/Wallet.tsx +214 -0
- package/evals/tasks/react-wallet/faulty/v3-http-4xx-unknown/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v3-http-4xx-unknown/src/Wallet.tsx +224 -0
- package/evals/tasks/react-wallet/faulty/v3-mutation-retry-3/meta.json +12 -0
- package/evals/tasks/react-wallet/faulty/v3-mutation-retry-3/src/Wallet.tsx +225 -0
- package/evals/tasks/react-wallet/faulty/v3-unknown-as-error/meta.json +11 -0
- package/evals/tasks/react-wallet/faulty/v3-unknown-as-error/src/Wallet.tsx +182 -0
- package/evals/tasks/react-wallet/faulty/v4-every-reject-unknown/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v4-every-reject-unknown/src/Wallet.tsx +160 -0
- package/evals/tasks/react-wallet/faulty/v4-keep-previous-data/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v4-keep-previous-data/src/Wallet.tsx +166 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-every-reject-unknown/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-every-reject-unknown/src/Wallet.tsx +161 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-keep-previous-data/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-keep-previous-data/src/Wallet.tsx +163 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-retry-spread/meta.json +12 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-retry-spread/src/Wallet.tsx +162 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-status-not-idle/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v4-proto-status-not-idle/src/Wallet.tsx +163 -0
- package/evals/tasks/react-wallet/faulty/v4-retry-spread/meta.json +12 -0
- package/evals/tasks/react-wallet/faulty/v4-retry-spread/src/Wallet.tsx +163 -0
- package/evals/tasks/react-wallet/faulty/v4-status-not-idle/meta.json +5 -0
- package/evals/tasks/react-wallet/faulty/v4-status-not-idle/src/Wallet.tsx +162 -0
- package/evals/tasks/react-wallet/hidden/react-wallet.test.ts +536 -0
- package/evals/tasks/react-wallet/prompt.md +88 -0
- package/evals/tasks/react-wallet/prompt.minimal.md +51 -0
- package/evals/tasks/react-wallet/solutions/thin/reference/src/Wallet.tsx +213 -0
- package/evals/tasks/react-wallet/solutions/thin/reference-module-scope/src/Wallet.tsx +227 -0
- package/evals/tasks/react-wallet/solutions/thin-guide/reference/src/Wallet.tsx +213 -0
- package/evals/tasks/react-wallet/solutions/thin-guide/reference-module-scope/src/Wallet.tsx +227 -0
- package/evals/tasks/react-wallet/solutions/v3/reference/src/Wallet.tsx +224 -0
- package/evals/tasks/react-wallet/solutions/v3/reference-module-scope/src/Wallet.tsx +230 -0
- package/evals/tasks/react-wallet/solutions/v4/reference/src/Wallet.tsx +160 -0
- package/evals/tasks/react-wallet/solutions/v4/reference-module-scope/src/Wallet.tsx +178 -0
- package/evals/tasks/react-wallet/solutions/v4-proto/reference/src/Wallet.tsx +161 -0
- package/evals/tasks/react-wallet/solutions/v4-proto/reference-module-scope/src/Wallet.tsx +161 -0
- package/evals/tasks/react-wallet/starter/src/Wallet.tsx +12 -0
- package/evals/tasks/react-wallet/starter/src/auth.ts +16 -0
- package/evals/tasks/react-wallet/starter/src/config.ts +14 -0
- package/evals/tasks/react-wallet/starter/src/ii-auth.ts +43 -0
- package/evals/tasks/react-wallet/starter/src/main.tsx +15 -0
- package/evals/tasks/react-wallet/starter/test/smoke.test.ts +34 -0
- package/evals/tasks/react-wallet/starter/tsconfig.json +18 -0
- package/evals/tasks/react-wallet/task.json +84 -0
- package/examples/canister-studio/.stackblitzrc +4 -0
- package/examples/canister-studio/README.md +183 -0
- package/examples/canister-studio/did/ckbtc_minter.did +806 -0
- package/examples/canister-studio/did/icp_ledger.did +586 -0
- package/examples/canister-studio/did/icrc1.did +88 -0
- package/examples/canister-studio/package.json +45 -0
- package/examples/canister-studio/scripts/smoke.ts +188 -0
- package/examples/canister-studio/src/calls/CacheKeyPanel.tsx +104 -0
- package/examples/canister-studio/src/calls/ConfirmWrite.tsx +265 -0
- package/examples/canister-studio/src/calls/ErrorPanel.test.tsx +113 -0
- package/examples/canister-studio/src/calls/ErrorPanel.tsx +214 -0
- package/examples/canister-studio/src/calls/MethodRunner.test.tsx +354 -0
- package/examples/canister-studio/src/calls/MethodRunner.tsx +57 -0
- package/examples/canister-studio/src/calls/ReadRunner.tsx +244 -0
- package/examples/canister-studio/src/calls/ResendPanel.tsx +165 -0
- package/examples/canister-studio/src/calls/ShareLink.tsx +59 -0
- package/examples/canister-studio/src/calls/WriteRunner.test.tsx +678 -0
- package/examples/canister-studio/src/calls/WriteRunner.tsx +670 -0
- package/examples/canister-studio/src/calls/dedupe.ts +189 -0
- package/examples/canister-studio/src/calls/error-info.ts +168 -0
- package/examples/canister-studio/src/calls/history.test.ts +284 -0
- package/examples/canister-studio/src/calls/history.ts +287 -0
- package/examples/canister-studio/src/calls/kinds.ts +68 -0
- package/examples/canister-studio/src/calls/prepare.ts +32 -0
- package/examples/canister-studio/src/calls/query-options.ts +30 -0
- package/examples/canister-studio/src/calls/read.ts +47 -0
- package/examples/canister-studio/src/calls/readback.ts +100 -0
- package/examples/canister-studio/src/calls/record.ts +123 -0
- package/examples/canister-studio/src/calls/safe-calls.test.ts +299 -0
- package/examples/canister-studio/src/calls/share.ts +46 -0
- package/examples/canister-studio/src/calls/testing/doubles.tsx +108 -0
- package/examples/canister-studio/src/calls/testing/fixtures.ts +185 -0
- package/examples/canister-studio/src/calls/useCanisterHandle.ts +35 -0
- package/examples/canister-studio/src/canisters/ckbtc_minter.envelope.json +4228 -0
- package/examples/canister-studio/src/canisters/ckbtc_minter.ts +868 -0
- package/examples/canister-studio/src/canisters/icp_ledger.envelope.json +3454 -0
- package/examples/canister-studio/src/canisters/icp_ledger.ts +584 -0
- package/examples/canister-studio/src/canisters/icrc1.envelope.json +840 -0
- package/examples/canister-studio/src/canisters/icrc1.ts +78 -0
- package/examples/canister-studio/src/components/ActionButton.tsx +32 -0
- package/examples/canister-studio/src/components/AppHeader.tsx +83 -0
- package/examples/canister-studio/src/components/AppShell.tsx +29 -0
- package/examples/canister-studio/src/components/AuthButton.tsx +79 -0
- package/examples/canister-studio/src/components/Badge.tsx +79 -0
- package/examples/canister-studio/src/components/CanisterHeader.tsx +200 -0
- package/examples/canister-studio/src/components/CanisterJump.tsx +130 -0
- package/examples/canister-studio/src/components/Card.tsx +64 -0
- package/examples/canister-studio/src/components/Code.tsx +101 -0
- package/examples/canister-studio/src/components/CopyButton.tsx +126 -0
- package/examples/canister-studio/src/components/Disclosure.tsx +34 -0
- package/examples/canister-studio/src/components/EmptyState.tsx +34 -0
- package/examples/canister-studio/src/components/MethodList.test.tsx +137 -0
- package/examples/canister-studio/src/components/MethodList.tsx +244 -0
- package/examples/canister-studio/src/components/Notice.tsx +36 -0
- package/examples/canister-studio/src/components/ProvenanceBadge.tsx +44 -0
- package/examples/canister-studio/src/components/RouteError.tsx +42 -0
- package/examples/canister-studio/src/components/SectionBoundary.tsx +76 -0
- package/examples/canister-studio/src/components/Spinner.tsx +33 -0
- package/examples/canister-studio/src/components/Tabs.tsx +96 -0
- package/examples/canister-studio/src/components/canister/CanisterLoadFailure.test.tsx +56 -0
- package/examples/canister-studio/src/components/canister/CanisterLoadFailure.tsx +165 -0
- package/examples/canister-studio/src/components/canister/CanisterNotFound.tsx +59 -0
- package/examples/canister-studio/src/components/canister/CanisterPending.tsx +33 -0
- package/examples/canister-studio/src/components/canister/MethodOverview.tsx +93 -0
- package/examples/canister-studio/src/components/canister/MethodWorkspace.test.tsx +201 -0
- package/examples/canister-studio/src/components/canister/MethodWorkspace.tsx +187 -0
- package/examples/canister-studio/src/components/canister/shared-call.test.ts +186 -0
- package/examples/canister-studio/src/components/canister/shared-call.ts +133 -0
- package/examples/canister-studio/src/components/canister/shared-link-loader.test.ts +116 -0
- package/examples/canister-studio/src/components/canister/use-canister-page.ts +44 -0
- package/examples/canister-studio/src/components/canister/workspace-key.test.ts +27 -0
- package/examples/canister-studio/src/components/canister/workspace-key.ts +36 -0
- package/examples/canister-studio/src/components/canister-id-input.ts +69 -0
- package/examples/canister-studio/src/components/canister-names.ts +11 -0
- package/examples/canister-studio/src/components/download.ts +34 -0
- package/examples/canister-studio/src/components/fallbacks.tsx +33 -0
- package/examples/canister-studio/src/components/helpers.test.ts +107 -0
- package/examples/canister-studio/src/components/history/HistoryList.tsx +284 -0
- package/examples/canister-studio/src/components/home/FeaturedLedger.tsx +149 -0
- package/examples/canister-studio/src/components/home/OpenCanister.tsx +99 -0
- package/examples/canister-studio/src/components/home/featured.test.tsx +92 -0
- package/examples/canister-studio/src/components/home/featured.ts +64 -0
- package/examples/canister-studio/src/components/interface/CandidTab.tsx +38 -0
- package/examples/canister-studio/src/components/interface/CompatReport.tsx +92 -0
- package/examples/canister-studio/src/components/interface/CompatibilityTab.tsx +190 -0
- package/examples/canister-studio/src/components/interface/ProjectTab.tsx +196 -0
- package/examples/canister-studio/src/components/interface/TypeScriptTab.tsx +114 -0
- package/examples/canister-studio/src/components/interface/tools.test.tsx +169 -0
- package/examples/canister-studio/src/components/modes.ts +31 -0
- package/examples/canister-studio/src/components/playground/MethodPicker.tsx +67 -0
- package/examples/canister-studio/src/components/playground/PlaygroundForms.tsx +112 -0
- package/examples/canister-studio/src/components/playground/PlaygroundTools.tsx +219 -0
- package/examples/canister-studio/src/components/playground/sample.ts +43 -0
- package/examples/canister-studio/src/components/playground/target.test.tsx +86 -0
- package/examples/canister-studio/src/components/primitives.test.tsx +121 -0
- package/examples/canister-studio/src/components/provenance.ts +38 -0
- package/examples/canister-studio/src/components/route-render.test.tsx +71 -0
- package/examples/canister-studio/src/components/use-task.ts +56 -0
- package/examples/canister-studio/src/components/wallet/BalancePanel.tsx +110 -0
- package/examples/canister-studio/src/components/wallet/LedgerSummary.tsx +63 -0
- package/examples/canister-studio/src/components/wallet/MinterPanel.tsx +255 -0
- package/examples/canister-studio/src/components/wallet/SendPanel.test.tsx +297 -0
- package/examples/canister-studio/src/components/wallet/SendPanel.tsx +446 -0
- package/examples/canister-studio/src/components/wallet/ledgers.test.ts +36 -0
- package/examples/canister-studio/src/components/wallet/ledgers.ts +111 -0
- package/examples/canister-studio/src/forms/JsonPanel.tsx +157 -0
- package/examples/canister-studio/src/forms/MethodForm.test.tsx +369 -0
- package/examples/canister-studio/src/forms/MethodForm.tsx +368 -0
- package/examples/canister-studio/src/forms/TypedForm.tsx +55 -0
- package/examples/canister-studio/src/forms/context.ts +62 -0
- package/examples/canister-studio/src/forms/convert.ts +131 -0
- package/examples/canister-studio/src/forms/edge.test.ts +252 -0
- package/examples/canister-studio/src/forms/engine.test.ts +358 -0
- package/examples/canister-studio/src/forms/engine.ts +1492 -0
- package/examples/canister-studio/src/forms/fields/BytesField.tsx +210 -0
- package/examples/canister-studio/src/forms/fields/Field.tsx +106 -0
- package/examples/canister-studio/src/forms/fields/FieldShell.tsx +101 -0
- package/examples/canister-studio/src/forms/fields/Group.tsx +74 -0
- package/examples/canister-studio/src/forms/fields/ListField.tsx +256 -0
- package/examples/canister-studio/src/forms/fields/Segmented.tsx +78 -0
- package/examples/canister-studio/src/forms/fields/TimestampField.tsx +108 -0
- package/examples/canister-studio/src/forms/fields/UnitsField.tsx +119 -0
- package/examples/canister-studio/src/forms/fields/composites.tsx +389 -0
- package/examples/canister-studio/src/forms/fields/leaves.tsx +350 -0
- package/examples/canister-studio/src/forms/fields.test.tsx +396 -0
- package/examples/canister-studio/src/forms/helpers.test.ts +225 -0
- package/examples/canister-studio/src/forms/hints.ts +128 -0
- package/examples/canister-studio/src/forms/json.ts +119 -0
- package/examples/canister-studio/src/forms/parsing.test.ts +217 -0
- package/examples/canister-studio/src/forms/useMethodForm.ts +251 -0
- package/examples/canister-studio/src/interface/browser.test.ts +23 -0
- package/examples/canister-studio/src/interface/browser.ts +153 -0
- package/examples/canister-studio/src/interface/cache.ts +68 -0
- package/examples/canister-studio/src/interface/cli-cache.test.ts +155 -0
- package/examples/canister-studio/src/interface/cli-cache.ts +125 -0
- package/examples/canister-studio/src/interface/compile.server.test.ts +198 -0
- package/examples/canister-studio/src/interface/compile.server.ts +262 -0
- package/examples/canister-studio/src/interface/compile.test.ts +108 -0
- package/examples/canister-studio/src/interface/compile.ts +305 -0
- package/examples/canister-studio/src/interface/docs.test.ts +75 -0
- package/examples/canister-studio/src/interface/docs.ts +100 -0
- package/examples/canister-studio/src/interface/functions.test.ts +42 -0
- package/examples/canister-studio/src/interface/functions.ts +200 -0
- package/examples/canister-studio/src/interface/live-candid.server.ts +91 -0
- package/examples/canister-studio/src/interface/live-loader.test.ts +515 -0
- package/examples/canister-studio/src/interface/live-loader.ts +364 -0
- package/examples/canister-studio/src/interface/load.test.ts +328 -0
- package/examples/canister-studio/src/interface/load.ts +249 -0
- package/examples/canister-studio/src/interface/read-candid.test.ts +185 -0
- package/examples/canister-studio/src/interface/read-candid.ts +233 -0
- package/examples/canister-studio/src/interface/server-result.ts +42 -0
- package/examples/canister-studio/src/interface/typed.ts +68 -0
- package/examples/canister-studio/src/interface/types.ts +121 -0
- package/examples/canister-studio/src/lib/format.test.ts +107 -0
- package/examples/canister-studio/src/lib/format.ts +139 -0
- package/examples/canister-studio/src/lib/hex.test.ts +43 -0
- package/examples/canister-studio/src/lib/hex.ts +33 -0
- package/examples/canister-studio/src/lib/ids.test.ts +70 -0
- package/examples/canister-studio/src/lib/ids.ts +93 -0
- package/examples/canister-studio/src/lib/reactor.test.ts +55 -0
- package/examples/canister-studio/src/lib/reactor.ts +55 -0
- package/examples/canister-studio/src/lib/registry.test.ts +74 -0
- package/examples/canister-studio/src/lib/registry.ts +238 -0
- package/examples/canister-studio/src/lib/schema.ts +148 -0
- package/examples/canister-studio/src/routeTree.gen.ts +227 -0
- package/examples/canister-studio/src/router.test.ts +290 -0
- package/examples/canister-studio/src/router.tsx +127 -0
- package/examples/canister-studio/src/routes/__root.tsx +58 -0
- package/examples/canister-studio/src/routes/canister.$canisterId.index.tsx +172 -0
- package/examples/canister-studio/src/routes/canister.$canisterId.interface.tsx +98 -0
- package/examples/canister-studio/src/routes/canister.$canisterId.tsx +91 -0
- package/examples/canister-studio/src/routes/history.tsx +55 -0
- package/examples/canister-studio/src/routes/index.tsx +169 -0
- package/examples/canister-studio/src/routes/playground.tsx +286 -0
- package/examples/canister-studio/src/routes/safety.tsx +57 -0
- package/examples/canister-studio/src/routes/wallet.tsx +213 -0
- package/examples/canister-studio/src/safety/LabTransferForm.tsx +84 -0
- package/examples/canister-studio/src/safety/RequestLog.tsx +79 -0
- package/examples/canister-studio/src/safety/SafetyLab.test.tsx +89 -0
- package/examples/canister-studio/src/safety/SafetyLab.tsx +140 -0
- package/examples/canister-studio/src/safety/ScenarioCard.tsx +262 -0
- package/examples/canister-studio/src/safety/lab-run.ts +283 -0
- package/examples/canister-studio/src/safety/mock-ledger.test.ts +99 -0
- package/examples/canister-studio/src/safety/mock-ledger.ts +263 -0
- package/examples/canister-studio/src/safety/scenarios.test.ts +157 -0
- package/examples/canister-studio/src/safety/scenarios.ts +924 -0
- package/examples/canister-studio/src/styles.css +3453 -0
- package/examples/canister-studio/src/styles.test.ts +46 -0
- package/examples/canister-studio/src/values/CallPreview.test.tsx +86 -0
- package/examples/canister-studio/src/values/CallPreview.tsx +148 -0
- package/examples/canister-studio/src/values/ErrValueView.tsx +66 -0
- package/examples/canister-studio/src/values/Inspector.tsx +133 -0
- package/examples/canister-studio/src/values/ReplyView.test.tsx +341 -0
- package/examples/canister-studio/src/values/ReplyView.tsx +164 -0
- package/examples/canister-studio/src/values/candid-text.test.ts +516 -0
- package/examples/canister-studio/src/values/candid-text.ts +479 -0
- package/examples/canister-studio/src/values/hints.ts +58 -0
- package/examples/canister-studio/src/values/json.test.ts +66 -0
- package/examples/canister-studio/src/values/json.ts +31 -0
- package/examples/canister-studio/src/values/leaves.tsx +309 -0
- package/examples/canister-studio/src/values/schema.test.ts +123 -0
- package/examples/canister-studio/src/values/schema.ts +78 -0
- package/examples/canister-studio/src/values/test-router.tsx +21 -0
- package/examples/canister-studio/src/values/tree.tsx +670 -0
- package/examples/canister-studio/src/values/use-sha256.ts +29 -0
- package/examples/canister-studio/tsconfig.json +20 -0
- package/examples/canister-studio/vite.config.ts +50 -0
- package/examples/canister-studio/vitest.config.ts +20 -0
- package/examples/icrc-ledger/.stackblitzrc +4 -0
- package/examples/icrc-ledger/README.md +100 -0
- package/examples/icrc-ledger/ckbtc_minter.did +12 -0
- package/examples/icrc-ledger/icp_ledger.did +147 -0
- package/examples/icrc-ledger/icrc1.did +88 -0
- package/examples/icrc-ledger/index.html +13 -0
- package/examples/icrc-ledger/package.json +40 -0
- package/examples/icrc-ledger/scripts/smoke.ts +151 -0
- package/examples/icrc-ledger/src/App.tsx +71 -0
- package/examples/icrc-ledger/src/ErrorPanel.tsx +105 -0
- package/examples/icrc-ledger/src/MainnetTab.tsx +450 -0
- package/examples/icrc-ledger/src/SandboxTab.test.tsx +379 -0
- package/examples/icrc-ledger/src/SandboxTab.tsx +761 -0
- package/examples/icrc-ledger/src/blocks.test.ts +247 -0
- package/examples/icrc-ledger/src/blocks.ts +140 -0
- package/examples/icrc-ledger/src/canisters/ckbtc_minter.envelope.json +96 -0
- package/examples/icrc-ledger/src/canisters/ckbtc_minter.ts +16 -0
- package/examples/icrc-ledger/src/canisters/icp_ledger.envelope.json +690 -0
- package/examples/icrc-ledger/src/canisters/icp_ledger.ts +223 -0
- package/examples/icrc-ledger/src/canisters/icrc1.envelope.json +840 -0
- package/examples/icrc-ledger/src/canisters/icrc1.ts +78 -0
- package/examples/icrc-ledger/src/format.test.ts +41 -0
- package/examples/icrc-ledger/src/format.ts +68 -0
- package/examples/icrc-ledger/src/ledger.ts +15 -0
- package/examples/icrc-ledger/src/main.tsx +10 -0
- package/examples/icrc-ledger/src/minter.ts +16 -0
- package/examples/icrc-ledger/src/sandbox.test.ts +464 -0
- package/examples/icrc-ledger/src/sandbox.ts +281 -0
- package/examples/icrc-ledger/src/styles.css +391 -0
- package/examples/icrc-ledger/src/transfer-form.test.ts +62 -0
- package/examples/icrc-ledger/src/transfer-form.ts +97 -0
- package/examples/icrc-ledger/tsconfig.json +19 -0
- package/examples/icrc-ledger/vite.config.ts +44 -0
- package/examples/icrc-ledger/vitest.config.ts +12 -0
- package/examples/next-ssr/.stackblitzrc +4 -0
- package/examples/next-ssr/README.md +112 -0
- package/examples/next-ssr/icrc1.did +88 -0
- package/examples/next-ssr/next.config.ts +10 -0
- package/examples/next-ssr/package.json +41 -0
- package/examples/next-ssr/scripts/smoke.ts +169 -0
- package/examples/next-ssr/src/app/account/CertifiedBalances.tsx +58 -0
- package/examples/next-ssr/src/app/account/account.test.tsx +165 -0
- package/examples/next-ssr/src/app/account/page.tsx +82 -0
- package/examples/next-ssr/src/app/api/balance/[ledger]/[principal]/route.ts +10 -0
- package/examples/next-ssr/src/app/globals.css +278 -0
- package/examples/next-ssr/src/app/layout.tsx +34 -0
- package/examples/next-ssr/src/app/page.tsx +46 -0
- package/examples/next-ssr/src/app/providers.browser.test.tsx +127 -0
- package/examples/next-ssr/src/app/providers.test.tsx +73 -0
- package/examples/next-ssr/src/app/providers.tsx +60 -0
- package/examples/next-ssr/src/canisters/icrc1.envelope.json +840 -0
- package/examples/next-ssr/src/canisters/icrc1.ts +78 -0
- package/examples/next-ssr/src/components/BalanceTable.tsx +43 -0
- package/examples/next-ssr/src/components/LedgerCard.test.tsx +96 -0
- package/examples/next-ssr/src/components/LedgerCard.tsx +230 -0
- package/examples/next-ssr/src/components/LedgerError.tsx +32 -0
- package/examples/next-ssr/src/components/LedgerSections.tsx +22 -0
- package/examples/next-ssr/src/components/MyBalances.test.tsx +253 -0
- package/examples/next-ssr/src/components/MyBalances.tsx +129 -0
- package/examples/next-ssr/src/components/SessionBadge.tsx +18 -0
- package/examples/next-ssr/src/components/hydration.test.tsx +259 -0
- package/examples/next-ssr/src/components/server-data.ts +10 -0
- package/examples/next-ssr/src/format.ts +46 -0
- package/examples/next-ssr/src/ledgers.ts +38 -0
- package/examples/next-ssr/src/server/balance-route.test.ts +151 -0
- package/examples/next-ssr/src/server/balance-route.ts +157 -0
- package/examples/next-ssr/src/server/error-summary.test.ts +34 -0
- package/examples/next-ssr/src/server/error-summary.ts +37 -0
- package/examples/next-ssr/src/server/parse-owner.test.ts +39 -0
- package/examples/next-ssr/src/server/parse-owner.ts +34 -0
- package/examples/next-ssr/src/server/prefetch-ledgers.test.ts +137 -0
- package/examples/next-ssr/src/server/prefetch-ledgers.ts +70 -0
- package/examples/next-ssr/src/server/read-balances.test.ts +103 -0
- package/examples/next-ssr/src/server/read-balances.ts +78 -0
- package/examples/next-ssr/src/server/request-client.rsc.test.tsx +110 -0
- package/examples/next-ssr/src/server/request-client.ts +24 -0
- package/examples/next-ssr/src/testing/mock-ledgers.ts +115 -0
- package/examples/next-ssr/src/testing/react-server-dom-turbopack.d.ts +15 -0
- package/examples/next-ssr/src/testing/setup.ts +10 -0
- package/examples/next-ssr/tsconfig.json +31 -0
- package/examples/next-ssr/vitest.config.ts +59 -0
- package/examples/node-agent-tool/.stackblitzrc +4 -0
- package/examples/node-agent-tool/README.md +165 -0
- package/examples/node-agent-tool/icp.yaml +11 -0
- package/examples/node-agent-tool/icrc1.did +88 -0
- package/examples/node-agent-tool/package.json +32 -0
- package/examples/node-agent-tool/src/canisters/icrc1.envelope.json +840 -0
- package/examples/node-agent-tool/src/canisters/icrc1.ts +78 -0
- package/examples/node-agent-tool/src/cli.test.ts +64 -0
- package/examples/node-agent-tool/src/cli.ts +23 -0
- package/examples/node-agent-tool/src/command-line.ts +159 -0
- package/examples/node-agent-tool/src/commands/balance.ts +73 -0
- package/examples/node-agent-tool/src/commands/demo.test.ts +51 -0
- package/examples/node-agent-tool/src/commands/demo.ts +359 -0
- package/examples/node-agent-tool/src/commands/info.ts +69 -0
- package/examples/node-agent-tool/src/commands/reads.test.ts +133 -0
- package/examples/node-agent-tool/src/commands/resend.test.ts +363 -0
- package/examples/node-agent-tool/src/commands/transfer.test.ts +313 -0
- package/examples/node-agent-tool/src/commands/transfer.ts +415 -0
- package/examples/node-agent-tool/src/commands/watch.test.ts +159 -0
- package/examples/node-agent-tool/src/commands/watch.ts +135 -0
- package/examples/node-agent-tool/src/commands/whoami.ts +36 -0
- package/examples/node-agent-tool/src/context.ts +20 -0
- package/examples/node-agent-tool/src/dispatch.ts +70 -0
- package/examples/node-agent-tool/src/failure.test.ts +59 -0
- package/examples/node-agent-tool/src/failure.ts +176 -0
- package/examples/node-agent-tool/src/identity.test.ts +242 -0
- package/examples/node-agent-tool/src/identity.ts +228 -0
- package/examples/node-agent-tool/src/input.ts +110 -0
- package/examples/node-agent-tool/src/ledgers.test.ts +74 -0
- package/examples/node-agent-tool/src/ledgers.ts +62 -0
- package/examples/node-agent-tool/src/mock-ledger.ts +211 -0
- package/examples/node-agent-tool/src/network.test.ts +128 -0
- package/examples/node-agent-tool/src/network.ts +101 -0
- package/examples/node-agent-tool/src/output.test.ts +208 -0
- package/examples/node-agent-tool/src/output.ts +163 -0
- package/examples/node-agent-tool/src/run.ts +73 -0
- package/examples/node-agent-tool/src/test-kit.ts +167 -0
- package/examples/node-agent-tool/tsconfig.json +18 -0
- package/examples/node-agent-tool/vitest.config.ts +8 -0
- package/examples/vite-wallet/.stackblitzrc +4 -0
- package/examples/vite-wallet/Cargo.lock +646 -0
- package/examples/vite-wallet/Cargo.toml +5 -0
- package/examples/vite-wallet/README.md +107 -0
- package/examples/vite-wallet/backend/Cargo.toml +12 -0
- package/examples/vite-wallet/backend/backend.did +37 -0
- package/examples/vite-wallet/backend/src/lib.rs +133 -0
- package/examples/vite-wallet/icp.yaml +44 -0
- package/examples/vite-wallet/index.html +13 -0
- package/examples/vite-wallet/ledger.did +54 -0
- package/examples/vite-wallet/package.json +46 -0
- package/examples/vite-wallet/public/.ic-assets.json5 +26 -0
- package/examples/vite-wallet/scripts/faucet-args.test.ts +30 -0
- package/examples/vite-wallet/scripts/faucet-args.ts +41 -0
- package/examples/vite-wallet/scripts/faucet.ts +41 -0
- package/examples/vite-wallet/src/AddressBook.test.tsx +191 -0
- package/examples/vite-wallet/src/AddressBook.tsx +147 -0
- package/examples/vite-wallet/src/App.tsx +53 -0
- package/examples/vite-wallet/src/Balance.test.tsx +57 -0
- package/examples/vite-wallet/src/Balance.tsx +58 -0
- package/examples/vite-wallet/src/EnvironmentPanel.test.tsx +83 -0
- package/examples/vite-wallet/src/EnvironmentPanel.tsx +103 -0
- package/examples/vite-wallet/src/ErrorNote.tsx +70 -0
- package/examples/vite-wallet/src/Profile.test.tsx +145 -0
- package/examples/vite-wallet/src/Profile.tsx +92 -0
- package/examples/vite-wallet/src/SendIcp.test.tsx +231 -0
- package/examples/vite-wallet/src/SendIcp.tsx +244 -0
- package/examples/vite-wallet/src/SendToContact.test.tsx +113 -0
- package/examples/vite-wallet/src/SendToContact.tsx +102 -0
- package/examples/vite-wallet/src/SignIn.test.tsx +106 -0
- package/examples/vite-wallet/src/SignIn.tsx +120 -0
- package/examples/vite-wallet/src/Wallet.test.tsx +89 -0
- package/examples/vite-wallet/src/account-switch.test.tsx +108 -0
- package/examples/vite-wallet/src/auth/dev-accounts.test.ts +113 -0
- package/examples/vite-wallet/src/auth/dev-accounts.ts +216 -0
- package/examples/vite-wallet/src/auth/local-page.test.ts +28 -0
- package/examples/vite-wallet/src/auth/local-page.ts +20 -0
- package/examples/vite-wallet/src/auth/wallet-auth.test.ts +159 -0
- package/examples/vite-wallet/src/auth/wallet-auth.ts +131 -0
- package/examples/vite-wallet/src/canisters/backend.envelope.json +275 -0
- package/examples/vite-wallet/src/canisters/backend.ts +58 -0
- package/examples/vite-wallet/src/canisters/ledger.envelope.json +451 -0
- package/examples/vite-wallet/src/canisters/ledger.ts +56 -0
- package/examples/vite-wallet/src/client.ts +45 -0
- package/examples/vite-wallet/src/main.tsx +18 -0
- package/examples/vite-wallet/src/optimistic-contacts.ts +113 -0
- package/examples/vite-wallet/src/refusal.ts +17 -0
- package/examples/vite-wallet/src/styles.css +282 -0
- package/examples/vite-wallet/src/test/test-wallet.tsx +322 -0
- package/examples/vite-wallet/src/token.ts +50 -0
- package/examples/vite-wallet/src/transfer.test.ts +178 -0
- package/examples/vite-wallet/src/transfer.ts +110 -0
- package/examples/vite-wallet/src/use-canisters.ts +49 -0
- package/examples/vite-wallet/tsconfig.json +19 -0
- package/examples/vite-wallet/vite.config.ts +47 -0
- package/examples/vite-wallet/vitest.config.ts +17 -0
- package/package.json +9 -4
- package/packages/core/.size-limit.js +47 -0
- package/packages/core/LICENSE +21 -0
- package/packages/core/README.md +84 -0
- package/packages/core/llms.txt +610 -0
- package/packages/core/package.json +89 -0
- package/packages/core/src/call.ts +961 -0
- package/packages/core/src/canister.ts +259 -0
- package/packages/core/src/client.ts +2061 -0
- package/packages/core/src/errors.ts +1079 -0
- package/packages/core/src/hydration.ts +239 -0
- package/packages/core/src/index.ts +23 -0
- package/packages/core/src/keys.ts +108 -0
- package/packages/core/src/management.ts +138 -0
- package/packages/core/src/network.ts +1020 -0
- package/packages/core/src/options.ts +1000 -0
- package/packages/core/src/runtime.ts +50 -0
- package/packages/core/src/testing/fake-replica.ts +1166 -0
- package/packages/core/src/testing/index.ts +16 -0
- package/packages/core/src/testing/test-auth.ts +340 -0
- package/packages/core/src/testing/test-client.ts +559 -0
- package/packages/core/src/types.ts +541 -0
- package/packages/core/src/units.ts +299 -0
- package/packages/core/src/version.ts +4 -0
- package/packages/core/tests/canister-helpers.ts +187 -0
- package/packages/core/tests/canister-id.test.ts +158 -0
- package/packages/core/tests/canister-unwrap.test.ts +94 -0
- package/packages/core/tests/canister.test-d.ts +406 -0
- package/packages/core/tests/canister.test.ts +1921 -0
- package/packages/core/tests/client-account-change.test.ts +131 -0
- package/packages/core/tests/client-agents.test.ts +402 -0
- package/packages/core/tests/client-auth-network.test.ts +719 -0
- package/packages/core/tests/client-disposed.test.ts +403 -0
- package/packages/core/tests/client-helpers.ts +136 -0
- package/packages/core/tests/client-hydration.test.ts +166 -0
- package/packages/core/tests/client-pinned.test.ts +626 -0
- package/packages/core/tests/client-session.test.ts +348 -0
- package/packages/core/tests/client.test-d.ts +181 -0
- package/packages/core/tests/client.test.ts +1162 -0
- package/packages/core/tests/encode.test.ts +171 -0
- package/packages/core/tests/env-canister-id.test.ts +666 -0
- package/packages/core/tests/env-cookie-copies.test.ts +182 -0
- package/packages/core/tests/error-guard.test.ts +222 -0
- package/packages/core/tests/errors.test-d.ts +280 -0
- package/packages/core/tests/errors.test.ts +1359 -0
- package/packages/core/tests/fixtures/README.md +28 -0
- package/packages/core/tests/fixtures/accounts.did +21 -0
- package/packages/core/tests/fixtures/accounts.envelope.json +367 -0
- package/packages/core/tests/fixtures/accounts.ts +26 -0
- package/packages/core/tests/fixtures/archive.did +31 -0
- package/packages/core/tests/fixtures/archive.envelope.json +259 -0
- package/packages/core/tests/fixtures/archive.ts +55 -0
- package/packages/core/tests/fixtures/icrc1.did +88 -0
- package/packages/core/tests/fixtures/icrc1.envelope.json +840 -0
- package/packages/core/tests/fixtures/icrc1.ts +78 -0
- package/packages/core/tests/fixtures/management.did +724 -0
- package/packages/core/tests/fixtures/management.envelope.json +4455 -0
- package/packages/core/tests/fixtures/management.ts +486 -0
- package/packages/core/tests/fixtures/shapes.did +33 -0
- package/packages/core/tests/fixtures/shapes.envelope.json +440 -0
- package/packages/core/tests/fixtures/shapes.ts +56 -0
- package/packages/core/tests/fixtures/skippable.did +15 -0
- package/packages/core/tests/fixtures/skippable.envelope.json +182 -0
- package/packages/core/tests/fixtures/skippable.ts +33 -0
- package/packages/core/tests/func.test.ts +154 -0
- package/packages/core/tests/identity-attributes.test.ts +214 -0
- package/packages/core/tests/keys.test.ts +289 -0
- package/packages/core/tests/management.test.ts +206 -0
- package/packages/core/tests/network-helpers.ts +121 -0
- package/packages/core/tests/network.test-d.ts +78 -0
- package/packages/core/tests/network.test.ts +1051 -0
- package/packages/core/tests/options.test.ts +1594 -0
- package/packages/core/tests/redirect-sign-in.test.ts +393 -0
- package/packages/core/tests/resend.test-d.ts +81 -0
- package/packages/core/tests/resend.test.ts +723 -0
- package/packages/core/tests/skip.test-d.ts +125 -0
- package/packages/core/tests/testing-entry.test.ts +73 -0
- package/packages/core/tests/testing-fake-replica.test.ts +1242 -0
- package/packages/core/tests/testing-test-auth.test-d.ts +84 -0
- package/packages/core/tests/testing-test-auth.test.ts +483 -0
- package/packages/core/tests/testing-test-client.test-d.ts +184 -0
- package/packages/core/tests/testing-test-client.test.ts +1272 -0
- package/packages/core/tests/time-realm.test.ts +63 -0
- package/packages/core/tests/time.test.ts +238 -0
- package/packages/core/tests/traps/README.md +39 -0
- package/packages/core/tests/traps/anonymous-write.test.ts +145 -0
- package/packages/core/tests/traps/classification-table.test.ts +256 -0
- package/packages/core/tests/traps/err-arm.test.ts +144 -0
- package/packages/core/tests/traps/fetch-spy.ts +39 -0
- package/packages/core/tests/traps/invalidation-after-write.test.ts +178 -0
- package/packages/core/tests/traps/ledger.ts +248 -0
- package/packages/core/tests/traps/root-key-off-local.test.ts +130 -0
- package/packages/core/tests/traps/stale-data-across-users.test.ts +173 -0
- package/packages/core/tests/traps/unresolved-name.test.ts +155 -0
- package/packages/core/tests/traps/update-as-query.test.ts +244 -0
- package/packages/core/tests/traps/update-not-resent.test.ts +126 -0
- package/packages/core/tests/traps/update-resent-when-never-delivered.test.ts +159 -0
- package/packages/core/tests/traps.test-d.ts +476 -0
- package/packages/core/tests/units.test-d.ts +118 -0
- package/packages/core/tests/units.test.ts +634 -0
- package/packages/core/tsconfig.json +19 -0
- package/packages/core/tsconfig.typecheck.json +16 -0
- package/packages/core/vitest.config.ts +13 -0
- package/packages/mcp/LICENSE +21 -0
- package/packages/mcp/README.md +189 -0
- package/packages/mcp/package.json +62 -0
- package/packages/mcp/src/candid/candid-text.test.ts +455 -0
- package/packages/mcp/src/candid/candid-text.ts +501 -0
- package/packages/mcp/src/candid/contract.test.ts +398 -0
- package/packages/mcp/src/candid/formats.ts +155 -0
- package/packages/mcp/src/candid/hex.ts +29 -0
- package/packages/mcp/src/candid/json-schema.test.ts +758 -0
- package/packages/mcp/src/candid/json-schema.ts +454 -0
- package/packages/mcp/src/candid/json.test.ts +1207 -0
- package/packages/mcp/src/candid/json.ts +1053 -0
- package/packages/mcp/src/candid/schema-walk.ts +189 -0
- package/packages/mcp/src/candid/type-text.test.ts +179 -0
- package/packages/mcp/src/candid/type-text.ts +238 -0
- package/packages/mcp/src/cli.ts +134 -0
- package/packages/mcp/src/identity.ts +188 -0
- package/packages/mcp/src/interface/cache.test.ts +48 -0
- package/packages/mcp/src/interface/cache.ts +68 -0
- package/packages/mcp/src/interface/cli-cache.test.ts +150 -0
- package/packages/mcp/src/interface/cli-cache.ts +122 -0
- package/packages/mcp/src/interface/compile-worker.test.ts +246 -0
- package/packages/mcp/src/interface/compile-worker.ts +290 -0
- package/packages/mcp/src/interface/compile.test.ts +155 -0
- package/packages/mcp/src/interface/compile.ts +281 -0
- package/packages/mcp/src/interface/docs.test.ts +105 -0
- package/packages/mcp/src/interface/docs.ts +86 -0
- package/packages/mcp/src/interface/fixtures/icrc1.did +88 -0
- package/packages/mcp/src/interface/hex.ts +8 -0
- package/packages/mcp/src/interface/ids.test.ts +71 -0
- package/packages/mcp/src/interface/ids.ts +87 -0
- package/packages/mcp/src/interface/loader.test.ts +804 -0
- package/packages/mcp/src/interface/loader.ts +519 -0
- package/packages/mcp/src/interface/read-candid.test.ts +300 -0
- package/packages/mcp/src/interface/read-candid.ts +259 -0
- package/packages/mcp/src/interface/types.ts +113 -0
- package/packages/mcp/src/network.ts +122 -0
- package/packages/mcp/src/options.ts +149 -0
- package/packages/mcp/src/server/approval.ts +159 -0
- package/packages/mcp/src/server/naming.ts +43 -0
- package/packages/mcp/src/server/results.ts +102 -0
- package/packages/mcp/src/server/server.ts +797 -0
- package/packages/mcp/src/server/tools.ts +116 -0
- package/packages/mcp/src/usage.ts +40 -0
- package/packages/mcp/tests/approval.test.ts +60 -0
- package/packages/mcp/tests/identity.test.ts +234 -0
- package/packages/mcp/tests/naming.test.ts +62 -0
- package/packages/mcp/tests/options.test.ts +140 -0
- package/packages/mcp/tests/server.test.ts +997 -0
- package/packages/mcp/tsconfig.json +19 -0
- package/packages/mcp/tsconfig.typecheck.json +10 -0
- package/packages/mcp/vitest.config.ts +10 -0
- package/packages/react/LICENSE +21 -0
- package/packages/react/README.md +328 -0
- package/packages/react/llms.txt +95 -0
- package/packages/react/package.json +95 -0
- package/packages/react/src/index.tsx +678 -0
- package/packages/react/tests/abandoned-render.test.tsx +816 -0
- package/packages/react/tests/auth.test.tsx +315 -0
- package/packages/react/tests/caller-keys.test.tsx +2334 -0
- package/packages/react/tests/client-time.test.ts +40 -0
- package/packages/react/tests/entry.test.ts +52 -0
- package/packages/react/tests/helpers.tsx +291 -0
- package/packages/react/tests/hydration.test.tsx +262 -0
- package/packages/react/tests/ownership.test.tsx +260 -0
- package/packages/react/tests/provider.server.test.tsx +169 -0
- package/packages/react/tests/query-client.test.tsx +107 -0
- package/packages/react/tests/strict-mode.test.tsx +288 -0
- package/packages/react/tests/suspense.test-d.tsx +357 -0
- package/packages/react/tests/two-query-cores.test.tsx +135 -0
- package/packages/react/tests/types.test-d.tsx +63 -0
- package/packages/react/tsconfig.json +23 -0
- package/packages/react/tsconfig.test.json +8 -0
- package/packages/react/tsconfig.typecheck.json +16 -0
- package/packages/react/vitest.config.ts +39 -0
- package/packages/vite-plugin/LICENSE +21 -0
- package/packages/vite-plugin/README.md +532 -0
- package/packages/vite-plugin/package.json +76 -0
- package/packages/vite-plugin/src/describe-value.test.ts +43 -0
- package/packages/vite-plugin/src/describe-value.ts +167 -0
- package/packages/vite-plugin/src/dev-environment.test.ts +747 -0
- package/packages/vite-plugin/src/dev-environment.ts +510 -0
- package/packages/vite-plugin/src/env.ts +431 -0
- package/packages/vite-plugin/src/fetch.ts +348 -0
- package/packages/vite-plugin/src/file-identity.ts +106 -0
- package/packages/vite-plugin/src/generate.ts +691 -0
- package/packages/vite-plugin/src/index.test.ts +1243 -0
- package/packages/vite-plugin/src/index.ts +2565 -0
- package/packages/vite-plugin/src/interface.ts +339 -0
- package/packages/vite-plugin/src/local-host.ts +34 -0
- package/packages/vite-plugin/src/options.ts +641 -0
- package/packages/vite-plugin/src/principal-text.test.ts +87 -0
- package/packages/vite-plugin/src/principal-text.ts +98 -0
- package/packages/vite-plugin/tests/close.test.ts +141 -0
- package/packages/vite-plugin/tests/environment-mode.test.ts +136 -0
- package/packages/vite-plugin/tests/fake-ic.ts +214 -0
- package/packages/vite-plugin/tests/fetch-sdk.test.ts +27 -0
- package/packages/vite-plugin/tests/fetch.test.ts +1196 -0
- package/packages/vite-plugin/tests/fixtures/fake-cli/bin.js +90 -0
- package/packages/vite-plugin/tests/fixtures/fake-cli/package.json +8 -0
- package/packages/vite-plugin/tests/fixtures/icrc1.did +88 -0
- package/packages/vite-plugin/tests/generation.test.ts +1036 -0
- package/packages/vite-plugin/tests/icp-command.test.ts +194 -0
- package/packages/vite-plugin/tests/icp-timeout.test.ts +83 -0
- package/packages/vite-plugin/tests/no-process-exit.test.ts +83 -0
- package/packages/vite-plugin/tests/on-generated.test.ts +323 -0
- package/packages/vite-plugin/tests/output-collision.test.ts +329 -0
- package/packages/vite-plugin/tests/package.test.ts +62 -0
- package/packages/vite-plugin/tests/project.test.ts +2993 -0
- package/packages/vite-plugin/tests/support.ts +339 -0
- package/packages/vite-plugin/tests/timeout.test.ts +107 -0
- package/packages/vite-plugin/tsconfig.json +23 -0
- package/packages/vite-plugin/tsconfig.typecheck.json +16 -0
- package/packages/vite-plugin/vitest.config.ts +9 -0
- package/pnpm-workspace.yaml +23 -0
- package/scripts/ai-context-files.js +72 -0
- package/scripts/assemble-docs-site.mjs +485 -0
- package/scripts/assemble-docs-site.test.mjs +568 -0
- package/scripts/build-examples.js +58 -0
- package/scripts/check-ai-context.js +963 -0
- package/scripts/check-ai-context.test.mjs +811 -0
- package/scripts/check-exports.mjs +767 -0
- package/scripts/check-exports.test.mjs +1136 -0
- package/scripts/check-snippets/ambient.d.ts +428 -0
- package/scripts/check-snippets/app/generated/backend.did +7 -0
- package/scripts/check-snippets/app/generated/backend.ts +15 -0
- package/scripts/check-snippets/app/generated/icrc1.did +88 -0
- package/scripts/check-snippets/app/generated/icrc1.ts +78 -0
- package/scripts/check-snippets/app/globals.ts +26 -0
- package/scripts/check-snippets/docs/guides/App.tsx +21 -0
- package/scripts/check-snippets/docs/guides/app/providers.tsx +23 -0
- package/scripts/check-snippets/docs/guides/auth-client.ts +47 -0
- package/scripts/check-snippets/docs/guides/canisters/backend.ts +3 -0
- package/scripts/check-snippets/docs/guides/canisters/icrc1.ts +3 -0
- package/scripts/check-snippets/docs/guides/components/LedgerCard.tsx +26 -0
- package/scripts/check-snippets/docs/guides/components/shell.tsx +11 -0
- package/scripts/check-snippets/docs/guides/components/sign-in-page.tsx +29 -0
- package/scripts/check-snippets/docs/guides/components/slow-section.tsx +5 -0
- package/scripts/check-snippets/docs/guides/generated/accounts.ts +95 -0
- package/scripts/check-snippets/docs/guides/generated/ckbtc_minter.ts +40 -0
- package/scripts/check-snippets/docs/guides/generated/icp_ledger.ts +267 -0
- package/scripts/check-snippets/docs/guides/ledger.ts +10 -0
- package/scripts/check-snippets/docs/guides/server/request-client.ts +8 -0
- package/scripts/check-snippets.mjs +993 -0
- package/scripts/check-snippets.test.mjs +338 -0
- package/scripts/check-stack.mjs +501 -0
- package/scripts/check-stack.test.mjs +800 -0
- package/scripts/clean-node-modules.js +67 -0
- package/scripts/example-projects.js +58 -0
- package/scripts/export-budget.mjs +145 -0
- package/scripts/faults.json +6749 -0
- package/scripts/lib/fault-workspace.mjs +210 -0
- package/scripts/lib/io.mjs +29 -0
- package/scripts/lib/io.test.mjs +38 -0
- package/scripts/lib/markdown-fences.mjs +56 -0
- package/scripts/lib/markdown-fences.test.mjs +84 -0
- package/scripts/lib/package-exports.mjs +54 -0
- package/scripts/lib/package-exports.test.mjs +66 -0
- package/scripts/lib/release-pr-steps.mjs +47 -0
- package/scripts/release-tag.mjs +95 -0
- package/scripts/release-tag.test.mjs +278 -0
- package/scripts/release-workflow.test.mjs +98 -0
- package/scripts/release.js +167 -0
- package/scripts/release.test.mjs +347 -0
- package/scripts/removed-v3-names.js +125 -0
- package/scripts/size-app/.size-limit.js +90 -0
- package/scripts/size-app/core.js +3 -0
- package/scripts/size-app/package.json +24 -0
- package/scripts/size-app/react.js +4 -0
- package/scripts/size-app.test.mjs +73 -0
- package/scripts/sync-ai-context-versions.js +102 -0
- package/scripts/sync-example-versions.js +151 -0
- package/scripts/test-examples-published.mjs +1585 -0
- package/scripts/test-examples-published.test.mjs +1586 -0
- package/scripts/traps/any-method-vars-not-a-list.json +5 -0
- package/scripts/traps/canister-method-unknown.json +5 -0
- package/scripts/traps/client-says-who-calls-once.json +5 -0
- package/scripts/traps/client-says-who-calls.json +5 -0
- package/scripts/traps/err-only-on-canister-err.json +14 -0
- package/scripts/traps/format-units-refuses-missing-value.json +5 -0
- package/scripts/traps/format-units-refuses-number.json +5 -0
- package/scripts/traps/format-units-unknown-option.json +5 -0
- package/scripts/traps/guard-err-is-the-methods.json +5 -0
- package/scripts/traps/guard-false-keeps-every-kind.json +5 -0
- package/scripts/traps/internals-not-exported.json +9 -0
- package/scripts/traps/network-refuses-unknown-name.json +5 -0
- package/scripts/traps/never-err-has-no-type.json +5 -0
- package/scripts/traps/options-method-unknown.json +5 -0
- package/scripts/traps/options-vars-wrong-type.json +5 -0
- package/scripts/traps/parse-units-refuses-number.json +5 -0
- package/scripts/traps/parse-units-unknown-option.json +5 -0
- package/scripts/traps/principal-is-not-plain-text.json +14 -0
- package/scripts/traps/query-options-refuses-oneway.json +5 -0
- package/scripts/traps/query-options-refuses-update.json +5 -0
- package/scripts/traps/refuse-next-unknown-option.json +5 -0
- package/scripts/traps/resend-key-reads-the-methods-arg.json +5 -0
- package/scripts/traps/resend-states-its-dedupe-key.json +5 -0
- package/scripts/traps/suspense-refuses-argument-skip.json +5 -0
- package/scripts/traps/suspense-refuses-skippable-read.json +5 -0
- package/scripts/traps/suspense-refuses-vars-skip-fits.json +5 -0
- package/scripts/traps/test-handler-method-unknown.json +5 -0
- package/scripts/traps/test-handler-nat-is-bigint.json +5 -0
- package/scripts/traps/test-handler-takes-the-domain-value.json +5 -0
- package/scripts/traps/vars-of-two-arguments-are-the-tuple.json +5 -0
- package/scripts/typecheck-examples.js +122 -0
- package/scripts/verify-faults.mjs +375 -0
- package/scripts/verify-faults.test.mjs +402 -0
- package/scripts/verify-package-artifacts.mjs +590 -0
- package/scripts/verify-peer-floors.js +399 -0
- package/scripts/verify-peer-floors.test.mjs +422 -0
- package/scripts/verify-test-fails-rules.mjs +104 -0
- package/scripts/verify-test-fails-rules.test.mjs +215 -0
- package/scripts/verify-test-fails.js +371 -0
- package/scripts/verify-traps.mjs +505 -0
- package/scripts/verify-traps.test.mjs +521 -0
- package/scripts/verify-typescript-floor.js +239 -0
- package/skill-packages/ic-reactor/SKILL.md +103 -0
- package/stack.json +8 -0
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin's options, read once when the plugin is made, each value checked
|
|
3
|
+
* before the plugin does anything with it.
|
|
4
|
+
*
|
|
5
|
+
* A JavaScript config is not type-checked, so an option can hold a value of
|
|
6
|
+
* any kind, and an object of options a key of any name. Only an omitted
|
|
7
|
+
* option (`undefined`) is one not given: every value given is checked, on
|
|
8
|
+
* every canister, with a `didFile` or not, and whether or not a run would use
|
|
9
|
+
* it, and quoted in a message by `describeValue`, which never throws. So is
|
|
10
|
+
* every key: one that is no option (a misspelled `canister`, `didfile` or
|
|
11
|
+
* `canisterID`) is refused whatever its value, `undefined` included, and the
|
|
12
|
+
* message names the option it may misspell. Never read, it would start the
|
|
13
|
+
* plugin with no canister, take a canister for one only named in the cookie,
|
|
14
|
+
* or generate one without its ID, without a word.
|
|
15
|
+
*
|
|
16
|
+
* - An option of the whole plugin (`canisters`, `injectEnvironment`,
|
|
17
|
+
* `failOnError`, `onGenerated`) that is not one throws when the config
|
|
18
|
+
* loads, and so does a key of the options that is none of them: read by a
|
|
19
|
+
* guess, the options could ship stale bindings or drop the local
|
|
20
|
+
* environment.
|
|
21
|
+
* - A canister whose options hold a value that is not one, or a key that is
|
|
22
|
+
* no option, is refused. Every run fails it, with the reasons, before the
|
|
23
|
+
* run does anything else: it fetches nothing, writes nothing, runs no
|
|
24
|
+
* `meant` process and makes no request for it, and the other
|
|
25
|
+
* canisters run as they would. Its name is still in the `ic_env` cookie,
|
|
26
|
+
* which carries every canister an entry names: the app may still call it.
|
|
27
|
+
*
|
|
28
|
+
* Each option is read once, here: a getter runs once, and one that throws
|
|
29
|
+
* refuses its canister. What the plugin keeps is a copy of what was read.
|
|
30
|
+
*
|
|
31
|
+
* Only `undefined` selects an option's default: every default here is chosen
|
|
32
|
+
* by `=== undefined`, never by `??` or `||`, which would take `null` (or `0`,
|
|
33
|
+
* `""`, `false`) for an option not given. Each value but `undefined` is
|
|
34
|
+
* checked first, and one that is not a value of the option is refused.
|
|
35
|
+
*
|
|
36
|
+
* Every object of options (the options, `canisters`, each canister's entry,
|
|
37
|
+
* a `network` of `{ host }`) is a plain object: one whose prototype is
|
|
38
|
+
* `Object.prototype` or `null`. A `Map`, a `Promise`, an instance of a class
|
|
39
|
+
* or an object that inherits from another is refused as any other value that
|
|
40
|
+
* is not one: read for its keys, a `Map` of canisters or a `Promise` of
|
|
41
|
+
* options would be read as none. Its keys are its own enumerable string keys,
|
|
42
|
+
* as `Object.keys` lists them (which runs no getter): each key of the
|
|
43
|
+
* options, of an entry and of a network is one of its type's options, and
|
|
44
|
+
* each key of `canisters` a canister's name.
|
|
45
|
+
*
|
|
46
|
+
* A canister's name is its name in the `icp` project, kept as given:
|
|
47
|
+
* `__proto__`, `constructor` and `toString` name canisters as any other name
|
|
48
|
+
* does. What the plugin keeps by canister name is kept in a `Map`, never in a
|
|
49
|
+
* plain object, where such a name would reach `Object.prototype` (an
|
|
50
|
+
* assignment to `__proto__` sets the prototype, and a lookup of `toString`
|
|
51
|
+
* finds a function). A name the `ic_env` cookie cannot carry
|
|
52
|
+
* (`cookieCarries`: every name `icp` gives a canister is one it carries) is
|
|
53
|
+
* left out of the cookie, with a warning.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
import { describeError, describeValue } from "./describe-value.js"
|
|
57
|
+
import { cookieCarries } from "./env.js"
|
|
58
|
+
import { resolveNetwork, type CanisterNetwork } from "./fetch.js"
|
|
59
|
+
import type { IcReactorPluginOptions } from "./index.js"
|
|
60
|
+
import { isPrincipalText } from "./principal-text.js"
|
|
61
|
+
|
|
62
|
+
/** Where a canister's module goes when it sets no `outDir`. */
|
|
63
|
+
export const DEFAULT_OUT_DIR = "src/canisters"
|
|
64
|
+
|
|
65
|
+
/** A canister's entry, as the options' type gives it. */
|
|
66
|
+
type CanisterEntry = NonNullable<IcReactorPluginOptions["canisters"]>[string]
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The options of `icReactor()`, of a canister's entry and of a `network` of
|
|
70
|
+
* `{ host }`, in the order of their types. Each is checked against its type
|
|
71
|
+
* (`satisfies`): an option the type gains, or loses, fails the type check
|
|
72
|
+
* until it is listed here, so no option the type allows is refused.
|
|
73
|
+
*/
|
|
74
|
+
const PLUGIN_OPTIONS = Object.keys({
|
|
75
|
+
canisters: true,
|
|
76
|
+
injectEnvironment: true,
|
|
77
|
+
failOnError: true,
|
|
78
|
+
onGenerated: true,
|
|
79
|
+
} satisfies Record<keyof IcReactorPluginOptions, true>)
|
|
80
|
+
const CANISTER_OPTIONS = Object.keys({
|
|
81
|
+
didFile: true,
|
|
82
|
+
outDir: true,
|
|
83
|
+
canisterId: true,
|
|
84
|
+
network: true,
|
|
85
|
+
methods: true,
|
|
86
|
+
verify: true,
|
|
87
|
+
} satisfies Record<keyof CanisterEntry, true>)
|
|
88
|
+
const NETWORK_OPTIONS = Object.keys({
|
|
89
|
+
host: true,
|
|
90
|
+
} satisfies Record<
|
|
91
|
+
keyof Extract<NonNullable<CanisterEntry["network"]>, object>,
|
|
92
|
+
true
|
|
93
|
+
>)
|
|
94
|
+
|
|
95
|
+
/** A canister with a `.did` to generate from: its options, every one checked. */
|
|
96
|
+
export interface Generated {
|
|
97
|
+
name: string
|
|
98
|
+
didFile: string
|
|
99
|
+
outDir: string
|
|
100
|
+
/** The live canister its `didFile` is fetched from when it is not on disk. */
|
|
101
|
+
canisterId?: string
|
|
102
|
+
network?: CanisterNetwork
|
|
103
|
+
/** The methods a fetched `didFile` is projected to. */
|
|
104
|
+
methods?: readonly string[]
|
|
105
|
+
verify?: "live"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A canister whose options cannot be used, and why. */
|
|
109
|
+
export interface Refused {
|
|
110
|
+
name: string
|
|
111
|
+
/**
|
|
112
|
+
* Every reason: a key of its entry that is no option first, then each
|
|
113
|
+
* option's, in the order of the options.
|
|
114
|
+
*/
|
|
115
|
+
problem: string
|
|
116
|
+
/**
|
|
117
|
+
* Its `didFile`, when that is a path. Canisters that share a `didFile` to
|
|
118
|
+
* be fetched share its fetch, so a refused one refuses it for them all.
|
|
119
|
+
*/
|
|
120
|
+
didFile?: string
|
|
121
|
+
/** Whether it gave a `canisterId`, of any value, as a canister to fetch from does. */
|
|
122
|
+
givesCanisterId: boolean
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The plugin's options as read and checked. */
|
|
126
|
+
export interface ReadOptions {
|
|
127
|
+
injectEnvironment: boolean
|
|
128
|
+
failOnError: boolean | undefined
|
|
129
|
+
/** Called after each module a run generates; checked to be a function. */
|
|
130
|
+
onGenerated: IcReactorPluginOptions["onGenerated"]
|
|
131
|
+
/**
|
|
132
|
+
* Every canister an entry names, which the `ic_env` cookie carries: all but
|
|
133
|
+
* those of `uncarriedNames`.
|
|
134
|
+
*/
|
|
135
|
+
names: string[]
|
|
136
|
+
/**
|
|
137
|
+
* The canisters an entry names that the cookie cannot carry
|
|
138
|
+
* (`cookieCarries`), which it leaves out, with a warning. They are
|
|
139
|
+
* generated, and refused, as any other.
|
|
140
|
+
*/
|
|
141
|
+
uncarriedNames: string[]
|
|
142
|
+
/**
|
|
143
|
+
* The cookie's ID of each canister whose `canisterId` is one, by canister
|
|
144
|
+
* name: a `Map`, so that any name is kept as given.
|
|
145
|
+
*/
|
|
146
|
+
configuredCanisterIds: Map<string, string>
|
|
147
|
+
/** `name: value` for each `canisterId` given that is not one. */
|
|
148
|
+
notCanisterIds: string[]
|
|
149
|
+
/** The canisters with a `didFile` whose options are all values. */
|
|
150
|
+
generated: Generated[]
|
|
151
|
+
/**
|
|
152
|
+
* The canisters that are refused: one whose options hold a value that is
|
|
153
|
+
* not one, with a `didFile` or not, and one whose options cannot be read.
|
|
154
|
+
*/
|
|
155
|
+
refused: Refused[]
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* An object of options, as the options, `canisters`, each canister's entry
|
|
160
|
+
* and a `network` of `{ host }` are: a plain object, whose prototype is
|
|
161
|
+
* `Object.prototype` or `null`, as an object written `{ … }` and those that
|
|
162
|
+
* `JSON.parse`, `Object.fromEntries` and `Object.create(null)` make are. Not
|
|
163
|
+
* `null`, a list or a function, nor an object of a class (a `Map`, a
|
|
164
|
+
* `Promise`, a `Date`, a boxed string, a class's instance) or one that
|
|
165
|
+
* inherits from another object: read as options, a `Map`'s entries and a
|
|
166
|
+
* `Promise`'s value are none, so its canisters or its options would be left
|
|
167
|
+
* out without a word. Never throws: a proxy is asked for its prototype, and
|
|
168
|
+
* one that throws (a revoked one) is not a plain object.
|
|
169
|
+
*/
|
|
170
|
+
function isOptionsObject(value: unknown): value is Record<string, unknown> {
|
|
171
|
+
try {
|
|
172
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
173
|
+
return false
|
|
174
|
+
}
|
|
175
|
+
const prototype: unknown = Object.getPrototypeOf(value)
|
|
176
|
+
return prototype === Object.prototype || prototype === null
|
|
177
|
+
} catch {
|
|
178
|
+
// A revoked proxy, or a proxy's trap that throws.
|
|
179
|
+
return false
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* `value`, which is not a plain object, as a message quotes it.
|
|
185
|
+
* `describeValue` names an object's class (`Map {}`, `Promise {}`,
|
|
186
|
+
* `Ledger {…}`), but quotes one whose prototype has no class to name as it
|
|
187
|
+
* quotes a plain object, `{…}`: the quote then says that it inherits.
|
|
188
|
+
*/
|
|
189
|
+
function describeNotPlain(value: unknown): string {
|
|
190
|
+
const quoted = describeValue(value)
|
|
191
|
+
return quoted.startsWith("{")
|
|
192
|
+
? `${quoted} (an object that inherits from another)`
|
|
193
|
+
: quoted
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** `value` as a path to read or write, relative to the Vite root. */
|
|
197
|
+
const isPath = (value: unknown): value is string =>
|
|
198
|
+
typeof value === "string" && value !== "" && !value.includes("\0")
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Why a boolean option is not one, or `undefined` when it is omitted or a
|
|
202
|
+
* boolean. Read by truthiness, `0`, `""` or `null` would turn the option off
|
|
203
|
+
* and `"false"` would turn it on, without a word.
|
|
204
|
+
*/
|
|
205
|
+
export function booleanProblem(
|
|
206
|
+
name: string,
|
|
207
|
+
value: unknown
|
|
208
|
+
): string | undefined {
|
|
209
|
+
if (value === undefined || typeof value === "boolean") return undefined
|
|
210
|
+
return (
|
|
211
|
+
`[ic-reactor] ${name} is ${describeValue(value)}, not true or false: ` +
|
|
212
|
+
`set it to true or false, or remove it for the default`
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Why `methods` cannot be projected to, or `undefined` when it can. */
|
|
217
|
+
export function methodsProblem(methods: unknown): string | undefined {
|
|
218
|
+
if (methods === undefined) return undefined
|
|
219
|
+
if (!Array.isArray(methods)) {
|
|
220
|
+
return `methods is ${describeValue(methods)}, not a list of method names`
|
|
221
|
+
}
|
|
222
|
+
if (methods.length === 0) {
|
|
223
|
+
return "methods is empty: name the methods the app calls, or remove methods for the whole interface"
|
|
224
|
+
}
|
|
225
|
+
for (const name of methods as unknown[]) {
|
|
226
|
+
if (typeof name !== "string" || name === "") {
|
|
227
|
+
return `methods holds ${describeValue(name)}, which is not a method name`
|
|
228
|
+
}
|
|
229
|
+
if (name.includes(",")) {
|
|
230
|
+
return `methods names ${describeValue(name)}, which has a comma: \`meant project\` takes the names separated by commas, so it cannot be projected to`
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return undefined
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Why `verify` is not an option value, or `undefined` when it is: omitted, or
|
|
238
|
+
* `"live"`.
|
|
239
|
+
*/
|
|
240
|
+
export function verifyProblem(verify: unknown): string | undefined {
|
|
241
|
+
if (verify === undefined || verify === "live") return undefined
|
|
242
|
+
return `verify is ${describeValue(verify)}, not "live": set it to "live" for the live check, or remove it for none`
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Why `canisterId` is not a canister ID, or `undefined` when it is one or is
|
|
247
|
+
* omitted. A canister ID is the text of a principal, which is told here, and
|
|
248
|
+
* not only by the fetch or the check that reads it: those load
|
|
249
|
+
* `@icp-sdk/core`, and a canister with `methods` would have its methods
|
|
250
|
+
* listed, by a `meant` process, before its check found the ID wrong.
|
|
251
|
+
*/
|
|
252
|
+
export function canisterIdProblem(canisterId: unknown): string | undefined {
|
|
253
|
+
if (canisterId === undefined) return undefined
|
|
254
|
+
if (typeof canisterId !== "string" || canisterId === "") {
|
|
255
|
+
return `canisterId is ${describeValue(canisterId)}, not a canister ID: give the canister's principal as text, or remove canisterId`
|
|
256
|
+
}
|
|
257
|
+
if (isPrincipalText(canisterId)) return undefined
|
|
258
|
+
return (
|
|
259
|
+
`canisterId is ${describeValue(canisterId)}, not a canister ID: it is not the text of a principal, ` +
|
|
260
|
+
`which is lowercase, in groups of five joined by dashes, with a checksum, and at most 63 characters. ` +
|
|
261
|
+
`Give the canister's ID as it is printed, or remove canisterId`
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** A read of one option: its value, or what reading it threw. */
|
|
266
|
+
type Read = { value: unknown; threw?: undefined } | { threw: string }
|
|
267
|
+
|
|
268
|
+
/** Read `key` of `object`, once. Never throws. */
|
|
269
|
+
function readKey(object: Record<string, unknown>, key: string): Read {
|
|
270
|
+
try {
|
|
271
|
+
return { value: object[key] }
|
|
272
|
+
} catch (error) {
|
|
273
|
+
return { threw: describeError(error) }
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The keys of `object`, its own enumerable ones, or what listing them threw
|
|
279
|
+
* (a proxy's trap). Runs no getter. Never throws.
|
|
280
|
+
*/
|
|
281
|
+
function listKeys(
|
|
282
|
+
object: Record<string, unknown>
|
|
283
|
+
): { keys: string[]; threw?: undefined } | { threw: string } {
|
|
284
|
+
try {
|
|
285
|
+
return { keys: Object.keys(object) }
|
|
286
|
+
} catch (error) {
|
|
287
|
+
return { threw: describeError(error) }
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** `a`, `a and b`, `a, b and c`. */
|
|
292
|
+
function listAnd(items: readonly string[]): string {
|
|
293
|
+
return items.length < 2
|
|
294
|
+
? items.join("")
|
|
295
|
+
: `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* How many single letters must be added, removed or replaced to turn `a`
|
|
300
|
+
* into `b`.
|
|
301
|
+
*/
|
|
302
|
+
function editDistance(a: string, b: string): number {
|
|
303
|
+
let row = Array.from({ length: b.length + 1 }, (_, j) => j)
|
|
304
|
+
for (let i = 1; i <= a.length; i++) {
|
|
305
|
+
const next = [i]
|
|
306
|
+
for (let j = 1; j <= b.length; j++) {
|
|
307
|
+
next.push(
|
|
308
|
+
Math.min(
|
|
309
|
+
row[j] + 1,
|
|
310
|
+
next[j - 1] + 1,
|
|
311
|
+
row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
|
|
312
|
+
)
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
row = next
|
|
316
|
+
}
|
|
317
|
+
return row[b.length]
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The option of `options` that `key` may misspell: the nearest, case aside,
|
|
322
|
+
* within two letters (`canister`, `didfile`, `canisterID`); `undefined` when
|
|
323
|
+
* none is that near.
|
|
324
|
+
*/
|
|
325
|
+
function misspelt(key: string, options: readonly string[]): string | undefined {
|
|
326
|
+
let nearest: string | undefined
|
|
327
|
+
let distance = 3
|
|
328
|
+
for (const option of options) {
|
|
329
|
+
// More than two letters apart by their lengths alone.
|
|
330
|
+
if (Math.abs(key.length - option.length) >= distance) continue
|
|
331
|
+
const apart = editDistance(key.toLowerCase(), option.toLowerCase())
|
|
332
|
+
if (apart < distance) {
|
|
333
|
+
nearest = option
|
|
334
|
+
distance = apart
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return nearest
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Why `keys`, the keys of an object of options, are not all among its
|
|
342
|
+
* `options`, or `undefined` when they are: each key that is none, quoted as
|
|
343
|
+
* given, with the option it may misspell. A key is refused whatever its
|
|
344
|
+
* value, `undefined` included: the key is what is wrong, and a misspelled
|
|
345
|
+
* `canisterID: process.env.LEDGER_ID` is so whether the variable is set or
|
|
346
|
+
* not.
|
|
347
|
+
*/
|
|
348
|
+
function unknownKeysProblem(
|
|
349
|
+
keys: readonly string[],
|
|
350
|
+
options: readonly string[]
|
|
351
|
+
): string | undefined {
|
|
352
|
+
const unknown = keys.filter((key) => !options.includes(key))
|
|
353
|
+
if (unknown.length === 0) return undefined
|
|
354
|
+
const quoted = unknown.map((key) => {
|
|
355
|
+
const meant = misspelt(key, options)
|
|
356
|
+
return meant === undefined
|
|
357
|
+
? describeValue(key)
|
|
358
|
+
: `${describeValue(key)} (did you mean ${meant}?)`
|
|
359
|
+
})
|
|
360
|
+
return `${listAnd(quoted)} ${unknown.length === 1 ? "is not an option" : "are not options"}`
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* The plugin's options, read and checked. Throws an `Error` that says what to
|
|
365
|
+
* change for an option of the whole plugin that is not one, or a key of the
|
|
366
|
+
* options that is no option; a canister's options never throw, and refuse
|
|
367
|
+
* that canister instead.
|
|
368
|
+
*/
|
|
369
|
+
export function readOptions(given: unknown): ReadOptions {
|
|
370
|
+
const options = given === undefined ? {} : given
|
|
371
|
+
if (!isOptionsObject(options)) {
|
|
372
|
+
throw new Error(
|
|
373
|
+
`[ic-reactor] the options are ${describeNotPlain(options)}, not a plain object: give icReactor() an object of options, or none`
|
|
374
|
+
)
|
|
375
|
+
}
|
|
376
|
+
// Every key is an option: a misspelled `canister`, never read, would start
|
|
377
|
+
// the plugin with no canister, without a word.
|
|
378
|
+
const listed = listKeys(options)
|
|
379
|
+
if (listed.threw !== undefined) {
|
|
380
|
+
throw new Error(
|
|
381
|
+
`[ic-reactor] the options could not be listed: ${listed.threw}`
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
const unknown = unknownKeysProblem(listed.keys, PLUGIN_OPTIONS)
|
|
385
|
+
if (unknown !== undefined) {
|
|
386
|
+
throw new Error(
|
|
387
|
+
`[ic-reactor] ${unknown} of icReactor(): its options are ${listAnd(PLUGIN_OPTIONS)}`
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
const top = (key: string): unknown => {
|
|
391
|
+
const read = readKey(options, key)
|
|
392
|
+
if (read.threw !== undefined) {
|
|
393
|
+
throw new Error(
|
|
394
|
+
`[ic-reactor] the option ${key} could not be read: ${read.threw}`
|
|
395
|
+
)
|
|
396
|
+
}
|
|
397
|
+
return read.value
|
|
398
|
+
}
|
|
399
|
+
// Thrown, so that the config does not load: either value read by guess
|
|
400
|
+
// could ship stale bindings or drop the local environment.
|
|
401
|
+
const injectEnvironment = top("injectEnvironment")
|
|
402
|
+
const failOnError = top("failOnError")
|
|
403
|
+
const problem =
|
|
404
|
+
booleanProblem("injectEnvironment", injectEnvironment) ??
|
|
405
|
+
booleanProblem("failOnError", failOnError)
|
|
406
|
+
if (problem) throw new Error(problem)
|
|
407
|
+
// Thrown too: a hook that is not a function would fail every run, or, read
|
|
408
|
+
// by truthiness, be skipped without a word.
|
|
409
|
+
const onGenerated = top("onGenerated")
|
|
410
|
+
if (onGenerated !== undefined && typeof onGenerated !== "function") {
|
|
411
|
+
throw new Error(
|
|
412
|
+
`[ic-reactor] onGenerated is ${describeValue(onGenerated)}, not a function: ` +
|
|
413
|
+
`give it a function to call after each generated module, or remove it`
|
|
414
|
+
)
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Only an omitted `canisters` is none: `null` is refused below, as any other
|
|
418
|
+
// value that is not a plain object of canisters is, a `Map` or a `Promise`
|
|
419
|
+
// of them included.
|
|
420
|
+
const givenCanisters = top("canisters")
|
|
421
|
+
const canisters = givenCanisters === undefined ? {} : givenCanisters
|
|
422
|
+
if (!isOptionsObject(canisters)) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
`[ic-reactor] canisters is ${describeNotPlain(canisters)}, not a plain object of canisters by name: ` +
|
|
425
|
+
`give each canister's options under its name, or remove canisters`
|
|
426
|
+
)
|
|
427
|
+
}
|
|
428
|
+
let keys: string[]
|
|
429
|
+
try {
|
|
430
|
+
keys = Object.keys(canisters)
|
|
431
|
+
} catch (error) {
|
|
432
|
+
throw new Error(
|
|
433
|
+
`[ic-reactor] the canisters could not be listed: ${describeError(error)}`
|
|
434
|
+
)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const read: ReadOptions = {
|
|
438
|
+
// Checked above: `undefined` or a boolean.
|
|
439
|
+
injectEnvironment:
|
|
440
|
+
injectEnvironment === undefined ? true : (injectEnvironment as boolean),
|
|
441
|
+
failOnError: failOnError as boolean | undefined,
|
|
442
|
+
// Checked above: `undefined` or a function.
|
|
443
|
+
onGenerated: onGenerated as IcReactorPluginOptions["onGenerated"],
|
|
444
|
+
names: [],
|
|
445
|
+
uncarriedNames: [],
|
|
446
|
+
configuredCanisterIds: new Map(),
|
|
447
|
+
notCanisterIds: [],
|
|
448
|
+
generated: [],
|
|
449
|
+
refused: [],
|
|
450
|
+
}
|
|
451
|
+
for (const name of keys) {
|
|
452
|
+
const entry = readKey(canisters, name)
|
|
453
|
+
// Omitted, as a conditional entry of a JavaScript config is.
|
|
454
|
+
if (entry.threw === undefined && entry.value === undefined) continue
|
|
455
|
+
// The cookie names every canister an entry names, but one whose name it
|
|
456
|
+
// cannot carry: read back, that one would be another key.
|
|
457
|
+
const carried = cookieCarries(name)
|
|
458
|
+
;(carried ? read.names : read.uncarriedNames).push(name)
|
|
459
|
+
if (entry.threw !== undefined || !isOptionsObject(entry.value)) {
|
|
460
|
+
read.refused.push({
|
|
461
|
+
name,
|
|
462
|
+
problem:
|
|
463
|
+
entry.threw !== undefined
|
|
464
|
+
? `its options could not be read: ${entry.threw}`
|
|
465
|
+
: `its options are ${describeNotPlain(entry.value)}, not a plain object of options (didFile, canisterId, …)`,
|
|
466
|
+
givesCanisterId: false,
|
|
467
|
+
})
|
|
468
|
+
continue
|
|
469
|
+
}
|
|
470
|
+
readCanister(name, entry.value, read, carried)
|
|
471
|
+
}
|
|
472
|
+
return read
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Read and check the options of the canister `name`, into `read`. `carried`:
|
|
477
|
+
* whether the cookie carries its name, and so its `canisterId`.
|
|
478
|
+
*/
|
|
479
|
+
function readCanister(
|
|
480
|
+
name: string,
|
|
481
|
+
entry: Record<string, unknown>,
|
|
482
|
+
read: ReadOptions,
|
|
483
|
+
carried: boolean
|
|
484
|
+
): void {
|
|
485
|
+
const problems: string[] = []
|
|
486
|
+
// Every key is an option, whatever its value: a misspelled `didfile`, never
|
|
487
|
+
// read, would take the canister for one only named in the cookie, and a
|
|
488
|
+
// misspelled `canisterID` would generate it without its ID.
|
|
489
|
+
const listed = listKeys(entry)
|
|
490
|
+
if (listed.threw !== undefined) {
|
|
491
|
+
problems.push(`its options could not be listed: ${listed.threw}`)
|
|
492
|
+
} else {
|
|
493
|
+
const unknown = unknownKeysProblem(listed.keys, CANISTER_OPTIONS)
|
|
494
|
+
if (unknown !== undefined) {
|
|
495
|
+
problems.push(
|
|
496
|
+
`${unknown} of a canister: its options are ${listAnd(CANISTER_OPTIONS)}`
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/** The value of `key`, `undefined` with a problem when reading it threw. */
|
|
501
|
+
const value = (key: string): unknown => {
|
|
502
|
+
const result = readKey(entry, key)
|
|
503
|
+
if (result.threw === undefined) return result.value
|
|
504
|
+
problems.push(`${key} could not be read: ${result.threw}`)
|
|
505
|
+
return undefined
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const problemsBefore = problems.length
|
|
509
|
+
const didFile = value("didFile")
|
|
510
|
+
const didFileThrew = problems.length > problemsBefore
|
|
511
|
+
// A canister with no `didFile` generates nothing, and is only named in the
|
|
512
|
+
// cookie. Its other options are checked all the same: a value that is not
|
|
513
|
+
// one refuses it too.
|
|
514
|
+
const hasDidFile = didFile !== undefined || didFileThrew
|
|
515
|
+
const canisterIdRead = readKey(entry, "canisterId")
|
|
516
|
+
const canisterId =
|
|
517
|
+
canisterIdRead.threw === undefined ? canisterIdRead.value : undefined
|
|
518
|
+
const canisterIdWrong =
|
|
519
|
+
canisterIdRead.threw === undefined
|
|
520
|
+
? canisterIdProblem(canisterId)
|
|
521
|
+
: undefined
|
|
522
|
+
|
|
523
|
+
// The cookie's: a configured ID wins over the one `icp` reports. Only a
|
|
524
|
+
// principal's text can be one: any other value given is left to `icp`, with
|
|
525
|
+
// a warning, rather than put in the cookie or taken for no canisterId. A
|
|
526
|
+
// canister the cookie cannot carry is in neither, and has the warning of
|
|
527
|
+
// its name; its `canisterId` is checked below all the same.
|
|
528
|
+
if (carried) {
|
|
529
|
+
if (canisterIdRead.threw !== undefined) {
|
|
530
|
+
read.notCanisterIds.push(
|
|
531
|
+
`${name}: could not be read (${canisterIdRead.threw})`
|
|
532
|
+
)
|
|
533
|
+
} else if (canisterId !== undefined && canisterIdWrong === undefined) {
|
|
534
|
+
read.configuredCanisterIds.set(name, canisterId as string)
|
|
535
|
+
} else if (canisterId !== undefined) {
|
|
536
|
+
read.notCanisterIds.push(`${name}: ${describeValue(canisterId)}`)
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (didFile !== undefined && !isPath(didFile)) {
|
|
541
|
+
problems.push(
|
|
542
|
+
`didFile is ${describeValue(didFile)}, not a path: give the canister's .did file relative to the Vite root, ` +
|
|
543
|
+
`or remove didFile for a canister that is only named in the ic_env cookie`
|
|
544
|
+
)
|
|
545
|
+
}
|
|
546
|
+
const outDir = value("outDir")
|
|
547
|
+
if (outDir !== undefined && !isPath(outDir)) {
|
|
548
|
+
problems.push(
|
|
549
|
+
`outDir is ${describeValue(outDir)}, not a path: give the directory relative to the Vite root, ` +
|
|
550
|
+
`or remove outDir for "src/canisters"`
|
|
551
|
+
)
|
|
552
|
+
}
|
|
553
|
+
if (canisterIdRead.threw !== undefined) {
|
|
554
|
+
problems.push(`canisterId could not be read: ${canisterIdRead.threw}`)
|
|
555
|
+
} else if (canisterIdWrong !== undefined) {
|
|
556
|
+
problems.push(canisterIdWrong)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// A copy: `{ host }` read once, so that no getter of the object given runs
|
|
560
|
+
// again when the network is resolved. Any other object (a `URL`, a `Map`,
|
|
561
|
+
// a `Promise`, a list) is not a network, whatever its `host`, and `{ host }`
|
|
562
|
+
// holds no other key: the plugin takes the root key from the host, so a
|
|
563
|
+
// `rootKey` or `fetchRootKey` would be read as nothing.
|
|
564
|
+
const givenNetwork = value("network")
|
|
565
|
+
let network: CanisterNetwork | undefined
|
|
566
|
+
if (isOptionsObject(givenNetwork)) {
|
|
567
|
+
const networkKeys = listKeys(givenNetwork)
|
|
568
|
+
if (networkKeys.threw !== undefined) {
|
|
569
|
+
problems.push(`network's keys could not be listed: ${networkKeys.threw}`)
|
|
570
|
+
} else {
|
|
571
|
+
const unknown = unknownKeysProblem(networkKeys.keys, NETWORK_OPTIONS)
|
|
572
|
+
if (unknown !== undefined) {
|
|
573
|
+
problems.push(
|
|
574
|
+
`${unknown} of network { host }: give the network as { host: "<http or https URL>" } alone`
|
|
575
|
+
)
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
const host = readKey(givenNetwork, "host")
|
|
579
|
+
if (host.threw !== undefined) {
|
|
580
|
+
problems.push(`network.host could not be read: ${host.threw}`)
|
|
581
|
+
} else {
|
|
582
|
+
network = { host: host.value } as CanisterNetwork
|
|
583
|
+
}
|
|
584
|
+
} else if (typeof givenNetwork === "object" && givenNetwork !== null) {
|
|
585
|
+
problems.push(
|
|
586
|
+
`network ${describeNotPlain(givenNetwork)} is not "ic", "local" or a plain object { host: "<http or https URL>" }`
|
|
587
|
+
)
|
|
588
|
+
} else {
|
|
589
|
+
network = givenNetwork as CanisterNetwork | undefined
|
|
590
|
+
}
|
|
591
|
+
if (network !== undefined) {
|
|
592
|
+
const resolved = resolveNetwork(network)
|
|
593
|
+
if (typeof resolved === "string") problems.push(resolved)
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// A copy of the list, read once.
|
|
597
|
+
let methods = value("methods")
|
|
598
|
+
try {
|
|
599
|
+
if (Array.isArray(methods)) methods = Array.from(methods as unknown[])
|
|
600
|
+
} catch (error) {
|
|
601
|
+
problems.push(`methods could not be read: ${describeError(error)}`)
|
|
602
|
+
methods = undefined
|
|
603
|
+
}
|
|
604
|
+
const methodsWrong = methodsProblem(methods)
|
|
605
|
+
if (methodsWrong) problems.push(methodsWrong)
|
|
606
|
+
|
|
607
|
+
const verify = value("verify")
|
|
608
|
+
const verifyWrong = verifyProblem(verify)
|
|
609
|
+
if (verifyWrong) {
|
|
610
|
+
problems.push(verifyWrong)
|
|
611
|
+
} else if (verify === "live" && hasDidFile && canisterId === undefined) {
|
|
612
|
+
// With no `didFile`, there is nothing to check: `"live"` is a value, and
|
|
613
|
+
// unused.
|
|
614
|
+
if (canisterIdRead.threw === undefined) {
|
|
615
|
+
problems.push(
|
|
616
|
+
`verify is "live", but it names no canisterId to check its didFile against`
|
|
617
|
+
)
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (problems.length > 0) {
|
|
622
|
+
read.refused.push({
|
|
623
|
+
name,
|
|
624
|
+
problem: problems.join("; "),
|
|
625
|
+
didFile: isPath(didFile) ? didFile : undefined,
|
|
626
|
+
givesCanisterId: canisterId !== undefined || !!canisterIdRead.threw,
|
|
627
|
+
})
|
|
628
|
+
return
|
|
629
|
+
}
|
|
630
|
+
if (!hasDidFile) return
|
|
631
|
+
read.generated.push({
|
|
632
|
+
name,
|
|
633
|
+
didFile: didFile as string,
|
|
634
|
+
// Checked above: `undefined` or a path.
|
|
635
|
+
outDir: outDir === undefined ? DEFAULT_OUT_DIR : (outDir as string),
|
|
636
|
+
canisterId: canisterId as string | undefined,
|
|
637
|
+
network,
|
|
638
|
+
methods: methods as readonly string[] | undefined,
|
|
639
|
+
verify: verify as "live" | undefined,
|
|
640
|
+
})
|
|
641
|
+
}
|