@socket.tech/dl-common 1.0.3-test.4 → 1.0.3-test.41

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.
Files changed (68) hide show
  1. package/dist/constants/confirmations.d.ts +5 -0
  2. package/dist/constants/confirmations.js +17 -0
  3. package/dist/constants/enums.d.ts +12 -2
  4. package/dist/constants/enums.js +12 -1
  5. package/dist/constants/types.d.ts +25 -3
  6. package/dist/constants/types.js +9 -1
  7. package/dist/constants/waitTime.d.ts +1 -0
  8. package/dist/constants/waitTime.js +7 -9
  9. package/dist/models/attestation.d.ts +2 -2
  10. package/dist/models/attestation.js +2 -2
  11. package/dist/models/index.d.ts +1 -0
  12. package/dist/models/index.js +1 -0
  13. package/dist/models/lastBlock.d.ts +28 -0
  14. package/dist/models/lastBlock.js +27 -0
  15. package/dist/models/message.d.ts +2 -2
  16. package/dist/models/message.js +2 -2
  17. package/dist/models/packet.d.ts +10 -2
  18. package/dist/models/packet.js +11 -2
  19. package/dist/models/proposal.d.ts +2 -2
  20. package/dist/models/proposal.js +2 -2
  21. package/dist/models/switchboard.d.ts +69 -0
  22. package/dist/models/switchboard.js +92 -0
  23. package/dist/models/transaction.d.ts +0 -0
  24. package/dist/models/transaction.js +280 -0
  25. package/dist/services/eventBridgeService.d.ts +8 -0
  26. package/dist/services/eventBridgeService.js +39 -0
  27. package/dist/services/index.d.ts +1 -0
  28. package/dist/services/index.js +1 -0
  29. package/dist/services/queueService.d.ts +2 -2
  30. package/dist/services/queueService.js +22 -14
  31. package/dist/utils/ethersAwsKmsSigner.d.ts +2 -2
  32. package/dist/utils/ethersAwsKmsSigner.js +6 -3
  33. package/dist/utils/extraUtils.d.ts +1 -0
  34. package/dist/utils/extraUtils.js +15 -7
  35. package/dist/utils/index.d.ts +2 -0
  36. package/dist/utils/index.js +2 -0
  37. package/dist/utils/relaySigner.d.ts +2 -4
  38. package/dist/utils/relaySigner.js +7 -10
  39. package/dist/utils/s3Service.d.ts +5 -0
  40. package/dist/utils/s3Service.js +45 -0
  41. package/dist/utils/signer/adapter.d.ts +18 -0
  42. package/dist/utils/signer/adapter.js +71 -0
  43. package/dist/utils/signer/address.d.ts +10 -0
  44. package/dist/utils/signer/address.js +42 -0
  45. package/dist/utils/signer/asn1-parser.d.ts +11 -0
  46. package/dist/utils/signer/asn1-parser.js +80 -0
  47. package/dist/utils/signer/crypto.d.ts +6 -0
  48. package/dist/utils/signer/crypto.js +34 -0
  49. package/dist/utils/signer/index.d.ts +4 -0
  50. package/dist/{types → utils/signer}/index.js +4 -2
  51. package/dist/utils/signer/kms-ethers-signer.d.ts +19 -0
  52. package/dist/utils/signer/kms-ethers-signer.js +32 -0
  53. package/dist/utils/signer/kms-signer.d.ts +14 -0
  54. package/dist/utils/signer/kms-signer.js +46 -0
  55. package/dist/utils/signer/signature.d.ts +17 -0
  56. package/dist/utils/signer/signature.js +65 -0
  57. package/dist/utils/signer/signer.d.ts +7 -0
  58. package/dist/utils/signer/signer.js +2 -0
  59. package/dist/utils/time.d.ts +1 -0
  60. package/dist/utils/time.js +3 -1
  61. package/package.json +52 -16
  62. package/dist/models/attestations.d.ts +0 -69
  63. package/dist/models/attestations.js +0 -59
  64. package/dist/types/codes.d.ts +0 -22
  65. package/dist/types/codes.js +0 -28
  66. package/dist/types/index.d.ts +0 -2
  67. package/dist/types/types.d.ts +0 -86
  68. package/dist/types/types.js +0 -41
