Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow only Layer1 / Layer2 to be passed in for fromEthersProvider #229

Open
fionnachan opened this issue Sep 15, 2022 · 0 comments
Open

Comments

@fionnachan
Copy link

Currently Resolution.fromEthersProvider can only be used with two types of params:

  1. Resolution.fromEthersProvider({}) (because the networks {} is not optional)
  2.  Resolution.fromEthersProvider({uns: {
         locations: {
           Layer1: {
             network: 'mainnet',
             provider: mainnetProvider
           },
           Layer2: {
             network: 'polygon-mainnet',
             provider: polygonProvider
           }
         }
     }});

I'd like to only resolve UD in Layer1, but not passing Layer2 would throw the following error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'network')
    at Resolution.fromEthersProvider (Resolution.js:320:1)
    at tryLookupUDName (HeaderAccountPopover.tsx:64:1)
    at resolveENSInfo (HeaderAccountPopover.tsx:118:1)
    at HeaderAccountPopover.tsx:128:1
    at invokePassiveEffectCreate (react-dom.development.js:23487:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at flushPassiveEffectsImpl (react-dom.development.js:23574:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at flushPassiveEffects (react-dom.development.js:23447:1)
    at react-dom.development.js:23324:1
    at workLoop (scheduler.development.js:417:1)
    at flushWork (scheduler.development.js:390:1)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)

Could you please allow only passing in one location?

Reference

static fromEthersProvider(networks: {
uns?: {
locations: {
Layer1: {
network: string;
provider: EthersProvider;
};
Layer2: {
network: string;
provider: EthersProvider;
};
};
};
}): Resolution {
return this.fromEthereumEip1193Provider({
uns: networks.uns
? {
locations: {
Layer1: {
network: networks.uns.locations.Layer1.network,
provider: Eip1193Factories.fromEthersProvider(
networks.uns.locations.Layer1.provider,
),
},
Layer2: {
network: networks.uns.locations.Layer2.network,
provider: Eip1193Factories.fromEthersProvider(
networks.uns.locations.Layer2.provider,
),
},
},
}
: undefined,
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant