getDeploy

The getDeploy method is used to deploy a fresh workflow.

Parameters:

// the public client / provider to make RPC calls
publicClient: PublicClient,
// the wallet client to sign and submit transactions
walletClient: WalletClient,
requestedModules: {
    // name of the Funding Manager module used
    fundingManager: RequestedModule<'fundingManager'>
    // name of the Authorizer module used
    authorizer: RequestedModule<'authorizer'>
    // name of the Payment Processor module used
    paymentProcessor: RequestedModule<'paymentProcessor'>
    // names of the optional modules used
    optionalModules: RequestedModule<'optionalModule'>[]
},

Returns: an object with the following properties

{
    // returns a schema of the inputs required for deploying, e.g. can be used to render input fields
    inputs: FormattedAbiParameter[]
    
    // a function that takes in deployment parameters, submits a deployment
    run(args: GetUserArgs<RequestedModules>): Promise<{orchestratorAddress: `0x${string}`, transactionHash: `0x${string}`}>
    
    // a function that takes in deployment parameters, simulates a deployment transaction and returns the orchestratorAddress
    simulate(args: GetUserArgs<RequestedModules>): Promise<{result: `0x${string}`}>
}

Example:

import { getDeploy } from '@inverter-network/sdk'

// Define the configuration for the workflow modules that need to be deployed
const requestedModules = {
    fundingManager: 'FM_Rebasing_v1',          // Funding manager module
    paymentProcessor: 'PP_Simple_v1',          // Payment processor module
    authorizer: 'AUT_Roles_v1',                // Authorizer module
    optionalModules: [                         // List of optional logic modules
        'LM_PC_RecurringPayments_v1'
    ]
} as const

// Retrieve the deployment functions by calling `getDeploy`
const { inputs, run, simulate } = getDeploy(
    publicClient,      // Public client interface for network interactions
    walletClient,      // Wallet client for managing blockchain transactions
    requestedModules   // Modules to be deployed
)

// Args based on the requested modules
const args = {
    orchestrator: {
        independentUpdates: true,
        independentUpdatesAdmin: '0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF',
    },
    fundingManager: {
        orchestratorTokenAddress: '0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF',
    },
    authorizer: {
       initialAdmin: "0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF",
    },
    optionalModules: {
        LM_PC_RecurringPayments_v1: {
            epochLength: '604800',
        },
    },
} as const

// returns the orchestrator address of the simulated deployment
const { result } = await simulate(args)

// returns the orchestrator address as well as the transaction hash
const { orchestratorAddress, transactionHash } await run(args)

Last updated