@koralabs/kora-labs-common 6.1.2 → 6.1.3

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.
@@ -53,8 +53,13 @@ export interface IApiMetrics {
53
53
  count?: number;
54
54
  schemaVersion?: number;
55
55
  }
56
+ export interface DefaultHandleInfo {
57
+ name: string;
58
+ og_number: number;
59
+ created_slot_number: number;
60
+ }
56
61
  export interface Holder {
57
- handles: Set<string>;
62
+ handles: DefaultHandleInfo[];
58
63
  defaultHandle: string;
59
64
  manuallySet: boolean;
60
65
  type: string;
@@ -117,6 +122,5 @@ export declare enum IndexNames {
117
122
  PAYMENT_KEY_HASH = "paymentkeyhashes",
118
123
  RARITY = "rarity",
119
124
  SLOT_HISTORY = "slothistory",
120
- SUBHANDLE = "subhandle",
121
- STAKE_KEY_HASH = "stakekeyhash"
125
+ SUBHANDLE = "subhandle"
122
126
  }
@@ -15,5 +15,4 @@ var IndexNames;
15
15
  IndexNames["RARITY"] = "rarity";
16
16
  IndexNames["SLOT_HISTORY"] = "slothistory";
17
17
  IndexNames["SUBHANDLE"] = "subhandle";
18
- IndexNames["STAKE_KEY_HASH"] = "stakekeyhash";
19
18
  })(IndexNames = exports.IndexNames || (exports.IndexNames = {}));
@@ -1,37 +1,15 @@
1
1
  import { IHandleSearchInput } from '..';
2
2
  export declare class HandleSearchModel implements IHandleSearchInput {
3
- private _characters?;
4
- private _length?;
5
- private _rarity?;
6
- private _numeric_modifiers?;
7
- private _search?;
8
- private _holder_address?;
9
- private _personalized?;
10
- private _handle_type?;
11
- private _og?;
12
- private _handles?;
13
- private _public_subhandles?;
3
+ characters?: string;
4
+ length?: string;
5
+ rarity?: string;
6
+ numeric_modifiers?: string;
7
+ search?: string;
8
+ holder_address?: string;
9
+ personalized?: boolean;
10
+ handle_type?: string;
11
+ public_subhandles?: boolean;
12
+ og?: 'true' | 'false';
13
+ handles?: string[];
14
14
  constructor(input?: IHandleSearchInput);
15
- get characters(): string | undefined;
16
- set characters(value: string | undefined);
17
- get rarity(): string | undefined;
18
- set rarity(value: string | undefined);
19
- get handle_type(): string | undefined;
20
- set handle_type(value: string | undefined);
21
- get length(): string | undefined;
22
- set length(value: string | undefined);
23
- get numeric_modifiers(): string | undefined;
24
- set numeric_modifiers(value: string | undefined);
25
- get search(): string | undefined;
26
- set search(value: string | undefined);
27
- get holder_address(): string | undefined;
28
- set holder_address(value: string | undefined);
29
- get personalized(): boolean | undefined;
30
- set personalized(value: boolean | undefined);
31
- get og(): "true" | "false" | undefined;
32
- set og(value: "true" | "false" | undefined);
33
- get public_subhandles(): boolean | undefined;
34
- set public_subhandles(value: boolean | undefined);
35
- get handles(): string[] | undefined;
36
- set handles(value: string[] | undefined);
37
15
  }
@@ -6,119 +6,50 @@ const errors_1 = require("../../errors");
6
6
  const utils_1 = require("../../utils");
