Skip to content

Commit

Permalink
Merge pull request #333 from irisnet/develop
Browse files Browse the repository at this point in the history
meage develop into master
  • Loading branch information
hangts committed Jan 3, 2024
2 parents 6c9f384 + 6fa9bbe commit d7379c9
Show file tree
Hide file tree
Showing 63 changed files with 10,452 additions and 502 deletions.
36 changes: 21 additions & 15 deletions README.md
Expand Up @@ -25,13 +25,13 @@ npm install https://github.com/irisnet/irishub-sdk-js.git
```typescript
interface ClientConfig {
node: string,//address of a rpc node on IRISnet
network: number, //[Number] 0: Mainnet, 1: Testnet
chainNetwork: consts.ChainNetwork; // IRISHUB = 0, Cosmos = 1, Akash = 2
chainId: string,
gas?: string,
fee?: {
denom: string;
amount: string;
},//default fee for transactions
}, //default fee for transactions
keyDAO: KeyDAO,//key manager for wallet, which must be implemented
bech32Prefix?: {
AccAddr: string,
Expand Down Expand Up @@ -116,15 +116,15 @@ The following selected examples demonstrate basic client usage.

- create account
```typescript
const account: { address: string, mnemonic: string } = client.keys.add(`iris_wallet`, 'S8js8Ka82lqAc');
const account: { address: string, mnemonic: string } = client.keys.add(`wallet name`, 'wallet password');
```
- recover account by mnemonic
```typescript
const account: string = client.keys.recover(`iris_wallet`, 'S8js8Ka82lqAc', `fatigue panther innocent dress person fluid animal raven material embark target spread kiss smile cycle begin rocket pull couple mass story analyst guilt network`);
const account: string = client.keys.recover(`wallet name`, 'wallet password', `mnemonic`);
```
- recover account by keystore
```typescript
const account: string = client.keys.recover(`iris_wallet`, 'S8js8Ka82lqAc', `{"version":"1","id":"1d295464-aaa8-418e-b374-3052a91dc26a","address":"faa1eqvkfthtrr93g4p9qspp54w6dtjtrn279vcmpn","crypto":{"ciphertext":"a6ee40e3b38a7b24a373ec006bcc039ccbae45dc3b1f314405ab51ee975d6b1f","cipherparams":{"iv":"453b83b1331d334b70d160616fe43ace"},"cipher":"aes-128-ctr","kdf":"pbkdf2","kdfparams":{"dklen":32,"salt":"e702e41edf7277a39f7f5cc641c19e1b492cc29bf737aec9b53b496c9f217b37","c":10000,"prf":"hmac-sha256"},"mac":"6e8ed2619f0b30f00c20f9f01858368efbd0feae5811792d8b41a60c2d71d310"}}`);
const account: string = client.keys.recover(`wallet name`, 'wallet password', `keystore`);
```
- transfer example
```typescript
Expand All @@ -135,8 +135,8 @@ const res = await client.bank.send({
amount:`1000000`
}],
baseTx:{
from:`iris_wallet`,
password:`S8js8Ka82lqAc`,
from:`wallet name`,
password:`wallet password`,
gas:50000,
fee:{
denom:`uiris`,
Expand All @@ -160,7 +160,7 @@ const res = await client.bank.send({
- queryDenomMetadata
- queryDenomsMetadata
- queryParams
### bank `src/modules/coinswap.ts`
### coinswap `src/modules/coinswap.ts`
- addLiquidity
- removeLiquidity
- swapOrder
Expand All @@ -180,7 +180,7 @@ const res = await client.bank.send({
- queryDelegatorValidators
- queryDelegatorWithdrawAddress
- queryCommunityPool
### keys `src/modules/farm.ts`
### farm `src/modules/farm.ts`
- stakeLp
- unStakeLp
- harvestReward
Expand All @@ -203,19 +203,26 @@ const res = await client.bank.send({
- vote
- voteWeighted

### bank `src/modules/htlc.ts`
### htlc `src/modules/htlc.ts`
- createHTLC
- claimHTLC
- queryHTLC
- queryAssetSupply
- queryAssetSupplies
- queryParams
### bank `src/modules/ibc.ts`
### ibc `src/modules/ibc/ibc.ts`
- transfer
- queryDenomTrace
- queryDenomTraces
- queryParams
- queryChannels
### ibc-nft-transfer `src/modules/ibc/ibc-nft-transfer.ts`
- transfer
- queryClassTrace
- queryClassTraces
- queryClassHash
- queryEscrowAddress
- queryParams
### keys `src/modules/keys.ts`
- add
- recover
Expand All @@ -236,7 +243,7 @@ const res = await client.bank.send({
- queryDenom
- queryDenoms
- queryNFT
### slashing `src/modules/oracle.ts`
### oracle `src/modules/oracle.ts`
- queryFeed
- queryFeeds
- queryFeedValue
Expand All @@ -247,11 +254,11 @@ const res = await client.bank.send({
- deserializeTxRaw
- deserializeSigningInfo
- deserializePubkey
### slashing `src/modules/random.ts`
### random `src/modules/random.ts`
- queryRandom
- queryRequest
- request
### slashing `src/modules/service.ts`
### service `src/modules/service.ts`
- queryDefinition
- queryBinding
- queryBindings
Expand Down Expand Up @@ -330,4 +337,3 @@ const res = await client.bank.send({
- broadcastTx
- newTxResult
- createMsg

36 changes: 21 additions & 15 deletions dist/README.md
Expand Up @@ -25,13 +25,13 @@ npm install https://github.com/irisnet/irishub-sdk-js.git
```typescript
interface ClientConfig {
node: string,//address of a rpc node on IRISnet
network: number, //[Number] 0: Mainnet, 1: Testnet
chainNetwork: consts.ChainNetwork; // IRISHUB = 0, Cosmos = 1, Akash = 2
chainId: string,
gas?: string,
fee?: {
denom: string;
amount: string;
},//default fee for transactions
}, //default fee for transactions
keyDAO: KeyDAO,//key manager for wallet, which must be implemented
bech32Prefix?: {
AccAddr: string,
Expand Down Expand Up @@ -116,15 +116,15 @@ The following selected examples demonstrate basic client usage.

- create account
```typescript
const account: { address: string, mnemonic: string } = client.keys.add(`iris_wallet`, 'S8js8Ka82lqAc');
const account: { address: string, mnemonic: string } = client.keys.add(`wallet name`, 'wallet password');
```
- recover account by mnemonic
```typescript
const account: string = client.keys.recover(`iris_wallet`, 'S8js8Ka82lqAc', `fatigue panther innocent dress person fluid animal raven material embark target spread kiss smile cycle begin rocket pull couple mass story analyst guilt network`);
const account: string = client.keys.recover(`wallet name`, 'wallet password', `mnemonic`);
```
- recover account by keystore
```typescript
const account: string = client.keys.recover(`iris_wallet`, 'S8js8Ka82lqAc', `{"version":"1","id":"1d295464-aaa8-418e-b374-3052a91dc26a","address":"faa1eqvkfthtrr93g4p9qspp54w6dtjtrn279vcmpn","crypto":{"ciphertext":"a6ee40e3b38a7b24a373ec006bcc039ccbae45dc3b1f314405ab51ee975d6b1f","cipherparams":{"iv":"453b83b1331d334b70d160616fe43ace"},"cipher":"aes-128-ctr","kdf":"pbkdf2","kdfparams":{"dklen":32,"salt":"e702e41edf7277a39f7f5cc641c19e1b492cc29bf737aec9b53b496c9f217b37","c":10000,"prf":"hmac-sha256"},"mac":"6e8ed2619f0b30f00c20f9f01858368efbd0feae5811792d8b41a60c2d71d310"}}`);
const account: string = client.keys.recover(`wallet name`, 'wallet password', `keystore`);
```
- transfer example
```typescript
Expand All @@ -135,8 +135,8 @@ const res = await client.bank.send({
amount:`1000000`
}],
baseTx:{
from:`iris_wallet`,
password:`S8js8Ka82lqAc`,
from:`wallet name`,
password:`wallet password`,
gas:50000,
fee:{
denom:`uiris`,
Expand All @@ -160,7 +160,7 @@ const res = await client.bank.send({
- queryDenomMetadata
- queryDenomsMetadata
- queryParams
### bank `src/modules/coinswap.ts`
### coinswap `src/modules/coinswap.ts`
- addLiquidity
- removeLiquidity
- swapOrder
Expand All @@ -180,7 +180,7 @@ const res = await client.bank.send({
- queryDelegatorValidators
- queryDelegatorWithdrawAddress
- queryCommunityPool
### keys `src/modules/farm.ts`
### farm `src/modules/farm.ts`
- stakeLp
- unStakeLp
- harvestReward
Expand All @@ -203,19 +203,26 @@ const res = await client.bank.send({
- vote
- voteWeighted

### bank `src/modules/htlc.ts`
### htlc `src/modules/htlc.ts`
- createHTLC
- claimHTLC
- queryHTLC
- queryAssetSupply
- queryAssetSupplies
- queryParams
### bank `src/modules/ibc.ts`
### ibc `src/modules/ibc/ibc.ts`
- transfer
- queryDenomTrace
- queryDenomTraces
- queryParams
- queryChannels
### ibc-nft-transfer `src/modules/ibc/ibc-nft-transfer.ts`
- transfer
- queryClassTrace
- queryClassTraces
- queryClassHash
- queryEscrowAddress
- queryParams
### keys `src/modules/keys.ts`
- add
- recover
Expand All @@ -236,7 +243,7 @@ const res = await client.bank.send({
- queryDenom
- queryDenoms
- queryNFT
### slashing `src/modules/oracle.ts`
### oracle `src/modules/oracle.ts`
- queryFeed
- queryFeeds
- queryFeedValue
Expand All @@ -247,11 +254,11 @@ const res = await client.bank.send({
- deserializeTxRaw
- deserializeSigningInfo
- deserializePubkey
### slashing `src/modules/random.ts`
### random `src/modules/random.ts`
- queryRandom
- queryRequest
- request
### slashing `src/modules/service.ts`
### service `src/modules/service.ts`
- queryDefinition
- queryBinding
- queryBindings
Expand Down Expand Up @@ -330,4 +337,3 @@ const res = await client.bank.send({
- broadcastTx
- newTxResult
- createMsg

12 changes: 6 additions & 6 deletions dist/package.json
@@ -1,6 +1,6 @@
{
"name": "@irisnet/irishub-sdk",
"version": "3.2.0",
"version": "3.3.0",
"description": "IRISHub JavaScript SDK",
"main": "index.js",
"typings": "index.ts",
Expand Down Expand Up @@ -38,12 +38,12 @@
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.14.7",
"@babel/preset-typescript": "^7.9.0",
"@types/jest": "^26.0.22",
"@types/node": "^10.0.3",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.6",
"babel-loader": "^9.1.2",
"eslint": "^6.8.0",
"eslint-loader": "^4.0.0",
"gts": "3.1.1",
"gts": "5.2.0",
"jest": "29.7.0",
"ts-loader": "^9.4.4",
"tslint": "^6.1.0",
Expand All @@ -53,12 +53,12 @@
"dependencies": {
"@babel/runtime": "^7.13.10",
"@types/mathjs": "6.0.11",
"@types/ws": "^7.4.5",
"@types/ws": "^8.5.10",
"axios": "^1.6.2",
"bcryptjs": "^2.4.3",
"bech32": "^1.1.3",
"bip32": "^2.0.4",
"bip39": "3.0.2",
"bip39": "3.1.0",
"crypto-browserify": "^3.12.0",
"crypto-js": "^4.0.0",
"events": "^3.1.0",
Expand Down
15 changes: 5 additions & 10 deletions dist/src/client.d.ts
Expand Up @@ -65,6 +65,9 @@ export declare class Client {
/** Ibc module */
private _ibc?;
get ibc(): modules.Ibc;
/** Ibc nft transfer module */
private _ibcNftTransfer?;
get ibcNftTransfer(): modules.IbcNftTransfer;
/** IRISHub SDK Constructor */
constructor(config: DefaultClientConfig);
/**
Expand All @@ -74,13 +77,6 @@ export declare class Client {
* @returns The SDK itself
*/
withKeyDAO(keyDAO: KeyDAO): this;
/**
* Set IRISHub network type
*
* @param network IRISHub network type, mainnet / testnet
* @returns The SDK itself
*/
withNetwork(network: consts.Network): this;
/**
* Set IRISHub network type
*
Expand Down Expand Up @@ -123,8 +119,8 @@ export declare class Client {
export interface ClientConfig {
/** IRISHub node rpc address */
node: string;
/** IRISHub network type, mainnet / testnet */
network?: consts.Network;
/** IRISHUB = 0, Cosmos = 1, Akash = 2 */
chainNetwork?: consts.ChainNetwork;
/** IRISHub chain-id */
chainId?: string;
/** Default gas limit */
Expand All @@ -142,7 +138,6 @@ export interface ClientConfig {
export declare class DefaultClientConfig implements ClientConfig {
node: string;
chainNetwork: consts.ChainNetwork;
network: consts.Network;
chainId: string;
gas: string;
fee: types.Coin;
Expand Down
25 changes: 10 additions & 15 deletions dist/src/client.js
Expand Up @@ -88,6 +88,8 @@ var Client = exports.Client = /*#__PURE__*/function () {
(0, _defineProperty2["default"])(this, "_htlc", void 0);
/** Ibc module */
(0, _defineProperty2["default"])(this, "_ibc", void 0);
/** Ibc nft transfer module */
(0, _defineProperty2["default"])(this, "_ibcNftTransfer", void 0);
this.config = config;
if (!this.config.rpcConfig) this.config.rpcConfig = {};
if (!this.config.bech32Prefix || !this.config.bech32Prefix.AccAddr) {
Expand Down Expand Up @@ -279,6 +281,14 @@ var Client = exports.Client = /*#__PURE__*/function () {
}
return this._ibc;
}
}, {
key: "ibcNftTransfer",
get: function get() {
if (!this._ibcNftTransfer) {
this._ibcNftTransfer = new modules.IbcNftTransfer(this);
}
return this._ibcNftTransfer;
}
}, {
key: "withKeyDAO",
value: function withKeyDAO(keyDAO) {
Expand All @@ -292,19 +302,6 @@ var Client = exports.Client = /*#__PURE__*/function () {
return this;
}

/**
* Set IRISHub network type
*
* @param network IRISHub network type, mainnet / testnet
* @returns The SDK itself
*/
}, {
key: "withNetwork",
value: function withNetwork(network) {
this.config.network = network;
return this;
}

/**
* Set IRISHub network type
*
Expand Down Expand Up @@ -382,15 +379,13 @@ var DefaultClientConfig = exports.DefaultClientConfig = /*#__PURE__*/(0, _create
(0, _classCallCheck2["default"])(this, DefaultClientConfig);
(0, _defineProperty2["default"])(this, "node", void 0);
(0, _defineProperty2["default"])(this, "chainNetwork", void 0);
(0, _defineProperty2["default"])(this, "network", void 0);
(0, _defineProperty2["default"])(this, "chainId", void 0);
(0, _defineProperty2["default"])(this, "gas", void 0);
(0, _defineProperty2["default"])(this, "fee", void 0);
(0, _defineProperty2["default"])(this, "keyDAO", void 0);
(0, _defineProperty2["default"])(this, "bech32Prefix", void 0);
(0, _defineProperty2["default"])(this, "rpcConfig", void 0);
this.node = '';
this.network = types.Network.Mainnet;
this.chainNetwork = types.ChainNetwork.Iris;
this.chainId = '';
this.gas = '100000';
Expand Down

0 comments on commit d7379c9

Please sign in to comment.