Skip to content

Commit d3c0b7e

Browse files
authored
Merge pull request #55 from initia-labs/feat/ibc
fix: can make do ibc relaying
2 parents 7494f14 + f8fa34d commit d3c0b7e

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

src/client/lcd/api/IbcAPI.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,32 @@ export class IbcAPI extends BaseAPI {
229229
d.pagination,
230230
]);
231231
}
232+
233+
public async unreceivedPackets(
234+
portId: string,
235+
channelId: string,
236+
sequences: number[],
237+
params: APIParams = {}
238+
): Promise<{ sequences: string[]; height: Height }> {
239+
return this.c.get<{ sequences: string[]; height: Height }>(
240+
`/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${sequences.join(
241+
','
242+
)}/unreceived_packets`,
243+
params
244+
);
245+
}
246+
247+
public async unreceivedAcks(
248+
portId: string,
249+
channelId: string,
250+
sequences: number[],
251+
params: APIParams = {}
252+
): Promise<{ sequences: string[]; height: Height }> {
253+
return this.c.get<{ sequences: string[]; height: Height }>(
254+
`/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${sequences.join(
255+
','
256+
)}/unreceived_acks`,
257+
params
258+
);
259+
}
232260
}

src/core/Block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface LastCommit {
6060
}
6161

6262
export interface Signature {
63-
block_id_flag: number;
63+
block_id_flag: string;
6464
validator_address: string;
6565
timestamp: string;
6666
signature: string;

src/core/ibc/core/channel/Packet.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class Packet extends JSONSerializable<
2121
public destination_channel: string,
2222
public data: string,
2323
public timeout_height: Height | undefined,
24-
public timeout_timestamp: number
24+
public timeout_timestamp: string
2525
) {
2626
super();
2727
}
@@ -92,7 +92,7 @@ export class Packet extends JSONSerializable<
9292
destination_channel,
9393
data,
9494
timeout_height ? Height.fromData(timeout_height) : undefined,
95-
Number.parseInt(timeout_timestamp)
95+
timeout_timestamp
9696
);
9797
}
9898

@@ -115,7 +115,7 @@ export class Packet extends JSONSerializable<
115115
destination_channel,
116116
data,
117117
timeout_height: timeout_height?.toData(),
118-
timeout_timestamp: timeout_timestamp.toFixed(),
118+
timeout_timestamp: timeout_timestamp,
119119
};
120120
return res;
121121
}
@@ -129,7 +129,7 @@ export class Packet extends JSONSerializable<
129129
proto.destinationChannel,
130130
Buffer.from(proto.data).toString('base64'),
131131
proto.timeoutHeight ? Height.fromProto(proto.timeoutHeight) : undefined,
132-
proto.timeoutTimestamp.toNumber()
132+
proto.timeoutTimestamp.toString()
133133
);
134134
}
135135

@@ -152,7 +152,7 @@ export class Packet extends JSONSerializable<
152152
destinationChannel: destination_channel,
153153
data: Buffer.from(data, 'base64'),
154154
timeoutHeight: timeout_height?.toProto(),
155-
timeoutTimestamp: Long.fromNumber(timeout_timestamp),
155+
timeoutTimestamp: Long.fromString(timeout_timestamp),
156156
});
157157
}
158158
}
@@ -166,7 +166,7 @@ export namespace Packet {
166166
destination_channel: string;
167167
data: string;
168168
timeout_height?: Height.Amino;
169-
timeout_timestamp: number;
169+
timeout_timestamp: string;
170170
}
171171

172172
export interface Data {

src/core/ibc/core/client/msgs/tendermint/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class Header extends JSONSerializable<any, Header.Data, Header.Proto> {
154154
Buffer.from(appHash).toString('base64'),
155155
Buffer.from(lastResultsHash).toString('base64'),
156156
Buffer.from(evidenceHash).toString('base64'),
157-
proposerAddress.toString()
157+
Buffer.from(proposerAddress).toString('base64')
158158
);
159159
}
160160

@@ -189,7 +189,7 @@ export class Header extends JSONSerializable<any, Header.Data, Header.Proto> {
189189
appHash: Buffer.from(appHash, 'base64'),
190190
lastResultsHash: Buffer.from(lastResultsHash, 'base64'),
191191
evidenceHash: Buffer.from(evidenceHash, 'base64'),
192-
proposerAddress: Buffer.from(proposerAddress),
192+
proposerAddress: Buffer.from(proposerAddress, 'base64'),
193193
});
194194
}
195195
}

0 commit comments

Comments
 (0)