fix(aegis): 0.9.1 — an unset custom RPC no longer becomes the text "undefined"

Mounting an imported TRX/ETH/SOL wallet read the optional custom RPC as
String(stored || undefined), so a wallet with no override got the literal
"undefined" as its server: every history and token fetch went to
"undefined/v1/accounts/…" and the panel showed "undefined" under the
balance. Only a real https URL overrides the network default now, and the
adapter itself rejects anything that does not look like one.
This commit is contained in:
Local Dev 2026-09-23 00:24:42 +02:00
parent 8174fccba0
commit 7a71b08cf7
3 changed files with 11 additions and 3 deletions

View file

@ -1,7 +1,7 @@
{
"id": "aegis",
"name": "Aegis Wallet",
"version": "0.9.0",
"version": "0.9.1",
"category": "plugin",
"description": "Multi-chain wallet (BCH, BTC, TRX, ETH, SOL, SC, DGB) derived from your Theseus vault. Dapps get window.bitcoincash on .x sites; window.tronWeb / window.tronLink / window.ethereum / window.solana on any https page.",
"author": "Silent Mode",

View file

@ -551,7 +551,12 @@ async function mountWallet(entry) {
} else if (entry.chain === "eth" || entry.chain === "trx" || entry.chain === "sol") {
adapter = new c.d.genericImportedAdapter.GenericImportedWallet({
...commonOpts, chain: entry.chain, address: entry.importedAddress,
rpcUrl: String(c.api.storage.get(`wallets/${entry.id}/rpcUrl`, "") || undefined),
// Only a real custom URL overrides the network default. The old
// String(x || undefined) turned an unset override into the text
// "undefined", which is truthy — so every imported TRX/ETH/SOL wallet
// without a custom RPC fetched "undefined/v1/accounts/…" and showed
// "undefined" as its server.
rpcUrl: String(c.api.storage.get(`wallets/${entry.id}/rpcUrl`, "") || "").trim() || undefined,
});
adapter.schedulePoll(20_000);
} else if (entry.chain === "sc") {

View file

@ -301,7 +301,10 @@ module.exports = function makeGenericImportedAdapter() {
this.chain = chain;
this.network = network;
this._cfg = cfg;
this._net = { ...net, rpc: rpcUrl || net.rpc };
// A custom RPC must look like one; anything else (empty, "undefined",
// a stray non-URL) falls back to the network default.
const customRpc = typeof rpcUrl === "string" && /^https?:\/\/\S+$/i.test(rpcUrl.trim()) ? rpcUrl.trim() : null;
this._net = { ...net, rpc: customRpc || net.rpc };
this.log = log;
this.onChange = onChange;
this._address = address;