Set up Inverter Network SDK: Refer to the Guide for detailed instructions.
Simulating the Workflow
All we have to do is decide on the requestedModules and we can display or use the output of the simulation. This simulation lets us retrieve the preliminary addresses of a workflow before it is deployed.
'use client'
import { useGetSimulatedWorkflow } from '@inverter-network/react/client'
import type {
MixedRequestedModules,
GetDeployWorkflowArgs,
} from '@inverter-network/sdk'
import { useAccount } from 'wagmi'
import { Spinner } from '@/components/ui/spinner'
// 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()
// 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>
const { data, isPending } = useGetSimulatedWorkflow({ requestedModules, args })
if (isPending) return (
<div className="w-screen h-screen flex flex-col items-center justify-center">
<Spinner />
</div>
)
// Return a simple ui to display the results
return (
<div className="w-screen h-screen flex flex-col items-center justify-center gap-3">
<h1>Orchestrator Address: {data?.orchestratorAddress}</h1>
<h1>Authorizer Address: {data?.authorizerAddress}</h1>
<h1>Funding Manager Address: {data?.fundingManagerAddress}</h1>
<h1>Payment Processor Address: {data?.paymentProcessorAddress}</h1>
<h1>Logic Module Addresses: {data?.logicModuleAddresses.join(', ')}</h1>
<h1>Deployment Bytecode: {data?.bytecode.slice(0, 100)}...</h1>
<h1>Trusted Forwared Address: {data?.trustedForwarderAddress}</h1>
<h1>Factory Address: {data?.factoryAddress}</h1>
</form>
)
}
( 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