example-js-sdk 0.0.6 → 0.0.8

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.
Files changed (120) hide show
  1. package/README.md +134 -52
  2. package/lib/OrbixSDK.d.ts +145 -0
  3. package/lib/{CarbonSDK.js → OrbixSDK.js} +52 -52
  4. package/lib/clients/ETHClient.d.ts +10 -10
  5. package/lib/clients/ETHClient.js +4 -4
  6. package/lib/clients/{CarbonQueryClient.d.ts → OrbixQueryClient.d.ts} +4 -4
  7. package/lib/clients/{CarbonQueryClient.js → OrbixQueryClient.js} +2 -2
  8. package/lib/clients/TokenClient.d.ts +26 -26
  9. package/lib/clients/TokenClient.js +5 -5
  10. package/lib/clients/index.d.ts +1 -1
  11. package/lib/clients/index.js +3 -3
  12. package/lib/codec/index.d.ts +1 -1
  13. package/lib/codec/index.js +253 -253
  14. package/lib/constant/eip712.d.ts +1 -1
  15. package/lib/constant/eip712.js +2 -2
  16. package/lib/constant/generic.d.ts +1 -1
  17. package/lib/constant/generic.js +2 -2
  18. package/lib/constant/ibc.d.ts +0 -1
  19. package/lib/constant/ibc.js +0 -32
  20. package/lib/constant/network.d.ts +2 -2
  21. package/lib/constant/network.js +3 -3
  22. package/lib/constant/node.js +2 -74
  23. package/lib/constant/web3Config.d.ts +5 -5
  24. package/lib/constant/web3Config.js +18 -22
  25. package/lib/index.d.ts +3 -3
  26. package/lib/index.js +7 -7
  27. package/lib/insights/balance.d.ts +2 -2
  28. package/lib/modules/admin.d.ts +23 -23
  29. package/lib/modules/admin.js +43 -43
  30. package/lib/modules/alliance.d.ts +6 -6
  31. package/lib/modules/alliance.js +5 -5
  32. package/lib/modules/bank.d.ts +2 -2
  33. package/lib/modules/bank.js +1 -1
  34. package/lib/modules/base.d.ts +4 -4
  35. package/lib/modules/bridge.d.ts +3 -3
  36. package/lib/modules/bridge.js +5 -5
  37. package/lib/modules/broker.d.ts +3 -3
  38. package/lib/modules/broker.js +2 -2
  39. package/lib/modules/coin.d.ts +8 -8
  40. package/lib/modules/coin.js +7 -7
  41. package/lib/modules/evm.d.ts +2 -2
  42. package/lib/modules/evm.js +1 -1
  43. package/lib/modules/evmmerge.d.ts +2 -2
  44. package/lib/modules/evmmerge.js +3 -3
  45. package/lib/modules/gov.d.ts +4 -4
  46. package/lib/modules/gov.js +3 -3
  47. package/lib/modules/grant.d.ts +4 -4
  48. package/lib/modules/grant.js +6 -6
  49. package/lib/modules/ibc.d.ts +3 -3
  50. package/lib/modules/ibc.js +2 -2
  51. package/lib/modules/leverage.d.ts +3 -3
  52. package/lib/modules/leverage.js +2 -2
  53. package/lib/modules/market.d.ts +15 -15
  54. package/lib/modules/market.js +7 -7
  55. package/lib/modules/order.d.ts +8 -8
  56. package/lib/modules/order.js +7 -7
  57. package/lib/modules/perpspool.d.ts +14 -14
  58. package/lib/modules/perpspool.js +23 -23
  59. package/lib/modules/position.d.ts +3 -3
  60. package/lib/modules/position.js +2 -2
  61. package/lib/modules/staking.d.ts +6 -6
  62. package/lib/modules/subaccount.d.ts +4 -4
  63. package/lib/modules/subaccount.js +3 -3
  64. package/lib/provider/amino/types/admin.js +12 -12
  65. package/lib/provider/amino/types/bank.js +2 -2
  66. package/lib/provider/amino/types/bridge.js +3 -3
  67. package/lib/provider/amino/types/broker.js +2 -2
  68. package/lib/provider/amino/types/coin.js +5 -5
  69. package/lib/provider/amino/types/evm.js +2 -2
  70. package/lib/provider/amino/types/evmmerge.js +2 -2
  71. package/lib/provider/amino/types/feemarket.js +2 -2
  72. package/lib/provider/amino/types/gov.js +17 -17
  73. package/lib/provider/amino/types/grant.js +6 -6
  74. package/lib/provider/amino/types/group.js +4 -4
  75. package/lib/provider/amino/types/ibc.js +2 -2
  76. package/lib/provider/amino/types/leverage.js +2 -2
  77. package/lib/provider/amino/types/market.js +7 -7
  78. package/lib/provider/amino/types/order.js +5 -5
  79. package/lib/provider/amino/types/perpspool.js +11 -11
  80. package/lib/provider/amino/types/position.js +2 -2
  81. package/lib/provider/amino/types/staking.js +5 -5
  82. package/lib/provider/amino/types/subaccount.js +4 -4
  83. package/lib/provider/keplr/KeplrAccount.d.ts +3 -3
  84. package/lib/provider/keplr/KeplrAccount.js +8 -8
  85. package/lib/provider/leap/LeapAccount.d.ts +3 -3
  86. package/lib/provider/leap/LeapAccount.js +7 -7
  87. package/lib/provider/metamask/MetaMask.d.ts +8 -8
  88. package/lib/provider/metamask/MetaMask.js +17 -17
  89. package/lib/provider/rainbowKit/RainbowKitAccount.d.ts +7 -7
  90. package/lib/provider/rainbowKit/RainbowKitAccount.js +12 -12
  91. package/lib/provider/sdk/SDKProvider.d.ts +4 -4
  92. package/lib/util/alliance.js +1 -1
  93. package/lib/util/blockchain.d.ts +5 -5
  94. package/lib/util/blockchain.js +11 -11
  95. package/lib/util/eip712.d.ts +2 -2
  96. package/lib/util/eip712.js +1 -1
  97. package/lib/util/ethermint.d.ts +4 -4
  98. package/lib/util/ethermint.js +1 -1
  99. package/lib/util/external.d.ts +2 -2
  100. package/lib/util/gov.js +16 -16
  101. package/lib/util/index.d.ts +1 -1
  102. package/lib/util/index.js +2 -2
  103. package/lib/util/legacyEIP712.js +1 -1
  104. package/lib/util/network.d.ts +1 -1
  105. package/lib/util/network.js +7 -7
  106. package/lib/util/provider.js +1 -1
  107. package/lib/util/tx.d.ts +3 -3
  108. package/lib/util/tx.js +9 -9
  109. package/lib/wallet/{CarbonSigner.d.ts → OrbixSigner.d.ts} +19 -19
  110. package/lib/wallet/{CarbonSigner.js → OrbixSigner.js} +19 -19
  111. package/lib/wallet/{CarbonSigningClient.d.ts → OrbixSigningClient.d.ts} +3 -3
  112. package/lib/wallet/{CarbonSigningClient.js → OrbixSigningClient.js} +9 -9
  113. package/lib/wallet/{CarbonWallet.d.ts → OrbixWallet.d.ts} +38 -38
  114. package/lib/wallet/{CarbonWallet.js → OrbixWallet.js} +39 -39
  115. package/lib/wallet/index.d.ts +2 -2
  116. package/lib/wallet/index.js +2 -2
  117. package/package.json +1 -1
  118. package/lib/CarbonSDK.d.ts +0 -145
  119. /package/lib/codec/{carbon-models.d.ts → orbix-models.d.ts} +0 -0
  120. /package/lib/codec/{carbon-models.js → orbix-models.js} +0 -0
