@koralabs/kora-labs-common 6.13.3 → 6.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "6.13.3",
3
+ "version": "6.13.4",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@aiken-lang/merkle-patricia-forestry": "^1.2.0",
41
41
  "@aws-sdk/client-dynamodb": "^3.549.0",
42
42
  "@aws-sdk/lib-dynamodb": "^3.549.0",
43
- "@cardano-sdk/core": "^0.46.15",
43
+ "@cardano-sdk/core": "^0.47.0",
44
44
  "@cardano-sdk/crypto": "^0.4.7",
45
45
  "@emurgo/cardano-message-signing-nodejs": "^1.1.0",
46
46
  "@types/jest": "^30.0.0",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@aiken-lang/merkle-patricia-forestry": "^1.2.0",
75
- "@cardano-sdk/core": "^0.46.12",
75
+ "@cardano-sdk/core": "^0.46.12 || ^0.47.0",
76
76
  "@cardano-sdk/crypto": "^0.4.5",
77
77
  "bip39": "^3.1.0",
78
78
  "@emurgo/cardano-message-signing-nodejs": "^1.1.0"
@@ -1,4 +1,3 @@
1
- import * as cbor from 'cbor';
2
1
  export { designerSchema } from './schema/designer';
3
2
  export { handleDatumSchema } from './schema/handleData';
4
3
  export { marketplaceDatumSchema } from './schema/marketplaceDatum';
@@ -53,7 +52,6 @@ export declare class DupeKey extends JsonToDatumObject {
53
52
  constructor(key: string);
54
53
  }
55
54
  export declare const encodeJsonToDatum: (json: any, options?: EncodeOptions) => Promise<string>;
56
- export declare const constrToTagged: (index: number, fields: unknown) => cbor.Tagged;
57
55
  export declare const decodeCborToJson: ({ cborString, schema, defaultKeyType, forJson }: {
58
56
  cborString: string;
59
57
  schema?: any;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.decodeCborToJson = exports.constrToTagged = exports.encodeJsonToDatum = exports.DupeKey = exports.DefaultTextFormat = exports.subHandleSettingsDatumSchema = exports.socialsSchema = exports.portalSchema = exports.marketplaceDatumSchema = exports.handleDatumSchema = exports.designerSchema = void 0;
36
+ exports.decodeCborToJson = exports.encodeJsonToDatum = exports.DupeKey = exports.DefaultTextFormat = exports.subHandleSettingsDatumSchema = exports.socialsSchema = exports.portalSchema = exports.marketplaceDatumSchema = exports.handleDatumSchema = exports.designerSchema = void 0;
37
37
  const boolean_1 = require("boolean");
38
38
  const cbor = __importStar(require("cbor"));
39
39
  var designer_1 = require("./schema/designer");
@@ -96,6 +96,7 @@ class JsonToDatumObject {
96
96
  else if (typeof this.json === 'object') {
97
97
  if (this.json !== null) {
98
98
  const fieldsMap = new Map();
99
+ let tag = null;
99
100
  const keys = this.json instanceof Map ? this.json.keys() : Object.keys(this.json);
100
101
  for (const key of keys) {
101
102
  if (key instanceof DupeKey) {
@@ -103,8 +104,11 @@ class JsonToDatumObject {
103
104
  }
104
105
  else {
105
106
  const split_key = parseInt((_a = key.split('_').at(1)) !== null && _a !== void 0 ? _a : '');
106
- if (key.startsWith('constructor_') && Number.isInteger(split_key) && split_key >= 0) {
107
- return encoder.pushAny((0, exports.constrToTagged)(split_key, this.json[key]));
107
+ if (key.startsWith('constructor_') &&
108
+ !isNaN(split_key) &&
109
+ [0, 1, 2, 3].includes(split_key)) {
110
+ tag = 121 + split_key;
111
+ return encoder.pushAny(new cbor.Tagged(tag, this.json[key]));
108
112
  }
109
113
  const bufferedKey = this.getFormattedKey(key);
110
114
  fieldsMap.set(bufferedKey, this.json[key]);
@@ -389,26 +393,15 @@ const decodeObject = ({ val, constr = null, schema = {}, defaultKeyType = Defaul
389
393
  return val;
390
394
  }
391
395
  };
392
- // Plutus Constr tag scheme (CIP-0005 / plutus-core): 0-6 -> 121-127, 7-127 -> 1280-1400,
393
- // anything else -> tag 102 wrapping [index, fields]. Every index must round-trip; an
394
- // unrecognized `constructor_N` key would otherwise be encoded as a text-keyed map.
395
- const constrToTagged = (index, fields) => {
396
- if (index <= 6)
397
- return new cbor.Tagged(121 + index, fields);
398
- if (index <= 127)
399
- return new cbor.Tagged(1280 + index - 7, fields);
400
- return new cbor.Tagged(102, [index, fields]);
401
- };
402
- exports.constrToTagged = constrToTagged;
403
- const CONSTR_DECODE_TAGS = {
404
- 102: ([index, fields]) => ({ [`constructor_${index}`]: fields })
405
- };
406
- for (let index = 0; index <= 127; index++) {
407
- CONSTR_DECODE_TAGS[index <= 6 ? 121 + index : 1280 + index - 7] = (val) => ({ [`constructor_${index}`]: val });
408
- }
409
396
  const decodeCborToJson = ({ cborString, schema, defaultKeyType, forJson }) => {
410
397
  const decoded = cbor.decodeAllSync(Buffer.from(cborString, 'hex'), {
411
- tags: CONSTR_DECODE_TAGS
398
+ tags: {
399
+ 121: (val) => ({ [`constructor_0`]: val }),
400
+ 122: (val) => ({ [`constructor_1`]: val }),
401
+ 123: (val) => ({ [`constructor_2`]: val }),
402
+ 124: (val) => ({ [`constructor_3`]: val }),
403
+ 125: (val) => ({ [`constructor_4`]: val })
404
+ }
412
405
  });
413
406
  let [data] = decoded;
414
407
  data = decodeObject({ val: data, schema, defaultKeyType, forJson });