@bitgo/public-types 6.78.3 → 6.78.4

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.
@@ -1,5 +1,8 @@
1
1
  import * as t from "io-ts";
2
- export declare const CantonAmount: t.Type<string | number, string | number, unknown>;
2
+ export interface CantonAmountBrand {
3
+ readonly CantonAmount: unique symbol;
4
+ }
5
+ export declare const CantonAmount: t.BrandC<t.StringC, CantonAmountBrand>;
3
6
  export declare const CantonTransferAcknowledgeIntent: t.IntersectionC<[t.IntersectionC<[t.TypeC<{
4
7
  intentType: t.KeyofC<{
5
8
  payment: t.LiteralC<"payment">;
@@ -90,7 +93,7 @@ export declare const CantonTransferAcknowledgeIntent: t.IntersectionC<[t.Interse
90
93
  contractId: t.StringC;
91
94
  senderPartyId: t.StringC;
92
95
  updateId: t.StringC;
93
- amount: t.Type<string | number, string | number, unknown>;
96
+ amount: t.BrandC<t.StringC, CantonAmountBrand>;
94
97
  expiry: t.NumberC;
95
98
  }>, t.PartialC<{
96
99
  memoId: t.StringC;
@@ -28,13 +28,7 @@ const t = __importStar(require("io-ts"));
28
28
  const baseIntent_1 = require("./baseIntent");
29
29
  const intentType_1 = require("./intentType");
30
30
  const CANTON_DECIMAL_AMOUNT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
31
- function isCantonAmount(value) {
32
- if (typeof value === "string") {
33
- return CANTON_DECIMAL_AMOUNT.test(value);
34
- }
35
- return typeof value === "number" && Number.isSafeInteger(value);
36
- }
37
- exports.CantonAmount = new t.Type("CantonAmount", isCantonAmount, (value, context) => isCantonAmount(value) ? t.success(value) : t.failure(value, context), t.identity);
31
+ exports.CantonAmount = t.brand(t.string, ((value) => CANTON_DECIMAL_AMOUNT.test(value)), "CantonAmount");
38
32
  exports.CantonTransferAcknowledgeIntent = t.intersection([
39
33
  baseIntent_1.BaseIntent,
40
34
  t.type({
@@ -1 +1 @@
1
- {"version":3,"file":"cantonTransferAcknowledgeIntent.js","sourceRoot":"","sources":["../../../../../src/schema/transactionRequest/intents/cantonTransferAcknowledgeIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAA0C;AAC1C,6CAA2C;AAE3C,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAE/D,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAMY,QAAA,YAAY,GAAG,IAAI,CAAC,CAAC,IAAI,CAKpC,cAAc,EACd,cAAc,EACd,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CACjB,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EACtE,CAAC,CAAC,QAAQ,CACX,CAAC;AAkBW,QAAA,+BAA+B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5D,uBAAU;IACV,CAAC,CAAC,IAAI,CAAC;QACL,UAAU,EAAE,wBAAW,CAAC,mBAAmB;QAC3C,UAAU,EAAE,CAAC,CAAC,MAAM;QACpB,aAAa,EAAE,CAAC,CAAC,MAAM;QACvB,QAAQ,EAAE,CAAC,CAAC,MAAM;QAClB,MAAM,EAAE,oBAAY;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QACR,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,KAAK,EAAE,CAAC,CAAC,MAAM;KAChB,CAAC;CACH,CAAC,CAAC"}
1
+ {"version":3,"file":"cantonTransferAcknowledgeIntent.js","sourceRoot":"","sources":["../../../../../src/schema/transactionRequest/intents/cantonTransferAcknowledgeIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAA0C;AAC1C,6CAA2C;AAE3C,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAUlD,QAAA,YAAY,GAAG,CAAC,CAAC,KAAK,CACjC,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,KAAa,EAAiD,EAAE,CAChE,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAEe,EAClD,cAAc,CACf,CAAC;AAkBW,QAAA,+BAA+B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5D,uBAAU;IACV,CAAC,CAAC,IAAI,CAAC;QACL,UAAU,EAAE,wBAAW,CAAC,mBAAmB;QAC3C,UAAU,EAAE,CAAC,CAAC,MAAM;QACpB,aAAa,EAAE,CAAC,CAAC,MAAM;QACvB,QAAQ,EAAE,CAAC,CAAC,MAAM;QAClB,MAAM,EAAE,oBAAY;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QACR,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,KAAK,EAAE,CAAC,CAAC,MAAM;KAChB,CAAC;CACH,CAAC,CAAC"}
@@ -2901,7 +2901,7 @@ export declare const TransactionIntent: t.UnionC<[t.IntersectionC<[t.Intersectio
2901
2901
  contractId: t.StringC;
2902
2902
  senderPartyId: t.StringC;
2903
2903
  updateId: t.StringC;
2904
- amount: t.Type<string | number, string | number, unknown>;
2904
+ amount: t.BrandC<t.StringC, import("./cantonTransferAcknowledgeIntent").CantonAmountBrand>;
2905
2905
  expiry: t.NumberC;
2906
2906
  }>, t.PartialC<{
2907
2907
  memoId: t.StringC;
@@ -2999,7 +2999,7 @@ export declare const TransactionRequestLite: t.IntersectionC<[t.IntersectionC<[t
2999
2999
  contractId: t.StringC;
3000
3000
  senderPartyId: t.StringC;
3001
3001
  updateId: t.StringC;
3002
- amount: t.Type<string | number, string | number, unknown>;
3002
+ amount: t.BrandC<t.StringC, import(".").CantonAmountBrand>;
3003
3003
  expiry: t.NumberC;
3004
3004
  }>, t.PartialC<{
3005
3005
  memoId: t.StringC;
@@ -20335,7 +20335,7 @@ export declare const TransactionRequest: t.UnionC<[t.IntersectionC<[t.Intersecti
20335
20335
  contractId: t.StringC;
20336
20336
  senderPartyId: t.StringC;
20337
20337
  updateId: t.StringC;
20338
- amount: t.Type<string | number, string | number, unknown>;
20338
+ amount: t.BrandC<t.StringC, import(".").CantonAmountBrand>;
20339
20339
  expiry: t.NumberC;
20340
20340
  }>, t.PartialC<{
20341
20341
  memoId: t.StringC;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo/public-types",
3
- "version": "6.78.3",
3
+ "version": "6.78.4",
4
4
  "description": "Collection of types exposed externally as part of the BitGo public API",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -11,14 +11,9 @@
11
11
  "main": "dist/src/index.js",
12
12
  "types": "dist/src/index.d.ts",
13
13
  "source": "src/index.ts",
14
- "customCodecFile": "openapi-gen.config.js",
15
- "openapi-generator": {
16
- "codec-file": "openapi-gen.config.js"
17
- },
18
14
  "files": [
19
15
  "dist/src/",
20
- "src",
21
- "openapi-gen.config.js"
16
+ "src"
22
17
  ],
23
18
  "scripts": {
24
19
  "build": "tsc --build --incremental --verbose .",
@@ -4,27 +4,21 @@ import { intentTypes } from "./intentType";
4
4
 
5
5
  const CANTON_DECIMAL_AMOUNT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
6
6
 
7
- function isCantonAmount(value: unknown): value is string | number {
8
- if (typeof value === "string") {
9
- return CANTON_DECIMAL_AMOUNT.test(value);
10
- }
11
- return typeof value === "number" && Number.isSafeInteger(value);
7
+ export interface CantonAmountBrand {
8
+ readonly CantonAmount: unique symbol;
12
9
  }
13
10
 
14
11
  /**
15
12
  * Exact Canton decimal-string amount codec.
16
- * Safe integer numbers remain accepted for legacy in-process callers; wire/API amounts stay strings.
13
+ * API amounts remain strings so the OpenAPI schema stays backward compatible.
17
14
  */
18
- export const CantonAmount = new t.Type<
19
- string | number,
20
- string | number,
21
- unknown
22
- >(
15
+ export const CantonAmount = t.brand(
16
+ t.string,
17
+ ((value: string): value is t.Branded<string, CantonAmountBrand> =>
18
+ CANTON_DECIMAL_AMOUNT.test(value)) as (
19
+ value: string,
20
+ ) => value is t.Branded<string, CantonAmountBrand>,
23
21
  "CantonAmount",
24
- isCantonAmount,
25
- (value, context) =>
26
- isCantonAmount(value) ? t.success(value) : t.failure(value, context),
27
- t.identity,
28
22
  );
29
23
  /**
30
24
  * @title Canton Transfer Acknowledge Intent
@@ -1,3 +0,0 @@
1
- module.exports = (E) => ({
2
- CantonAmount: () => E.right({ type: "string" }),
3
- });