Skip to content

Commit f9bea19

Browse files
author
Fabrice Bascoulergue
authored
Bring changes to production (#26)
* Add mint capabilities to client (#25) * Improve ledger test implementation and documentation (#24) * Improve ledger test implem and documentation * Use node 14 LTS as base for CICD * Bump version to 0.4.9
1 parent ef7e65a commit f9bea19

File tree

14 files changed

+1286
-58
lines changed

14 files changed

+1286
-58
lines changed

.github/workflows/merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
node-version: [12.x]
16+
node-version: [14.x]
1717

1818
steps:
1919
- name: Checkout code

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node-version: [10.x, 12.x, 14.x, 15.x]
17+
node-version: [14.x]
1818

1919
env:
2020
CLOUDSDK_CORE_PROJECT: dev

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ Directly importing the CosmJS SDK or other cryptographic library should be consi
7272

7373
Do not hesitate to contribute to this repository. This SDK is intended to be a one-stop-shop for all Lum Network javascript implementations and should definitely be improved over time by all its users.
7474

75+
### Unittests
76+
77+
#### All unittests except the ones involving a Ledger device (skipped by default) can be run using the following command
78+
79+
```bash
80+
yarn test
81+
```
82+
83+
#### Ledger unittests
84+
85+
In order to run the unittest involving Ledger devices you need to do the following:
86+
87+
1. Chose which application you want to use for the tests (Cosmos or Lum)
88+
2. Remove the `.skip` from all the tests your want to run in `./tests/ledger.test.ts`
89+
3. Connect a Ledger device and open either the Cosmos application or the Lum application
90+
4. Run `yarn test tests/ledger.test.ts`
91+
5. Follow the instructions on your Ledger device to pass each test that require a user input
92+
7593
## Protocol Buffer Codecs
7694

7795
### Introduction

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lum-network/sdk-javascript",
3-
"version": "0.4.8",
3+
"version": "0.4.9",
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",
@@ -65,6 +65,7 @@
6565
"@babel/plugin-transform-runtime": "^7.12.10",
6666
"@babel/preset-env": "^7.8.3",
6767
"@babel/preset-typescript": "^7.8.3",
68+
"@ledgerhq/hw-transport-node-hid": "^6.6.0",
6869
"@types/jest": "^26.0.20",
6970
"@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
7071
"axios": "^0.21.1",

scripts/define-proto.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ protoc \
3939
"$COSMOS_PROTO_DIR/cosmos/gov/v1beta1/query.proto" \
4040
"$COSMOS_PROTO_DIR/cosmos/gov/v1beta1/gov.proto" \
4141
"$COSMOS_PROTO_DIR/cosmos/gov/v1beta1/tx.proto" \
42+
"$COSMOS_PROTO_DIR/cosmos/mint/v1beta1/query.proto" \
43+
"$COSMOS_PROTO_DIR/cosmos/mint/v1beta1/mint.proto" \
4244
"$COSMOS_PROTO_DIR/cosmos/tx/signing/v1beta1/signing.proto" \
4345
"$COSMOS_PROTO_DIR/cosmos/tx/v1beta1/tx.proto" \
4446
"$COSMOS_PROTO_DIR/cosmos/vesting/v1beta1/vesting.proto" \

src/client/LumClient.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Uint64 } from '@cosmjs/math';
21
import { Tendermint34Client, StatusResponse } from '@cosmjs/tendermint-rpc';
32
import {
43
QueryClient as StargateQueryClient,
@@ -15,13 +14,12 @@ import {
1514
accountFromAny,
1615
} from '@cosmjs/stargate';
1716

18-
import { BaseAccount } from '../codec/cosmos/auth/v1beta1/auth';
19-
import { LumWallet, LumUtils, LumTypes, LumRegistry } from '..';
20-
import { BeamExtension, setupBeamExtension as BeamSetupBeamExtension } from '../extensions';
17+
import { LumWallet, LumUtils, LumTypes } from '..';
18+
import { BeamExtension, setupBeamExtension as BeamSetupBeamExtension, MintExtension, setupMintExtension as MintSetupExtension } from '../extensions';
2119

2220
export class LumClient {
2321
readonly tmClient: Tendermint34Client;
24-
readonly queryClient: StargateQueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & GovExtension & BeamExtension;
22+
readonly queryClient: StargateQueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & GovExtension & MintExtension & BeamExtension;
2523
private chainId?: string;
2624

2725
/**
@@ -38,6 +36,7 @@ export class LumClient {
3836
StargateDistributionExtension,
3937
StargateStakingExtension,
4038
StargateGovExtension,
39+
MintSetupExtension,
4140
BeamSetupBeamExtension,
4241
);
4342

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
/* eslint-disable */
2+
import Long from 'long';
3+
import _m0 from 'protobufjs/minimal';
4+
5+
export const protobufPackage = 'cosmos.mint.v1beta1';
6+
7+
/** Minter represents the minting state. */
8+
export interface Minter {
9+
/** current annual inflation rate */
10+
inflation: string;
11+
/** current annual expected provisions */
12+
annualProvisions: string;
13+
}
14+
15+
/** Params holds parameters for the mint module. */
16+
export interface Params {
17+
/** type of coin to mint */
18+
mintDenom: string;
19+
/** maximum annual change in inflation rate */
20+
inflationRateChange: string;
21+
/** maximum inflation rate */
22+
inflationMax: string;
23+
/** minimum inflation rate */
24+
inflationMin: string;
25+
/** goal of percent bonded atoms */
26+
goalBonded: string;
27+
/** expected blocks per year */
28+
blocksPerYear: Long;
29+
}
30+
31+
const baseMinter: object = { inflation: '', annualProvisions: '' };
32+
33+
export const Minter = {
34+
encode(message: Minter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
35+
if (message.inflation !== '') {
36+
writer.uint32(10).string(message.inflation);
37+
}
38+
if (message.annualProvisions !== '') {
39+
writer.uint32(18).string(message.annualProvisions);
40+
}
41+
return writer;
42+
},
43+
44+
decode(input: _m0.Reader | Uint8Array, length?: number): Minter {
45+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
46+
let end = length === undefined ? reader.len : reader.pos + length;
47+
const message = { ...baseMinter } as Minter;
48+
while (reader.pos < end) {
49+
const tag = reader.uint32();
50+
switch (tag >>> 3) {
51+
case 1:
52+
message.inflation = reader.string();
53+
break;
54+
case 2:
55+
message.annualProvisions = reader.string();
56+
break;
57+
default:
58+
reader.skipType(tag & 7);
59+
break;
60+
}
61+
}
62+
return message;
63+
},
64+
65+
fromJSON(object: any): Minter {
66+
const message = { ...baseMinter } as Minter;
67+
if (object.inflation !== undefined && object.inflation !== null) {
68+
message.inflation = String(object.inflation);
69+
} else {
70+
message.inflation = '';
71+
}
72+
if (object.annualProvisions !== undefined && object.annualProvisions !== null) {
73+
message.annualProvisions = String(object.annualProvisions);
74+
} else {
75+
message.annualProvisions = '';
76+
}
77+
return message;
78+
},
79+
80+
toJSON(message: Minter): unknown {
81+
const obj: any = {};
82+
message.inflation !== undefined && (obj.inflation = message.inflation);
83+
message.annualProvisions !== undefined && (obj.annualProvisions = message.annualProvisions);
84+
return obj;
85+
},
86+
87+
fromPartial(object: DeepPartial<Minter>): Minter {
88+
const message = { ...baseMinter } as Minter;
89+
if (object.inflation !== undefined && object.inflation !== null) {
90+
message.inflation = object.inflation;
91+
} else {
92+
message.inflation = '';
93+
}
94+
if (object.annualProvisions !== undefined && object.annualProvisions !== null) {
95+
message.annualProvisions = object.annualProvisions;
96+
} else {
97+
message.annualProvisions = '';
98+
}
99+
return message;
100+
},
101+
};
102+
103+
const baseParams: object = { mintDenom: '', inflationRateChange: '', inflationMax: '', inflationMin: '', goalBonded: '', blocksPerYear: Long.UZERO };
104+
105+
export const Params = {
106+
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
107+
if (message.mintDenom !== '') {
108+
writer.uint32(10).string(message.mintDenom);
109+
}
110+
if (message.inflationRateChange !== '') {
111+
writer.uint32(18).string(message.inflationRateChange);
112+
}
113+
if (message.inflationMax !== '') {
114+
writer.uint32(26).string(message.inflationMax);
115+
}
116+
if (message.inflationMin !== '') {
117+
writer.uint32(34).string(message.inflationMin);
118+
}
119+
if (message.goalBonded !== '') {
120+
writer.uint32(42).string(message.goalBonded);
121+
}
122+
if (!message.blocksPerYear.isZero()) {
123+
writer.uint32(48).uint64(message.blocksPerYear);
124+
}
125+
return writer;
126+
},
127+
128+
decode(input: _m0.Reader | Uint8Array, length?: number): Params {
129+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
130+
let end = length === undefined ? reader.len : reader.pos + length;
131+
const message = { ...baseParams } as Params;
132+
while (reader.pos < end) {
133+
const tag = reader.uint32();
134+
switch (tag >>> 3) {
135+
case 1:
136+
message.mintDenom = reader.string();
137+
break;
138+
case 2:
139+
message.inflationRateChange = reader.string();
140+
break;
141+
case 3:
142+
message.inflationMax = reader.string();
143+
break;
144+
case 4:
145+
message.inflationMin = reader.string();
146+
break;
147+
case 5:
148+
message.goalBonded = reader.string();
149+
break;
150+
case 6:
151+
message.blocksPerYear = reader.uint64() as Long;
152+
break;
153+
default:
154+
reader.skipType(tag & 7);
155+
break;
156+
}
157+
}
158+
return message;
159+
},
160+
161+
fromJSON(object: any): Params {
162+
const message = { ...baseParams } as Params;
163+
if (object.mintDenom !== undefined && object.mintDenom !== null) {
164+
message.mintDenom = String(object.mintDenom);
165+
} else {
166+
message.mintDenom = '';
167+
}
168+
if (object.inflationRateChange !== undefined && object.inflationRateChange !== null) {
169+
message.inflationRateChange = String(object.inflationRateChange);
170+
} else {
171+
message.inflationRateChange = '';
172+
}
173+
if (object.inflationMax !== undefined && object.inflationMax !== null) {
174+
message.inflationMax = String(object.inflationMax);
175+
} else {
176+
message.inflationMax = '';
177+
}
178+
if (object.inflationMin !== undefined && object.inflationMin !== null) {
179+
message.inflationMin = String(object.inflationMin);
180+
} else {
181+
message.inflationMin = '';
182+
}
183+
if (object.goalBonded !== undefined && object.goalBonded !== null) {
184+
message.goalBonded = String(object.goalBonded);
185+
} else {
186+
message.goalBonded = '';
187+
}
188+
if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) {
189+
message.blocksPerYear = Long.fromString(object.blocksPerYear);
190+
} else {
191+
message.blocksPerYear = Long.UZERO;
192+
}
193+
return message;
194+
},
195+
196+
toJSON(message: Params): unknown {
197+
const obj: any = {};
198+
message.mintDenom !== undefined && (obj.mintDenom = message.mintDenom);
199+
message.inflationRateChange !== undefined && (obj.inflationRateChange = message.inflationRateChange);
200+
message.inflationMax !== undefined && (obj.inflationMax = message.inflationMax);
201+
message.inflationMin !== undefined && (obj.inflationMin = message.inflationMin);
202+
message.goalBonded !== undefined && (obj.goalBonded = message.goalBonded);
203+
message.blocksPerYear !== undefined && (obj.blocksPerYear = (message.blocksPerYear || Long.UZERO).toString());
204+
return obj;
205+
},
206+
207+
fromPartial(object: DeepPartial<Params>): Params {
208+
const message = { ...baseParams } as Params;
209+
if (object.mintDenom !== undefined && object.mintDenom !== null) {
210+
message.mintDenom = object.mintDenom;
211+
} else {
212+
message.mintDenom = '';
213+
}
214+
if (object.inflationRateChange !== undefined && object.inflationRateChange !== null) {
215+
message.inflationRateChange = object.inflationRateChange;
216+
} else {
217+
message.inflationRateChange = '';
218+
}
219+
if (object.inflationMax !== undefined && object.inflationMax !== null) {
220+
message.inflationMax = object.inflationMax;
221+
} else {
222+
message.inflationMax = '';
223+
}
224+
if (object.inflationMin !== undefined && object.inflationMin !== null) {
225+
message.inflationMin = object.inflationMin;
226+
} else {
227+
message.inflationMin = '';
228+
}
229+
if (object.goalBonded !== undefined && object.goalBonded !== null) {
230+
message.goalBonded = object.goalBonded;
231+
} else {
232+
message.goalBonded = '';
233+
}
234+
if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) {
235+
message.blocksPerYear = object.blocksPerYear as Long;
236+
} else {
237+
message.blocksPerYear = Long.UZERO;
238+
}
239+
return message;
240+
},
241+
};
242+
243+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long;
244+
export type DeepPartial<T> = T extends Builtin
245+
? T
246+
: T extends Array<infer U>
247+
? Array<DeepPartial<U>>
248+
: T extends ReadonlyArray<infer U>
249+
? ReadonlyArray<DeepPartial<U>>
250+
: T extends {}
251+
? { [K in keyof T]?: DeepPartial<T[K]> }
252+
: Partial<T>;
253+
254+
if (_m0.util.Long !== Long) {
255+
_m0.util.Long = Long as any;
256+
_m0.configure();
257+
}

0 commit comments

Comments
 (0)