Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/stride #21

Merged
merged 4 commits into from
Feb 23, 2023
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 .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
[submodule "allianced"]
path = allianced
url = git@github.com:terra-money/alliance.git
branch = v0.0.1-beta1/v0.45-sdk
branch = v0.0.1-beta1/v0.45-sdk
3 changes: 2 additions & 1 deletion js/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ node_modules
/google/
/ibc/
/tendermint/
/alliance/
/alliance/
/stride/
4 changes: 2 additions & 2 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@terra-money/terra.proto",
"version": "2.2.0-beta.3",
"version": "2.2.0-beta.4",
"description": "JS and TS types relating to Protocol Buffers used by Terra project",
"contributors": [
"Yun Yeo <YunSuk-Yeo@users.noreply.github.com>"
Expand All @@ -14,6 +14,7 @@
"access": "public"
},
"files": [
"stride/",
"alliance/",
"confio/",
"cosmos/",
Expand Down Expand Up @@ -44,4 +45,4 @@
"ts-proto": "^1.82.5",
"typescript": "~4.0"
}
}
}
2 changes: 1 addition & 1 deletion js/scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"

DIRS="alliance confio cosmos cosmos_proto cosmwasm gogoproto google ibc tendermint"
DIRS="stride alliance confio cosmos cosmos_proto cosmwasm gogoproto google ibc tendermint"

for dir in $DIRS; do
rm -rf "$dir"
Expand Down
4 changes: 3 additions & 1 deletion js/scripts/proto-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ mkdir -p "$OUT_DIR"
echo "Processing proto files ..."
ALLIANCED_DIR="../allianced/proto"
TERRAD_THIRD_PARTY_DIR="../terrad/third_party/proto"
STRIDE_DIR="../third_party"

protoc \
--plugin="protoc-gen-ts_proto=${PROTOC_GEN_TS_PROTO_PATH}" \
--ts_proto_out="${OUT_DIR}" \
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=true,outputClientImpl=grpc-web" \
--proto_path="$ALLIANCED_DIR" \
--proto_path="$TERRAD_THIRD_PARTY_DIR" \
$(find ${ALLIANCED_DIR} ${TERRAD_THIRD_PARTY_DIR} -path -prune -o -name '*.proto' -print0 | xargs -0)
--proto_path="$STRIDE_DIR" \
$(find ${ALLIANCED_DIR} ${TERRAD_THIRD_PARTY_DIR} ${STRIDE_DIR} -path -prune -o -name '*.proto' -print0 | xargs -0)
196 changes: 196 additions & 0 deletions js/src/stride/claim/claim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";

export const protobufPackage = "stride.claim";

export enum Action {
ACTION_FREE = 0,
ACTION_LIQUID_STAKE = 1,
ACTION_DELEGATE_STAKE = 2,
UNRECOGNIZED = -1,
}

export function actionFromJSON(object: any): Action {
switch (object) {
case 0:
case "ACTION_FREE":
return Action.ACTION_FREE;
case 1:
case "ACTION_LIQUID_STAKE":
return Action.ACTION_LIQUID_STAKE;
case 2:
case "ACTION_DELEGATE_STAKE":
return Action.ACTION_DELEGATE_STAKE;
case -1:
case "UNRECOGNIZED":
default:
return Action.UNRECOGNIZED;
}
}

export function actionToJSON(object: Action): string {
switch (object) {
case Action.ACTION_FREE:
return "ACTION_FREE";
case Action.ACTION_LIQUID_STAKE:
return "ACTION_LIQUID_STAKE";
case Action.ACTION_DELEGATE_STAKE:
return "ACTION_DELEGATE_STAKE";
default:
return "UNKNOWN";
}
}

/** A Claim Records is the metadata of claim data per address */
export interface ClaimRecord {
/** airdrop identifier */
airdropIdentifier: string;
/** address of claim user */
address: string;
/** weight that represent the portion from total allocation */
weight: string;
/**
* true if action is completed
* index of bool in array refers to action enum #
*/
actionCompleted: boolean[];
}

const baseClaimRecord: object = { airdropIdentifier: "", address: "", weight: "", actionCompleted: false };

