Fixed ENS names for JsonRpcSigner.

This commit is contained in:
Richard Moore 2021-06-25 00:02:08 -04:00
parent 7deb4c174a
commit 1e31b34a5a
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

View File

@ -183,10 +183,22 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
transaction.gasLimit = this.provider.estimateGas(estimate); 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({ return resolveProperties({
tx: resolveProperties(transaction), tx: resolveProperties(transaction),
sender: fromAddress sender: fromAddress
}).then(({ tx, sender }) => { }).then(({ tx, sender }) => {
if (tx.from != null) { if (tx.from != null) {
if (tx.from.toLowerCase() !== sender) { if (tx.from.toLowerCase() !== sender) {
logger.throwArgumentError("from address mismatch", "transaction", transaction); logger.throwArgumentError("from address mismatch", "transaction", transaction);