Skip to content

Commit

Permalink
fix: use chainid from siwe payload
Browse files Browse the repository at this point in the history
  • Loading branch information
nichonien committed Mar 14, 2023
1 parent 497a6bb commit 0308638
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions lib/LoginStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class LoginStrategy extends BaseStrategy {
);
}
let userDid;
if ((await this.getChainName(this.provider)) === 'ewc') {
if (payload.chainId === EWC_CHAIN_ID) {
userDid = this.didUnification(`did:ethr:ewc:${payload.address}`);
} else {
userDid = this.didUnification(`did:ethr:volta:${payload.address}`);
Expand Down Expand Up @@ -480,15 +480,6 @@ export class LoginStrategy extends BaseStrategy {
return `${didParts[0]}:${didParts[1]}:${chainName}:${didParts[2]}`;
}

/**
* @param {providers.JsonRpcProvider} provider
* @returns {string} name of the chain provider is connected to
*/
async getChainName(provider: providers.JsonRpcProvider): Promise<string> {
const chainID = (await provider.getNetwork()).chainId;
return chainID === EWC_CHAIN_ID ? 'ewc' : 'volta';
}

isEIP191TokenPayload(payload: unknown): payload is ITokenPayload {
if (!payload) return false;
if (typeof payload !== 'object') return false;
Expand Down

0 comments on commit 0308638

Please sign in to comment.