From c103bdc2d2722700c8483d19e0fe06d6b9d7489b Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 26 Oct 2023 13:19:31 +0200 Subject: [PATCH 1/7] :pencil: Mint placeholder text --- src/components/pages/MintPOAP.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/pages/MintPOAP.jsx b/src/components/pages/MintPOAP.jsx index bc8304e..af00a99 100644 --- a/src/components/pages/MintPOAP.jsx +++ b/src/components/pages/MintPOAP.jsx @@ -92,7 +92,7 @@ export default function MintPOAP() {

Ready to mint your POAP

- set_address_to_mint_to( target.value ) } value={ address_to_mint_to } /> + set_address_to_mint_to( target.value ) } value={ address_to_mint_to } /> From 49c8e11cd69e44064392983bb98a5f4f47a08013 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 26 Oct 2023 15:25:50 +0200 Subject: [PATCH 2/7] :wrench: Validate on Email --- src/components/pages/MintPOAP.jsx | 13 ++++++++----- src/modules/validations.js | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/pages/MintPOAP.jsx b/src/components/pages/MintPOAP.jsx index af00a99..5efbdd9 100644 --- a/src/components/pages/MintPOAP.jsx +++ b/src/components/pages/MintPOAP.jsx @@ -8,7 +8,8 @@ import { log } from "../../modules/helpers" import Loading from "../molecules/Loading" import { mint_code_to_address } from "../../modules/firebase" import { useParams } from "react-router-dom" -import { eth_address_or_ens_regex } from "../../modules/validations" +import { eth_address_or_ens_regex, valid_email_regex } from "../../modules/validations" +import { serveToast } from '../molecules/Toast' export default function MintPOAP() { @@ -46,10 +47,11 @@ export default function MintPOAP() { log( `Minting POAP for ${ address_to_mint_to }` ) set_loading( `Minting your POAP` ) - // Validate address - if( !address_to_mint_to?.match( eth_address_or_ens_regex ) ) throw new Error( `Please input a valid address` ) + // Validate address based on address or email + if( !address_to_mint_to?.match( eth_address_or_ens_regex ) && !address_to_mint_to?.match( valid_email_regex ) ) { + throw new Error( 'Please input a valid Ethereum address/ENS or email address' ) + } - // Mint POAP const { data: { error } } = await mint_code_to_address( { claim_code, address_to_mint_to, challenge_code } ) if( error ) throw new Error( error ) @@ -59,7 +61,8 @@ export default function MintPOAP() { } catch ( e ) { log( `Error minting POAP for ${ address_to_mint_to }: `, e ) - alert( `${ e.message }` ) + serveToast( { message: `${ e.message }`, type: 'error' } ) + } finally { set_loading( false ) diff --git a/src/modules/validations.js b/src/modules/validations.js index b174122..b13dcb7 100644 --- a/src/modules/validations.js +++ b/src/modules/validations.js @@ -1 +1,2 @@ -export const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.eth)/i \ No newline at end of file +export const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.eth)/i +export const valid_email_regex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i From 0824b7e5f4c176b181191b42035e2ee04ec1d803 Mon Sep 17 00:00:00 2001 From: Mentor Date: Thu, 26 Oct 2023 15:43:42 +0200 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=90=9B=20fix=20regexes=20to=20allow?= =?UTF-8?q?=20for=20all=20TLDs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/modules/validations.js | 5 +++-- src/modules/validations.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/modules/validations.js b/functions/modules/validations.js index cd44c12..1db1cc2 100644 --- a/functions/modules/validations.js +++ b/functions/modules/validations.js @@ -17,7 +17,8 @@ exports.sanitise_email = input => { } -const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.eth)/i +// TLDs may be 1-63 characters long, see https://www.rfc-editor.org/rfc/rfc1034 +const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.*{1-63})/i exports.eth_address_or_ens_regex = eth_address_or_ens_regex exports.sanitise_address_or_ens = input => { @@ -64,4 +65,4 @@ exports.sanitise_poap_drop_secret_code = input => { exports.sanitise_string = string => `${ string }`.toLocaleLowerCase().trim() -exports.ens_address_regex = /(.*\.eth)/i \ No newline at end of file +exports.ens_address_regex = /(.*\..{1,63})/i \ No newline at end of file diff --git a/src/modules/validations.js b/src/modules/validations.js index b13dcb7..7fe4149 100644 --- a/src/modules/validations.js +++ b/src/modules/validations.js @@ -1,2 +1,5 @@ -export const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.eth)/i +// TLDs may be 1-63 characters long, see https://www.rfc-editor.org/rfc/rfc1034 +export const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.*{1-63})/i + +// Very naive regex validation for email addresses export const valid_email_regex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i From f5048325930b4d675649e5f08a543c55f24dccd6 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 26 Oct 2023 16:44:34 +0200 Subject: [PATCH 4/7] :wrench: Regex ens refactor --- functions/modules/validations.js | 2 +- src/modules/validations.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/modules/validations.js b/functions/modules/validations.js index 1db1cc2..ab06496 100644 --- a/functions/modules/validations.js +++ b/functions/modules/validations.js @@ -18,7 +18,7 @@ exports.sanitise_email = input => { } // TLDs may be 1-63 characters long, see https://www.rfc-editor.org/rfc/rfc1034 -const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.*{1-63})/i +const eth_address_or_ens_regex = /(0x[a-fA-F0-9]{40})|(.*\.[a-z]{2,63})/i exports.eth_address_or_ens_regex = eth_address_or_ens_regex exports.sanitise_address_or_ens = input => { diff --git a/src/modules/validations.js b/src/modules/validations.js index 7fe4149..245c6dc 100644 --- a/src/modules/validations.js +++ b/src/modules/validations.js @@ -1,5 +1,5 @@ // TLDs may be 1-63 characters long, see https://www.rfc-editor.org/rfc/rfc1034 -export const eth_address_or_ens_regex = /(0x[a-f0-9]{40})|(.*\.*{1-63})/i +export const eth_address_or_ens_regex = /(0x[a-fA-F0-9]{40})|(.*\.[a-z]{2,63})/i // Very naive regex validation for email addresses export const valid_email_regex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i From a9480af89d2fa59eb9116f15540fce47c2c47e2c Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Oct 2023 11:00:34 +0100 Subject: [PATCH 5/7] :boom: Deleting functions --- functions/index.js | 236 ++++++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/functions/index.js b/functions/index.js index 01a9508..dedfeec 100644 --- a/functions/index.js +++ b/functions/index.js @@ -1,119 +1,119 @@ -// V1 Dependencies -const functions = require( "firebase-functions" ) +// // V1 Dependencies +// const functions = require( "firebase-functions" ) -// V1 Runtime config -const generousRuntime = { - timeoutSeconds: 540, - memory: '4GB' -} - -const { log, dev } = require( './modules/helpers' ) -log( `⚠️ Verbose mode on, ${ dev ? '⚙️ dev mode on' : '🚀 production mode on' }` ) - -// Runtime config -const { v1_oncall, v2_oncall } = require( './runtime/on_call_runtimes' ) -const { v1_onrequest, v2_onrequest } = require( './runtime/on_request_runtimes' ) - -// /////////////////////////////// -// Code status managers -// /////////////////////////////// - -const { refreshScannedCodesStatuses, refresh_unknown_and_unscanned_codes, getEventDataFromCode, check_code_status } = require( './modules/codes' ) - -// Get event data of a code -exports.getEventDataFromCode = v1_oncall( getEventDataFromCode ) - -// Get all data of a code -exports.check_code_status = v1_oncall( check_code_status ) - -// Refresh all codes ( trigger from frontend on page mount of EventView ) -exports.requestManualCodeRefresh = v1_oncall( [ 'high_memory', 'long_timeout' ], refresh_unknown_and_unscanned_codes ) - -// Allow frontend to trigger updates for scanned codes, ( triggers on a periodic interval from EventView ), is lighter than requestManualCodeRefresh as it checks only scanned and claimed == true codes -exports.refreshScannedCodesStatuses = v1_oncall( [ 'high_memory', 'long_timeout' ], refreshScannedCodesStatuses ) - -// Directly mint a code to an address -const { mint_code_to_address } = require( './modules/minting' ) -exports.mint_code_to_address = v2_oncall( [ 'high_memory', 'long_timeout' ], mint_code_to_address ) - -// Let admins recalculate available codes -const { recalculate_available_codes_admin } = require( './modules/codes' ) -exports.recalculate_available_codes = v2_oncall( recalculate_available_codes_admin ) - -// /////////////////////////////// -// Event data -// /////////////////////////////// - -const { registerEvent, deleteEvent, getUniqueOrganiserEmails } = require( './modules/events' ) -exports.registerEvent = v1_oncall( [ 'high_memory', 'long_timeout' ], registerEvent ) -exports.deleteEvent = v1_oncall( deleteEvent ) - -// Email export to update event organisers -exports.getUniqueOrganiserEmails = v1_oncall( getUniqueOrganiserEmails ) - -// /////////////////////////////// -// QR Middleware API -// /////////////////////////////// -const claimMiddleware = require( './modules/claim' ) -exports.claimMiddleware = v2_onrequest( [ 'max_concurrency', 'keep_warm', 'memory' ], claimMiddleware ) - -/* /////////////////////////////// -// Kiosk generator middleware API -// /////////////////////////////*/ -const generate_kiosk = require( './modules/kiosk_generator' ) -exports.generate_kiosk = v1_onrequest( generate_kiosk ) - -// /////////////////////////////// -// Housekeeping -// /////////////////////////////// - -const { updateEventAvailableCodes } = require( './modules/codes' ) -const { delete_data_of_deleted_event, updatePublicEventData } = require( './modules/events' ) -const { clean_up_expired_items } = require( './modules/health' ) - -// Delete items where parents were deleted -exports.clean_up_expired_items = functions.runWith( generousRuntime ).pubsub.schedule( 'every 24 hours' ).onRun( clean_up_expired_items ) -exports.delete_data_of_deleted_event = functions.firestore.document( `events/{eventId}` ).onDelete( delete_data_of_deleted_event ) - -// Update items where parents were updated -exports.updatePublicEventData = functions.firestore.document( `events/{eventId}` ).onWrite( updatePublicEventData ) -exports.updateEventAvailableCodes = functions.firestore.document( `codes/{codeId}` ).onUpdate( updateEventAvailableCodes ) - - -/* /////////////////////////////// -// Security -// /////////////////////////////*/ -const { validateCallerDevice, validateCallerCaptcha } = require( './modules/security' ) -exports.validateCallerDevice = v2_oncall( [ 'high_memory', 'long_timeout', 'keep_warm' ], validateCallerDevice ) -exports.validateCallerCaptcha = v1_oncall( validateCallerCaptcha ) - -// Log kiosk opens -const { log_kiosk_open } = require( './modules/security' ) -exports.log_kiosk_open = v2_oncall( log_kiosk_open ) - -/* /////////////////////////////// -// Code claiming -// /////////////////////////////*/ -const { get_code_by_challenge } = require( './modules/codes' ) -exports.get_code_by_challenge = v1_oncall( get_code_by_challenge ) - -/* /////////////////////////////// -// Health check -// /////////////////////////////*/ -const { health_check, public_health_check } = require( './modules/health' ) -exports.health_check = v1_oncall( health_check ) -exports.ping = v2_oncall( [ 'max_concurrency' ],ping => 'pong' ) - -/* /////////////////////////////// -// Static QR system -// /////////////////////////////*/ -const { claim_code_by_email } = require( './modules/codes' ) -const { export_emails_of_static_drop, create_static_drop, update_public_static_drop_data, delete_emails_of_static_drop } = require( './modules/static_qr_drop' ) -exports.export_emails_of_static_drop = v1_oncall( export_emails_of_static_drop ) -exports.delete_emails_of_static_drop = v1_oncall( delete_emails_of_static_drop ) -exports.claim_code_by_email = v1_oncall( claim_code_by_email ) -exports.create_static_drop = v1_oncall( create_static_drop ) -exports.update_public_static_drop_data = functions.firestore.document( `static_drop_private/{drop_id}` ).onWrite( update_public_static_drop_data ) - -// Public health check -exports.public_health_check = v1_onrequest( public_health_check ) \ No newline at end of file +// // V1 Runtime config +// const generousRuntime = { +// timeoutSeconds: 540, +// memory: '4GB' +// } + +// const { log, dev } = require( './modules/helpers' ) +// log( `⚠️ Verbose mode on, ${ dev ? '⚙️ dev mode on' : '🚀 production mode on' }` ) + +// // Runtime config +// const { v1_oncall, v2_oncall } = require( './runtime/on_call_runtimes' ) +// const { v1_onrequest, v2_onrequest } = require( './runtime/on_request_runtimes' ) + +// // /////////////////////////////// +// // Code status managers +// // /////////////////////////////// + +// const { refreshScannedCodesStatuses, refresh_unknown_and_unscanned_codes, getEventDataFromCode, check_code_status } = require( './modules/codes' ) + +// // Get event data of a code +// exports.getEventDataFromCode = v1_oncall( getEventDataFromCode ) + +// // Get all data of a code +// exports.check_code_status = v1_oncall( check_code_status ) + +// // Refresh all codes ( trigger from frontend on page mount of EventView ) +// exports.requestManualCodeRefresh = v1_oncall( [ 'high_memory', 'long_timeout' ], refresh_unknown_and_unscanned_codes ) + +// // Allow frontend to trigger updates for scanned codes, ( triggers on a periodic interval from EventView ), is lighter than requestManualCodeRefresh as it checks only scanned and claimed == true codes +// exports.refreshScannedCodesStatuses = v1_oncall( [ 'high_memory', 'long_timeout' ], refreshScannedCodesStatuses ) + +// // Directly mint a code to an address +// const { mint_code_to_address } = require( './modules/minting' ) +// exports.mint_code_to_address = v2_oncall( [ 'high_memory', 'long_timeout' ], mint_code_to_address ) + +// // Let admins recalculate available codes +// const { recalculate_available_codes_admin } = require( './modules/codes' ) +// exports.recalculate_available_codes = v2_oncall( recalculate_available_codes_admin ) + +// // /////////////////////////////// +// // Event data +// // /////////////////////////////// + +// const { registerEvent, deleteEvent, getUniqueOrganiserEmails } = require( './modules/events' ) +// exports.registerEvent = v1_oncall( [ 'high_memory', 'long_timeout' ], registerEvent ) +// exports.deleteEvent = v1_oncall( deleteEvent ) + +// // Email export to update event organisers +// exports.getUniqueOrganiserEmails = v1_oncall( getUniqueOrganiserEmails ) + +// // /////////////////////////////// +// // QR Middleware API +// // /////////////////////////////// +// const claimMiddleware = require( './modules/claim' ) +// exports.claimMiddleware = v2_onrequest( [ 'max_concurrency', 'keep_warm', 'memory' ], claimMiddleware ) + +// /* /////////////////////////////// +// // Kiosk generator middleware API +// // /////////////////////////////*/ +// const generate_kiosk = require( './modules/kiosk_generator' ) +// exports.generate_kiosk = v1_onrequest( generate_kiosk ) + +// // /////////////////////////////// +// // Housekeeping +// // /////////////////////////////// + +// const { updateEventAvailableCodes } = require( './modules/codes' ) +// const { delete_data_of_deleted_event, updatePublicEventData } = require( './modules/events' ) +// const { clean_up_expired_items } = require( './modules/health' ) + +// // Delete items where parents were deleted +// exports.clean_up_expired_items = functions.runWith( generousRuntime ).pubsub.schedule( 'every 24 hours' ).onRun( clean_up_expired_items ) +// exports.delete_data_of_deleted_event = functions.firestore.document( `events/{eventId}` ).onDelete( delete_data_of_deleted_event ) + +// // Update items where parents were updated +// exports.updatePublicEventData = functions.firestore.document( `events/{eventId}` ).onWrite( updatePublicEventData ) +// exports.updateEventAvailableCodes = functions.firestore.document( `codes/{codeId}` ).onUpdate( updateEventAvailableCodes ) + + +// /* /////////////////////////////// +// // Security +// // /////////////////////////////*/ +// const { validateCallerDevice, validateCallerCaptcha } = require( './modules/security' ) +// exports.validateCallerDevice = v2_oncall( [ 'high_memory', 'long_timeout', 'keep_warm' ], validateCallerDevice ) +// exports.validateCallerCaptcha = v1_oncall( validateCallerCaptcha ) + +// // Log kiosk opens +// const { log_kiosk_open } = require( './modules/security' ) +// exports.log_kiosk_open = v2_oncall( log_kiosk_open ) + +// /* /////////////////////////////// +// // Code claiming +// // /////////////////////////////*/ +// const { get_code_by_challenge } = require( './modules/codes' ) +// exports.get_code_by_challenge = v1_oncall( get_code_by_challenge ) + +// /* /////////////////////////////// +// // Health check +// // /////////////////////////////*/ +// const { health_check, public_health_check } = require( './modules/health' ) +// exports.health_check = v1_oncall( health_check ) +// exports.ping = v2_oncall( [ 'max_concurrency' ],ping => 'pong' ) + +// /* /////////////////////////////// +// // Static QR system +// // /////////////////////////////*/ +// const { claim_code_by_email } = require( './modules/codes' ) +// const { export_emails_of_static_drop, create_static_drop, update_public_static_drop_data, delete_emails_of_static_drop } = require( './modules/static_qr_drop' ) +// exports.export_emails_of_static_drop = v1_oncall( export_emails_of_static_drop ) +// exports.delete_emails_of_static_drop = v1_oncall( delete_emails_of_static_drop ) +// exports.claim_code_by_email = v1_oncall( claim_code_by_email ) +// exports.create_static_drop = v1_oncall( create_static_drop ) +// exports.update_public_static_drop_data = functions.firestore.document( `static_drop_private/{drop_id}` ).onWrite( update_public_static_drop_data ) + +// // Public health check +// exports.public_health_check = v1_onrequest( public_health_check ) \ No newline at end of file From 749a615095ea9b827817d30cf03c915223b65b92 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Oct 2023 11:02:30 +0100 Subject: [PATCH 6/7] :pencil: Bring back functions --- functions/index.js | 236 ++++++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/functions/index.js b/functions/index.js index dedfeec..01a9508 100644 --- a/functions/index.js +++ b/functions/index.js @@ -1,119 +1,119 @@ -// // V1 Dependencies -// const functions = require( "firebase-functions" ) +// V1 Dependencies +const functions = require( "firebase-functions" ) -// // V1 Runtime config -// const generousRuntime = { -// timeoutSeconds: 540, -// memory: '4GB' -// } - -// const { log, dev } = require( './modules/helpers' ) -// log( `⚠️ Verbose mode on, ${ dev ? '⚙️ dev mode on' : '🚀 production mode on' }` ) - -// // Runtime config -// const { v1_oncall, v2_oncall } = require( './runtime/on_call_runtimes' ) -// const { v1_onrequest, v2_onrequest } = require( './runtime/on_request_runtimes' ) - -// // /////////////////////////////// -// // Code status managers -// // /////////////////////////////// - -// const { refreshScannedCodesStatuses, refresh_unknown_and_unscanned_codes, getEventDataFromCode, check_code_status } = require( './modules/codes' ) - -// // Get event data of a code -// exports.getEventDataFromCode = v1_oncall( getEventDataFromCode ) - -// // Get all data of a code -// exports.check_code_status = v1_oncall( check_code_status ) - -// // Refresh all codes ( trigger from frontend on page mount of EventView ) -// exports.requestManualCodeRefresh = v1_oncall( [ 'high_memory', 'long_timeout' ], refresh_unknown_and_unscanned_codes ) - -// // Allow frontend to trigger updates for scanned codes, ( triggers on a periodic interval from EventView ), is lighter than requestManualCodeRefresh as it checks only scanned and claimed == true codes -// exports.refreshScannedCodesStatuses = v1_oncall( [ 'high_memory', 'long_timeout' ], refreshScannedCodesStatuses ) - -// // Directly mint a code to an address -// const { mint_code_to_address } = require( './modules/minting' ) -// exports.mint_code_to_address = v2_oncall( [ 'high_memory', 'long_timeout' ], mint_code_to_address ) - -// // Let admins recalculate available codes -// const { recalculate_available_codes_admin } = require( './modules/codes' ) -// exports.recalculate_available_codes = v2_oncall( recalculate_available_codes_admin ) - -// // /////////////////////////////// -// // Event data -// // /////////////////////////////// - -// const { registerEvent, deleteEvent, getUniqueOrganiserEmails } = require( './modules/events' ) -// exports.registerEvent = v1_oncall( [ 'high_memory', 'long_timeout' ], registerEvent ) -// exports.deleteEvent = v1_oncall( deleteEvent ) - -// // Email export to update event organisers -// exports.getUniqueOrganiserEmails = v1_oncall( getUniqueOrganiserEmails ) - -// // /////////////////////////////// -// // QR Middleware API -// // /////////////////////////////// -// const claimMiddleware = require( './modules/claim' ) -// exports.claimMiddleware = v2_onrequest( [ 'max_concurrency', 'keep_warm', 'memory' ], claimMiddleware ) - -// /* /////////////////////////////// -// // Kiosk generator middleware API -// // /////////////////////////////*/ -// const generate_kiosk = require( './modules/kiosk_generator' ) -// exports.generate_kiosk = v1_onrequest( generate_kiosk ) - -// // /////////////////////////////// -// // Housekeeping -// // /////////////////////////////// - -// const { updateEventAvailableCodes } = require( './modules/codes' ) -// const { delete_data_of_deleted_event, updatePublicEventData } = require( './modules/events' ) -// const { clean_up_expired_items } = require( './modules/health' ) - -// // Delete items where parents were deleted -// exports.clean_up_expired_items = functions.runWith( generousRuntime ).pubsub.schedule( 'every 24 hours' ).onRun( clean_up_expired_items ) -// exports.delete_data_of_deleted_event = functions.firestore.document( `events/{eventId}` ).onDelete( delete_data_of_deleted_event ) - -// // Update items where parents were updated -// exports.updatePublicEventData = functions.firestore.document( `events/{eventId}` ).onWrite( updatePublicEventData ) -// exports.updateEventAvailableCodes = functions.firestore.document( `codes/{codeId}` ).onUpdate( updateEventAvailableCodes ) - - -// /* /////////////////////////////// -// // Security -// // /////////////////////////////*/ -// const { validateCallerDevice, validateCallerCaptcha } = require( './modules/security' ) -// exports.validateCallerDevice = v2_oncall( [ 'high_memory', 'long_timeout', 'keep_warm' ], validateCallerDevice ) -// exports.validateCallerCaptcha = v1_oncall( validateCallerCaptcha ) - -// // Log kiosk opens -// const { log_kiosk_open } = require( './modules/security' ) -// exports.log_kiosk_open = v2_oncall( log_kiosk_open ) - -// /* /////////////////////////////// -// // Code claiming -// // /////////////////////////////*/ -// const { get_code_by_challenge } = require( './modules/codes' ) -// exports.get_code_by_challenge = v1_oncall( get_code_by_challenge ) - -// /* /////////////////////////////// -// // Health check -// // /////////////////////////////*/ -// const { health_check, public_health_check } = require( './modules/health' ) -// exports.health_check = v1_oncall( health_check ) -// exports.ping = v2_oncall( [ 'max_concurrency' ],ping => 'pong' ) - -// /* /////////////////////////////// -// // Static QR system -// // /////////////////////////////*/ -// const { claim_code_by_email } = require( './modules/codes' ) -// const { export_emails_of_static_drop, create_static_drop, update_public_static_drop_data, delete_emails_of_static_drop } = require( './modules/static_qr_drop' ) -// exports.export_emails_of_static_drop = v1_oncall( export_emails_of_static_drop ) -// exports.delete_emails_of_static_drop = v1_oncall( delete_emails_of_static_drop ) -// exports.claim_code_by_email = v1_oncall( claim_code_by_email ) -// exports.create_static_drop = v1_oncall( create_static_drop ) -// exports.update_public_static_drop_data = functions.firestore.document( `static_drop_private/{drop_id}` ).onWrite( update_public_static_drop_data ) - -// // Public health check -// exports.public_health_check = v1_onrequest( public_health_check ) \ No newline at end of file +// V1 Runtime config +const generousRuntime = { + timeoutSeconds: 540, + memory: '4GB' +} + +const { log, dev } = require( './modules/helpers' ) +log( `⚠️ Verbose mode on, ${ dev ? '⚙️ dev mode on' : '🚀 production mode on' }` ) + +// Runtime config +const { v1_oncall, v2_oncall } = require( './runtime/on_call_runtimes' ) +const { v1_onrequest, v2_onrequest } = require( './runtime/on_request_runtimes' ) + +// /////////////////////////////// +// Code status managers +// /////////////////////////////// + +const { refreshScannedCodesStatuses, refresh_unknown_and_unscanned_codes, getEventDataFromCode, check_code_status } = require( './modules/codes' ) + +// Get event data of a code +exports.getEventDataFromCode = v1_oncall( getEventDataFromCode ) + +// Get all data of a code +exports.check_code_status = v1_oncall( check_code_status ) + +// Refresh all codes ( trigger from frontend on page mount of EventView ) +exports.requestManualCodeRefresh = v1_oncall( [ 'high_memory', 'long_timeout' ], refresh_unknown_and_unscanned_codes ) + +// Allow frontend to trigger updates for scanned codes, ( triggers on a periodic interval from EventView ), is lighter than requestManualCodeRefresh as it checks only scanned and claimed == true codes +exports.refreshScannedCodesStatuses = v1_oncall( [ 'high_memory', 'long_timeout' ], refreshScannedCodesStatuses ) + +// Directly mint a code to an address +const { mint_code_to_address } = require( './modules/minting' ) +exports.mint_code_to_address = v2_oncall( [ 'high_memory', 'long_timeout' ], mint_code_to_address ) + +// Let admins recalculate available codes +const { recalculate_available_codes_admin } = require( './modules/codes' ) +exports.recalculate_available_codes = v2_oncall( recalculate_available_codes_admin ) + +// /////////////////////////////// +// Event data +// /////////////////////////////// + +const { registerEvent, deleteEvent, getUniqueOrganiserEmails } = require( './modules/events' ) +exports.registerEvent = v1_oncall( [ 'high_memory', 'long_timeout' ], registerEvent ) +exports.deleteEvent = v1_oncall( deleteEvent ) + +// Email export to update event organisers +exports.getUniqueOrganiserEmails = v1_oncall( getUniqueOrganiserEmails ) + +// /////////////////////////////// +// QR Middleware API +// /////////////////////////////// +const claimMiddleware = require( './modules/claim' ) +exports.claimMiddleware = v2_onrequest( [ 'max_concurrency', 'keep_warm', 'memory' ], claimMiddleware ) + +/* /////////////////////////////// +// Kiosk generator middleware API +// /////////////////////////////*/ +const generate_kiosk = require( './modules/kiosk_generator' ) +exports.generate_kiosk = v1_onrequest( generate_kiosk ) + +// /////////////////////////////// +// Housekeeping +// /////////////////////////////// + +const { updateEventAvailableCodes } = require( './modules/codes' ) +const { delete_data_of_deleted_event, updatePublicEventData } = require( './modules/events' ) +const { clean_up_expired_items } = require( './modules/health' ) + +// Delete items where parents were deleted +exports.clean_up_expired_items = functions.runWith( generousRuntime ).pubsub.schedule( 'every 24 hours' ).onRun( clean_up_expired_items ) +exports.delete_data_of_deleted_event = functions.firestore.document( `events/{eventId}` ).onDelete( delete_data_of_deleted_event ) + +// Update items where parents were updated +exports.updatePublicEventData = functions.firestore.document( `events/{eventId}` ).onWrite( updatePublicEventData ) +exports.updateEventAvailableCodes = functions.firestore.document( `codes/{codeId}` ).onUpdate( updateEventAvailableCodes ) + + +/* /////////////////////////////// +// Security +// /////////////////////////////*/ +const { validateCallerDevice, validateCallerCaptcha } = require( './modules/security' ) +exports.validateCallerDevice = v2_oncall( [ 'high_memory', 'long_timeout', 'keep_warm' ], validateCallerDevice ) +exports.validateCallerCaptcha = v1_oncall( validateCallerCaptcha ) + +// Log kiosk opens +const { log_kiosk_open } = require( './modules/security' ) +exports.log_kiosk_open = v2_oncall( log_kiosk_open ) + +/* /////////////////////////////// +// Code claiming +// /////////////////////////////*/ +const { get_code_by_challenge } = require( './modules/codes' ) +exports.get_code_by_challenge = v1_oncall( get_code_by_challenge ) + +/* /////////////////////////////// +// Health check +// /////////////////////////////*/ +const { health_check, public_health_check } = require( './modules/health' ) +exports.health_check = v1_oncall( health_check ) +exports.ping = v2_oncall( [ 'max_concurrency' ],ping => 'pong' ) + +/* /////////////////////////////// +// Static QR system +// /////////////////////////////*/ +const { claim_code_by_email } = require( './modules/codes' ) +const { export_emails_of_static_drop, create_static_drop, update_public_static_drop_data, delete_emails_of_static_drop } = require( './modules/static_qr_drop' ) +exports.export_emails_of_static_drop = v1_oncall( export_emails_of_static_drop ) +exports.delete_emails_of_static_drop = v1_oncall( delete_emails_of_static_drop ) +exports.claim_code_by_email = v1_oncall( claim_code_by_email ) +exports.create_static_drop = v1_oncall( create_static_drop ) +exports.update_public_static_drop_data = functions.firestore.document( `static_drop_private/{drop_id}` ).onWrite( update_public_static_drop_data ) + +// Public health check +exports.public_health_check = v1_onrequest( public_health_check ) \ No newline at end of file From ee4c232791d2025af2691c8ee9b9e8c4f048914f Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Oct 2023 13:10:09 +0100 Subject: [PATCH 7/7] :pencil: corrections UI --- public/locales/en/translation.json | 4 ++-- src/components/molecules/MethodCard.jsx | 2 +- src/components/molecules/ModalSide.jsx | 4 ++-- src/components/pages/EventAdmin.jsx | 5 ++--- src/components/pages/MintPOAP.jsx | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index efb36d2..0992fab 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -245,7 +245,7 @@ "confirmDeleteDispenser": "Are you sure you want to delete your POAP Kiosk?\n\nThis cannot be undone, but you can always create a new POAP Kiosk following the same simple steps you used to make this one.", "succesDeleteDispenser": "Deletion success!\n\nYour POAP Kiosk has been deleted.", "deletionCancelled": "Deletion cancelled, your event still exists.", - "errorDeleteDispenser": "Error Deleting POAP Kiosk: {{ message }}", + "errorDeleteDispenser": "Error Deleting POAP Kiosk: {{ message }}.", "amountScannedMessage": "Your POAP Kiosk QR was scanned {{ scans }} times and {{ claimed }} out of {{ codes }} POAPs were claimed.", "editActions": { "editHeading": "Admin actions", @@ -256,7 +256,7 @@ "confirmRecalculate": "During the recalculation process, your POAP Kiosk will be unstable and might not work as expected.\n\nAre you sure you want to recalculate?", "recalculationCancelled": "Recalculation was cancelled, nothing changed", "recalculationSuccess": "Recalculation succeeded, your POAP Kiosk should be working as expected again.", - "recalculating": "Recalculating the amount of codes available for this Kiosk", + "recalculating": "Recalculating the amount of codes available for this Kiosk.", "hero": { "subheading": { "reviewed": "⚠️ Your event is being reviewed", diff --git a/src/components/molecules/MethodCard.jsx b/src/components/molecules/MethodCard.jsx index 3fc2e21..125bfa3 100644 --- a/src/components/molecules/MethodCard.jsx +++ b/src/components/molecules/MethodCard.jsx @@ -193,7 +193,7 @@ export const MethodCard = ( { event, eventLink, adminLink, onDelete, onRecalcula return - + diff --git a/src/components/molecules/ModalSide.jsx b/src/components/molecules/ModalSide.jsx index 8374df7..dc37a99 100644 --- a/src/components/molecules/ModalSide.jsx +++ b/src/components/molecules/ModalSide.jsx @@ -29,11 +29,10 @@ export const StyledModal = styled( ReactModal )` align-items: center; justify-content: flex-end; overflow: scroll; - /* padding: var(--spacing-3); */ ` const Modal = styled( Section )` - padding: 2rem 1rem; + padding: 5rem 2rem 1rem 2rem; display: flex; flex-direction: column; height: 100%; @@ -41,6 +40,7 @@ const Modal = styled( Section )` max-width: 450px; background: white; box-shadow: 0px 0 5px 2px rgba( 0, 0, 0, .1); + border-left: 1px solid var(--primary-700); ` export default ( { children, open = true, showClose = false, setIsOpen, ...props } ) => { diff --git a/src/components/pages/EventAdmin.jsx b/src/components/pages/EventAdmin.jsx index 9349277..81eb52a 100644 --- a/src/components/pages/EventAdmin.jsx +++ b/src/components/pages/EventAdmin.jsx @@ -47,7 +47,6 @@ const ModalButtonContainer = styled.div` flex-direction: row; justify-content: center; gap: 1rem; - margin-top: 1rem; ` // /////////////////////////////// @@ -249,7 +248,7 @@ export default function EventAdmin( ) { Are you sure you want to refresh the mint link counter? Your POAP Kiosk will be unstable and might not work as expected. - + @@ -267,7 +266,7 @@ export default function EventAdmin( ) { Are you sure you want to delete this kiosk? You can create a new kiosk for this POAP after deletion. - + diff --git a/src/components/pages/MintPOAP.jsx b/src/components/pages/MintPOAP.jsx index 5efbdd9..122677f 100644 --- a/src/components/pages/MintPOAP.jsx +++ b/src/components/pages/MintPOAP.jsx @@ -49,7 +49,7 @@ export default function MintPOAP() { // Validate address based on address or email if( !address_to_mint_to?.match( eth_address_or_ens_regex ) && !address_to_mint_to?.match( valid_email_regex ) ) { - throw new Error( 'Please input a valid Ethereum address/ENS or email address' ) + throw new Error( 'Please input a valid Ethereum address/ENS or email address.' ) } const { data: { error } } = await mint_code_to_address( { claim_code, address_to_mint_to, challenge_code } )