Skip to content

Commit 1d61eaa

Browse files
authored
Added vesting types, bumped dependencies and fixed download script (#34)
* Upgrade coin type * Added vesting types (#33) * Fixed download script * Added vesting module to registry * Uncommitted vesting changes * Bumpd version and dependencies
1 parent 9b51fcd commit 1d61eaa

File tree

14 files changed

+1454
-897
lines changed

14 files changed

+1454
-897
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ console.log(`Wallet address: ${wallet.getAddress()}`);
6161

6262
**IMPORTANT NOTES:**
6363
- Transaction signature using Ledger only works with legacy amino (wich will be deprecated at some point)
64-
- Derivation path using the Cosmos Ledger application cannot be set to the default Lum Path for now `m/44'/837'/0'/*/*` and must remain on the Cosmos path `m/44'/'118/0'/*/*`
64+
- Derivation path using the Cosmos Ledger application cannot be set to the default Lum Path for now `m/44'/880'/0'/*/*` and must remain on the Cosmos path `m/44'/'118/0'/*/*`
6565

6666
#### Ledger
6767

docs/lib/modules/lumconstants.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
### HDPath
3232

33-
**HDPath**: ``"m/44'/837'/0'/"``
33+
**HDPath**: ``"m/44'/880'/0'/"``
3434

3535
Lum Network HDPath
3636

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lum-network/sdk-javascript",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"license": "Apache-2.0",
55
"description": "Javascript SDK library for NodeJS and Web browsers to interact with the Lum Network.",
66
"homepage": "https://github.com/lum-network/sdk-javascript#readme",
@@ -40,15 +40,15 @@
4040
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
4141
},
4242
"dependencies": {
43-
"@cosmjs/crypto": "^0.26.0",
44-
"@cosmjs/encoding": "^0.26.0",
45-
"@cosmjs/math": "^0.26.0",
46-
"@cosmjs/proto-signing": "^0.26.0",
47-
"@cosmjs/stargate": "^0.26.0",
48-
"@cosmjs/tendermint-rpc": "^0.26.0",
49-
"@cosmjs/utils": "^0.26.0",
50-
"@ledgerhq/hw-app-cosmos": "^6.7.0",
51-
"@ledgerhq/hw-transport": "^6.7.0",
43+
"@cosmjs/crypto": "^0.26.4",
44+
"@cosmjs/encoding": "^0.26.4",
45+
"@cosmjs/math": "^0.26.4",
46+
"@cosmjs/proto-signing": "^0.26.4",
47+
"@cosmjs/stargate": "^0.26.4",
48+
"@cosmjs/tendermint-rpc": "^0.26.4",
49+
"@cosmjs/utils": "^0.26.4",
50+
"@ledgerhq/hw-app-cosmos": "^6.11.2",
51+
"@ledgerhq/hw-transport": "^6.11.2",
5252
"@types/crypto-js": "^4.0.2",
5353
"@types/ledgerhq__hw-transport": "^4.21.4",
5454
"@types/uuid": "^8.3.1",
@@ -59,26 +59,26 @@
5959
},
6060
"optionalDependencies": {},
6161
"devDependencies": {
62-
"@babel/cli": "^7.15.7",
63-
"@babel/core": "^7.15.5",
64-
"@babel/plugin-proposal-class-properties": "^7.14.5",
65-
"@babel/plugin-transform-runtime": "^7.12.10",
66-
"@babel/preset-env": "^7.15.0",
67-
"@babel/preset-typescript": "^7.15.0",
68-
"@ledgerhq/hw-transport-node-hid": "^6.7.0",
69-
"@types/jest": "^27.0.1",
62+
"@babel/cli": "^7.16.0",
63+
"@babel/core": "^7.16.0",
64+
"@babel/plugin-proposal-class-properties": "^7.16.0",
65+
"@babel/plugin-transform-runtime": "^7.16.0",
66+
"@babel/preset-env": "^7.16.0",
67+
"@babel/preset-typescript": "^7.16.0",
68+
"@ledgerhq/hw-transport-node-hid": "^6.11.2",
69+
"@types/jest": "^27.0.2",
7070
"@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
7171
"axios": "^0.21.4",
7272
"cross-env": "^7.0.3",
7373
"eslint": "^7.19.0",
7474
"gts": "^3.1.0",
75-
"jest": "^27.2.0",
75+
"jest": "^27.3.1",
7676
"prettier": "^2.4.1",
7777
"rimraf": "^3.0.2",
78-
"ts-jest": "^27.0.5",
79-
"ts-proto": "^1.83.1",
80-
"typedoc": "^0.22.4",
81-
"typedoc-plugin-markdown": "^3.11.0",
82-
"typescript": "^4.4.3"
78+
"ts-jest": "^27.0.7",
79+
"ts-proto": "^1.85.0",
80+
"typedoc": "^0.22.9",
81+
"typedoc-plugin-markdown": "^3.11.6",
82+
"typescript": "^4.4.4"
8383
}
8484
}

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/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const LumBech32PrefixConsPub = 'lumvalconspub';
5050
* @see https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
5151
* @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
5252
*/
53-
export const HDPath = "m/44'/837'/0'/";
53+
export const HDPath = "m/44'/880'/0'/";
5454

5555
/**
5656
* Get a Lum Network HDPath for a specified account index

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+
};

0 commit comments

Comments
 (0)