Deploy a Workflow

Setup Requirements

  1. Set up Inverter Network SDK: Refer to the Quick Start Guide for detailed instructions.

( optional ) You can pass in a ModuleData typed object into the requestedModules constant's fields, this makes it so that you can work with your self managed inverter modules

// EXEMPLE MixedRequestedModules USAGE
import type { ModuleData, MixedRequestedModules } from '@inverter-network/sdk'

const AUT_Roles_v1 = {'<your_module_data>'} as const satisifies ModuleData

const requestedModules = {
    fundingManager: 'FM_DepositVault_v1',
    paymentProcessor: 'PP_Simple_v1',
    authorizer: AUT_Roles_v1,
} as const satisfies MixedRequestedModules

Deploying the Workflow

All we have to do is decide on the requestedModules retrieve the runDeployment mutation and fill in the typesafe arg then we can run the mutation in our UI.

'use client'

import { useDeployWorkflow } from '@inverter-network/react/client'
import type {
  MixedRequestedModules,
  GetDeployWorkflowArgs,
} from '@inverter-network/sdk'

import { Button } from '@/components/ui/button'
import { useAccount } from 'wagmi'

// Defined the modules to be deployed 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 MixedRequestedModules

export default function Page() {
  const { address } = useAccount()

  const { runDeployment } = useDeployWorkflow({ requestedModules })

  // Define the args for the modules in typesafe manner
  const args = {
    fundingManager: {
      orchestratorTokenAddress: '<your_funding_token_address>',
    },
    authorizer: {
      initialAdmin: address,
    },
  } as const satisfies GetDeployWorkflowArgs<typeof requestedModules>

  // Return a simple ui to trigger the flow
  return (
    <form
      className="w-screen h-screen flex flex-col items-center justify-center gap-3"
      onSubmit={(e) => {
        e.preventDefault()
        runDeployment.mutate(args)
      }}
    >
      <h1>Orchestrator Address: {runDeployment.data?.orchestratorAddress}</h1>

      <h1>Transaction Hash: {runDeployment.data?.transactionHash}</h1>

      <Button type="submit" loading={runDeployment.isPending}>
        Deploy
      </Button>
    </form>
  )
}

Last updated