@agoric/client-utils 0.1.1-dev-ff8c142.0 → 0.1.1-dev-3852448.0
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 +7 -7
- package/src/sync-tools.js +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/client-utils",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-3852448.0+3852448",
|
|
4
4
|
"description": "Utilities for building Agoric clients",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"ts-blank-space": "^0.4.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agoric/casting": "0.4.3-dev-
|
|
31
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
32
|
-
"@agoric/internal": "0.3.3-dev-
|
|
33
|
-
"@agoric/smart-wallet": "0.5.4-dev-
|
|
34
|
-
"@agoric/vats": "0.15.2-dev-
|
|
30
|
+
"@agoric/casting": "0.4.3-dev-3852448.0+3852448",
|
|
31
|
+
"@agoric/ertp": "0.16.3-dev-3852448.0+3852448",
|
|
32
|
+
"@agoric/internal": "0.3.3-dev-3852448.0+3852448",
|
|
33
|
+
"@agoric/smart-wallet": "0.5.4-dev-3852448.0+3852448",
|
|
34
|
+
"@agoric/vats": "0.15.2-dev-3852448.0+3852448",
|
|
35
35
|
"@cosmjs/stargate": "^0.32.3",
|
|
36
36
|
"@cosmjs/tendermint-rpc": "^0.32.3",
|
|
37
37
|
"@endo/common": "^1.2.7",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
],
|
|
59
59
|
"timeout": "20m"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "3852448223cc9c62413e8ee5414edb50416cca32"
|
|
62
62
|
}
|
package/src/sync-tools.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - operation: query dest account's balance
|
|
10
10
|
* - condition: dest account has a balance >= sent token
|
|
11
11
|
* - Making sure an offer resulted successfully
|
|
12
|
+
* - Making sure an offer was exited successfully
|
|
12
13
|
*
|
|
13
14
|
*/
|
|
14
15
|
|
|
@@ -287,3 +288,40 @@ export const waitUntilInvitationReceived = (addr, io, options) => {
|
|
|
287
288
|
{ reusePromise: true, setTimeout, ...resolvedOptions },
|
|
288
289
|
);
|
|
289
290
|
};
|
|
291
|
+
|
|
292
|
+
/// ////////// Making sure an offer was exited successfully /////////////
|
|
293
|
+
|
|
294
|
+
const makeQueryWalletCurrent = follow => (/** @type {string} */ addr) =>
|
|
295
|
+
follow('-lF', `:published.wallet.${addr}.current`);
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @param {object} update
|
|
299
|
+
* @param {string} offerId
|
|
300
|
+
* @returns {boolean}
|
|
301
|
+
*/
|
|
302
|
+
const checkLiveOffers = (update, offerId) => {
|
|
303
|
+
const liveOffers = update.liveOffers;
|
|
304
|
+
if (!liveOffers) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return !liveOffers.some(element => element.includes(offerId));
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @param {string} addr
|
|
312
|
+
* @param {string} offerId
|
|
313
|
+
* @param {{ follow: () => object, log: typeof console.log, setTimeout: typeof global.setTimeout}} io
|
|
314
|
+
* @param {WaitUntilOptions} options
|
|
315
|
+
*/
|
|
316
|
+
export const waitUntilOfferExited = async (addr, offerId, io, options) => {
|
|
317
|
+
const { follow, setTimeout } = io;
|
|
318
|
+
const queryWalletCurrent = makeQueryWalletCurrent(follow);
|
|
319
|
+
const { errorMessage, ...resolvedOptions } = overrideDefaultOptions(options);
|
|
320
|
+
|
|
321
|
+
return retryUntilCondition(
|
|
322
|
+
async () => queryWalletCurrent(addr),
|
|
323
|
+
update => checkLiveOffers(update, offerId),
|
|
324
|
+
errorMessage,
|
|
325
|
+
{ setTimeout, ...resolvedOptions },
|
|
326
|
+
);
|
|
327
|
+
};
|