From b0c711efad61aaa5d2596bbee1d30fb6dab71d05 Mon Sep 17 00:00:00 2001 From: wwills2 Date: Thu, 22 Feb 2024 16:00:37 -0500 Subject: [PATCH] feat: blockchain and usage fees are now concurrent --- src/handles/datalayer.handles.ts | 9 ++++++--- src/utils/fees.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/handles/datalayer.handles.ts b/src/handles/datalayer.handles.ts index ab5e2ea..9bcfef9 100644 --- a/src/handles/datalayer.handles.ts +++ b/src/handles/datalayer.handles.ts @@ -27,7 +27,7 @@ import DataLayer, { } from 'chia-datalayer'; import Wallet, {SpendableCoinRequest} from 'chia-wallet'; -import {sendConstFee} from "../utils/fees.js"; +import {sendFixedFee} from "../utils/fees.js"; export async function mountDatalayerRpcHandles() { const datalayer = new DataLayer({verbose: true}); @@ -67,9 +67,12 @@ export async function mountDatalayerRpcHandles() { // ensure that the user has at least 2 coins: 1 for the usage fee and 1 for the datastore fee if (spendableCoins.confirmed_records.length > 0) { - sendConstFee(network, spendableCoins.confirmed_records.length); + sendFixedFee(network, spendableCoins.confirmed_records.length); setTimeout(() => { - return datalayer.createDataStore(createDataStoreParams, options); + return datalayer.createDataStore(createDataStoreParams, { + ...options, + waitForWalletAvailability: false + }); }, 1000); } else { return { diff --git a/src/utils/fees.ts b/src/utils/fees.ts index f091d72..aae85da 100644 --- a/src/utils/fees.ts +++ b/src/utils/fees.ts @@ -5,7 +5,7 @@ const stdFeeXch = 0.01; const feePer100MbXch = 0.01; const walletAddress: string = 'xch1djjwc54ax3gz4n5fthkt5q4nhgerlx8e5n92435gr3scdsxrcf6sh55z5w'; -export const sendConstFee = (network: string, numSpendableCoins: number) => { +export const sendFixedFee = (network: string, numSpendableCoins: number) => { const wallet = new Wallet({verbose: true}); // if the user has 2 spendable coins, send the usage fee