Skip to content

Commit

Permalink
Fixed ENS names for JsonRpcSigner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jun 25, 2021
1 parent 7deb4c1 commit 1e31b34
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/providers/src.ts/json-rpc-provider.ts
Expand Up @@ -183,10 +183,22 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
transaction.gasLimit = this.provider.estimateGas(estimate);
}

if (transaction.to != null) {
transaction.to = Promise.resolve(transaction.to).then(async (to) => {
if (to == null) { return null; }
const address = await this.provider.resolveName(to);
if (address == null) {
logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to);
}
return address;
});
}

return resolveProperties({
tx: resolveProperties(transaction),
sender: fromAddress
}).then(({ tx, sender }) => {

if (tx.from != null) {
if (tx.from.toLowerCase() !== sender) {
logger.throwArgumentError("from address mismatch", "transaction", transaction);
Expand Down

0 comments on commit 1e31b34

Please sign in to comment.