Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
borispoehland committed Aug 7, 2024
1 parent 4b92a15 commit 58f1a12
Show file tree
Hide file tree
Showing 43 changed files with 2,418 additions and 2,290 deletions.
34 changes: 17 additions & 17 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off"
},
"env": {
"node": true,
"es6": true
}
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/consistent-type-imports": "error"
},
"env": {
"node": true,
"es6": true
}
}
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

25 changes: 25 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const config = {
trailingComma: 'es5',
tabWidth: 2,
semi: false,
singleQuote: true,
importOrder: [
'^(react/(.*)$)|^(react$)',
'^(next/(.*)$)|^(next$)',
'',
'<THIRD_PARTY_MODULES>',
'',
'^@/(.*)$',
'',
'^[./]',
],
importOrderSeparation: false,
importOrderSortSpecifiers: true,
importOrderBuiltinModulesToTop: true,
importOrderMergeDuplicateImports: true,
plugins: [
'@ianvs/prettier-plugin-sort-imports',
],
}

export default config
186 changes: 144 additions & 42 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"build:esm": "webpack --config webpack-esm.config.mjs",
"build:cjs": "webpack --config webpack-cjs.config.mjs",
"build": "npm run build:types && npm run build:esm && npm run build:cjs",
"lint": "eslint 'src/**/*.ts' --fix",
"format": "prettier --write 'src/**/*.ts'",
"lint": "eslint 'src/**/*.{ts,tsx}' --fix",
"format": "prettier --write 'src/**/*.{ts,tsx}'",
"commit": "git-cz",
"release": "semantic-release",
"docs": "typedoc --out docs src/**/*.ts"
Expand Down Expand Up @@ -74,8 +74,10 @@
},
"homepage": "https://github.com/XOXNO/sdk-js#readme",
"devDependencies": {
"@aws-sdk/client-ses": "^3.624.0",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@swc/cli": "^0.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/client-email.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './client-email/post-email';
export * from './client-email/post-email'
15 changes: 8 additions & 7 deletions src/client-email/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Heading, Img, Link, Text } from '@react-email/components';
import React, { type ComponentProps } from 'react';
import React, { type ComponentProps } from 'react'

import type { Components } from 'react-markdown';
import ReactMarkdown from 'react-markdown';
import { bodyStyle, headingStyle, linkStyle } from '../email/utils';
import { Heading, Img, Link, Text } from '@react-email/components'
import ReactMarkdown from 'react-markdown'
import type { Components } from 'react-markdown'

import { bodyStyle, headingStyle, linkStyle } from '../email/utils'

const MarkdownComponents: Partial<Components> = {
h1: ({ children }) => (
Expand Down Expand Up @@ -48,8 +49,8 @@ const MarkdownComponents: Partial<Components> = {
),
img: (props) => <Img {...props} width="100%" className="rounded-lg" />,
a: (props) => <Link style={linkStyle} {...props} />,
};
}

export function Markdown(props: ComponentProps<typeof ReactMarkdown>) {
return <ReactMarkdown components={MarkdownComponents} {...props} />;
return <ReactMarkdown components={MarkdownComponents} {...props} />
}
50 changes: 24 additions & 26 deletions src/client-email/post-email.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement, type ComponentProps } from 'react';
import React, { createElement, type ComponentProps } from 'react'

import {
Body,
Expand All @@ -7,23 +7,21 @@ import {
Link,
Section,
Text,
} from '@react-email/components';
import { createTranslator } from 'next-intl';
} from '@react-email/components'
import { createTranslator } from 'next-intl'

import React from 'react';
import { Markdown } from './Markdown';
import type { IHost, Translations } from '../email/utils'
import {
Center,
GeneralEmail,
IHost,
MEDIA,
Translations,
bodyStyle,
Center,
defaultHost,
GeneralEmail,
getHost,
linkStyle,
MEDIA,
renderGenericEmail,
} from '../email/utils';
} from '../email/utils'
import { Markdown } from './Markdown'

const translations = {
namespace: '',
Expand All @@ -41,18 +39,18 @@ const translations = {
},
},
},
} as const satisfies Translations;
} as const satisfies Translations

type IProps = {
host?: IHost;
subject: string;
message: string;
host?: IHost
subject: string
message: string
style?: {
backgroundColor: string;
};
};
backgroundColor: string
}
}

const messages = translations.translations.en;
const messages = translations.translations.en

