@cryptorubic/web3 1.1.0-alpha-stellar.11 → 1.1.0-alpha-stellar.12
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
|
@@ -25,13 +25,14 @@ export declare class StellarAdapter extends AbstractAdapter<StellarClient, Stell
|
|
|
25
25
|
callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<BlockchainName>[]>;
|
|
26
26
|
callForTokenInfo(tokenAddress: string): Promise<Token<BlockchainName>>;
|
|
27
27
|
checkEnoughBalance(token: TokenAmount, walletAddress: string): Promise<boolean>;
|
|
28
|
+
checkTrustline(token: TokenAmount, walletAddress: string): Promise<boolean>;
|
|
28
29
|
getTokenContractId(tokenAddress: string): string;
|
|
29
30
|
private convertTokenAddressToAsset;
|
|
30
31
|
read<T>(address: string, method: string, methodArgs?: {
|
|
31
32
|
value: string;
|
|
32
33
|
type: string;
|
|
33
34
|
}[]): Promise<T>;
|
|
34
|
-
simulateTransaction(config: StellarTransactionConfig
|
|
35
|
+
simulateTransaction(config: StellarTransactionConfig): Promise<string>;
|
|
35
36
|
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
36
37
|
callContractMethod<T extends Web3PrimitiveType = string>(_contractAddress: string, _contractAbi: Abi | undefined, _methodName: string, _methodArguments?: {
|
|
37
38
|
value: string;
|
|
@@ -75,6 +75,15 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
75
75
|
const userBalance = await this.getBalance(walletAddress, token.address);
|
|
76
76
|
return userBalance.gte(token.weiAmount);
|
|
77
77
|
}
|
|
78
|
+
async checkTrustline(token, walletAddress) {
|
|
79
|
+
try {
|
|
80
|
+
const trustline = await this.public.getTrustline(walletAddress, this.convertTokenAddressToAsset(token.address));
|
|
81
|
+
return token.weiAmount.gte(trustline.limit().toString());
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
78
87
|
getTokenContractId(tokenAddress) {
|
|
79
88
|
if (web3_pure_1.Web3Pure.isNativeAddress(core_1.BLOCKCHAIN_NAME.STELLAR, tokenAddress)) {
|
|
80
89
|
return stellar_sdk_1.Asset.native().contractId(stellar_sdk_1.Networks.PUBLIC);
|
|
@@ -103,10 +112,13 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
103
112
|
const rawValue = resp.result.retval;
|
|
104
113
|
return (0, stellar_sdk_1.scValToNative)(rawValue);
|
|
105
114
|
}
|
|
106
|
-
async simulateTransaction(config
|
|
115
|
+
async simulateTransaction(config) {
|
|
107
116
|
try {
|
|
108
|
-
await this.public.simulateTransaction(stellar_sdk_1.TransactionBuilder.fromXDR(config.transaction, stellar_sdk_1.Networks.PUBLIC));
|
|
109
|
-
|
|
117
|
+
const resp = await this.public.simulateTransaction(stellar_sdk_1.TransactionBuilder.fromXDR(config.transaction, stellar_sdk_1.Networks.PUBLIC));
|
|
118
|
+
if ('error' in resp) {
|
|
119
|
+
throw new Error(resp.error);
|
|
120
|
+
}
|
|
121
|
+
return resp.minResourceFee;
|
|
110
122
|
}
|
|
111
123
|
catch (err) {
|
|
112
124
|
this.logger?.customError('Error while simulating transaction', err);
|