Skip to content

Commit

Permalink
refactor: Improve API service architecture and add copyright notices
Browse files Browse the repository at this point in the history
- Refactored ExplorerService to use centralized Polkadot API connection
- Added proper dependency injection with tsyringe
- Implemented singleton pattern for API services
- Added copyright notices to all source files
- Fixed connection state management
- Improved error handling

Contributes to #5
  • Loading branch information
carloskiron committed Mar 3, 2025
1 parent 645b76c commit 7b89bef
Show file tree
Hide file tree
Showing 56 changed files with 1,587 additions and 367 deletions.
16 changes: 16 additions & 0 deletions src/app/application-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use client'
import { Avatar } from '@/components/avatar'
import { BlockHeaders } from '@/components/etf/latestBlocks'
Expand Down
26 changes: 26 additions & 0 deletions src/app/client-layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client';

import '@/styles/tailwind.css';
import { Inter } from 'next/font/google';
import { ConnectedWalletProvider } from '@/components/etf/connectedWalletContext';
import { PolkadotProvider } from '@/contexts/PolkadotContext';
import { ApplicationLayout } from './application-layout';
import { DIProvider } from '@/components/providers/di-provider';

const inter = Inter({ subsets: ['latin'] });

export function ClientLayout({ children }: { children: React.ReactNode }) {
return (
<body className={inter.className}>
<DIProvider>
<PolkadotProvider>
<ConnectedWalletProvider>
<ApplicationLayout>
{children}
</ApplicationLayout>
</ConnectedWalletProvider>
</PolkadotProvider>
</DIProvider>
</body>
);
}
18 changes: 17 additions & 1 deletion src/app/compose/[...id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use client'

import { Badge } from '@/components/badge'
Expand Down Expand Up @@ -87,4 +103,4 @@ export default function ExecutedTransaction({ params }: { readonly params: { rea
</div>
</div> : <div>Loading...</div>
);
}
}
18 changes: 17 additions & 1 deletion src/app/compose/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use client'

import { Badge } from '@/components/badge'
Expand All @@ -13,7 +29,7 @@ import { NUMBER_BLOCKS_EXECUTED, useConnectedWallet } from '@/components/etf/con
import { ConnectWallet } from '@/components/etf/connectWallet'
import { useState } from 'react'
import { ExclamationTriangleIcon, XCircleIcon } from '@heroicons/react/20/solid'
import { explorerClient } from '../explorerClient'
import { explorerClient } from '@/lib/explorer-client';

interface LatestError {
index: number;
Expand Down
18 changes: 17 additions & 1 deletion src/app/compose/schedule/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use client'

import { Button } from '@/components/button'
Expand All @@ -15,7 +31,7 @@ import { useState } from 'react'
import { DelayedTransactionDetails } from '@/domain/DelayedTransactionDetails'
import { XCircleIcon } from '@heroicons/react/20/solid'
import { useRouter } from 'next/navigation'
import { explorerClient } from '@/app/explorerClient'
import { explorerClient } from '@/lib/explorer-client'

const FUTURE_BLOCK_DEFAULT_START: number = 100;

Expand Down
18 changes: 0 additions & 18 deletions src/app/explorerClient.ts

This file was deleted.

22 changes: 18 additions & 4 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import '@/styles/tailwind.css'
import type { Metadata } from 'next'
import type React from 'react'
import { ApplicationLayout } from './application-layout'
import { ClientLayout } from './client-layout'

export const metadata: Metadata = {
title: {
Expand All @@ -23,9 +39,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
</head>
<body>
<ApplicationLayout>
{children}
</ApplicationLayout>
<ClientLayout>{children}</ClientLayout>
</body>
</html>
)
Expand Down
16 changes: 16 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use client'

import { Badge } from '@/components/badge'
Expand Down
16 changes: 16 additions & 0 deletions src/components/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as Headless from '@headlessui/react'
import clsx from 'clsx'
import type React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions src/components/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as Headless from '@headlessui/react'
import clsx from 'clsx'
import React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions src/components/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as Headless from '@headlessui/react'
import clsx from 'clsx'
import React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as Headless from '@headlessui/react'
import { clsx } from 'clsx'
import React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions src/components/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as Headless from '@headlessui/react'
import { clsx } from 'clsx'
import type React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions src/components/description-list.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import clsx from 'clsx'

export function DescriptionList({ className, ...props }: React.ComponentPropsWithoutRef<'dl'>) {
Expand Down
16 changes: 16 additions & 0 deletions src/components/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as Headless from '@headlessui/react'
import clsx from 'clsx'
import type React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions src/components/divider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import clsx from 'clsx'

export function Divider({
Expand Down
16 changes: 16 additions & 0 deletions src/components/dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2025 by Ideal Labs, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use client'

import * as Headless from '@headlessui/react'
Expand Down
Loading

0 comments on commit 7b89bef

Please sign in to comment.