@socket.tech/dl-common 1.0.3-test.7 → 1.0.3-test.9

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.
@@ -104,3 +104,14 @@ export interface AttestFailure {
104
104
  reason: TripReason;
105
105
  }
106
106
  export type AttestResponse = AttestSuccess | AttestFailure;
107
+ export type MessageData = {
108
+ messageId: string;
109
+ destPlug: string;
110
+ srcPlug: string;
111
+ dstChainSlug: ChainSlug;
112
+ srcChainSlug: ChainSlug;
113
+ payload: string;
114
+ minMsgGasLimit: string;
115
+ executionParams: string;
116
+ packedMessage: string;
117
+ };
@@ -5,6 +5,7 @@ export declare const isEmpty: (data: any) => boolean;
5
5
  export declare const checkMissingFields: (fields: {
6
6
  [key: string]: any;
7
7
  }) => void;
8
+ export declare const checkEnvValue: (key: string) => string;
8
9
  export declare const checkMissingFieldsAndType: (fields: {
9
10
  [key: string]: any;
10
11
  }, types?: {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.responseBody = exports.filterFields = exports.removeFields = exports.checkObjectFieldsAndType = exports.checkMissingFieldsAndType = exports.checkMissingFields = exports.isEmpty = void 0;
4
- const __1 = require("..");
3
+ exports.responseBody = exports.filterFields = exports.removeFields = exports.checkObjectFieldsAndType = exports.checkMissingFieldsAndType = exports.checkEnvValue = exports.checkMissingFields = exports.isEmpty = void 0;
4
+ const constants_1 = require("../constants");
5
5
  /**
6
6
  * defining functions.
7
7
  */
@@ -18,18 +18,26 @@ const checkMissingFields = (fields) => {
18
18
  for (const field in fields) {
19
19
  let value = fields[field];
20
20
  if (!value) {
21
- throw (0, __1.BadRequestError)(`missing field : ${field}`);
21
+ throw (0, constants_1.BadRequestError)(`missing field : ${field}`);
22
22
  }
23
23
  }
24
24
  };
25
25
  exports.checkMissingFields = checkMissingFields;
26
+ const checkEnvValue = (key) => {
27
+ let value = process.env[key];
28
+ if (!value) {
29
+ throw (0, constants_1.InternalServerError)(`${key} not found`);
30
+ }
31
+ return value;
32
+ };
33
+ exports.checkEnvValue = checkEnvValue;
26
34
  const checkMissingFieldsAndType = (fields, types = {}) => {
27
35
  for (const field in fields) {
28
36
  if ((0, exports.isEmpty)(fields[field])) {
29
- throw (0, __1.BadRequestError)(`missing field : ${field}`);
37
+ throw (0, constants_1.BadRequestError)(`missing field : ${field}`);
30
38
  }
31
39
  if (types[field] && typeof fields[field] !== types[field]) {
32
- throw (0, __1.BadRequestError)(`Type of ${field} expected : "${types[field]}", got : "${typeof fields[field]}"`);
40
+ throw (0, constants_1.BadRequestError)(`Type of ${field} expected : "${types[field]}", got : "${typeof fields[field]}"`);
33
41
  }
34
42
  }
35
43
  };
@@ -38,13 +46,13 @@ const checkObjectFieldsAndType = (data, types = {}, prefix = "") => {
38
46
  let keys = Object.keys(types);
39
47
  for (const key of keys) {
40
48
  if ((0, exports.isEmpty)(data[key])) {
41
- throw (0, __1.BadRequestError)(`missing field : ${prefix}.${key}`);
49
+ throw (0, constants_1.BadRequestError)(`missing field : ${prefix}.${key}`);
42
50
  }
43
51
  if (typeof data[key] === "object") {
44
52
  (0, exports.checkObjectFieldsAndType)(data[key], types[key], `${prefix}.${key}`);
45
53
  }
46
54
  else if (typeof data[key] !== types[key]) {
47
- throw (0, __1.BadRequestError)(`Type of ${prefix}.${key} expected : "${types[key]}", got : "${typeof data[key]}"`);
55
+ throw (0, constants_1.BadRequestError)(`Type of ${prefix}.${key} expected : "${types[key]}", got : "${typeof data[key]}"`);
48
56
  }
49
57
  }
50
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket.tech/dl-common",
3
- "version": "1.0.3-test.7",
3
+ "version": "1.0.3-test.9",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "common utilities for socket data layer.",
@@ -20,7 +20,7 @@
20
20
  "start": "serverless offline start --reloadHandler -s dev",
21
21
  "start:dev": "serverless offline start --reloadHandler -s dev",
22
22
  "deploy": "npx sls deploy -s dev --verbose",
23
- "deploy:prod": "npx sls deploy -s prod --verbose",
23
+ "deploy:prod": "export AWS_PROFILE=dlprod && npx sls deploy -s prod --verbose",
24
24
  "deploy:surge": "npx sls deploy -s surge --verbose",
25
25
  "build": "tsc --project lib.tsconfig.json",
26
26
  "build:clean": "rm -rf tsconfig.build.tsbuildinfo && rm -rf ./dist",
@@ -38,7 +38,7 @@
38
38
  "@aws-sdk/client-sqs": "^3.421.0",
39
39
  "@aws-sdk/smithy-client": "^3.329.0",
40
40
  "@ethersproject/providers": "^5.7.2",
41
- "@socket.tech/dl-core": "2.4.8-test.1",
41
+ "@socket.tech/dl-core": "2.4.10",
42
42
  "@socket.tech/ll-common": "^0.0.19",
43
43
  "async-redis": "^2.0.0",
44
44
  "ethers": "^5.7.1",