diff --git a/README.md b/README.md index 50a1f1b3..c38cc995 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ considered compromised.** If you want to test services on mainnet with this tool, make sure to create a new account and fund it with the minimum assets required. +Note, that dy default base fee is 100 stroops. That may not be enough for mainnet application, and base fee can be changed via `REACT_APP_BASE_FEE` environment variable + ## Getting A Test Account Up and Running You can use the demo wallet to interact with the following anchor services: diff --git a/packages/demo-wallet-client/src/ducks/claimAsset.ts b/packages/demo-wallet-client/src/ducks/claimAsset.ts index 121e9f4e..a318619e 100644 --- a/packages/demo-wallet-client/src/ducks/claimAsset.ts +++ b/packages/demo-wallet-client/src/ducks/claimAsset.ts @@ -1,5 +1,4 @@ import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; -import { BASE_FEE } from "stellar-sdk"; import { RootState } from "config/store"; import { accountSelector } from "ducks/account"; import { getErrorMessage } from "demo-wallet-shared/build/helpers/getErrorMessage"; @@ -65,7 +64,7 @@ export const claimAssetAction = createAsyncThunk< assetCode, networkPassphrase: networkConfig.network, networkUrl: networkConfig.url, - fee: BASE_FEE, + fee: networkConfig.baseFee, }); return { result, trustedAssetAdded }; diff --git a/packages/demo-wallet-shared/helpers/getNetworkConfig.ts b/packages/demo-wallet-shared/helpers/getNetworkConfig.ts index 56db059f..4cefad83 100644 --- a/packages/demo-wallet-shared/helpers/getNetworkConfig.ts +++ b/packages/demo-wallet-shared/helpers/getNetworkConfig.ts @@ -1,8 +1,9 @@ -import { Networks } from "stellar-sdk"; +import {Networks, BASE_FEE} from "stellar-sdk"; export const getNetworkConfig = () => { return { network: window._env_.HORIZON_PASSPHRASE || Networks.TESTNET, url: window._env_.HORIZON_URL || "https://horizon-testnet.stellar.org", + baseFee: process?.env?.REACT_APP_BASE_FEE || BASE_FEE, }; }; diff --git a/packages/demo-wallet-shared/methods/sep24/pollWithdrawUntilComplete.ts b/packages/demo-wallet-shared/methods/sep24/pollWithdrawUntilComplete.ts index 05cf9ec9..e1f9f6da 100644 --- a/packages/demo-wallet-shared/methods/sep24/pollWithdrawUntilComplete.ts +++ b/packages/demo-wallet-shared/methods/sep24/pollWithdrawUntilComplete.ts @@ -1,7 +1,6 @@ import { Account, Asset, - BASE_FEE, Keypair, Operation, Horizon, @@ -10,6 +9,7 @@ import { import { log } from "../../helpers/log"; import { createMemoFromType } from "../createMemoFromType"; import { TransactionStatus } from "../../types/types"; +import {getNetworkConfig} from "../../helpers/getNetworkConfig"; export const pollWithdrawUntilComplete = async ({ secretKey, @@ -93,7 +93,7 @@ export const pollWithdrawUntilComplete = async ({ const account = new Account(keypair.publicKey(), sequence); const txn = new TransactionBuilder(account, { - fee: BASE_FEE, + fee: getNetworkConfig().baseFee, networkPassphrase, }) .addOperation( diff --git a/packages/demo-wallet-shared/methods/sep31Send/sendPayment.ts b/packages/demo-wallet-shared/methods/sep31Send/sendPayment.ts index 37d8f55c..f5969cdf 100644 --- a/packages/demo-wallet-shared/methods/sep31Send/sendPayment.ts +++ b/packages/demo-wallet-shared/methods/sep31Send/sendPayment.ts @@ -2,7 +2,6 @@ import { getCatchError } from "@stellar/frontend-helpers"; import { Account, Asset, - BASE_FEE, Keypair, Memo, Operation, @@ -11,6 +10,7 @@ import { } from "stellar-sdk"; import { log } from "../../helpers/log"; import { MemoTypeString } from "../../types/types"; +import {getNetworkConfig} from "../../helpers/getNetworkConfig"; interface SendPaymentProps { secretKey: string; @@ -100,7 +100,7 @@ export const sendPayment = async ({ } const tx = new TransactionBuilder(new Account(publicKey, sequence), { - fee: (Number(BASE_FEE) * 5).toString(), + fee: (Number(getNetworkConfig().baseFee) * 5).toString(), networkPassphrase, }) .addOperation( diff --git a/packages/demo-wallet-shared/methods/sep6/pollWithdrawUntilComplete.ts b/packages/demo-wallet-shared/methods/sep6/pollWithdrawUntilComplete.ts index 04cdc2cb..62b5602b 100644 --- a/packages/demo-wallet-shared/methods/sep6/pollWithdrawUntilComplete.ts +++ b/packages/demo-wallet-shared/methods/sep6/pollWithdrawUntilComplete.ts @@ -1,7 +1,6 @@ import { Account, Asset, - BASE_FEE, Keypair, Operation, Horizon, @@ -10,6 +9,7 @@ import { import { log } from "../../helpers/log"; import { createMemoFromType } from "../createMemoFromType"; import { AnyObject, TransactionStatus } from "../../types/types"; +import {getNetworkConfig} from "../../helpers/getNetworkConfig"; export const pollWithdrawUntilComplete = async ({ amount, @@ -95,7 +95,7 @@ export const pollWithdrawUntilComplete = async ({ const account = new Account(keypair.publicKey(), sequence); const txn = new TransactionBuilder(account, { - fee: BASE_FEE, + fee: getNetworkConfig().baseFee, networkPassphrase, }) .addOperation( diff --git a/packages/demo-wallet-shared/methods/submitPaymentTransaction.ts b/packages/demo-wallet-shared/methods/submitPaymentTransaction.ts index dac584e0..93284e3b 100644 --- a/packages/demo-wallet-shared/methods/submitPaymentTransaction.ts +++ b/packages/demo-wallet-shared/methods/submitPaymentTransaction.ts @@ -1,5 +1,4 @@ import { - BASE_FEE, Keypair, Horizon, Account, @@ -115,7 +114,7 @@ export const buildPaymentTransaction = async ({ } transaction = new TransactionBuilder(source, { - fee: BASE_FEE, + fee: getNetworkConfig().baseFee, networkPassphrase: getNetworkConfig().network, timebounds: await server.fetchTimebounds(100), }).addOperation(operation); diff --git a/packages/demo-wallet-shared/methods/trustAsset.ts b/packages/demo-wallet-shared/methods/trustAsset.ts index c912292b..c8da1004 100644 --- a/packages/demo-wallet-shared/methods/trustAsset.ts +++ b/packages/demo-wallet-shared/methods/trustAsset.ts @@ -1,6 +1,5 @@ import { TransactionBuilder, - BASE_FEE, Operation, Asset, Keypair, @@ -9,6 +8,7 @@ import { import { getErrorMessage } from "../helpers/getErrorMessage"; import { log } from "../helpers/log"; import { TrustAssetParam } from "../types/types"; +import {getNetworkConfig} from "../helpers/getNetworkConfig"; export const trustAsset = async ({ secretKey, @@ -36,7 +36,7 @@ export const trustAsset = async ({ log.instruction({ title: "Building add trustline transaction" }); const transaction = new TransactionBuilder(account, { - fee: BASE_FEE, + fee: getNetworkConfig().baseFee, networkPassphrase, }) .addOperation(