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'>[]
    },
    factoryType?: FactoryType // to specify a supported custom factory @default - 'default'
}

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>, options?: MethodOptions): 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}`;
        request: SimulateContractReturnType['request'];
    }>
    
    // a function that takes in deployment parameters, estimates the deployment gas and return value and formatted value
    estimateGas(args: GetUserArgs<RequestedModules>): Promise<{
        value: string;
        formatted: string;
    }>
}

Example:

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

// Define the configuration for the workflow modules that need to be deployed
const requestedModules = {
    fundingManager: 'FM_DepositVault_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 satisfies RequestedModules

const factoryType = 'default' satisfies FactoryType

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

// Args based on the requested modules
// Should either be `as const` or be passed dirrectly in the `estimateGas`, `run` or `simulate` function args
const args = {
    orchestrator: {
        independentUpdates: true,
        independentUpdatesAdmin: '0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF',
    },
    fundingManager: {
        orchestratorTokenAddress: '0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF',
    },
    authorizer: {
       initialAdmin: "0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF",
    },
    optionalModules: {
        LM_PC_RecurringPayments_v1: {
            epochLength: '604800',
        },
    },
} as const satisfies GetUserArgs<typeof requestedModules, typeof factoryType>

// returns the gas in formatted and raw
const { value, formatted } = await estimateGas(args)

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

// returns the orchestrator address as well as the transaction hash
const { orchestratorAddress, transactionHash } await run(args, {
    confirmations: 1,
    onHash: (hash) => {console.log(hash)},
    onConfirmation: (receipt) => {console.log(receipt)},
    onApprove: (receipts) => {console.log(receipts)}
})

Last updated