-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: staking extension and git submodules
- Loading branch information
Showing
11 changed files
with
107 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "cosmos-sdk"] | ||
path = cosmos-sdk | ||
url = https://github.com/cosmos/cosmos-sdk | ||
[submodule "nibiru"] | ||
path = nibiru | ||
url = https://github.com/NibiruChain/nibiru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,5 +117,6 @@ | |
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"gitHead": "bac1729be8575a9e75bf9e04447a63c45e227c8c" | ||
"gitHead": "bac1729be8575a9e75bf9e04447a63c45e227c8c", | ||
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,8 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Test for ./nibiru/ directory | ||
if [ -d "./nibiru/" ]; then | ||
echo "The ./nibiru/ directory exists." | ||
cd nibiru | ||
git checkout main | ||
cd .. | ||
elif [ -d "../nibiru/" ]; then | ||
cd ../nibiru | ||
git checkout main | ||
git pull | ||
cd ../ts-sdk | ||
else | ||
cd .. | ||
git clone [email protected]:NibiruChain/nibiru.git | ||
cd ts-sdk | ||
fi | ||
git submodule init | ||
git submodule update | ||
|
||
yarn gql-generate & yarn proto-gen | ||
yarn build:tsc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { QueryClient, coin } from "@cosmjs/stargate" | ||
import * as query from "../../protojs/cosmos/staking/v1beta1/tx" | ||
import { setupStakingExtension } 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 = setupStakingExtension(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 = setupStakingExtension(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: {} }) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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<MsgCancelUnbondingDelegationResponse> | ||
}> | ||
} | ||
|
||
export const setupStakingExtension = (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 | ||
}, | ||
}, | ||
} | ||
} |