Skip to content

Commit

Permalink
Merge pull request #55 from initia-labs/feat/ibc
Browse files Browse the repository at this point in the history
fix: can make do ibc relaying
  • Loading branch information
joon9823 authored May 24, 2024
2 parents 7494f14 + f8fa34d commit d3c0b7e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
28 changes: 28 additions & 0 deletions src/client/lcd/api/IbcAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,32 @@ export class IbcAPI extends BaseAPI {
d.pagination,
]);
}

public async unreceivedPackets(
portId: string,
channelId: string,
sequences: number[],
params: APIParams = {}
): Promise<{ sequences: string[]; height: Height }> {
return this.c.get<{ sequences: string[]; height: Height }>(
`/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${sequences.join(
','
)}/unreceived_packets`,
params
);
}

public async unreceivedAcks(
portId: string,
channelId: string,
sequences: number[],
params: APIParams = {}
): Promise<{ sequences: string[]; height: Height }> {
return this.c.get<{ sequences: string[]; height: Height }>(
`/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${sequences.join(
','
)}/unreceived_acks`,
params
);
}
}
2 changes: 1 addition & 1 deletion src/core/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface LastCommit {
}

export interface Signature {
block_id_flag: number;
block_id_flag: string;
validator_address: string;
timestamp: string;
signature: string;
Expand Down
12 changes: 6 additions & 6 deletions src/core/ibc/core/channel/Packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Packet extends JSONSerializable<
public destination_channel: string,
public data: string,
public timeout_height: Height | undefined,
public timeout_timestamp: number
public timeout_timestamp: string
) {
super();
}
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Packet extends JSONSerializable<
destination_channel,
data,
timeout_height ? Height.fromData(timeout_height) : undefined,
Number.parseInt(timeout_timestamp)
timeout_timestamp
);
}

Expand All @@ -115,7 +115,7 @@ export class Packet extends JSONSerializable<
destination_channel,
data,
timeout_height: timeout_height?.toData(),
timeout_timestamp: timeout_timestamp.toFixed(),
timeout_timestamp: timeout_timestamp,
};
return res;
}
Expand All @@ -129,7 +129,7 @@ export class Packet extends JSONSerializable<
proto.destinationChannel,
Buffer.from(proto.data).toString('base64'),
proto.timeoutHeight ? Height.fromProto(proto.timeoutHeight) : undefined,
proto.timeoutTimestamp.toNumber()
proto.timeoutTimestamp.toString()
);
}

Expand All @@ -152,7 +152,7 @@ export class Packet extends JSONSerializable<
destinationChannel: destination_channel,
data: Buffer.from(data, 'base64'),
timeoutHeight: timeout_height?.toProto(),
timeoutTimestamp: Long.fromNumber(timeout_timestamp),
timeoutTimestamp: Long.fromString(timeout_timestamp),
});
}
}
Expand All @@ -166,7 +166,7 @@ export namespace Packet {
destination_channel: string;
data: string;
timeout_height?: Height.Amino;
timeout_timestamp: number;
timeout_timestamp: string;
}

export interface Data {
Expand Down
4 changes: 2 additions & 2 deletions src/core/ibc/core/client/msgs/tendermint/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class Header extends JSONSerializable<any, Header.Data, Header.Proto> {
Buffer.from(appHash).toString('base64'),
Buffer.from(lastResultsHash).toString('base64'),
Buffer.from(evidenceHash).toString('base64'),
proposerAddress.toString()
Buffer.from(proposerAddress).toString('base64')
);
}

Expand Down Expand Up @@ -189,7 +189,7 @@ export class Header extends JSONSerializable<any, Header.Data, Header.Proto> {
appHash: Buffer.from(appHash, 'base64'),
lastResultsHash: Buffer.from(lastResultsHash, 'base64'),
evidenceHash: Buffer.from(evidenceHash, 'base64'),
proposerAddress: Buffer.from(proposerAddress),
proposerAddress: Buffer.from(proposerAddress, 'base64'),
});
}
}
Expand Down

0 comments on commit d3c0b7e

Please sign in to comment.