-
Notifications
You must be signed in to change notification settings - Fork 21
Feat/optional sender - squashed #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Deploying algokit-lora with
|
| Latest commit: |
cc92c31
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ae649f33.algokit-lora.pages.dev |
| Branch Preview URL: | https://feat-optional-sender-improve.algokit-lora.pages.dev |
PatrickDinh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @@ -0,0 +1,33 @@ | |||
| import { Nfd } from '@/features/nfd/data/types' | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
| export type Props = PropsWithChildren<{ | ||
| address: string | Address | ||
| short?: boolean | ||
| className?: string | ||
| showCopyButton?: boolean | ||
| showQRButton?: boolean | ||
| nfd?: Nfd | ||
| autoPopulated?: boolean | ||
| }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be type Props = AddressOrNfdLinkProps & { autoPopulated?: boolean }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better!
| manager: asAddressOrNfd(data.manager.value!), | ||
| reserve: asAddressOrNfd(data.reserve.value!), | ||
| freeze: asAddressOrNfd(data.freeze.value!), | ||
| clawback: asAddressOrNfd(data.clawback.value!), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you use asAddressOrNfd here? If I recall correctly these values can be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, back to optional.
manager: asOptionalAddressOrNfd(data.manager), reserve: asOptionalAddressOrNfd(data.reserve), freeze: asOptionalAddressOrNfd(data.freeze), clawback: asOptionalAddressOrNfd(data.clawback),
| manager: asAddressOrNfd(data.manager.value!), | ||
| reserve: asAddressOrNfd(data.reserve.value!), | ||
| freeze: asAddressOrNfd(data.freeze.value!), | ||
| clawback: asAddressOrNfd(data.clawback.value!), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, why use asAddressOrNfd?
| } | ||
| } | ||
|
|
||
| return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the sender can't be resolved, the value is set to '', is it intended? Have you checked the behaviour of the transaction wizard when the value is ''?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking for that case like this now
`const val = data?.value ?? ''
const res = data?.resolvedAddress ?? ''
const isEmpty = !val && !res
if (isEmpty) {`
| ) | ||
|
|
||
| const result = await localnet.context.waitForIndexerTransaction(transactionId) | ||
| expect(result.transaction.sender).toBe(testAccount.addr.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should compare it with the kmd account (from account manager) because I'm not sure is the testAccount is guarantee to be the same.
package-lock.json
Outdated
| "version": "4.1.16", | ||
| "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.16.tgz", | ||
| "integrity": "sha512-BX5iaSsloNuvKNHRN3k2RcCuTEgASTo77mofW0vmeHkfrDWaoFAFvNHpEgtu0eqyypcyiBkDWzSMxJhp3AUVcw==", | ||
| "version": "4.1.17", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't update package-lock in this PR. If it needs to be updated, it should be a separate PR that deals with dependencies
| <p>Create and send transactions to the selected network using a connected wallet.</p> | ||
| <TransactionsBuilder | ||
| defaultTransactions={searchParamsTransactions} | ||
| key={searchParamsTransactions.transactions.map((t) => t.id).join('|')} // rerender when it gets populated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good idea, you should wrap this in a loading spinner when it's loading. Have a look at RenderLoadable for inspiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a PageLoader before rendering the TransactionBuilder. That removes the update based on key change (hacky) approach.
src/features/transaction-wizard/utils/use-transaction-search-params-builder.ts
Outdated
Show resolved
Hide resolved
| if (errors && errors.length > 0) { | ||
| for (const error of errors) { | ||
| toast.error(error) | ||
| let cancelled = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is cancelled needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed together with the unused error handling
| import { betanetId, mainnetId, testnetId, fnetId, localnetId } from '@/features/network/data' | ||
| import { algorandClient } from '@/features/common/data/algo-client' | ||
|
|
||
| export default async function resolveSenderAddress(data?: { value?: string; resolvedAddress?: string }): Promise<TransactionSender> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't pick this up in the previous round, I think we should avoid using export default. We use named export everywhere else in this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think data shouldn't be undefined
| export default async function resolveSenderAddress(data?: { value?: string; resolvedAddress?: string }): Promise<TransactionSender> { | ||
| const { id: networkId } = settingsStore.get(networkConfigAtom) | ||
|
|
||
| const val = data?.value ?? '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can simplify this function by
export async function resolveSenderAddress(data: { value?: string; resolvedAddress?: string }): Promise<TransactionSender> {
if (data.value) {
return data
}
// The rest
}
Makes the logic simple, if the data has value, just return it.
| if (errors && errors.length > 0) { | ||
| for (const error of errors) { | ||
| toast.error(error) | ||
| let mounted = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I missed something but I don't understand the purpose of the mounted variable. You init it with true and never change the value. Maybe it isn't needed
| for (const error of errors) { | ||
| toast.error(error) | ||
| let mounted = true | ||
| const loadTransactions = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should refactor the async logic inside useEffect. Elsewhere we use jotai atom to deal with loading data. Have a look at the transaction-page.tsx for example. I am aware that it needs to few pieces to setup so if you need a hand, please let me know.
| const senderInput = await component.findByLabelText(/Sender/) | ||
| fireEvent.input(senderInput, { | ||
| target: { value: testAccount.addr }, | ||
| target: { value: walletAccount.addr }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change testAccount to walletAccount here? I thought that walletAccount is only used when the sender isn't set. I don't expect the see any changes in this test to be honest. It shouldn't be affected by the optional sender feature you are working on.
…e unsigned commits
…params transaction builder
…estWallet + address PR comments
… fields that got required
235900a to
cc92c31
Compare
feat(optional sender) - squashed
This PR replaces the previous one that contained unsigned commits.
I’ve taken the latest version from that branch, squashed all commits into a single signed commit, and reopened it here to maintain a clean history.
Both this PR and the old one have been moved to draft.
I’ll be pushing new commits here to address all review comments and suggestions made earlier today on the previous PR.
Please continue the discussion and review process on this new PR moving forward. 🚀