-
Notifications
You must be signed in to change notification settings - Fork 22
/
MsgExecAuthorized.ts
115 lines (103 loc) 路 2.85 KB
/
MsgExecAuthorized.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
114
115
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Msg } from '../../Msg';
import { MsgExec as MsgExec_pb } from '@terra-money/terra.proto/cosmos/authz/v1beta1/tx';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
export class MsgExecAuthorized extends JSONSerializable<
MsgExecAuthorized.Amino,
MsgExecAuthorized.Data,
MsgExecAuthorized.Proto
> {
/**
* @param grantee authorization grantee
* @param msgs list of messages to execute
*/
constructor(public grantee: AccAddress, public msgs: Msg[]) {
super();
}
public static fromAmino(
data: MsgExecAuthorized.Amino,
isClassic?: boolean
): MsgExecAuthorized {
const {
value: { grantee, msgs },
} = data;
return new MsgExecAuthorized(
grantee,
msgs.map(x => Msg.fromAmino(x, isClassic))
);
}
public toAmino(isClassic?: boolean): MsgExecAuthorized.Amino {
const { grantee, msgs } = this;
return {
type: isClassic ? 'msgauth/MsgExecAuthorized' : 'cosmos-sdk/MsgExec',
value: {
grantee,
msgs: msgs.map(msg => {
return msg.toAmino(isClassic);
}),
},
};
}
public static fromData(
proto: MsgExecAuthorized.Data,
isClassic?: boolean
): MsgExecAuthorized {
const { grantee, msgs } = proto;
return new MsgExecAuthorized(
grantee,
msgs.map(x => Msg.fromData(x, isClassic))
);
}
public toData(isClassic?: boolean): MsgExecAuthorized.Data {
const { grantee, msgs } = this;
return {
'@type': '/cosmos.authz.v1beta1.MsgExec',
grantee,
msgs: msgs.map(msg => msg.toData(isClassic)),
};
}
public static fromProto(
proto: MsgExecAuthorized.Proto,
isClassic?: boolean
): MsgExecAuthorized {
return new MsgExecAuthorized(
proto.grantee,
proto.msgs.map(x => Msg.fromProto(x, isClassic))
);
}
public toProto(isClassic?: boolean): MsgExecAuthorized.Proto {
const { grantee, msgs } = this;
return MsgExec_pb.fromPartial({
grantee,
msgs: msgs.map(m => m.packAny(isClassic)),
});
}
public packAny(isClassic?: boolean): Any {
return Any.fromPartial({
typeUrl: '/cosmos.authz.v1beta1.MsgExec',
value: MsgExec_pb.encode(this.toProto(isClassic)).finish(),
});
}
public static unpackAny(msgAny: Any, isClassic?: boolean): MsgExecAuthorized {
return MsgExecAuthorized.fromProto(
MsgExec_pb.decode(msgAny.value),
isClassic
);
}
}
export namespace MsgExecAuthorized {
export interface Amino {
type: 'msgauth/MsgExecAuthorized' | 'cosmos-sdk/MsgExec';
value: {
grantee: AccAddress;
msgs: Msg.Amino[];
};
}
export interface Data {
'@type': '/cosmos.authz.v1beta1.MsgExec';
grantee: AccAddress;
msgs: Msg.Data[];
}
export type Proto = MsgExec_pb;
}