Skip to content

Commit

Permalink
Merge pull request #370 from energywebfoundation/#SWTCH-2172
Browse files Browse the repository at this point in the history
fix: add chainName to did for siwe verification
  • Loading branch information
nichonien authored Mar 14, 2023
2 parents a362752 + 0308638 commit 6bb579a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/LoginStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DomainReader,
ResolverContractType,
IRoleDefinitionV2,
EWC_CHAIN_ID,
} from '@energyweb/credential-governance';
import { knownResolvers } from './defaultConfig';
import {
Expand Down Expand Up @@ -302,7 +303,12 @@ export class LoginStrategy extends BaseStrategy {
null
);
}
const userDid = this.didUnification(`did:ethr:${payload.address}`);
let userDid;
if (payload.chainId === EWC_CHAIN_ID) {
userDid = this.didUnification(`did:ethr:ewc:${payload.address}`);
} else {
userDid = this.didUnification(`did:ethr:volta:${payload.address}`);
}
const siwe = new SiweMessage(payload);
try {
await siwe.verify({
Expand Down Expand Up @@ -464,7 +470,6 @@ export class LoginStrategy extends BaseStrategy {
if (foundChainInfo) return did;

const didParts = did.split(':');

let chainName = 'volta';
if (
this.cacheServerClient?.isAvailable &&
Expand Down

0 comments on commit 6bb579a

Please sign in to comment.