carbon-js-sdk 0.4.26 → 0.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
4
4
  import { CarbonQueryClient, ETHClient, HydrogenClient, InsightsQueryClient, NEOClient, TokenClient, ZILClient } from "./clients";
5
5
  import * as clients from "./clients";
6
6
  import N3Client from "./clients/N3Client";
7
- import { AdminModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
7
+ import { AdminModule, AllianceModule, BankModule, BrokerModule, CDPModule, CoinModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
8
8
  import { StakingModule } from "./modules/staking";
9
9
  import { CosmosLedger, Keplr, LeapExtended } from "./provider";
10
10
  import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts } from "./wallet";
@@ -48,6 +48,7 @@ declare class CarbonSDK {
48
48
  tmClient: Tendermint34Client;
49
49
  token: TokenClient;
50
50
  admin: AdminModule;
51
+ alliance: AllianceModule;
51
52
  order: OrderModule;
52
53
  lp: LiquidityPoolModule;
53
54
  subaccount: SubAccountModule;
package/lib/CarbonSDK.js CHANGED
@@ -71,6 +71,7 @@ class CarbonSDK {
71
71
  this.token = (_e = opts.token) !== null && _e !== void 0 ? _e : clients_1.TokenClient.instance(this.query, this);
72
72
  this.hydrogen = clients_1.HydrogenClient.instance(this.networkConfig, this.token);
73
73
  this.admin = new modules_1.AdminModule(this);
74
+ this.alliance = new modules_1.AllianceModule(this);
74
75
  this.order = new modules_1.OrderModule(this);
75
76
  this.lp = new modules_1.LiquidityPoolModule(this);
76
77
  this.subaccount = new modules_1.SubAccountModule(this);
@@ -36,7 +36,7 @@ import { QueryClientImpl as PositionQueryClient } from "../codec/position/query"
36
36
  import { QueryClientImpl as PricingQueryClient } from "../codec/pricing/query";
37
37
  import { QueryClientImpl as ProfileQueryClient } from "../codec/profile/query";
38
38
  import { QueryClientImpl as SubaccountQueryClient } from "../codec/subaccount/query";
39
- import { QueryClientImpl as AlliancesClient } from "../codec/alliance/query";
39
+ import { QueryClientImpl as AllianceClient } from "../codec/alliance/query";
40
40
  import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
41
41
  import BlockchainClient from "./BlockchainClient";
42
42
  export interface IBCClientGroup {
@@ -81,7 +81,7 @@ declare class CarbonQueryClient {
81
81
  staking: StakingQueryClient;
82
82
  upgrade: UpgradeQueryClient;
83
83
  cosmosTm: CosmosTmClient;
84
- alliances: AlliancesClient;
84
+ alliance: AllianceClient;
85
85
  chain: BlockchainClient;
86
86
  ibc: IBCClientGroup;
87
87
  private baseClient;
@@ -51,6 +51,7 @@ class CarbonQueryClient {
51
51
  const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
52
52
  this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
53
53
  this.adl = new query_1.QueryClientImpl(rpcClient);
54
+ this.alliance = new query_39.QueryClientImpl(rpcClient);
54
55
  this.book = new query_2.QueryClientImpl(rpcClient);
55
56
  this.broker = new query_3.QueryClientImpl(rpcClient);
56
57
  this.coin = new query_5.QueryClientImpl(rpcClient);
@@ -82,7 +83,6 @@ class CarbonQueryClient {
82
83
  this.staking = new query_15.QueryClientImpl(rpcClient);
83
84
  this.upgrade = new query_16.QueryClientImpl(rpcClient);
84
85
  this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
85
- this.alliances = new query_39.QueryClientImpl(rpcClient);
86
86
  this.ibc = {
87
87
  controller: new query_19.QueryClientImpl(rpcClient),
88
88
  host: new query_20.QueryClientImpl(rpcClient),
@@ -0,0 +1,43 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { CarbonTx } from "../util";
3
+ import BaseModule from "./base";
4
+ export declare class AllianceModule extends BaseModule {
5
+ delegateTokens(params: AllianceModule.DelegateTokensParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
6
+ undelegateTokens(params: AllianceModule.DelegateTokensParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
7
+ redelegateTokens(params: AllianceModule.RedelegateTokensParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
8
+ claimRewards(params: AllianceModule.ClaimRewardsParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
9
+ withdrawAllRewards(params: AllianceModule.WithdrawAllRewardsParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
10
+ }
11
+ export declare namespace AllianceModule {
12
+ interface DelegateTokensParams {
13
+ delegatorAddress?: string;
14
+ validatorAddress: string;
15
+ amount: BigNumber;
16
+ denom: string;
17
+ }
18
+ interface UndelegateTokensParams {
19
+ delegatorAddress?: string;
20
+ validatorAddress: string;
21
+ amount: BigNumber;
22
+ denom: string;
23
+ }
24
+ interface RedelegateTokensParams {
25
+ delegatorAddress?: string;
26
+ validatorSrcAddress: string;
27
+ validatorDstAddress: string;
28
+ amount: BigNumber;
29
+ denom: string;
30
+ }
31
+ interface ClaimRewardsParams {
32
+ delegatorAddress?: string;
33
+ validatorAddress: string;
34
+ denom: string;
35
+ }
36
+ interface WithdrawAllRewardsParams {
37
+ delegatorAddress?: string;
38
+ delegations: {
39
+ validatorAddress: string;
40
+ denom: string;
41
+ }[];
42
+ }
43
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AllianceModule = void 0;
16
+ const codec_1 = require("../codec");
17
+ const tx_1 = require("../codec/alliance/tx");
18
+ const tx_2 = require("cosmjs-types/cosmos/distribution/v1beta1/tx");
19
+ const base_1 = __importDefault(require("./base"));
20
+ class AllianceModule extends base_1.default {
21
+ delegateTokens(params, opts) {
22
+ var _a;
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const wallet = this.getWallet();
25
+ const value = tx_1.MsgDelegate.fromPartial({
26
+ delegatorAddress: (_a = params.delegatorAddress) !== null && _a !== void 0 ? _a : wallet.bech32Address,
27
+ validatorAddress: params.validatorAddress,
28
+ amount: {
29
+ amount: params.amount.toString(10),
30
+ denom: params.denom,
31
+ },
32
+ });
33
+ return wallet.sendTx({
34
+ typeUrl: codec_1.TxTypes.MsgAllianceDelegate,
35
+ value,
36
+ }, opts);
37
+ });
38
+ }
39
+ undelegateTokens(params, opts) {
40
+ var _a;
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const wallet = this.getWallet();
43
+ const value = tx_1.MsgUndelegate.fromPartial({
44
+ delegatorAddress: (_a = params.delegatorAddress) !== null && _a !== void 0 ? _a : wallet.bech32Address,
45
+ validatorAddress: params.validatorAddress,
46
+ amount: {
47
+ amount: params.amount.toString(10),
48
+ denom: params.denom,
49
+ },
50
+ });
51
+ return wallet.sendTx({
52
+ typeUrl: codec_1.TxTypes.MsgAllianceUndelegate,
53
+ value,
54
+ }, opts);
55
+ });
56
+ }
57
+ redelegateTokens(params, opts) {
58
+ var _a;
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const wallet = this.getWallet();
61
+ const value = tx_1.MsgRedelegate.fromPartial({
62
+ delegatorAddress: (_a = params.delegatorAddress) !== null && _a !== void 0 ? _a : wallet.bech32Address,
63
+ validatorSrcAddress: params.validatorSrcAddress,
64
+ validatorDstAddress: params.validatorDstAddress,
65
+ amount: {
66
+ amount: params.amount.toString(10),
67
+ denom: params.denom,
68
+ },
69
+ });
70
+ return wallet.sendTx({
71
+ typeUrl: codec_1.TxTypes.MsgAllianceRedelegate,
72
+ value,
73
+ }, opts);
74
+ });
75
+ }
76
+ claimRewards(params, opts) {
77
+ var _a;
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const wallet = this.getWallet();
80
+ const value = tx_1.MsgClaimDelegationRewards.fromPartial({
81
+ delegatorAddress: (_a = params.delegatorAddress) !== null && _a !== void 0 ? _a : wallet.bech32Address,
82
+ validatorAddress: params.validatorAddress,
83
+ denom: params.denom,
84
+ });
85
+ return wallet.sendTx({
86
+ typeUrl: codec_1.TxTypes.MsgAllianceClaimDelegationRewards,
87
+ value,
88
+ }, opts);
89
+ });
90
+ }
91
+ withdrawAllRewards(params, opts) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const wallet = this.getWallet();
94
+ const msgs = params.delegations.map((delegation) => {
95
+ var _a, _b;
96
+ if (delegation.denom === "swth") {
97
+ return {
98
+ typeUrl: codec_1.TxTypes.MsgWithdrawDelegatorReward,
99
+ value: tx_2.MsgWithdrawDelegatorReward.fromPartial({
100
+ delegatorAddress: (_a = params.delegatorAddress) !== null && _a !== void 0 ? _a : wallet.bech32Address,
101
+ validatorAddress: delegation.validatorAddress,
102
+ }),
103
+ };
104
+ }
105
+ else {
106
+ return {
107
+ typeUrl: codec_1.TxTypes.MsgAllianceClaimDelegationRewards,
108
+ value: tx_1.MsgClaimDelegationRewards.fromPartial({
109
+ delegatorAddress: (_b = params.delegatorAddress) !== null && _b !== void 0 ? _b : wallet.bech32Address,
110
+ validatorAddress: delegation.validatorAddress,
111
+ denom: delegation.denom,
112
+ }),
113
+ };
114
+ }
115
+ });
116
+ return wallet.sendTxs(msgs, opts);
117
+ });
118
+ }
119
+ }
120
+ exports.AllianceModule = AllianceModule;
@@ -1,9 +1,11 @@
1
1
  export * from "./admin";
2
+ export * from "./alliance";
2
3
  export * from "./bank";
3
4
  export * from "./broker";
4
5
  export * from "./cdp";
5
6
  export * from "./coin";
6
7
  export * from "./cosmwasm";
8
+ export * from "./fee";
7
9
  export * from "./gov";
8
10
  export * from "./ibc";
9
11
  export * from "./leverage";
@@ -14,5 +16,4 @@ export * from "./order";
14
16
  export * from "./position";
15
17
  export * from "./profile";
16
18
  export * from "./subaccount";
17
- export * from "./fee";
18
19
  export * from "./xchain";
@@ -11,11 +11,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./admin"), exports);
14
+ __exportStar(require("./alliance"), exports);
14
15
  __exportStar(require("./bank"), exports);
15
16
  __exportStar(require("./broker"), exports);
16
17
  __exportStar(require("./cdp"), exports);
17
18
  __exportStar(require("./coin"), exports);
18
19
  __exportStar(require("./cosmwasm"), exports);
20
+ __exportStar(require("./fee"), exports);
19
21
  __exportStar(require("./gov"), exports);
20
22
  __exportStar(require("./ibc"), exports);
21
23
  __exportStar(require("./leverage"), exports);
@@ -26,5 +28,4 @@ __exportStar(require("./order"), exports);
26
28
  __exportStar(require("./position"), exports);
27
29
  __exportStar(require("./profile"), exports);
28
30
  __exportStar(require("./subaccount"), exports);
29
- __exportStar(require("./fee"), exports);
30
31
  __exportStar(require("./xchain"), exports);
@@ -14,7 +14,6 @@ export declare class PerpsLiquidityModule extends BaseModule {
14
14
  }
15
15
  export declare namespace PerpsLiquidityModule {
16
16
  interface CreatePerpetualPoolParams {
17
- creator: string;
18
17
  name: string;
19
18
  depositDenom: string;
20
19
  shareTokenSymbol: string;
@@ -23,7 +22,6 @@ export declare namespace PerpsLiquidityModule {
23
22
  withdrawalFeeBps: string;
24
23
  }
25
24
  interface UpdatePerpetualPoolParams {
26
- creator: string;
27
25
  name: string;
28
26
  poolId: Long;
29
27
  depositDenom: string;
@@ -33,24 +31,20 @@ export declare namespace PerpsLiquidityModule {
33
31
  withdrawalFeeBps: Long;
34
32
  }
35
33
  interface DepositToPerpetualsPoolParams {
36
- creator: string;
37
34
  poolId: Long;
38
35
  depositAmount: string;
39
36
  minShareAmount: string;
40
37
  }
41
38
  interface WithdrawFromPerpetualsPoolParams {
42
- creator: string;
43
39
  poolId: Long;
44
40
  shareAmount: string;
45
41
  minReceiveAmount: string;
46
42
  }
47
43
  interface RegisterToPlPoolParams {
48
- creator: string;
49
44
  poolId: Long;
50
45
  marketId: string;
51
46
  }
52
47
  interface DeregisterFromPlPoolParams {
53
- creator: string;
54
48
  marketId: string;
55
49
  }
56
50
  }
@@ -33,7 +33,7 @@ class PerpsLiquidityModule extends base_1.default {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  const wallet = this.getWallet();
35
35
  const value = __1.Models.MsgCreatePlPool.fromPartial({
36
- creator: params.creator,
36
+ creator: wallet.bech32Address,
37
37
  name: params.name,
38
38
  depositDenom: params.depositDenom,
39
39
  shareTokenSymbol: params.shareTokenSymbol,
@@ -57,7 +57,7 @@ class PerpsLiquidityModule extends base_1.default {
57
57
  withdrawalFeeBps: params.withdrawalFeeBps,
58
58
  };
59
59
  const value = __1.Models.MsgUpdatePlPool.fromPartial({
60
- creator: params.creator,
60
+ creator: wallet.bech32Address,
61
61
  poolId: params.poolId,
62
62
  updatePoolParams: updatePoolParam,
63
63
  });
@@ -71,7 +71,7 @@ class PerpsLiquidityModule extends base_1.default {
71
71
  return __awaiter(this, void 0, void 0, function* () {
72
72
  const wallet = this.getWallet();
73
73
  const value = __1.Models.MsgDepositToPlPool.fromPartial({
74
- creator: params.creator,
74
+ creator: wallet.bech32Address,
75
75
  poolId: params.poolId,
76
76
  depositAmount: params.depositAmount,
77
77
  minShareAmount: params.minShareAmount,
@@ -86,7 +86,7 @@ class PerpsLiquidityModule extends base_1.default {
86
86
  return __awaiter(this, void 0, void 0, function* () {
87
87
  const wallet = this.getWallet();
88
88
  const value = __1.Models.MsgWithdrawFromPlPool.fromPartial({
89
- creator: params.creator,
89
+ creator: wallet.bech32Address,
90
90
  poolId: params.poolId,
91
91
  shareAmount: params.shareAmount,
92
92
  minReceiveAmount: params.minReceiveAmount,
@@ -101,7 +101,7 @@ class PerpsLiquidityModule extends base_1.default {
101
101
  return __awaiter(this, void 0, void 0, function* () {
102
102
  const wallet = this.getWallet();
103
103
  const value = __1.Models.MsgRegisterToPlPool.fromPartial({
104
- creator: params.creator,
104
+ creator: wallet.bech32Address,
105
105
  poolId: params.poolId,
106
106
  marketId: params.marketId,
107
107
  });
@@ -115,7 +115,7 @@ class PerpsLiquidityModule extends base_1.default {
115
115
  return __awaiter(this, void 0, void 0, function* () {
116
116
  const wallet = this.getWallet();
117
117
  const value = __1.Models.MsgDeregisterFromPlPool.fromPartial({
118
- creator: params.creator,
118
+ creator: wallet.bech32Address,
119
119
  marketId: params.marketId,
120
120
  });
121
121
  return yield wallet.sendTx({
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LEGACY_ACCOUNTS_MAINNET = exports.LEGACY_ACCOUNTS_TESTNET = void 0;
4
- // As of 16 May 2023
4
+ // As of 26 May 2023
5
5
  exports.LEGACY_ACCOUNTS_TESTNET = {
6
6
  "Ethereum": [
7
7
  "0x32c1069dcf38a7294ee9633fcb897c18cabd1668",
@@ -23,7 +23,8 @@ exports.LEGACY_ACCOUNTS_TESTNET = {
23
23
  "0x05a2F90551Dcba19C42c6E85FB00843C0859a427",
24
24
  "0xad045ec15DbBe6FebE8e7D1EC85Eb7D496c4ebe1",
25
25
  "0xcFa83a56f1479BB9CD5a25f36a0C3E44EE08D7DB",
26
- "0x8e2C2E908195F87Bc6C14fAEC31F7726d094b3c6"
26
+ "0x8e2C2E908195F87Bc6C14fAEC31F7726d094b3c6",
27
+ "0x791b066E4309B0f696419D29BD11c6597f822b45"
27
28
  ]
28
29
  };
29
30
  // To be updated
@@ -40,7 +40,7 @@ function populateEvmTransactionDetails(api, req) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  const provider = api.evmJsonRpc;
42
42
  const evmHexAddress = (_b = (_a = api.wallet) === null || _a === void 0 ? void 0 : _a.evmHexAddress) !== null && _b !== void 0 ? _b : '';
43
- const request = {
43
+ let request = {
44
44
  to: (_c = req.to) !== null && _c !== void 0 ? _c : '',
45
45
  from: (_d = req.from) !== null && _d !== void 0 ? _d : (_e = api.wallet) === null || _e === void 0 ? void 0 : _e.evmHexAddress,
46
46
  nonce: (_f = req.nonce) !== null && _f !== void 0 ? _f : (yield provider.getTransactionCount(evmHexAddress)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",