@koralabs/kora-labs-common 5.1.26 → 5.1.27

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.
@@ -20,3 +20,5 @@ export declare enum ERROR_TEXT {
20
20
  HANDLE_PAGE_AND_SLOT_NUMBER_INVALID = "'page' and 'slot_number' can't be used together"
21
21
  }
22
22
  export declare const HANDLES_PER_PAGE_MAX = 1000;
23
+ export declare const EMPTY = "|empty|";
24
+ export declare const TWELVE_HOURS_IN_SLOTS = 43200;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a, _b;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.HANDLES_PER_PAGE_MAX = exports.ERROR_TEXT = exports.KORA_USER_AGENT = exports.HANDLES_API_KEY = exports.REGEX_SUB_HANDLE = exports.REGEX_HANDLE = exports.REGEX_SPLIT_ON_NUMS = exports.REGEX_SPLIT_ON_CHARS = exports.RESPONSE_NOT_ALLOWED = exports.RESPONSE_INVALID_HANDLE_FORMAT = exports.RESPONSE_UNAVAILABLE_LEGENDARY = exports.RESPONSE_UNAVAILABLE_RESERVED = exports.RESPONSE_UNAVAILABLE_ACTIVE_SESSION = exports.RESPONSE_UNAVAILABLE_PAID = exports.RESPONSE_AVAILABLE = void 0;
4
+ exports.TWELVE_HOURS_IN_SLOTS = exports.EMPTY = exports.HANDLES_PER_PAGE_MAX = exports.ERROR_TEXT = exports.KORA_USER_AGENT = exports.HANDLES_API_KEY = exports.REGEX_SUB_HANDLE = exports.REGEX_HANDLE = exports.REGEX_SPLIT_ON_NUMS = exports.REGEX_SPLIT_ON_CHARS = exports.RESPONSE_NOT_ALLOWED = exports.RESPONSE_INVALID_HANDLE_FORMAT = exports.RESPONSE_UNAVAILABLE_LEGENDARY = exports.RESPONSE_UNAVAILABLE_RESERVED = exports.RESPONSE_UNAVAILABLE_ACTIVE_SESSION = exports.RESPONSE_UNAVAILABLE_PAID = exports.RESPONSE_AVAILABLE = void 0;
5
5
  const constants_1 = require("../constants");
6
6
  exports.RESPONSE_AVAILABLE = 'Yay! This handle is available.';
7
7
  exports.RESPONSE_UNAVAILABLE_PAID = 'Sorry! This Handle is pending mint or already minted.';
@@ -26,3 +26,5 @@ var ERROR_TEXT;
26
26
  ERROR_TEXT["HANDLE_PAGE_AND_SLOT_NUMBER_INVALID"] = "'page' and 'slot_number' can't be used together";
27
27
  })(ERROR_TEXT = exports.ERROR_TEXT || (exports.ERROR_TEXT = {}));
28
28
  exports.HANDLES_PER_PAGE_MAX = 1000;
29
+ exports.EMPTY = '|empty|';
30
+ exports.TWELVE_HOURS_IN_SLOTS = 43200; // value comes from the securityParam here: https://cips.cardano.org/cips/cip9/#nonupdatableparameters then converted to slots
@@ -1,8 +1,8 @@
1
+ export * from './api';
2
+ export * from './constants';
1
3
  export * from './interfaces';
2
4
  export * from './interfaces/api';
3
- export * from './interfaces/handlesRepository';
4
- export * from './constants';
5
- export * from './api';
5
+ export * from './interfaces/handlesProvider';
6
+ export * from './models';
6
7
  export * from './policies';
7
8
  export * from './utils';
8
- export * from './models';
package/handles/index.js CHANGED
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api"), exports);
18
+ __exportStar(require("./constants"), exports);
17
19
  __exportStar(require("./interfaces"), exports);
18
20
  __exportStar(require("./interfaces/api"), exports);
19
- __exportStar(require("./interfaces/handlesRepository"), exports);
20
- __exportStar(require("./constants"), exports);
21
- __exportStar(require("./api"), exports);
21
+ __exportStar(require("./interfaces/handlesProvider"), exports);
22
+ __exportStar(require("./models"), exports);
22
23
  __exportStar(require("./policies"), exports);
23
24
  __exportStar(require("./utils"), exports);