export const ClaimRecord = {
encode(message: ClaimRecord, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.airdropIdentifier !== "") {
writer.uint32(10).string(message.airdropIdentifier);
}
if (message.address !== "") {
writer.uint32(18).string(message.address);
}
if (message.weight !== "") {
writer.uint32(26).string(message.weight);
}
writer.uint32(34).fork();
for (const v of message.actionCompleted) {
writer.bool(v);
}
writer.ldelim();
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): ClaimRecord {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseClaimRecord } as ClaimRecord;
message.actionCompleted = [];
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.airdropIdentifier = reader.string();
break;
case 2:
message.address = reader.string();
break;
case 3:
message.weight = reader.string();
break;
case 4:
if ((tag & 7) === 2) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.actionCompleted.push(reader.bool());
}
} else {
message.actionCompleted.push(reader.bool());
}
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): ClaimRecord {
const message = { ...baseClaimRecord } as ClaimRecord;
message.actionCompleted = [];
if (object.airdropIdentifier !== undefined && object.airdropIdentifier !== null) {
message.airdropIdentifier = String(object.airdropIdentifier);
} else {
message.airdropIdentifier = "";
}
if (object.address !== undefined && object.address !== null) {
message.address = String(object.address);
} else {
message.address = "";
}
if (object.weight !== undefined && object.weight !== null) {
message.weight = String(object.weight);
} else {
message.weight = "";
}
if (object.actionCompleted !== undefined && object.actionCompleted !== null) {
for (const e of object.actionCompleted) {
message.actionCompleted.push(Boolean(e));
}
}
return message;
},

toJSON(message: ClaimRecord): unknown {
const obj: any = {};
message.airdropIdentifier !== undefined && (obj.airdropIdentifier = message.airdropIdentifier);
message.address !== undefined && (obj.address = message.address);
message.weight !== undefined && (obj.weight = message.weight);
if (message.actionCompleted) {
obj.actionCompleted = message.actionCompleted.map((e) => e);
} else {
obj.actionCompleted = [];
}
return obj;
},

fromPartial(object: DeepPartial<ClaimRecord>): ClaimRecord {
const message = { ...baseClaimRecord } as ClaimRecord;
message.actionCompleted = [];
if (object.airdropIdentifier !== undefined && object.airdropIdentifier !== null) {
message.airdropIdentifier = object.airdropIdentifier;
} else {
message.airdropIdentifier = "";
}
if (object.address !== undefined && object.address !== null) {
message.address = object.address;
} else {
message.address = "";
}
if (object.weight !== undefined && object.weight !== null) {
message.weight = object.weight;
} else {
message.weight = "";
}
if (object.actionCompleted !== undefined && object.actionCompleted !== null) {
for (const e of object.actionCompleted) {
message.actionCompleted.push(e);
}
}
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();
}
110 changes: 110 additions & 0 deletions js/src/stride/claim/genesis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { Params } from "../../stride/claim/params";
import { ClaimRecord } from "../../stride/claim/claim";

export const protobufPackage = "stride.claim";

/** GenesisState defines the claim module's genesis state. */
export interface GenesisState {
/** params defines all the parameters of the module. */
params?: Params;
/** list of claim records, one for every airdrop recipient */
claimRecords: ClaimRecord[];
}

const baseGenesisState: object = {};

export const GenesisState = {
encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.params !== undefined) {
Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}
for (const v of message.claimRecords) {
ClaimRecord.encode(v!, writer.uint32(18).fork()).ldelim();
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGenesisState } as GenesisState;
message.claimRecords = [];
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.params = Params.decode(reader, reader.uint32());
break;
case 2:
message.claimRecords.push(ClaimRecord.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): GenesisState {
const message = { ...baseGenesisState } as GenesisState;
message.claimRecords = [];
if (object.params !== undefined && object.params !== null) {
message.params = Params.fromJSON(object.params);
} else {
message.params = undefined;
}
if (object.claimRecords !== undefined && object.claimRecords !== null) {
for (const e of object.claimRecords) {
message.claimRecords.push(ClaimRecord.fromJSON(e));
}
}
return message;
},

toJSON(message: GenesisState): unknown {
const obj: any = {};
message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined);
if (message.claimRecords) {
obj.claimRecords = message.claimRecords.map((e) => (e ? ClaimRecord.toJSON(e) : undefined));
} else {
obj.claimRecords = [];
}
return obj;
},

fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = { ...baseGenesisState } as GenesisState;
message.claimRecords = [];
if (object.params !== undefined && object.params !== null) {
message.params = Params.fromPartial(object.params);
} else {
message.params = undefined;
}
if (object.claimRecords !== undefined && object.claimRecords !== null) {
for (const e of object.claimRecords) {
message.claimRecords.push(ClaimRecord.fromPartial(e));
}
}
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