-
Notifications
You must be signed in to change notification settings - Fork 22
/
MsgGrantAuthorization.ts
129 lines (117 loc) 路 3.31 KB
/
MsgGrantAuthorization.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { AuthorizationGrant } from '../authorizations';
import { MsgGrant as MsgGrant_pb } from '@terra-money/terra.proto/cosmos/authz/v1beta1/tx';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { Grant as Grant_pb } from '@terra-money/terra.proto/cosmos/authz/v1beta1/authz';
export class MsgGrantAuthorization extends JSONSerializable<
MsgGrantAuthorization.Amino,
MsgGrantAuthorization.Data,
MsgGrantAuthorization.Proto
> {
/**
* @param depositor depositor's account address
* @param amount coins to fund the community pool
*/
constructor(
public granter: AccAddress,
public grantee: AccAddress,
public grant: AuthorizationGrant
) {
super();
}
public static fromAmino(
data: MsgGrantAuthorization.Amino,
isClassic?: boolean
): MsgGrantAuthorization {
const {
value: { granter, grantee, grant },
} = data;
return new MsgGrantAuthorization(
granter,
grantee,
AuthorizationGrant.fromAmino(grant, isClassic)
);
}
public toAmino(isClassic?: boolean): MsgGrantAuthorization.Amino {
const { granter, grantee, grant } = this;
return {
type: isClassic ? 'msgauth/MsgGrantAuthorization' : 'cosmos-sdk/MsgGrant',
value: {
granter,
grantee,
grant: grant.toAmino(isClassic),
},
};
}
public static fromData(
data: MsgGrantAuthorization.Data,
isClassic?: boolean
): MsgGrantAuthorization {
const { granter, grantee, grant } = data;
return new MsgGrantAuthorization(
granter,
grantee,
AuthorizationGrant.fromData(grant, isClassic)
);
}
public toData(isClassic?: boolean): MsgGrantAuthorization.Data {
const { granter, grantee, grant } = this;
return {
'@type': '/cosmos.authz.v1beta1.MsgGrant',
granter,
grantee,
grant: grant.toData(isClassic),
};
}
public static fromProto(
data: MsgGrantAuthorization.Proto,
isClassic?: boolean
): MsgGrantAuthorization {
return new MsgGrantAuthorization(
data.granter,
data.grantee,
AuthorizationGrant.fromProto(data.grant as Grant_pb, isClassic)
);
}
public toProto(isClassic?: boolean): MsgGrantAuthorization.Proto {
const { grant, granter, grantee } = this;
return MsgGrant_pb.fromPartial({
grant: grant.toProto(isClassic),
grantee,
granter,
});
}
public packAny(isClassic?: boolean): Any {
return Any.fromPartial({
typeUrl: '/cosmos.authz.v1beta1.MsgGrant',
value: MsgGrant_pb.encode(this.toProto(isClassic)).finish(),
});
}
public static unpackAny(
msgAny: Any,
isClassic?: boolean
): MsgGrantAuthorization {
return MsgGrantAuthorization.fromProto(
MsgGrant_pb.decode(msgAny.value),
isClassic
);
}
}
export namespace MsgGrantAuthorization {
export interface Amino {
type: 'msgauth/MsgGrantAuthorization' | 'cosmos-sdk/MsgGrant';
value: {
granter: AccAddress;
grantee: AccAddress;
grant: AuthorizationGrant.Amino;
};
}
export interface Data {
'@type': '/cosmos.authz.v1beta1.MsgGrant';
granter: AccAddress;
grantee: AccAddress;
grant: AuthorizationGrant.Data;
}
export type Proto = MsgGrant_pb;
}