24
- __exportStar(require("./models"), exports);
@@ -40,10 +40,10 @@ export interface HandleHistory {
40
40
  old: Partial<StoredHandle> | null;
41
41
  new?: Partial<StoredHandle> | null;
42
42
  }
43
- export interface ISlotHistoryIndex {
43
+ export interface ISlotHistory {
44
44
  [handleHex: string]: HandleHistory;
45
45
  }
46
- export interface IHandleStoreMetrics {
46
+ export interface IApiMetrics {
47
47
  firstSlot?: number;
48
48
  lastSlot?: number;
49
49
  currentSlot?: number;
@@ -54,6 +54,8 @@ export interface IHandleStoreMetrics {
54
54
  tipBlockHash?: string;
55
55
  memorySize?: number;
56
56
  networkSync?: number;
57
+ count?: number;
58
+ schemaVersion?: number;
57
59
  }
58
60
  export interface SaveMintingTxInput {
59
61
  hex: string;
@@ -92,12 +94,15 @@ export interface SaveMintingTxInput {
92
94
  id_hash?: string;
93
95
  pz_enabled?: boolean;
94
96
  last_edited_time?: number;
97
+ policy: string;
95
98
  }
96
99
  export interface SaveWalletAddressMoveInput {
97
100
  slotNumber: number;
98
101
  name: string;
99
102
  adaAddress: string;
100
103
  utxo: string;
104
+ lovelace: number;
105
+ policy: string;
101
106
  datum?: string;
102
107
  script?: {
103
108
  type: string;
@@ -119,14 +124,15 @@ export interface SaveSubHandleSettingsInput {
119
124
  utxoDetails: IUTxO;
120
125
  slotNumber: number;
121
126
  }
122
- export interface HolderAddressIndex {
127
+ export interface Holder {
128
+ address: string;
123
129
  handles: Set<string>;
124
130
  defaultHandle: string;
125
131
  manuallySet: boolean;
126
132
  type: string;
127
133
  knownOwnerName: string;
128
134
  }
129
- export interface HolderAddressDetails {
135
+ export interface HolderViewModel {
130
136
  total_handles: number;
131
137
  address: string;
132
138
  type: string;
@@ -165,3 +171,18 @@ export interface IGetHolderAddressDetailsRequest {
165
171
  export type INormalizedQueryParams = {
166
172
  [key: string]: string;
167
173
  };
174
+ export declare enum IndexNames {
175
+ ADDRESS = "address",
176
+ CHARACTER = "characters",
177
+ HANDLE = "handle",
178
+ HASH_OF_STAKE_KEY_HASH = "hashofstakekeyhash",
179
+ HOLDER = "holder",
180
+ LENGTH = "length",
181
+ NUMERIC_MODIFIER = "numericmodifiers",
182
+ OG = "og",
183
+ PAYMENT_KEY_HASH = "paymentkeyhashes",
184
+ RARITY = "rarity",
185
+ SLOT_HISTORY = "slothistory",
186
+ SUBHANDLE = "subhandle",
187
+ STAKE_KEY_HASH = "stakekeyhash"
188
+ }
@@ -1,2 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexNames = void 0;
4
+ var IndexNames;
5
+ (function (IndexNames) {
6
+ IndexNames["ADDRESS"] = "address";
7
+ IndexNames["CHARACTER"] = "characters";
8
+ IndexNames["HANDLE"] = "handle";
9
+ IndexNames["HASH_OF_STAKE_KEY_HASH"] = "hashofstakekeyhash";
10
+ IndexNames["HOLDER"] = "holder";
11
+ IndexNames["LENGTH"] = "length";
12
+ IndexNames["NUMERIC_MODIFIER"] = "numericmodifiers";
13
+ IndexNames["OG"] = "og";
14
+ IndexNames["PAYMENT_KEY_HASH"] = "paymentkeyhashes";
15
+ IndexNames["RARITY"] = "rarity";
16
+ IndexNames["SLOT_HISTORY"] = "slothistory";
17
+ IndexNames["SUBHANDLE"] = "subhandle";
18
+ IndexNames["STAKE_KEY_HASH"] = "stakekeyhash";
19
+ })(IndexNames = exports.IndexNames || (exports.IndexNames = {}));
@@ -0,0 +1,28 @@
1
+ import { IApiMetrics, IndexNames, StoredHandle } from './api';
2
+ export interface IHandlesProvider {
3
+ initialize: () => Promise<IHandlesProvider>;
4
+ destroy: () => void;
5
+ rollBackToGenesis: () => void;
6
+ getStartingPoint: (save: ({ handle, oldHandle, saveHistory }: {
7
+ handle: StoredHandle;
8
+ oldHandle?: StoredHandle;
9
+ saveHistory?: boolean;
10
+ }) => Promise<void>, failed: boolean) => Promise<{
11
+ slot: number;
12
+ id: string;
13
+ } | null>;
14
+ getHandle: (key: string) => StoredHandle | null;
15
+ getHandleByHex: (hex: string) => StoredHandle | null;
16
+ getAllHandles: () => StoredHandle[];
17
+ setHandle: (key: string, value: StoredHandle) => void;
18
+ removeHandle: (handleName: string) => void;
19
+ getIndex: (index: IndexNames) => any;
20
+ getValuesFromIndex: (index: IndexNames, key: string | number) => any;
21
+ setValueOnIndex: (index: IndexNames, key: string | number, value: any) => void;
22
+ removeValueFromIndex: (index: IndexNames, key: string | number, value: string) => void;
23
+ removeKeyFromIndex: (index: IndexNames, key: string | number) => void;
24
+ getMetrics: () => IApiMetrics;
25
+ setMetrics: (metrics: IApiMetrics) => void;
26
+ count: () => number;
27
+ getSchemaVersion: () => number;
28
+ }
@@ -1,5 +1,5 @@
1
1
  import { BoolInt, FeaturedItemType, HexString, HexStringOrEmpty } from '../../types';
2
- import { ISlotHistoryIndex, StoredHandle } from './api';
2
+ import { ISlotHistory, StoredHandle } from './api';
3
3
  export declare enum Rarity {
4
4
  basic = "basic",
5
5
  common = "common",
@@ -71,7 +71,11 @@ export interface IPersonalizationPortal {
71
71
  export declare enum ScriptType {
72
72
  PZ_CONTRACT = "pz_contract",
73
73
  SUB_HANDLE_SETTINGS = "sub_handle_settings",
74
- MARKETPLACE_CONTRACT = "marketplace_contract"
74
+ MARKETPLACE_CONTRACT = "marketplace_contract",
75
+ DEMI_MINT = "demi_mint",
76
+ DEMI_MINT_PROXY = "demi_mint_proxy",
77
+ DEMI_MINTING_DATA = "demi_minting_data",
78
+ DEMI_ORDERS = "demi_orders"
75
79
  }
76
80
  export interface ScriptDetails {
77
81
  handle: string;
@@ -155,7 +159,7 @@ export interface ICip68Handle extends IHandle {
155
159
  export interface IPersonalizedHandle extends ICip68Handle {
156
160
  personalization?: IPersonalization;
157
161
  }
158
- export interface IHandleStats {
162
+ export interface IApiMetricsViewModel {
159
163
  percentage_complete: string;
160
164
  current_memory_used: number;
161
165
  ogmios_elapsed: string;
@@ -344,7 +348,7 @@ export interface IHandleFileContent {
344
348
  hash: string;
345
349
  schemaVersion?: number;
346
350
  handles: Record<string, StoredHandle>;
347
- history: [number, ISlotHistoryIndex][];
351
+ history: [number, ISlotHistory][];
348
352
  }
349
353
  export interface IHandleSvgOptions extends IPersonalizationDesigner {
350
354
  pfp_image?: string;
@@ -14,6 +14,10 @@ var ScriptType;
14
14
  ScriptType["PZ_CONTRACT"] = "pz_contract";
15
15
  ScriptType["SUB_HANDLE_SETTINGS"] = "sub_handle_settings";
16
16
  ScriptType["MARKETPLACE_CONTRACT"] = "marketplace_contract";
17
+ ScriptType["DEMI_MINT"] = "demi_mint";
18
+ ScriptType["DEMI_MINT_PROXY"] = "demi_mint_proxy";
19
+ ScriptType["DEMI_MINTING_DATA"] = "demi_minting_data";
20
+ ScriptType["DEMI_ORDERS"] = "demi_orders";
17
21
  })(ScriptType = exports.ScriptType || (exports.ScriptType = {}));
18
22
  var HandleType;
19
23
  (function (HandleType) {
@@ -1,25 +1,18 @@
1
1
  import { Network } from '../types';
2
- export declare const HANDLE_POLICIES: {
3
- preview: {
4
- f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a: {
5
- firstMintingSlot: number;
6
- lastMintingSlot: null;
7
- sunsetSlot: null;
8
- };
9
- };
10
- preprod: {
11
- f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a: {
12
- firstMintingSlot: number;
13
- lastMintingSlot: null;
14
- sunsetSlot: null;
15
- };
16
- };
17
- mainnet: {
18
- f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a: {
19
- firstMintingSlot: number;
20
- lastMintingSlot: null;
21
- sunsetSlot: null;
22
- };
2
+ interface PolicyIds {
3
+ [key: string]: {
4
+ firstMintingSlot: number;
5
+ lastMintingSlot: number | null;
6
+ sunsetSlot: number | null;
7
+ isDeMi?: boolean;
23
8
  };
9
+ }
10
+ interface HandlePolicies {
11
+ 'preview': PolicyIds;
12
+ 'preprod': PolicyIds;
13
+ 'mainnet': PolicyIds;
24
14
  getActivePolicy(network: Network, atSlot?: number): string | undefined;
25
- };
15
+ contains(network: Network, policyId: string): boolean;
16
+ }
17
+ export declare const HANDLE_POLICIES: HandlePolicies;
18
+ export {};
@@ -3,12 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HANDLE_POLICIES = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  exports.HANDLE_POLICIES = {
6
- 'preview': { 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null } },
6
+ 'preview': {
7
+ 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null },
8
+ '6c32db33a422e0bc2cb535bb850b5a6e9a9572222056d6ddc9cbc26e': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null, isDeMi: true }
9
+ },
7
10
  'preprod': { 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null } },
8
11
  'mainnet': { 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null } },
9
- getActivePolicy(network, atSlot) {
12
+ getActivePolicy(network, atSlot, isDeMi = false) {
10
13
  var _a;
11
14
  const theSlot = atSlot ? atSlot : (0, utils_1.getSlotNumberFromDate)(new Date(Date.now()));
12
- return (_a = Object.entries(this[network]).find(([, value]) => { var _a; return value.firstMintingSlot <= theSlot && ((_a = value.lastMintingSlot) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY) >= theSlot; })) === null || _a === void 0 ? void 0 : _a[0];
15
+ return (_a = Object.entries(this[network]).find(([, value]) => { var _a; return value.firstMintingSlot <= theSlot && ((_a = value.lastMintingSlot) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY) >= theSlot && value.isDeMi == isDeMi; })) === null || _a === void 0 ? void 0 : _a[0];
16
+ },
17
+ contains(network, policyId) {
18
+ return Object.keys(this[network]).includes(policyId);
13
19
  }
14
20
  };
package/logger/index.js CHANGED
@@ -59,8 +59,22 @@ class Logger {
59
59
  const log_milliseconds = milliseconds != undefined && milliseconds != null ? `, "milliseconds": ${milliseconds}` : '';
60
60
  const log_count = count != undefined && count != null ? `, "count": ${count}` : '';
61
61
  const log_dimensions = dimensions && Object.keys(dimensions).length ? `, "dimensions": ${JSON.stringify(dimensions)}` : '';
62
+ let logFunc = console.log;
63
+ switch (category) {
64
+ case LogCategory.DEBUG:
65
+ logFunc = console.debug;
66
+ break;
67
+ case LogCategory.WARN:
68
+ logFunc = console.warn;
69
+ break;
70
+ case LogCategory.ERROR:
71
+ case LogCategory.FATAL:
72
+ case LogCategory.NOTIFY:
73
+ logFunc = console.error;
74
+ break;
75
+ }
62
76
  // PLEASE KEEP THIS ALL ON ONE LINE SO LOGS AREN'T BROKEN UP
63
- console.log(`{"network": "${Logger.network}", "application": "${Logger.application}", "category": "${category !== null && category !== void 0 ? category : LogCategory.INFO}", "message": "${message}"${log_event}, "timestamp": "${now}"${log_milliseconds}${log_count}${log_dimensions} }`);
77
+ logFunc(`{"network": "${Logger.network}", "application": "${Logger.application}", "category": "${category !== null && category !== void 0 ? category : LogCategory.INFO}", "message": "${message}"${log_event}, "timestamp": "${now}"${log_milliseconds}${log_count}${log_dimensions} }`);
64
78
  // PLEASE KEEP THIS ALL ON ONE LINE SO LOGS AREN'T BROKEN UP
65
79
  }
66
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "5.1.26",
3
+ "version": "5.1.27",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,63 +0,0 @@
1
- import { IHandleFileContent, IHandleStats, IUTxO } from '..';
2
- import { HandlePaginationModel } from '../models/handlePagination.model';
3
- import { HandleSearchModel } from '../models/handleSearch.model';
4
- import { HolderPaginationModel } from '../models/holderPagination.model';
5
- import { HolderAddressDetails, IHandleStoreMetrics, SaveMintingTxInput, SavePersonalizationInput, SaveSubHandleSettingsInput, SaveWalletAddressMoveInput, StoredHandle } from './api';
6
- export interface IHandlesRepository {
7
- initialize: () => IHandlesRepository;
8
- getAll: (params: {
9
- pagination: HandlePaginationModel;
10
- search: HandleSearchModel;
11
- }) => Promise<{
12
- searchTotal: number;
13
- handles: StoredHandle[];
14
- }>;
15
- getHandlesByPaymentKeyHashes: (hashes: string[]) => string[];
16
- getHandlesByAddresses: (addresses: string[]) => string[];
17
- getHandlesByHolderAddresses: (addresses: string[]) => string[];
18
- getHandlesByStakeKeyHashes: (hashes: string[]) => string[];
19
- getAllHandleNames: (search: HandleSearchModel, sort: string) => Promise<string[]>;
20
- getHandleByName: (handleName: string) => Promise<StoredHandle | null>;
21
- getHandleByHex: (handleHex: string) => Promise<StoredHandle | null>;
22
- getHolderAddressDetails: (key: string) => Promise<HolderAddressDetails>;
23
- getAllHolders: (params: {
24
- pagination: HolderPaginationModel;
25
- }) => Promise<HolderAddressDetails[]>;
26
- getHandleStats: () => IHandleStats;
27
- getTotalHandlesStats: () => {
28
- total_handles: number;
29
- total_holders: number;
30
- };
31
- currentHttpStatus: () => number;
32
- getHandleDatumByName: (handleName: string) => Promise<string | null>;
33
- getSubHandleSettings: (handleName: string) => Promise<{
34
- settings?: string;
35
- utxo: IUTxO;
36
- } | null>;
37
- getSubHandles: (handleName: string) => Promise<StoredHandle[]>;
38
- getTimeMetrics: () => {
39
- elapsedOgmiosExec: number;
40
- elapsedBuildingExec: number;
41
- };
42
- setMetrics: (metrics: IHandleStoreMetrics) => void;
43
- getMetrics: () => IHandleStats;
44
- getFilesContent(): Promise<IHandleFileContent[] | null>;
45
- prepareHandlesStorage: (fileContent: IHandleFileContent) => Promise<void>;
46
- rollBackToGenesis: () => Promise<void>;
47
- isCaughtUp: () => boolean;
48
- burnHandle: (handleName: string, slotNumber: number) => Promise<void>;
49
- rewindChangesToSlot: ({ slot, hash, lastSlot }: {
50
- slot: number;
51
- hash: string;
52
- lastSlot: number;
53
- }) => Promise<{
54
- name: string;
55
- action: string;
56
- handle: Partial<StoredHandle> | undefined;
57
- }[]>;
58
- savePersonalizationChange: ({ name, hex, personalization, reference_token, personalizationDatum, slotNumber, metadata }: SavePersonalizationInput) => Promise<void>;
59
- saveSubHandleSettingsChange: ({ name, settingsDatum, utxoDetails, slotNumber }: SaveSubHandleSettingsInput) => Promise<void>;
60
- saveMintedHandle: (input: SaveMintingTxInput) => Promise<void>;
61
- saveHandleUpdate: ({ name, adaAddress, utxo, slotNumber, datum, script }: SaveWalletAddressMoveInput) => Promise<void>;
62
- destroy: () => void;
63
- }