Skip to content

Commit df3cf87

Browse files
authored
Merge pull request #148 from AbstractSDK/adair/0.25-update
Abstract 0.25
2 parents e4d85c7 + b21bebd commit df3cf87

15 files changed

+266
-29
lines changed

.changeset/smooth-walls-compare.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@abstract-money/core": minor
3+
"@abstract-money/cosmwasm-utils": patch
4+
---
5+
6+
Update Abstract to 0.25 with account instantiation changes

packages/core/abstract.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import { registry, vanilla } from '@abstract-money/cli/plugins'
44
const contractsConfig = [
55
{
66
name: 'account',
7-
version: '0.24.1',
7+
version: '0.25.0',
88
},
99
{
1010
name: 'registry',
11-
version: '0.24.1',
11+
version: '0.25.0',
1212
},
1313
{
1414
name: 'ans-host',
15-
version: '0.24.1',
15+
version: '0.25.0',
1616
},
1717
{
1818
name: 'ibc-client',
19-
version: '0.24.1',
19+
version: '0.25.0',
2020
},
2121
{
2222
name: 'ica-client',
23-
version: '0.24.1',
23+
version: '0.25.0',
2424
},
2525
]
2626

packages/core/src/actions/public/get-registry-module-data.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,31 @@ export async function getRegistryModuleData<
5757
return null
5858
}
5959

60-
return await rawQuery<ModuleData | null>({
61-
client: cosmWasmClient,
62-
address: firstInstantiation,
63-
key: 'module_data',
64-
})
60+
let moduleData: ModuleData | null = null
61+
try {
62+
moduleData = await rawQuery<ModuleData | null>({
63+
client: cosmWasmClient,
64+
address: firstInstantiation,
65+
key: 'mod',
66+
})
67+
} catch (error) {
68+
try {
69+
moduleData = await rawQuery<ModuleData | null>({
70+
client: cosmWasmClient,
71+
address: firstInstantiation,
72+
key: 'module_data',
73+
})
74+
} catch (error2) {
75+
console.debug(
76+
`Could not retrieve module_data for ${formatModuleIdWithVersion(
77+
module.info.namespace,
78+
module.info.name,
79+
module.info.version,
80+
)}`,
81+
error,
82+
error2,
83+
)
84+
}
85+
}
86+
return moduleData
6587
}

