-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: acl addresses must be stored in lowercases for permissions (#290)
- Loading branch information
1 parent
cdbdaf5
commit 8f0bdaf
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/migrations/0014_permissions_set_addresses_lowercase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Migration, MigratorComponents, PermissionType } from '../types' | ||
import SQL from 'sql-template-strings' | ||
|
||
export const migration: Migration = { | ||
id: '0014_permissions_set_addresses_lowercase', | ||
run: async (components: Pick<MigratorComponents, 'database' | 'nameOwnership' | 'storage' | 'worldsManager'>) => { | ||
const worlds = await components.database.query('SELECT name, permissions FROM worlds ORDER BY name') | ||
|
||
for (const world of worlds.rows) { | ||
const permissions = world.permissions | ||
for (const permissionType of Object.keys(permissions)) { | ||
const permission = permissions[permissionType] | ||
if (permission.type === PermissionType.AllowList) { | ||
permission.wallets = permission.wallets.map((address: string) => address.toLowerCase()) | ||
} | ||
} | ||
|
||
await components.database.query(SQL` | ||
UPDATE worlds | ||
SET permissions = ${JSON.stringify(permissions)}::json | ||
WHERE name = ${world.name}`) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters