Skip to content

Commit

Permalink
chore: VTransferIBCEvent type
Browse files Browse the repository at this point in the history
- adds a VTransferIBCEvent type, for acknowledgementPacket and writeAcknowledgement events
  • Loading branch information
0xpatrickdev committed Jul 16, 2024
1 parent 764eadd commit 80d5bdf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/vats/src/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TargetAppI, AppTransformerI } from './bridge-target.js';

/**
* @import {TargetApp, TargetHost} from './bridge-target.js'
* @import {VTransferIBCEvent} from './types.js';
*/

/**
Expand Down Expand Up @@ -49,6 +50,7 @@ const prepareTransferInterceptor = (zone, vowTools) => {
}),
{
public: {
/** @param {VTransferIBCEvent} obj */
async receiveUpcall(obj) {
const { isActiveTap, tap } = this.state;

Expand Down
22 changes: 22 additions & 0 deletions packages/vats/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { FungibleTokenPacketData } from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
import type { BridgeIdValue, Remote } from '@agoric/internal';
import type { Bytes } from '@agoric/network';
import type { Guarded } from '@endo/exo';
Expand Down Expand Up @@ -264,3 +265,24 @@ type SendPacketDownCall = {
packet: IBCPacket;
relativeTimeoutNs: bigint;
};

export type VTransferIBCEvent = {
type: 'VTRANSFER_IBC_EVENT';
blockHeight: number;
blockTime: number;
/**
* Indicates the type of IBC packet event:
* - 'acknowledgementPacket': passive tap that communicates the result of an acknowledged packet
* - 'writeAcknowledgement': active tap where the receiver can return a write acknowledgement
*/
event: 'acknowledgementPacket' | 'writeAcknowledgement';
acknowledgement: Bytes;
/**
* Use `JSON.parse(atob(packet.data))` to get a
* {@link FungibleTokenPacketData} object.
*/
packet: IBCPacket;
relayer: string;
/** e.g. the chain address of the LocalChainAccount */
target: string;
};

0 comments on commit 80d5bdf

Please sign in to comment.