@@ -0,0 +1,5 @@
1
+ import { ChainSlug } from "@socket.tech/dl-core";
2
+ export declare const getConfirmations: (chainSlug: ChainSlug) => number;
3
+ export declare const Confirmations: {
4
+ [chain: number]: number;
5
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Confirmations = exports.getConfirmations = void 0;
4
+ const dl_core_1 = require("@socket.tech/dl-core");
5
+ const getConfirmations = (chainSlug) => {
6
+ if (dl_core_1.TestnetIds.includes(chainSlug)) {
7
+ return 1;
8
+ }
9
+ return exports.Confirmations[chainSlug];
10
+ };
11
+ exports.getConfirmations = getConfirmations;
12
+ exports.Confirmations = {
13
+ [dl_core_1.ChainSlug.MAINNET]: 12,
14
+ [dl_core_1.ChainSlug.ARBITRUM]: 1,
15
+ [dl_core_1.ChainSlug.OPTIMISM]: 18,
16
+ [dl_core_1.ChainSlug.AEVO]: 18,
17
+ };
@@ -15,7 +15,11 @@ export declare enum MessageStatuses {
15
15
  PROPOSED = "PROPOSED",
16
16
  CONFIRMED = "CONFIRMED",
17
17
  EXECUTION_SUCCESS = "EXECUTION_SUCCESS",
18
- EXECUTION_FAILURE = "EXECUTION_FAILURE"
18
+ EXECUTION_FAILURE = "EXECUTION_FAILURE",
19
+ VERIFIED = "VERIFIED",
20
+ ATTESTED = "ATTESTED",
21
+ EXECUTING = "EXECUTING",
22
+ INBOUND_REVERTING = "INBOUND_REVERTING"
19
23
  }
20
24
  export declare enum MessageStatusStep {
21
25
  RECEIVED = 0,
@@ -29,5 +33,11 @@ export declare enum StatusCodes {
29
33
  SUCCESS = "SUCCESS",
30
34
  NOT_FOUND = "NOT_FOUND",
31
35
  BAD_REQUEST = "BAD_REQUEST",
32
- INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
36
+ UNAUTHORIZED = "UNAUTHORIZED",
37
+ INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR",
38
+ RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED"
39
+ }
40
+ export declare enum Accounts {
41
+ dl = "dl",
42
+ ll = "ll"
33
43
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StatusCodes = exports.MessageStatusStep = exports.MessageStatuses = exports.tableNames = void 0;
3
+ exports.Accounts = exports.StatusCodes = exports.MessageStatusStep = exports.MessageStatuses = exports.tableNames = void 0;
4
4
  var tableNames;
5
5
  (function (tableNames) {
6
6
  tableNames["packet"] = "packets";
@@ -21,6 +21,10 @@ var MessageStatuses;
21
21
  MessageStatuses["CONFIRMED"] = "CONFIRMED";
22
22
  MessageStatuses["EXECUTION_SUCCESS"] = "EXECUTION_SUCCESS";
23
23
  MessageStatuses["EXECUTION_FAILURE"] = "EXECUTION_FAILURE";
24
+ MessageStatuses["VERIFIED"] = "VERIFIED";
25
+ MessageStatuses["ATTESTED"] = "ATTESTED";
26
+ MessageStatuses["EXECUTING"] = "EXECUTING";
27
+ MessageStatuses["INBOUND_REVERTING"] = "INBOUND_REVERTING";
24
28
  })(MessageStatuses || (exports.MessageStatuses = MessageStatuses = {}));
25
29
  var MessageStatusStep;
26
30
  (function (MessageStatusStep) {
@@ -36,5 +40,12 @@ var StatusCodes;
36
40
  StatusCodes["SUCCESS"] = "SUCCESS";
37
41
  StatusCodes["NOT_FOUND"] = "NOT_FOUND";
38
42
  StatusCodes["BAD_REQUEST"] = "BAD_REQUEST";
43
+ StatusCodes["UNAUTHORIZED"] = "UNAUTHORIZED";
39
44
  StatusCodes["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
45
+ StatusCodes["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
40
46
  })(StatusCodes || (exports.StatusCodes = StatusCodes = {}));
47
+ var Accounts;
48
+ (function (Accounts) {
49
+ Accounts["dl"] = "dl";
50
+ Accounts["ll"] = "ll";
51
+ })(Accounts || (exports.Accounts = Accounts = {}));
@@ -1,6 +1,6 @@
1
1
  import { TripReason } from "../models";
2
2
  import { StatusCodes } from "./enums";
3
- import { ChainSlug, IntegrationTypes } from "@socket.tech/dl-core";
3
+ import { IntegrationTypes } from "@socket.tech/dl-core";
4
4
  export type Speed = "safeLow" | "average" | "fast" | "fastest";
5
5
  export declare enum InboundStatus {
6
6
  NOT_TRIED = "NOT_TRIED",
@@ -17,8 +17,16 @@ export interface FeeEstimate {
17
17
  export declare enum RelayerAPIStatus {
18
18
  FAILED = "FAILED",
19
19
  SIMULATION_FAILED = "SIMULATION_FAILED",
20
- COMPLETED = "COMPLETED"
20
+ COMPLETED = "COMPLETED",
21
+ DUPLICATE_NONCE_TX = "DUPLICATE_NONCE_TX"
21
22
  }
23
+ export declare const ErrorReasons: {
24
+ ZERO_AMOUNT: string;
25
+ PRE_EXEC_VALIDATION_ERROR: string;
26
+ WRONG_PLUG_CONNECTION: string;
27
+ INBOUND_FAILURE: string;
28
+ LOW_GAS_LIMIT: string;
29
+ };
22
30
  export declare class ServerError {
23
31
  code: Omit<StatusCodes, StatusCodes.SUCCESS>;
24
32
  message?: string;
@@ -37,6 +45,7 @@ export type SealParams = {
37
45
  srcChainSlug: number;
38
46
  dstChainSlug: number;
39
47
  dstSwitchboard: string;
48
+ srcSwitchboard: string;
40
49
  integrationType: IntegrationTypes;
41
50
  message: {
42
51
  messageId: string;
@@ -84,7 +93,7 @@ export interface ExecuteSigResponse {
84
93
  }
85
94
  export interface AttestRequest {
86
95
  switchboardAddress: string;
87
- dstChainSlug: ChainSlug;
96
+ dstChainSlug: number;
88
97
  packetId: string;
89
98
  root: string;
90
99
  proposalCount: number;
@@ -94,6 +103,8 @@ export interface AttestSuccess {
94
103
  packetId: string;
95
104
  proposalCount: number;
96
105
  signature: string;
106
+ digest: string;
107
+ signerAddress: string;
97
108
  }
98
109
  export interface AttestFailure {
99
110
  proposalValid: false;
@@ -102,3 +113,14 @@ export interface AttestFailure {
102
113
  reason: TripReason;
103
114
  }
104
115
  export type AttestResponse = AttestSuccess | AttestFailure;
116
+ export type MessageData = {
117
+ messageId: string;
118
+ destPlug: string;
119
+ srcPlug: string;
120
+ dstChainSlug: number;
121
+ srcChainSlug: number;
122
+ payload: string;
123
+ minMsgGasLimit: string;
124
+ executionParams: string;
125
+ packedMessage: string;
126
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InternalServerError = exports.BadRequestError = exports.ServerError = exports.RelayerAPIStatus = exports.InboundStatus = void 0;
3
+ exports.InternalServerError = exports.BadRequestError = exports.ServerError = exports.ErrorReasons = exports.RelayerAPIStatus = exports.InboundStatus = void 0;
4
4
  const enums_1 = require("./enums");
5
5
  var InboundStatus;
6
6
  (function (InboundStatus) {
@@ -14,7 +14,15 @@ var RelayerAPIStatus;
14
14
  RelayerAPIStatus["FAILED"] = "FAILED";
15
15
  RelayerAPIStatus["SIMULATION_FAILED"] = "SIMULATION_FAILED";
16
16
  RelayerAPIStatus["COMPLETED"] = "COMPLETED";
17
+ RelayerAPIStatus["DUPLICATE_NONCE_TX"] = "DUPLICATE_NONCE_TX";
17
18
  })(RelayerAPIStatus || (exports.RelayerAPIStatus = RelayerAPIStatus = {}));
19
+ exports.ErrorReasons = {
20
+ ZERO_AMOUNT: "ZERO_AMOUNT",
21
+ PRE_EXEC_VALIDATION_ERROR: "PRE_EXEC_VALIDATION_ERROR",
22
+ WRONG_PLUG_CONNECTION: "WRONG_PLUG_CONNECTION",
23
+ INBOUND_FAILURE: "INBOUND_FAILURE",
24
+ LOW_GAS_LIMIT: "LOW_GAS_LIMIT",
25
+ };
18
26
  class ServerError {
19
27
  constructor(code, message) {
20
28
  this.code = code;
@@ -1,5 +1,6 @@
1
1
  import { ChainSlug, IntegrationTypes } from "@socket.tech/dl-core";
2
2
  export declare const getWaitTime: (integrationType: IntegrationTypes, srcChainSlug: ChainSlug, dstChainSlug: ChainSlug) => number;
3
+ export declare const getNativeWaitTime: (srcChainSlug: ChainSlug, dstChainSlug: ChainSlug) => number;
3
4
  export declare const NativeWaitTime: {
4
5
  [srcChain in ChainSlug]?: {
5
6
  [dstChain in ChainSlug]?: number;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NativeWaitTime = exports.getWaitTime = void 0;
3
+ exports.NativeWaitTime = exports.getNativeWaitTime = exports.getWaitTime = void 0;
4
4
  const dl_core_1 = require("@socket.tech/dl-core");
5
5
  const getWaitTime = (integrationType, srcChainSlug, dstChainSlug) => {
6
- var _a, _b;
7
6
  switch (integrationType) {
8
7
  case dl_core_1.IntegrationTypes.fast:
9
8
  return 0;
@@ -12,13 +11,17 @@ const getWaitTime = (integrationType, srcChainSlug, dstChainSlug) => {
12
11
  case dl_core_1.IntegrationTypes.optimistic:
13
12
  return 2 * 3600;
14
13
  case dl_core_1.IntegrationTypes.native:
15
- return (_b = (_a = exports.NativeWaitTime[srcChainSlug]) === null || _a === void 0 ? void 0 : _a[dstChainSlug]) !== null && _b !== void 0 ? _b : 2 * 3600;
14
+ return (0, exports.getNativeWaitTime)(srcChainSlug, dstChainSlug);
16
15
  default:
17
16
  return 0;
18
- break;
19
17
  }
20
18
  };
21
19
  exports.getWaitTime = getWaitTime;
20
+ const getNativeWaitTime = (srcChainSlug, dstChainSlug) => {
21
+ var _a, _b;
22
+ return (_b = (_a = exports.NativeWaitTime[srcChainSlug]) === null || _a === void 0 ? void 0 : _a[dstChainSlug]) !== null && _b !== void 0 ? _b : 0;
23
+ };
24
+ exports.getNativeWaitTime = getNativeWaitTime;
22
25
  exports.NativeWaitTime = {
23
26
  [dl_core_1.ChainSlug.OPTIMISM_GOERLI]: {
24
27
  [dl_core_1.ChainSlug.GOERLI]: 5 * 60,
@@ -43,9 +46,4 @@ exports.NativeWaitTime = {
43
46
  [dl_core_1.ChainSlug.POLYGON_MAINNET]: {
44
47
  [dl_core_1.ChainSlug.MAINNET]: 4 * 3600,
45
48
  },
46
- [dl_core_1.ChainSlug.MAINNET]: {
47
- [dl_core_1.ChainSlug.ARBITRUM]: 10 * 60,
48
- [dl_core_1.ChainSlug.OPTIMISM]: 10 * 60,
49
- [dl_core_1.ChainSlug.POLYGON_MAINNET]: 10 * 60,
50
- },
51
49
  };
@@ -33,10 +33,10 @@ export declare const AttestationModel: {
33
33
  type: DataTypes.StringDataTypeConstructor;
34
34
  };
35
35
  srcChainSlug: {
36
- type: DataTypes.IntegerDataTypeConstructor;
36
+ type: DataTypes.BigIntDataTypeConstructor;
37
37
  };
38
38
  dstChainSlug: {
39
- type: DataTypes.IntegerDataTypeConstructor;
39
+ type: DataTypes.BigIntDataTypeConstructor;
40
40
  };
41
41
  integrationType: {
42
42
  type: DataTypes.StringDataTypeConstructor;
@@ -24,10 +24,10 @@ exports.AttestationModel = {
24
24
  type: sequelize_1.DataTypes.STRING,
25
25
  },
26
26
  srcChainSlug: {
27
- type: sequelize_1.DataTypes.INTEGER,
27
+ type: sequelize_1.DataTypes.BIGINT,
28
28
  },
29
29
  dstChainSlug: {
30
- type: sequelize_1.DataTypes.INTEGER,
30
+ type: sequelize_1.DataTypes.BIGINT,
31
31
  },
32
32
  integrationType: {
33
33
  type: sequelize_1.DataTypes.STRING,
@@ -3,3 +3,4 @@ export * from "./message";
3
3
  export * from "./attestSignature";
4
4
  export * from "./attestation";
5
5
  export * from "./proposal";
6
+ export * from "./switchboard";
@@ -19,3 +19,4 @@ __exportStar(require("./message"), exports);
19
19
  __exportStar(require("./attestSignature"), exports);
20
20
  __exportStar(require("./attestation"), exports);
21
21
  __exportStar(require("./proposal"), exports);
22
+ __exportStar(require("./switchboard"), exports);
@@ -0,0 +1,28 @@
1
+ import { DataTypes, Model } from "sequelize";
2
+ export declare class LastBlock extends Model {
3
+ id: number;
4
+ chainSlug: number;
5
+ blockNumber: number;
6
+ isFullySynced: boolean;
7
+ isActive: boolean;
8
+ }
9
+ export declare const LastBlockModel: {
10
+ id: {
11
+ type: DataTypes.IntegerDataTypeConstructor;
12
+ autoIncrement: boolean;
13
+ };
14
+ chainSlug: {
15
+ type: DataTypes.BigIntDataTypeConstructor;
16
+ primaryKey: boolean;
17
+ };
18
+ blockNumber: {
19
+ type: DataTypes.IntegerDataTypeConstructor;
20
+ };
21
+ isFullySynced: {
22
+ type: DataTypes.AbstractDataTypeConstructor;
23
+ };
24
+ isActive: {
25
+ type: DataTypes.AbstractDataTypeConstructor;
26
+ defaultValue: boolean;
27
+ };
28
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LastBlockModel = exports.LastBlock = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ class LastBlock extends sequelize_1.Model {
6
+ }
7
+ exports.LastBlock = LastBlock;
8
+ exports.LastBlockModel = {
9
+ id: {
10
+ type: sequelize_1.DataTypes.INTEGER,
11
+ autoIncrement: true,
12
+ },
13
+ chainSlug: {
14
+ type: sequelize_1.DataTypes.BIGINT,
15
+ primaryKey: true,
16
+ },
17
+ blockNumber: {
18
+ type: sequelize_1.DataTypes.INTEGER,
19
+ },
20
+ isFullySynced: {
21
+ type: sequelize_1.DataTypes.BOOLEAN,
22
+ },
23
+ isActive: {
24
+ type: sequelize_1.DataTypes.BOOLEAN,
25
+ defaultValue: true,
26
+ },
27
+ };
@@ -49,10 +49,10 @@ export declare const MessageModel: {
49
49
  autoIncrement: boolean;
50
50
  };
51
51
  srcChainSlug: {
52
- type: DataTypes.IntegerDataTypeConstructor;
52
+ type: DataTypes.BigIntDataTypeConstructor;
53
53
  };
54
54
  dstChainSlug: {
55
- type: DataTypes.IntegerDataTypeConstructor;
55
+ type: DataTypes.BigIntDataTypeConstructor;
56
56
  };
57
57
  srcPlug: {
58
58
  type: DataTypes.StringDataTypeConstructor;
@@ -20,10 +20,10 @@ exports.MessageModel = {
20
20
  autoIncrement: true,
21
21
  },
22
22
  srcChainSlug: {
23
- type: sequelize_1.DataTypes.INTEGER,
23
+ type: sequelize_1.DataTypes.BIGINT,
24
24
  },
25
25
  dstChainSlug: {
26
- type: sequelize_1.DataTypes.INTEGER,
26
+ type: sequelize_1.DataTypes.BIGINT,
27
27
  },
28
28
  srcPlug: {
29
29
  type: sequelize_1.DataTypes.STRING,
@@ -34,6 +34,7 @@ export declare enum TripReason {
34
34
  }
35
35
  export declare class Packet extends Model {
36
36
  id: number;
37
+ switchboardId: string;
37
38
  packetId: string;
38
39
  srcChainSlug: number;
39
40
  dstChainSlug: number;
@@ -63,6 +64,7 @@ export declare class Packet extends Model {
63
64
  attestRelayStatus: AttestRelayStatus;
64
65
  outboundTxHash: string;
65
66
  outboundTime: number;
67
+ sealIndexTime: number;
66
68
  proposeTime: number;
67
69
  attestTime: number;
68
70
  packetTripTxHash: string;
@@ -81,10 +83,10 @@ export declare const PacketModel: {
81
83
  autoIncrement: boolean;
82
84
  };
83
85
  srcChainSlug: {
84
- type: DataTypes.IntegerDataTypeConstructor;
86
+ type: DataTypes.BigIntDataTypeConstructor;
85
87
  };
86
88
  dstChainSlug: {
87
- type: DataTypes.IntegerDataTypeConstructor;
89
+ type: DataTypes.BigIntDataTypeConstructor;
88
90
  };
89
91
  srcCapacitor: {
90
92
  type: DataTypes.StringDataTypeConstructor;
@@ -92,6 +94,9 @@ export declare const PacketModel: {
92
94
  dstSwitchboard: {
93
95
  type: DataTypes.StringDataTypeConstructor;
94
96
  };
97
+ switchboardId: {
98
+ type: DataTypes.StringDataTypeConstructor;
99
+ };
95
100
  integrationType: {
96
101
  type: DataTypes.EnumDataTypeConstructor;
97
102
  values: IntegrationTypes[];
@@ -165,6 +170,9 @@ export declare const PacketModel: {
165
170
  sealTime: {
166
171
  type: DataTypes.IntegerDataTypeConstructor;
167
172
  };
173
+ sealIndexTime: {
174
+ type: DataTypes.IntegerDataTypeConstructor;
175
+ };
168
176
  sealSignature: {
169
177
  type: DataTypes.StringDataTypeConstructor;
170
178
  };
@@ -50,10 +50,10 @@ exports.PacketModel = {
50
50
  autoIncrement: true,
51
51
  },
52
52
  srcChainSlug: {
53
- type: sequelize_1.DataTypes.INTEGER,
53
+ type: sequelize_1.DataTypes.BIGINT,
54
54
  },
55
55
  dstChainSlug: {
56
- type: sequelize_1.DataTypes.INTEGER,
56
+ type: sequelize_1.DataTypes.BIGINT,
57
57
  },
58
58
  srcCapacitor: {
59
59
  type: sequelize_1.DataTypes.STRING,
@@ -61,6 +61,9 @@ exports.PacketModel = {
61
61
  dstSwitchboard: {
62
62
  type: sequelize_1.DataTypes.STRING,
63
63
  },
64
+ switchboardId: {
65
+ type: sequelize_1.DataTypes.STRING,
66
+ },
64
67
  integrationType: {
65
68
  type: sequelize_1.DataTypes.ENUM,
66
69
  values: [...Object.values(dl_core_1.IntegrationTypes)],
@@ -134,6 +137,9 @@ exports.PacketModel = {
134
137
  sealTime: {
135
138
  type: sequelize_1.DataTypes.INTEGER,
136
139
  },
140
+ sealIndexTime: {
141
+ type: sequelize_1.DataTypes.INTEGER,
142
+ },
137
143
  sealSignature: {
138
144
  type: sequelize_1.DataTypes.STRING,
139
145
  },
@@ -223,6 +229,9 @@ function processStrings(packet) {
223
229
  if (packet.dstSwitchboard) {
224
230
  packet.dstSwitchboard = (0, utils_1.toLowerCase)(packet.dstSwitchboard);
225
231
  }
232
+ if (packet.switchboardId) {
233
+ packet.switchboardId = (0, utils_1.toLowerCase)(packet.switchboardId);
234
+ }
226
235
  if (packet.packetTripTxHash) {
227
236
  packet.packetTripTxHash = (0, utils_1.toLowerCase)(packet.packetTripTxHash);
228
237
  }
@@ -51,10 +51,10 @@ export declare const ProposalModel: {
51
51
  primaryKey: boolean;
52
52
  };
53
53
  srcChainSlug: {
54
- type: DataTypes.IntegerDataTypeConstructor;
54
+ type: DataTypes.BigIntDataTypeConstructor;
55
55
  };
56
56
  dstChainSlug: {
57
- type: DataTypes.IntegerDataTypeConstructor;
57
+ type: DataTypes.BigIntDataTypeConstructor;
58
58
  };
59
59
  packetId: {
60
60
  type: DataTypes.StringDataTypeConstructor;
@@ -40,10 +40,10 @@ exports.ProposalModel = {
40
40
  primaryKey: true,
41
41
  },
42
42
  srcChainSlug: {
43
- type: sequelize_1.DataTypes.INTEGER,
43
+ type: sequelize_1.DataTypes.BIGINT,
44
44
  },
45
45
  dstChainSlug: {
46
- type: sequelize_1.DataTypes.INTEGER,
46
+ type: sequelize_1.DataTypes.BIGINT,
47
47
  },
48
48
  packetId: {
49
49
  type: sequelize_1.DataTypes.STRING,
@@ -0,0 +1,69 @@
1
+ import { IntegrationTypes } from "@socket.tech/dl-core";
2
+ import { DataTypes, Model } from "sequelize";
3
+ export declare enum CapacitorType {
4
+ singleCapacitor = "1",
5
+ hashChainCapacitor = "2"
6
+ }
7
+ export declare class Switchboard extends Model {
8
+ id: number;
9
+ switchboardId: string;
10
+ srcChainSlug: number;
11
+ dstChainSlug: number;
12
+ maxPacketLength: number;
13
+ srcSwitchboard: string;
14
+ dstSwitchboard: string;
15
+ srcCapacitor: string;
16
+ srcDecapacitor: string;
17
+ capacitorType: CapacitorType;
18
+ isEnabled: boolean;
19
+ integrationType: IntegrationTypes;
20
+ }
21
+ export declare const SwitchboardModel: {
22
+ id: {
23
+ type: DataTypes.IntegerDataTypeConstructor;
24
+ autoIncrement: boolean;
25
+ primaryKey: boolean;
26
+ };
27
+ switchboardId: {
28
+ type: DataTypes.StringDataTypeConstructor;
29
+ };
30
+ srcChainSlug: {
31
+ type: DataTypes.BigIntDataTypeConstructor;
32
+ unique: string;
33
+ };
34
+ dstChainSlug: {
35
+ type: DataTypes.BigIntDataTypeConstructor;
36
+ unique: string;
37
+ };
38
+ maxPacketLength: {
39
+ type: DataTypes.IntegerDataTypeConstructor;
40
+ };
41
+ srcSwitchboard: {
42
+ type: DataTypes.StringDataTypeConstructor;
43
+ unique: string;
44
+ };
45
+ dstSwitchboard: {
46
+ type: DataTypes.StringDataTypeConstructor;
47
+ };
48
+ srcCapacitor: {
49
+ type: DataTypes.StringDataTypeConstructor;
50
+ };
51
+ srcDecapacitor: {
52
+ type: DataTypes.StringDataTypeConstructor;
53
+ };
54
+ capacitorType: {
55
+ type: DataTypes.EnumDataTypeConstructor;
56
+ values: CapacitorType[];
57
+ defaultValue: CapacitorType;
58
+ };
59
+ isEnabled: {
60
+ type: DataTypes.AbstractDataTypeConstructor;
61
+ defaultValue: boolean;
62
+ };
63
+ integrationType: {
64
+ type: DataTypes.EnumDataTypeConstructor;
65
+ values: IntegrationTypes[];
66
+ defaultValue: IntegrationTypes;
67
+ };
68
+ };
69
+ export declare const addSwitchboardHooks: () => Promise<void>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSwitchboardHooks = exports.SwitchboardModel = exports.Switchboard = exports.CapacitorType = void 0;
4
+ const dl_core_1 = require("@socket.tech/dl-core");
5
+ const sequelize_1 = require("sequelize");
6
+ const __1 = require("..");
7
+ var CapacitorType;
8
+ (function (CapacitorType) {
9
+ CapacitorType["singleCapacitor"] = "1";
10
+ CapacitorType["hashChainCapacitor"] = "2";
11
+ })(CapacitorType || (exports.CapacitorType = CapacitorType = {}));
12
+ class Switchboard extends sequelize_1.Model {
13
+ }
14
+ exports.Switchboard = Switchboard;
15
+ exports.SwitchboardModel = {
16
+ id: {
17
+ type: sequelize_1.DataTypes.INTEGER,
18
+ autoIncrement: true,
19
+ primaryKey: true,
20
+ },
21
+ switchboardId: {
22
+ type: sequelize_1.DataTypes.STRING,
23
+ },
24
+ srcChainSlug: {
25
+ type: sequelize_1.DataTypes.BIGINT,
26
+ unique: "uniqueSwitchboardPointer",
27
+ },
28
+ dstChainSlug: {
29
+ type: sequelize_1.DataTypes.BIGINT,
30
+ unique: "uniqueSwitchboardPointer",
31
+ },
32
+ maxPacketLength: {
33
+ type: sequelize_1.DataTypes.INTEGER,
34
+ },
35
+ srcSwitchboard: {
36
+ type: sequelize_1.DataTypes.STRING,
37
+ unique: "uniqueSwitchboardPointer",
38
+ },
39
+ dstSwitchboard: {
40
+ type: sequelize_1.DataTypes.STRING,
41
+ },
42
+ srcCapacitor: {
43
+ type: sequelize_1.DataTypes.STRING,
44
+ },
45
+ srcDecapacitor: {
46
+ type: sequelize_1.DataTypes.STRING,
47
+ },
48
+ capacitorType: {
49
+ type: sequelize_1.DataTypes.ENUM,
50
+ values: [...Object.values(CapacitorType)],
51
+ defaultValue: CapacitorType.singleCapacitor,
52
+ },
53
+ isEnabled: {
54
+ type: sequelize_1.DataTypes.BOOLEAN,
55
+ defaultValue: false,
56
+ },
57
+ integrationType: {
58
+ type: sequelize_1.DataTypes.ENUM,
59
+ values: [...Object.values(dl_core_1.IntegrationTypes)],
60
+ defaultValue: dl_core_1.IntegrationTypes.unknown,
61
+ },
62
+ };
63
+ const addSwitchboardHooks = async () => {
64
+ Switchboard.beforeBulkCreate((switchboards, options) => {
65
+ for (let index = 0; index < switchboards.length; index++) {
66
+ switchboards[index] = processStrings(switchboards[index]);
67
+ switchboards[index] = createSwitchboardId(switchboards[index]);
68
+ }
69
+ });
70
+ Switchboard.beforeSave((switchboard, options) => {
71
+ switchboard = processStrings(switchboard);
72
+ });
73
+ };
74
+ exports.addSwitchboardHooks = addSwitchboardHooks;
75
+ function processStrings(switchboard) {
76
+ if (switchboard.srcSwitchboard)
77
+ switchboard.srcSwitchboard = (0, __1.toLowerCase)(switchboard.srcSwitchboard);
78
+ if (switchboard.dstSwitchboard)
79
+ switchboard.dstSwitchboard = (0, __1.toLowerCase)(switchboard.dstSwitchboard);
80
+ if (switchboard.srcCapacitor)
81
+ switchboard.srcCapacitor = (0, __1.toLowerCase)(switchboard.srcCapacitor);
82
+ if (switchboard.srcDecapacitor)
83
+ switchboard.srcDecapacitor = (0, __1.toLowerCase)(switchboard.srcDecapacitor);
84
+ return switchboard;
85
+ }
86
+ function createSwitchboardId(switchboard) {
87
+ if (switchboard.srcSwitchboard &&
88
+ switchboard.srcChainSlug &&
89
+ switchboard.dstChainSlug)
90
+ switchboard.switchboardId = `${switchboard.srcChainSlug}-${switchboard.dstChainSlug}-${switchboard.srcSwitchboard.toLowerCase()}`;
91
+ return switchboard;
92
+ }
File without changes