Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to abstract 0.23 #123

Merged
merged 6 commits into from
Aug 19, 2024
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
9 changes: 9 additions & 0 deletions examples/wagemos-cosmoskit-nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# wagemos-cosmoskit-nextjs

## 0.3.25

### Patch Changes

- Updated dependencies []:
- @abstract-money/[email protected]
- @abstract-money/[email protected]
- @abstract-money/[email protected]

## 0.3.24

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions examples/wagemos-cosmoskit-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wagemos-cosmoskit-nextjs",
"version": "0.3.24",
"version": "0.3.25",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -13,7 +13,7 @@
"@abstract-money/core": "workspace:*",
"@abstract-money/provider-cosmoskit": "workspace:*",
"@abstract-money/react": "workspace:*",
"@chain-registry/types": "^0.13.1",
"@chain-registry/types": "^0.45.50",
"@cosmjs/stargate": "^0.32.3",
"@cosmos-kit/keplr": "^2.4.15",
"@cosmos-kit/react": "^2.6.0",
Expand All @@ -25,7 +25,7 @@
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@tanstack/react-query": "^4",
"chain-registry": "^1.18.1",
"chain-registry": "^1.63.60",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cosmjs-types": "^0.9.0",
Expand Down
9 changes: 9 additions & 0 deletions examples/wagemos-graz-nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# wagemos-graz-nextjs

## 0.3.25

### Patch Changes

- Updated dependencies []:
- @abstract-money/[email protected]
- @abstract-money/[email protected]
- @abstract-money/[email protected]

## 0.3.24

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/wagemos-graz-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wagemos-graz-nextjs",
"version": "0.3.24",
"version": "0.3.25",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"type": "module",
"dependencies": {
"@abstract-money/bundle-require": "workspace:*",
"@abstract-money/ts-codegen": "^0.35.8",
"@abstract-money/ts-codegen": "0.36.0-beta-1",
"@cosmjs/cosmwasm-stargate": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
"abort-controller": "^3.0.0",
Expand Down
20 changes: 20 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
## 0.1.0

## 1.4.0

### Minor Changes

- Update Abstract to 0.23

This change updates:

- Abstract to 0.23
- Chain registry to 0.60.60

Breaking changes:

- `Manager.proposeOwnership` has been removed

Semi-breaking changes:

- Chain registry updating means that consumers will also need to update their chain registry + types
- Raw manager ownership query results have changed types.

## 1.3.4

### Patch Changes
Expand Down
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.23.0-beta.0',
version: '0.23.0',
},
{
name: 'proxy',
version: '0.23.0-beta.0',
version: '0.23.0',
},
{
name: 'module-factory',
version: '0.23.0-beta.0',
version: '0.23.0',
},
{
name: 'version-control',
version: '0.23.0-beta.0',
version: '0.23.0',
},
{
name: 'ans-host',
version: '0.23.0-beta.0',
version: '0.23.0',
},
{
name: 'account-factory',
version: '0.23.0-beta.0',
version: '0.23.0',
},
{
name: 'ibc-client',
version: '0.23.0-beta.0',
version: '0.23.0',
},
]

Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/core",
"version": "1.3.4",
"version": "1.4.0",
"description": "Typings for Abstract smart contracts",
"homepage": "https://github.com/AbstractSDK/abstract.js#readme",
"author": "adairrr <[email protected]>",
Expand All @@ -27,15 +27,15 @@
},
"dependencies": {
"@abstract-money/cosmwasm-utils": "workspace:*",
"@chain-registry/types": "^0.13.1",
"@chain-registry/types": "^0.45.50",
"@cosmjs/cosmwasm-stargate": "^0.32.3",
"@cosmjs/encoding": "^0.32.3",
"@cosmjs/proto-signing": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
"@cosmjs/tendermint-rpc": "^0.32.3",
"@rimbu/bimap": "^1.1.1",
"bech32": "^2.0.0",
"chain-registry": "^1.18.1",
"chain-registry": "^1.63.60",
"cosmjs-types": "^0.9.0",
"graphql-request": "^6.1.0",
"lodash": "^4.17.21",
Expand Down
29 changes: 0 additions & 29 deletions packages/core/src/actions/account/wallet/propose-owner.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/core/src/actions/account/wallet/update-ownership.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ManagerClient } from '../../../codegen/abstract'
import { Action } from '../../../codegen/abstract/cosmwasm-codegen/Manager.types'
import { GovAction } from '../../../codegen/abstract/cosmwasm-codegen/Manager.types'
import { WithCosmWasmSignOptions } from '../../../types/parameters'
import { getManagerClientFromApi } from './get-manager-client-from-api'
import { BaseAccountWalletParameters } from './types'

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

