-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
175 additions
and
57 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/components/Organisms/AddressTransactions/AddressTransactions.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type Meta, type StoryObj } from "@storybook/react"; | ||
import { AddressTransactions as AddressTransactionsComponent } from "./AddressTransactions"; | ||
|
||
type Story = StoryObj<typeof AddressTransactionsComponent>; | ||
|
||
const meta: Meta<typeof AddressTransactionsComponent> = { | ||
title: "Organisms/Address Transactions", | ||
component: AddressTransactionsComponent, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const AddressTransactions: Story = { | ||
args: { | ||
chain_name: "eth-mainnet", | ||
address: "0x972B8FAD70de6e430D8b368198AbFF1E42eFf022", | ||
}, | ||
}; |
51 changes: 51 additions & 0 deletions
51
src/components/Organisms/AddressTransactions/AddressTransactions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { type Option, None, Some } from "@/utils/option"; | ||
import { type Transaction } from "@covalenthq/client-sdk"; | ||
import { useEffect, useState } from "react"; | ||
import { type AddressTransactionsProps } from "@/utils/types/molecules.types"; | ||
import { Transactions } from "@/components/Shared"; | ||
import { useGoldRush } from "@/utils/store"; | ||
|
||
export const AddressTransactions: React.FC<AddressTransactionsProps> = ({ | ||
chain_name, | ||
address, | ||
...props | ||
}) => { | ||
const { covalentClient } = useGoldRush(); | ||
|
||
const [maybeResult, setResult] = useState<Option<Transaction[]>>(None); | ||
const [errorMessage, setErrorMessage] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
setResult(None); | ||
setErrorMessage(null); | ||
try { | ||
const { data, ...error } = | ||
await covalentClient.TransactionService.getAllTransactionsForAddressByPage( | ||
chain_name, | ||
address.trim(), | ||
{ | ||
noLogs: true, | ||
withSafe: false, | ||
quoteCurrency: "USD", | ||
} | ||
); | ||
if (error.error) { | ||
setErrorMessage(error.error_message); | ||
throw error; | ||
} | ||
setResult(new Some(data.items)); | ||
} catch (exception) { | ||
console.error(exception); | ||
} | ||
})(); | ||
}, [chain_name, address]); | ||
|
||
return ( | ||
<Transactions | ||
{...props} | ||
errorMessage={errorMessage} | ||
maybeResult={maybeResult} | ||
/> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
src/components/Organisms/BlockTransactions/BlockTransactions.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type Meta, type StoryObj } from "@storybook/react"; | ||
import { BlockTransactions as BlockTransactionsComponent } from "./BlockTransactions"; | ||
|
||
type Story = StoryObj<typeof BlockTransactionsComponent>; | ||
|
||
const meta: Meta<typeof BlockTransactionsComponent> = { | ||
title: "Organisms/Block Transactions", | ||
component: BlockTransactionsComponent, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const BlockTransactions: Story = { | ||
args: { | ||
chain_name: "eth-mainnet", | ||
block_height: 19575410, | ||
}, | ||
}; |
51 changes: 51 additions & 0 deletions
51
src/components/Organisms/BlockTransactions/BlockTransactions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { type Option, None, Some } from "@/utils/option"; | ||
import { type Transaction } from "@covalenthq/client-sdk"; | ||
import { useEffect, useState } from "react"; | ||
import { type BlockTransactionsProps } from "@/utils/types/molecules.types"; | ||
import { Transactions } from "@/components/Shared"; | ||
import { useGoldRush } from "@/utils/store"; | ||
|
||
export const BlockTransactions: React.FC<BlockTransactionsProps> = ({ | ||
chain_name, | ||
block_height, | ||
...props | ||
}) => { | ||
const { covalentClient } = useGoldRush(); | ||
|
||
const [maybeResult, setResult] = useState<Option<Transaction[]>>(None); | ||
const [errorMessage, setErrorMessage] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
setResult(None); | ||
setErrorMessage(null); | ||
try { | ||
const { data, ...error } = | ||
await covalentClient.TransactionService.getTransactionsForBlock( | ||
chain_name, | ||
block_height, | ||
{ | ||
noLogs: true, | ||
withSafe: false, | ||
quoteCurrency: "USD", | ||
} | ||
); | ||
if (error.error) { | ||
setErrorMessage(error.error_message); | ||
throw error; | ||
} | ||
setResult(new Some(data.items)); | ||
} catch (exception) { | ||
console.error(exception); | ||
} | ||
})(); | ||
}, [chain_name, block_height]); | ||
|
||
return ( | ||
<Transactions | ||
{...props} | ||
errorMessage={errorMessage} | ||
maybeResult={maybeResult} | ||
/> | ||
); | ||
}; |
18 changes: 0 additions & 18 deletions
18
src/components/Organisms/TransactionsList/TransactionsList.stories.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as BalancePriceDelta } from "./BalancePriceDelta"; | ||
export { default as CopyImage } from "./CopyImage"; | ||
export { default as IconWrapper } from "./IconWrapper"; | ||
export { default as Transactions } from "./Transactions"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters