Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/shiny-penguins-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@abstract-money/core": minor
"@abstract-money/react": minor
---

Add new init2 address generation, 0.23 changes
14 changes: 7 additions & 7 deletions packages/core/abstract.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ import { registry, vanilla } from '@abstract-money/cli/plugins'
const contractsConfig = [
{
name: 'manager',
version: '0.22.1',
version: '0.23.0-beta.0',
},
{
name: 'proxy',
version: '0.22.1',
version: '0.23.0-beta.0',
},
{
name: 'module-factory',
version: '0.22.1',
version: '0.23.0-beta.0',
},
{
name: 'version-control',
version: '0.22.1',
version: '0.23.0-beta.0',
},
{
name: 'ans-host',
version: '0.22.1',
version: '0.23.0-beta.0',
},
{
name: 'account-factory',
version: '0.22.1',
version: '0.23.0-beta.0',
},
{
name: 'ibc-client',
version: '0.22.1',
version: '0.23.0-beta.0',
},
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
ModuleId,
chainIdToName,
getInstantiate2Address,
} from '@abstract-money/core'
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { VersionControlTypes } from '../../../codegen/abstract'
import { abstractModuleId } from '../../../utils/modules/abstract-module-id'
import { getVersionControlAddressFromApi } from '../../get-version-control-address-from-api'
import { getAppModuleCodeIdFromVersionControl } from '../../public/get-app-module-code-id-from-version-control'
import { getModuleFactoryAddressFromVersionControl } from '../../public/get-module-factory-address-from-version-control'
import { CommonModuleNames } from '../../public/types'

export type GetManagerInstantiate2AddressFromApi = {
accountId: VersionControlTypes.AccountId
cosmWasmClient: CosmWasmClient
apiUrl: string
}

/**
* Retrieve the calculated manager init2 address from the api.
* @param accountId
* @param cosmWasmClient
* @param apiUrl
*/
export async function getManagerInstantiate2AddressFromApi({
accountId,
cosmWasmClient,
apiUrl,
}: GetManagerInstantiate2AddressFromApi) {
const chainId = await cosmWasmClient.getChainId()
const chainName = chainIdToName(chainId)

const versionControlAddress = await getVersionControlAddressFromApi({
apiUrl,
chainName,
})

const moduleFactoryAddress = await getModuleFactoryAddressFromVersionControl({
cosmWasmClient,
versionControlAddress,
})

const managerCodeId = await getAppModuleCodeIdFromVersionControl({
moduleId: abstractModuleId(CommonModuleNames.MANAGER),
version: 'latest',
cosmWasmClient,
versionControlAddress,
})

const moduleCodeDetails = await cosmWasmClient.getCodeDetails(managerCodeId)

return getInstantiate2Address(
moduleFactoryAddress,
moduleCodeDetails.checksum,
{ ...accountId, chainName },
)
}
29 changes: 29 additions & 0 deletions packages/core/src/actions/account/wallet/enable-ibc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ABSTRACT_NAMESPACE } from '@abstract-money/core'
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { ManagerClient, VersionControlTypes } from '../../../codegen/abstract'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { CommonModuleNames } from '../../public/types'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { installModules } from './install-modules'

export type EnableIbcParameters = WithCosmWasmSignOptions<{
accountId: VersionControlTypes.AccountId
signingCosmWasmClient: SigningCosmWasmClient
apiUrl: string
sender: string
}>

export async function enableIbc({ ...parameters }: EnableIbcParameters) {
return installModules({
...parameters,
modules: [
{
module: {
name: CommonModuleNames.IBC_CLIENT,
namespace: ABSTRACT_NAMESPACE,
version: 'latest',
},
},
],
})
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { IbcClientTypes, ManagerTypes } from '../../../codegen/abstract'
import { CallbackInfo } from '../../../codegen/abstract/cosmwasm-codegen/IbcClient.types'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { MaybeArray } from '../../../types/utils'
import { executeIbcAction } from './execute-ibc-action'
import { BaseWalletParameters } from './types'

type Base64EncodedJson = string

export type ExecuteOnRemoteParameters = Omit<
WithCosmWasmSignOptions<
BaseWalletParameters & {
Expand Down
29 changes: 29 additions & 0 deletions packages/core/src/actions/account/wallet/install-modules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { ManagerClient, VersionControlTypes } from '../../../codegen/abstract'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type InstallModulesParameters = WithCosmWasmSignOptions<
BaseWalletParameters &
Parameters<typeof ManagerClient.prototype.installModules>[0]
>

export async function installModules({
accountId,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
...rest
}: InstallModulesParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
sender,
apiUrl,
})
return managerClient.installModules(rest, fee, memo, funds)
}
29 changes: 29 additions & 0 deletions packages/core/src/actions/account/wallet/propose-owner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ManagerClient } from '../../../codegen/abstract'
import { Action } from '../../../codegen/abstract/cosmwasm-codegen/Manager.types'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type ProposeOwnerParameters = WithCosmWasmSignOptions<
BaseWalletParameters &
Parameters<typeof ManagerClient.prototype.proposeOwner>[0]
>

