Skip to content

Commit

Permalink
Added ICA Execute action.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Oct 20, 2023
1 parent 20aa811 commit 86718ba
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 29 deletions.
4 changes: 4 additions & 0 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
"raisedHand": "Raised hand",
"recycle": "Recycle",
"robot": "Robot",
"rocketShip": "Rocket ship",
"suitAndTie": "Suit and tie",
"swords": "Swords",
"telescope": "Telescope",
Expand Down Expand Up @@ -332,6 +333,7 @@
"feeTokenNotFound": "Fee token not found.",
"govTokenBalancesDoNotSumTo100": "Total token distribution percentage must equal 100%, but it currently sums to {{totalPercent}}.",
"icaAccountAlreadyExists": "ICA account already exists on {{chain}}.",
"icaAccountDoesNotExist": "ICA account does not exist on {{chain}}.",
"icaAddressNotLoaded": "ICA address not loaded.",
"insufficientForDeposit": "You do not have enough funds to cover a deposit of {{amount}} ${{tokenSymbol}}.",
"insufficientFunds": "Insufficient funds.",
Expand Down Expand Up @@ -836,6 +838,7 @@
"govTokenAddress": "Governance Token",
"groupAddress": "CW4 Group",
"historySinceDate": "History since {{date}}",
"icaExecuteDescription": "Execute an action from an ICA account on another chain.",
"inboxConfigPreferencesDescription": "Choose where you want to receive notifications. Website notifications appear here on the Inbox page.",
"inboxDescription": "Your notification inbox.",
"inboxEmailTooltip": "Receive inbox notifications in your email.",
Expand Down Expand Up @@ -1297,6 +1300,7 @@
"history": "History",
"holdings": "Holdings",
"home": "Home",
"icaExecute": "ICA Execute",
"identity": "Identity",
"inbox": "Inbox",
"inboxConfiguration": "Inbox configuration",
Expand Down
2 changes: 1 addition & 1 deletion packages/state/recoil/selectors/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const isContractSelector = selectorFamily<
// If contract does not exist, not the desired contract.
if (
err instanceof Error &&
err.message.includes('contract: not found: invalid request')
err.message.includes('not found: invalid request')
) {
console.error(err)
return false
Expand Down
42 changes: 20 additions & 22 deletions packages/stateful/actions/core/advanced/CreateIcaAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,26 @@ export const makeCreateIcaAccountAction: ActionMaker<CreateIcaAccountData> = ({

const info = getIbcTransferInfoBetweenChains(sourceChainId, chainId)

return chainId
? makeStargateMessage({
stargate: {
typeUrl: MsgRegisterInterchainAccount.typeUrl,
value: MsgRegisterInterchainAccount.fromPartial({
owner: address,
connectionId: info.sourceChain.connection_id,
version: JSON.stringify(
Metadata.fromPartial({
version: 'ics27-1',
controllerConnectionId: info.sourceChain.connection_id,
hostConnectionId: info.destinationChain.connection_id,
// Empty when registering a new address.
address: '',
encoding: 'proto3',
txType: 'sdk_multi_msg',
})
),
}),
},
})
: undefined
return makeStargateMessage({
stargate: {
typeUrl: MsgRegisterInterchainAccount.typeUrl,
value: MsgRegisterInterchainAccount.fromPartial({
owner: address,
connectionId: info.sourceChain.connection_id,
version: JSON.stringify(
Metadata.fromPartial({
version: 'ics27-1',
controllerConnectionId: info.sourceChain.connection_id,
hostConnectionId: info.destinationChain.connection_id,
// Empty when registering a new address.
address: '',
encoding: 'proto3',
txType: 'sdk_multi_msg',
})
),
}),
},
})
}, [])

const useDecodedCosmosMsg: UseDecodedCosmosMsg<CreateIcaAccountData> = (
Expand Down
43 changes: 43 additions & 0 deletions packages/stateful/actions/core/advanced/IcaExecute/Component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useTranslation } from 'react-i18next'

import {
NestedActionsEditor,
NestedActionsEditorOptions,
NestedActionsRenderer,
NestedActionsRendererProps,
} from '@dao-dao/stateless'
import { NestedActionsEditorFormData } from '@dao-dao/types'
import { ActionComponent } from '@dao-dao/types/actions'

export type IcaExecuteData = {
chainId: string
// Set automatically once chain ID is chosen.
icaRemoteAddress: string
} & NestedActionsEditorFormData

export type IcaExecuteOptions = NestedActionsEditorOptions &
Omit<NestedActionsRendererProps, 'msgsFieldName'>

export const IcaExecuteComponent: ActionComponent<IcaExecuteOptions> = (
props
) => {
const { t } = useTranslation()
const { fieldNamePrefix, isCreating, options } = props

return (
<>
<p className="title-text -mb-1">{t('title.actions')}</p>

{isCreating ? (
<NestedActionsEditor {...props} />
) : (
<div className="flex flex-col gap-2">
<NestedActionsRenderer
{...options}
msgsFieldName={fieldNamePrefix + 'msgs'}
/>
</div>
)}
</>
)
}
29 changes: 29 additions & 0 deletions packages/stateful/actions/core/advanced/IcaExecute/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# IcaExecute

Execute messages from an ICA account.

## Bulk import format

This is relevant when bulk importing actions, as described in [this
guide](https://github.com/DA0-DA0/dao-dao-ui/wiki/Bulk-importing-actions).

### Key

`icaExecute`

### Data format

```json
{
"chainId": "<CHAIN ID>",
"_actionData": [
// ACTIONS
]
}
```

Each action in `_actionData` should be formatted similar to how bulk actions are
formatted, with `key` and `data` fields, except `key` should be replaced with
`actionKey`. Thus, each object in `_actionData` should be an object with
`actionKey` and `data`, formatted the same as the `actions` array in the bulk
JSON format.
Loading

0 comments on commit 86718ba

Please sign in to comment.