/
MsgChannelCloseConfirm.ts
113 lines (103 loc) · 3.2 KB
/
MsgChannelCloseConfirm.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { JSONSerializable } from '../../../../util/json';
import { AccAddress } from '../../../bech32';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { Height } from '../client/Height';
import { MsgChannelCloseConfirm as MsgChannelCloseConfirm_pb } from '@terra-money/terra.proto/ibc/core/channel/v1/tx';
/**
* MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B to acknowledge the change of channel state to CLOSED on Chain A.
*/
export class MsgChannelCloseConfirm extends JSONSerializable<
any,
MsgChannelCloseConfirm.Data,
MsgChannelCloseConfirm.Proto
> {
/**
* @param port_id identifier of the port to use
* @param channel_id
* @param proof_init
* @param proof_height
* @param signer signer address
*/
constructor(
public port_id: string,
public channel_id: string,
public proof_init: string,
public proof_height: Height | undefined,
public signer: AccAddress
) {
super();
}
public static fromAmino(_: any): MsgChannelCloseConfirm {
_;
throw new Error('Amino not supported');
}
public toAmino(): any {
throw new Error('Amino not supported');
}
public static fromData(
data: MsgChannelCloseConfirm.Data
): MsgChannelCloseConfirm {
const { port_id, channel_id, proof_init, proof_height, signer } = data;
return new MsgChannelCloseConfirm(
port_id,
channel_id,
proof_init,
proof_height ? Height.fromData(proof_height) : undefined,
signer
);
}
public toData(): MsgChannelCloseConfirm.Data {
const { port_id, channel_id, proof_init, proof_height, signer } = this;
return {
'@type': '/ibc.core.channel.v1.MsgChannelCloseConfirm',
port_id,
channel_id,
proof_init,
proof_height: proof_height ? proof_height.toData() : undefined,
signer,
};
}
public static fromProto(
proto: MsgChannelCloseConfirm.Proto
): MsgChannelCloseConfirm {
return new MsgChannelCloseConfirm(
proto.portId,
proto.channelId,
Buffer.from(proto.proofInit).toString('base64'),
proto.proofHeight ? Height.fromProto(proto.proofHeight) : undefined,
proto.signer
);
}
public toProto(): MsgChannelCloseConfirm.Proto {
const { port_id, channel_id, proof_init, proof_height, signer } = this;
return MsgChannelCloseConfirm_pb.fromPartial({
portId: port_id,
channelId: channel_id,
proofInit: Buffer.from(proof_init, 'base64'),
proofHeight: proof_height ? proof_height.toProto() : undefined,
signer,
});
}
public packAny(): Any {
return Any.fromPartial({
typeUrl: '/ibc.core.channel.v1.MsgChannelCloseConfirm',
value: MsgChannelCloseConfirm_pb.encode(this.toProto()).finish(),
});
}
public static unpackAny(msgAny: Any): MsgChannelCloseConfirm {
return MsgChannelCloseConfirm.fromProto(
MsgChannelCloseConfirm_pb.decode(msgAny.value)
);
}
}
export namespace MsgChannelCloseConfirm {
export interface Data {
'@type': '/ibc.core.channel.v1.MsgChannelCloseConfirm';
port_id: string;
channel_id: string;
proof_init: string;
proof_height?: Height.Data;
signer: AccAddress;
}
export type Proto = MsgChannelCloseConfirm_pb;
}