Skip to content

Commit

Permalink
feat: modify getvault and getallvaults function contract, update mino…
Browse files Browse the repository at this point in the history
…r visuals
  • Loading branch information
Polybius93 committed Apr 8, 2024
1 parent 8ea87b9 commit 00ccbf8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ interface FlowPropertyMap {

const flowPropertyMap: FlowPropertyMap = {
mint: {
2: { title: 'a) Locking BTC in progress', subtitle: 'Minting dlcBTC' },
3: { title: 'Minted dlcBTC' },
3: { title: 'a) Locking BTC in progress', subtitle: 'Minting dlcBTC' },
4: { title: 'Minted dlcBTC' },
},
unmint: {
1: {
Expand Down Expand Up @@ -50,7 +50,7 @@ export function TransactionSummary({
const currentVault = allVaults.find(vault => vault.uuid === currentStep[1]);

const showProcessing =
(flow === 'mint' && currentStep[0] === 2) || (flow === 'unmint' && currentStep[0] === 1);
(flow === 'mint' && currentStep[0] === 3) || (flow === 'unmint' && currentStep[0] === 1);

return (
<VStack alignItems={'start'} w={'300px'} spacing={'15px'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function SuccessfulFlowModal({
return (
<ModalLayout title={'Success!'} isOpen={isOpen} onClose={() => handleClose()}>
<TransactionSummary
currentStep={[flow === 'mint' ? 3 : 2, vaultUUID]}
currentStep={[flow === 'mint' ? 4 : 2, vaultUUID]}
flow={flow}
blockchain={'ethereum'}
handleClose={() => handleClose()}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/proof-of-reserve/proof-of-reserve.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function ProofOfReserve(): React.JSX.Element {
return (
<ProofOfReserveLayout>
<Text w={'100%'} px={'35px'} color={'white'} fontSize={'4xl'} fontWeight={600}>
My Vaults
Proof of Reserve
</Text>
<TokenStatsBoardLayout>
<TokenStatsBoardTVL totalSupply={totalSupply} bitcoinPrice={bitcoinPrice} />
Expand Down
19 changes: 11 additions & 8 deletions src/app/hooks/use-ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function throwEthereumError(message: string, error: any): void {

export function useEthereum(): UseEthereumReturnType {
const { vaults } = useContext(VaultContext);
const { protocolContract, dlcBTCContract } = useEthereumContext();
const { protocolContract, dlcBTCContract, observerProtocolContract } = useEthereumContext();

const { address, network } = useSelector((state: RootState) => state.account);

Expand Down Expand Up @@ -127,9 +127,9 @@ export function useEthereum(): UseEthereumReturnType {

async function getAllVaults(): Promise<void> {
try {
if (!protocolContract) throw new Error('Protocol contract not initialized');
await protocolContract.callStatic.getAllVaultsForAddress(address);
const vaults: RawVault[] = await protocolContract.getAllVaultsForAddress(address);
if (!observerProtocolContract) throw new Error('Protocol contract not initialized');
await observerProtocolContract.callStatic.getAllVaultsForAddress(address);
const vaults: RawVault[] = await observerProtocolContract.getAllVaultsForAddress(address);
const formattedVaults: Vault[] = vaults.map(formatVault);
if (!network) return;
store.dispatch(
Expand All @@ -151,8 +151,8 @@ export function useEthereum(): UseEthereumReturnType {
): Promise<void> {
for (let i = 0; i < maxRetries; i++) {
try {
if (!protocolContract) throw new Error('Protocol contract not initialized');
const vault: RawVault = await protocolContract.getVault(vaultUUID);
if (!observerProtocolContract) throw new Error('Protocol contract not initialized');
const vault: RawVault = await observerProtocolContract.getVault(vaultUUID);
if (!vault) throw new Error('Vault is undefined');
if (vault.status !== vaultState) throw new Error('Vault is not in the correct state');
const formattedVault: Vault = formatVault(vault);
Expand All @@ -177,8 +177,11 @@ export function useEthereum(): UseEthereumReturnType {
async function getAllFundedVaults(ethereumNetwork: EthereumNetwork): Promise<RawVault[]> {
try {
const dlcManagerContract = await getDefaultProvider(ethereumNetwork, 'DLCManager');
const vaults: RawVault[] = await dlcManagerContract.getFundedDLCs(0, 1000000);
return vaults;
const vaults: RawVault[] = await dlcManagerContract.getFundedDLCs(0, 10000);
const filteredVaults = vaults.filter(
vault => vault.uuid != '0x0000000000000000000000000000000000000000000000000000000000000000'
);
return filteredVaults;
} catch (error) {
throw new EthereumError(`Could not fetch Funded Vaults: ${error}`);
}
Expand Down

0 comments on commit 00ccbf8

Please sign in to comment.