Skip to content

Commit 9410535

Browse files
authored
Added vesting types (#33)
* Fixed download script * Added vesting module to registry * Uncommitted vesting changes
1 parent 0fab782 commit 9410535

File tree

8 files changed

+231
-4
lines changed

8 files changed

+231
-4
lines changed

scripts/get-proto.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ IBC_SDK_DIR="$IBC_DIR/ibc-go"
3434
IBC_ZIP_FILE="$IBC_DIR/tmp.zip"
3535

3636
# Init IBC REF
37-
IBC_REF=${IBC_REF:-"master"}
37+
IBC_REF=${IBC_REF:-"main"}
3838
IBC_SUFFIX=${IBC_REF}
3939
[[ $IBC_SUFFIX =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]] && IBC_SUFFIX=${IBC_SUFFIX#v}
4040

src/codec/cosmos/vesting/v1beta1/tx.ts

Lines changed: 182 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable */
22
import Long from 'long';
33
import _m0 from 'protobufjs/minimal';
4-
import { Coin } from '../../../cosmos/base/v1beta1/coin';
4+
import { Coin } from "../../base/v1beta1/coin";
5+
import { Period } from "./vesting";
56

67
export const protobufPackage = 'cosmos.vesting.v1beta1';
78

@@ -20,6 +21,23 @@ export interface MsgCreateVestingAccount {
2021
/** MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. */
2122
export interface MsgCreateVestingAccountResponse {}
2223

24+
/**
25+
* MsgCreateVestingAccount defines a message that enables creating a vesting
26+
* account.
27+
*/
28+
export interface MsgCreatePeriodicVestingAccount {
29+
fromAddress: string;
30+
toAddress: string;
31+
startTime: Long;
32+
vestingPeriods: Period[];
33+
}
34+
35+
/**
36+
* MsgCreateVestingAccountResponse defines the Msg/CreatePeriodicVestingAccount
37+
* response type.
38+
*/
39+
export interface MsgCreatePeriodicVestingAccountResponse {}
40+
2341
const baseMsgCreateVestingAccount: object = { fromAddress: '', toAddress: '', endTime: Long.ZERO, delayed: false };
2442

2543
export const MsgCreateVestingAccount = {
@@ -188,26 +206,189 @@ export const MsgCreateVestingAccountResponse = {
188206
},
189207
};
190208

209+
const baseMsgCreatePeriodicVestingAccount: object = { fromAddress: '', toAddress: '', startTime: Long.ZERO };
210+
211+
export const MsgCreatePeriodicVestingAccount = {
212+
encode(message: MsgCreatePeriodicVestingAccount, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
213+
if (message.fromAddress !== '') {
214+
writer.uint32(10).string(message.fromAddress);
215+
}
216+
if (message.toAddress !== '') {
217+
writer.uint32(18).string(message.toAddress);
218+
}
219+
if (!message.startTime.isZero()) {
220+
writer.uint32(24).int64(message.startTime);
221+
}
222+
for (const v of message.vestingPeriods) {
223+
Period.encode(v!, writer.uint32(34).fork()).ldelim();
224+
}
225+
return writer;
226+
},
227+
228+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgCreatePeriodicVestingAccount {
229+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
230+
let end = length === undefined ? reader.len : reader.pos + length;
231+
const message = { ...baseMsgCreatePeriodicVestingAccount } as MsgCreatePeriodicVestingAccount;
232+
message.vestingPeriods = [];
233+
while (reader.pos < end) {
234+
const tag = reader.uint32();
235+
switch (tag >>> 3) {
236+
case 1:
237+
message.fromAddress = reader.string();
238+
break;
239+
case 2:
240+
message.toAddress = reader.string();
241+
break;
242+
case 3:
243+
message.startTime = reader.int64() as Long;
244+
break;
245+
case 4:
246+
message.vestingPeriods.push(Period.decode(reader, reader.uint32()));
247+
break;
248+
default:
249+
reader.skipType(tag & 7);
250+
break;
251+
}
252+
}
253+
return message;
254+
},
255+
256+
fromJSON(object: any): MsgCreatePeriodicVestingAccount {
257+
const message = { ...baseMsgCreatePeriodicVestingAccount } as MsgCreatePeriodicVestingAccount;
258+
message.vestingPeriods = [];
259+
if (object.fromAddress !== undefined && object.fromAddress !== null) {
260+
message.fromAddress = String(object.fromAddress);
261+
} else {
262+
message.fromAddress = '';
263+
}
264+
if (object.toAddress !== undefined && object.toAddress !== null) {
265+
message.toAddress = String(object.toAddress);
266+
} else {
267+
message.toAddress = '';
268+
}
269+
if (object.startTime !== undefined && object.startTime !== null) {
270+
message.startTime = Long.fromString(object.startTime);
271+
} else {
272+
message.startTime = Long.ZERO;
273+
}
274+
if (object.vestingPeriods !== undefined && object.vestingPeriods !== null) {
275+
for (const e of object.vestingPeriods) {
276+
message.vestingPeriods.push(Period.fromJSON(e));
277+
}
278+
}
279+
return message;
280+
},
281+
282+
toJSON(message: MsgCreatePeriodicVestingAccount): unknown {
283+
const obj: any = {};
284+
message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress);
285+
message.toAddress !== undefined && (obj.toAddress = message.toAddress);
286+
message.startTime !== undefined && (obj.startTime = (message.startTime || Long.ZERO).toString());
287+
if (message.vestingPeriods) {
288+
obj.vestingPeriods = message.vestingPeriods.map((e) => (e ? Period.toJSON(e) : undefined));
289+
} else {
290+
obj.vestingPeriods = [];
291+
}
292+
return obj;
293+
},
294+
295+
fromPartial(object: DeepPartial<MsgCreatePeriodicVestingAccount>): MsgCreatePeriodicVestingAccount {
296+
const message = { ...baseMsgCreatePeriodicVestingAccount } as MsgCreatePeriodicVestingAccount;
297+
message.vestingPeriods = [];
298+
if (object.fromAddress !== undefined && object.fromAddress !== null) {
299+
message.fromAddress = object.fromAddress;
300+
} else {
301+
message.fromAddress = '';
302+
}
303+
if (object.toAddress !== undefined && object.toAddress !== null) {
304+
message.toAddress = object.toAddress;
305+
} else {
306+
message.toAddress = '';
307+
}
308+
if (object.startTime !== undefined && object.startTime !== null) {
309+
message.startTime = object.startTime as Long;
310+
} else {
311+
message.startTime = Long.ZERO;
312+
}
313+
if (object.vestingPeriods !== undefined && object.vestingPeriods !== null) {
314+
for (const e of object.vestingPeriods) {
315+
message.vestingPeriods.push(Period.fromPartial(e));
316+
}
317+
}
318+
return message;
319+
},
320+
};
321+
322+
const baseMsgCreatePeriodicVestingAccountResponse: object = {};
323+
324+
export const MsgCreatePeriodicVestingAccountResponse = {
325+
encode(_: MsgCreatePeriodicVestingAccountResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
326+
return writer;
327+
},
328+
329+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgCreatePeriodicVestingAccountResponse {
330+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
331+
let end = length === undefined ? reader.len : reader.pos + length;
332+
const message = { ...baseMsgCreatePeriodicVestingAccountResponse } as MsgCreatePeriodicVestingAccountResponse;
333+
while (reader.pos < end) {
334+
const tag = reader.uint32();
335+
switch (tag >>> 3) {
336+
default:
337+
reader.skipType(tag & 7);
338+
break;
339+
}
340+
}
341+
return message;
342+
},
343+
344+
fromJSON(_: any): MsgCreatePeriodicVestingAccountResponse {
345+
const message = { ...baseMsgCreatePeriodicVestingAccountResponse } as MsgCreatePeriodicVestingAccountResponse;
346+
return message;
347+
},
348+
349+
toJSON(_: MsgCreatePeriodicVestingAccountResponse): unknown {
350+
const obj: any = {};
351+
return obj;
352+
},
353+
354+
fromPartial(_: DeepPartial<MsgCreatePeriodicVestingAccountResponse>): MsgCreatePeriodicVestingAccountResponse {
355+
const message = { ...baseMsgCreatePeriodicVestingAccountResponse } as MsgCreatePeriodicVestingAccountResponse;
356+
return message;
357+
},
358+
};
359+
191360
/** Msg defines the bank Msg service. */
192361
export interface Msg {
193362
/**
194363
* CreateVestingAccount defines a method that enables creating a vesting
195364
* account.
196365
*/
197366
CreateVestingAccount(request: MsgCreateVestingAccount): Promise<MsgCreateVestingAccountResponse>;
367+
/**
368+
* CreatePeriodicVestingAccount defines a method that enables creating a
369+
* periodic vesting account.
370+
*/
371+
CreatePeriodicVestingAccount(request: MsgCreatePeriodicVestingAccount): Promise<MsgCreatePeriodicVestingAccountResponse>;
198372
}
199373

200374
export class MsgClientImpl implements Msg {
201375
private readonly rpc: Rpc;
202376
constructor(rpc: Rpc) {
203377
this.rpc = rpc;
204378
this.CreateVestingAccount = this.CreateVestingAccount.bind(this);
379+
this.CreatePeriodicVestingAccount = this.CreatePeriodicVestingAccount.bind(this);
205380
}
206381
CreateVestingAccount(request: MsgCreateVestingAccount): Promise<MsgCreateVestingAccountResponse> {
207382
const data = MsgCreateVestingAccount.encode(request).finish();
208383
const promise = this.rpc.request('cosmos.vesting.v1beta1.Msg', 'CreateVestingAccount', data);
209384
return promise.then((data) => MsgCreateVestingAccountResponse.decode(new _m0.Reader(data)));
210385
}
386+
387+
CreatePeriodicVestingAccount(request: MsgCreatePeriodicVestingAccount): Promise<MsgCreatePeriodicVestingAccountResponse> {
388+
const data = MsgCreatePeriodicVestingAccount.encode(request).finish();
389+
const promise = this.rpc.request('cosmos.vesting.v1beta1.Msg', 'CreatePeriodicVestingAccount', data);
390+
return promise.then((data) => MsgCreatePeriodicVestingAccountResponse.decode(new _m0.Reader(data)));
391+
}
211392
}
212393

213394
interface Rpc {

src/codec/cosmos/vesting/v1beta1/vesting.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable */
22
import Long from 'long';
33
import _m0 from 'protobufjs/minimal';
4-
import { BaseAccount } from '../../../cosmos/auth/v1beta1/auth';
5-
import { Coin } from '../../../cosmos/base/v1beta1/coin';
4+
import { BaseAccount } from "../../auth/v1beta1/auth";
5+
import { Coin } from "../../base/v1beta1/coin";
66

77
export const protobufPackage = 'cosmos.vesting.v1beta1';
88

@@ -56,6 +56,8 @@ export interface PeriodicVestingAccount {
5656
* PermanentLockedAccount implements the VestingAccount interface. It does
5757
* not ever release coins, locking them indefinitely. Coins in this account can
5858
* still be used for delegating and for governance votes even while locked.
59+
*
60+
* Since: cosmos-sdk 0.43
5961
*/
6062
export interface PermanentLockedAccount {
6163
baseVestingAccount?: BaseVestingAccount;

src/messages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export * from './gov';
77
export * from './authz';
88
export * from './feegrant';
99
export * from './slashing';
10+
export * from './vesting';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Long from 'long';
2+
import { Message } from '../Message';
3+
4+
import { MsgCreatePeriodicVestingAccount } from '../../codec/cosmos/vesting/v1beta1/tx';
5+
import { Period } from '../../codec/cosmos/vesting/v1beta1/vesting';
6+
7+
export const MsgCreatePeriodicVestingAccountUrl = '/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount';
8+
9+
export const BuildMsgCreatePeriodicVestingAccount = (fromAddress: string, toAddress: string, startTime: Long, vestingPeriods: Period[]): Message => {
10+
return {
11+
typeUrl: MsgCreatePeriodicVestingAccountUrl,
12+
value: {
13+
fromAddress,
14+
toAddress,
15+
startTime,
16+
vestingPeriods,
17+
} as MsgCreatePeriodicVestingAccount,
18+
};
19+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Message } from '../Message';
2+
import { MsgCreateVestingAccount } from '../../codec/cosmos/vesting/v1beta1/tx';
3+
import { Coin } from '../../types';
4+
import Long from 'long';
5+
6+
export const MsgCreateVestingAccountUrl = '/cosmos.vesting.v1beta1.MsgCreateVestingAccount';
7+
8+
export const BuildMsgCreateVestingAccount = (fromAddress: string, toAddress: string, amount: Coin[], endTime: Long, delayed: boolean): Message => {
9+
return {
10+
typeUrl: MsgCreateVestingAccountUrl,
11+
value: {
12+
fromAddress,
13+
toAddress,
14+
amount,
15+
endTime,
16+
delayed,
17+
} as MsgCreateVestingAccount,
18+
};
19+
};

src/messages/vesting/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './MsgCreatePeriodicVestingAccount';
2+
export * from './MsgCreateVestingAccount';

src/registry/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ParameterChangeProposal } from '../codec/cosmos/params/v1beta1/params';
1616
import { MsgUnjail } from '../codec/cosmos/slashing/v1beta1/tx';
1717
import { MsgBeginRedelegate, MsgCreateValidator, MsgDelegate, MsgEditValidator, MsgUndelegate } from '../codec/cosmos/staking/v1beta1/tx';
1818
import { CancelSoftwareUpgradeProposal, SoftwareUpgradeProposal } from '../codec/cosmos/upgrade/v1beta1/upgrade';
19+
import { MsgCreatePeriodicVestingAccount, MsgCreateVestingAccount } from '../codec/cosmos/vesting/v1beta1/tx';
1920

2021
import {
2122
MsgAcknowledgement,
@@ -72,6 +73,8 @@ const registryTypes: Iterable<[string, GeneratedType]> = [
7273
['/cosmos.staking.v1beta1.MsgUndelegate', MsgUndelegate],
7374
['/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal', SoftwareUpgradeProposal],
7475
['/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal', CancelSoftwareUpgradeProposal],
76+
['/cosmos.vesting.v1beta1.MsgCreateVestingAccount', MsgCreateVestingAccount],
77+
['/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount', MsgCreatePeriodicVestingAccount],
7578
['/ibc.core.channel.v1.MsgChannelOpenInit', MsgChannelOpenInit],
7679
['/ibc.core.channel.v1.MsgChannelOpenTry', MsgChannelOpenTry],
7780
['/ibc.core.channel.v1.MsgChannelOpenAck', MsgChannelOpenAck],

0 commit comments

Comments
 (0)