Skip to content

Commit

Permalink
Merge pull request #247 from hangts/feature/v3.0.0
Browse files Browse the repository at this point in the history
Feature/v3.0.0
  • Loading branch information
kaifei Hu authored Jun 17, 2022
2 parents bedf3f0 + 3edcdd2 commit 42ca9de
Show file tree
Hide file tree
Showing 254 changed files with 65,066 additions and 1,271 deletions.
87 changes: 76 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,27 @@ const res = await client.bank.send({
}
})
```
### auth `src/modules/auth.ts`
- newStdTx
- queryAccount
- queryAccounts
- queryParams
### bank `src/modules/bank.ts`
- send
- multiSend
- queryBalance
- queryAllBalances
- queryTotalSupply
- querySupplyOf
- queryDenomMetadata
- queryDenomsMetadata
- queryParams
### auth `src/modules/auth.ts`
- newStdTx
- queryAccount
- queryParams
### bank `src/modules/coinswap.ts`
- addLiquidity
- removeLiquidity
- swapOrder
- queryLiquidity

### distribution `src/modules/distribution.ts`
- setWithdrawAddr
- withdrawRewards
Expand All @@ -171,6 +180,14 @@ const res = await client.bank.send({
- queryDelegatorValidators
- queryDelegatorWithdrawAddress
- queryCommunityPool
### keys `src/modules/farm.ts`
- stakeLp
- unStakeLp
- harvestReward
- queryFarmPools
- queryFarmPool
- queryFarmer
- queryParams
### gov `src/modules/gov.ts`
- queryProposal
- queryProposals
Expand All @@ -184,6 +201,20 @@ const res = await client.bank.send({
- submitCommunityTaxUsageProposal
- deposit
- vote

### bank `src/modules/htlc.ts`
- createHTLC
- claimHTLC
- queryHTLC
- queryAssetSupply
- queryAssetSupplies
- queryParams
### bank `src/modules/ibc.ts`
- transfer
- queryDenomTrace
- queryDenomTraces
- queryParams
- queryChannels
### keys `src/modules/keys.ts`
- add
- recover
Expand All @@ -204,6 +235,46 @@ const res = await client.bank.send({
- queryDenom
- queryDenoms
- queryNFT
### slashing `src/modules/oracle.ts`
- queryFeed
- queryFeeds
- queryFeedValue
### protobuf `src/modules/protobuf.ts`
- deserializeTx
- unpackMsg
- deserializeSignDoc
- deserializeTxRaw
- deserializeSigningInfo
- deserializePubkey
### slashing `src/modules/random.ts`
- queryRandom
- queryRequest
- request
### slashing `src/modules/service.ts`
- queryDefinition
- queryBinding
- queryBindings
- queryRequest
- queryRequests
- queryRequestsByReqCtx
- queryRequestContext
- queryResponse
- queryResponses
- queryFees
- defineService
- bindService
- updateServiceBinding
- disableServiceBinding
- enableServiceBinding
- invokeService
- setWithdrawAddress
- refundServiceDeposit
- startRequestContext
- pauseRequestContext
- killRequestContext
- updateRequestContext
- withdrawEarnedFees
- withdrawTax
### slashing `src/modules/slashing.ts`
- queryParams
- querySigningInfo
Expand Down Expand Up @@ -235,6 +306,7 @@ const res = await client.bank.send({
- queryValidators
- searchTxs
- queryNetInfo
- queryGlobalAccountNumber
### token `src/modules/token.ts`
- issueToken
- editToken
Expand All @@ -257,11 +329,4 @@ const res = await client.bank.send({
- broadcastTx
- newTxResult
- createMsg
### protobuf `src/modules/protobuf.ts`
- deserializeTx
- unpackMsg
- deserializeSignDoc
- deserializeTxRaw
- deserializeSigningInfo
- deserializePubkey

4 changes: 2 additions & 2 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irisnet/irishub-sdk",
"version": "2.0.1",
"version": "3.0.0",
"description": "IRISHub JavaScript SDK",
"main": "index.js",
"typings": "index.ts",
Expand All @@ -25,7 +25,7 @@
"test": "yarn run node && jest -i --config jest.config.js && sh test/scripts/clean.sh",
"check": "gts check",
"clean": "gts clean",
"build": "rm -rf dist/* && tsc --emitDeclarationOnly && babel --extensions .ts src -d dist/src && cp LICENSE dist/ && cp README.md dist/ && cp package.json dist/ && cp -rf src/types/proto-types dist/src/types/proto-types",
"build": "rm -rf dist/* && tsc --emitDeclarationOnly && babel --extensions '.ts' src -d dist/src && cp LICENSE dist/ && cp README.md dist/ && cp package.json dist/ && cp -rf src/types/proto-types dist/src/types/proto-types",
"buildForWindows": "rm -rf dist/* && tsc --emitDeclarationOnly && babel --extensions .ts src -d dist/src && cp LICENSE dist/ && cp README.md dist/ && cp package.json dist/ && cp -rf src/types/proto-types dist/src/types/proto-types",
"fix": "gts fix",
"docs": "npx typedoc && docker build -t irisnet/docs-irishub-sdk-js .",
Expand Down
3 changes: 2 additions & 1 deletion dist/src/helper/modelCreator.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as types from '../types';
export declare class ModelCreator {
static createPaginationModel(page_number?: number, page_size?: number, count_total?: boolean, key?: string): any;
static createPaginationModel(pageInfo?: types.Pagination): any;
}
19 changes: 10 additions & 9 deletions dist/src/helper/modelCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ var ModelCreator = /*#__PURE__*/function () {

(0, _createClass2["default"])(ModelCreator, null, [{
key: "createPaginationModel",
value: function createPaginationModel() {
var page_number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var page_size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 30;
var count_total = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var key = arguments.length > 3 ? arguments[3] : undefined;
value: function createPaginationModel(pageInfo) {
var _pageInfo$count_total, _pageInfo$reverse;

var pagination = new types.base_query_pagination_pb.PageRequest();

if (is.not.undefined(key)) {
if (is.not.undefined(pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.key)) {
//only one of offset or key should be set.
pagination.setKey(key);
pagination.setKey(pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.key);
} else {
var page_number = (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.page_number) || 1;
var page_size = (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.page_size) || 10;
pagination.setOffset((page_number - 1) * page_size > 0 ? (page_number - 1) * page_size : 0);
pagination.setLimit(page_size > 0 ? page_size : 10);
pagination.setLimit(page_size);
}

pagination.setCountTotal(count_total);
pagination.setCountTotal((_pageInfo$count_total = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.count_total) !== null && _pageInfo$count_total !== void 0 ? _pageInfo$count_total : true);
pagination.setReverse((_pageInfo$reverse = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.reverse) !== null && _pageInfo$reverse !== void 0 ? _pageInfo$reverse : false);
return pagination;
}
}]);
Expand Down
6 changes: 5 additions & 1 deletion dist/src/modules/auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export declare class Auth {
* Account returns account details based on address.
* @param address defines the address to query for.
*/
queryAccount(address: string): Promise<types.BaseAccount>;
queryAccount(address: string): Promise<object>;
/**
* Accounts returns all the existing accounts
*/
queryAccounts(pagination?: types.Pagination): Promise<object[]>;
/**
* Params queries all parameters.
*/
Expand Down
35 changes: 27 additions & 8 deletions dist/src/modules/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var is = _interopRequireWildcard(require("is_js"));

var _errors = require("../errors");

var _helper = require("../helper");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
Expand Down Expand Up @@ -97,24 +99,41 @@ var Auth = /*#__PURE__*/function () {
}, {
key: "queryAccount",
value: function queryAccount(address) {
var _this = this;

if (!address) {
throw new _errors.SdkError("address can ont be empty");
}

var request = new types.auth_query_pb.QueryAccountRequest();
request.setAddress(address);
return this.client.rpcClient.protoQuery('/cosmos.auth.v1beta1.Query/Account', request, types.auth_query_pb.QueryAccountResponse).then(function (data) {
var result = {};
return this.client.rpcClient.protoQuery('/cosmos.auth.v1beta1.Query/Account', request, types.auth_query_pb.QueryAccountResponse).then(function (res) {
if (res && res.account) {
res.account = _this.client.protobuf.deserializeAccount(res.account);
}

if (data && data.account && data.account.value) {
result = types.auth_auth_pb.BaseAccount.deserializeBinary(data.account.value).toObject();
return res;
});
}
/**
* Accounts returns all the existing accounts
*/

if (result.pubKey && result.pubKey.value) {
result.pubKey = types.crypto_secp256k1_keys_pb.PubKey.deserializeBinary(result.pubKey.value).toObject();
}
}, {
key: "queryAccounts",
value: function queryAccounts(pagination) {
var _this2 = this;

var request = new types.auth_query_pb.QueryAccountsRequest();
request.setPagination(_helper.ModelCreator.createPaginationModel(pagination));
return this.client.rpcClient.protoQuery('/cosmos.auth.v1beta1.Query/Accounts', request, types.auth_query_pb.QueryAccountsResponse).then(function (res) {
if (res && res.accountsList) {
res.accountsList = res.accountsList.map(function (item) {
return _this2.client.protobuf.deserializeAccount(item);
});
}

return result;
return res;
});
}
/**
Expand Down
10 changes: 9 additions & 1 deletion dist/src/modules/bank.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export declare class Bank {
/**
* TotalSupply queries the total supply of all coins.
*/
queryTotalSupply(): Promise<object>;
queryTotalSupply(pagination?: types.Pagination): Promise<object>;
/**
* SupplyOf queries the supply of a single coin.
* @param denom is the coin denom to query balances for.
Expand All @@ -57,4 +57,12 @@ export declare class Bank {
* Params queries the parameters of x/bank module.
*/
queryParams(): Promise<object>;
/**
* DenomsMetadata queries the client metadata of a given coin denomination.
*/
queryDenomMetadata(denom: string): Promise<object>;
/**
* DenomsMetadata queries the client metadata for all registered coin denominations.
*/
queryDenomsMetadata(pagination?: types.Pagination): Promise<object>;
}
31 changes: 30 additions & 1 deletion dist/src/modules/bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var types = _interopRequireWildcard(require("../types"));

var _errors = require("../errors");

var _helper = require("../helper");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
Expand Down Expand Up @@ -201,8 +203,9 @@ var Bank = /*#__PURE__*/function () {

}, {
key: "queryTotalSupply",
value: function queryTotalSupply() {
value: function queryTotalSupply(pagination) {
var request = new types.bank_query_pb.QueryTotalSupplyRequest();
request.setPagination(_helper.ModelCreator.createPaginationModel(pagination));
return this.client.rpcClient.protoQuery('/cosmos.bank.v1beta1.Query/TotalSupply', request, types.bank_query_pb.QueryTotalSupplyResponse);
}
/**
Expand Down Expand Up @@ -231,6 +234,32 @@ var Bank = /*#__PURE__*/function () {
var request = new types.bank_query_pb.QueryParamsRequest();
return this.client.rpcClient.protoQuery('/cosmos.bank.v1beta1.Query/Params', request, types.bank_query_pb.QueryParamsResponse);
}
/**
* DenomsMetadata queries the client metadata of a given coin denomination.
*/

}, {
key: "queryDenomMetadata",
value: function queryDenomMetadata(denom) {
if (!denom) {
throw new _errors.SdkError("denom can ont be empty");
}

var request = new types.bank_query_pb.QueryDenomMetadataRequest();
request.setDenom(denom);
return this.client.rpcClient.protoQuery('/cosmos.bank.v1beta1.Query/DenomMetadata', request, types.bank_query_pb.QueryDenomMetadataResponse);
}
/**
* DenomsMetadata queries the client metadata for all registered coin denominations.
*/

}, {
key: "queryDenomsMetadata",
value: function queryDenomsMetadata(pagination) {
var request = new types.bank_query_pb.QueryDenomsMetadataRequest();
request.setPagination(_helper.ModelCreator.createPaginationModel(pagination));
return this.client.rpcClient.protoQuery('/cosmos.bank.v1beta1.Query/DenomsMetadata', request, types.bank_query_pb.QueryDenomsMetadataResponse);
}
}]);
return Bank;
}();
Expand Down
2 changes: 1 addition & 1 deletion dist/src/modules/distribution.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export declare class Distribution {
* @param page_number
* @param page_size
*/
queryValidatorSlashes(validator_address: string, starting_height?: number, ending_height?: number, page_number?: number, page_size?: number): Promise<object>;
queryValidatorSlashes(validator_address: string, starting_height?: number, ending_height?: number, pagination?: types.Pagination): Promise<object>;
/**
* DelegationRewards queries the total rewards accrued by a delegation.
* @param validator_address defines the validator address to query for
Expand Down
7 changes: 2 additions & 5 deletions dist/src/modules/distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,15 @@ var Distribution = /*#__PURE__*/function () {
value: function queryValidatorSlashes(validator_address) {
var starting_height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var ending_height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var page_number = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
var page_size = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
var pagination = arguments.length > 3 ? arguments[3] : undefined;

if (!validator_address) {
throw new _errors.SdkError("validator_address can ont be empty");
}

var pagination = _helper.ModelCreator.createPaginationModel(page_number, page_size, true);

var request = new types.distribution_query_pb.QueryValidatorSlashesRequest();
request.setValidatorAddress(validator_address);
request.setPagination(pagination);
request.setPagination(_helper.ModelCreator.createPaginationModel(pagination));

if (starting_height) {
request.setStartingHeight(starting_height);
Expand Down
16 changes: 16 additions & 0 deletions dist/src/modules/farm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ export declare class Farm {
* @returns
*/
harvestReward(pool_id: string, baseTx: BaseTx): Promise<types.TxResult>;
/**
* query Farm Pools
*/
queryFarmPools(pagination?: types.Pagination): Promise<object>;
/**
* query Farm Pool
*/
queryFarmPool(id: string): Promise<object>;
/**
* query Farmer
*/
queryFarmer(farmer: string, pool_id: string): Promise<object>;
/**
* query Params
*/
queryParams(): Promise<object>;
}
Loading

0 comments on commit 42ca9de

Please sign in to comment.