Skip to content

Commit

Permalink
Fixed default JsonRpcSigner (ethers-io#532).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 31, 2019
1 parent 5a797bb commit 9034dcf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src.ts/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ export class JsonRpcSigner extends Signer {

defineReadOnly(this, "provider", provider);

// Statically attach to a given address
if (addressOrIndex == null) { addressOrIndex = 0; }
if (addressOrIndex) {
if (typeof(addressOrIndex) === "string") {
defineReadOnly(this, "_address", this.provider.formatter.address(addressOrIndex));
defineReadOnly(this, "_index", null);
} else if (typeof(addressOrIndex) === "number") {
defineReadOnly(this, "_index", addressOrIndex);
defineReadOnly(this, "_address", null);
} else {
errors.throwError("invalid address or index", errors.INVALID_ARGUMENT, { argument: "addressOrIndex", value: addressOrIndex });
}

if (typeof(addressOrIndex) === "string") {
defineReadOnly(this, "_address", this.provider.formatter.address(addressOrIndex));
defineReadOnly(this, "_index", null);

} else if (typeof(addressOrIndex) === "number") {
defineReadOnly(this, "_index", addressOrIndex);
defineReadOnly(this, "_address", null);

} else {
errors.throwError("invalid address or index", errors.INVALID_ARGUMENT, { argument: "addressOrIndex", value: addressOrIndex });
}
}

Expand Down

0 comments on commit 9034dcf

Please sign in to comment.