@agoric/client-utils 0.2.0-upgrade-18a-dev-4ee0508.0 → 0.2.0-upgrade-19-dev-6f73842.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/client-utils",
3
- "version": "0.2.0-upgrade-18a-dev-4ee0508.0+4ee0508",
3
+ "version": "0.2.0-upgrade-19-dev-6f73842.0+6f73842",
4
4
  "description": "Utilities for building Agoric clients",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -27,19 +27,19 @@
27
27
  "ts-blank-space": "^0.4.4"
28
28
  },
29
29
  "dependencies": {
30
- "@agoric/casting": "0.4.3-upgrade-18a-dev-4ee0508.0+4ee0508",
31
- "@agoric/ertp": "0.16.3-upgrade-18a-dev-4ee0508.0+4ee0508",
32
- "@agoric/internal": "0.4.0-upgrade-18a-dev-4ee0508.0+4ee0508",
33
- "@agoric/smart-wallet": "0.5.4-upgrade-18a-dev-4ee0508.0+4ee0508",
34
- "@agoric/vats": "0.16.0-upgrade-18a-dev-4ee0508.0+4ee0508",
30
+ "@agoric/casting": "0.4.3-upgrade-19-dev-6f73842.0+6f73842",
31
+ "@agoric/ertp": "0.16.3-upgrade-19-dev-6f73842.0+6f73842",
32
+ "@agoric/internal": "0.4.0-upgrade-19-dev-6f73842.0+6f73842",
33
+ "@agoric/smart-wallet": "0.5.4-upgrade-19-dev-6f73842.0+6f73842",
34
+ "@agoric/vats": "0.16.0-upgrade-19-dev-6f73842.0+6f73842",
35
35
  "@cosmjs/stargate": "^0.32.3",
36
36
  "@cosmjs/tendermint-rpc": "^0.32.3",
37
- "@endo/common": "^1.2.8",
38
- "@endo/errors": "^1.2.8",
39
- "@endo/marshal": "^1.6.2",
40
- "@endo/pass-style": "^1.4.7",
41
- "@endo/patterns": "^1.4.7",
42
- "@endo/promise-kit": "^1.1.8"
37
+ "@endo/common": "^1.2.9",
38
+ "@endo/errors": "^1.2.9",
39
+ "@endo/marshal": "^1.6.3",
40
+ "@endo/pass-style": "^1.4.8",
41
+ "@endo/patterns": "^1.4.8",
42
+ "@endo/promise-kit": "^1.1.9"
43
43
  },
44
44
  "ava": {
45
45
  "extensions": {
@@ -58,5 +58,5 @@
58
58
  ],
59
59
  "timeout": "20m"
60
60
  },
61
- "gitHead": "4ee05088e5ada989a866a11ff65838d395505ce6"
61
+ "gitHead": "6f73842af496b44e61731f3beaf81767d8ea08dd"
62
62
  }
@@ -0,0 +1,50 @@
1
+ const { freeze } = Object;
2
+
3
+ /**
4
+ * @typedef {object} IntervalIO
5
+ * @property {typeof setTimeout} setTimeout
6
+ * @property {typeof clearTimeout} clearTimeout
7
+ * @property {typeof Date.now} now
8
+ */
9
+
10
+ /**
11
+ * Creates an async iterable that emits values at specified intervals.
12
+ * @param {number} intervalMs - The interval duration in milliseconds.
13
+ * @param {IntervalIO} io
14
+ * @returns {{
15
+ * [Symbol.asyncIterator]: () => AsyncGenerator<number, void, void>
16
+ * }}
17
+ */
18
+ export const makeIntervalIterable = (
19
+ intervalMs,
20
+ { setTimeout, clearTimeout, now },
21
+ ) => {
22
+ const self = freeze({
23
+ /**
24
+ * The async generator implementation.
25
+ * @returns {AsyncGenerator<number, void, void>}
26
+ */
27
+ async *[Symbol.asyncIterator]() {
28
+ let timeoutId;
29
+ /** @type {undefined | ((x: number) => void) } */
30
+ let resolveNext;
31
+
32
+ await null;
33
+ try {
34
+ for (;;) {
35
+ timeoutId = setTimeout(() => {
36
+ // Promise.withResovers() would obviate this check
37
+ if (resolveNext) {
38
+ resolveNext(now());
39
+ }
40
+ }, intervalMs);
41
+ yield await new Promise(resolve => (resolveNext = resolve));
42
+ }
43
+ } finally {
44
+ // Ensure cleanup on completion
45
+ clearTimeout(timeoutId);
46
+ }
47
+ },
48
+ });
49
+ return self;
50
+ };
@@ -4,6 +4,7 @@ import { makeStargateClient } from './rpc.js';
4
4
  import { makeAgoricNames, makeVstorageKit } from './vstorage-kit.js';
5
5
 
6
6
  /**
7
+ * @import {EReturn} from '@endo/far';
7
8
  * @import {Amount, Brand} from '@agoric/ertp/src/types.js'
8
9
  * @import {CurrentWalletRecord, UpdateRecord} from '@agoric/smart-wallet/src/smartWallet.js';
9
10
  * @import {MinimalNetworkConfig} from './network-config.js';
@@ -110,4 +111,4 @@ export const makeSmartWalletKit = async ({ fetch, delay }, networkConfig) => {
110
111
  pollOffer,
111
112
  };
112
113
  };
113
- /** @typedef {Awaited<ReturnType<typeof makeSmartWalletKit>>} SmartWalletKit */
114
+ /** @typedef {EReturn<typeof makeSmartWalletKit>} SmartWalletKit */
package/src/types.d.ts CHANGED
@@ -10,6 +10,7 @@ import type {
10
10
  CurrentWalletRecord,
11
11
  UpdateRecord,
12
12
  } from '@agoric/smart-wallet/src/smartWallet.js';
13
+ import type { ContractRecord, PoolMetrics } from '@agoric/fast-usdc';
13
14
 
14
15
  // For static string key types. String template matching has to be in the ternary below.
15
16
  type PublishedTypeMap = {
@@ -34,4 +35,12 @@ export type TypedPublished<T extends string> = T extends keyof PublishedTypeMap
34
35
  ? OutcomeRecord
35
36
  : T extends `vaultFactory.managers.manager${number}.metrics`
36
37
  ? VaultManagerMetrics
37
- : unknown;
38
+ : T extends 'agoricNames.instance'
39
+ ? Array<[string, Instance]>
40
+ : T extends 'agoricNames.brand'
41
+ ? Array<[string, Brand]>
42
+ : T extends 'fastUsdc'
43
+ ? ContractRecord
44
+ : T extends 'fastUsdc.poolMetrics'
45
+ ? PoolMetrics
46
+ : unknown;