@koralabs/kora-labs-common 5.1.34 → 5.1.35

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,5 +20,3 @@ 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.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;
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;
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,5 +26,3 @@ 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';
3
1
  export * from './interfaces';
4
2
  export * from './interfaces/api';
5
- export * from './interfaces/handlesProvider';
6
- export * from './models';
3
+ export * from './interfaces/handlesRepository';
4
+ export * from './constants';
5
+ export * from './api';
7
6
  export * from './policies';
8
7
  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);
19
17
  __exportStar(require("./interfaces"), exports);
20
18
  __exportStar(require("./interfaces/api"), exports);
21
- __exportStar(require("./interfaces/handlesProvider"), exports);
22
- __exportStar(require("./models"), exports);
19
+ __exportStar(require("./interfaces/handlesRepository"), exports);
20
+ __exportStar(require("./constants"), exports);
21
+ __exportStar(require("./api"), exports);
23
22
  __exportStar(require("./policies"), exports);
24
23
  __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 ISlotHistory {
43
+ export interface ISlotHistoryIndex {
44
44
  [handleHex: string]: HandleHistory;
45
45
  }
46
- export interface IApiMetrics {
46
+ export interface IHandleStoreMetrics {
47
47
  firstSlot?: number;
48
48
  lastSlot?: number;
49
49
  currentSlot?: number;
@@ -54,8 +54,6 @@ export interface IApiMetrics {
54
54
  tipBlockHash?: string;
55
55
  memorySize?: number;
56
56
  networkSync?: number;
57
- count?: number;
58
- schemaVersion?: number;
59
57
  }
60
58
  export interface SaveMintingTxInput {
61
59
  hex: string;
@@ -125,15 +123,14 @@ export interface SaveSubHandleSettingsInput {
125
123
  utxoDetails: IUTxO;
126
124
  slotNumber: number;
127
125
  }
128
- export interface Holder {
129
- address: string;
126
+ export interface HolderAddressIndex {
130
127
  handles: Set<string>;
131
128
  defaultHandle: string;
132
129
  manuallySet: boolean;
133
130
  type: string;
134
131
  knownOwnerName: string;
135
132
  }
136
- export interface HolderViewModel {
133
+ export interface HolderAddressDetails {
137
134
  total_handles: number;
138
135
  address: string;
139
136
  type: string;
@@ -172,18 +169,3 @@ export interface IGetHolderAddressDetailsRequest {
172
169
  export type INormalizedQueryParams = {
173
170
  [key: string]: string;
174
171
  };
175
- export declare enum IndexNames {
176
- ADDRESS = "address",
177
- CHARACTER = "characters",
178
- HANDLE = "handle",
179
- HASH_OF_STAKE_KEY_HASH = "hashofstakekeyhash",
180
- HOLDER = "holder",
181
- LENGTH = "length",
182
- NUMERIC_MODIFIER = "numericmodifiers",
183
- OG = "og",
184
- PAYMENT_KEY_HASH = "paymentkeyhashes",
185
- RARITY = "rarity",
186
- SLOT_HISTORY = "slothistory",
187
- SUBHANDLE = "subhandle",
188
- STAKE_KEY_HASH = "stakekeyhash"
189
- }
@@ -1,19 +1,2 @@
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,63 @@
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
+ }
@@ -1,5 +1,5 @@
1
1
  import { BoolInt, FeaturedItemType, HexString, HexStringOrEmpty } from '../../types';
2
- import { ISlotHistory, StoredHandle } from './api';
2
+ import { ISlotHistoryIndex, StoredHandle } from './api';
3
3
  export declare enum Rarity {
4
4
  basic = "basic",
5
5
  common = "common",
@@ -159,7 +159,7 @@ export interface ICip68Handle extends IHandle {
159
159
  export interface IPersonalizedHandle extends ICip68Handle {
160
160
  personalization?: IPersonalization;
161
161
  }
162
- export interface IApiMetricsViewModel {
162
+ export interface IHandleStats {
163
163
  percentage_complete: string;
164
164
  current_memory_used: number;
165
165
  ogmios_elapsed: string;
@@ -348,7 +348,7 @@ export interface IHandleFileContent {
348
348
  hash: string;
349
349
  schemaVersion?: number;
350
350
  handles: Record<string, StoredHandle>;
351
- history: [number, ISlotHistory][];
351
+ history: [number, ISlotHistoryIndex][];
352
352
  }
353
353
  export interface IHandleSvgOptions extends IPersonalizationDesigner {
354
354
  pfp_image?: string;
@@ -7,7 +7,10 @@ exports.HANDLE_POLICIES = {
7
7
  'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null },
8
8
  '6c32db33a422e0bc2cb535bb850b5a6e9a9572222056d6ddc9cbc26e': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null, isDeMi: true }
9
9
  },
10
- 'preprod': { 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null } },
10
+ 'preprod': {
11
+ 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null },
12
+ '6c32db33a422e0bc2cb535bb850b5a6e9a9572222056d6ddc9cbc26e': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null, isDeMi: true }
13
+ },
11
14
  'mainnet': { 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null } },
12
15
  getActivePolicy(network, isDeMi = false, atSlot) {
13
16
  var _a;
package/logger/index.js CHANGED
@@ -59,22 +59,8 @@ 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
- }
76
62
  // PLEASE KEEP THIS ALL ON ONE LINE SO LOGS AREN'T BROKEN UP
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} }`);
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} }`);
78
64
  // PLEASE KEEP THIS ALL ON ONE LINE SO LOGS AREN'T BROKEN UP
79
65
  }
80
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "5.1.34",
3
+ "version": "5.1.35",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AddressDetails, AddressType, AssetNameLabel } from '../../types';
4
2
  export declare const getNativeCrypto: () => Promise<any>;
5
3
  export declare function dec2hex(dec: number): string;
@@ -19,9 +17,8 @@ export declare const buildPaymentAddressType: (address: string) => AddressType;
19
17
  export declare const buildStakeKey: (address: string) => string | null;
20
18
  export declare const getPaymentKeyHash: (address: string) => Promise<string | null>;
21
19
  export declare const bech32FromHex: (hex: string, isTestnet?: boolean, type?: 'addr' | 'stake' | 'pool' | 'drep' | 'cc_hot' | 'cc_cold') => string;
22
- export declare const bech32AddressFromHashes: (paymentHash: string, paymentHashType?: 'key' | 'script', stakeHash?: string, stakeHashType?: 'key' | 'script', type?: 'addr' | 'stake', isTestnet?: boolean) => string;
23
20
  export declare const getAddressHolderDetails: (addr: string) => AddressDetails;
24
21
  export declare const checkKnownSmartContracts: (address: string, stake?: string | null) => string;
25
22
  export declare const getDateStringFromSlot: (currentSlot: number) => Date;
26
23
  export declare const getSlotNumberFromDate: (date: Date) => number;
27
- export declare const blake2b: (input: string | Buffer | Uint8Array, outlen?: number) => string;
24
+ export declare const blake2b: (input: string, outlen?: number) => string;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.blake2b = exports.getSlotNumberFromDate = exports.getDateStringFromSlot = exports.checkKnownSmartContracts = exports.getAddressHolderDetails = exports.bech32AddressFromHashes = exports.bech32FromHex = exports.getPaymentKeyHash = exports.buildStakeKey = exports.buildPaymentAddressType = exports.getPaymentAddressType = exports.checkNameLabel = exports.parseAssetNameLabel = exports.decodeAddress = exports.getChallengeFromVerifier = exports.base64urlencode = exports.sha256 = exports.getRandomCodeVerifier = exports.dec2hex = exports.getNativeCrypto = void 0;
29
+ exports.blake2b = exports.getSlotNumberFromDate = exports.getDateStringFromSlot = exports.checkKnownSmartContracts = exports.getAddressHolderDetails = exports.bech32FromHex = exports.getPaymentKeyHash = exports.buildStakeKey = exports.buildPaymentAddressType = exports.getPaymentAddressType = exports.checkNameLabel = exports.parseAssetNameLabel = exports.decodeAddress = exports.getChallengeFromVerifier = exports.base64urlencode = exports.sha256 = exports.getRandomCodeVerifier = exports.dec2hex = exports.getNativeCrypto = void 0;
30
30
  const bech32_1 = require("bech32");
31
31
  const blakejs_1 = require("blakejs");
32
32
  const bs58_1 = __importDefault(require("bs58"));
@@ -218,23 +218,6 @@ const bech32FromHex = (hex, isTestnet = !constants_1.IS_PRODUCTION, type = 'addr
218
218
  return bech32_1.bech32.encode(prefix, words, bytes.length * 2 + prefix.length);
219
219
  };
220
220
  exports.bech32FromHex = bech32FromHex;
221
- const bech32AddressFromHashes = (paymentHash, paymentHashType = 'key', stakeHash = '', stakeHashType = 'key', type = 'addr', isTestnet = !constants_1.IS_PRODUCTION) => {
222
- let headerByte = 0;
223
- if (!stakeHash) {
224
- headerByte += 6;
225
- }
226
- else {
227
- if (stakeHashType == 'script') {
228
- headerByte += 2;
229
- }
230
- }
231
- if (paymentHashType == 'script') {
232
- headerByte += 1;
233
- }
234
- const hex = `${headerByte.toString(16)}${isTestnet ? 0 : 1}${paymentHash}${stakeHash}`;
235
- return (0, exports.bech32FromHex)(hex, isTestnet, type);
236
- };
237
- exports.bech32AddressFromHashes = bech32AddressFromHashes;
238
221
  const getAddressHolderDetails = (addr) => {
239
222
  const addressType = (0, exports.buildPaymentAddressType)(addr);
240
223
  let knownOwnerName = (0, exports.checkKnownSmartContracts)(addr);
@@ -307,6 +290,6 @@ const getSlotNumberFromDate = (date) => {
307
290
  };
308
291
  exports.getSlotNumberFromDate = getSlotNumberFromDate;
309
292
  const blake2b = (input, outlen = 32) => {
310
- return (0, blakejs_1.blake2bHex)(typeof input == 'string' ? Buffer.from(input, 'hex') : input, undefined, outlen);
293
+ return (0, blakejs_1.blake2bHex)(input, undefined, outlen);
311
294
  };
312
295
  exports.blake2b = blake2b;
@@ -1,28 +0,0 @@
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
- }