|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import { ExecuteInstruction } from '@cosmjs/cosmwasm-stargate'; |
|
|
|
|
|
|
|
|
|
import { Address, HexString } from '@hyperlane-xyz/utils'; |
|
|
|
|
import { Address, HexString, assert, ensure0x } from '@hyperlane-xyz/utils'; |
|
|
|
|
|
|
|
|
|
import { BaseCosmWasmAdapter } from '../../app/MultiProtocolApp'; |
|
|
|
|
import { |
|
|
|
@ -24,6 +24,11 @@ import { ChainName } from '../../types'; |
|
|
|
|
|
|
|
|
|
import { ICoreAdapter } from './types'; |
|
|
|
|
|
|
|
|
|
const MESSAGE_DISPATCH_EVENT_TYPE = 'wasm-mailbox_dispatch'; |
|
|
|
|
const MESSAGE_DISPATCH_ID_EVENT_TYPE = 'wasm-mailbox_dispatch_id'; |
|
|
|
|
const MESSAGE_ID_ATTRIBUTE_KEY = 'message_id'; |
|
|
|
|
const MESSAGE_DESTINATION_ATTRIBUTE_KEY = 'destination'; |
|
|
|
|
|
|
|
|
|
type MailboxResponse = |
|
|
|
|
| DefaultHookResponse |
|
|
|
|
| RequiredHookResponse |
|
|
|
@ -169,8 +174,32 @@ export class CosmWasmCoreAdapter |
|
|
|
|
`Unsupported provider type for CosmosCoreAdapter ${sourceTx.type}`, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
// TODO: parse mailbox logs and extract message ids
|
|
|
|
|
throw new Error('Method not implemented.'); |
|
|
|
|
const dispatchIdEvents = sourceTx.receipt.events.filter( |
|
|
|
|
(e) => e.type === MESSAGE_DISPATCH_ID_EVENT_TYPE, |
|
|
|
|
); |
|
|
|
|
const dispatchEvents = sourceTx.receipt.events.filter( |
|
|
|
|
(e) => e.type === MESSAGE_DISPATCH_EVENT_TYPE, |
|
|
|
|
); |
|
|
|
|
assert( |
|
|
|
|
dispatchIdEvents.length === dispatchEvents.length, |
|
|
|
|
'Mismatched dispatch and dispatch id events', |
|
|
|
|
); |
|
|
|
|
const result: Array<{ messageId: string; destination: ChainName }> = []; |
|
|
|
|
for (let i = 0; i < dispatchIdEvents.length; i++) { |
|
|
|
|
const idAttribute = dispatchIdEvents[i].attributes.find( |
|
|
|
|
(a) => a.key === MESSAGE_ID_ATTRIBUTE_KEY, |
|
|
|
|
); |
|
|
|
|
const destAttribute = dispatchEvents[i].attributes.find( |
|
|
|
|
(a) => a.key === MESSAGE_DESTINATION_ATTRIBUTE_KEY, |
|
|
|
|
); |
|
|
|
|
assert(idAttribute, 'No message id attribute found in dispatch event'); |
|
|
|
|
assert(destAttribute, 'No destination attribute found in dispatch event'); |
|
|
|
|
result.push({ |
|
|
|
|
messageId: ensure0x(idAttribute.value), |
|
|
|
|
destination: this.multiProvider.getChainName(destAttribute.value), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async waitForMessageProcessed( |
|
|
|
|