Skip to content

Commit

Permalink
fix: store did key addresses in the default SS58 format used by the k…
Browse files Browse the repository at this point in the history
…eyring

bump migration script to run on version 2.0.2 or earlier
  • Loading branch information
F-OBrien authored and adamdossa committed Aug 28, 2024
1 parent dfb8ba2 commit 7f1425a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ const initApiPromise = (network: NetworkName, networkUrl: string) =>
};
}

const isSecKeyAdded = identityStateData[did].secKeys.includes(encodeAddress(account, api.registry.chainSS58));
const isMsKeyAdded = identityStateData[did].msKeys.includes(encodeAddress(account, api.registry.chainSS58));
const isSecKeyAdded = identityStateData[did].secKeys.includes(encodeAddress(account));
const isMsKeyAdded = identityStateData[did].msKeys.includes(encodeAddress(account));

if (isPrimary) {
identityStateData[did].priKey = encodeAddress(account, api.registry.chainSS58);
identityStateData[did].priKey = encodeAddress(account);
} else if (isSecondary && !isSecKeyAdded) {
identityStateData[did].secKeys = [...identityStateData[did].secKeys, encodeAddress(account, api.registry.chainSS58)];
identityStateData[did].secKeys = [...identityStateData[did].secKeys, encodeAddress(account)];
} else if (isMultiSig && !isMsKeyAdded) {
identityStateData[did].msKeys = [...identityStateData[did].msKeys, encodeAddress(account, api.registry.chainSS58)];
identityStateData[did].msKeys = [...identityStateData[did].msKeys, encodeAddress(account)];
}

const claimData = await api.query.identity.claims.entries(
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/src/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function isVersionEarlierOrEqual (version: string, compareTo: string): boolean {
return true;
}

// Run the migration applicable to version 1.8.3 or earlier
// Run the migration applicable to version 2.0.2 or earlier
async function runMigrations () {
const migrate = new AccountMigrations();

Expand All @@ -33,8 +33,8 @@ export async function checkForUpdateAndMigrate (details: chrome.runtime.Installe
if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
const previousVersion = details.previousVersion;

// Migrate Account Prefixes. Runs when no lastVersion or a previous version of 1.8.3 or earlier
if (previousVersion && isVersionEarlierOrEqual(previousVersion, '1.8.3')) {
// Migrate Account Prefixes. Runs when no lastVersion or a previous version of 2.0.2 or earlier
if (previousVersion && isVersionEarlierOrEqual(previousVersion, '2.0.2')) {
await runMigrations();
}
}
Expand Down

0 comments on commit 7f1425a

Please sign in to comment.