Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuripetusko authored and github-actions[bot] committed Jan 17, 2024
1 parent 65e686c commit f0b78b3
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 69 deletions.
18 changes: 9 additions & 9 deletions packages/ipfs-utils/src/lib/get-ipfs-cid.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { expect, test } from "vitest";
import { getIpfsCidFromGatewayUrl } from "./get-ipfs-cid.js";
import { expect, test } from 'vitest';
import { getIpfsCidFromGatewayUrl } from './get-ipfs-cid.js';

test("getIpfsCidFromGatewayUrl", async () => {
test('getIpfsCidFromGatewayUrl', async () => {
expect(
getIpfsCidFromGatewayUrl("https://cloudflare-ipfs.com/ipfs/foo")
).to.not.eq("bar");
getIpfsCidFromGatewayUrl('https://cloudflare-ipfs.com/ipfs/foo'),
).to.not.eq('bar');

expect(
getIpfsCidFromGatewayUrl("https://cloudflare-ipfs.com/ipfs/foo")
).to.eq("foo");
getIpfsCidFromGatewayUrl('https://cloudflare-ipfs.com/ipfs/foo'),
).to.eq('foo');

expect(
getIpfsCidFromGatewayUrl("https://cloudflare-ipfs.com/ipfs/foo/bar")
).to.eq("foo/bar");
getIpfsCidFromGatewayUrl('https://cloudflare-ipfs.com/ipfs/foo/bar'),
).to.eq('foo/bar');
});
4 changes: 2 additions & 2 deletions packages/ipfs-utils/src/lib/ipfs.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect, test } from 'vitest';
import {
DEFAULT_IPFS_GATEWAY_KEYS,
DEFAULT_IPFS_GATEWAY_URLS,
containsCID,
convertToDesiredGateway,
sanitizeIpfsUrl,
DEFAULT_IPFS_GATEWAY_KEYS,
DEFAULT_IPFS_GATEWAY_URLS,
} from './ipfs.js';

