@socket.tech/dl-common 1.0.14 → 1.0.16
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.
- package/dist/dl-common/utils/signer/adapter.d.ts +3 -1
- package/dist/dl-common/utils/signer/adapter.js +5 -0
- package/dist/dl-common/utils/signer/adapter.js.map +1 -1
- package/dist/dl-common/utils/signer/kms-ethers-signer.d.ts +3 -1
- package/dist/dl-common/utils/signer/kms-ethers-signer.js +5 -0
- package/dist/dl-common/utils/signer/kms-ethers-signer.js.map +1 -1
- package/dist/dl-common/utils/signer/kms-signer.d.ts +2 -0
- package/dist/dl-common/utils/signer/kms-signer.js +7 -0
- package/dist/dl-common/utils/signer/kms-signer.js.map +1 -1
- package/dist/dl-common/utils/signer/signer.d.ts +2 -0
- package/dist/src/services/sealService.js +12 -0
- package/dist/src/services/sealService.js.map +1 -1
- package/package.json +3 -3
- package/dist/constants/confirmations.d.ts +0 -5
- package/dist/constants/confirmations.js +0 -17
- package/dist/constants/enums.d.ts +0 -38
- package/dist/constants/enums.js +0 -45
- package/dist/constants/index.d.ts +0 -3
- package/dist/constants/index.js +0 -19
- package/dist/constants/types.d.ts +0 -126
- package/dist/constants/types.js +0 -45
- package/dist/constants/waitTime.d.ts +0 -8
- package/dist/constants/waitTime.js +0 -49
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -36
- package/dist/models/attestSignature.d.ts +0 -35
- package/dist/models/attestSignature.js +0 -53
- package/dist/models/attestation.d.ts +0 -70
- package/dist/models/attestation.js +0 -86
- package/dist/models/index.d.ts +0 -6
- package/dist/models/index.js +0 -22
- package/dist/models/message.d.ts +0 -166
- package/dist/models/message.js +0 -183
- package/dist/models/packet.d.ts +0 -241
- package/dist/models/packet.js +0 -250
- package/dist/models/proposal.d.ts +0 -127
- package/dist/models/proposal.js +0 -141
- package/dist/models/switchboard.d.ts +0 -69
- package/dist/models/switchboard.js +0 -92
- package/dist/services/cacheService.d.ts +0 -14
- package/dist/services/cacheService.js +0 -77
- package/dist/services/eventBridgeService.d.ts +0 -8
- package/dist/services/eventBridgeService.js +0 -39
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.js +0 -20
- package/dist/services/queueService.d.ts +0 -10
- package/dist/services/queueService.js +0 -54
- package/dist/utils/address.d.ts +0 -2
- package/dist/utils/address.js +0 -8
- package/dist/utils/axios.d.ts +0 -2
- package/dist/utils/axios.js +0 -54
- package/dist/utils/dataStructHelper.d.ts +0 -2
- package/dist/utils/dataStructHelper.js +0 -10
- package/dist/utils/discord.d.ts +0 -2
- package/dist/utils/discord.js +0 -35
- package/dist/utils/ethersAwsKmsSigner.d.ts +0 -2
- package/dist/utils/ethersAwsKmsSigner.js +0 -26
- package/dist/utils/eventGetter.d.ts +0 -4
- package/dist/utils/eventGetter.js +0 -50
- package/dist/utils/extraUtils.d.ts +0 -32
- package/dist/utils/extraUtils.js +0 -103
- package/dist/utils/idUtils.d.ts +0 -14
- package/dist/utils/idUtils.js +0 -50
- package/dist/utils/index.d.ts +0 -13
- package/dist/utils/index.js +0 -29
- package/dist/utils/relaySigner.d.ts +0 -21
- package/dist/utils/relaySigner.js +0 -68
- package/dist/utils/s3Service.d.ts +0 -4
- package/dist/utils/s3Service.js +0 -41
- package/dist/utils/secretManagerService.d.ts +0 -2
- package/dist/utils/secretManagerService.js +0 -33
- package/dist/utils/signer/adapter.d.ts +0 -18
- package/dist/utils/signer/adapter.js +0 -71
- package/dist/utils/signer/address.d.ts +0 -10
- package/dist/utils/signer/address.js +0 -42
- package/dist/utils/signer/asn1-parser.d.ts +0 -11
- package/dist/utils/signer/asn1-parser.js +0 -80
- package/dist/utils/signer/crypto.d.ts +0 -6
- package/dist/utils/signer/crypto.js +0 -34
- package/dist/utils/signer/index.d.ts +0 -4
- package/dist/utils/signer/index.js +0 -20
- package/dist/utils/signer/kms-ethers-signer.d.ts +0 -19
- package/dist/utils/signer/kms-ethers-signer.js +0 -32
- package/dist/utils/signer/kms-signer.d.ts +0 -14
- package/dist/utils/signer/kms-signer.js +0 -46
- package/dist/utils/signer/signature.d.ts +0 -17
- package/dist/utils/signer/signature.js +0 -65
- package/dist/utils/signer/signer.d.ts +0 -7
- package/dist/utils/signer/signer.js +0 -2
- package/dist/utils/time.d.ts +0 -2
- package/dist/utils/time.js +0 -7
package/dist/models/proposal.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addProposalHooks = exports.ProposalModel = exports.Proposal = exports.ProposalTripRelayStatus = exports.MatchState = exports.RootMatchState = exports.TripStatus = void 0;
|
|
4
|
-
const sequelize_1 = require("sequelize");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
var TripStatus;
|
|
7
|
-
(function (TripStatus) {
|
|
8
|
-
TripStatus["TRIP_REQUIRED"] = "TRIP_REQUIRED";
|
|
9
|
-
TripStatus["TRIP_INITIATED"] = "TRIP_INITIATED";
|
|
10
|
-
TripStatus["TRIP_SUCCESSFUL"] = "TRIP_SUCCESSFUL";
|
|
11
|
-
TripStatus["TRIP_FAILED"] = "TRIP_FAILED";
|
|
12
|
-
TripStatus["NO"] = "NO";
|
|
13
|
-
})(TripStatus || (exports.TripStatus = TripStatus = {}));
|
|
14
|
-
var RootMatchState;
|
|
15
|
-
(function (RootMatchState) {
|
|
16
|
-
RootMatchState["ROOTS_MATCHED"] = "ROOTS_MATCHED";
|
|
17
|
-
RootMatchState["ROOTS_MISMATCHED"] = "ROOTS_MISMATCHED";
|
|
18
|
-
RootMatchState["NO"] = "NO";
|
|
19
|
-
})(RootMatchState || (exports.RootMatchState = RootMatchState = {}));
|
|
20
|
-
var MatchState;
|
|
21
|
-
(function (MatchState) {
|
|
22
|
-
MatchState["MATCHED"] = "MATCHED";
|
|
23
|
-
MatchState["MISMATCHED"] = "MISMATCHED";
|
|
24
|
-
MatchState["NO"] = "NO";
|
|
25
|
-
})(MatchState || (exports.MatchState = MatchState = {}));
|
|
26
|
-
var ProposalTripRelayStatus;
|
|
27
|
-
(function (ProposalTripRelayStatus) {
|
|
28
|
-
ProposalTripRelayStatus["IS_TRIPPING"] = "IS_TRIPPING";
|
|
29
|
-
ProposalTripRelayStatus["NO"] = "NO";
|
|
30
|
-
ProposalTripRelayStatus["TRIPPING_FAILED"] = "TRIPPING_FAILED";
|
|
31
|
-
ProposalTripRelayStatus["TRIPPED"] = "TRIPPED";
|
|
32
|
-
})(ProposalTripRelayStatus || (exports.ProposalTripRelayStatus = ProposalTripRelayStatus = {}));
|
|
33
|
-
class Proposal extends sequelize_1.Model {
|
|
34
|
-
}
|
|
35
|
-
exports.Proposal = Proposal;
|
|
36
|
-
exports.ProposalModel = {
|
|
37
|
-
id: {
|
|
38
|
-
type: sequelize_1.DataTypes.INTEGER,
|
|
39
|
-
autoIncrement: true,
|
|
40
|
-
primaryKey: true,
|
|
41
|
-
},
|
|
42
|
-
srcChainSlug: {
|
|
43
|
-
type: sequelize_1.DataTypes.BIGINT,
|
|
44
|
-
},
|
|
45
|
-
dstChainSlug: {
|
|
46
|
-
type: sequelize_1.DataTypes.BIGINT,
|
|
47
|
-
},
|
|
48
|
-
packetId: {
|
|
49
|
-
type: sequelize_1.DataTypes.STRING,
|
|
50
|
-
unique: "uniqueProposalPointer",
|
|
51
|
-
},
|
|
52
|
-
proposalCount: {
|
|
53
|
-
type: sequelize_1.DataTypes.INTEGER,
|
|
54
|
-
unique: "uniqueProposalPointer",
|
|
55
|
-
},
|
|
56
|
-
root: {
|
|
57
|
-
type: sequelize_1.DataTypes.STRING,
|
|
58
|
-
},
|
|
59
|
-
switchboard: {
|
|
60
|
-
type: sequelize_1.DataTypes.STRING,
|
|
61
|
-
unique: "uniqueProposalPointer",
|
|
62
|
-
},
|
|
63
|
-
proposer: {
|
|
64
|
-
type: sequelize_1.DataTypes.STRING,
|
|
65
|
-
},
|
|
66
|
-
proposeTxHash: {
|
|
67
|
-
type: sequelize_1.DataTypes.STRING,
|
|
68
|
-
defaultValue: "",
|
|
69
|
-
},
|
|
70
|
-
proposeTime: {
|
|
71
|
-
type: sequelize_1.DataTypes.INTEGER,
|
|
72
|
-
},
|
|
73
|
-
tripTxId: {
|
|
74
|
-
type: sequelize_1.DataTypes.STRING,
|
|
75
|
-
defaultValue: "",
|
|
76
|
-
},
|
|
77
|
-
tripTxHash: {
|
|
78
|
-
type: sequelize_1.DataTypes.STRING,
|
|
79
|
-
defaultValue: "",
|
|
80
|
-
},
|
|
81
|
-
tripTime: {
|
|
82
|
-
type: sequelize_1.DataTypes.INTEGER,
|
|
83
|
-
},
|
|
84
|
-
tripErrorMessage: {
|
|
85
|
-
type: sequelize_1.DataTypes.STRING,
|
|
86
|
-
defaultValue: "",
|
|
87
|
-
},
|
|
88
|
-
isTripped: {
|
|
89
|
-
type: sequelize_1.DataTypes.BOOLEAN,
|
|
90
|
-
defaultValue: false,
|
|
91
|
-
},
|
|
92
|
-
tripRelayStatus: {
|
|
93
|
-
type: sequelize_1.DataTypes.ENUM,
|
|
94
|
-
values: [...Object.values(ProposalTripRelayStatus)],
|
|
95
|
-
defaultValue: ProposalTripRelayStatus.NO,
|
|
96
|
-
},
|
|
97
|
-
totalAttestations: {
|
|
98
|
-
type: sequelize_1.DataTypes.INTEGER,
|
|
99
|
-
defaultValue: 0,
|
|
100
|
-
},
|
|
101
|
-
rootMatchState: {
|
|
102
|
-
type: sequelize_1.DataTypes.ENUM,
|
|
103
|
-
values: [...Object.values(RootMatchState)],
|
|
104
|
-
defaultValue: RootMatchState.NO,
|
|
105
|
-
},
|
|
106
|
-
switchboardMatchState: {
|
|
107
|
-
type: sequelize_1.DataTypes.ENUM,
|
|
108
|
-
values: [...Object.values(MatchState)],
|
|
109
|
-
defaultValue: MatchState.NO,
|
|
110
|
-
},
|
|
111
|
-
isTripRequired: {
|
|
112
|
-
type: sequelize_1.DataTypes.BOOLEAN,
|
|
113
|
-
defaultValue: false,
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
function processStrings(proposal) {
|
|
117
|
-
if (proposal.packetId)
|
|
118
|
-
proposal.packetId = (0, utils_1.toLowerCase)(proposal.packetId);
|
|
119
|
-
if (proposal.root)
|
|
120
|
-
proposal.root = (0, utils_1.toLowerCase)(proposal.root);
|
|
121
|
-
if (proposal.switchboard)
|
|
122
|
-
proposal.switchboard = (0, utils_1.toLowerCase)(proposal.switchboard);
|
|
123
|
-
if (proposal.proposer)
|
|
124
|
-
proposal.proposer = (0, utils_1.toLowerCase)(proposal.proposer);
|
|
125
|
-
if (proposal.proposeTxHash)
|
|
126
|
-
proposal.proposeTxHash = (0, utils_1.toLowerCase)(proposal.proposeTxHash);
|
|
127
|
-
if (proposal.tripTxHash)
|
|
128
|
-
proposal.tripTxHash = (0, utils_1.toLowerCase)(proposal.tripTxHash);
|
|
129
|
-
return proposal;
|
|
130
|
-
}
|
|
131
|
-
const addProposalHooks = () => {
|
|
132
|
-
Proposal.beforeBulkCreate((proposal, options) => {
|
|
133
|
-
for (let index = 0; index < proposal.length; index++) {
|
|
134
|
-
proposal[index] = processStrings(proposal[index]);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
Proposal.beforeSave((proposal, options) => {
|
|
138
|
-
proposal = processStrings(proposal);
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
exports.addProposalHooks = addProposalHooks;
|
|
@@ -1,69 +0,0 @@
|
|
|
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>;
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare let client: any;
|
|
2
|
-
export declare const initCache: (host: string, port: number, password: string, stage: string, serviceName: string) => void;
|
|
3
|
-
export declare const formatKey: (key: string) => string;
|
|
4
|
-
export declare const getKey: (key: string) => Promise<any>;
|
|
5
|
-
export declare const lock: (key: string, expire?: number) => Promise<boolean>;
|
|
6
|
-
export declare const deleteKey: (key: string) => Promise<any>;
|
|
7
|
-
export declare const unlock: (key: string) => Promise<any>;
|
|
8
|
-
export declare const setKey: (key: string, value: any, expire?: number, setIfNotExist?: boolean) => Promise<boolean>;
|
|
9
|
-
export declare const rpush: (key: string, values: any[]) => Promise<any>;
|
|
10
|
-
export declare const lpop: (key: string) => Promise<any>;
|
|
11
|
-
export declare const getListLength: (key: string) => Promise<any>;
|
|
12
|
-
export declare const increment: (key: string) => Promise<any>;
|
|
13
|
-
export declare const decrement: (key: string) => Promise<any>;
|
|
14
|
-
export declare const sendCommand: (command: string, params: any[]) => Promise<any>;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendCommand = exports.decrement = exports.increment = exports.getListLength = exports.lpop = exports.rpush = exports.setKey = exports.unlock = exports.deleteKey = exports.lock = exports.getKey = exports.formatKey = exports.initCache = exports.client = void 0;
|
|
4
|
-
const redis = require("async-redis");
|
|
5
|
-
let deploymentStage;
|
|
6
|
-
let servicePrefix;
|
|
7
|
-
const initCache = (host, port, password, stage, serviceName) => {
|
|
8
|
-
exports.client = redis.createClient({
|
|
9
|
-
port,
|
|
10
|
-
host,
|
|
11
|
-
password,
|
|
12
|
-
});
|
|
13
|
-
deploymentStage = stage;
|
|
14
|
-
servicePrefix = serviceName;
|
|
15
|
-
};
|
|
16
|
-
exports.initCache = initCache;
|
|
17
|
-
const formatKey = (key) => {
|
|
18
|
-
return deploymentStage + "_" + servicePrefix + "_" + key;
|
|
19
|
-
};
|
|
20
|
-
exports.formatKey = formatKey;
|
|
21
|
-
const getKey = async (key) => {
|
|
22
|
-
return await exports.client.get((0, exports.formatKey)(key));
|
|
23
|
-
};
|
|
24
|
-
exports.getKey = getKey;
|
|
25
|
-
const lock = async (key, expire = 0) => {
|
|
26
|
-
return await (0, exports.setKey)(key, "locked", expire, true);
|
|
27
|
-
};
|
|
28
|
-
exports.lock = lock;
|
|
29
|
-
const deleteKey = async (key) => {
|
|
30
|
-
return await exports.client.del((0, exports.formatKey)(key));
|
|
31
|
-
};
|
|
32
|
-
exports.deleteKey = deleteKey;
|
|
33
|
-
const unlock = async (key) => {
|
|
34
|
-
return await exports.client.del((0, exports.formatKey)(key));
|
|
35
|
-
};
|
|
36
|
-
exports.unlock = unlock;
|
|
37
|
-
const setKey = async (key, value, expire = 0, setIfNotExist = false) => {
|
|
38
|
-
let params = [(0, exports.formatKey)(key), value];
|
|
39
|
-
if (expire > 0)
|
|
40
|
-
params.push("EX", expire);
|
|
41
|
-
if (setIfNotExist)
|
|
42
|
-
params.push("NX");
|
|
43
|
-
let response = await exports.client.sendCommand("SET", params);
|
|
44
|
-
if (response) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
return false;
|
|
49
|
-
};
|
|
50
|
-
exports.setKey = setKey;
|
|
51
|
-
const rpush = async (key, values) => {
|
|
52
|
-
return await exports.client.rpush((0, exports.formatKey)(key), values);
|
|
53
|
-
};
|
|
54
|
-
exports.rpush = rpush;
|
|
55
|
-
const lpop = async (key) => {
|
|
56
|
-
return await exports.client.lpop((0, exports.formatKey)(key));
|
|
57
|
-
};
|
|
58
|
-
exports.lpop = lpop;
|
|
59
|
-
const getListLength = async (key) => {
|
|
60
|
-
return await exports.client.llen((0, exports.formatKey)(key));
|
|
61
|
-
};
|
|
62
|
-
exports.getListLength = getListLength;
|
|
63
|
-
const increment = async (key) => {
|
|
64
|
-
let value = await exports.client.incr((0, exports.formatKey)(key));
|
|
65
|
-
console.log("incremented key : ", (0, exports.formatKey)(key), " value : ", value);
|
|
66
|
-
return value;
|
|
67
|
-
};
|
|
68
|
-
exports.increment = increment;
|
|
69
|
-
const decrement = async (key) => {
|
|
70
|
-
return await exports.client.decr((0, exports.formatKey)(key));
|
|
71
|
-
};
|
|
72
|
-
exports.decrement = decrement;
|
|
73
|
-
const sendCommand = async (command, params) => {
|
|
74
|
-
params[0] = (0, exports.formatKey)(params[0]);
|
|
75
|
-
return await exports.client.sendCommand(command, params);
|
|
76
|
-
};
|
|
77
|
-
exports.sendCommand = sendCommand;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type EventBridgeEntry = {
|
|
2
|
-
eventBus: string;
|
|
3
|
-
source: string;
|
|
4
|
-
detailType: string;
|
|
5
|
-
data: Object;
|
|
6
|
-
};
|
|
7
|
-
export declare const initEventBridgeClient: (region?: string) => void;
|
|
8
|
-
export declare const sendEvents: (events: EventBridgeEntry[]) => Promise<import("@aws-sdk/client-eventbridge").PutEventsCommandOutput>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendEvents = exports.initEventBridgeClient = void 0;
|
|
4
|
-
const client_eventbridge_1 = require("@aws-sdk/client-eventbridge");
|
|
5
|
-
let client;
|
|
6
|
-
const initEventBridgeClient = (region = "us-east-1") => {
|
|
7
|
-
client = new client_eventbridge_1.EventBridgeClient({ region });
|
|
8
|
-
};
|
|
9
|
-
exports.initEventBridgeClient = initEventBridgeClient;
|
|
10
|
-
const sendEvents = async (events) => {
|
|
11
|
-
// async/await.
|
|
12
|
-
try {
|
|
13
|
-
if (!client) {
|
|
14
|
-
throw new Error("EventBridge client is not initialized. Call initEventBridgeClient first.");
|
|
15
|
-
}
|
|
16
|
-
let entries = events.map((event) => {
|
|
17
|
-
let { eventBus, source, detailType, data } = event;
|
|
18
|
-
return {
|
|
19
|
-
Source: source,
|
|
20
|
-
DetailType: detailType,
|
|
21
|
-
Detail: JSON.stringify(data),
|
|
22
|
-
EventBusName: eventBus,
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
const params = {
|
|
26
|
-
Entries: entries,
|
|
27
|
-
};
|
|
28
|
-
const command = new client_eventbridge_1.PutEventsCommand(params);
|
|
29
|
-
return await client.send(command);
|
|
30
|
-
// process data.
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
// finally.
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.sendEvents = sendEvents;
|
package/dist/services/index.d.ts
DELETED
package/dist/services/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./queueService"), exports);
|
|
18
|
-
__exportStar(require("./cacheService"), exports);
|
|
19
|
-
__exportStar(require("./eventBridgeService"), exports);
|
|
20
|
-
// export * from "./apiService";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const initQueue: (region: string) => void;
|
|
2
|
-
export declare const sendStandardSqsMessage: (queueUrl: string, data: any, DelaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
3
|
-
export declare const sendStandardBatchMessages: (QueueUrl: string, dataArray: any[], DelaySecondsArray?: number[]) => Promise<import("@aws-sdk/client-sqs").SendMessageBatchCommandOutput>;
|
|
4
|
-
export declare const sendFifoSqsMessage: (queueUrl: string, data: any, MessageGroupId: string) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
5
|
-
declare const _default: {
|
|
6
|
-
sendStandardSqsMessage: (queueUrl: string, data: any, DelaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
7
|
-
sendFifoSqsMessage: (queueUrl: string, data: any, MessageGroupId: string) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
8
|
-
sendStandardBatchMessages: (QueueUrl: string, dataArray: any[], DelaySecondsArray?: number[]) => Promise<import("@aws-sdk/client-sqs").SendMessageBatchCommandOutput>;
|
|
9
|
-
};
|
|
10
|
-
export default _default;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendFifoSqsMessage = exports.sendStandardBatchMessages = exports.sendStandardSqsMessage = exports.initQueue = void 0;
|
|
4
|
-
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
5
|
-
let client;
|
|
6
|
-
const initQueue = (region) => {
|
|
7
|
-
client = new client_sqs_1.SQSClient({ region });
|
|
8
|
-
};
|
|
9
|
-
exports.initQueue = initQueue;
|
|
10
|
-
const sendStandardSqsMessage = async (queueUrl, data, DelaySeconds = 0) => {
|
|
11
|
-
let sqsOrderData = {
|
|
12
|
-
MessageBody: JSON.stringify(data),
|
|
13
|
-
QueueUrl: queueUrl,
|
|
14
|
-
DelaySeconds,
|
|
15
|
-
};
|
|
16
|
-
// Send the order data to the SQS queue
|
|
17
|
-
const command = new client_sqs_1.SendMessageCommand(sqsOrderData);
|
|
18
|
-
return await client.send(command);
|
|
19
|
-
};
|
|
20
|
-
exports.sendStandardSqsMessage = sendStandardSqsMessage;
|
|
21
|
-
const sendStandardBatchMessages = async (QueueUrl, dataArray, DelaySecondsArray = []) => {
|
|
22
|
-
let Entries = [];
|
|
23
|
-
for (let i = 0; i < dataArray.length; i++) {
|
|
24
|
-
Entries.push({
|
|
25
|
-
MessageBody: JSON.stringify(dataArray[i]),
|
|
26
|
-
Id: i,
|
|
27
|
-
DelaySeconds: DelaySecondsArray[i] ? DelaySecondsArray[i] : 0,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
let sqsOrderData = {
|
|
31
|
-
Entries,
|
|
32
|
-
QueueUrl,
|
|
33
|
-
};
|
|
34
|
-
// Send the order data to the SQS queue
|
|
35
|
-
const command = new client_sqs_1.SendMessageBatchCommand(sqsOrderData);
|
|
36
|
-
return await client.send(command);
|
|
37
|
-
};
|
|
38
|
-
exports.sendStandardBatchMessages = sendStandardBatchMessages;
|
|
39
|
-
const sendFifoSqsMessage = async (queueUrl, data, MessageGroupId) => {
|
|
40
|
-
let sqsOrderData = {
|
|
41
|
-
MessageBody: JSON.stringify(data),
|
|
42
|
-
QueueUrl: queueUrl,
|
|
43
|
-
MessageGroupId,
|
|
44
|
-
};
|
|
45
|
-
// Send the order data to the SQS queue
|
|
46
|
-
const command = new client_sqs_1.SendMessageCommand(sqsOrderData);
|
|
47
|
-
return await client.send(command);
|
|
48
|
-
};
|
|
49
|
-
exports.sendFifoSqsMessage = sendFifoSqsMessage;
|
|
50
|
-
exports.default = {
|
|
51
|
-
sendStandardSqsMessage: exports.sendStandardSqsMessage,
|
|
52
|
-
sendFifoSqsMessage: exports.sendFifoSqsMessage,
|
|
53
|
-
sendStandardBatchMessages: exports.sendStandardBatchMessages,
|
|
54
|
-
};
|
package/dist/utils/address.d.ts
DELETED
package/dist/utils/address.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toLowerCase = exports.checksum = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
const checksum = (address) => ethers_1.utils.getAddress(address);
|
|
6
|
-
exports.checksum = checksum;
|
|
7
|
-
const toLowerCase = (address) => address.toLowerCase();
|
|
8
|
-
exports.toLowerCase = toLowerCase;
|
package/dist/utils/axios.d.ts
DELETED
package/dist/utils/axios.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.axiosPost = exports.axiosGet = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const __1 = require("..");
|
|
9
|
-
const axiosGet = async (url, config = {}, errorLogging = false) => {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
if (!url)
|
|
12
|
-
throw (0, __1.InternalServerError)("GET request url not provided");
|
|
13
|
-
try {
|
|
14
|
-
const response = await axios_1.default.get(url, config);
|
|
15
|
-
return { success: true, ...response === null || response === void 0 ? void 0 : response.data };
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
if (errorLogging) {
|
|
19
|
-
console.log("status : ", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status);
|
|
20
|
-
console.log("error occurred, url : ", url, "\n error : ", error === null || error === void 0 ? void 0 : error.message, (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data);
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
success: false,
|
|
24
|
-
status: (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.status,
|
|
25
|
-
message: error === null || error === void 0 ? void 0 : error.message,
|
|
26
|
-
...(_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
exports.axiosGet = axiosGet;
|
|
31
|
-
const axiosPost = async (url, data, config = {}, errorLogging = false) => {
|
|
32
|
-
var _a, _b, _c, _d;
|
|
33
|
-
if (!url)
|
|
34
|
-
throw (0, __1.InternalServerError)("POST request url not provided");
|
|
35
|
-
if (!data)
|
|
36
|
-
throw (0, __1.InternalServerError)("POST request data not provided");
|
|
37
|
-
try {
|
|
38
|
-
const response = await axios_1.default.post(url, data, config);
|
|
39
|
-
return { success: true, ...response === null || response === void 0 ? void 0 : response.data };
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
if (errorLogging) {
|
|
43
|
-
console.log("status : ", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status);
|
|
44
|
-
console.log("error occurred, url : ", url, "data : ", data, "\n error : ", error === null || error === void 0 ? void 0 : error.message, (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
success: false,
|
|
48
|
-
message: error === null || error === void 0 ? void 0 : error.message,
|
|
49
|
-
status: (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.status,
|
|
50
|
-
...(_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.axiosPost = axiosPost;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunks = exports.MAX_PAYLOAD_SIZE = void 0;
|
|
4
|
-
exports.MAX_PAYLOAD_SIZE = 10 * 1024; // max is 24.5 kb, left some buffer for function and batch encoding
|
|
5
|
-
function* chunks(arr, n) {
|
|
6
|
-
for (let i = 0; i < arr.length; i += n) {
|
|
7
|
-
yield arr.slice(i, i + n);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.chunks = chunks;
|
package/dist/utils/discord.d.ts
DELETED
package/dist/utils/discord.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendToDiscordWebhook = exports.initDiscord = void 0;
|
|
4
|
-
const __1 = require("..");
|
|
5
|
-
const axios_1 = require("./axios");
|
|
6
|
-
let discordWebhookUrl;
|
|
7
|
-
let serviceName;
|
|
8
|
-
const initDiscord = (webhookUrl_, serviceName_) => {
|
|
9
|
-
discordWebhookUrl = webhookUrl_;
|
|
10
|
-
serviceName = serviceName_;
|
|
11
|
-
};
|
|
12
|
-
exports.initDiscord = initDiscord;
|
|
13
|
-
const sendToDiscordWebhook = async (title, data, optionalConfig = {}) => {
|
|
14
|
-
try {
|
|
15
|
-
if (!discordWebhookUrl) {
|
|
16
|
-
throw (0, __1.InternalServerError)("DISCORD_WEBHOOK_URL not provided");
|
|
17
|
-
}
|
|
18
|
-
let content = formatMsg(title, data);
|
|
19
|
-
await (0, axios_1.axiosPost)(discordWebhookUrl, { content, ...optionalConfig });
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.sendToDiscordWebhook = sendToDiscordWebhook;
|
|
26
|
-
const formatMsg = (title, data) => {
|
|
27
|
-
let message = `**${title}**\n`;
|
|
28
|
-
// Iterate through the object's key-value pairs
|
|
29
|
-
for (const key in data) {
|
|
30
|
-
if (data.hasOwnProperty(key)) {
|
|
31
|
-
message += `${key}: ${data[key]}\n`;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return message;
|
|
35
|
-
};
|