From d93870ce99440cabd5f124e73586f43779138527 Mon Sep 17 00:00:00 2001 From: HashMapsData2Value <83883690+HashMapsData2Value@users.noreply.github.com> Date: Wed, 22 Jan 2025 01:13:29 +0300 Subject: [PATCH 1/5] feat: set fee and expose fee as part of post --- src/components/app/Compose.tsx | 56 +++++++++++++++----------------- src/components/app/Post/Post.tsx | 19 ++++++----- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/components/app/Compose.tsx b/src/components/app/Compose.tsx index cc5a551..5da29df 100644 --- a/src/components/app/Compose.tsx +++ b/src/components/app/Compose.tsx @@ -49,35 +49,11 @@ const Compose = ({ const maxMessageLength = 800; const [topicName, setTopicName] = useState(""); const maxTopicLength = 60; + const [fee, setFee] = useState(0.001); const [isSending, setIsSending] = useState(false); const activeHandle = activeAddress ? handles[activeAddress] || "" : ""; - /** - * As the longest fixed part of a message is a reply: - * `ARC00-0;r;0000000000000000000000000000000000000000000000000000;;` (64 characters) - * - * ..and the longest NFD (including segment) is: - * `{27}.{27}.algo` (60 characters*) - * - * So, that's: - * ARC00-0;r;0000000000000000000000000000000000000000000000000000;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; (124 characters) - * - * ...leaving 900 for a message. - * - * I figure we'd want media attachment's at some point - * (common IPFS CID lengths are between 46 [v0] to 55 [v1, base58+sha256]), - * and to give the message format space for extensions, - * let's settle on 800 characters for a message. - * - * So that's: - * - * 60 characters max for a handle - * 800 characters max for a message - * - * *See [Fisherman's Discord post](https://discord.com/channels/925410112368156732/925410112951160879/1190400846547144754)) - */ - const sendMessage = async () => { if (!activeAddress) throw new Error("No active account"); if ( @@ -117,6 +93,9 @@ const Compose = ({ const transactionComposer = new algosdk.AtomicTransactionComposer(); const suggestedParams = await algodClient.getTransactionParams().do(); + + suggestedParams.flatFee = true; + suggestedParams.fee = fee*1_000_000; const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: activeAddress, @@ -196,9 +175,6 @@ const Compose = ({ } }} /> - {/* - {maxTopicLength - topicName.length}/{maxTopicLength} - */} )} @@ -260,6 +236,28 @@ const Compose = ({ +
+
+ + { + const value = parseFloat(evt.target.value); + if (!isNaN(value) && value >= 0.001) { + setFee(value); + } + }} + /> +
+
); @@ -270,4 +268,4 @@ function getDescriptionQuote() { return quotes[index]; } -export default Compose; +export default Compose; \ No newline at end of file diff --git a/src/components/app/Post/Post.tsx b/src/components/app/Post/Post.tsx index 7e647bc..753a6c2 100644 --- a/src/components/app/Post/Post.tsx +++ b/src/components/app/Post/Post.tsx @@ -182,6 +182,15 @@ const Post = ({ +
+ + {`${microalgosToAlgos(fee)} Fee`} + +
+