@bitgo/public-types 6.78.0 → 6.78.1

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,4 +1,5 @@
1
1
  import * as t from "io-ts";
2
+ export declare const CantonAmount: t.Type<string | number, string | number, unknown>;
2
3
  export declare const CantonTransferAcknowledgeIntent: t.IntersectionC<[t.IntersectionC<[t.TypeC<{
3
4
  intentType: t.KeyofC<{
4
5
  payment: t.LiteralC<"payment">;
@@ -89,7 +90,7 @@ export declare const CantonTransferAcknowledgeIntent: t.IntersectionC<[t.Interse
89
90
  contractId: t.StringC;
90
91
  senderPartyId: t.StringC;
91
92
  updateId: t.StringC;
92
- amount: t.UnionC<[t.StringC, t.NumberC]>;
93
+ amount: t.Type<string | number, string | number, unknown>;
93
94
  expiry: t.NumberC;
94
95
  }>, t.PartialC<{
95
96
  memoId: t.StringC;
@@ -23,10 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CantonTransferAcknowledgeIntent = void 0;
26
+ exports.CantonTransferAcknowledgeIntent = exports.CantonAmount = void 0;
27
27
  const t = __importStar(require("io-ts"));
28
28
  const baseIntent_1 = require("./baseIntent");
29
29
  const intentType_1 = require("./intentType");
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);
30
38
  exports.CantonTransferAcknowledgeIntent = t.intersection([
31
39
  baseIntent_1.BaseIntent,
32
40
  t.type({
@@ -34,7 +42,7 @@ exports.CantonTransferAcknowledgeIntent = t.intersection([
34
42
  contractId: t.string,
35
43
  senderPartyId: t.string,
36
44
  updateId: t.string,
37
- amount: t.union([t.string, t.number]),
45
+ amount: exports.CantonAmount,
38
46
  expiry: t.number,
39
47
  }),
40
48
  t.partial({
@@ -1 +1 @@
1
- {"version":3,"file":"cantonTransferAcknowledgeIntent.js","sourceRoot":"","sources":["../../../../../src/schema/transactionRequest/intents/cantonTransferAcknowledgeIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAA0C;AAC1C,6CAA2C;AAmB9B,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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QACrC,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;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"}
@@ -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.UnionC<[t.StringC, t.NumberC]>;
2904
+ amount: t.Type<string | number, string | number, unknown>;
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.UnionC<[t.StringC, t.NumberC]>;
3002
+ amount: t.Type<string | number, string | number, unknown>;
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.UnionC<[t.StringC, t.NumberC]>;
20338
+ amount: t.Type<string | number, string | number, unknown>;
20339
20339
  expiry: t.NumberC;
20340
20340
  }>, t.PartialC<{
20341
20341
  memoId: t.StringC;
@@ -0,0 +1,3 @@
1
+ module.exports = (E) => ({
2
+ CantonAmount: () => E.right({ type: "string" }),
3
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo/public-types",
3
- "version": "6.78.0",
3
+ "version": "6.78.1",
4
4
  "description": "Collection of types exposed externally as part of the BitGo public API",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -11,9 +11,11 @@
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",
14
15
  "files": [
15
16
  "dist/src/",
16
- "src"
17
+ "src",
18
+ "openapi-gen.config.js"
17
19
  ],
18
20
  "scripts": {
19
21
  "build": "tsc --build --incremental --verbose .",
@@ -2,6 +2,30 @@ import * as t from "io-ts";
2
2
  import { BaseIntent } from "./baseIntent";
3
3
  import { intentTypes } from "./intentType";
4
4
 
5
+ const CANTON_DECIMAL_AMOUNT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
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);
12
+ }
13
+
14
+ /**
15
+ * Exact Canton decimal-string amount codec.
16
+ * Safe integer numbers remain accepted for legacy in-process callers; wire/API amounts stay strings.
17
+ */
18
+ export const CantonAmount = new t.Type<
19
+ string | number,
20
+ string | number,
21
+ unknown
22
+ >(
23
+ "CantonAmount",
24
+ isCantonAmount,
25
+ (value, context) =>
26
+ isCantonAmount(value) ? t.success(value) : t.failure(value, context),
27
+ t.identity,
28
+ );
5
29
  /**
6
30
  * @title Canton Transfer Acknowledge Intent
7
31
  *
@@ -14,7 +38,7 @@ import { intentTypes } from "./intentType";
14
38
  * @param {String} contractId - The contract id that needs to be acted on by the receiver
15
39
  * @param {String} senderPartyId - The address (partyId) of the sender
16
40
  * @param {String} updateId - The transaction id of the deposit
17
- * @param {String} amount - The exact deposit amount as a decimal string; numbers remain accepted for compatibility
41
+ * @param {String} amount - The exact deposit amount as a decimal string
18
42
  * @param {Number} expiry - The expiry epoch
19
43
  * @param {String} [memoId] - The optional memoId
20
44
  * @param {String} [token] - The optional token
@@ -26,7 +50,7 @@ export const CantonTransferAcknowledgeIntent = t.intersection([
26
50
  contractId: t.string,
27
51
  senderPartyId: t.string,
28
52
  updateId: t.string,
29
- amount: t.union([t.string, t.number]),
53
+ amount: CantonAmount,
30
54
  expiry: t.number,
31
55
  }),
32
56
  t.partial({