const PostEmail = ({
host = defaultHost,
Expand All @@ -64,9 +62,9 @@ const PostEmail = ({
locale: 'en',
messages,
namespace: 'post',
});
})

const HOST = getHost(host);
const HOST = getHost(host)

return (
<GeneralEmail title={subject}>
Expand Down Expand Up @@ -112,13 +110,13 @@ const PostEmail = ({
</Container>
</Body>
</GeneralEmail>
);
};
)
}

export const renderPostEmail = async (
props: ComponentProps<typeof PostEmail>
) => {
const Email = createElement(PostEmail, props, null);
const Email = createElement(PostEmail, props, null)

return renderGenericEmail(Email);
};
return renderGenericEmail(Email)
}
71 changes: 36 additions & 35 deletions src/collection/__tests__/collection.test.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
import { CollectionModule, XOXNOClient } from '../../index';
import { AuctionTypes, FieldsToSelect, SearchNFTsResponse } from '../../types';
import { CollectionModule, XOXNOClient } from '../../index'
import type { SearchNFTsResponse } from '../../types'
import { AuctionTypes, FieldsToSelect } from '../../types'

describe('CollectionModule', () => {
let collectionModule: CollectionModule;
const inputCollection = 'BANANA-e955fd';
let collectionModule: CollectionModule
const inputCollection = 'BANANA-e955fd'
beforeAll(() => {
XOXNOClient.init();
collectionModule = new CollectionModule();
});
XOXNOClient.init()
collectionModule = new CollectionModule()
})

beforeEach(async () => {
return new Promise((resolve) => setTimeout(resolve, 1000));
});
return new Promise((resolve) => setTimeout(resolve, 1000))
})

test('getCollectionProfile should return the correct result', async () => {
const collectionModule = new CollectionModule();
const result = await collectionModule.getCollectionProfile(inputCollection);
expect(result.collection).toEqual(inputCollection);
});
const collectionModule = new CollectionModule()
const result = await collectionModule.getCollectionProfile(inputCollection)
expect(result.collection).toEqual(inputCollection)
})

test('getCollectionProfiles should return the correct results', async () => {
const collectionModule = new CollectionModule();
const result = await collectionModule.getCollections();
expect(result).toBeDefined();
expect(result.results).toHaveLength(25);
});
const collectionModule = new CollectionModule()
const result = await collectionModule.getCollections()
expect(result).toBeDefined()
expect(result.results).toHaveLength(25)
})

it('should get the floor price of a collection', async () => {
const floorPrice =
await collectionModule.getCollectionFloorPrice(inputCollection);
expect(floorPrice).toBeLessThan(1);
});
await collectionModule.getCollectionFloorPrice(inputCollection)
expect(floorPrice).toBeLessThan(1)
})

it('should get the collection attributes', async () => {
const attributesInfo =
await collectionModule.getCollectionAttributes(inputCollection);
await collectionModule.getCollectionAttributes(inputCollection)
expect(attributesInfo).toMatchObject({
Accessorie: {
Dollars: {
attributeOccurrence: 260,
},
},
});
});
})
})

it('should get the collection trading activity', async () => {
const tradingActivity = await collectionModule.getTradingActivity({
collections: [inputCollection],
top: 1,
});
})
expect(tradingActivity).toMatchObject({
getNextPagePayload: {
top: 1,
skip: 1,
collections: [inputCollection],
},
});
})

const tradingActivitySecondPage = await collectionModule.getTradingActivity(
tradingActivity.getNextPagePayload
);
)
expect(tradingActivitySecondPage).toMatchObject({
getNextPagePayload: {
top: 1,
skip: 2,
collections: [inputCollection],
},
});
});
})
})

it('should get fetch and filter NFTs from a collection', async () => {
const nfts: SearchNFTsResponse = await collectionModule.getNFTs({
Expand All @@ -84,22 +85,22 @@ describe('CollectionModule', () => {
FieldsToSelect.Royalties,
FieldsToSelect.Collection,
],
});
})
expect(nfts).toMatchObject({
getNextPagePayload: {
top: 1,
skip: 1,
},
});
})

const nftsSecondPage = await collectionModule.getNFTs(
nfts.getNextPagePayload
);
)
expect(nftsSecondPage).toMatchObject({
getNextPagePayload: {
top: 1,
skip: 2,
},
});
});
});
})
})
})
Loading

0 comments on commit 58f1a12

Please sign in to comment.