Skip to content

useUpgradeModules

Hook to upgrade modules in an Abstract account

Import

import { useUpgradeModules } from '@abstract-money/react'

Usage

index.tsx
import { useUpgradeModules } from '@abstract-money/react'
import { stringToAccountId } from '@abstract-money/core'
 
function App() {
  const upgradeModules = useUpgradeModules({
    accountId: stringToAccountId('pion-1'),
    chainName: 'pion',
  })
 
  return (
    <button
      onClick={() =>
        upgradeModules.mutate({
          fee: 'auto',
          args: {
            // @ts-ignore broken ts-codegen for nested arrays
            modules: [
              [{
                namespace: 'abstract',
                name: 'etf',
                version: 'latest',
              },
              "=migrateMsgBase64"
              ],
              [{
                namespace: 'abstract',
                name: 'dex',
                version: 'latest',
              },
              null
              ]
            ],
          },
        })
      }
    >
      upgrade modules
    </button>
  )
}

Hook Parameters

accountId

AccountId | undefined

Account Id to be used to fetch the query.

chainName

string | undefined

Name of the chain to be used to fetch the query.

mutation

MutationOptions | undefined

MutationOptions to use.

Mutation Parameters

fee

number | StdFee | "auto"

The fee to be paid for the transaction. Can be a number, a StdFee object, or "auto" for automatic fee calculation.

args

Arguments passed to the mutation. This includes:

modules

ModuleInfo$1[][]

An array of arrays containing ModuleInfo$1 objects. Each ModuleInfo$1 object represents a module to be upgraded and includes:

  • name: string - The name of the module.
  • namespace: string - The namespace of the module.
  • version: "latest" | { version: string } - The version of the module, either "latest" or a specific version string.

subAccountId (optional)

number | undefined

The ID of the sub-account to upgrade modules for. If not provided, the upgrade will be performed on the main account.