Skip to content

Commit

Permalink
[WIP] Rapha/feat/chain v1.4.0 upgrade (#95)
Browse files Browse the repository at this point in the history
* feat: use buf to generate proto files
* feat: upgrade types to 1.4.0
* feat: upgrade sdk to 1.4.0
  • Loading branch information
shifty11 authored Nov 8, 2023
1 parent ba3c1d6 commit f36689b
Show file tree
Hide file tree
Showing 57 changed files with 9,567 additions and 4,629 deletions.
4 changes: 2 additions & 2 deletions common/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"@cosmjs/proto-signing": "^0.27.1",
"@cosmjs/stargate": "^0.27.1",
"@kyvejs/sdk": "1.0.5",
"@kyvejs/types": "1.0.3",
"@kyvejs/types": "1.1.0",
"@types/cli-progress": "^3.9.2",
"@types/jsonfile": "^6.0.1",
"arweave": "^1.10.17",
"axios": "^0.24.0",
"bignumber.js": "^9.0.1",
"bignumber.js": "^9.1.2",
"clone": "^2.1.2",
"commander": "^9.4.1",
"diff": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion common/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Sdk instance can be configured with a network object.
const network = {
rpc: "https://rpc.korellia.kyve.network",
rest: "https://api.korellia.kyve.network",
chainId: "korellia",
chainId: "korellia-2",
chainName: "Korellia",
}
const sdk = new KyveSDK(network);
Expand Down
18 changes: 9 additions & 9 deletions common/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"lint:fix": "eslint --fix . --ignore-path ../../.eslintignore --ext ts --ext tsx --ext js --ext jsx"
},
"dependencies": {
"@cosmjs/amino": "^0.30.1",
"@cosmjs/crypto": "^0.30.1",
"@cosmjs/encoding": "^0.30.1",
"@cosmjs/proto-signing": "^0.30.1",
"@cosmjs/stargate": "^0.30.1",
"@cosmjs/tendermint-rpc": "^0.30.1",
"@cosmjs/amino": "^0.31.3",
"@cosmjs/crypto": "^0.31.3",
"@cosmjs/encoding": "^0.31.3",
"@cosmjs/proto-signing": "^0.31.3",
"@cosmjs/stargate": "^0.31.3",
"@cosmjs/tendermint-rpc": "^0.31.3",
"@cosmostation/extension-client": "^0.0.6",
"@keplr-wallet/cosmos": "^0.11.38",
"@kyvejs/types": "1.0.3",
"@keplr-wallet/cosmos": "^0.12.39",
"@kyvejs/types": "1.1.0",
"axios": "0.25.0",
"bech32": "2.0.0",
"bignumber.js": "9.0.2",
"bignumber.js": "9.1.2",
"humanize-number": "0.0.2",
"qs": "^6.10.5"
},
Expand Down
5 changes: 3 additions & 2 deletions common/sdk/src/amino/bundles.amino.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AminoConverters } from "@cosmjs/stargate";
import {
MsgSubmitBundleProposal,
MsgVoteBundleProposal,
MsgClaimUploaderRole,
MsgSkipUploaderRole,
MsgSubmitBundleProposal,
MsgVoteBundleProposal,
} from "@kyvejs/types/client/kyve/bundles/v1beta1/tx";

import { isNotEmpty } from "../utils";

export const createBundlesAminoConverters = (): AminoConverters => {
Expand Down
3 changes: 2 additions & 1 deletion common/sdk/src/amino/delegation.amino.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AminoConverters } from "@cosmjs/stargate";
import {
MsgDelegate,
MsgWithdrawRewards,
MsgRedelegate,
MsgUndelegate,
MsgWithdrawRewards,
} from "@kyvejs/types/client/kyve/delegation/v1beta1/tx";

import { isNotEmpty } from "../utils";

