Skip to content

Commit

Permalink
Add host chain name helpers and fix bug with remote-account-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
adairrr committed Jun 24, 2024
1 parent 092a808 commit ac063e9
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 8 deletions.
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.20

### Patch Changes

- Updated dependencies []:
- @abstract-money/core@1.3.4
- @abstract-money/react@1.3.7
- @abstract-money/provider-cosmoskit@5.0.7

## 0.3.19

### 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.3.19",
"version": "0.3.20",
"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.3.20

### Patch Changes

- Updated dependencies []:
- @abstract-money/core@1.3.4
- @abstract-money/react@1.3.7
- @abstract-money/provider-graz@5.0.7

## 0.3.19

### 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.19",
"version": "0.3.20",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev",
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

## 1.3.4

### Patch Changes

- Add host chain name helpers and fix bug with remote-account-ids

## 1.3.3

### 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": "1.3.3",
"version": "1.3.4",
"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
@@ -1,4 +1,8 @@
import { AccountId, chainIdToName } from '@abstract-money/core'
import {
AccountId,
chainIdToName,
hostChainNameToName,
} from '@abstract-money/core'
import {
GetRemoteProxiesParameters,
getRemoteAccountProxies,
Expand Down Expand Up @@ -35,10 +39,12 @@ export async function getRemoteAccountIds({
? [sourceChainName]
: accountId.trace.remote.concat(sourceChainName)

const remoteChainName = hostChainNameToName(hostChainName)

return {
seq: accountId.seq,
trace: { remote: remoteTrace },
chainName: hostChainName,
chainName: remoteChainName,
} satisfies AccountId
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const CHAIN_ID_SEPARATOR = '-'

export const chainIdToHostChainName = (chainId: string) => {
return chainId.split(CHAIN_ID_SEPARATOR)[0]
}
13 changes: 13 additions & 0 deletions packages/core/src/utils/chain-registry/host-chain-name-to-name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { chainIdToHostChainName, chains } from '@abstract-money/core'

export function hostChainNameToName(hostChainName: string) {
const chainName = chains.find(
({ chain_name, chain_id }) =>
chain_name === hostChainName ||
chainIdToHostChainName(chain_id) === hostChainName,
)?.chain_name
if (!chainName) {
throw new Error(`Chain not found by hostChain: ${hostChainName}`)
}
return chainName
}
2 changes: 2 additions & 0 deletions packages/core/src/utils/chain-registry/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './assets'
export * from './chains'
export * from './chain-id-to-name'
export * from './host-chain-name-to-name'
export * from './chain-id-to-host-chain-name'
export * from './chain-name-to-id'
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

## 5.0.7

### Patch Changes

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

## 5.0.6

### 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.6",
"version": "5.0.7",
"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

## 5.0.7

### Patch Changes

- Updated dependencies []:
- @abstract-money/core@1.3.4
- @abstract-money/react@1.3.7

## 5.0.6

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

## 1.3.7

### Patch Changes

- Add host chain name helpers and fix bug with remote-account-ids

- Updated dependencies []:
- @abstract-money/core@1.3.4

## 1.3.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/react",
"version": "1.3.6",
"version": "1.3.7",
"description": "React Hooks for Abstract SDK",
"homepage": "https://github.com/AbstractSDK/abstract.js#readme",
"author": "dalechyn <[email protected]>",
Expand Down

0 comments on commit ac063e9

Please sign in to comment.