Skip to content

Conversation

mfbz
Copy link
Contributor

@mfbz mfbz commented Oct 1, 2025

Add a hook to easily retrieve or build an authorization function to be used for signing transactions.

Close #2645

@mfbz mfbz requested a review from a team as a code owner October 1, 2025 15:58
Copy link

changeset-bot bot commented Oct 1, 2025

🦋 Changeset detected

Latest commit: b43788e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@onflow/react-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-sdk-demo Ready Ready Preview Comment Oct 3, 2025 10:14pm


interface UseFlowAuthzArgs {
/** Custom authorization configuration, if not provided, uses current user's wallet authorization. */
customAuthz?: CustomAuthzConfig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
customAuthz?: CustomAuthzConfig
authz?: CustomAuthzConfig

for consistency with how we expose flowClient in useFlowClient hook. Unless you have strong opinions here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it make sense

Comment on lines 134 to 154
const fcl = useFlowClient({flowClient})

const authorization: AuthorizationFunction = useMemo(() => {
if (customAuthz) {
return (
account: Partial<InteractionAccount>
): Partial<InteractionAccount> => {
return {
...account,
addr: customAuthz.address,
keyId: customAuthz.keyId ?? 0,
signingFunction: customAuthz.signingFunction,
}
}
}

// Current user authorization as default
return fcl.currentUser.authorization as any
}, [fcl, customAuthz])

return authorization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const fcl = useFlowClient({flowClient})
const authorization: AuthorizationFunction = useMemo(() => {
if (customAuthz) {
return (
account: Partial<InteractionAccount>
): Partial<InteractionAccount> => {
return {
...account,
addr: customAuthz.address,
keyId: customAuthz.keyId ?? 0,
signingFunction: customAuthz.signingFunction,
}
}
}
// Current user authorization as default
return fcl.currentUser.authorization as any
}, [fcl, customAuthz])
return authorization
const fcl = useFlowClient({flowClient})
return authz || fcl.authz

"@onflow/react-sdk": minor
---

Added useFlowAuthz hook
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be more descriptive? It bubbles up tot release notes right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented 👍

@mfbz mfbz requested review from chasefleming and jribbink October 2, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] useFlowAuthz function

3 participants