@cryptorubic/web3 1.1.0-alpha-stellar.48 → 1.1.0-alpha-stellar.49
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.
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@ export declare class StellarAdapter extends AbstractAdapter<StellarClient, Stell
|
|
|
42
42
|
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
43
43
|
getMinWeiBalance(userAddress: string): Promise<BigNumber>;
|
|
44
44
|
getFeeFromTransaction(xdr: string): BigNumber;
|
|
45
|
+
private parseTxError;
|
|
45
46
|
callContractMethod<T extends Web3PrimitiveType = string>(_contractAddress: string, _contractAbi: Abi | undefined, _methodName: string, _methodArguments?: {
|
|
46
47
|
value: string;
|
|
47
48
|
type: string;
|
|
@@ -10,6 +10,7 @@ const stellar_sdk_2 = require("@stellar/stellar-sdk");
|
|
|
10
10
|
const bignumber_js_1 = require("bignumber.js");
|
|
11
11
|
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
12
12
|
const fake_stellar_wallet_1 = require("./constants/fake-stellar-wallet");
|
|
13
|
+
const insufficient_funds_gas_price_value_error_1 = require("../../../errors/cross-chain/insufficient-funds-gas-price-value.error");
|
|
13
14
|
class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
14
15
|
constructor(rpc, httpClient, logger, clientParams) {
|
|
15
16
|
super(core_1.BLOCKCHAIN_NAME.STELLAR, logger);
|
|
@@ -130,12 +131,12 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
130
131
|
networkPassphrase: stellar_sdk_1.Networks.PUBLIC,
|
|
131
132
|
address: this.signer.walletAddress
|
|
132
133
|
});
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
134
|
+
const resp = await this.public.sendTransaction(stellar_sdk_1.TransactionBuilder.fromXDR(signedTxXdr, stellar_sdk_1.Networks.PUBLIC));
|
|
135
|
+
const resStatus = await this.public.pollTransaction(resp.hash);
|
|
136
|
+
if (resStatus.status === 'FAILED') {
|
|
137
|
+
this.parseTxError(resStatus.resultXdr);
|
|
137
138
|
}
|
|
138
|
-
return
|
|
139
|
+
return resStatus.txHash;
|
|
139
140
|
}
|
|
140
141
|
catch (err) {
|
|
141
142
|
this.logger?.customError('FAILED TO ADD TRUSTLINE', err);
|
|
@@ -225,6 +226,13 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
225
226
|
const parsedTranssaction = stellar_sdk_1.TransactionBuilder.fromXDR(xdr, stellar_sdk_1.Networks.PUBLIC);
|
|
226
227
|
return new bignumber_js_1.default(parsedTranssaction.fee);
|
|
227
228
|
}
|
|
229
|
+
parseTxError(txResult) {
|
|
230
|
+
const failedOperation = txResult.result().results()[0];
|
|
231
|
+
const failedOperationCode = failedOperation.tr().value().switch().name;
|
|
232
|
+
if (failedOperationCode === stellar_sdk_1.xdr.ChangeTrustResultCode.changeTrustLowReserve().name) {
|
|
233
|
+
throw new insufficient_funds_gas_price_value_error_1.InsufficientFundsGasPriceValueError();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
228
236
|
async callContractMethod(_contractAddress, _contractAbi = [], _methodName, _methodArguments = [], _options) {
|
|
229
237
|
throw new Error('Method call is not supported');
|
|
230
238
|
}
|