From 81dc8ed867eec4e6ddcde92ff810f78afc5917f8 Mon Sep 17 00:00:00 2001 From: findolor Date: Mon, 15 Aug 2022 11:50:15 +0300 Subject: [PATCH] Refactor for prod build --- components/AnchorButton.tsx | 2 -- components/Button.tsx | 1 - components/MetadataModal.tsx | 3 +-- pages/collections/create.tsx | 2 +- services/s3.ts | 21 --------------------- utils/csvToArray.ts | 31 ------------------------------- 6 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 services/s3.ts delete mode 100644 utils/csvToArray.ts diff --git a/components/AnchorButton.tsx b/components/AnchorButton.tsx index f1a5b0e..09d2999 100644 --- a/components/AnchorButton.tsx +++ b/components/AnchorButton.tsx @@ -34,5 +34,3 @@ export const AnchorButton = (props: AnchorButtonProps) => { ) } - -export default AnchorButton diff --git a/components/Button.tsx b/components/Button.tsx index ecba0e9..da9dcfc 100644 --- a/components/Button.tsx +++ b/components/Button.tsx @@ -39,4 +39,3 @@ export const Button = (props: ButtonProps) => { ) } -export default Button diff --git a/components/MetadataModal.tsx b/components/MetadataModal.tsx index 66d2670..d9a99ab 100644 --- a/components/MetadataModal.tsx +++ b/components/MetadataModal.tsx @@ -6,7 +6,7 @@ import { useMetadataAttributesState } from 'components/forms/MetadataAttributes. import { useEffect, useState } from 'react' import toast from 'react-hot-toast' -import Button from './Button' +import { Button } from './Button' import { TextInput } from './forms/FormInput' import { useInputState } from './forms/FormInput.hooks' import { MetadataAttributes } from './forms/MetadataAttributes' @@ -22,7 +22,6 @@ export interface MetadataModalProps { export const MetadataModal = (props: MetadataModalProps) => { const metadataFile: File = props.metadataFile const [metadata, setMetadata] = useState(null) - const [imageURL, setImageURL] = useState('') let parsedMetadata: any const parseMetadata = async () => { diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index e5f9045..b6a283a 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -5,7 +5,7 @@ import { coin } from '@cosmjs/proto-signing' import { Alert } from 'components/Alert' import { Anchor } from 'components/Anchor' -import Button from 'components/Button' +import { Button } from 'components/Button' import { CollectionDetails, MintingDetails, diff --git a/services/s3.ts b/services/s3.ts deleted file mode 100644 index 7f4eecd..0000000 --- a/services/s3.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { PutObjectCommand, S3 } from '@aws-sdk/client-s3' -import { S3_BUCKET, S3_ENDPOINT, S3_KEY, S3_REGION, S3_SECRET } from 'utils/constants' - -const PARAMS = { - Bucket: S3_BUCKET, - ACL: 'private', -} - -const s3Client = new S3({ - endpoint: S3_ENDPOINT, - region: S3_REGION, - credentials: { - accessKeyId: S3_KEY, - secretAccessKey: S3_SECRET, - }, -}) - -export const uploadObject = async (key: string, body: string) => { - const data = await s3Client.send(new PutObjectCommand({ ...PARAMS, Key: key, Body: body })) - return data -} diff --git a/utils/csvToArray.ts b/utils/csvToArray.ts deleted file mode 100644 index 6a719cc..0000000 --- a/utils/csvToArray.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { AccountProps } from './isValidAccountsFile' - -export const csvToArray = (str: string, delimiter = ',') => { - let newline = '\n' - if (str.includes('\r')) newline = '\r' - if (str.includes('\r\n')) newline = '\r\n' - - const headers = str.slice(0, str.indexOf(newline)).split(delimiter) - if (headers.length !== 2) { - throw new Error('Invalid accounts file') - } - if (headers[0] !== 'address' || headers[1] !== 'amount') { - throw new Error('Invalid accounts file') - } - - const rows = str.slice(str.indexOf('\n') + 1).split(newline) - - const arr = rows - .filter((row) => row !== '') - .map((row) => { - const values = row.split(delimiter) - const el = headers.reduce((object, header, index) => { - // @ts-expect-error assume object as Record - object[header] = values[index] - return object - }, {}) - return el - }) - - return arr as AccountProps[] -}