From fa64304a1905e3edb7dde6d7a044ffb2fc65b998 Mon Sep 17 00:00:00 2001 From: Camillo C Date: Mon, 6 Dec 2021 12:12:55 +0100 Subject: [PATCH] add DEFAULT_NEWORK in .env.example and use it in settings.ts (#210) * added DEFAULT_NEWORK param in .env.example and settings.ts * improved example * Update .env.example Co-authored-by: Fabien --- .env.example | 1 + src/writer/settings.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index d9c73e98..fe704e99 100644 --- a/.env.example +++ b/.env.example @@ -15,3 +15,4 @@ SERVICE_PUSH_NOTIFICATIONS=0 SERVICE_PUSHER_BEAMS_INSTANCE_ID= SERVICE_PUSHER_BEAMS_SECRET_KEY= SNAPSHOT_URI=http://localhost:3000 +DEFAULT_NETWORK=1 diff --git a/src/writer/settings.ts b/src/writer/settings.ts index b65f97ee..8b11543e 100644 --- a/src/writer/settings.ts +++ b/src/writer/settings.ts @@ -4,6 +4,8 @@ import { storeSettings } from '../helpers/adapters/mysql'; import { jsonParse } from '../helpers/utils'; import { spaces } from '../helpers/spaces'; +const DEFAULT_NETWORK = process.env.DEFAULT_NETWORK || '1'; + export async function verify(body): Promise { const msg = jsonParse(body.msg); @@ -16,7 +18,7 @@ export async function verify(body): Promise { return Promise.reject('wrong space format'); } - const spaceUri = await snapshot.utils.getSpaceUri(msg.space); + const spaceUri = await snapshot.utils.getSpaceUri(msg.space, DEFAULT_NETWORK); const isOwner = spaceUri.includes(body.address); const admins = (spaces[msg.space]?.admins || []).map(admin => admin.toLowerCase()