@cryptorubic/web3 1.1.0-alpha-stellar.15 → 1.1.0-alpha-stellar.16

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "1.1.0-alpha-stellar.15",
3
+ "version": "1.1.0-alpha-stellar.16",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -27,6 +27,7 @@ export declare class StellarAdapter extends AbstractAdapter<StellarClient, Stell
27
27
  checkEnoughBalance(token: TokenAmount | PriceTokenAmount, walletAddress: string): Promise<boolean>;
28
28
  checkTrustline(token: TokenAmount | PriceTokenAmount, walletAddress: string): Promise<boolean>;
29
29
  addTrustline(tokenAddress: string): Promise<string>;
30
+ encodeTrustline(tokenAddress: string, walletAddress: string): Promise<string>;
30
31
  getTokenContractId(tokenAddress: string): string;
31
32
  private convertTokenAddressToAsset;
32
33
  read<T>(address: string, method: string, methodArgs?: {
@@ -110,6 +110,19 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
110
110
  throw err;
111
111
  }
112
112
  }
113
+ async encodeTrustline(tokenAddress, walletAddress) {
114
+ const account = await this.public.getAccount(walletAddress);
115
+ const tx = new stellar_sdk_1.TransactionBuilder(account, {
116
+ fee: stellar_sdk_1.BASE_FEE,
117
+ networkPassphrase: stellar_sdk_1.Networks.PUBLIC
118
+ })
119
+ .addOperation(stellar_sdk_1.Operation.changeTrust({
120
+ asset: this.convertTokenAddressToAsset(tokenAddress)
121
+ }))
122
+ .setTimeout(30)
123
+ .build();
124
+ return tx.toXDR();
125
+ }
113
126
  getTokenContractId(tokenAddress) {
114
127
  if (web3_pure_1.Web3Pure.isNativeAddress(core_1.BLOCKCHAIN_NAME.STELLAR, tokenAddress)) {
115
128
  return stellar_sdk_1.Asset.native().contractId(stellar_sdk_1.Networks.PUBLIC);