test('containsCID', async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/ipfs-utils/src/lib/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export const containsCID = (ipfsUrl?: string | null) => {

export const convertToDesiredGateway = (
ipfsUrl?: string | null,
gatewayPrefixovider = DEFAULT_IPFS_GATEWAY_URLS[DEFAULT_IPFS_GATEWAY_KEYS.pinata],
gatewayPrefixovider = DEFAULT_IPFS_GATEWAY_URLS[
DEFAULT_IPFS_GATEWAY_KEYS.pinata
],
) => {
const results = containsCID(ipfsUrl);
if (!ipfsUrl || results.containsCid !== true || !results.cid) {
Expand Down
8 changes: 4 additions & 4 deletions packages/nft-renderer/panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { defineConfig } from "@pandacss/dev";
import { defineConfig } from '@pandacss/dev';

export default defineConfig({
// Whether to use css reset
preflight: true,
prefix: 'rmrk-nft-renderer',

// Where to look for your css declarations
include: ["./src/**/*.{js,jsx,ts,tsx}"],
include: ['./src/**/*.{js,jsx,ts,tsx}'],

// Files to exclude
exclude: [],
Expand All @@ -17,6 +17,6 @@ export default defineConfig({
},

// The output directory for your css system
outdir: "styled-system",
jsxFramework: "react",
outdir: 'styled-system',
jsxFramework: 'react',
});
2 changes: 1 addition & 1 deletion packages/nft-renderer/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module.exports = {
plugins: {
'@pandacss/dev/postcss': {},
},
}
};
60 changes: 30 additions & 30 deletions packages/nft-renderer/src/components/nft-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import "../styles/index.css";
import { MultiLayer2DRenderer } from "@rmrk-team/rmrk-2d-renderer";
import { MultiLayer2DRenderer } from '@rmrk-team/rmrk-2d-renderer';
import {
RMRKEquippableImpl,
mapChainIdToNetwork,
} from "@rmrk-team/rmrk-evm-utils";
} from '@rmrk-team/rmrk-evm-utils';
import {
useFetchIpfsMetadata,
useGetAssetData,
useGetComposedState,
useGetInterfaceSupport,
} from "@rmrk-team/rmrk-hooks";
import React, { useEffect, useRef, useState } from "react";
import { isAddress } from "viem";
import type { Address } from "viem";
import { usePublicClient, useReadContract } from "wagmi";
import type { Chain } from "wagmi/chains";
import type { RenderPart } from "../types/types.js";
} from '@rmrk-team/rmrk-hooks';
import React, { useEffect, useRef, useState } from 'react';
import { css } from 'styled-system/css';
import { isAddress } from 'viem';
import type { Address } from 'viem';
import { usePublicClient, useReadContract } from 'wagmi';
import type { Chain } from 'wagmi/chains';
import '../styles/index.css';
import type { RenderPart } from '../types/types.js';
// import { sanitizeIpfsUrl } from '../lib/ipfs';
import { Providers } from "./providers.js";
import { css } from "styled-system/css";
import { Providers } from './providers.js';

interface INFTRenderer {
chainId: Chain["id"];
chainId: Chain['id'];
contractAddress: Address;
tokenId: bigint;
advancedMode?: boolean;
Expand Down Expand Up @@ -82,7 +82,7 @@ export function NFTRenderer({
interfaceSupport: { supports721, supportsEquippable, supportsMultiAsset },
} = useGetInterfaceSupport(
{ contractAddress, chainId },
{ enabled: isContract }
{ enabled: isContract },
);

const {
Expand All @@ -92,7 +92,7 @@ export function NFTRenderer({
} = useReadContract({
address: contractAddress,
abi: RMRKEquippableImpl,
functionName: "tokenURI",
functionName: 'tokenURI',
args: [tokenIdBigint],
chainId,
query: { enabled: isContract && supports721 },
Expand Down Expand Up @@ -123,7 +123,7 @@ export function NFTRenderer({
supportsEquippableInterface: supportsEquippable,
supportsMultiAssetInterface: supportsMultiAsset,
},
{ enabled: isContract }
{ enabled: isContract },
);

const {
Expand All @@ -139,11 +139,11 @@ export function NFTRenderer({
? [
...fixedPartsWithMetadatas.map((p) => ({
z: p.z,
src: p.metadata?.mediaUri || "",
src: p.metadata?.mediaUri || '',
})),
...slotPartsWithMetadatas.map((p) => ({
z: p.z,
src: p.metadata?.mediaUri || "",
src: p.metadata?.mediaUri || '',
})),
]
: undefined;
Expand All @@ -155,13 +155,13 @@ export function NFTRenderer({
src:
primaryAsset?.metadata?.mediaUri ||
primaryAsset?.metadata?.image ||
"",
'',
},
]
: undefined;

const tokenRenderPart: RenderPart[] | undefined = primaryAsset
? [{ z: 1, src: tokenMetadata?.mediaUri || tokenMetadata?.image || "" }]
? [{ z: 1, src: tokenMetadata?.mediaUri || tokenMetadata?.image || '' }]
: undefined;

const renderParts = catalogRenderParts || assetRenderPart || tokenRenderPart;
Expand Down Expand Up @@ -203,17 +203,17 @@ export function NFTRenderer({
<div
ref={rendererContainerRef}
className={css({
width: "100%",
height: "100%",
position: "relative",
display: "flex",
justifyContent: "center",
width: '100%',
height: '100%',
position: 'relative',
display: 'flex',
justifyContent: 'center',
})}
>
{isLoading ? (
<div
className={css({
alignSelf: "center",
alignSelf: 'center',
})}
>
{loader}
Expand Down Expand Up @@ -254,10 +254,10 @@ export function NFTRenderer({
fillBgWithImageBlur
loader={loader}
className={css({
aspectRatio: "1/1",
objectFit: "contain",
width: "100%",
height: "100%",
aspectRatio: '1/1',
objectFit: 'contain',
width: '100%',
height: '100%',
})}
/>
) : null}
Expand Down
8 changes: 4 additions & 4 deletions packages/rmrk-2d-renderer/panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { defineConfig } from "@pandacss/dev";
import { defineConfig } from '@pandacss/dev';

export default defineConfig({
// Whether to use css reset
preflight: true,
prefix: 'rmrk-2d-renderer',

// Where to look for your css declarations
include: ["./src/**/*.{js,jsx,ts,tsx}"],
include: ['./src/**/*.{js,jsx,ts,tsx}'],

// Files to exclude
exclude: [],
Expand All @@ -17,6 +17,6 @@ export default defineConfig({
},

// The output directory for your css system
outdir: "styled-system",
jsxFramework: "react",
outdir: 'styled-system',
jsxFramework: 'react',
});
2 changes: 1 addition & 1 deletion packages/rmrk-2d-renderer/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module.exports = {
plugins: {
'@pandacss/dev/postcss': {},
},
}
};
2 changes: 1 addition & 1 deletion packages/rmrk-2d-renderer/src/lib/rmrk-2d-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import type { ICanvas } from 'pixi.js';
import type { CSSProperties } from 'react';
import React, { useEffect, useMemo } from 'react';
import { useCallback, useState } from 'react';
import { css, cx } from 'styled-system/css';
import useImage from 'use-image';
import { Skeleton } from '../ui/skeleton.js';
import { INHERIT_RENDER_CONTEXT } from './consts.js';
import { css, cx } from 'styled-system/css';

const useObserveElementDimensions = (ref?: React.RefObject<HTMLDivElement>) => {
const [width, setWidth] = useState(0);
Expand Down
13 changes: 8 additions & 5 deletions packages/rmrk-evm-utils/src/lib/chain-mapping.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { expect, test } from 'vitest';
import {EVM_NETWORKS, mapEvmNetworkToSupportedChain} from "./chain-mapping.js";
import {base, mainnet} from "wagmi/chains";
import { base, mainnet } from 'wagmi/chains';
import {
EVM_NETWORKS,
mapEvmNetworkToSupportedChain,
} from './chain-mapping.js';

test('mapEvmNetworkToSupportedChain', async () => {
expect(mapEvmNetworkToSupportedChain(EVM_NETWORKS.base)).not.toBe(mainnet);
expect(mapEvmNetworkToSupportedChain(EVM_NETWORKS.base)).toBe(base);
})
expect(mapEvmNetworkToSupportedChain(EVM_NETWORKS.base)).not.toBe(mainnet);
expect(mapEvmNetworkToSupportedChain(EVM_NETWORKS.base)).toBe(base);
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect, test } from 'vitest';
import { base, mainnet } from 'wagmi/chains';
import { EVM_NETWORKS, mapChainIdToNetwork } from './chain-mapping.js';
import { getChainIdByNetworkName } from './get-chain-id-by-network-name.js';
import {EVM_NETWORKS, mapChainIdToNetwork} from './chain-mapping.js';
import {base, mainnet} from 'wagmi/chains';

test('getChainIdByNetworkName', async () => {
expect(getChainIdByNetworkName(EVM_NETWORKS.base)).toBe(base.id);
expect(getChainIdByNetworkName('foo')).toBe(undefined);
});

test('mapChainIdToNetwork', async () => {
expect(mapChainIdToNetwork(base.id)).toBe(EVM_NETWORKS.base);
expect(mapChainIdToNetwork(mainnet.id)).not.toBe(EVM_NETWORKS.base);
expect(mapChainIdToNetwork(base.id)).toBe(EVM_NETWORKS.base);
expect(mapChainIdToNetwork(mainnet.id)).not.toBe(EVM_NETWORKS.base);
});
2 changes: 1 addition & 1 deletion packages/rmrk-evm-utils/src/lib/get-is-evm-network.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest';
import { getIsEvmNetwork } from './get-is-evm-network.js';
import { EVM_NETWORKS } from './chain-mapping.js';
import { getIsEvmNetwork } from './get-is-evm-network.js';

test('getIsEvmNetwork', async () => {
expect(getIsEvmNetwork('foo')).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest';
import { getIsExpectedNetwork } from './get-is-expected-network.js';
import { EVM_NETWORKS } from './chain-mapping.js';
import { getIsExpectedNetwork } from './get-is-expected-network.js';

test('getIsExpectedNetwork', async () => {
expect(getIsExpectedNetwork('ethereum', [EVM_NETWORKS.base])).toBe(false);
Expand Down
6 changes: 1 addition & 5 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ export default defineConfig({
test: {
coverage: {
reporter: process.env.CI ? ['lcov'] : ['text', 'json', 'html'],
exclude: [
'**/dist/**',
'**/*.test.ts',
'**/*.test-d.ts'
],
exclude: ['**/dist/**', '**/*.test.ts', '**/*.test-d.ts'],
},
// globalSetup: ['./packages/test/src/globalSetup.ts'],
// setupFiles: ['./packages/test/src/setup.ts'],
Expand Down

0 comments on commit f0b78b3

Please sign in to comment.