From 1d09461f748696a69ebc349daaa096596d60b1d5 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Wed, 26 Jun 2024 07:23:54 -0700 Subject: [PATCH] revert: cosmos submodule only (#362) * revert: cosmos submodule only * fix: rem * fix: rem * fix: update --- .eslintrc.json | 2 +- .gitmodules | 3 --- .prettierignore | 1 - cosmos-sdk | 1 - scripts/protocgen.sh | 12 +---------- src/sdk/query/index.ts | 1 - src/sdk/query/query.ts | 6 +----- src/sdk/query/staking.test.ts | 39 ----------------------------------- src/sdk/query/staking.ts | 29 -------------------------- src/sdk/tx/txClient.ts | 2 -- 10 files changed, 3 insertions(+), 93 deletions(-) delete mode 160000 cosmos-sdk delete mode 100644 src/sdk/query/staking.test.ts delete mode 100644 src/sdk/query/staking.ts diff --git a/.eslintrc.json b/.eslintrc.json index 2f8ac782..f1a66860 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,5 +13,5 @@ "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended" ], - "ignorePatterns": ["nibiru/*", "cosmos-sdk/*"] + "ignorePatterns": ["nibiru/*"] } diff --git a/.gitmodules b/.gitmodules index f82158ce..0bb2cf91 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "cosmos-sdk"] - path = cosmos-sdk - url = https://github.com/cosmos/cosmos-sdk [submodule "nibiru"] path = nibiru url = https://github.com/NibiruChain/nibiru diff --git a/.prettierignore b/.prettierignore index 7436e434..d22617e7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ /nibiru -/cosmos-sdk # Rest of file is .gitignore diff --git a/cosmos-sdk b/cosmos-sdk deleted file mode 160000 index b48fd666..00000000 --- a/cosmos-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b48fd66678a98b915888cc84976399ac17164370 diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index ae5cd124..905ef937 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -11,7 +11,6 @@ set -eo pipefail # PKG_OUT_DIR: Output path where the generated code will go upon # successful execution. NIBIRU_REPO="./nibiru" -COSMOS_SDK_REPO="./cosmos-sdk" PKG_OUT_DIR="./src/protojs" # ----------------------------------------------------------------------------- @@ -28,13 +27,6 @@ for dir in $(find $NIBIRU_REPO/proto -path -prune -o -name '*.proto' -print0 | x done done; -for dir in $(find $COSMOS_SDK_REPO/x/staking/proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | uniq | sort); do \ - for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do - echo "Generating ts proto code for $file" - buf generate --template $NIBIRU_REPO/proto/buf.gen.ts.yaml -o $PKG_OUT_DIR $file - done -done; - yarn generate-barrels # # the `descriptor.ts` file is only used for gogoproto, and it causes issues with TS-generated code rm $PKG_OUT_DIR/google/protobuf/descriptor.ts @@ -47,14 +39,12 @@ rm -rf $PKG_OUT_DIR/cosmos/msg rm $PKG_OUT_DIR/google/api/annotations.ts rm $PKG_OUT_DIR/index.gogoproto.ts rm $PKG_OUT_DIR/index.amino.ts -rm $PKG_OUT_DIR/index.google.ts rm $PKG_OUT_DIR/index.cosmos.msg.v1.ts rm $PKG_OUT_DIR/index.cosmos.msg.ts -rm $PKG_OUT_DIR/index.cosmos.query.v1.ts -rm $PKG_OUT_DIR/index.cosmos.query.ts sed 's/export \* as gogoproto from \"\.\/index\.gogoproto\"\;//' $PKG_OUT_DIR/index.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts sed 's/export \* as amino from \"\.\/index\.amino\"\;//' $PKG_OUT_DIR/index.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts sed 's/export \* as google from \"\.\/index\.google\"\;//' $PKG_OUT_DIR/index.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.ts sed 's/export \* from \"\.\/google\/api\/annotations\"\;//' $PKG_OUT_DIR/index.google.api.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.google.api.ts +sed 's/export \* as protobuf from \"\.\/index.google.protobuf\"\;//' $PKG_OUT_DIR/index.google.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.google.ts sed 's/export \* as msg from \"\.\/index.cosmos.msg\"\;//' $PKG_OUT_DIR/index.cosmos.ts > tmpfile && mv tmpfile $PKG_OUT_DIR/index.cosmos.ts diff --git a/src/sdk/query/index.ts b/src/sdk/query/index.ts index 22e95d02..bba5ece6 100644 --- a/src/sdk/query/index.ts +++ b/src/sdk/query/index.ts @@ -7,5 +7,4 @@ export * from "./epochs" export * from "./inflation" export * from "./oracle" export * from "./query" -export * from "./staking" export * from "./sudo" diff --git a/src/sdk/query/query.ts b/src/sdk/query/query.ts index 59e2290a..dd05e714 100644 --- a/src/sdk/query/query.ts +++ b/src/sdk/query/query.ts @@ -29,13 +29,11 @@ import { SudoExtension, InflationExtension, setupInflationExtension, - setupStakeExtension, Result, bytesToHex, hexToBytes, setupDevgasExtension, DevgasExtension, - StakeExtension, } from ".." export type NibiruExtensions = StargateQueryClient & @@ -47,7 +45,6 @@ export type NibiruExtensions = StargateQueryClient & DistributionExtension & GovExtension & StakingExtension & - StakeExtension & IbcExtension & WasmExtension & AuthExtension @@ -93,8 +90,7 @@ export class NibiruQuerier extends StargateClient { setupStakingExtension, setupIbcExtension, setupWasmExtension, - setupAuthExtension, - setupStakeExtension + setupAuthExtension ) } diff --git a/src/sdk/query/staking.test.ts b/src/sdk/query/staking.test.ts deleted file mode 100644 index ba06dc87..00000000 --- a/src/sdk/query/staking.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { QueryClient, coin } from "@cosmjs/stargate" -import * as query from "../../protojs/cosmos/staking/v1beta1/tx" -import { setupStakeExtension } from "." -import Long from "long" - -describe("setupStakingExtension", () => { - const mockBaseQueryClient = {} as QueryClient - - jest.spyOn(query, "MsgClientImpl").mockReturnValue({ - QuerySudoers: jest.fn().mockResolvedValue({ staking: {} }), - } as unknown as query.MsgClientImpl) - - test("should setup sudo extension correctly", () => { - const extension = setupStakeExtension(mockBaseQueryClient) - - expect(extension.staking).toBeDefined() - expect(extension.staking.cancelUnbondingDelegation).toBeInstanceOf(Function) - }) - - describe("sudo.querySudoers", () => { - test("should call QuerySudoersRequest and return the response", async () => { - const querySudoersRequest = jest - .spyOn(query.MsgCancelUnbondingDelegation, "fromPartial") - .mockReturnValue({} as query.MsgCancelUnbondingDelegation) - - const extension = setupStakeExtension(mockBaseQueryClient) - const testArgs = { - validatorAddress: "", - delegatorAddress: "", - amount: coin(1, "unibi"), - creationHeight: new Long(0), - } - const result = await extension.staking.cancelUnbondingDelegation(testArgs) - - expect(querySudoersRequest).toHaveBeenCalledWith(testArgs) - expect(result).toEqual({ staking: {} }) - }) - }) -}) diff --git a/src/sdk/query/staking.ts b/src/sdk/query/staking.ts deleted file mode 100644 index a46e00a1..00000000 --- a/src/sdk/query/staking.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" -import { - MsgCancelUnbondingDelegation, - MsgCancelUnbondingDelegationResponse, - MsgClientImpl, -} from "../../protojs/cosmos/staking/v1beta1/tx" - -export interface StakeExtension { - readonly staking: Readonly<{ - cancelUnbondingDelegation: ( - args: MsgCancelUnbondingDelegation - ) => Promise - }> -} - -export const setupStakeExtension = (base: QueryClient): StakeExtension => { - const rpcClient = createProtobufRpcClient(base) - const queryService = new MsgClientImpl(rpcClient) - - return { - staking: { - cancelUnbondingDelegation: async (args: MsgCancelUnbondingDelegation) => { - const req = MsgCancelUnbondingDelegation.fromPartial(args) - const resp = await queryService.CancelUnbondingDelegation(req) - return resp - }, - }, - } -} diff --git a/src/sdk/tx/txClient.ts b/src/sdk/tx/txClient.ts index 33a498e4..81ef2530 100644 --- a/src/sdk/tx/txClient.ts +++ b/src/sdk/tx/txClient.ts @@ -24,7 +24,6 @@ import { setupOracleExtension, setupEpochsExtension, setupDevgasExtension, - setupStakeExtension, } from ".." export const nibiruRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [ @@ -53,7 +52,6 @@ export class NibiruTxClient extends SigningStargateClient { setupDistributionExtension, setupGovExtension, setupStakingExtension, - setupStakeExtension, setupIbcExtension, setupWasmExtension, setupAuthExtension