Skip to content

Commit

Permalink
Merge branch 'rapha/cosmos-sdk-0.47.x-upgrade' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 authored Nov 2, 2023
2 parents ca53fe1 + 79b52af commit 0e7c9a5
Show file tree
Hide file tree
Showing 54 changed files with 11,018 additions and 5,976 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.2.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",
"fs-extra": "^10.0.1",
Expand Down
Empty file removed common/protocol/yarn.lock
Empty file.
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.2.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
79 changes: 79 additions & 0 deletions common/sdk/src/amino/funders.amino.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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
})
}
};
};
2 changes: 1 addition & 1 deletion common/sdk/src/amino/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./gov.v1.amino";
export * from "./pool.amino";
export * from "./funders.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.

4 changes: 2 additions & 2 deletions common/sdk/src/clients/full-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import KyveClient from "./rpc-client/client";
import KyveWebClient from "./rpc-client/web.client";

import {
createPoolAminoConverters,
createFundersAminoConverters,
createStakersAminoConverters,
createDelegationAminoConverters,
createBundlesAminoConverters,
Expand Down Expand Up @@ -48,7 +48,7 @@ export async function getSigningKyveClient(
aminoTypes: new AminoTypes({
...createDefaultAminoConverters(),
...createGovV1AminoConverters(),
...createPoolAminoConverters(),
...createFundersAminoConverters(),
...createStakersAminoConverters(),
...createDelegationAminoConverters(),
...createBundlesAminoConverters(),
Expand Down
47 changes: 46 additions & 1 deletion common/sdk/src/clients/lcd-client/query/v1beta1/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import kyveQueryBundlesRes from "@kyvejs/types/lcd/kyve/query/v1beta1/bundles";
import kyveQueryDelegationRes from "@kyvejs/types/lcd/kyve/query/v1beta1/delegation";
import kyveQueryPoolsRes from "@kyvejs/types/lcd/kyve/query/v1beta1/pools";
import kyveQueryStakersRes from "@kyvejs/types/lcd/kyve/query/v1beta1/stakers";
import kyveQueryFunders from "@kyvejs/types/client/kyve/query/v1beta1/funders";
import kyveQueryFundersRes from "@kyvejs/types/lcd/kyve/query/v1beta1/funders";

import { AbstractKyveLCDClient } from "../../lcd-client.abstract";
import {AbstractKyveLCDClient} from "../../lcd-client.abstract";

type NestedPartial<T> = {
[K in keyof T]?: T[K] extends Array<infer R>
Expand Down Expand Up @@ -249,4 +251,47 @@ 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 **/
}
10 changes: 5 additions & 5 deletions common/sdk/src/clients/rpc-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import KyveBaseMethods from "./kyve/base/v1beta1/base";
import KyveBundlesMethods from "./kyve/bundles/v1beta1/bundles";
import KyveDelegationMethods from "./kyve/delegation/v1beta1/delegation";
import KyveGovMethodsV1 from "./kyve/gov/v1/gov";
import KyvePoolMethods from "./kyve/pool/v1beta1/pool";
import KyveFundersMethods from "./kyve/funders/v1beta1/funders";
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,8 @@ 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
79 changes: 79 additions & 0 deletions common/sdk/src/clients/rpc-client/kyve/funders/v1beta1/funders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { StdFee } from '@cosmjs/amino/build/signdoc';
import {
MsgCreateFunder,
MsgDefundPool,
MsgFundPool,
MsgUpdateFunder
} from '@kyvejs/types/client/kyve/funders/v1beta1/tx';

import { withTypeUrl } from '../../../../../registry/tx.registry';
import { KyveSigning, PendingTx } from '../../../signing';

export default class KyveFundersMethods extends KyveSigning {
public createFunder(
value: Omit<MsgCreateFunder, 'creator'>,
options?: {
fee?: StdFee | 'auto' | number;
memo?: string;
}
) {
const tx = withTypeUrl.createFunder({
...value,
creator: this.account.address
});

return new PendingTx({ tx: [tx] }, () =>
this.getPendingSignedTx(tx, options)
);
}

public updateFunder(
value: Omit<MsgUpdateFunder, 'creator'>,
options?: {
fee?: StdFee | 'auto' | number;
memo?: string;
}
) {
const tx = withTypeUrl.updateFunder({
...value,
creator: this.account.address
});

return new PendingTx({ tx: [tx] }, () =>
this.getPendingSignedTx(tx, options)
);
}

public fundPool(
value: Omit<MsgFundPool, 'creator'>,
options?: {
fee?: StdFee | 'auto' | number;
memo?: string;
}
) {
const tx = withTypeUrl.fundPool({
...value,
creator: this.account.address
});

return new PendingTx({ tx: [tx] }, () =>
this.getPendingSignedTx(tx, options)
);
}

public defundPool(
value: Omit<MsgDefundPool, 'creator'>,
options?: {
fee?: StdFee | 'auto' | number;
memo?: string;
}
) {
const tx = withTypeUrl.defundPool({
...value,
creator: this.account.address
});
return new PendingTx({ tx: [tx] }, () =>
this.getPendingSignedTx(tx, options)
);
}
}
Loading

0 comments on commit 0e7c9a5

Please sign in to comment.