@koralabs/kora-labs-common 4.2.0 → 4.2.2

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": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -14,6 +14,7 @@ export declare const subHandleSettingsDatumSchema: {
14
14
  font: string;
15
15
  text_ribbon_gradient: string;
16
16
  };
17
+ '[4]': string;
17
18
  };
18
19
  '[1]': {
19
20
  '[0]': string;
@@ -30,6 +31,7 @@ export declare const subHandleSettingsDatumSchema: {
30
31
  font: string;
31
32
  text_ribbon_gradient: string;
32
33
  };
34
+ '[4]': string;
33
35
  };
34
36
  '[2]': string;
35
37
  '[3]': string;
@@ -15,7 +15,8 @@ const subHandleSettings = {
15
15
  qr_image: 'string',
16
16
  font: 'string',
17
17
  text_ribbon_gradient: 'string'
18
- }
18
+ },
19
+ '[4]': 'bool'
19
20
  };
20
21
  exports.subHandleSettingsDatumSchema = {
21
22
  '[0]': subHandleSettings,
package/utils/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare const asyncForEach: <T, U>(array: T[], callback: (item: T, index:
7
7
  export declare const isNumeric: (n: string) => boolean;
8
8
  export declare const isNullEmptyOrUndefined: (value: any) => boolean;
9
9
  export declare const isAlphaNumeric: (str: string) => boolean;
10
- export declare const getDateFromSlot: (currentSlot: number) => number;
11
- export declare const getSlotNumberFromDate: (date: Date) => number;
10
+ export declare const getDateFromSlot: (currentSlot: number, network?: string) => number;
11
+ export declare const getSlotNumberFromDate: (date: Date, network?: string) => number;
12
12
  export { DefaultTextFormat as KeyType, encodeJsonToDatum, decodeCborToJson } from './cbor';
13
13
  export * from './crypto';
package/utils/index.js CHANGED
@@ -64,27 +64,25 @@ const isAlphaNumeric = (str) => {
64
64
  return /^[a-zA-Z0-9]+$/.test(str);
65
65
  };
66
66
  exports.isAlphaNumeric = isAlphaNumeric;
67
- const getDateFromSlot = (currentSlot) => {
68
- var _a, _b;
67
+ const getDateFromSlot = (currentSlot, network) => {
68
+ var _a;
69
69
  // TODO: Make this work for all networks
70
70
  //console.log(`preview slot date = ${new Date(currentSlot * 1000)}`)
71
- if (((_a = process.env.NETWORK) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'preview') {
71
+ const currentNetwork = network ? network.toLowerCase() : (_a = process.env.NETWORK) === null || _a === void 0 ? void 0 : _a.toLowerCase();
72
+ if (currentNetwork == 'preview')
72
73
  return (1666656000 + currentSlot) * 1000;
73
- }
74
- if (((_b = process.env.NETWORK) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'preprod') {
74
+ if (currentNetwork == 'preprod')
75
75
  return (1654041600 + currentSlot) * 1000;
76
- }
77
76
  return (1596491091 + (currentSlot - 4924800)) * 1000;
78
77
  };
79
78
  exports.getDateFromSlot = getDateFromSlot;
80
- const getSlotNumberFromDate = (date) => {
81
- var _a, _b;
82
- if (((_a = process.env.NETWORK) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'preview') {
79
+ const getSlotNumberFromDate = (date, network) => {
80
+ var _a;
81
+ const currentNetwork = network ? network.toLowerCase() : (_a = process.env.NETWORK) === null || _a === void 0 ? void 0 : _a.toLowerCase();
82
+ if (currentNetwork == 'preview')
83
83
  return Math.floor(date.getTime() / 1000) - 1666656000;
84
- }
85
- if (((_b = process.env.NETWORK) === null || _b === void 0 ? void 0 : _b.toLowerCase()) == 'preprod') {
84
+ if (currentNetwork == 'preprod')
86
85
  return Math.floor(date.getTime() / 1000) - 1654041600;
87
- }
88
86
  // Ignore parens to show intent
89
87
  // prettier-ignore
90
88
  return (Math.floor(date.getTime() / 1000) - 1596491091) + 4924800;