@stellar-broker/client 0.6.11 → 0.6.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/mediator.js +14 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-broker/client",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "description": "Client library for StellarBroker service",
5
5
  "author": "team@stellar.broker",
6
6
  "homepage": "https://stellar.broker",
package/src/mediator.js CHANGED
@@ -192,6 +192,20 @@ export class Mediator {
192
192
  amount: fromStroops(this.sellingAmount)
193
193
  }))
194
194
  }
195
+ //create trustline for buying asset
196
+ if (!buyingAsset.isNative()) {
197
+ ops.push(Operation.changeTrust({
198
+ source: this.mediatorAddress,
199
+ asset: buyingAsset
200
+ }))
201
+ //if source account itself doesn't have trustline for buying asset
202
+ if (!findTrustline(sourceAccount, buyingAsset)) {
203
+ ops.push(Operation.changeTrust({
204
+ source: this.source,
205
+ asset: buyingAsset
206
+ }))
207
+ }
208
+ }
195
209
 
196
210
  if (sourceAccount.signers.length > 1) { //multisig or delegated schema
197
211
  let {thresholds, signers} = sourceAccount
@@ -235,13 +249,6 @@ export class Mediator {
235
249
  }))
236
250
  }
237
251
 
238
- //create trustline for buying asset
239
- if (!buyingAsset.isNative()) {
240
- ops.push(Operation.changeTrust({
241
- source: this.mediatorAddress,
242
- asset: buyingAsset
243
- }))
244
- }
245
252
  //store the record in the localStorage
246
253
  localStorage.setItem(this.storagePrefix + this.mediatorAddress, this.source)
247
254
  //confirm tx