export const createDelegationAminoConverters = (): AminoConverters => {
Expand Down
82 changes: 82 additions & 0 deletions common/sdk/src/amino/funders.amino.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { AminoConverters } from "@cosmjs/stargate";
import {
MsgCreateFunder,
MsgDefundPool,
MsgFundPool,
MsgUpdateFunder,
} from "@kyvejs/types/client/kyve/funders/v1beta1/tx";

import { isNotEmpty } from "../utils";

export const createFundersAminoConverters = (): AminoConverters => {
return {
"/kyve.funders.v1beta1.MsgFundPool": {
aminoType: "kyve/funders/MsgFundPool",
toAmino: (msg: MsgFundPool) => ({
creator: msg.creator,
...(isNotEmpty(msg.pool_id) && { pool_id: msg.pool_id }),
...(isNotEmpty(msg.amount) && { amount: msg.amount }),
...(isNotEmpty(msg.amount_per_bundle) && {
amount_per_bundle: msg.amount_per_bundle,
}),
}),
fromAmino: (msg): MsgFundPool => ({
creator: msg.creator,
pool_id: msg.pool_id,
amount: msg.amount,
amount_per_bundle: msg.amount_per_bundle,
}),
},
"/kyve.funders.v1beta1.MsgDefundPool": {
aminoType: "kyve/funders/MsgDefundPool",
toAmino: (msg: MsgDefundPool) => ({
creator: msg.creator,
...(isNotEmpty(msg.pool_id) && { id: msg.pool_id }),
...(isNotEmpty(msg.amount) && { amount: msg.amount }),
}),
fromAmino: (msg): MsgDefundPool => ({
creator: msg.creator,
pool_id: msg.pool_id,
amount: msg.amount,
}),
},
"/kyve.funders.v1beta1.MsgCreateFunder": {
aminoType: "kyve/funders/MsgCreateFunder",
toAmino: (msg: MsgCreateFunder) => ({
creator: msg.creator,
...(isNotEmpty(msg.moniker) && { moniker: msg.moniker }),
...(isNotEmpty(msg.description) && { description: msg.description }),
...(isNotEmpty(msg.website) && { website: msg.website }),
...(isNotEmpty(msg.identity) && { identity: msg.identity }),
...(isNotEmpty(msg.contact) && { contact: msg.contact }),
}),
fromAmino: (msg): MsgCreateFunder => ({
creator: msg.creator,
moniker: msg.moniker,
description: msg.description,
website: msg.website,
identity: msg.identity,
contact: msg.contact,
}),
},
"/kyve.funders.v1beta1.MsgUpdateFunder": {
aminoType: "kyve/funders/MsgUpdateFunder",
toAmino: (msg: MsgUpdateFunder) => ({
creator: msg.creator,
...(isNotEmpty(msg.moniker) && { moniker: msg.moniker }),
...(isNotEmpty(msg.description) && { description: msg.description }),
...(isNotEmpty(msg.website) && { website: msg.website }),
...(isNotEmpty(msg.identity) && { identity: msg.identity }),
...(isNotEmpty(msg.contact) && { contact: msg.contact }),
}),
fromAmino: (msg): MsgUpdateFunder => ({
creator: msg.creator,
moniker: msg.moniker,
description: msg.description,
website: msg.website,
identity: msg.identity,
contact: msg.contact,
}),
},
};
};
1 change: 1 addition & 0 deletions common/sdk/src/amino/gov.v1.amino.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AminoConverters } from "@cosmjs/stargate";
import { MsgVote } from "@kyvejs/types/client/cosmos/gov/v1/tx";

import { isNotEmpty } from "../utils";

