Make sure we have a signer in some cases

This commit is contained in:
Alexis Sellier
2021-05-21 15:29:12 +02:00
parent 58ce44f5f5
commit 34298a1081
4 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -107,7 +107,7 @@
<div class="nav">
<a use:link href="/registrations">Register</a>
<a use:link href="/vesting/">Vesting</a>
{#if config && config.network.name === 'ropsten'}
{#if config && config.signer && config.network.name === 'ropsten'}
<a use:link href="/orgs/">Orgs</a>
{/if}
</div>
+6
View File
@@ -32,6 +32,8 @@ export class Org {
}
async setName(name: string, config: Config): Promise<TransactionResponse> {
assert(config.signer);
const org = new ethers.Contract(
this.address,
orgAbi,
@@ -78,6 +80,8 @@ export class Org {
threshold: number,
config: Config,
): Promise<TransactionResponse> {
assert(config.signer);
const orgFactory = new ethers.Contract(
config.orgFactory.address,
orgFactoryAbi,
@@ -93,6 +97,8 @@ export class Org {
owner: string,
config: Config,
): Promise<TransactionResponse> {
assert(config.signer);
const orgFactory = new ethers.Contract(
config.orgFactory.address,
orgFactoryAbi,
+6 -2
View File
@@ -84,6 +84,8 @@ export async function registrationFee(config: Config) {
}
export async function registerName(name: string, owner: string, config: Config) {
assert(config.signer);
if (! name) return;
let commitmentJson = window.localStorage.getItem('commitment');
@@ -119,6 +121,8 @@ async function commitAndRegister(name: string, owner: string, config: Config) {
}
async function commit(commitment: string, fee: BigNumber, minAge: number, config: Config) {
assert(config.signer);
state.set(State.Committing);
const owner = config.signer;
@@ -188,10 +192,10 @@ async function permitSignature(
}
async function register(name: string, owner: string, salt: Uint8Array, config: Config) {
assert(config.signer);
state.set(State.Registering);
const signer = config.provider.getSigner();
const tx = await registrar(config).connect(signer).register(
const tx = await registrar(config).connect(config.signer).register(
name, owner, ethers.BigNumber.from(salt), { gasLimit: 150000 }
);
console.log("Sent", tx);
+3
View File
@@ -2,6 +2,7 @@ import type { TransactionResponse } from '@ethersproject/providers';
import type { EnsResolver } from '@ethersproject/providers';
import { ethers } from 'ethers';
import type { Config } from '@app/config';
import { assert } from '@app/error';
const resolverAbi = [
"function multicall(bytes[] calldata data) returns(bytes[] memory results)",
@@ -12,6 +13,8 @@ const resolverAbi = [
export type EnsRecord = { name: string, value: string };
export async function setRecords(name: string, records: EnsRecord[], resolver: EnsResolver, config: Config): Promise<TransactionResponse> {
assert(config.signer);
const resolverContract = new ethers.Contract(resolver.address, resolverAbi, config.signer);
const node = ethers.utils.namehash(`${name}.${config.registrar.domain}`);