@agoric/portfolio-api 0.1.1-dev-9fca75b.0.9fca75b → 0.1.1-dev-192500d.0.192500d

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/portfolio-api",
3
- "version": "0.1.1-dev-9fca75b.0.9fca75b",
3
+ "version": "0.1.1-dev-192500d.0.192500d",
4
4
  "description": "API for Portfolio management",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,11 +27,11 @@
27
27
  "generate:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts"
28
28
  },
29
29
  "dependencies": {
30
- "@agoric/orchestration": "0.1.1-dev-9fca75b.0.9fca75b",
30
+ "@agoric/orchestration": "0.1.1-dev-192500d.0.192500d",
31
31
  "@endo/common": "^1.2.13"
32
32
  },
33
33
  "devDependencies": {
34
- "@agoric/internal": "0.3.3-dev-9fca75b.0.9fca75b",
34
+ "@agoric/internal": "0.3.3-dev-192500d.0.192500d",
35
35
  "@types/js-yaml": "^4",
36
36
  "ajv": "^6.12.6",
37
37
  "ava": "^5.3.0",
@@ -64,5 +64,5 @@
64
64
  "engines": {
65
65
  "node": "^20.9 || ^22.11"
66
66
  },
67
- "gitHead": "9fca75b18acc53a00245b7377d787b93107f02b3"
67
+ "gitHead": "192500d7a565f6b43c468a28996d24375e4ff5c7"
68
68
  }
@@ -2,8 +2,13 @@
2
2
  * Mnemonic IDs for supported financial instruments in which a portfolio can use
3
3
  * assets to take a position.
4
4
  *
5
- * Treat these identifers as opaque strings. There are separate data structures
6
- * to map them to functional interfaces for interoperation.
5
+ * These identifiers are to be treated as opaque strings, but must not start
6
+ * with punctuation that could result in them being misinterpreted as any other
7
+ * kind of {@link AssetPlaceRef} (e.g., a `<`-prefixed {@link SeatKeyword} or
8
+ * `@`-prefixed {@link InterChainAccountRef}), and in fact must start with an
9
+ * ASCII letter unless the implementation of {@link isInstrumentId} is relaxed.
10
+ * There are separate data structures to map them to functional interfaces for
11
+ * interoperation.
7
12
  */
8
13
  export type InstrumentId = (typeof InstrumentId)[keyof typeof InstrumentId];
9
14
  export namespace InstrumentId {
@@ -1 +1 @@
1
- {"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["instruments.js"],"names":[],"mappings":";;;;;;;2BAOU,CAAC,OAAO,YAAY,EAAE,MAAM,OAAO,YAAY,CAAC"}
1
+ {"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["instruments.js"],"names":[],"mappings":";;;;;;;;;;;;2BAYU,CAAC,OAAO,YAAY,EAAE,MAAM,OAAO,YAAY,CAAC"}
@@ -2,8 +2,13 @@
2
2
  * Mnemonic IDs for supported financial instruments in which a portfolio can use
3
3
  * assets to take a position.
4
4
  *
5
- * Treat these identifers as opaque strings. There are separate data structures
6
- * to map them to functional interfaces for interoperation.
5
+ * These identifiers are to be treated as opaque strings, but must not start
6
+ * with punctuation that could result in them being misinterpreted as any other
7
+ * kind of {@link AssetPlaceRef} (e.g., a `<`-prefixed {@link SeatKeyword} or
8
+ * `@`-prefixed {@link InterChainAccountRef}), and in fact must start with an
9
+ * ASCII letter unless the implementation of {@link isInstrumentId} is relaxed.
10
+ * There are separate data structures to map them to functional interfaces for
11
+ * interoperation.
7
12
  *
8
13
  * @enum {(typeof InstrumentId)[keyof typeof InstrumentId]}
9
14
  */
package/src/main.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./constants.js";
2
2
  export * from "./instruments.js";
3
3
  export * from "./resolver.js";
4
+ export * from "./type-guards.js";
4
5
  export * from "./types-index.js";
5
6
  //# sourceMappingURL=main.d.ts.map
package/src/main.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './constants.js';
2
2
  export * from './instruments.js';
3
3
  export * from './resolver.js';
4
+ export * from './type-guards.js';
4
5
 
5
6
  // eslint-disable-next-line import/export -- just types
6
7
  export * from './types-index.js';
@@ -1,10 +1,18 @@
1
- import type { InterChainAccountRef, LocalChainAccountRef } from './types.js';
1
+ import type { InstrumentId } from './instruments.js';
2
+ import type { LocalChainAccountRef, InterChainAccountRef } from './types.js';
2
3
  /**
3
- * Does it match the pattern, without regard to supported chains.
4
+ * Without regard to supported chains, is the input plausibly a
5
+ * LocalChainAccountRef (i.e., does it start with `+`)?
4
6
  */
5
7
  export declare const isLocalChainAccountRef: (ref: string) => ref is LocalChainAccountRef;
6
8
  /**
7
- * Does it match the pattern, without regard to supported chains.
9
+ * Without regard to supported chains, is the input plausibly an
10
+ * InterChainAccountRef (i.e., does it start with `@`)?
8
11
  */
9
12
  export declare const isInterChainAccountRef: (ref: string) => ref is InterChainAccountRef;
13
+ /**
14
+ * Without regard to supported chains, is the input plausibly an InstrumentId
15
+ * (i.e., does it start with an ASCII letter)?
16
+ */
17
+ export declare const isInstrumentId: (ref: string) => ref is InstrumentId;
10
18
  //# sourceMappingURL=type-guards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC;AAGtD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC"}
1
+ {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,GAAG,IAAI,YAC5B,CAAC"}
@@ -1,7 +1,9 @@
1
- import type { InterChainAccountRef, LocalChainAccountRef } from './types.js';
1
+ import type { InstrumentId } from './instruments.js';
2
+ import type { LocalChainAccountRef, InterChainAccountRef } from './types.js';
2
3
 
3
4
  /**
4
- * Does it match the pattern, without regard to supported chains.
5
+ * Without regard to supported chains, is the input plausibly a
6
+ * LocalChainAccountRef (i.e., does it start with `+`)?
5
7
  */
6
8
  export const isLocalChainAccountRef = (
7
9
  ref: string,
@@ -9,9 +11,18 @@ export const isLocalChainAccountRef = (
9
11
  harden(isLocalChainAccountRef);
10
12
 
11
13
  /**
12
- * Does it match the pattern, without regard to supported chains.
14
+ * Without regard to supported chains, is the input plausibly an
15
+ * InterChainAccountRef (i.e., does it start with `@`)?
13
16
  */
14
17
  export const isInterChainAccountRef = (
15
18
  ref: string,
16
19
  ): ref is InterChainAccountRef => ref.startsWith('@');
17
20
  harden(isInterChainAccountRef);
21
+
22
+ /**
23
+ * Without regard to supported chains, is the input plausibly an InstrumentId
24
+ * (i.e., does it start with an ASCII letter)?
25
+ */
26
+ export const isInstrumentId = (ref: string): ref is InstrumentId =>
27
+ !!ref.match(/^[a-z]/i);
28
+ harden(isInstrumentId);