Skip to content

feat: implement fiber wasm demo#367

Draft
ashuralyk wants to merge 2 commits intockb-devrel:masterfrom
ashuralyk:feat/fiber-js-demo
Draft

feat: implement fiber wasm demo#367
ashuralyk wants to merge 2 commits intockb-devrel:masterfrom
ashuralyk:feat/fiber-js-demo

Conversation

@ashuralyk
Copy link
Copy Markdown
Contributor

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 16, 2026

Deploy Preview for docsccc ready!

Name Link
🔨 Latest commit b6ff57b
🔍 Latest deploy log https://app.netlify.com/projects/docsccc/deploys/69e821e6c4c1d10008f93094
😎 Deploy Preview https://deploy-preview-367--docsccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 73 (🟢 up 6 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 16, 2026

Deploy Preview for apiccc ready!

Name Link
🔨 Latest commit b6ff57b
🔍 Latest deploy log https://app.netlify.com/projects/apiccc/deploys/69e821e6b22000000877cf6d
😎 Deploy Preview https://deploy-preview-367--apiccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 84 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 94 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 16, 2026

Deploy Preview for liveccc ready!

Name Link
🔨 Latest commit b6ff57b
🔍 Latest deploy log https://app.netlify.com/projects/liveccc/deploys/69e821e622bd0c00083a2dbc
😎 Deploy Preview https://deploy-preview-367--liveccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 39 (🟢 up 2 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 16, 2026

⚠️ No Changeset found

Latest commit: b6ff57b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 16, 2026

Deploy Preview for appccc ready!

Name Link
🔨 Latest commit b6ff57b
🔍 Latest deploy log https://app.netlify.com/projects/appccc/deploys/69e821e6d27d8a00084eb443
😎 Deploy Preview https://deploy-preview-367--appccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 86 (no change from production)
Accessibility: 89 (🟢 up 1 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a Fiber node demo for managing in-browser nodes, peers, and payments. Feedback focuses on narrowing security header scope to maintain wallet compatibility, fixing signature byte conversion for key derivation, and replacing floating-point math with fixed-point utilities to ensure precision for CKB amounts.

async headers() {
return [
{
source: "/(.*)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The source pattern /(.*) applies the COOP and COEP headers to all routes. However, the comments on lines 9-12 state that these headers should only be applied to /connected/Fiber because they break cross-origin wallet popups (like JoyID) used on other pages. Applying these headers globally will break wallet functionality for the rest of the application, including the /fiber-sign-proxy mentioned in the comments.

Suggested change
source: "/(.*)",
source: "/connected/Fiber",

addLog("info", `Signing "${message}"…`);
try {
const sig = await signer.signMessage(message);
const sigBytes = new TextEncoder().encode(sig.signature);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The sig.signature returned by CCC signers is a hex string. Using TextEncoder().encode() will encode the literal characters of the hex string (e.g., '0', 'x', 'a'...) rather than the actual bytes of the signature. This results in incorrect entropy for the derived keys. Use ccc.bytesFrom() to correctly parse the hex signature into bytes, adhering to the repository's standard for handling hex-like types.

Suggested change
const sigBytes = new TextEncoder().encode(sig.signature);
const sigBytes = ccc.bytesFrom(sig.signature);
References
  1. Functions should accept more generic types like HexLike and perform necessary type conversions internally, rather than requiring the caller to do so.

const result = await invoke<FjOpenChannel>("open_channel", [
{
pubkey: peerId,
funding_amount: ccc.numToHex(Math.round(Number(fundingAmount) * 1e8)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using floating-point arithmetic (Number(fundingAmount) * 1e8) to handle CKB amounts can lead to precision issues. It is safer to use ccc.fixedPointFrom(fundingAmount, 8) which handles decimal parsing using bigint internally to avoid floating-point errors.

Suggested change
funding_amount: ccc.numToHex(Math.round(Number(fundingAmount) * 1e8)),
funding_amount: ccc.numToHex(ccc.fixedPointFrom(fundingAmount, 8)),

const preimage = ccc.hexFrom(crypto.getRandomValues(new Uint8Array(32)));
const result = await invoke<FjInvoice>("new_invoice", [
{
amount: ccc.numToHex(ccc.numFrom(Math.round(Number(amount) * 1e8))),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using floating-point arithmetic to handle CKB amounts can lead to precision issues. Use ccc.fixedPointFrom(amount, 8) to safely convert the string input to a shannon-denominated bigint.

Suggested change
amount: ccc.numToHex(ccc.numFrom(Math.round(Number(amount) * 1e8))),
amount: ccc.numToHex(ccc.fixedPointFrom(amount, 8)),


/** Converts a shannon balance (hex) to a CKB string with 4 decimal places. */
export function hexToCkb(hex: string): string {
return (Number(ccc.numFrom(hex)) / 1e8).toFixed(4);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Converting large shannon balances to Number can result in precision loss if the value exceeds Number.MAX_SAFE_INTEGER (~90 million CKB). Use ccc.fixedPointToString to safely format bigint balances for display without losing precision.

Suggested change
return (Number(ccc.numFrom(hex)) / 1e8).toFixed(4);
return ccc.fixedPointToString(ccc.numFrom(hex), 8);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant