Skip to content

Commit

Permalink
Merge pull request #253 from irisnet/develop
Browse files Browse the repository at this point in the history
R4R: merge to master
  • Loading branch information
kaifei Hu authored Jul 28, 2022
2 parents ff78bb7 + 42ca9de commit e910ee2
Show file tree
Hide file tree
Showing 321 changed files with 88,333 additions and 1,836 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
.vscode
docs
.idea/
.idea/
/node_modules/
/.github/
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

3 changes: 2 additions & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irisnet/irishub-sdk",
"version": "2.0.0",
"version": "3.0.0",
"description": "IRISHub JavaScript SDK",
"main": "index.js",
"typings": "index.ts",
Expand All @@ -26,6 +26,7 @@
"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",
"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 .",
"proto-gen": "sh ./scripts/protocgen.sh"
Expand Down
3 changes: 3 additions & 0 deletions dist/src/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export declare class Client {
/** Coinswap module */
private _coinswap?;
get coinswap(): modules.Coinswap;
/** Farm module */
private _farm?;
get farm(): modules.Farm;
/** NFT module */
private _nft?;
get nft(): modules.Nft;
Expand Down
16 changes: 16 additions & 0 deletions dist/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var Client = /*#__PURE__*/function () {
(0, _defineProperty2["default"])(this, "_utils", void 0);
(0, _defineProperty2["default"])(this, "_tendermint", void 0);
(0, _defineProperty2["default"])(this, "_coinswap", void 0);
(0, _defineProperty2["default"])(this, "_farm", void 0);
(0, _defineProperty2["default"])(this, "_nft", void 0);
(0, _defineProperty2["default"])(this, "_htlc", void 0);
(0, _defineProperty2["default"])(this, "_ibc", void 0);
Expand Down Expand Up @@ -286,6 +287,21 @@ var Client = /*#__PURE__*/function () {

return this._coinswap;
}
/** Farm module */

}, {
key: "farm",
get: function get() {
if (this.config.chainNetwork != consts.ChainNetwork.Iris) {
throw new _errors.SdkError('This module is not supported on the current chain network.', _errors.CODES.Panic);
}

if (!this._farm) {
this._farm = new modules.Farm(this);
}

return this._farm;
}
/** NFT module */

}, {
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
6 changes: 3 additions & 3 deletions dist/src/modules/coinswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ var Coinswap = /*#__PURE__*/function () {
throw new _errors.SdkError("id can ont be empty");
}

var request = new types.coinswap_query_pb.QueryLiquidityRequest();
request.setId(id);
return this.client.rpcClient.protoQuery('/irismod.coinswap.Query/Liquidity', request, types.coinswap_query_pb.QueryLiquidityResponse);
var request = new types.coinswap_query_pb.QueryLiquidityPoolRequest();
request.setLptDenom(id);
return this.client.rpcClient.protoQuery('/irismod.coinswap.Query/LiquidityPool', request, types.coinswap_query_pb.QueryLiquidityPoolResponse);
}
}]);
return Coinswap;
Expand Down
Loading

0 comments on commit e910ee2

Please sign in to comment.