export const createGovV1AminoConverters = (): AminoConverters => {
Expand Down
6 changes: 3 additions & 3 deletions common/sdk/src/amino/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./bundles.amino";
export * from "./delegation.amino";
export * from "./funders.amino";
export * from "./gov.v1.amino";
export * from "./pool.amino";
export * from "./stakers.amino";
export * from "./delegation.amino";
export * from "./bundles.amino";
37 changes: 0 additions & 37 deletions common/sdk/src/amino/pool.amino.ts

This file was deleted.

9 changes: 5 additions & 4 deletions common/sdk/src/amino/stakers.amino.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { AminoConverters } from "@cosmjs/stargate";
import { Decimal } from "@cosmjs/math";
import { AminoConverters } from "@cosmjs/stargate";
import {
MsgClaimCommissionRewards,
MsgCreateStaker,
MsgUpdateMetadata,
MsgJoinPool,
MsgUpdateCommission,
MsgLeavePool,
MsgClaimCommissionRewards,
MsgUpdateCommission,
MsgUpdateMetadata,
} from "@kyvejs/types/client/kyve/stakers/v1beta1/tx";

import { isNotEmpty } from "../utils";

function protoDecimalToJson(decimal: string): string {
Expand Down
19 changes: 9 additions & 10 deletions common/sdk/src/clients/full-client.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { OfflineAminoSigner } from "@cosmjs/amino/build/signer";
import { OfflineSigner, Registry } from "@cosmjs/proto-signing";
import { AminoTypes, GasPrice, SigningStargateClient } from "@cosmjs/stargate";

import { IConfig } from "../constants";
import * as KyveRegistryTx from "../registry/tx.registry";
import KyveClient from "./rpc-client/client";
import KyveWebClient from "./rpc-client/web.client";
import { createDefaultAminoConverters } from "@cosmjs/stargate";

import {
createPoolAminoConverters,
createStakersAminoConverters,
createDelegationAminoConverters,
createBundlesAminoConverters,
createDelegationAminoConverters,
createFundersAminoConverters,
createGovV1AminoConverters,
createStakersAminoConverters,
} from "../amino";
import { createDefaultAminoConverters } from "@cosmjs/stargate";
import { IConfig } from "../constants";
import * as KyveRegistryTx from "../registry/tx.registry";
import KyveClient from "./rpc-client/client";
import KyveWebClient from "./rpc-client/web.client";

export async function getSigningKyveClient(
config: IConfig,
Expand Down Expand Up @@ -48,7 +47,7 @@ export async function getSigningKyveClient(
aminoTypes: new AminoTypes({
...createDefaultAminoConverters(),
...createGovV1AminoConverters(),
...createPoolAminoConverters(),
...createFundersAminoConverters(),
...createStakersAminoConverters(),
...createDelegationAminoConverters(),
...createBundlesAminoConverters(),
Expand Down
47 changes: 47 additions & 0 deletions common/sdk/src/clients/lcd-client/query/v1beta1/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import paginationQuery from "@kyvejs/types/client/cosmos/base/query/v1beta1/pagi
import kyveQueryAccount from "@kyvejs/types/client/kyve/query/v1beta1/account";
import kyveQueryBundles from "@kyvejs/types/client/kyve/query/v1beta1/bundles";
import kyveQueryDelegation from "@kyvejs/types/client/kyve/query/v1beta1/delegation";
import kyveQueryFunders from "@kyvejs/types/client/kyve/query/v1beta1/funders";
import kyveQueryParamsRes from "@kyvejs/types/client/kyve/query/v1beta1/params";
import kyveQueryPools from "@kyvejs/types/client/kyve/query/v1beta1/pools";
import kyveQueryStakers from "@kyvejs/types/client/kyve/query/v1beta1/stakers";
import kyveQueryAccountRes from "@kyvejs/types/lcd/kyve/query/v1beta1/account";
import kyveQueryBundlesRes from "@kyvejs/types/lcd/kyve/query/v1beta1/bundles";
import kyveQueryDelegationRes from "@kyvejs/types/lcd/kyve/query/v1beta1/delegation";
import kyveQueryFundersRes from "@kyvejs/types/lcd/kyve/query/v1beta1/funders";
import kyveQueryPoolsRes from "@kyvejs/types/lcd/kyve/query/v1beta1/pools";
import kyveQueryStakersRes from "@kyvejs/types/lcd/kyve/query/v1beta1/stakers";

Expand Down Expand Up @@ -249,4 +251,49 @@ export class KyveRegistryLCDClient extends AbstractKyveLCDClient {
return await this.request(endpoint);
}
/** End Account **/

/** Funders **/
async funder(
params: kyveQueryFunders.QueryFunderRequest
): Promise<kyveQueryFundersRes.QueryFunderResponse> {
const endpoint = `/kyve/query/v1beta1/funder/${params.address}`;
return await this.request(endpoint);
}

async funders(
params?: PaginationAllPartialRequestUtilType<kyveQueryFunders.QueryFundersRequest>
): Promise<
PaginationResponseTypeUtil<kyveQueryFundersRes.QueryFundersResponse>
> {
const parameters: Record<string, any> = {};
if (typeof params?.pagination !== "undefined") {
parameters.pagination = params.pagination;
}

if (typeof params?.search !== "undefined") {
parameters.search = params.search;
}

const endpoint = `/kyve/query/v1beta1/funders`;
return await this.request(endpoint, parameters);
}

async fundings_by_funder(
params: PaginationPartialRequestUtilType<kyveQueryFunders.QueryFundingsByFunderRequest>
): Promise<
PaginationResponseTypeUtil<kyveQueryFundersRes.QueryFundingsByFunderResponse>
> {
const endpoint = `/kyve/query/v1beta1/fundings_by_funder/${params.address}`;
return await this.request(endpoint, params);
}

async fundings_by_pool(
params: PaginationPartialRequestUtilType<kyveQueryFunders.QueryFundingsByPoolRequest>
): Promise<
PaginationResponseTypeUtil<kyveQueryFundersRes.QueryFundingsByPoolResponse>
> {
const endpoint = `/kyve/query/v1beta1/fundings_by_pool/${params.pool_id}`;
return await this.request(endpoint, params);
}
/** EndFunders **/
}
14 changes: 9 additions & 5 deletions common/sdk/src/clients/rpc-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { IConfig } from "../../constants";
import KyveBaseMethods from "./kyve/base/v1beta1/base";
import KyveBundlesMethods from "./kyve/bundles/v1beta1/bundles";
import KyveDelegationMethods from "./kyve/delegation/v1beta1/delegation";
import KyveFundersMethods from "./kyve/funders/v1beta1/funders";
import KyveGovMethodsV1 from "./kyve/gov/v1/gov";
import KyvePoolMethods from "./kyve/pool/v1beta1/pool";
import KyveStakersMethods from "./kyve/stakers/v1beta1/stakers";

export default class KyveClient {
Expand All @@ -28,8 +28,8 @@ export default class KyveClient {
delegation: {
v1beta1: KyveDelegationMethods;
};
pool: {
v1beta1: KyvePoolMethods;
funders: {
v1beta1: KyveFundersMethods;
};
stakers: {
v1beta1: KyveStakersMethods;
Expand Down Expand Up @@ -68,8 +68,12 @@ export default class KyveClient {
gov: {
v1: new KyveGovMethodsV1(this.nativeClient, this.account, config),
},
pool: {
v1beta1: new KyvePoolMethods(this.nativeClient, this.account, config),
funders: {
v1beta1: new KyveFundersMethods(
this.nativeClient,
this.account,
config
),
},
stakers: {
v1beta1: new KyveStakersMethods(
Expand Down
Loading

0 comments on commit f36689b

Please sign in to comment.