Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [14.x]

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
node-version: [14.x]

env:
CLOUDSDK_CORE_PROJECT: dev
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ Directly importing the CosmJS SDK or other cryptographic library should be consi

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.

### Unittests

#### All unittests except the ones involving a Ledger device (skipped by default) can be run using the following command

```bash
yarn test
```

#### Ledger unittests

In order to run the unittest involving Ledger devices you need to do the following:

1. Chose which application you want to use for the tests (Cosmos or Lum)
2. Remove the `.skip` from all the tests your want to run in `./tests/ledger.test.ts`
3. Connect a Ledger device and open either the Cosmos application or the Lum application
4. Run `yarn test tests/ledger.test.ts`
5. Follow the instructions on your Ledger device to pass each test that require a user input

## Protocol Buffer Codecs

### Introduction
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lum-network/sdk-javascript",
"version": "0.4.8",
"version": "0.4.9",
"license": "Apache-2.0",
"description": "Javascript SDK library for NodeJS and Web browsers to interact with the Lum Network.",
"homepage": "https://github.com/lum-network/sdk-javascript#readme",
Expand Down Expand Up @@ -65,6 +65,7 @@
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@ledgerhq/hw-transport-node-hid": "^6.6.0",
"@types/jest": "^26.0.20",
"@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
"axios": "^0.21.1",
Expand Down
2 changes: 2 additions & 0 deletions scripts/define-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ protoc \
"$COSMOS_PROTO_DIR/cosmos/gov/v1beta1/query.proto" \
"$COSMOS_PROTO_DIR/cosmos/gov/v1beta1/gov.proto" \
"$COSMOS_PROTO_DIR/cosmos/gov/v1beta1/tx.proto" \
"$COSMOS_PROTO_DIR/cosmos/mint/v1beta1/query.proto" \
"$COSMOS_PROTO_DIR/cosmos/mint/v1beta1/mint.proto" \
"$COSMOS_PROTO_DIR/cosmos/tx/signing/v1beta1/signing.proto" \
"$COSMOS_PROTO_DIR/cosmos/tx/v1beta1/tx.proto" \
"$COSMOS_PROTO_DIR/cosmos/vesting/v1beta1/vesting.proto" \
Expand Down
9 changes: 4 additions & 5 deletions src/client/LumClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Uint64 } from '@cosmjs/math';
import { Tendermint34Client, StatusResponse } from '@cosmjs/tendermint-rpc';
import {
QueryClient as StargateQueryClient,
Expand All @@ -15,13 +14,12 @@ import {
accountFromAny,
} from '@cosmjs/stargate';

import { BaseAccount } from '../codec/cosmos/auth/v1beta1/auth';
import { LumWallet, LumUtils, LumTypes, LumRegistry } from '..';
import { BeamExtension, setupBeamExtension as BeamSetupBeamExtension } from '../extensions';
import { LumWallet, LumUtils, LumTypes } from '..';
import { BeamExtension, setupBeamExtension as BeamSetupBeamExtension, MintExtension, setupMintExtension as MintSetupExtension } from '../extensions';

export class LumClient {
readonly tmClient: Tendermint34Client;
readonly queryClient: StargateQueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & GovExtension & BeamExtension;
readonly queryClient: StargateQueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & GovExtension & MintExtension & BeamExtension;
private chainId?: string;

/**
Expand All @@ -38,6 +36,7 @@ export class LumClient {
StargateDistributionExtension,
StargateStakingExtension,
StargateGovExtension,
MintSetupExtension,
BeamSetupBeamExtension,
);

Expand Down
257 changes: 257 additions & 0 deletions src/codec/cosmos/mint/v1beta1/mint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
/* eslint-disable */
import Long from 'long';
import _m0 from 'protobufjs/minimal';

export const protobufPackage = 'cosmos.mint.v1beta1';

/** Minter represents the minting state. */
export interface Minter {
/** current annual inflation rate */
inflation: string;
/** current annual expected provisions */
annualProvisions: string;
}

/** Params holds parameters for the mint module. */
export interface Params {
/** type of coin to mint */
mintDenom: string;
/** maximum annual change in inflation rate */
inflationRateChange: string;
/** maximum inflation rate */
inflationMax: string;
/** minimum inflation rate */
inflationMin: string;
/** goal of percent bonded atoms */
goalBonded: string;
/** expected blocks per year */
blocksPerYear: Long;
}

const baseMinter: object = { inflation: '', annualProvisions: '' };

export const Minter = {
encode(message: Minter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.inflation !== '') {
writer.uint32(10).string(message.inflation);
}
if (message.annualProvisions !== '') {
writer.uint32(18).string(message.annualProvisions);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): Minter {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseMinter } as Minter;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.inflation = reader.string();
break;
case 2:
message.annualProvisions = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): Minter {
const message = { ...baseMinter } as Minter;
if (object.inflation !== undefined && object.inflation !== null) {
message.inflation = String(object.inflation);
} else {
message.inflation = '';
}
if (object.annualProvisions !== undefined && object.annualProvisions !== null) {
message.annualProvisions = String(object.annualProvisions);
} else {
message.annualProvisions = '';
}
return message;
},

toJSON(message: Minter): unknown {
const obj: any = {};
message.inflation !== undefined && (obj.inflation = message.inflation);
message.annualProvisions !== undefined && (obj.annualProvisions = message.annualProvisions);
return obj;
},

fromPartial(object: DeepPartial<Minter>): Minter {
const message = { ...baseMinter } as Minter;
if (object.inflation !== undefined && object.inflation !== null) {
message.inflation = object.inflation;
} else {
message.inflation = '';
}
if (object.annualProvisions !== undefined && object.annualProvisions !== null) {
message.annualProvisions = object.annualProvisions;
} else {
message.annualProvisions = '';
}
return message;
},
};

const baseParams: object = { mintDenom: '', inflationRateChange: '', inflationMax: '', inflationMin: '', goalBonded: '', blocksPerYear: Long.UZERO };

export const Params = {
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.mintDenom !== '') {
writer.uint32(10).string(message.mintDenom);
}
if (message.inflationRateChange !== '') {
writer.uint32(18).string(message.inflationRateChange);
}
if (message.inflationMax !== '') {
writer.uint32(26).string(message.inflationMax);
}
if (message.inflationMin !== '') {
writer.uint32(34).string(message.inflationMin);
}
if (message.goalBonded !== '') {
writer.uint32(42).string(message.goalBonded);
}
if (!message.blocksPerYear.isZero()) {
writer.uint32(48).uint64(message.blocksPerYear);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): Params {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseParams } as Params;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.mintDenom = reader.string();
break;
case 2:
message.inflationRateChange = reader.string();
break;
case 3:
message.inflationMax = reader.string();
break;
case 4:
message.inflationMin = reader.string();
break;
case 5:
message.goalBonded = reader.string();
break;
case 6:
message.blocksPerYear = reader.uint64() as Long;
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): Params {
const message = { ...baseParams } as Params;
if (object.mintDenom !== undefined && object.mintDenom !== null) {
message.mintDenom = String(object.mintDenom);
} else {
message.mintDenom = '';
}
if (object.inflationRateChange !== undefined && object.inflationRateChange !== null) {
message.inflationRateChange = String(object.inflationRateChange);
} else {
message.inflationRateChange = '';
}
if (object.inflationMax !== undefined && object.inflationMax !== null) {
message.inflationMax = String(object.inflationMax);
} else {
message.inflationMax = '';
}
if (object.inflationMin !== undefined && object.inflationMin !== null) {
message.inflationMin = String(object.inflationMin);
} else {
message.inflationMin = '';
}
if (object.goalBonded !== undefined && object.goalBonded !== null) {
message.goalBonded = String(object.goalBonded);
} else {
message.goalBonded = '';
}
if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) {
message.blocksPerYear = Long.fromString(object.blocksPerYear);
} else {
message.blocksPerYear = Long.UZERO;
}
return message;
},

