Skip to content

Commit

Permalink
feat: blockchain and usage fees are now concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Feb 22, 2024
1 parent 10e6af0 commit b0c711e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/handles/datalayer.handles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b0c711e

Please sign in to comment.