export async function proposeOwner({
accountId,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
...rest
}: ProposeOwnerParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
sender,
apiUrl,
})
return managerClient.proposeOwner({ ...rest }, fee, memo, funds)
}
29 changes: 29 additions & 0 deletions packages/core/src/actions/account/wallet/uninstall-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { ManagerClient, VersionControlTypes } from '../../../codegen/abstract'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type UninstallModulesParameters = WithCosmWasmSignOptions<
BaseWalletParameters &
Parameters<typeof ManagerClient.prototype.uninstallModule>[0]
>

export async function uninstallModule({
accountId,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
...rest
}: UninstallModulesParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
sender,
apiUrl,
})
return managerClient.uninstallModule(rest, fee, memo, funds)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type CreateSubAccountParameters = WithCosmWasmSignOptions<
export type UpdateInfoParameters = WithCosmWasmSignOptions<
BaseWalletParameters &
Parameters<typeof ManagerClient.prototype.updateSettings>[0]
Parameters<typeof ManagerClient.prototype.updateInfo>[0]
>

export async function updateSettings({
export async function updateInfo({
accountId,
ibcEnabled,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
...rest
}: CreateSubAccountParameters) {
}: UpdateInfoParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
sender,
apiUrl,
})
return managerClient.updateSettings({ ...rest, ibcEnabled }, fee, memo, funds)
return managerClient.updateInfo({ ...rest }, fee, memo, funds)
}
30 changes: 30 additions & 0 deletions packages/core/src/actions/account/wallet/update-ownership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ManagerClient } from '../../../codegen/abstract'
import { Action } from '../../../codegen/abstract/cosmwasm-codegen/Manager.types'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type UpdateOwnershipParameters = WithCosmWasmSignOptions<
BaseWalletParameters & {
update: Action
}
>

export async function updateOwnership({
accountId,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
update,
}: UpdateOwnershipParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
sender,
apiUrl,
})
return managerClient.updateOwnership(update, fee, memo, funds)
}
28 changes: 28 additions & 0 deletions packages/core/src/actions/account/wallet/update-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ManagerClient } from '../../../codegen/abstract'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type UpdateStatusParameters = WithCosmWasmSignOptions<
BaseWalletParameters &
Parameters<typeof ManagerClient.prototype.updateStatus>[0]
>

export async function updateStatus({
accountId,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
...rest
}: UpdateStatusParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
sender,
apiUrl,
})
return managerClient.updateStatus({ ...rest }, fee, memo, funds)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@ import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { ManagerClient, VersionControlTypes } from '../../../codegen/abstract'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseWalletParameters } from './types'

export type UpgradeModuleParameters = WithCosmWasmSignOptions<
{
accountId: VersionControlTypes.AccountId
signingCosmWasmClient: SigningCosmWasmClient
apiUrl: string
sender: string
} & Omit<
Parameters<typeof ManagerClient.prototype.upgrade>[0],
'accountId'
> & { subAccountId?: number }
export type UpgradeModulesParameters = WithCosmWasmSignOptions<
BaseWalletParameters & Parameters<typeof ManagerClient.prototype.upgrade>[0]
>

export async function upgradeModule({
export async function upgradeModules({
accountId,
subAccountId,
signingCosmWasmClient,
apiUrl,
sender,
fee,
memo,
funds,
...rest
}: UpgradeModuleParameters) {
}: UpgradeModulesParameters) {
const managerClient = await getManagerClientFromApi({
accountId,
signingCosmWasmClient,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export * from './account/wallet/execute'
export * from './account/wallet/get-manager-client-from-api'
export * from './account/wallet/get-proxy-client-from-api'
export * from './account/wallet/remove-namespace'
export * from './account/wallet/upgrade-module'
export * from './account/wallet/upgrade-modules'
export * from './account/wallet/withdraw'

export * from './public/get-abstract-module-address-from-version-control'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'

import { ABSTRACT_NAMESPACE } from '@abstract-money/core'
import { VersionControlTypes } from '../../codegen/abstract'
import { versionControlModuleToAddress } from '../../utils/version-control/version-control-module-to-address'
import { getVersionControlQueryClient } from './get-version-control-query-client'

const ABSTRACT_NAMESPACE = 'abstract'

export type GetAbstractModuleAddressFromVersionControl = {
moduleName: string
cosmWasmClient: CosmWasmClient
Expand Down
Loading