Skip to content

Commit

Permalink
feat: add mirror working with corrected logic
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Mar 13, 2024
1 parent 65890dd commit 6204175
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 179 deletions.
43 changes: 24 additions & 19 deletions src/handles/datalayer.handles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ export async function mountDatalayerRpcHandles() {
};
}

const totalTransactionWithUsageFee =
addMirrorParams.amount + parseInt(addMirrorParams.fee) + xchToMojos(fixedFeeXch);
if (getWalletBalanceResponse?.wallet_balance?.spendable_balance > totalTransactionWithUsageFee){
sendFixedFee(network, spendableCoins.confirmed_records.length);
}

await new Promise(ignore => setTimeout(ignore, 1000));

const addMirrorPromise = datalayer.addMirror(addMirrorParams, {
...options,
waitForWalletAvailability: false,
includeFee: false
});

const totalTransactionWithUsageFee = parseInt(addMirrorParams.fee) + xchToMojos(fixedFeeXch);

const addMirrorResult = await addMirrorPromise;
if (addMirrorResult?.success &&
(getWalletBalanceResponse?.wallet_balance?.spendable_balance > totalTransactionWithUsageFee)){
sendFixedFee(network, spendableCoins.confirmed_records.length);
}

console.log('#######', addMirrorPromise);
return addMirrorPromise;
});

Expand Down Expand Up @@ -126,17 +126,17 @@ export async function mountDatalayerRpcHandles() {
};
}

const createStorePromise = datalayer.createDataStore(createDataStoreParams, {
...options,
waitForWalletAvailability: false
});

const createStoreResult = await createStorePromise;
if (createStoreResult?.success){
const totalTransactionWithUsageFee = parseInt(createDataStoreParams.fee) + xchToMojos(fixedFeeXch);
if (getWalletBalanceResponse?.wallet_balance?.spendable_balance > totalTransactionWithUsageFee){
sendFixedFee(network, spendableCoins.confirmed_records.length);
}

return createStorePromise;
setTimeout(() => {
return datalayer.createDataStore(createDataStoreParams, {
...options,
waitForWalletAvailability: false,
includeFee: false
});
}, 1000);
},
);

Expand Down Expand Up @@ -169,7 +169,12 @@ export async function mountDatalayerRpcHandles() {
};
}

return datalayer.deleteMirror(deleteMirrorParams, options);
console.log('********', deleteMirrorParams)
return datalayer.deleteMirror(deleteMirrorParams, {
...options,
waitForWalletAvailability: false,
includeFee: false
});
});

ipcMain.handle('datalayerGetKeys', (_, getKeysParams: GetKeysParams, options: Options) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/renderer/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './ipc';
export * from './getUserIp';
export * from './datalayerStorage';
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from "react";
import { Modal } from "flowbite-react";
import {FormattedMessage} from "react-intl";

interface AddSubscriptionErrorModalProps {
interface AddMirrorErrorModalProps {
showModal: boolean;
setShowModal: (showModal: boolean) => void;
errorMessage?: string;
}

const AddMirrorErrorModal: React.FC<AddSubscriptionErrorModalProps> = (
{ showModal, setShowModal, errorMessage}: AddSubscriptionErrorModalProps) => {
const AddMirrorErrorModal: React.FC<AddMirrorErrorModalProps> = (
{ showModal, setShowModal, errorMessage}: AddMirrorErrorModalProps) => {

return (
<Modal show={showModal} onClose={() => setShowModal(false)}>
Expand All @@ -20,16 +20,16 @@ const AddMirrorErrorModal: React.FC<AddSubscriptionErrorModalProps> = (
<div className="space-y-6">
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400">
{
errorMessage || <FormattedMessage id="error-occurred-while-adding-mirror"/>
errorMessage || <FormattedMessage id="an-error-occurred-while-adding-the-mirror"/>
}
</p>
<div className="space-y-2">
<div className="space-y-1">
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400">
<FormattedMessage id={'confirm-entered-store-id-is-correct-and-references-a-valid-store'}/>
</p>
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400">
<FormattedMessage id="ensure-chia-services-are-running-and-accessible"/>
</p>
</p>
</div>
</div>
</Modal.Body>
Expand Down
Loading

0 comments on commit 6204175

Please sign in to comment.