Skip to content

Commit 7a36dae

Browse files
authored
Feature/lum 296 (#35)
* Fix typo * Implement vesting utils * Update vesting utils implementation to handle vesting delegations * Update sdk refs and add lum airdrop module * Update codecs using latest proto version * Bump version to 0.7.1
1 parent 74ab616 commit 7a36dae

File tree

94 files changed

+2214
-3751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2214
-3751
lines changed

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lum-network/sdk-javascript",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
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",
@@ -35,18 +35,19 @@
3535
"format": "prettier --write '**/*.{js,jsx,ts,tsx,css,json,md,html,yml}'",
3636
"bump": "npm version",
3737
"preget-proto": "rm -rf proto",
38-
"get-proto": "COSMOS_REF=v0.44.1 IBC_REF=v1.2.0 LUM_REF=master sh ./scripts/get-proto.sh",
38+
"get-proto": "COSMOS_REF=v0.44.4 IBC_REF=v1.2.0 LUM_REF=v1.0.4 sh ./scripts/get-proto.sh",
3939
"define-proto": "sh ./scripts/define-proto.sh",
4040
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
4141
},
4242
"dependencies": {
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",
43+
"@cosmjs/amino": "^0.26.5",
44+
"@cosmjs/crypto": "^0.26.5",
45+
"@cosmjs/encoding": "^0.26.5",
46+
"@cosmjs/math": "^0.26.5",
47+
"@cosmjs/proto-signing": "^0.26.5",
48+
"@cosmjs/stargate": "^0.26.5",
49+
"@cosmjs/tendermint-rpc": "^0.26.5",
50+
"@cosmjs/utils": "^0.26.5",
5051
"@ledgerhq/hw-app-cosmos": "^6.11.2",
5152
"@ledgerhq/hw-transport": "^6.11.2",
5253
"@types/crypto-js": "^4.0.2",

scripts/define-proto.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ protoc \
9191
"$THIRD_PARTY_PROTO_DIR/tendermint/types/types.proto" \
9292
"$THIRD_PARTY_PROTO_DIR/tendermint/types/validator.proto" \
9393
"$THIRD_PARTY_PROTO_DIR/tendermint/version/types.proto" \
94+
"$LUM_PROTO_DIR/airdrop/claim.proto" \
95+
"$LUM_PROTO_DIR/airdrop/query.proto" \
96+
"$LUM_PROTO_DIR/airdrop/params.proto" \
9497
"$LUM_PROTO_DIR/beam/beam.proto" \
9598
"$LUM_PROTO_DIR/beam/query.proto" \
9699
"$LUM_PROTO_DIR/beam/tx.proto"

scripts/get-proto.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ LUM_ZIP_FILE="$LUM_DIR/tmp.zip"
5757

5858
# Init LUM REF
5959
LUM_REF=${LUM_REF:-"master"}
60-
LUM_SUFFIX=${LUM_REF}
60+
LUM_SUFFIX=${LUM_REF//[\/]/-}
6161
[[ $LUM_SUFFIX =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]] && LUM_SUFFIX=${LUM_SUFFIX#v}
6262

6363
# Create the LUM dir

src/client/LumClient.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Tendermint34Client, StatusResponse } from '@cosmjs/tendermint-rpc';
2-
import { QueryClient as StargateQueryClient, accountFromAny } from '@cosmjs/stargate';
2+
import { QueryClient as StargateQueryClient } from '@cosmjs/stargate';
33

44
import { LumWallet, LumUtils, LumTypes } from '..';
55
import {
@@ -19,6 +19,8 @@ import {
1919
setupMintExtension,
2020
StakingExtension,
2121
setupStakingExtension,
22+
AirdropExtension,
23+
setupAirdropExtension,
2224
} from '../extensions';
2325
import { setupSlashingExtension, SlashingExtension } from '../extensions/slashing';
2426
import { AuthzExtension, setupAuthzExtension } from '../extensions/authz';
@@ -37,7 +39,8 @@ export class LumClient {
3739
MintExtension &
3840
StakingExtension &
3941
SlashingExtension &
40-
FeegrantExtension;
42+
FeegrantExtension &
43+
AirdropExtension;
4144
private chainId?: string;
4245

4346
/**
@@ -60,6 +63,7 @@ export class LumClient {
6063
setupStakingExtension,
6164
setupSlashingExtension,
6265
setupFeegrantExtension,
66+
setupAirdropExtension,
6367
);
6468

6569
// Used for debugging while gasWanted, gasUsed and codespace are still waiting to be included in the code lib
@@ -162,7 +166,7 @@ export class LumClient {
162166
if (!anyAccount) {
163167
return null;
164168
}
165-
return accountFromAny(anyAccount);
169+
return LumUtils.accountFromAny(anyAccount);
166170
};
167171

168172
/**

src/codec/airdrop/claim.ts

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/* eslint-disable */
2+
import Long from 'long';
3+
import _m0 from 'protobufjs/minimal';
4+
import { Coin } from '../cosmos/base/v1beta1/coin';
5+
6+
export const protobufPackage = 'lum.network.airdrop';
7+
8+
export enum Action {
9+
ActionVote = 0,
10+
ActionDelegateStake = 1,
11+
UNRECOGNIZED = -1,
12+
}
13+
14+
export function actionFromJSON(object: any): Action {
15+
switch (object) {
16+
case 0:
17+
case 'ActionVote':
18+
return Action.ActionVote;
19+
case 1:
20+
case 'ActionDelegateStake':
21+
return Action.ActionDelegateStake;
22+
case -1:
23+
case 'UNRECOGNIZED':
24+
default:
25+
return Action.UNRECOGNIZED;
26+
}
27+
}
28+
29+
export function actionToJSON(object: Action): string {
30+
switch (object) {
31+
case Action.ActionVote:
32+
return 'ActionVote';
33+
case Action.ActionDelegateStake:
34+
return 'ActionDelegateStake';
35+
default:
36+
return 'UNKNOWN';
37+
}
38+
}
39+
40+
export interface ClaimRecord {
41+
address: string;
42+
initialClaimableAmount: Coin[];
43+
actionCompleted: boolean[];
44+
}
45+
46+
const baseClaimRecord: object = { address: '', actionCompleted: false };
47+
48+
export const ClaimRecord = {
49+
encode(message: ClaimRecord, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
50+
if (message.address !== '') {
51+
writer.uint32(10).string(message.address);
52+
}
53+
for (const v of message.initialClaimableAmount) {
54+
Coin.encode(v!, writer.uint32(18).fork()).ldelim();
55+
}
56+
writer.uint32(26).fork();
57+
for (const v of message.actionCompleted) {
58+
writer.bool(v);
59+
}
60+
writer.ldelim();
61+
return writer;
62+
},
63+
64+
decode(input: _m0.Reader | Uint8Array, length?: number): ClaimRecord {
65+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
66+
let end = length === undefined ? reader.len : reader.pos + length;
67+
const message = { ...baseClaimRecord } as ClaimRecord;
68+
message.initialClaimableAmount = [];
69+
message.actionCompleted = [];
70+
while (reader.pos < end) {
71+
const tag = reader.uint32();
72+
switch (tag >>> 3) {
73+
case 1:
74+
message.address = reader.string();
75+
break;
76+
case 2:
77+
message.initialClaimableAmount.push(Coin.decode(reader, reader.uint32()));
78+
break;
79+
case 3:
80+
if ((tag & 7) === 2) {
81+
const end2 = reader.uint32() + reader.pos;
82+
while (reader.pos < end2) {
83+
message.actionCompleted.push(reader.bool());
84+
}
85+
} else {
86+
message.actionCompleted.push(reader.bool());
87+
}
88+
break;
89+
default:
90+
reader.skipType(tag & 7);
91+
break;
92+
}
93+
}
94+
return message;
95+
},
96+
97+
fromJSON(object: any): ClaimRecord {
98+
const message = { ...baseClaimRecord } as ClaimRecord;
99+
message.initialClaimableAmount = [];
100+
message.actionCompleted = [];
101+
if (object.address !== undefined && object.address !== null) {
102+
message.address = String(object.address);
103+
} else {
104+
message.address = '';
105+
}
106+
if (object.initialClaimableAmount !== undefined && object.initialClaimableAmount !== null) {
107+
for (const e of object.initialClaimableAmount) {
108+
message.initialClaimableAmount.push(Coin.fromJSON(e));
109+
}
110+
}
111+
if (object.actionCompleted !== undefined && object.actionCompleted !== null) {
112+
for (const e of object.actionCompleted) {
113+
message.actionCompleted.push(Boolean(e));
114+
}
115+
}
116+
return message;
117+
},
118+
119+
toJSON(message: ClaimRecord): unknown {
120+
const obj: any = {};
121+
message.address !== undefined && (obj.address = message.address);
122+
if (message.initialClaimableAmount) {
123+
obj.initialClaimableAmount = message.initialClaimableAmount.map((e) => (e ? Coin.toJSON(e) : undefined));
124+
} else {
125+
obj.initialClaimableAmount = [];
126+
}
127+
if (message.actionCompleted) {
128+
obj.actionCompleted = message.actionCompleted.map((e) => e);
129+
} else {
130+
obj.actionCompleted = [];
131+
}
132+
return obj;
133+
},
134+
135+
fromPartial(object: DeepPartial<ClaimRecord>): ClaimRecord {
136+
const message = { ...baseClaimRecord } as ClaimRecord;
137+
message.address = object.address ?? '';
138+
message.initialClaimableAmount = [];
139+
if (object.initialClaimableAmount !== undefined && object.initialClaimableAmount !== null) {
140+
for (const e of object.initialClaimableAmount) {
141+
message.initialClaimableAmount.push(Coin.fromPartial(e));
142+
}
143+
}
144+
message.actionCompleted = [];
145+
if (object.actionCompleted !== undefined && object.actionCompleted !== null) {
146+
for (const e of object.actionCompleted) {
147+
message.actionCompleted.push(e);
148+
}
149+
}
150+
return message;
151+
},
152+
};
153+
154+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long;
155+
export type DeepPartial<T> = T extends Builtin
156+
? T
157+
: T extends Array<infer U>
158+
? Array<DeepPartial<U>>
159+
: T extends ReadonlyArray<infer U>
160+
? ReadonlyArray<DeepPartial<U>>
161+
: T extends {}
162+
? { [K in keyof T]?: DeepPartial<T[K]> }
163+
: Partial<T>;
164+
165+
if (_m0.util.Long !== Long) {
166+
_m0.util.Long = Long as any;
167+
_m0.configure();
168+
}

0 commit comments

Comments
 (0)