Skip to content

Commit

Permalink
Merge branch 'mainline' into believathon
Browse files Browse the repository at this point in the history
  • Loading branch information
adairrr committed Nov 26, 2024
2 parents 3480a3e + ba39dbe commit 7395311
Show file tree
Hide file tree
Showing 24 changed files with 167 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-turtles-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@abstract-money/core": patch
---

Ensure that hostChainNameToName doesn't throw
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.4.9

### Patch Changes

- Updated dependencies [[`5bb5a12`](https://github.com/AbstractSDK/abstract.js/commit/5bb5a12dc20cec33ea0e1a3569387a1497e2bc7b)]:
- @abstract-money/core@3.4.2
- @abstract-money/react@2.3.5
- @abstract-money/provider-cosmoskit@10.0.5

## 0.4.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion 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.4.8",
"version": "0.4.9",
"private": true,
"scripts": {
"dev": "next dev",
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.4.9

### Patch Changes

- Updated dependencies [[`5bb5a12`](https://github.com/AbstractSDK/abstract.js/commit/5bb5a12dc20cec33ea0e1a3569387a1497e2bc7b)]:
- @abstract-money/core@3.4.2
- @abstract-money/provider-graz@11.0.2
- @abstract-money/react@2.3.5

## 0.4.8

### 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.4.8",
"version": "0.4.9",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev",
Expand Down
7 changes: 7 additions & 0 deletions packages/actions-xion/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @abstract-money/actions-xion

## 0.0.4

### Patch Changes

- Updated dependencies [[`5bb5a12`](https://github.com/AbstractSDK/abstract.js/commit/5bb5a12dc20cec33ea0e1a3569387a1497e2bc7b)]:
- @abstract-money/core@3.4.2

## 0.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/actions-xion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/actions-xion",
"version": "0.0.3",
"version": "0.0.4",
"description": "Abstraxion utils",
"author": "adairrr <[email protected]>",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## 0.1.0

## 3.4.2

### Patch Changes

- [`5bb5a12`](https://github.com/AbstractSDK/abstract.js/commit/5bb5a12dc20cec33ea0e1a3569387a1497e2bc7b) Thanks [@adairrr](https://github.com/adairrr)! - Update adapter message builders

## 3.4.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/core",
"version": "3.4.1",
"version": "3.4.2",
"description": "Typings for Abstract smart contracts",
"homepage": "https://github.com/AbstractSDK/abstract.js#readme",
"author": "adairrr <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'

import { AdapterQueryMsgBuilder } from '@abstract-money/core'
import { RegistryTypes } from '../../../codegen/abstract'
import { getAccountAddressFromApi } from './get-account-address-from-api'

export type GetAdapterAuthorizedAddresses = {
cosmWasmClient: CosmWasmClient
apiUrl: string
accountId: RegistryTypes.AccountId
adapterAddress: string
}

export async function getAdapterAuthorizedAddresses({
cosmWasmClient,
accountId,
adapterAddress,
apiUrl,
}: GetAdapterAuthorizedAddresses) {
const account = await getAccountAddressFromApi({
accountId,
cosmWasmClient,
apiUrl,
})

return await cosmWasmClient.queryContractSmart(
adapterAddress,
AdapterQueryMsgBuilder.authorizedAddresses(account),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function hostChainNameToName(hostChainName: string) {
const chainName = chains.find(
({ chain_name, chain_id }) =>
chain_name === hostChainName ||
chainIdToHostChainName(chain_id) === hostChainName,
(chain_id && chainIdToHostChainName(chain_id) === hostChainName),
)?.chain_name
if (!chainName) {
throw new Error(`Chain not found by hostChain: ${hostChainName}`)
Expand Down
25 changes: 17 additions & 8 deletions packages/core/src/utils/modules/msg-factory/Adapter.msg-factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContractMsg } from '@abstract-money/core'
import { type AppQueryMsg, ContractMsg } from '@abstract-money/core'
import { CamelCasedProperties } from 'type-fest'
import {
AdapterBaseExecuteMsg,
Expand Down Expand Up @@ -33,17 +33,17 @@ import {
export abstract class AdapterExecuteMsgFactory {
/**
* Make a request to an adapter module.
* @param proxyAddress
* @param accountAddress
* @param request
*/
static executeAdapter = <TAppMsg>({
proxyAddress,
accountAddress,
request,
}: CamelCasedProperties<
AdapterRequestMsg<TAppMsg>
>): AdapterExecuteMsg<TAppMsg> => {
return ModuleExecuteMsgFactory.module({
proxy_address: proxyAddress,
account_address: accountAddress,
request,
})
}
Expand Down Expand Up @@ -82,14 +82,14 @@ export abstract class AdapterQueryMsgBuilder {

/**
* Base adapter authorized addresses query.
* @param proxyAddress
* @param accountAddress
*/
static authorizedAddresses = (
proxyAddress?: string,
accountAddress?: string,
): AdapterQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
authorized_addresses: {
proxy_address: proxyAddress,
account_address: accountAddress,
},
})
}
Expand All @@ -99,7 +99,16 @@ export abstract class AdapterQueryMsgBuilder {
*/
static config = (): AdapterQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
config: {},
base_config: {},
})
}

/**
* App module data query.
*/
static moduleData = (): AppQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
module_data: {},
})
}
}
13 changes: 8 additions & 5 deletions packages/core/src/utils/modules/msg-factory/Adapter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type AdapterBaseExecuteMsg = {
}
}
export type AdapterRequestMsg<TAppMsg> = {
proxy_address?: string | null
account_address?: string | null
request: TAppMsg
}

Expand All @@ -18,11 +18,14 @@ export type AdapterExecuteMsg<TAppMsg> = ModuleExecuteMsg<
export type AdapterBaseQueryMsg =
| {
authorized_addresses: {
proxy_address?: string | null
account_address?: string | null
}
}
| {
config: Record<string, never>
base_config: Record<string, never>
}
| {
module_data: Record<string, never>
}

export type AdapterQueryMsg<TAppMsg> = ModuleQueryMsg<
Expand All @@ -32,15 +35,15 @@ export type AdapterQueryMsg<TAppMsg> = ModuleQueryMsg<

export type AdapterBaseInitMsg = {
ans_host_address: string
version_control_address: string
registry_address: string
}

export interface AdapterAuthorizedAddressesResponse {
addresses: string[]
}

export interface AdapterConfigResponse {
version_control_address: string
registry_address: string
ans_host_address: string
dependencies: string[]
}
22 changes: 20 additions & 2 deletions packages/core/src/utils/modules/msg-factory/App.msg-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export abstract class AppQueryMsgFactory {
*/
static config = (): AppQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
config: {},
base_config: {},
})
}

Expand All @@ -65,7 +65,25 @@ export abstract class AppQueryMsgFactory {
*/
static admin = (): AppQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
admin: {},
base_admin: {},
})
}

/**
* App module data query.
*/
static moduleData = (): AppQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
module_data: {},
})
}

