-
Notifications
You must be signed in to change notification settings - Fork 586
feat: Changing pre-filled value for interact tab #950
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { Button } from '@shared/ui/button'; | |
| import { Card } from '@shared/ui/card'; | ||
| import { Tooltip, TooltipContent, TooltipTrigger } from '@shared/ui/tooltip'; | ||
| import { useWallet } from '@solana/wallet-adapter-react'; | ||
| import { useEffect, useRef } from 'react'; | ||
| import { Loader, Send } from 'react-feather'; | ||
| import { Control, Controller, FieldPath } from 'react-hook-form'; | ||
|
|
||
|
|
@@ -50,12 +51,18 @@ export function InteractInstruction({ | |
| const pdas = usePdas({ form, idl, instruction }); | ||
| const getAutocompleteItems = createGetAutocompleteItems({ pdas, publicKey }); | ||
|
|
||
| const walletPrefillDependency = createWalletPrefillDependency(instruction, publicKey, fieldNames); | ||
| const lastPrefillAddressRef = useRef<string | undefined>(undefined); | ||
| useEffect(() => { | ||
| createWalletPrefillDependency(instruction, fieldNames, lastPrefillAddressRef).onValueChange(publicKey, form); | ||
| // instruction and fieldNames are stable for the lifetime of this component instance | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [publicKey, form]); | ||
|
|
||
| const knownAccountsPrefillDependency = createKnownAccountsPrefillDependency(instruction, fieldNames); | ||
| const pdaPrefillDependency = createPdaPrefillDependency(idl, instruction, fieldNames); | ||
| useFormPrefill({ | ||
| config: { | ||
| externalDependencies: [walletPrefillDependency, knownAccountsPrefillDependency, pdaPrefillDependency], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: There are some concerns with architecture and a simpler fix available. The current approach lifts wallet prefill out of the
Suggested fix:
|
||
| externalDependencies: [knownAccountsPrefillDependency, pdaPrefillDependency], | ||
| }, | ||
| form, | ||
| }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.