packages/core/src/actions/wallet/create-account.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type CreateAccountParameters = WithCosmWasmSignOptions<
3030
install_modules?: MergedModuleInstallConfig[]
3131
}
3232
>,
33-
'owner'
33+
'owner' | 'code_id'
3434
>
3535
>
3636
>
@@ -44,6 +44,7 @@ export async function createAccount({
4444
namespace,
4545
authenticator,
4646
link,
47+
codeId,
4748
accountId,
4849
enableIbc,
4950
owner,
@@ -82,6 +83,7 @@ export async function createAccount({
8283
})
8384

8485
const instantiateMsg: AccountTypes.InstantiateMsg = {
86+
code_id: codeId ?? accountCodeId,
8587
owner: owner || {
8688
monarchy: {
8789
monarch: sender,

packages/core/src/actions/wallet/get-ans-host-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type GetAnsHostClientParameters = {
88
ansHostAddress: string
99
}
1010

11-
export async function getAnsHostClient({
11+
export function getAnsHostClient({
1212
signingCosmWasmClient,
1313
sender,
1414
ansHostAddress,

packages/core/src/actions/wallet/get-registry-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type GetRegistryClientParameters = {
88
registryAddress: string
99
}
1010

11-
export async function getRegistryClient({
11+
export function getRegistryClient({
1212
signingCosmWasmClient,
1313
sender,
1414
registryAddress,

packages/core/src/actions/wallet/get-sender-address.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export type GetSenderAddressParameters = {
22
sender: string
33
}
44

5-
export async function getSenderAddress({ sender }: GetSenderAddressParameters) {
5+
export function getSenderAddress({ sender }: GetSenderAddressParameters) {
66
return sender
77
}

packages/core/src/actions/wallet/get-signing-cosm-wasm-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type GetSigningCosmWasmClientParameters = {
44
signingCosmWasmClient: SigningCosmWasmClient
55
}
66

7-
export async function getSigningCosmWasmClient({
7+
export function getSigningCosmWasmClient({
88
signingCosmWasmClient,
99
}: GetSigningCosmWasmClientParameters) {
1010
return signingCosmWasmClient

packages/core/src/clients/create-wallet-client.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
22
import type { Evaluate } from '../types/utils'
33
import { ABSTRACT_API_URL } from '../utils'
44
import { type Client } from './create-client'
5-
import { PublicClientConfig, createPublicClient } from './create-public-client'
5+
import {
6+
PublicClient,
7+
PublicClientConfig,
8+
createPublicClient,
9+
} from './create-public-client'
10+
import { PublicActions } from './decorators/public'
611
import { type WalletActions, walletActions } from './decorators/wallet'
712

813
export type WalletClientConfig = Omit<PublicClientConfig, 'cosmWasmClient'> & {
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { accountIdToString } from './account-id-to-string'
3+
4+
describe('accountIdToString', () => {
5+
it('should convert a local account ID object to string', () => {
6+
const accountId = {
7+
chainName: 'neutrontestnet',
8+
seq: 42,
9+
trace: 'local' as const,
10+
}
11+
const result = accountIdToString(accountId)
12+
expect(result).toEqual('neutrontestnet-42')
13+
})
14+
15+
it('should convert a simple chain account ID object to string', () => {
16+
const accountId = {
17+
chainName: 'neutrontestnet',
18+
seq: 42,
19+
trace: 'local' as const,
20+
}
21+
const result = accountIdToString(accountId)
22+
expect(result).toEqual('neutrontestnet-42')
23+
})
24+
25+
it('should convert a multi-hop chain account ID object to string', () => {
26+
const accountId = {
27+
chainName: 'neutron',
28+
seq: 42,
29+
trace: {
30+
remote: ['osmosis'],
31+
},
32+
}
33+
const result = accountIdToString(accountId)
34+
expect(result).toEqual('neutron>osmosis-42')
35+
})
36+
37+
it('should convert a complex multi-hop chain account ID object to string', () => {
38+
const accountId = {
39+
chainName: 'neutron',
40+
seq: 42,
41+
trace: {
42+
remote: ['juno', 'osmosis'],
43+
},
44+
}
45+
const result = accountIdToString(accountId)
46+
expect(result).toEqual('neutron>osmosis>juno-42')
47+
})
48+
49+
it('should throw an error if seq is not a valid number', () => {
50+
const accountId = {
51+
chainName: 'neutron',
52+
seq: -1,
53+
trace: 'local' as const,
54+
}
55+
expect(() => accountIdToString(accountId)).toThrow(
56+
'Invalid account sequence: -1',
57+
)
58+
})
59+
60+
it('should throw an error if chainName is missing', () => {
61+
const accountId = {
62+
seq: 42,
63+
trace: 'local' as const,
64+
chainName: '',
65+
}
66+
expect(() => accountIdToString(accountId)).toThrow(
67+
'AccountId must have a chainName',
68+
)
69+
})
70+
71+
it('should throw an error if trace is not valid', () => {
72+
const accountId = {
73+
chainName: 'neutron',
74+
seq: 42,
75+
trace: { remote: [] },
76+
}
77+
expect(() => accountIdToString(accountId)).toThrow(
78+
'Invalid remote trace: []',
79+
)
80+
})
81+
82+
it('should throw an error if trace is not valid', () => {
83+
const accountId = {
84+
chainName: 'neutron',
85+
seq: 42,
86+
trace: { remote: [''] },
87+
}
88+
expect(() => accountIdToString(accountId)).toThrow(
89+
'Invalid remote trace: [""]',
90+
)
91+
})
92+
})

0 commit comments

Comments
 (0)