@stellar-broker/client 0.6.7 → 0.6.9
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 +1 -1
- package/src/mediator.js +7 -6
package/package.json
CHANGED
package/src/mediator.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {Asset, Keypair, Memo, Operation, TransactionBuilder, Horizon, Networks, StrKey,
|
|
1
|
+
import {Asset, Keypair, Memo, Operation, TransactionBuilder, Horizon, Networks, StrKey, TimeoutInfinite} from '@stellar/stellar-sdk'
|
|
2
2
|
import {fromStroops, toStroops} from './stroops.js'
|
|
3
3
|
import {convertToStellarAsset} from './asset.js'
|
|
4
4
|
import {AuthorizationWrapper} from './authorization.js'
|
|
5
5
|
|
|
6
6
|
//additional XLM amount to cover tx fees
|
|
7
|
-
const defaultFeesReserve =
|
|
7
|
+
const defaultFeesReserve = 2.5
|
|
8
8
|
const defaultStoragePrefix = 'msb_'
|
|
9
9
|
|
|
10
10
|
export class Mediator {
|
|
@@ -137,7 +137,8 @@ export class Mediator {
|
|
|
137
137
|
if (!sourceAccount)
|
|
138
138
|
throw new Error('Mediator account doesn\'t exist on the ledger')
|
|
139
139
|
//calculate fees reserve + account entries reserve
|
|
140
|
-
const
|
|
140
|
+
const subentries = sourceAccount.signers.length - 1 + [this.sellingAsset, this.buyingAsset].filter(a => !a.isNative()).length
|
|
141
|
+
const feesReserve = defaultFeesReserve + 0.5 * subentries
|
|
141
142
|
const ops = []
|
|
142
143
|
//create new random keypair for the trade
|
|
143
144
|
this.mediator = Keypair.random()
|
|
@@ -195,7 +196,7 @@ export class Mediator {
|
|
|
195
196
|
source: this.mediatorAddress,
|
|
196
197
|
inflationDest: this.source, //store source account to the inflation dest
|
|
197
198
|
homeDomain: 'mediator.stellar.broker',
|
|
198
|
-
masterWeight: Math.max(thresholds.high_threshold, thresholds.med_threshold), //own signer always has the highest weight
|
|
199
|
+
masterWeight: Math.max(1, thresholds.high_threshold, thresholds.med_threshold), //own signer always has the highest weight
|
|
199
200
|
highThreshold: thresholds.high_threshold,
|
|
200
201
|
medThreshold: thresholds.med_threshold,
|
|
201
202
|
lowThreshold: thresholds.low_threshold,
|
|
@@ -208,7 +209,7 @@ export class Mediator {
|
|
|
208
209
|
for (let i = 1; i < signers.length; i++) {
|
|
209
210
|
ops.push(Operation.setOptions({
|
|
210
211
|
source: this.mediatorAddress,
|
|
211
|
-
signer: {
|
|
212
|
+
signer: { //cope signers and weights
|
|
212
213
|
ed25519PublicKey: signers[i].key,
|
|
213
214
|
weight: Math.max(1, signers[i].weight)
|
|
214
215
|
}
|
|
@@ -310,7 +311,7 @@ export class Mediator {
|
|
|
310
311
|
fee: '1000000',
|
|
311
312
|
networkPassphrase: Networks.PUBLIC
|
|
312
313
|
})
|
|
313
|
-
builder.setTimeout(
|
|
314
|
+
builder.setTimeout(TimeoutInfinite)
|
|
314
315
|
//add memo if needed
|
|
315
316
|
if (memo) {
|
|
316
317
|
builder.addMemo(Memo.text(memo))
|