Operate a Workflow
'use client'
import { useWorkflow } from '@inverter-network/react/client'
import { type RequestedModules, type GetUserArgs } from '@inverter-network/sdk'
import { Button } from '@inverter-network/react'
import { useMutation } from '@tanstack/react-query'
export default function Page() {
// Defined the modules to be used in the workflow in typesafe manner
const requestedModules = {
fundingManager: 'FM_DepositVault_v1',
paymentProcessor: 'PP_Simple_v1',
authorizer: 'AUT_Roles_v1',
optionalModules: [
'LM_PC_Bounties_v1'
]
} as const satisfies RequestedModules
const workflow = useWorkflow({
orchestratorAddress: <your_orchestrator_address>,
requestedModules
})
// Setup a read mutation to run the workflow function
const readTitle = useMutation({
mutationFn: async () => {
if (!workflow.data) throw new Error('No workflow instance found')
return await workflow.data.fundingManager.read.title.run()
}
})
// Return a simple ui to trigger the flow
return (
<div className="w-screen h-screen flex flex-col items-center justify-center">
<h1>Funding Manager Title: {readTitle.data}</h1>
<Button
onClick=() => { readTitle.mutate() }
loading={readTitle.isPending}
>Deploy<Button>
</div>
)
}
Last updated