Skip to content

Commit

Permalink
Merge pull request #118 from cosmos-client/remove-accaddress
Browse files Browse the repository at this point in the history
Remove accaddress
  • Loading branch information
Senna46 authored Sep 27, 2023
2 parents 8a7e2ec + d3809d5 commit f425aa5
Show file tree
Hide file tree
Showing 16 changed files with 354 additions and 238 deletions.
2 changes: 1 addition & 1 deletion gen-openapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rm swagger.yaml
cp ./cosmos-sdk/client/docs/swagger-ui/swagger.yaml ./swagger.yaml

docker run --rm \
-v ${PWD}:/local openapitools/openapi-generator-cli generate \
-v ${PWD}:/local openapitools/openapi-generator-cli generate --skip-validate-spec \
-g typescript-axios -i /local/swagger.yaml -o /local/src/openapi/

# rm swagger.yaml
4 changes: 2 additions & 2 deletions gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ npx pbts \
-o ./src/proto.d.ts \
./src/proto.js

echo Edit proto.d.ts to resolve the conflict of `tendermint` namespace.
echo Require to rename `cometbft` proto
echo Edit proto.d.ts to resolve the conflict of tendermint namespace.
echo Require to rename cometbft proto

rm -r ./proto
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cosmos-client/core",
"description": "REST API client for Cosmos SDK blockchain",
"version": "0.47.1",
"version": "0.47.3",
"author": "CauchyE, Inc.",
"bugs": {
"url": "https://github.com/cosmos-client/cosmos-client-ts/issues"
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.6.0-SNAPSHOT
7.0.0-SNAPSHOT
423 changes: 229 additions & 194 deletions src/openapi/api.ts

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/rest/auth/module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { QueryApi } from '../../openapi/api';
import { CosmosSDK } from '../../sdk';
import { AccAddress } from '../../types';

export function account(sdk: CosmosSDK, address: AccAddress) {
return new QueryApi(undefined, sdk.url).account(address.toString());
export function account(sdk: CosmosSDK, address: string) {
return new QueryApi(undefined, sdk.url).account(address);
}

export function params(sdk: CosmosSDK) {
Expand Down
9 changes: 4 additions & 5 deletions src/rest/authz/module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { QueryApi } from '../../openapi/api';
import { CosmosSDK } from '../../sdk';
import { AccAddress } from '../../types';

export function grants(
sdk: CosmosSDK,
granter: AccAddress,
grantee: AccAddress,
granter: string,
grantee: string,
msgTypeUrl?: string,
paginationKey?: string,
paginationOffset?: bigint,
paginationLimit?: bigint,
paginationCountTotal?: boolean,
) {
return new QueryApi(undefined, sdk.url).grants(
granter.toString(),
grantee.toString(),
granter,
grantee,
msgTypeUrl,
paginationKey,
paginationOffset?.toString(),
Expand Down
8 changes: 4 additions & 4 deletions src/rest/bank/bank-multisig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('bank', () => {
});
const address = cosmosclient.AccAddress.fromPublicKey(multisigPubKey);

const fromAddress = address;
const toAddress = address;
const fromAddress = address.toString();
const toAddress = address.toString();

// get account info
const account = await cosmosclient.rest.auth
Expand All @@ -45,8 +45,8 @@ describe('bank', () => {

// build tx
const msgSend = new cosmosclient.proto.cosmos.bank.v1beta1.MsgSend({
from_address: fromAddress.toString(),
to_address: toAddress.toString(),
from_address: fromAddress,
to_address: toAddress,
amount: [{ denom: 'token', amount: '1' }],
});

Expand Down
8 changes: 4 additions & 4 deletions src/rest/bank/bank.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('bank', () => {

expect(address.toString()).toBe('cosmos14ynfqqa6j5k3kcqm2ymf3l66d9x07ysxgnvdyx');

const fromAddress = address;
const toAddress = address;
const fromAddress = address.toString();
const toAddress = address.toString();

// get account info
const account = await cosmosclient.rest.auth
Expand All @@ -31,8 +31,8 @@ describe('bank', () => {

// build tx
const msgSend = new cosmosclient.proto.cosmos.bank.v1beta1.MsgSend({
from_address: fromAddress.toString(),
to_address: toAddress.toString(),
from_address: fromAddress,
to_address: toAddress,
amount: [{ denom: 'token', amount: '1' }],
});

Expand Down
9 changes: 4 additions & 5 deletions src/rest/bank/module.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { QueryApi } from '../../openapi/api';
import { CosmosSDK } from '../../sdk';
import { AccAddress } from '../../types';

export function allBalances(
sdk: CosmosSDK,
address: AccAddress,
address: string,
paginationKey?: string,
paginationOffset?: bigint,
paginationLimit?: bigint,
paginationCountTotal?: boolean,
) {
return new QueryApi(undefined, sdk.url).allBalances(
address.toString(),
address,
paginationKey,
paginationOffset?.toString(),
paginationLimit?.toString(),
paginationCountTotal,
);
}

export function balance(sdk: CosmosSDK, address: AccAddress, denom: string) {
return new QueryApi(undefined, sdk.url).balance(address.toString(), denom);
export function balance(sdk: CosmosSDK, address: string, denom: string) {
return new QueryApi(undefined, sdk.url).balance(address, denom);
}

export function params(sdk: CosmosSDK) {
Expand Down
7 changes: 3 additions & 4 deletions src/rest/feegrant/module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { QueryApi } from '../../openapi/api';
import { CosmosSDK } from '../../sdk';
import { AccAddress } from '../../types';

export function allowance(sdk: CosmosSDK, granter: AccAddress, grantee: AccAddress) {
export function allowance(sdk: CosmosSDK, granter: string, grantee: string) {
return new QueryApi(undefined, sdk.url).allowance(granter.toString(), grantee.toString());
}

export function allowances(
sdk: CosmosSDK,
grantee: AccAddress,
grantee: string,
paginationKey?: string,
paginationOffset?: bigint,
paginationLimit?: bigint,
paginationCountTotal?: boolean,
) {
return new QueryApi(undefined, sdk.url).allowances(
grantee.toString(),
grantee,
paginationKey,
paginationOffset?.toString(),
paginationLimit?.toString(),
Expand Down
96 changes: 90 additions & 6 deletions src/rest/gov/module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { QueryApi } from '../../openapi/api';
import { GovV1ProposalProposalStatusEnum, QueryApi } from '../../openapi/api';
import { CosmosSDK } from '../../sdk';
import { AccAddress } from '../../types';

export function params(sdk: CosmosSDK, paramsType: string) {
return new QueryApi(undefined, sdk.url).govParams(paramsType);
}

// deprecated gov/v1beta1
export function proposals(
sdk: CosmosSDK,
proposalStatus?:
Expand Down Expand Up @@ -33,10 +33,39 @@ export function proposals(
);
}

export function govV1Proposals(
sdk: CosmosSDK,
proposalStatus?: GovV1ProposalProposalStatusEnum,
voter?: string,
depositor?: string,
paginationKey?: string,
paginationOffset?: string,
paginationLimit?: string,
paginationCountTotal?: boolean,
paginationReverse?: boolean,
) {
return new QueryApi(undefined, sdk.url).govV1Proposal(
proposalStatus,
voter,
depositor,
paginationKey,
paginationOffset,
paginationLimit,
paginationCountTotal,
paginationReverse,
);
}

// deprecated gov/v1beta1
export function proposal(sdk: CosmosSDK, proposalID: string) {
return new QueryApi(undefined, sdk.url).proposal(proposalID);
}

export function govV1Proposal(sdk: CosmosSDK, proposalID: string) {
return new QueryApi(undefined, sdk.url).govV1Proposal_2(proposalID);
}

// deprecated gov/v1beta1
export function deposits(
sdk: CosmosSDK,
proposalID: string,
Expand All @@ -54,14 +83,44 @@ export function deposits(
);
}

export function deposit(sdk: CosmosSDK, proposalID: string, depositor: AccAddress) {
return new QueryApi(undefined, sdk.url).deposit(proposalID, depositor.toString());
export function govV1Deposits(
sdk: CosmosSDK,
proposalID: string,
paginationKey?: string,
paginationOffset?: string,
paginationLimit?: string,
paginationCountTotal?: boolean,
paginationReverse?: boolean,
) {
return new QueryApi(undefined, sdk.url).govV1Deposit(
proposalID,
paginationKey,
paginationOffset,
paginationLimit,
paginationCountTotal,
paginationReverse
);
}

// deprecated gov/v1beta1
export function deposit(sdk: CosmosSDK, proposalID: string, depositor: string) {
return new QueryApi(undefined, sdk.url).deposit(proposalID, depositor);
}

export function govV1Deposit(sdk: CosmosSDK, proposalID: string, depositor: string) {
return new QueryApi(undefined, sdk.url).govV1Deposit_1(proposalID, depositor);
}

// deprecated gov/v1beta1
export function tallyresult(sdk: CosmosSDK, proposalID: string) {
return new QueryApi(undefined, sdk.url).tallyResult(proposalID);
}

export function govV1TallyResult(sdk: CosmosSDK, proposalID: string) {
return new QueryApi(undefined, sdk.url).govV1TallyResult(proposalID);
}

// deprecated gov/v1beta1
export function votes(
sdk: CosmosSDK,
proposalID: string,
Expand All @@ -79,6 +138,31 @@ export function votes(
);
}

export function vote(sdk: CosmosSDK, proposalID: string, voter: AccAddress) {
return new QueryApi(undefined, sdk.url).vote(proposalID, voter.toString());
export function govV1Votes(
sdk: CosmosSDK,
proposalID: string,
paginationKey?: string,
paginationOffset?: string,
paginationLimit?: string,
paginationCountTotal?: boolean,
paginationReverse?: boolean,
) {
return new QueryApi(undefined, sdk.url).govV1Votes(
proposalID,
paginationKey,
paginationOffset,
paginationLimit,
paginationCountTotal,
paginationReverse
);
}

// deprecated gov/v1beta1
export function vote(sdk: CosmosSDK, proposalID: string, voter: string) {
return new QueryApi(undefined, sdk.url).vote(proposalID, voter);
}

export function govV1Vote(sdk: CosmosSDK, proposalID: string, voter: string) {
return new QueryApi(undefined, sdk.url).govV1Vote(proposalID, voter);
}

7 changes: 4 additions & 3 deletions src/rest/tx/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ServiceApi,
BroadcastTxRequest,
BroadcastTxRequestModeEnum as BroadcastTxMode,
GetTxsEventOrderByEnum,
} from '../../openapi/api';
import { CosmosSDK } from '../../sdk';

Expand All @@ -20,11 +21,11 @@ export function getTxsEvent(
sdk: CosmosSDK,
events?: string[],
paginationKey?: string,
paginationOffset?: bigint,
paginationLimit?: bigint,
paginationOffset?: string,
paginationLimit?: string,
paginationCountTotal?: boolean,
paginationReverse?: boolean,
orderBy?: 'ORDER_BY_UNSPECIFIED' | 'ORDER_BY_ASC' | 'ORDER_BY_DESC',
orderBy?: GetTxsEventOrderByEnum,
page?: string,
limit?: string
) {
Expand Down
2 changes: 1 addition & 1 deletion src/types/codec/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function instanceToProtoAny(value: { constructor: Function }) {

const typeURL = constructor && config.codecMaps.inv.get(constructor);
if (!typeURL) {
throw Error(`This type is not registered: ${typeURL}`);
throw Error(`This type is not registered: ${constructor}`);
}

const packed = new google.protobuf.Any({
Expand Down
4 changes: 2 additions & 2 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13632,7 +13632,7 @@ paths:
/cosmos/gov/v1/proposals:
get:
summary: Proposals queries all proposals based on given status.
operationId: GovV1Proposals
operationId: GovV1Proposal
responses:
'200':
description: A successful response.
Expand Down Expand Up @@ -14739,7 +14739,7 @@ paths:
/cosmos/gov/v1/proposals/{proposal_id}/deposits:
get:
summary: Deposits queries all deposits of a single proposal.
operationId: GovV1Deposits
operationId: GovV1Deposit
responses:
'200':
description: A successful response.
Expand Down

0 comments on commit f425aa5

Please sign in to comment.