@@ -1,9 +1,9 @@
1
- import { OverrideConfig } from "../CarbonSDK";
2
- import { CarbonQueryClient } from "../clients";
1
+ import { OverrideConfig } from "../OrbixSDK";
2
+ import { OrbixQueryClient } from "../clients";
3
3
  import GasFee from "../clients/GasFee";
4
4
  import { Network, NetworkConfig, SupportedEip6963Provider } from "../constant";
5
5
  import { ProviderAgent } from "../constant/walletProvider";
6
- import { CarbonTx } from "../util";
6
+ import { OrbixTx } from "../util";
7
7
  import { AccessTokenResponse, GrantRequest } from "../util/auth";
8
8
  import { SmartWalletBlockchain } from "../util/blockchain";
9
9
  import { BroadcastTxMode } from "../util/tx";
@@ -13,9 +13,9 @@ import { Account, DeliverTxResponse } from "@cosmjs/stargate";
13
13
  import { Tendermint37Client } from "@cosmjs/tendermint-rpc";
14
14
  import { BroadcastTxAsyncResponse, BroadcastTxSyncResponse, TxResponse } from "@cosmjs/tendermint-rpc/build/tendermint37/responses";
15
15
  import { TxRaw as StargateTxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
16
- import { CarbonSigner, CarbonSignerTypes } from "./CarbonSigner";
17
- import { CarbonSigningClient } from "./CarbonSigningClient";
18
- export interface CarbonWalletGenericOpts {
16
+ import { OrbixSigner, OrbixSignerTypes } from "./OrbixSigner";
17
+ import { OrbixSigningClient } from "./OrbixSigningClient";
18
+ export interface OrbixWalletGenericOpts {
19
19
  tmClient?: Tendermint37Client;
20
20
  txDefaultBroadcastMode?: BroadcastTxMode;
21
21
  network?: Network;
@@ -33,27 +33,27 @@ export interface CarbonWalletGenericOpts {
33
33
  /**
34
34
  * Optional callback that will be called before signing is requested/executed.
35
35
  */
36
- onRequestSign?: CarbonWallet.OnRequestSignCallback;
36
+ onRequestSign?: OrbixWallet.OnRequestSignCallback;
37
37
  /**
38
38
  * Optional callback that will be called when signing is complete.
39
39
  */
40
- onSignComplete?: CarbonWallet.OnSignCompleteCallback;
40
+ onSignComplete?: OrbixWallet.OnSignCompleteCallback;
41
41
  /**
42
42
  * Optional callback that will be called after tx is broadcast successful.
43
43
  */
44
- onBroadcastTxSuccess?: CarbonWallet.OnBroadcastTxSuccessCallback;
44
+ onBroadcastTxSuccess?: OrbixWallet.OnBroadcastTxSuccessCallback;
45
45
  /**
46
46
  * Optional callback that will be called if tx broadcast fails.
47
47
  */
48
- onBroadcastTxFail?: CarbonWallet.OnBroadcastTxFailCallback;
48
+ onBroadcastTxFail?: OrbixWallet.OnBroadcastTxFailCallback;
49
49
  /**
50
50
  * Optional callback that will be called before authentication is requested
51
51
  */
52
- onRequestAuth?: CarbonWallet.OnRequestAuthCallback;
52
+ onRequestAuth?: OrbixWallet.OnRequestAuthCallback;
53
53
  /**
54
54
  * Optional callback that will be called after authentication is complete
55
55
  */
56
- onAuthComplete?: CarbonWallet.OnAuthComplete;
56
+ onAuthComplete?: OrbixWallet.OnAuthComplete;
57
57
  }
58
58
  export interface AuthInfo {
59
59
  message: string;
@@ -75,7 +75,7 @@ type PrivateKeyOpts = {
75
75
  };
76
76
  type CustomSignerOpts = {
77
77
  mode: "customSigner";
78
- signer: CarbonSigner;
78
+ signer: OrbixSigner;
79
79
  publicKeyBase64: string;
80
80
  };
81
81
  type ViewOnlyOpts = {
@@ -88,7 +88,7 @@ type QROpts = {
88
88
  granter: string;
89
89
  expiry: Date;
90
90
  };
91
- export type CarbonWalletInitOpts = CarbonWalletGenericOpts & (MnemonicOpts | PrivateKeyOpts | CustomSignerOpts | ViewOnlyOpts | QROpts);
91
+ export type OrbixWalletInitOpts = OrbixWalletGenericOpts & (MnemonicOpts | PrivateKeyOpts | CustomSignerOpts | ViewOnlyOpts | QROpts);
92
92
  export interface AccountInfo extends Account {
93
93
  chainId: string;
94
94
  }
@@ -96,20 +96,20 @@ export interface Grantee {
96
96
  expiry: Date;
97
97
  signer: OfflineDirectSigner;
98
98
  }
99
- export declare class CarbonWallet {
99
+ export declare class OrbixWallet {
100
100
  network: Network;
101
101
  configOverride: Partial<NetworkConfig>;
102
102
  networkConfig: NetworkConfig;
103
- onRequestSign?: CarbonWallet.OnRequestSignCallback;
104
- onSignComplete?: CarbonWallet.OnSignCompleteCallback;
105
- onBroadcastTxSuccess?: CarbonWallet.OnBroadcastTxSuccessCallback;
106
- onBroadcastTxFail?: CarbonWallet.OnBroadcastTxFailCallback;
107
- onRequestAuth?: CarbonWallet.OnRequestAuthCallback;
108
- onAuthComplete?: CarbonWallet.OnAuthComplete;
103
+ onRequestSign?: OrbixWallet.OnRequestSignCallback;
104
+ onSignComplete?: OrbixWallet.OnSignCompleteCallback;
105
+ onBroadcastTxSuccess?: OrbixWallet.OnBroadcastTxSuccessCallback;
106
+ onBroadcastTxFail?: OrbixWallet.OnBroadcastTxFailCallback;
107
+ onRequestAuth?: OrbixWallet.OnRequestAuthCallback;
108
+ onAuthComplete?: OrbixWallet.OnAuthComplete;
109
109
  defaultTimeoutBlocks: number;
110
110
  mnemonic?: string;
111
111
  privateKey?: Buffer;
112
- signer: CarbonSigner;
112
+ signer: OrbixSigner;
113
113
  bech32Address: string;
114
114
  evmBech32Address: string;
115
115
  hexAddress: string;
@@ -117,7 +117,7 @@ export declare class CarbonWallet {
117
117
  accountMerged?: boolean;
118
118
  triggerMerge?: boolean;
119
119
  publicKey: Buffer;
120
- query?: CarbonQueryClient;
120
+ query?: OrbixQueryClient;
121
121
  txDefaultBroadCastMode?: BroadcastTxMode;
122
122
  initialized: boolean;
123
123
  accountInfo?: AccountInfo;
@@ -135,8 +135,8 @@ export declare class CarbonWallet {
135
135
  private sequenceInvalidated;
136
136
  private txSignManager;
137
137
  private txDispatchManager;
138
- constructor(opts: CarbonWalletInitOpts);
139
- initialize(queryClient: CarbonQueryClient, gasFee: GasFee, fallbackConfig?: OverrideConfig | null, opts?: CarbonWalletGenericOpts): Promise<CarbonWallet>;
138
+ constructor(opts: OrbixWalletInitOpts);
139
+ initialize(queryClient: OrbixQueryClient, gasFee: GasFee, fallbackConfig?: OverrideConfig | null, opts?: OrbixWalletGenericOpts): Promise<OrbixWallet>;
140
140
  reloadJwtToken(request?: GrantRequest, authMessage?: string): Promise<void>;
141
141
  queryViewOnlyEvmHexAddress(): Promise<void>;
142
142
  private refreshJwtToken;
@@ -144,40 +144,40 @@ export declare class CarbonWallet {
144
144
  private constructGrantRequest;
145
145
  setGrantee(grantee?: Grantee): void;
146
146
  isGranteeValid(): boolean;
147
- updateNetwork(network: Network): CarbonWallet;
147
+ updateNetwork(network: Network): OrbixWallet;
148
148
  setAuthorizedMsgs(msgs?: string[]): void;
149
- getSignedTx(signerAddress: string, messages: readonly EncodeObject[], sequence: number, opts: Omit<CarbonTx.SignTxOpts, "sequence">, granterAddress?: string): Promise<CarbonWallet.TxRaw>;
149
+ getSignedTx(signerAddress: string, messages: readonly EncodeObject[], sequence: number, opts: Omit<OrbixTx.SignTxOpts, "sequence">, granterAddress?: string): Promise<OrbixWallet.TxRaw>;
150
150
  /**
151
151
  * broadcast TX and wait for block confirmation
152
152
  *
153
153
  */
154
- broadcastTx(txRaw: CarbonWallet.TxRaw, opts?: CarbonTx.BroadcastTxOpts): Promise<CarbonWallet.SendTxResponse>;
154
+ broadcastTx(txRaw: OrbixWallet.TxRaw, opts?: OrbixTx.BroadcastTxOpts): Promise<OrbixWallet.SendTxResponse>;
155
155
  /**
156
156
  * broadcast TX to mempool but doesnt wait for block confirmation
157
157
  *
158
158
  */
159
- broadcastTxToMempoolWithoutConfirm(txRaw: CarbonWallet.TxRaw): Promise<CarbonWallet.SendTxToMempoolWithoutConfirmResponse>;
159
+ broadcastTxToMempoolWithoutConfirm(txRaw: OrbixWallet.TxRaw): Promise<OrbixWallet.SendTxToMempoolWithoutConfirmResponse>;
160
160
  /**
161
161
  * broadcast TX but doesnt wait for block confirmation nor submission to mempool
162
162
  *
163
163
  */
164
- broadcastTxWithoutConfirm(txRaw: CarbonWallet.TxRaw): Promise<CarbonWallet.SendTxWithoutConfirmResponse>;
165
- signAndBroadcast(messages: EncodeObject[], signOpts?: CarbonTx.SignTxOpts, broadcastOpts?: CarbonTx.BroadcastTxOpts): Promise<DeliverTxResponse | BroadcastTxSyncResponse | BroadcastTxAsyncResponse>;
164
+ broadcastTxWithoutConfirm(txRaw: OrbixWallet.TxRaw): Promise<OrbixWallet.SendTxWithoutConfirmResponse>;
165
+ signAndBroadcast(messages: EncodeObject[], signOpts?: OrbixTx.SignTxOpts, broadcastOpts?: OrbixTx.BroadcastTxOpts): Promise<DeliverTxResponse | BroadcastTxSyncResponse | BroadcastTxAsyncResponse>;
166
166
  private signTx;
167
167
  private signWithGrantee;
168
168
  private getBroadcastFunc;
169
169
  private dispatchTx;
170
- sendTxs(msgs: EncodeObject[], opts?: CarbonTx.SignTxOpts): Promise<CarbonWallet.SendTxResponse>;
171
- sendInitialMergeAccountTx(msgs: EncodeObject[], opts?: CarbonTx.SignTxOpts): Promise<void>;
172
- sendTxsWithoutConfirm(msgs: EncodeObject[], opts?: CarbonTx.SignTxOpts): Promise<CarbonWallet.SendTxToMempoolWithoutConfirmResponse>;
173
- sendTx(msg: EncodeObject, opts?: CarbonTx.SignTxOpts): Promise<CarbonWallet.SendTxResponse>;
170
+ sendTxs(msgs: EncodeObject[], opts?: OrbixTx.SignTxOpts): Promise<OrbixWallet.SendTxResponse>;
171
+ sendInitialMergeAccountTx(msgs: EncodeObject[], opts?: OrbixTx.SignTxOpts): Promise<void>;
172
+ sendTxsWithoutConfirm(msgs: EncodeObject[], opts?: OrbixTx.SignTxOpts): Promise<OrbixWallet.SendTxToMempoolWithoutConfirmResponse>;
173
+ sendTx(msg: EncodeObject, opts?: OrbixTx.SignTxOpts): Promise<OrbixWallet.SendTxResponse>;
174
174
  waitForTx(txHash: string, throwIfNotIncludedInBlock?: boolean, timeoutMs?: number, pollIntervalMs?: number): Promise<TxResponse>;
175
- getSigningClient(): Promise<CarbonSigningClient>;
175
+ getSigningClient(): Promise<OrbixSigningClient>;
176
176
  getTimeoutHeight(): Promise<number | undefined>;
177
177
  getTmClient(reconnect?: boolean): Promise<Tendermint37Client>;
178
178
  getChainId(): string;
179
179
  getEvmChainId(): string;
180
- isSigner(signerType: CarbonSignerTypes): boolean;
180
+ isSigner(signerType: OrbixSignerTypes): boolean;
181
181
  isLedgerSigner(): boolean;
182
182
  isLedgerViaBrowserExtension(): boolean;
183
183
  isPrivateKeySigner(): boolean;
@@ -203,7 +203,7 @@ export declare class CarbonWallet {
203
203
  private isNonceMismatchError;
204
204
  private getQueryClient;
205
205
  }
206
- export declare namespace CarbonWallet {
206
+ export declare namespace OrbixWallet {
207
207
  type SendTxResponse = DeliverTxResponse | BroadcastTxSyncResponse | BroadcastTxAsyncResponse;
208
208
  type SendTxToMempoolWithoutConfirmResponse = BroadcastTxSyncResponse;
209
209
  type SendTxWithoutConfirmResponse = BroadcastTxAsyncResponse;
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CarbonWallet = void 0;
7
- const CarbonSDK_1 = require("../CarbonSDK");
6
+ exports.OrbixWallet = void 0;
7
+ const OrbixSDK_1 = require("../OrbixSDK");
8
8
  const codec_1 = require("../codec");
9
9
  const auth_1 = require("../codec/cosmos/auth/v1beta1/auth");
10
10
  const web3_1 = require("../codec/ethermint/types/v1/web3");
@@ -34,11 +34,11 @@ const dayjs_1 = __importDefault(require("dayjs"));
34
34
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
35
35
  const ethers_1 = require("ethers");
36
36
  const jwt_decode_1 = require("jwt-decode");
37
- const CarbonSigner_1 = require("./CarbonSigner");
38
- const CarbonSigningClient_1 = require("./CarbonSigningClient");
37
+ const OrbixSigner_1 = require("./OrbixSigner");
38
+ const OrbixSigningClient_1 = require("./OrbixSigningClient");
39
39
  const bytes_1 = require("../util/bytes");
40
40
  dayjs_1.default.extend(utc_1.default);
41
- class CarbonWallet {
41
+ class OrbixWallet {
42
42
  constructor(opts) {
43
43
  this.initialized = false;
44
44
  this.isRainbowKit = false;
@@ -103,7 +103,7 @@ class CarbonWallet {
103
103
  prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
104
104
  if (!prefix)
105
105
  throw new Error("cannot instantiate wallet signer, no prefix");
106
- this.signer = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
106
+ this.signer = new OrbixSigner_1.OrbixPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
107
107
  break;
108
108
  }
109
109
  case "privateKey": {
@@ -115,7 +115,7 @@ class CarbonWallet {
115
115
  prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
116
116
  if (!prefix)
117
117
  throw new Error("cannot instantiate wallet signer, no prefix");
118
- this.signer = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
118
+ this.signer = new OrbixSigner_1.OrbixPrivateKeySigner((0, bytes_1.toUint8Array)(this.privateKey), prefix);
119
119
  break;
120
120
  }
121
121
  case "customSigner": {
@@ -125,7 +125,7 @@ class CarbonWallet {
125
125
  break;
126
126
  }
127
127
  case "viewOnly": {
128
- this.signer = new CarbonSigner_1.CarbonNonSigner();
128
+ this.signer = new OrbixSigner_1.OrbixNonSigner();
129
129
  this.publicKey = Buffer.from([]);
130
130
  this.bech32Address = opts.bech32Address;
131
131
  break;
@@ -140,7 +140,7 @@ class CarbonWallet {
140
140
  prefix = address_1.SWTHAddress.getBech32Prefix(addressOpts?.network, addressOpts?.bech32Prefix);
141
141
  if (!prefix)
142
142
  throw new Error("cannot instantiate wallet signer, no prefix");
143
- const pkSigner = new CarbonSigner_1.CarbonPrivateKeySigner((0, bytes_1.toUint8Array)(util_1.AddressUtils.SWTHAddress.mnemonicToPrivateKey(opts.mnemonic)), prefix);
143
+ const pkSigner = new OrbixSigner_1.OrbixPrivateKeySigner((0, bytes_1.toUint8Array)(util_1.AddressUtils.SWTHAddress.mnemonicToPrivateKey(opts.mnemonic)), prefix);
144
144
  this.signer = pkSigner;
145
145
  this.setGrantee({
146
146
  expiry: opts.expiry,
@@ -267,7 +267,7 @@ class CarbonWallet {
267
267
  const fee = opts?.fee ?? this.estimateTxFee(messages, feeDenom);
268
268
  const txRaw = await signingClient.sign(signerAddress, messages, fee, memo, signerData, granterAddress);
269
269
  let sig;
270
- if ((0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer)) {
270
+ if ((0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer)) {
271
271
  if (this.signer.legacyEip712SignMode) {
272
272
  const feePayerSigBz = web3_1.ExtensionOptionsWeb3Tx.decode(tx_2.TxBody.decode(txRaw.bodyBytes).extensionOptions[0].value).feePayerSig;
273
273
  sig = Uint8Array.from(Buffer.from(feePayerSigBz.slice(0, -1)));
@@ -295,12 +295,12 @@ class CarbonWallet {
295
295
  */
296
296
  async broadcastTx(txRaw, opts = {}) {
297
297
  const { pollIntervalMs = 3000, timeoutMs = 60000 } = opts;
298
- const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
299
- const carbonClient = await this.getSigningClient();
300
- const response = await carbonClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
298
+ const tx = OrbixWallet.TxRaw.encode(txRaw).finish();
299
+ const orbixClient = await this.getSigningClient();
300
+ const response = await orbixClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
301
301
  if ((0, stargate_1.isDeliverTxFailure)(response)) {
302
302
  // tx failed
303
- throw new tx_1.CarbonCustomError(`[${response.code}] ${response.rawLog}`, tx_1.ErrorType.BLOCK_FAIL, response);
303
+ throw new tx_1.OrbixCustomError(`[${response.code}] ${response.rawLog}`, tx_1.ErrorType.BLOCK_FAIL, response);
304
304
  }
305
305
  return response;
306
306
  }
@@ -309,12 +309,12 @@ class CarbonWallet {
309
309
  *
310
310
  */
311
311
  async broadcastTxToMempoolWithoutConfirm(txRaw) {
312
- const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
312
+ const tx = OrbixWallet.TxRaw.encode(txRaw).finish();
313
313
  const tmClient = await this.getTmClient();
314
314
  const response = await tmClient.broadcastTxSync({ tx });
315
315
  if (!(0, responses_1.broadcastTxSyncSuccess)(response)) {
316
316
  // tx failed
317
- throw new tx_1.CarbonCustomError(`[${response.code}] ${response.log}`, tx_1.ErrorType.BROADCAST_FAIL, response);
317
+ throw new tx_1.OrbixCustomError(`[${response.code}] ${response.log}`, tx_1.ErrorType.BROADCAST_FAIL, response);
318
318
  }
319
319
  return response;
320
320
  }
@@ -323,7 +323,7 @@ class CarbonWallet {
323
323
  *
324
324
  */
325
325
  async broadcastTxWithoutConfirm(txRaw) {
326
- const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
326
+ const tx = OrbixWallet.TxRaw.encode(txRaw).finish();
327
327
  const tmClient = await this.getTmClient();
328
328
  return tmClient.broadcastTxAsync({ tx });
329
329
  }
@@ -349,12 +349,12 @@ class CarbonWallet {
349
349
  else {
350
350
  try {
351
351
  if (!this.accountInfo
352
- || this.accountInfo?.address === this.evmBech32Address // refresh to check if carbon acc is present
352
+ || this.accountInfo?.address === this.evmBech32Address // refresh to check if orbix acc is present
353
353
  || this.sequenceInvalidated)
354
354
  await this.reloadAccountSequence();
355
355
  let timeoutHeight;
356
356
  // timeoutHeight is not supported for EIP-712
357
- if (!(0, CarbonSigner_1.isCarbonEIP712Signer)(this.signer)) {
357
+ if (!(0, OrbixSigner_1.isOrbixEIP712Signer)(this.signer)) {
358
358
  timeoutHeight = await this.getTimeoutHeight();
359
359
  }
360
360
  let sequence;
@@ -427,7 +427,7 @@ class CarbonWallet {
427
427
  ...signOpts?.explicitSignerData,
428
428
  };
429
429
  const tmClient = await this.getTmClient();
430
- const signingClient = new CarbonSigningClient_1.CarbonSigningClient(tmClient, signer);
430
+ const signingClient = new OrbixSigningClient_1.OrbixSigningClient(tmClient, signer);
431
431
  const signedTx = await signingClient.sign(granteeAddress, msgExecMessages, fee, memo, signerData, this.bech32Address);
432
432
  this.txDispatchManager.enqueue({
433
433
  ...txRequest,
@@ -483,7 +483,7 @@ class CarbonWallet {
483
483
  }
484
484
  try {
485
485
  const result = await this.signAndBroadcast(msgs, opts);
486
- if (msgs[0].typeUrl === util_1.CarbonTx.Types.MsgMergeAccount) {
486
+ if (msgs[0].typeUrl === util_1.OrbixTx.Types.MsgMergeAccount) {
487
487
  this.updateMergeAccountStatus();
488
488
  }
489
489
  await util_1.GenericUtils.callIgnoreError(() => this.onBroadcastTxSuccess?.(msgs));
@@ -497,7 +497,7 @@ class CarbonWallet {
497
497
  async sendInitialMergeAccountTx(msgs, opts) {
498
498
  let msg;
499
499
  await this.reloadMergeAccountStatus();
500
- if (!this.accountMerged && msgs[0].typeUrl !== util_1.CarbonTx.Types.MsgMergeAccount) {
500
+ if (!this.accountMerged && msgs[0].typeUrl !== util_1.OrbixTx.Types.MsgMergeAccount) {
501
501
  const accountInfo = await this.reloadAccountInfo();
502
502
  if (!accountInfo) {
503
503
  throw new Error('Account not found!');
@@ -505,8 +505,8 @@ class CarbonWallet {
505
505
  const { address, sequence, accountNumber } = accountInfo;
506
506
  try {
507
507
  msg = {
508
- typeUrl: util_1.CarbonTx.Types.MsgMergeAccount,
509
- value: CarbonSDK_1.Carbon.Evmmerge.MsgMergeAccount.fromPartial({
508
+ typeUrl: util_1.OrbixTx.Types.MsgMergeAccount,
509
+ value: OrbixSDK_1.Orbix.Evmmerge.MsgMergeAccount.fromPartial({
510
510
  creator: address,
511
511
  pubKey: this.publicKey.toString('hex'),
512
512
  }),
@@ -554,7 +554,7 @@ class CarbonWallet {
554
554
  const { result } = response;
555
555
  const isDeliverTxFailure = result.code !== 0;
556
556
  if (isDeliverTxFailure && throwIfNotIncludedInBlock)
557
- throw new tx_1.CarbonCustomError(`[${result.code}] ${result.log}`, tx_1.ErrorType.BLOCK_FAIL, response);
557
+ throw new tx_1.OrbixCustomError(`[${result.code}] ${result.log}`, tx_1.ErrorType.BLOCK_FAIL, response);
558
558
  return response;
559
559
  }
560
560
  catch (err) {
@@ -577,7 +577,7 @@ class CarbonWallet {
577
577
  async getSigningClient() {
578
578
  const tmClient = await this.getTmClient();
579
579
  if (!this.signingClient) {
580
- this.signingClient = new CarbonSigningClient_1.CarbonSigningClient(tmClient, this.signer);
580
+ this.signingClient = new OrbixSigningClient_1.OrbixSigningClient(tmClient, this.signer);
581
581
  }
582
582
  return this.signingClient;
583
583
  }
@@ -599,37 +599,37 @@ class CarbonWallet {
599
599
  this.tmClient = await tendermint_rpc_1.Tendermint37Client.connect(this.networkConfig.tmRpcUrl);
600
600
  const status = await this.tmClient.status();
601
601
  this.chainId = status.nodeInfo.network;
602
- this.evmChainId = constant_1.CarbonEvmChainIDs[this.network];
602
+ this.evmChainId = constant_1.OrbixEvmChainIDs[this.network];
603
603
  }
604
604
  return this.tmClient;
605
605
  }
606
606
  getChainId() {
607
607
  if (!this.chainId)
608
- throw new Error("CarbonWallet is not initialized");
608
+ throw new Error("OrbixWallet is not initialized");
609
609
  return this.chainId;
610
610
  }
611
611
  getEvmChainId() {
612
612
  if (!this.evmChainId)
613
- throw new Error("CarbonWallet is not initialized");
613
+ throw new Error("OrbixWallet is not initialized");
614
614
  return this.evmChainId;
615
615
  }
616
616
  isSigner(signerType) {
617
617
  return this.signer.type === signerType;
618
618
  }
619
619
  isLedgerSigner() {
620
- return this.isSigner(CarbonSigner_1.CarbonSignerTypes.Ledger) || this.isLedgerViaBrowserExtension();
620
+ return this.isSigner(OrbixSigner_1.OrbixSignerTypes.Ledger) || this.isLedgerViaBrowserExtension();
621
621
  }
622
622
  isLedgerViaBrowserExtension() {
623
623
  return (this.providerAgent === walletProvider_1.ProviderAgent.KeplrExtension || this.providerAgent === walletProvider_1.ProviderAgent.LeapExtension) && !(0, proto_signing_1.isOfflineDirectSigner)(this.signer);
624
624
  }
625
625
  isPrivateKeySigner() {
626
- return this.isSigner(CarbonSigner_1.CarbonSignerTypes.PrivateKey);
626
+ return this.isSigner(OrbixSigner_1.OrbixSignerTypes.PrivateKey);
627
627
  }
628
628
  isBrowserInjectedSigner() {
629
- return this.isSigner(CarbonSigner_1.CarbonSignerTypes.BrowserInjected);
629
+ return this.isSigner(OrbixSigner_1.OrbixSignerTypes.BrowserInjected);
630
630
  }
631
631
  isNonSigner() {
632
- return this.isSigner(CarbonSigner_1.CarbonSignerTypes.PublicKey);
632
+ return this.isSigner(OrbixSigner_1.OrbixSignerTypes.PublicKey);
633
633
  }
634
634
  isSmartWalletEnabled() {
635
635
  return !!(this.mnemonic || this.privateKey);
@@ -661,7 +661,7 @@ class CarbonWallet {
661
661
  }
662
662
  }
663
663
  async reloadAccountInfo() {
664
- // carbon account always takes priority
664
+ // orbix account always takes priority
665
665
  let evmBech32Acc = null;
666
666
  const bech32Acc = this.bech32Address && await this.getAccount(this.bech32Address);
667
667
  if (!bech32Acc && this.evmBech32Address) {
@@ -731,7 +731,7 @@ class CarbonWallet {
731
731
  return this.providerAgent === walletProvider_1.ProviderAgent.MetamaskExtension || this.isRainbowKit;
732
732
  }
733
733
  isViewOnlyWallet() {
734
- return this.signer.type === CarbonSigner_1.CarbonSignerTypes.PublicKey;
734
+ return this.signer.type === OrbixSigner_1.OrbixSignerTypes.PublicKey;
735
735
  }
736
736
  estimateTxFee(messages, feeDenom = constant_1.DEFAULT_FEE_DENOM) {
737
737
  const denomGasPrice = this.gasFee?.getGasPrice(feeDenom);
@@ -784,7 +784,7 @@ class CarbonWallet {
784
784
  return this.query;
785
785
  }
786
786
  }
787
- exports.CarbonWallet = CarbonWallet;
788
- (function (CarbonWallet) {
789
- CarbonWallet.TxRaw = { ...tx_2.TxRaw };
790
- })(CarbonWallet || (exports.CarbonWallet = CarbonWallet = {}));
787
+ exports.OrbixWallet = OrbixWallet;
788
+ (function (OrbixWallet) {
789
+ OrbixWallet.TxRaw = { ...tx_2.TxRaw };
790
+ })(OrbixWallet || (exports.OrbixWallet = OrbixWallet = {}));
@@ -1,2 +1,2 @@
1
- export * from "./CarbonSigner";
2
- export * from "./CarbonWallet";
1
+ export * from "./OrbixSigner";
2
+ export * from "./OrbixWallet";
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./CarbonSigner"), exports);
18
- __exportStar(require("./CarbonWallet"), exports);
17
+ __exportStar(require("./OrbixSigner"), exports);
18
+ __exportStar(require("./OrbixWallet"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-js-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "TypeScript SDK for Mememax Orbix blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,145 +0,0 @@
1
- import { Network, NetworkConfig, Network as _Network } from "./constant";
2
- import { Tendermint37Client } from "@cosmjs/tendermint-rpc";
3
- import * as clients from "./clients";
4
- import { CarbonQueryClient, HydrogenClient, InsightsQueryClient, TokenClient } from "./clients";
5
- import GasFee from "./clients/GasFee";
6
- import GrpcQueryClient from "./clients/GrpcQueryClient";
7
- import { AdminModule, AllianceModule, BankModule, BridgeModule, BrokerModule, CoinModule, EvmMergeModule, EvmModule, FeeModule, GovModule, IBCModule, LeverageModule, MarketModule, OracleModule, OrderModule, PerpspoolModule, PositionModule, SubAccountModule } from "./modules";
8
- import { GrantModule } from "./modules/grant";
9
- import { StakingModule } from "./modules/staking";
10
- import { CosmosLedger, Keplr, LeapExtended } from "./provider";
11
- import { MetaMask } from "./provider/metamask/MetaMask";
12
- import RainbowKitAccount from "./provider/rainbowKit/RainbowKitAccount";
13
- import { CarbonSigner, CarbonWallet, CarbonWalletGenericOpts, EvmWalletOpts, RainbowKitWalletOpts } from "./wallet";
14
- export { CarbonTx } from "./util";
15
- export { CarbonSigner, CarbonSignerTypes, CarbonWallet, CarbonWalletGenericOpts, CarbonWalletInitOpts } from "./wallet";
16
- export * as Carbon from "./codec/carbon-models";
17
- export interface CarbonSDKOpts {
18
- network: Network;
19
- tmClient: Tendermint37Client;
20
- wallet?: CarbonWallet;
21
- chainId?: string;
22
- evmChainId?: string;
23
- token?: TokenClient;
24
- query?: CarbonQueryClient;
25
- hydrogen?: HydrogenClient;
26
- insights?: InsightsQueryClient;
27
- config?: Partial<NetworkConfig>;
28
- grpcQueryClient?: GrpcQueryClient;
29
- useTmAbciQuery?: boolean;
30
- defaultTimeoutBlocks?: number;
31
- gasFee?: GasFee;
32
- }
33
- export interface CarbonSDKInitOpts {
34
- network: Network;
35
- tmClient?: Tendermint37Client;
36
- config?: Partial<NetworkConfig>;
37
- wallet?: CarbonWallet;
38
- skipInit?: boolean;
39
- defaultTimeoutBlocks?: number;
40
- /**
41
- * temporary flag to disable GRPC Query client service when required
42
- * TODO: Deprecate when grpc query client is implemented across all networks
43
- */
44
- useTmAbciQuery?: boolean;
45
- }
46
- export interface OverrideConfig {
47
- chainId: string;
48
- evmChainId: string;
49
- }
50
- /**
51
- * Carbon SDK
52
- *
53
- *
54
- */
55
- declare class CarbonSDK {
56
- static DEFAULT_NETWORK: Network;
57
- static DenomPrefix: {
58
- LPToken: string;
59
- CDPToken: string;
60
- PerpPoolToken: string;
61
- UserVaultToken: string;
62
- };
63
- initialized: boolean;
64
- readonly query: CarbonQueryClient;
65
- readonly useTmAbciQuery: boolean;
66
- insights: InsightsQueryClient;
67
- hydrogen: HydrogenClient;
68
- wallet?: CarbonWallet;
69
- gasFee?: GasFee;
70
- network: Network;
71
- configOverride: Partial<NetworkConfig>;
72
- networkConfig: NetworkConfig;
73
- tmClient: Tendermint37Client;
74
- token: TokenClient;
75
- admin: AdminModule;
76
- alliance: AllianceModule;
77
- order: OrderModule;
78
- perpspool: PerpspoolModule;
79
- grant: GrantModule;
80
- subaccount: SubAccountModule;
81
- leverage: LeverageModule;
82
- market: MarketModule;
83
- broker: BrokerModule;
84
- position: PositionModule;
85
- coin: CoinModule;
86
- oracle: OracleModule;
87
- gov: GovModule;
88
- staking: StakingModule;
89
- bank: BankModule;
90
- fee: FeeModule;
91
- ibc: IBCModule;
92
- evm: EvmModule;
93
- evmmerge: EvmMergeModule;
94
- bridge: BridgeModule;
95
- chainId: string;
96
- evmChainId: string;
97
- constructor(opts: CarbonSDKOpts);
98
- static instance(opts?: CarbonSDKInitOpts): Promise<CarbonSDK>;
99
- static instanceWithWallet(wallet: CarbonWallet, sdkOpts?: CarbonSDKInitOpts): Promise<ConnectedCarbonSDK>;
100
- static instanceWithPrivateKey(privateKey: string | Buffer, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
101
- static instanceWithMnemonic(mnemonic: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
102
- static instanceWithSigner(signer: CarbonSigner, publicKeyBase64: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
103
- static instanceWithLedger(ledger: CosmosLedger, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
104
- static instanceWithKeplr(keplr: Keplr, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
105
- static instanceWithLeap(leap: LeapExtended, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
106
- static instanceWithMetamask(metamask: MetaMask, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
107
- static instanceWithRainbowKit(rainbowKit: RainbowKitAccount, sdkOpts: CarbonSDKInitOpts | undefined, rainbowKitWalletOpts: RainbowKitWalletOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
108
- static instanceViewOnly(bech32Address: string, sdkOpts?: CarbonSDKInitOpts, walletOpts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
109
- initialize(): Promise<CarbonSDK>;
110
- getGasFee(): Promise<GasFee>;
111
- clone(): CarbonSDK;
112
- generateOpts(): CarbonSDKOpts;
113
- connect(wallet: CarbonWallet, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
114
- disconnect(): CarbonSDK;
115
- connectWithPrivateKey(privateKey: string | Buffer, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
116
- connectWithMnemonic(mnemonic: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
117
- connectWithSigner(signer: CarbonSigner, publicKeyBase64: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
118
- connectWithLedger(ledger: CosmosLedger, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
119
- connectWithKeplr(keplr: Keplr, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
120
- connectWithLeap(leap: LeapExtended, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
121
- connectWithMetamask(metamask: MetaMask, opts?: CarbonWalletGenericOpts, evmWalletOpts?: EvmWalletOpts): Promise<ConnectedCarbonSDK>;
122
- connectWithRainbowKit(rainbowKit: RainbowKitAccount, rainbowKitWalletOpts: RainbowKitWalletOpts, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
123
- connectViewOnly(bech32Address: string, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
124
- connectWithQr(granteeMnemonic: string, granterAddress: string, expiry: Date, opts?: CarbonWalletGenericOpts): Promise<ConnectedCarbonSDK>;
125
- getConfig(): NetworkConfig;
126
- getTokenClient(): TokenClient;
127
- getConnectedWallet(): CarbonWallet;
128
- log(...args: any[]): void;
129
- private checkWallet;
130
- static parseNetwork: (network: string, defaultNetwork?: Network | null) => Network | null;
131
- }
132
- export declare class ConnectedCarbonSDK extends CarbonSDK {
133
- wallet: CarbonWallet;
134
- constructor(wallet: CarbonWallet, opts: CarbonSDKOpts);
135
- clone(): ConnectedCarbonSDK;
136
- }
137
- declare namespace CarbonSDK {
138
- export import Network = _Network;
139
- export import CarbonQueryClient = clients.CarbonQueryClient;
140
- export import ETHClient = clients.ETHClient;
141
- export import HydrogenClient = clients.HydrogenClient;
142
- export import InsightsQueryClient = clients.InsightsQueryClient;
143
- export import TokenClient = clients.TokenClient;
144
- }
145
- export default CarbonSDK;
File without changes