docs: document Buffer polyfill required by the Tron adapter - #107
Open
ScreamingHawk wants to merge 1 commit into
Open
docs: document Buffer polyfill required by the Tron adapter#107ScreamingHawk wants to merge 1 commit into
ScreamingHawk wants to merge 1 commit into
Conversation
TronWeb reads the Node `Buffer` global at module-eval time, so importing `tronAdapter` in a browser throws without a polyfill. Also lists `tronAdapter` in the available adapters table and notes that `svmAdapter` does not need the polyfill.
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TronWeb, pulled in by
@0xtrails/tvm, reads the NodeBufferglobal while its modules evaluate. In a browser that throwsReferenceError: Buffer is not definedon import and takes down the surrounding React tree — a blank page, not a caught error.This bit app.trails.build in production (0xsequence/trails-app#48). The SDK demo app hit the same thing earlier and carries the same polyfill, so it is worth documenting rather than rediscovering a third time.
Changes to
sdk/adapters/overview.mdxtronAdapter/@0xtrails/tvmto the available adapters table — it was missing entirelyOn the SVM question
I checked rather than assumed. Built
app.trails.buildwithsvmAdapteralone and no polyfill, loaded it in headless Chromium:typeof globalThis.Buffer === "undefined", zero errors, page renders normally. Solana genuinely does not need it, so the docs say so explicitly instead of vaguely grouping the two edge rails together.Caveat called out in the docs
The polyfill only works if it evaluates before TronWeb. Bundlers that hoist or split entries can reorder that, so the section points at build-time injection (Vite
define,webpack.ProvidePlugin) as the more robust fallback.mintlify broken-linkspasses.