7
7
  class HandleSearchModel {
8
8
  constructor(input) {
9
+ var _a;
9
10
  for (const key in input) {
10
- if (input.hasOwnProperty(key) && this.hasOwnProperty(key)) {
11
- this[key] = input[key];
12
- }
11
+ this[key] = input[key];
13
12
  }
14
- }
15
- get characters() {
16
- return this._characters;
17
- }
18
- set characters(value) {
19
13
  const validCharacters = ['letters', 'numbers', 'special'];
20
- if (value && !validCharacters.some((v) => value.split(',').includes(v))) {
14
+ if (this.characters && !validCharacters.some((v) => this.characters.split(',').includes(v))) {
21
15
  throw new errors_1.ModelException(`characters must be ${validCharacters.join(', ')}`);
22
16
  }
23
- this._characters = value;
24
- }
25
- get rarity() {
26
- return this._rarity;
27
- }
28
- set rarity(value) {
29
17
  const validRarity = Object.values(__1.Rarity);
30
- if (value && !validRarity.some((v) => value.split(',').includes(v))) {
18
+ if (this.rarity && !validRarity.some((v) => this.rarity.split(',').includes(v))) {
31
19
  throw new errors_1.ModelException(`rarity must be ${validRarity.join(', ')}`);
32
20
  }
33
- this._rarity = value;
34
- }
35
- get handle_type() {
36
- return this._handle_type;
37
- }
38
- set handle_type(value) {
39
21
  const validHandleType = Object.values(__1.HandleType);
40
- if (value && !validHandleType.some((v) => value.split(',').includes(v))) {
22
+ if (this.handle_type && !validHandleType.some((v) => this.handle_type.split(',').includes(v))) {
41
23
  throw new errors_1.ModelException(`handle_type must be ${validHandleType.join(', ')}`);
42
24
  }
43
- this._handle_type = value;
44
- }
45
- get length() {
46
- return this._length;
47
- }
48
- set length(value) {
49
- const lengthMErrorMsg = "Length must be a number or a range of numbers (ex: 1-28) and can't exceed 28";
50
- if (!value) {
51
- this._length = value;
52
- return;
53
- }
54
- let minLength = value;
55
- let maxLength = value;
56
- if (value === null || value === void 0 ? void 0 : value.includes('-')) {
57
- minLength = value.split('-')[0];
58
- maxLength = value.split('-')[1];
59
- }
60
- if (!(0, utils_1.isNumeric)(minLength) || !(0, utils_1.isNumeric)(maxLength)) {
61
- throw new errors_1.ModelException(lengthMErrorMsg);
62
- }
63
- if (parseInt(minLength) > 28 || parseInt(maxLength) > 28) {
64
- throw new errors_1.ModelException(lengthMErrorMsg);
65
- }
66
- if (parseInt(minLength) > parseInt(maxLength)) {
67
- throw new errors_1.ModelException('Invalid length range');
25
+ if (this.length) {
26
+ const lengthMErrorMsg = "Length must be a number or a range of numbers (ex: 1-28) and can't exceed 28";
27
+ let minLength = this.length;
28
+ let maxLength = this.length;
29
+ if ((_a = this.length) === null || _a === void 0 ? void 0 : _a.includes('-')) {
30
+ minLength = this.length.split('-')[0];
31
+ maxLength = this.length.split('-')[1];
32
+ }
33
+ if (!(0, utils_1.isNumeric)(minLength) || !(0, utils_1.isNumeric)(maxLength)) {
34
+ throw new errors_1.ModelException(lengthMErrorMsg);
35
+ }
36
+ if (parseInt(minLength) > 28 || parseInt(maxLength) > 28) {
37
+ throw new errors_1.ModelException(lengthMErrorMsg);
38
+ }
39
+ if (parseInt(minLength) > parseInt(maxLength)) {
40
+ throw new errors_1.ModelException('Invalid length range');
41
+ }
68
42
  }
69
- this._length = value;
70
- }
71
- get numeric_modifiers() {
72
- return this._numeric_modifiers;
73
- }
74
- set numeric_modifiers(value) {
75
43
  const validModifiers = ['negative', 'decimal'];
76
- if (value && !validModifiers.some((v) => value.split(',').includes(v))) {
44
+ if (this.numeric_modifiers && !validModifiers.some((v) => this.numeric_modifiers.split(',').includes(v))) {
77
45
  throw new errors_1.ModelException(`numeric_modifiers must be ${validModifiers.join(', ')}`);
78
46
  }
79
- this._numeric_modifiers = value;
80
- }
81
- get search() {
82
- return this._search;
83
- }
84
- set search(value) {
85
- if (value && value.length < 3) {
47
+ if (this.search && this.search.length < 3) {
86
48
  throw new errors_1.ModelException('search must be at least 3 characters');
87
49
  }
88
- this._search = value;
89
- }
90
- get holder_address() {
91
- return this._holder_address;
92
- }
93
- set holder_address(value) {
94
- this._holder_address = value;
95
- }
96
- get personalized() {
97
- return this._personalized;
98
- }
99
- set personalized(value) {
100
- this._personalized = value;
101
- }
102
- get og() {
103
- return this._og;
104
- }
105
- set og(value) {
106
- this._og = value;
107
- }
108
- get public_subhandles() {
109
- return this._public_subhandles;
110
- }
111
- set public_subhandles(value) {
112
- this._public_subhandles = value;
113
- }
114
- get handles() {
115
- return this._handles;
116
- }
117
- set handles(value) {
118
- if (value && !Array.isArray(value)) {
119
- throw new errors_1.ModelException(`expected array and received ${typeof value}`);
50
+ if (this.handles && !Array.isArray(this.handles)) {
51
+ throw new errors_1.ModelException(`expected array and received ${typeof this.handles}`);
120
52
  }
121
- this._handles = value;
122
53
  }
123
54
  }
124
55
  exports.HandleSearchModel = HandleSearchModel;
@@ -7,8 +7,14 @@ 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 } },
11
- 'mainnet': { '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
+ },
14
+ 'mainnet': {
15
+ 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null },
16
+ '6c32db33a422e0bc2cb535bb850b5a6e9a9572222056d6ddc9cbc26e': { firstMintingSlot: 0, lastMintingSlot: null, sunsetSlot: null, isDeMi: true }
17
+ },
12
18
  getActivePolicy(network, isDeMi = false, atSlot) {
13
19
  var _a;
14
20
  const theSlot = atSlot ? atSlot : (0, utils_1.getSlotNumberFromDate)(new Date(Date.now()));
package/handles/utils.js CHANGED
@@ -128,7 +128,7 @@ const buildDrep = (address, id_hash) => {
128
128
  const decoded = (_a = (0, utils_1.decodeAddress)(address)) === null || _a === void 0 ? void 0 : _a.slice(2, 58);
129
129
  if (!decoded || decoded == '')
130
130
  return undefined;
131
- const hashed = crypto.createHash('md5').update(Buffer.from(decoded, 'hex')).digest('hex');
131
+ const hashed = crypto.createHash('md5').update(decoded).digest('hex');
132
132
  if (!id_hash.startsWith(hashed))
133
133
  return undefined;
134
134
  const typeByte = id_hash.slice(32, 34);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -303,6 +303,12 @@ const getSlotNumberFromDate = (date) => {
303
303
  };
304
304
  exports.getSlotNumberFromDate = getSlotNumberFromDate;
305
305
  const blake2b = (input, outlen = 32) => {
306
- return (0, blakejs_1.blake2bHex)(typeof input == 'string' ? Buffer.from(input, 'hex') : input, undefined, outlen);
306
+ if (typeof input == 'string') {
307
+ input = Buffer.from(input, 'hex');
308
+ }
309
+ if (input instanceof Buffer) {
310
+ input = new Uint8Array(input);
311
+ }
312
+ return (0, blakejs_1.blake2bHex)(input, undefined, outlen);
307
313
  };
308
314
  exports.blake2b = blake2b;