carbon-js-sdk 0.4.13 → 0.4.15

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.
@@ -12,8 +12,8 @@ export interface ETHClientOpts {
12
12
  blockchain: typeof ETHClient.SUPPORTED_BLOCKCHAINS[number];
13
13
  }
14
14
  interface ETHTxParams {
15
- gasPriceGwei: BigNumber;
16
- gasLimit: BigNumber;
15
+ gasPriceGwei?: BigNumber;
16
+ gasLimit?: BigNumber;
17
17
  ethAddress: string;
18
18
  signer: ethers.Signer;
19
19
  nonce?: number;
@@ -26,8 +26,8 @@ export interface BridgeParams {
26
26
  recoveryAddress: string;
27
27
  toAddress: string;
28
28
  feeAmount: BigNumber;
29
- gasPriceGwei: BigNumber;
30
- gasLimit: BigNumber;
29
+ gasPriceGwei?: BigNumber;
30
+ gasLimit?: BigNumber;
31
31
  signer: ethers.Signer;
32
32
  signCompleteCallback?: () => void;
33
33
  nonce?: number;
@@ -75,11 +75,7 @@ class ETHClient {
75
75
  const rpcProvider = this.getProvider();
76
76
  const contract = new ethers_1.ethers.Contract(contractAddress, eth_1.ABIs.erc20, rpcProvider);
77
77
  const nonce = yield this.getTxNonce(ethAddress, params.nonce, rpcProvider);
78
- const approveResultTx = yield contract.connect(signer).approve(spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : token.bridgeAddress, ethers_1.ethers.constants.MaxUint256, {
79
- nonce,
80
- gasPrice: gasPriceGwei.shiftedBy(9).toString(10),
81
- gasLimit: gasLimit.toString(10),
82
- });
78
+ const approveResultTx = yield contract.connect(signer).approve(spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : token.bridgeAddress, ethers_1.ethers.constants.MaxUint256, Object.assign(Object.assign({ nonce }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })));
83
79
  return approveResultTx;
84
80
  });
85
81
  }
@@ -127,13 +123,7 @@ class ETHClient {
127
123
  amount.toString(10),
128
124
  feeAmount.toString(10),
129
125
  amount.toString(10),
130
- ], // callAmount
131
- {
132
- gasLimit: gasLimit.toString(10),
133
- gasPrice: gasPriceGwei.shiftedBy(9).toString(10),
134
- nonce,
135
- value: ethAmount.toString(10),
136
- });
126
+ ], Object.assign(Object.assign(Object.assign({}, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })), { nonce, value: ethAmount.toString(10) }));
137
127
  signCompleteCallback === null || signCompleteCallback === void 0 ? void 0 : signCompleteCallback();
138
128
  return bridgeResultTx;
139
129
  });
@@ -141,7 +131,7 @@ class ETHClient {
141
131
  lockDeposit(params) {
142
132
  return __awaiter(this, void 0, void 0, function* () {
143
133
  const { address, token, amount, gasPriceGwei, gasLimit, ethAddress, signer, signCompleteCallback } = params;
144
- if (gasLimit.lt(150000)) {
134
+ if (gasLimit === null || gasLimit === void 0 ? void 0 : gasLimit.lt(150000)) {
145
135
  throw new Error("Minimum gas required: 150,000");
146
136
  }
147
137
  const networkConfig = this.getNetworkConfig();
@@ -164,7 +154,7 @@ class ETHClient {
164
154
  amount.toString(),
165
155
  "0",
166
156
  amount.toString(), // callAmount
167
- ], Object.assign({ nonce, value: "0", gasPrice: gasPriceGwei.shiftedBy(9).toString(10), gasLimit: gasLimit.toString(10) }, (token.tokenAddress === "0000000000000000000000000000000000000000" && {
157
+ ], Object.assign(Object.assign(Object.assign({ nonce, value: "0" }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })), (token.tokenAddress === "0000000000000000000000000000000000000000" && {
168
158
  value: amount.toString(),
169
159
  })));
170
160
  signCompleteCallback === null || signCompleteCallback === void 0 ? void 0 : signCompleteCallback();
@@ -7,8 +7,11 @@ interface RequestArguments {
7
7
  params?: unknown[] | object;
8
8
  }
9
9
  interface MetaMaskAPI {
10
+ isMetaMask: boolean;
11
+ chainId: string | null;
10
12
  isConnected: () => boolean;
11
13
  request: (args: RequestArguments) => Promise<unknown>;
14
+ on: (eventName: string, listener: (...args: unknown[]) => void) => any;
12
15
  }
13
16
  export interface MetaMaskChangeNetworkParam {
14
17
  chainId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",