/**
* App top level owner query.
*/
static topLevelOwner = (): AppQueryMsg<never> => {
return ModuleQueryMsgFactory.base({
top_level_owner: {},
})
}
}
18 changes: 15 additions & 3 deletions packages/core/src/utils/modules/msg-factory/App.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,30 @@ export type AppExecuteMsg<TAppMsg> = ModuleExecuteMsg<
>
export type AppBaseQueryMsg =
| {
admin: Record<string, never>
base_admin: Record<string, never>
}
| {
config: Record<string, never>
base_config: Record<string, never>
}
| {
module_data: Record<string, never>
}
| {
top_level_owner: Record<string, never>
}

export type AppQueryMsg<TAppMsg> = ModuleQueryMsg<AppBaseQueryMsg, TAppMsg>

export type AppBaseInitMsg = {
ans_host_address: string
version_control_address: string
registry_address: string
}

// Empty migrate msg
export type AppBaseMigrateMsg = Record<string, never>

export interface AppConfigResponse {
account: string
ans_host_address: string
registry_address: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export abstract class ModuleInitMsgFactory {
return {
base: {
ans_host_address: ansHostAddress,
version_control_address: registryAddress,
registry_address: registryAddress,
},
module: appModuleInitMsg,
}
Expand All @@ -99,7 +99,7 @@ export abstract class ModuleInitMsgFactory {
return {
base: {
ans_host_address: ansHostAddress,
version_control_address: registryAddress,
registry_address: registryAddress,
},
module: adapterInitMsg,
}
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

## 10.0.5

### Patch Changes

- Updated dependencies []:
- @abstract-money/react@2.3.5

## 10.0.4

### 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": "10.0.4",
"version": "10.0.5",
"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

## 11.0.2

### Patch Changes

- Updated dependencies [[`5bb5a12`](https://github.com/AbstractSDK/abstract.js/commit/5bb5a12dc20cec33ea0e1a3569387a1497e2bc7b)]:
- @abstract-money/core@3.4.2
- @abstract-money/react@2.3.5

## 11.0.1

### 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": "11.0.1",
"version": "11.0.2",
"description": "Provider for Graz",
"homepage": "https://github.com/AbstractSDK/abstract.js#readme",
"author": "dalechyn <[email protected]>",
Expand Down
8 changes: 8 additions & 0 deletions packages/provider-xion/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @abstract-money/provider-xion

## 4.0.2

### Patch Changes

- Updated dependencies [[`5bb5a12`](https://github.com/AbstractSDK/abstract.js/commit/5bb5a12dc20cec33ea0e1a3569387a1497e2bc7b)]:
- @abstract-money/core@3.4.2
- @abstract-money/react@2.3.5

## 4.0.1

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

0 comments on commit 7395311

Please sign in to comment.