@cryptorubic/web3 1.1.0-alpha-stellar.16 → 1.1.0-alpha-stellar.20
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
|
@@ -38,7 +38,8 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
38
38
|
const resp = await this.public.getTrustline(userAddress, this.convertTokenAddressToAsset(tokenAddress));
|
|
39
39
|
return new bignumber_js_1.default(resp.balance().toString());
|
|
40
40
|
}
|
|
41
|
-
catch {
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error(err);
|
|
42
43
|
return new bignumber_js_1.default(0);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -89,21 +90,16 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
89
90
|
}
|
|
90
91
|
async addTrustline(tokenAddress) {
|
|
91
92
|
try {
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})
|
|
97
|
-
.addOperation(stellar_sdk_1.Operation.changeTrust({
|
|
98
|
-
asset: this.convertTokenAddressToAsset(tokenAddress)
|
|
99
|
-
}))
|
|
100
|
-
.setTimeout(30)
|
|
101
|
-
.build();
|
|
102
|
-
return this.signer.sendTransaction({
|
|
103
|
-
txOptions: {
|
|
104
|
-
transaction: tx
|
|
105
|
-
}
|
|
93
|
+
const tx = await this.encodeTrustline(tokenAddress, this.signer.walletAddress);
|
|
94
|
+
const { signedTxXdr } = await this.signer.wallet.signTransaction(tx, {
|
|
95
|
+
networkPassphrase: stellar_sdk_1.Networks.PUBLIC,
|
|
96
|
+
address: this.signer.walletAddress
|
|
106
97
|
});
|
|
98
|
+
const resp = await this.public.sendTransaction(stellar_sdk_1.TransactionBuilder.fromXDR(signedTxXdr, stellar_sdk_1.Networks.PUBLIC));
|
|
99
|
+
if (resp.status === 'ERROR') {
|
|
100
|
+
throw new Error('Failed to execute transaction', { cause: resp.errorResult });
|
|
101
|
+
}
|
|
102
|
+
return resp.hash;
|
|
107
103
|
}
|
|
108
104
|
catch (err) {
|
|
109
105
|
this.logger?.customError('FAILED TO ADD TRUSTLINE', err);
|