Skip to content

Commit

Permalink
Merge pull request #1527 from cosmos/short-denoms
Browse files Browse the repository at this point in the history
Require protocol to be set in endpoint URLs
  • Loading branch information
webmaster128 authored Dec 19, 2023
2 parents 7ee2aa0 + 8979eac commit b23d0b7
Show file tree
Hide file tree
Showing 31 changed files with 256 additions and 224 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ and this project adheres to

[#1522]: https://github.com/cosmos/cosmjs/pull/1522

### Changed

- @cosmjs/tendermint-rpc: Require protocol to be set in endpoint URLs (https://,
http://, wss:// or ws://). Otherwise an error is raised instead of falling
back to ws://. ([#1527])

[#1527]: https://github.com/cosmos/cosmjs/pull/1527

## [0.32.1] - 2023-12-04

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/faucet/src/faucet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const faucetMnemonic =
describe("Faucet", () => {
const pathBuilder = makeCosmoshubPath;

const apiUrl = "localhost:26658";
const apiUrl = "http://localhost:26658";
const stargate = true;
let originalEnvVariable: string | undefined;

Expand Down
6 changes: 3 additions & 3 deletions packages/stargate/src/modules/auth/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("AuthExtension", () => {
describe("account", () => {
it("works for unused account", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrlHttp);
const account = await client.auth.account(unused.address);
assert(account);

Expand All @@ -36,7 +36,7 @@ describe("AuthExtension", () => {

it("works for account with pubkey and non-zero sequence", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrlHttp);
const account = await client.auth.account(validator.delegatorAddress);
assert(account);

Expand All @@ -53,7 +53,7 @@ describe("AuthExtension", () => {

it("rejects for non-existent address", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrlHttp);

await expectAsync(client.auth.account(nonExistentAddress)).toBeRejectedWithError(
/account cosmos1p79apjaufyphcmsn4g07cynqf0wyjuezqu84hd not found/i,
Expand Down
8 changes: 4 additions & 4 deletions packages/stargate/src/modules/authz/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("AuthzExtension", () => {
hdPaths: [makeCosmoshubPath(1), makeCosmoshubPath(2)],
});
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrl,
simapp.tendermintUrlHttp,
wallet,
defaultSigningClientOptions,
);
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("AuthzExtension", () => {
describe("grants", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrlHttp);
const response = await client.authz.grants(granter1Address, grantee1Address, "");
expect(response.grants.length).toEqual(1);
const grant = response.grants[0];
Expand All @@ -103,7 +103,7 @@ describe("AuthzExtension", () => {
describe("granter grants", () => {
it("works", async () => {
pendingWithoutSimapp46OrHigher();
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrlHttp);
const response = await client.authz.granterGrants(granter1Address);
expect(response.grants.length).toBeGreaterThanOrEqual(1);
const grant = response.grants.find(
Expand Down Expand Up @@ -134,7 +134,7 @@ describe("AuthzExtension", () => {
describe("grantee grants", () => {
it("works", async () => {
pendingWithoutSimapp46OrHigher();
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrlHttp);
const response = await client.authz.granteeGrants(grantee1Address);
expect(response.grants.length).toEqual(1);
const grant = response.grants[0];
Expand Down
22 changes: 11 additions & 11 deletions packages/stargate/src/modules/bank/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("BankExtension", () => {
describe("balance", () => {
it("works for different existing balances", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const response1 = await client.bank.balance(unused.address, simapp.denomFee);
expect(response1).toEqual({
Expand All @@ -37,7 +37,7 @@ describe("BankExtension", () => {

it("returns zero for non-existent balance", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const response = await client.bank.balance(unused.address, "gintonic");
expect(response).toEqual({
Expand All @@ -50,7 +50,7 @@ describe("BankExtension", () => {

it("returns zero for non-existent address", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const response = await client.bank.balance(nonExistentAddress, simapp.denomFee);
expect(response).toEqual({
Expand All @@ -65,7 +65,7 @@ describe("BankExtension", () => {
describe("allBalances", () => {
it("returns all balances for unused account", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const balances = await client.bank.allBalances(unused.address);
expect(balances).toEqual([
Expand All @@ -84,7 +84,7 @@ describe("BankExtension", () => {

it("returns an empty list for non-existent account", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const balances = await client.bank.allBalances(nonExistentAddress);
expect(balances).toEqual([]);
Expand All @@ -96,7 +96,7 @@ describe("BankExtension", () => {
describe("totalSupply", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const { supply } = await client.bank.totalSupply();
expect(supply).toEqual([
Expand All @@ -117,7 +117,7 @@ describe("BankExtension", () => {
describe("supplyOf", () => {
it("works for existing denom", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const response = await client.bank.supplyOf(simapp.denomFee);
expect(response).toEqual({
Expand All @@ -130,7 +130,7 @@ describe("BankExtension", () => {

it("returns zero for non-existent denom", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const response = await client.bank.supplyOf("gintonic");
expect(response).toEqual({
Expand All @@ -145,7 +145,7 @@ describe("BankExtension", () => {
describe("denomMetadata", () => {
it("works for existent denom", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const metadata = await client.bank.denomMetadata("ucosm");
expect(metadata).toEqual(
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("BankExtension", () => {

it("works for non-existent denom", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

await expectAsync(client.bank.denomMetadata("nothere")).toBeRejectedWithError(/code = NotFound/i);

Expand All @@ -186,7 +186,7 @@ describe("BankExtension", () => {
describe("denomsMetadata", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);

const metadatas = await client.bank.denomsMetadata();
expect(metadatas.length).toEqual(1);
Expand Down
20 changes: 10 additions & 10 deletions packages/stargate/src/modules/distribution/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("DistributionExtension", () => {
if (simappEnabled()) {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrl,
simapp.tendermintUrlHttp,
wallet,
defaultSigningClientOptions,
);
Expand All @@ -60,7 +60,7 @@ describe("DistributionExtension", () => {
describe("communityPool", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.communityPool();
expect(response.pool).toBeDefined();
Expand All @@ -73,7 +73,7 @@ describe("DistributionExtension", () => {
describe("delegationRewards", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.delegationRewards(
faucet.address0,
Expand All @@ -89,7 +89,7 @@ describe("DistributionExtension", () => {
describe("delegationTotalRewards", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.delegationTotalRewards(faucet.address0);
expect(response.rewards).toBeDefined();
Expand All @@ -102,7 +102,7 @@ describe("DistributionExtension", () => {
describe("delegatorValidators", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.delegatorValidators(faucet.address0);
expect(response.validators).toBeDefined();
Expand All @@ -115,7 +115,7 @@ describe("DistributionExtension", () => {
describe("delegatorWithdrawAddress", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.delegatorWithdrawAddress(faucet.address0);
expect(response.withdrawAddress).toBeDefined();
Expand All @@ -128,7 +128,7 @@ describe("DistributionExtension", () => {
describe("params", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.params();
expect(response.params).toBeDefined();
Expand All @@ -141,7 +141,7 @@ describe("DistributionExtension", () => {
describe("validatorCommission", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.validatorCommission(validator.validatorAddress);
expect(response.commission).toBeDefined();
Expand All @@ -154,7 +154,7 @@ describe("DistributionExtension", () => {
describe("validatorOutstandingRewards", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.validatorOutstandingRewards(validator.validatorAddress);
expect(response.rewards).toBeDefined();
Expand All @@ -167,7 +167,7 @@ describe("DistributionExtension", () => {
describe("validatorSlashes", () => {
it("works", async () => {
pendingWithoutSimapp();
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrlHttp);

const response = await client.distribution.validatorSlashes(validator.validatorAddress, 1, 5);
expect(response.slashes).toBeDefined();
Expand Down
16 changes: 11 additions & 5 deletions packages/stargate/src/modules/gov/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("gov messages", () => {
voterWallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic, { hdPaths: voterPaths });
voterWalletAmino = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic, { hdPaths: voterPaths });
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrl,
simapp.tendermintUrlHttp,
voterWallet,
defaultSigningClientOptions,
);
Expand Down Expand Up @@ -132,7 +132,7 @@ describe("gov messages", () => {
pendingWithoutSimapp();
assert(voterWallet);
assert(proposalId, "Missing proposal ID");
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, voterWallet);
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrlHttp, voterWallet);

const voteMsg: MsgVoteEncodeObject = {
typeUrl: "/cosmos.gov.v1beta1.MsgVote",
Expand All @@ -152,7 +152,10 @@ describe("gov messages", () => {
pendingWithoutSimapp();
assert(voterWalletAmino);
assert(proposalId, "Missing proposal ID");
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, voterWalletAmino);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrlHttp,
voterWalletAmino,
);

const voteMsg: MsgVoteEncodeObject = {
typeUrl: "/cosmos.gov.v1beta1.MsgVote",
Expand All @@ -174,7 +177,7 @@ describe("gov messages", () => {
pendingWithoutSimapp();
assert(voterWallet);
assert(proposalId, "Missing proposal ID");
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, voterWallet);
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrlHttp, voterWallet);

const voteMsg: MsgVoteWeightedEncodeObject = {
typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted",
Expand Down Expand Up @@ -208,7 +211,10 @@ describe("gov messages", () => {
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");
assert(voterWalletAmino);
assert(proposalId, "Missing proposal ID");
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, voterWalletAmino);
const client = await SigningStargateClient.connectWithSigner(
simapp.tendermintUrlHttp,
voterWalletAmino,
);

const voteMsg: MsgVoteWeightedEncodeObject = {
typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted",
Expand Down
Loading

0 comments on commit b23d0b7

Please sign in to comment.