Expand Down
15 changes: 0 additions & 15 deletions packages/core/src/clients/decorators/account-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { executeRemote } from '../../actions/account/wallet/execute-remote'
import { getManagerClientFromApi } from '../../actions/account/wallet/get-manager-client-from-api'
import { getProxyClientFromApi } from '../../actions/account/wallet/get-proxy-client-from-api'
import { installModules } from '../../actions/account/wallet/install-modules'
import { proposeOwner } from '../../actions/account/wallet/propose-owner'
import { revokeNamespace } from '../../actions/account/wallet/remove-namespace'
import { requestFundsFromRemote } from '../../actions/account/wallet/request-remote-funds'
import { sendFundsToRemote } from '../../actions/account/wallet/send-funds-to-remote'
Expand Down Expand Up @@ -138,11 +137,6 @@ export type AccountWalletActions = {
typeof updateOwnership
>,
): ReturnType<typeof updateOwnership>
proposeOwner(
parameters: ExtractAndPartializeDecoratedParametersFromParameters<
typeof proposeOwner
>,
): ReturnType<typeof proposeOwner>
enableIbc(
parameters: ExtractAndPartializeDecoratedParametersFromParameters<
typeof enableIbc
Expand Down Expand Up @@ -319,15 +313,6 @@ export function accountWalletActions(
...parameters,
...extra,
}),
proposeOwner: ({ extra, ...parameters }) =>
proposeOwner({
accountId,
signingCosmWasmClient,
apiUrl,
sender,
...parameters,
...extra,
}),
enableIbc: ({ extra, ...parameters }) =>
enableIbc({
accountId,
Expand Down
51 changes: 43 additions & 8 deletions packages/core/src/legacy/clients/AbstractAccountClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { type JsonObject } from '@cosmjs/cosmwasm-stargate/build/modules'
import { type Coin } from '@cosmjs/stargate'
import { type StdFee } from '@cosmjs/stargate'
import { match } from 'ts-pattern'
import { P, match } from 'ts-pattern'
import {
ManagerClient,
ManagerExecuteMsgBuilder,
Expand All @@ -22,6 +22,7 @@ import {
} from '../../codegen/abstract'

type ManagerModuleInfo = ManagerTypes.ManagerModuleInfo
type GovernanceDetails = ManagerTypes.GovernanceDetailsForString
type CosmosMsgForEmpty = ProxyTypes.CosmosMsgForEmpty
import { ABSTRACT_CONSTANTS } from '../constants'
import {
Expand All @@ -34,9 +35,11 @@ import {
AdapterQueryMsgBuilder,
} from '../generics/adapter/Adapter.msg-factory'
type ModuleReference = VersionControlTypes.ModuleReference
import semver from 'semver/preload'
import { jsonToBinary } from '../../utils/encoding'
import { ContractMsg, EncodedMsg } from '../messages'
import { type AbstractClient, type AbstractQueryClient } from './AbstractClient'
import { rawQuery } from './helpers'
import { AbstractAccountId } from './objects/AbstractAccountId'
import { AnsAssetList } from './objects/AnsAssetList'
import { AssetInfo } from './objects/AssetInfo'
Expand Down Expand Up @@ -215,6 +218,18 @@ export class AbstractAccountQueryClient implements IAbstractAccountQueryClient {
return namespace ?? null
}

public async managerVersion(): Promise<string> {
const { version } = await rawQuery<{
contract: string
version: string
}>({
readOnlyClient: this.managerQueryClient.client,
address: this.managerQueryClient.contractAddress,
key: 'contract_info',
})
return version
}

/**
* Return the owner of the Account.
*
Expand All @@ -223,16 +238,36 @@ export class AbstractAccountQueryClient implements IAbstractAccountQueryClient {
*/
public async getOwner(invalidateCache?: boolean): Promise<string | null> {
if (invalidateCache || this._owner === undefined) {
this._owner = await this.managerQueryClient
const version = await this.managerVersion()

const owner = (await this.managerQueryClient
.ownership()
.then((res) => res.owner ?? null)
.catch((error) => {
console.error('Failed to fetch the owner:', error)
throw error
})
.then(({ owner }) => owner)) as unknown

// > 0.23.0 returns the full governance type
if (semver.gte(version, '0.23.0')) {
const governance = owner as unknown as GovernanceDetails

this._owner = match(governance)
.with({ Monarchy: { monarch: P.select() } }, (monarch) => monarch)
.with({ SubAccount: { proxy: P.select() } }, (proxy) => proxy)
.with({ Renounced: {} }, () => null)
.with({ NFT: { collection_addr: P.select() } }, (col) => col)
.with({ External: { governance_address: P.select() } }, (ext) => ext)
.otherwise((e) => {
console.warn(
`Unknown governance type for ${
this.managerAddress
}: ${JSON.stringify(e)}`,
)
return JSON.stringify(e)
})
} else {
this._owner = owner as string
}
}

return this._owner
return this._owner ?? null
}

/**
Expand Down
7 changes: 7 additions & 0 deletions packages/provider-cosmoskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @abstract-money/provider-cosmoskit

## 6.0.0

### Patch Changes

- Updated dependencies []:
- @abstract-money/[email protected]

## 5.0.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/provider-cosmoskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/provider-cosmoskit",
"version": "5.0.11",
"version": "6.0.0",
"description": "Provider for CosmosKit",
"homepage": "https://github.com/AbstractSDK/abstract.js#readme",
"author": "dalechyn <[email protected]>",
Expand Down
8 changes: 8 additions & 0 deletions packages/provider-graz/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @abstract-money/provider-graz

## 6.0.0

### Patch Changes

- Updated dependencies []:
- @abstract-money/[email protected]
- @abstract-money/[email protected]

## 5.0.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/provider-graz/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/provider-graz",
"version": "5.0.11",
"version": "6.0.0",
"description": "Provider for Graz",
"homepage": "https://github.com/AbstractSDK/abstract.js#readme",
"author": "dalechyn <[email protected]>",
Expand Down
Loading
Loading