Skip to content

Commit 8460479

Browse files
committed
params is optional
1 parent e420e22 commit 8460479

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

client/src/glue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export class ManualGlue extends Glue {
409409
// wallet_addEthereumChain isn't exactly the safest endpoint, so we
410410
// don't expect wallets to implement it. We try optimistically but
411411
// fall back to human instructions if necessary.
412-
console.debug("`wallet_addEthereumChain` failed, going manual");
412+
console.debug("`wallet_addEthereumChain` failed, going manual", e);
413413
}
414414

415415
await this.instruct(

client/src/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ function main() {
123123
throw new TypeError("'method' in body not a string");
124124
}
125125

126-
if (!("params" in msg.body)) {
127-
throw new TypeError("'params' not in message body");
128-
}
129-
130-
if (!(msg.body.params instanceof Array)) {
131-
throw new TypeError("'params' in body not an array");
126+
let params: unknown[];
127+
if ("params" in msg.body) {
128+
if (!(msg.body.params instanceof Array)) {
129+
throw new TypeError(
130+
"'params' in body not an array"
131+
);
132+
}
133+
134+
params = msg.body.params;
135+
} else {
136+
params = [];
132137
}
133138

134139
if (!("number" in msg)) {
@@ -137,7 +142,7 @@ function main() {
137142

138143
result.result = await blockchain.send(
139144
msg.body.method,
140-
msg.body.params
145+
params
141146
);
142147
webSocket?.send(
143148
JSON.stringify({

0 commit comments

Comments
 (0)