toJSON(message: Params): unknown {
const obj: any = {};
message.mintDenom !== undefined && (obj.mintDenom = message.mintDenom);
message.inflationRateChange !== undefined && (obj.inflationRateChange = message.inflationRateChange);
message.inflationMax !== undefined && (obj.inflationMax = message.inflationMax);
message.inflationMin !== undefined && (obj.inflationMin = message.inflationMin);
message.goalBonded !== undefined && (obj.goalBonded = message.goalBonded);
message.blocksPerYear !== undefined && (obj.blocksPerYear = (message.blocksPerYear || Long.UZERO).toString());
return obj;
},

fromPartial(object: DeepPartial<Params>): Params {
const message = { ...baseParams } as Params;
if (object.mintDenom !== undefined && object.mintDenom !== null) {
message.mintDenom = object.mintDenom;
} else {
message.mintDenom = '';
}
if (object.inflationRateChange !== undefined && object.inflationRateChange !== null) {
message.inflationRateChange = object.inflationRateChange;
} else {
message.inflationRateChange = '';
}
if (object.inflationMax !== undefined && object.inflationMax !== null) {
message.inflationMax = object.inflationMax;
} else {
message.inflationMax = '';
}
if (object.inflationMin !== undefined && object.inflationMin !== null) {
message.inflationMin = object.inflationMin;
} else {
message.inflationMin = '';
}
if (object.goalBonded !== undefined && object.goalBonded !== null) {
message.goalBonded = object.goalBonded;
} else {
message.goalBonded = '';
}
if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) {
message.blocksPerYear = object.blocksPerYear as Long;
} else {
message.blocksPerYear = Long.UZERO;
}
return message;
},
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long;
export type DeepPartial<T> = T extends Builtin
? T
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
Loading