Skip to content

Commit feb0add

Browse files
committed
address feedback
1 parent 88c7859 commit feb0add

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

app/scripts/migrations/160.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe(`migration #${version}`, () => {
2828
expect(newStorage.meta).toStrictEqual({ version });
2929
});
3030

31-
it('adds the `endowment:caip25` permission with the current globally selected chainId (and no accounts) permissioned to Snaps with the `endowment:ethereum-provider` permission and which do not already a `endowment:caip25` permission', async () => {
31+
it('adds the `endowment:caip25` permission with the current globally selected chainId (and no accounts) permissioned to Snaps with the `endowment:ethereum-provider` permission and which do not already have a `endowment:caip25` permission', async () => {
3232
const oldStorage = {
3333
meta: { version: oldVersion },
3434
data: {

app/scripts/migrations/160.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,10 @@ function transformState(state: Record<string, unknown>) {
211211
let caip25PermissionCaveatWithCurrentChainIdAndAccountsSet =
212212
caip25PermissionCaveatWithCurrentChainIdSet;
213213

214-
if (subject.permissions[Caip25EndowmentPermissionName]) {
215-
const existingCaveat = subject.permissions[
216-
Caip25EndowmentPermissionName
217-
]?.caveats?.find((caveat) => caveat.type === Caip25CaveatType);
218-
if (existingCaveat && existingCaveat.value) {
219-
const alreadyPermissionedAccounts = getEthAccounts(
220-
existingCaveat.value as Caip25CaveatValue,
221-
);
214+
const existingCaveat = getExistingCaip25PermissionCaveat(subject);
215+
if (existingCaveat) {
216+
const alreadyPermissionedAccounts = getEthAccounts(existingCaveat);
217+
if (alreadyPermissionedAccounts) {
222218
caip25PermissionCaveatWithCurrentChainIdAndAccountsSet = setEthAccounts(
223219
caip25PermissionCaveatWithCurrentChainIdSet,
224220
alreadyPermissionedAccounts,

0 commit comments

Comments
 (0)