@paraswap/dex-lib 3.7.2 → 3.7.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.
- package/build/abi/Redstone.json +739 -0
- package/build/abi/aavev3stata/Factory.json +128 -0
- package/build/abi/aavev3stata/Token.json +735 -0
- package/build/abi/angle-transmuter/MorphoOracle.json +193 -0
- package/build/abi/angle-transmuter/MorphoVault.json +2506 -0
- package/build/abi/angle-transmuter/Pyth.json +1534 -0
- package/build/abi/angle-transmuter/Transmuter.json +1711 -0
- package/build/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
- package/build/abi/idle-dao/idle-cdo-factory.json +38 -0
- package/build/abi/idle-dao/idle-cdo.json +1245 -0
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v3-stata/aave-v3-stata.d.ts +50 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js +365 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -0
- package/build/dex/aave-v3-stata/config.d.ts +4 -0
- package/build/dex/aave-v3-stata/config.js +50 -0
- package/build/dex/aave-v3-stata/config.js.map +1 -0
- package/build/dex/aave-v3-stata/tokens.d.ts +9 -0
- package/build/dex/aave-v3-stata/tokens.js +37 -0
- package/build/dex/aave-v3-stata/tokens.js.map +1 -0
- package/build/dex/aave-v3-stata/types.d.ts +46 -0
- package/build/dex/aave-v3-stata/types.js +23 -0
- package/build/dex/aave-v3-stata/types.js.map +1 -0
- package/build/dex/aave-v3-stata/utils.d.ts +4 -0
- package/build/dex/aave-v3-stata/utils.js +67 -0
- package/build/dex/aave-v3-stata/utils.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +67 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +448 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +59 -0
- package/build/dex/angle-transmuter/angle-transmuter.js +264 -0
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
- package/build/dex/angle-transmuter/backedOracle.js +56 -0
- package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
- package/build/dex/angle-transmuter/config.d.ts +4 -0
- package/build/dex/angle-transmuter/config.js +50 -0
- package/build/dex/angle-transmuter/config.js.map +1 -0
- package/build/dex/angle-transmuter/constants.d.ts +9 -0
- package/build/dex/angle-transmuter/constants.js +136 -0
- package/build/dex/angle-transmuter/constants.js.map +1 -0
- package/build/dex/angle-transmuter/morphoOracle.d.ts +42 -0
- package/build/dex/angle-transmuter/morphoOracle.js +179 -0
- package/build/dex/angle-transmuter/morphoOracle.js.map +1 -0
- package/build/dex/angle-transmuter/morphoVault.d.ts +20 -0
- package/build/dex/angle-transmuter/morphoVault.js +84 -0
- package/build/dex/angle-transmuter/morphoVault.js.map +1 -0
- package/build/dex/angle-transmuter/pyth.d.ts +19 -0
- package/build/dex/angle-transmuter/pyth.js +70 -0
- package/build/dex/angle-transmuter/pyth.js.map +1 -0
- package/build/dex/angle-transmuter/redstone.d.ts +20 -0
- package/build/dex/angle-transmuter/redstone.js +64 -0
- package/build/dex/angle-transmuter/redstone.js.map +1 -0
- package/build/dex/angle-transmuter/transmuter.d.ts +55 -0
- package/build/dex/angle-transmuter/transmuter.js +398 -0
- package/build/dex/angle-transmuter/transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/types.d.ts +189 -0
- package/build/dex/angle-transmuter/types.js +33 -0
- package/build/dex/angle-transmuter/types.js.map +1 -0
- package/build/dex/angle-transmuter/utils.d.ts +9 -0
- package/build/dex/angle-transmuter/utils.js +257 -0
- package/build/dex/angle-transmuter/utils.js.map +1 -0
- package/build/dex/idle-dao/config.d.ts +6 -0
- package/build/dex/idle-dao/config.js +307 -0
- package/build/dex/idle-dao/config.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao.d.ts +41 -0
- package/build/dex/idle-dao/idle-dao.js +238 -0
- package/build/dex/idle-dao/idle-dao.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/idle-dao/tokens.d.ts +9 -0
- package/build/dex/idle-dao/tokens.js +65 -0
- package/build/dex/idle-dao/tokens.js.map +1 -0
- package/build/dex/idle-dao/types.d.ts +35 -0
- package/build/dex/idle-dao/types.js +11 -0
- package/build/dex/idle-dao/types.js.map +1 -0
- package/build/dex/idle-dao/utils.d.ts +8 -0
- package/build/dex/idle-dao/utils.js +148 -0
- package/build/dex/idle-dao/utils.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/lib/chainlink.d.ts +2 -0
- package/build/lib/chainlink.js +9 -0
- package/build/lib/chainlink.js.map +1 -1
- package/build/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/abi/Redstone.json +739 -0
- package/src/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
- package/src/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
- package/src/abi/angle-transmuter/MorphoOracle.json +193 -0
- package/src/abi/angle-transmuter/MorphoVault.json +2506 -0
- package/src/abi/angle-transmuter/Pyth.json +1534 -0
- package/src/abi/angle-transmuter/Transmuter.json +1711 -0
- package/src/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
- package/src/dex/angle-transmuter/angle-transmuter-e2e.test.ts +156 -0
- package/src/dex/angle-transmuter/angle-transmuter-events.test.ts +365 -0
- package/src/dex/angle-transmuter/angle-transmuter-integration.test.ts +390 -0
- package/src/dex/angle-transmuter/angle-transmuter-pool.ts +895 -0
- package/src/dex/angle-transmuter/angle-transmuter.ts +408 -0
- package/src/dex/angle-transmuter/backedOracle.ts +91 -0
- package/src/dex/angle-transmuter/config.ts +50 -0
- package/src/dex/angle-transmuter/constants.ts +138 -0
- package/src/dex/angle-transmuter/morphoOracle.ts +335 -0
- package/src/dex/angle-transmuter/morphoVault.ts +134 -0
- package/src/dex/angle-transmuter/pyth.ts +105 -0
- package/src/dex/angle-transmuter/redstone.ts +105 -0
- package/src/dex/angle-transmuter/transmuter.ts +619 -0
- package/src/dex/angle-transmuter/types.ts +203 -0
- package/src/dex/angle-transmuter/utils.ts +358 -0
- package/src/dex/index.ts +2 -0
- package/src/lib/chainlink.ts +15 -0
- package/tests/constants-e2e.ts +48 -3
- package/build/abi/Uncompressor.json +0 -250
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/etherfi/etherfi.d.ts +0 -26
- package/build/dex/etherfi/etherfi.js +0 -96
- package/build/dex/etherfi/etherfi.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/sdai/config.d.ts +0 -11
- package/build/dex/sdai/config.js +0 -21
- package/build/dex/sdai/config.js.map +0 -1
- package/build/dex/sdai/constants.d.ts +0 -2
- package/build/dex/sdai/constants.js +0 -6
- package/build/dex/sdai/constants.js.map +0 -1
- package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
- package/build/dex/sdai/scripts/validate-state.js +0 -102
- package/build/dex/sdai/scripts/validate-state.js.map +0 -1
- package/build/dex/sdai/sdai-pool.d.ts +0 -16
- package/build/dex/sdai/sdai-pool.js +0 -85
- package/build/dex/sdai/sdai-pool.js.map +0 -1
- package/build/dex/sdai/sdai.d.ts +0 -51
- package/build/dex/sdai/sdai.js +0 -172
- package/build/dex/sdai/sdai.js.map +0 -1
- package/build/dex/sdai/types.d.ts +0 -21
- package/build/dex/sdai/types.js +0 -11
- package/build/dex/sdai/types.js.map +0 -1
- package/build/dex/sdai/utils.d.ts +0 -4
- package/build/dex/sdai/utils.js +0 -39
- package/build/dex/sdai/utils.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/build/executor/compressor/Compressor.d.ts +0 -23
- package/build/executor/compressor/Compressor.js +0 -144
- package/build/executor/compressor/Compressor.js.map +0 -1
- package/build/executor/compressor/compress.d.ts +0 -17
- package/build/executor/compressor/compress.js +0 -187
- package/build/executor/compressor/compress.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
- package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
- package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +0 -17
- package/build/executor/compressor/fetchSaved.js.map +0 -1
- package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
- package/build/executor/compressor/utils/computeCostL2.js +0 -14
- package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
- package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
- package/build/executor/compressor/utils/getAllIndexes.js +0 -12
- package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
- package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
- package/build/executor/compressor/utils/getByteForAddress.js +0 -14
- package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
- package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
- package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intToByte.d.ts +0 -2
- package/build/executor/compressor/utils/intToByte.js +0 -10
- package/build/executor/compressor/utils/intToByte.js.map +0 -1
|
@@ -1,187 +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
|
-
const computeCostL2_1 = __importDefault(require("./utils/computeCostL2"));
|
|
7
|
-
const intToByte_1 = __importDefault(require("./utils/intToByte"));
|
|
8
|
-
const searchUnusedBytes_1 = __importDefault(require("./compress_functions/searchUnusedBytes"));
|
|
9
|
-
const byteSubstitution_1 = __importDefault(require("./compress_functions/byteSubstitution"));
|
|
10
|
-
const findLongestAndSubstitute_1 = __importDefault(require("./compress_functions/findLongestAndSubstitute"));
|
|
11
|
-
const addressSubstitution_1 = __importDefault(require("./compress_functions/addressSubstitution"));
|
|
12
|
-
const addressSubstitutionFromObject_1 = __importDefault(require("./compress_functions/addressSubstitutionFromObject"));
|
|
13
|
-
const lodash_1 = require("lodash");
|
|
14
|
-
const zeroByte = '00';
|
|
15
|
-
const ffByte = 'ff';
|
|
16
|
-
const trimHex = (hex) => {
|
|
17
|
-
return hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
18
|
-
};
|
|
19
|
-
const compress = function ({ initialCallData, addresses, options, network, }) {
|
|
20
|
-
if (initialCallData.length % 2 !== 0)
|
|
21
|
-
throw new Error('Initial data of odd length');
|
|
22
|
-
if (!options)
|
|
23
|
-
options = {};
|
|
24
|
-
const initialCost = (0, computeCostL2_1.default)(initialCallData);
|
|
25
|
-
initialCallData = trimHex(initialCallData);
|
|
26
|
-
let callData = initialCallData;
|
|
27
|
-
const savedAddresses = (0, lodash_1.pickBy)(addresses, v => v.saved);
|
|
28
|
-
let newAddresses = Object.keys((0, lodash_1.pickBy)(addresses, v => !v.saved)).map(address => address.substring(2).toLocaleLowerCase());
|
|
29
|
-
// SAVED ADDRESSES SUBSTITUTIONS
|
|
30
|
-
if (!options.skipAddressSubstitution) {
|
|
31
|
-
callData = (0, addressSubstitutionFromObject_1.default)({
|
|
32
|
-
callData,
|
|
33
|
-
addressesObject: savedAddresses,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
if (!options.skipNewAddressSubstitution) {
|
|
37
|
-
// NEW ADDRESSES REMOVING USELESS AND HIGHLIGHTING GOOD
|
|
38
|
-
newAddresses = newAddresses.filter(addr => callData.includes(addr));
|
|
39
|
-
// NEW ADDRESSES SUBSTITUTIONS
|
|
40
|
-
callData = (0, addressSubstitution_1.default)({
|
|
41
|
-
callData,
|
|
42
|
-
addresses: newAddresses,
|
|
43
|
-
isSavedAddresses: false,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// ZEROES SUBSTITUTIONS
|
|
47
|
-
// I couldn't get ride of 0 around addresses because of potential zeroes absence around addresses in later call data formats
|
|
48
|
-
// An idea could be to have another address prefix to handle this case (one with both sides having 00 by default), but it doesn't optimize that much
|
|
49
|
-
let { compressedCallData, bufferOfOccurences } = (0, byteSubstitution_1.default)({
|
|
50
|
-
byte: zeroByte,
|
|
51
|
-
callData,
|
|
52
|
-
addressPrefix: 'RR',
|
|
53
|
-
newAddressPrefix: 'TT',
|
|
54
|
-
});
|
|
55
|
-
let numberOfZeroes = bufferOfOccurences;
|
|
56
|
-
// console.log({numberOfZeroes})
|
|
57
|
-
// COUNTING BYTES AND CHOSING MAX BYTE IN ZEROES
|
|
58
|
-
// Counting bytes occurences in numberOfZeroes
|
|
59
|
-
let byteCountsInZeroes = {};
|
|
60
|
-
for (let i = 0; i < numberOfZeroes.length; i += 2) {
|
|
61
|
-
const byte = numberOfZeroes.substring(i, i + 2);
|
|
62
|
-
if (!byteCountsInZeroes[byte])
|
|
63
|
-
byteCountsInZeroes[byte] = 1;
|
|
64
|
-
else
|
|
65
|
-
byteCountsInZeroes[byte]++;
|
|
66
|
-
}
|
|
67
|
-
// Finding max byte in numberOfZeroes
|
|
68
|
-
let maxByteInZeroes = '';
|
|
69
|
-
let maxInZeroes = 0;
|
|
70
|
-
for (let byte of Object.keys(byteCountsInZeroes)) {
|
|
71
|
-
if (byteCountsInZeroes[byte] > maxInZeroes) {
|
|
72
|
-
maxInZeroes = byteCountsInZeroes[byte];
|
|
73
|
-
maxByteInZeroes = byte;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Substituting max byte of numberOfZeroes in compressedData
|
|
77
|
-
for (let i = 0; i < compressedCallData.length; i += 2) {
|
|
78
|
-
const currentByte = compressedCallData.slice(i, i + 2);
|
|
79
|
-
if (currentByte === zeroByte) {
|
|
80
|
-
if (i < compressedCallData.length - 2) {
|
|
81
|
-
const nextByte = compressedCallData.slice(i + 2, i + 4);
|
|
82
|
-
if (nextByte === maxByteInZeroes) {
|
|
83
|
-
compressedCallData =
|
|
84
|
-
compressedCallData.substring(0, i + 2) +
|
|
85
|
-
zeroByte +
|
|
86
|
-
compressedCallData.substring(i + 4);
|
|
87
|
-
i += 2;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (currentByte === 'RR')
|
|
92
|
-
i += 6;
|
|
93
|
-
else if (currentByte === 'TT')
|
|
94
|
-
i += 2;
|
|
95
|
-
}
|
|
96
|
-
// console.log({maxByteInZeroes, maxInZeroes, compressedCallData})
|
|
97
|
-
// SEARCH FOR UNIQUE ADDRESSES PREFIXES AND DUPLICATED STRING MARKERS
|
|
98
|
-
let { addressPrefix, newAddressPrefix, duplicatedStringMarkers } = (0, searchUnusedBytes_1.default)({
|
|
99
|
-
newAddresses,
|
|
100
|
-
compressedCallData,
|
|
101
|
-
});
|
|
102
|
-
// console.log({addressPrefix, newAddressPrefix, duplicatedStringMarkers})
|
|
103
|
-
// ADDRESSES PREFIX SUBSTITUTIONS
|
|
104
|
-
if (addressPrefix &&
|
|
105
|
-
addressPrefix !== '' &&
|
|
106
|
-
!options.skipAddressSubstitution) {
|
|
107
|
-
const regex = new RegExp('RR', 'g');
|
|
108
|
-
compressedCallData = compressedCallData.replace(regex, addressPrefix);
|
|
109
|
-
}
|
|
110
|
-
else if (addressPrefix === '' && !options.skipAddressSubstitution) {
|
|
111
|
-
// If no unused byte for addressPrefix remove the logic for address
|
|
112
|
-
return compress({
|
|
113
|
-
initialCallData: initialCallData,
|
|
114
|
-
addresses,
|
|
115
|
-
options: {
|
|
116
|
-
skipAddressSubstitution: true,
|
|
117
|
-
skipNewAddressSubstitution: true,
|
|
118
|
-
},
|
|
119
|
-
network,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
else if (options.skipAddressSubstitution) {
|
|
123
|
-
addressPrefix = '00';
|
|
124
|
-
}
|
|
125
|
-
if (newAddressPrefix &&
|
|
126
|
-
newAddressPrefix !== '' &&
|
|
127
|
-
!options.skipNewAddressSubstitution) {
|
|
128
|
-
const regex = new RegExp('TT', 'g');
|
|
129
|
-
compressedCallData = compressedCallData.replace(regex, newAddressPrefix);
|
|
130
|
-
}
|
|
131
|
-
else if (newAddressPrefix === '' &&
|
|
132
|
-
newAddresses.length &&
|
|
133
|
-
!options.skipNewAddressSubstitution) {
|
|
134
|
-
// If no unused byte for newAddressPrefix remove the logic for address
|
|
135
|
-
return compress({
|
|
136
|
-
initialCallData: initialCallData,
|
|
137
|
-
addresses,
|
|
138
|
-
options: {
|
|
139
|
-
skipNewAddressSubstitution: true,
|
|
140
|
-
},
|
|
141
|
-
network,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// INDEX OF METHOD SUBSTITUTION
|
|
145
|
-
compressedCallData = ffByte + trimHex(compressedCallData);
|
|
146
|
-
const newAddressesString = options.skipNewAddressSubstitution
|
|
147
|
-
? '00'
|
|
148
|
-
: (0, intToByte_1.default)(newAddresses.length) +
|
|
149
|
-
(newAddresses.length > 0 ? newAddressPrefix : '') +
|
|
150
|
-
newAddresses.join('');
|
|
151
|
-
const prefixCallData = addressPrefix + newAddressesString;
|
|
152
|
-
// SUBSTITUTING FF
|
|
153
|
-
const firstBytes = compressedCallData.substring(0, 2);
|
|
154
|
-
const compressedFFSubstituted = (0, byteSubstitution_1.default)({
|
|
155
|
-
byte: ffByte,
|
|
156
|
-
callData: compressedCallData.substring(2),
|
|
157
|
-
compressedCallData: firstBytes,
|
|
158
|
-
addressPrefix: options.skipAddressSubstitution ? 'RR' : addressPrefix,
|
|
159
|
-
newAddressPrefix: options.skipNewAddressSubstitution
|
|
160
|
-
? 'TT'
|
|
161
|
-
: newAddressPrefix,
|
|
162
|
-
});
|
|
163
|
-
compressedCallData = compressedFFSubstituted.compressedCallData;
|
|
164
|
-
// FINDING LONGEST RECURRENT STRINGS TO COMPRESS
|
|
165
|
-
let { newCompressedData, nbOfDuplicatedStrings } = (0, findLongestAndSubstitute_1.default)({
|
|
166
|
-
compressedCallData: compressedCallData.substring(2),
|
|
167
|
-
markers: duplicatedStringMarkers,
|
|
168
|
-
});
|
|
169
|
-
if (newCompressedData)
|
|
170
|
-
compressedCallData = firstBytes + newCompressedData;
|
|
171
|
-
if (!maxByteInZeroes)
|
|
172
|
-
maxByteInZeroes = '00';
|
|
173
|
-
compressedCallData =
|
|
174
|
-
'0x' + prefixCallData + maxByteInZeroes + compressedCallData + zeroByte;
|
|
175
|
-
// We append the markers at the end of the string to find them back in the contract
|
|
176
|
-
for (let i = 0; i < nbOfDuplicatedStrings; i++) {
|
|
177
|
-
compressedCallData += duplicatedStringMarkers[i];
|
|
178
|
-
}
|
|
179
|
-
// 0x + address prefix (1B) | nbOfNewAddresses (1B) | newAddressPrefix (0/1B) | newAddresses (n * 20B) |
|
|
180
|
-
// maxByteInZeroes (1B) | FF | compressedData | 00 | duplicatedStringMarkers
|
|
181
|
-
const finalCost = (0, computeCostL2_1.default)(compressedCallData);
|
|
182
|
-
if (compressedCallData.length % 2 !== 0)
|
|
183
|
-
throw new Error('Data of odd length');
|
|
184
|
-
return { compressedData: compressedCallData, initialCost, finalCost };
|
|
185
|
-
};
|
|
186
|
-
exports.default = compress;
|
|
187
|
-
//# sourceMappingURL=compress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../src/executor/compressor/compress.ts"],"names":[],"mappings":";;;;;AAAA,0EAAgD;AAChD,kEAA0C;AAE1C,+FAAuE;AACvE,6FAAqE;AACrE,6GAAqF;AACrF,mGAA2E;AAC3E,uHAA+F;AAC/F,mCAAgC;AAEhC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,MAAM,GAAG,IAAI,CAAC;AAoBpB,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,C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
|
-
"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
|
-
const intToByte_1 = __importDefault(require("./../utils/intToByte"));
|
|
7
|
-
const intTo3Bytes_1 = __importDefault(require("../utils/intTo3Bytes"));
|
|
8
|
-
const addressSubstitution = ({ callData, addresses, isSavedAddresses, }) => {
|
|
9
|
-
for (let i = 0; i < addresses.length; i++) {
|
|
10
|
-
if (addresses[i] === '0000000000000000000000000000000000000000')
|
|
11
|
-
continue;
|
|
12
|
-
let index = callData.indexOf(addresses[i]);
|
|
13
|
-
if (index === -1)
|
|
14
|
-
continue;
|
|
15
|
-
while (index !== -1) {
|
|
16
|
-
if (index % 2 === 0) {
|
|
17
|
-
callData =
|
|
18
|
-
callData.substring(0, index) +
|
|
19
|
-
(isSavedAddresses ? 'RR' : 'TT') +
|
|
20
|
-
(!isSavedAddresses ? (0, intToByte_1.default)(i) : (0, intTo3Bytes_1.default)(i)) +
|
|
21
|
-
callData.substring(index + addresses[i].length);
|
|
22
|
-
}
|
|
23
|
-
index = callData.indexOf(addresses[i], index + 1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return callData;
|
|
27
|
-
};
|
|
28
|
-
exports.default = addressSubstitution;
|
|
29
|
-
//# sourceMappingURL=addressSubstitution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressSubstitution.js","sourceRoot":"","sources":["../../../../src/executor/compressor/compress_functions/addressSubstitution.ts"],"names":[],"mappings":";;;;;AAAA,qEAA6C;AAC7C,uEAA+C;AAE/C,MAAM,mBAAmB,GAAG,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,gBAAgB,GAKjB,EAAU,EAAE;IACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,0CAA0C;YAAE,SAAS;QAC1E,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,SAAS;QAC3B,OAAO,KAAK,KAAK,CAAC,CAAC,EAAE;YACnB,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;gBACnB,QAAQ;oBACN,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC;wBAC5B,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;wBAChC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAA,mBAAS,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,qBAAW,EAAC,CAAC,CAAC,CAAC;wBACnD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;aACnD;YACD,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;SACnD;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC"}
|
|
@@ -1,40 +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
|
-
const intTo3Bytes_1 = __importDefault(require("../utils/intTo3Bytes"));
|
|
7
|
-
const ZERO_ADDRESS = '0000000000000000000000000000000000000000';
|
|
8
|
-
const addressSubstitutionFromObject = ({ callData, addressesObject, }) => {
|
|
9
|
-
const addresses = [];
|
|
10
|
-
for (let i = 0; i < callData.length; i += 2) {
|
|
11
|
-
const callDataPart = callData.slice(i, i + 40);
|
|
12
|
-
const addressObj = addressesObject[`0x${callDataPart}`];
|
|
13
|
-
if (addressObj?.saved)
|
|
14
|
-
addresses.push(callDataPart);
|
|
15
|
-
}
|
|
16
|
-
addresses
|
|
17
|
-
.filter(address => {
|
|
18
|
-
const notZero = address !== ZERO_ADDRESS;
|
|
19
|
-
const inCalldata = callData.indexOf(address) !== -1;
|
|
20
|
-
const isSaved = addressesObject[`0x${address}`].saved;
|
|
21
|
-
return notZero && inCalldata && isSaved;
|
|
22
|
-
})
|
|
23
|
-
.forEach(address => {
|
|
24
|
-
let index = callData.indexOf(address);
|
|
25
|
-
const bytes3 = (0, intTo3Bytes_1.default)(addressesObject[`0x${address}`].index);
|
|
26
|
-
while (index !== -1) {
|
|
27
|
-
if (index % 2 === 0) {
|
|
28
|
-
callData =
|
|
29
|
-
callData.substring(0, index) +
|
|
30
|
-
'RR' +
|
|
31
|
-
bytes3 +
|
|
32
|
-
callData.substring(index + address.length);
|
|
33
|
-
}
|
|
34
|
-
index = callData.indexOf(address, index + 1);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return callData;
|
|
38
|
-
};
|
|
39
|
-
exports.default = addressSubstitutionFromObject;
|
|
40
|
-
//# sourceMappingURL=addressSubstitutionFromObject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressSubstitutionFromObject.js","sourceRoot":"","sources":["../../../../src/executor/compressor/compress_functions/addressSubstitutionFromObject.ts"],"names":[],"mappings":";;;;;AAAA,uEAA+C;AAE/C,MAAM,YAAY,GAAG,0CAA0C,CAAC;AAEhE,MAAM,6BAA6B,GAAG,CAAC,EACrC,QAAQ,EACR,eAAe,GAIhB,EAAU,EAAE;IACX,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CA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C,CAAC;AAEF,kBAAe,6BAA6B,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare const byteSubstitution: ({ byte, callData, compressedCallData, addressPrefix, newAddressPrefix, }: {
|
|
2
|
-
byte: string;
|
|
3
|
-
callData: string;
|
|
4
|
-
compressedCallData?: string | undefined;
|
|
5
|
-
addressPrefix: string;
|
|
6
|
-
newAddressPrefix: string;
|
|
7
|
-
}) => {
|
|
8
|
-
bufferOfOccurences: string;
|
|
9
|
-
compressedCallData: string;
|
|
10
|
-
};
|
|
11
|
-
export default byteSubstitution;
|
|
@@ -1,64 +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
|
-
const intToByte_1 = __importDefault(require("../utils/intToByte"));
|
|
7
|
-
const byteSubstitution = ({ byte, callData, compressedCallData, addressPrefix, newAddressPrefix, }) => {
|
|
8
|
-
let countNoByte = 0; // Count of non-target bytes
|
|
9
|
-
let countByte = 0; // Count of target bytes
|
|
10
|
-
let bufferOfOccurences = ''; // Stores occurrences of target bytes
|
|
11
|
-
if (!compressedCallData)
|
|
12
|
-
compressedCallData = '';
|
|
13
|
-
// Looping through call data byte by byte
|
|
14
|
-
for (let i = 0; i < callData.length; i += 2) {
|
|
15
|
-
let amountToIncreaseI = 0;
|
|
16
|
-
const currentByte = callData.slice(i, i + 2);
|
|
17
|
-
// Handling target byte substitution
|
|
18
|
-
if (currentByte === byte) {
|
|
19
|
-
if (countNoByte > 0 || i == 0) {
|
|
20
|
-
compressedCallData += byte;
|
|
21
|
-
countNoByte = 0;
|
|
22
|
-
}
|
|
23
|
-
// Handle byte count exceeding limit
|
|
24
|
-
if (++countByte > 254) {
|
|
25
|
-
let hexValue = (0, intToByte_1.default)(countByte);
|
|
26
|
-
bufferOfOccurences += hexValue;
|
|
27
|
-
compressedCallData += byte + hexValue;
|
|
28
|
-
countByte = 0;
|
|
29
|
-
}
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// Handle other bytes and address prefixes
|
|
34
|
-
if (countByte > 0) {
|
|
35
|
-
let hexValue = (0, intToByte_1.default)(countByte);
|
|
36
|
-
if (byte === 'ff' && countByte === 1)
|
|
37
|
-
hexValue = '00';
|
|
38
|
-
bufferOfOccurences += hexValue;
|
|
39
|
-
compressedCallData += hexValue;
|
|
40
|
-
countByte = 0;
|
|
41
|
-
}
|
|
42
|
-
// Check for address and new address prefixes
|
|
43
|
-
if (currentByte === addressPrefix || currentByte === newAddressPrefix) {
|
|
44
|
-
let sliceLength = currentByte === addressPrefix ? 8 : 4;
|
|
45
|
-
compressedCallData += callData.slice(i, i + sliceLength);
|
|
46
|
-
amountToIncreaseI = sliceLength - 2;
|
|
47
|
-
countNoByte = 0;
|
|
48
|
-
}
|
|
49
|
-
countNoByte++;
|
|
50
|
-
}
|
|
51
|
-
if (!amountToIncreaseI)
|
|
52
|
-
compressedCallData += callData.slice(i, i + 2);
|
|
53
|
-
i += amountToIncreaseI;
|
|
54
|
-
}
|
|
55
|
-
// Append remaining byte counts after loop
|
|
56
|
-
if (countByte > 0) {
|
|
57
|
-
let hexValue = (0, intToByte_1.default)(countByte);
|
|
58
|
-
bufferOfOccurences += hexValue;
|
|
59
|
-
compressedCallData += hexValue;
|
|
60
|
-
}
|
|
61
|
-
return { bufferOfOccurences, compressedCallData };
|
|
62
|
-
};
|
|
63
|
-
exports.default = byteSubstitution;
|
|
64
|
-
//# sourceMappingURL=byteSubstitution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"byteSubstitution.js","sourceRoot":"","sources":["../../../../src/executor/compressor/compress_functions/byteSubstitution.ts"],"names":[],"mappings":";;;;;AAAA,mEAA2C;AAE3C,MAAM,gBAAgB,GAAG,CAAC,EACxB,IAAI,EAC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kB,IAAI,QAAQ,CAAC;gBAC/B,SAAS,GAAG,CAAC,CAAC;aACf;YACD,6CAA6C;YAC7C,IAAI,WAAW,KAAK,aAAa,IAAI,WAAW,KAAK,gBAAgB,EAAE;gBACrE,IAAI,WAAW,GAAG,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxD,kBAAkB,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC;gBACzD,iBAAiB,GAAG,WAAW,GAAG,CAAC,CAAC;gBACpC,WAAW,GAAG,CAAC,CAAC;aACjB;YACD,WAAW,EAAE,CAAC;SACf;QACD,IAAI,CAAC,iBAAiB;YAAE,kBAAkB,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvE,CAAC,IAAI,iBAAiB,CAAC;KACxB;IAED,0CAA0C;IAC1C,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,IAAI,QAAQ,GAAG,IAAA,mBAAS,EAAC,SAAS,CAAC,CAAC;QACpC,kBAAkB,IAAI,QAAQ,CAAC;QAC/B,kBAAkB,IAAI,QAAQ,CAAC;KAChC;IAED,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
|
|
@@ -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
|
-
const intToByte_1 = __importDefault(require("../utils/intToByte"));
|
|
7
|
-
const ffByte = 'ff';
|
|
8
|
-
const zeroByte = '00';
|
|
9
|
-
const ffSubstitution = ({ compressedCallData, indexOfMethods, addressPrefix, newAddressPrefix, }) => {
|
|
10
|
-
let ffCount = 0;
|
|
11
|
-
let maxI;
|
|
12
|
-
const startFFSearch = indexOfMethods > -1 ? 2 : 10;
|
|
13
|
-
for (let i = startFFSearch; i < compressedCallData.length; i += 2) {
|
|
14
|
-
const byte = compressedCallData.substring(i, i + 2);
|
|
15
|
-
maxI = i;
|
|
16
|
-
if (byte === ffByte) {
|
|
17
|
-
if (++ffCount > 254) {
|
|
18
|
-
// in case more than 255 bytes of ff
|
|
19
|
-
compressedCallData =
|
|
20
|
-
compressedCallData.substring(0, i + (1 - ffCount) * 2) +
|
|
21
|
-
(0, intToByte_1.default)(ffCount) +
|
|
22
|
-
compressedCallData.substring(i);
|
|
23
|
-
i -= ffCount * 2;
|
|
24
|
-
i += 2;
|
|
25
|
-
ffCount = 0;
|
|
26
|
-
}
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (ffCount > 0) {
|
|
30
|
-
if (ffCount === 1)
|
|
31
|
-
compressedCallData =
|
|
32
|
-
compressedCallData.substring(0, i) +
|
|
33
|
-
zeroByte +
|
|
34
|
-
compressedCallData.substring(i);
|
|
35
|
-
else {
|
|
36
|
-
compressedCallData =
|
|
37
|
-
compressedCallData.substring(0, i + (1 - ffCount) * 2) +
|
|
38
|
-
(0, intToByte_1.default)(ffCount) +
|
|
39
|
-
compressedCallData.substring(i);
|
|
40
|
-
i -= ffCount * 2;
|
|
41
|
-
}
|
|
42
|
-
i += 2;
|
|
43
|
-
ffCount = 0;
|
|
44
|
-
}
|
|
45
|
-
if (byte === addressPrefix)
|
|
46
|
-
i += 6;
|
|
47
|
-
if (byte === newAddressPrefix)
|
|
48
|
-
i += 2;
|
|
49
|
-
}
|
|
50
|
-
// console.log({ maxI: max, length: compressedCallData.length, compressedCallData });
|
|
51
|
-
return compressedCallData;
|
|
52
|
-
};
|
|
53
|
-
exports.default = ffSubstitution;
|
|
54
|
-
//# sourceMappingURL=ffSubstitution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ffSubstitution.js","sourceRoot":"","sources":["../../../../src/executor/compressor/compress_functions/ffSubstitution.ts"],"names":[],"mappings":";;;;;AAAA,mEAA2C;AAE3C,MAAM,MAAM,GAAG,IAAI,CAAC;AACpB,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,MAAM,cAAc,GAAG,CAAC,EACtB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,GAMjB,EAAU,EAAE;IACX,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,IAAY,CAAC;IACjB,MAAM,aAAa,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnD,KAAK,IAAI,CAAC,GAAG,aAAa,EAAE,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACjE,MAAM,IAAI,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,IAAI,GAAG,CAAC,CAAC;QACT,IAAI,IAAI,KAAK,MAAM,EAAE;YACnB,IAAI,EAAE,OAAO,GAAG,GAAG,EAAE;gBACnB,oCAAoC;gBACpC,kBAAkB;oBAChB,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;wBACtD,IAAA,mBAAS,EAAC,OAAO,CAAC;wBAClB,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAClC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;gBACjB,CAAC,IAAI,CAAC,CAAC;gBACP,OAAO,GAAG,CAAC,CAAC;aACb;YACD,SAAS;SACV;QACD,IAAI,OAAO,GAAG,CAAC,EAAE;YACf,IAAI,OAAO,KAAK,CAAC;gBACf,kBAAkB;oBAChB,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;wBAClC,QAAQ;wBACR,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;iBAC/B;gBACH,kBAAkB;oBAChB,kBAAkB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;wBACtD,IAAA,mBAAS,EAAC,OAAO,CAAC;wBAClB,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAClC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;aAClB;YACD,CAAC,IAAI,CAAC,CAAC;YACP,OAAO,GAAG,CAAC,CAAC;SACb;QACD,IAAI,IAAI,KAAK,aAAa;YAAE,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,KAAK,gBAAgB;YAAE,CAAC,IAAI,CAAC,CAAC;KACvC;IACD,qFAAqF;IACrF,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC"}
|
|
@@ -1,67 +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
|
-
const findLongestDuplicatedString_1 = __importDefault(require("../utils/findLongestDuplicatedString"));
|
|
7
|
-
const findLongestAndSubstitute = ({ compressedCallData, markers, }) => {
|
|
8
|
-
if (!markers)
|
|
9
|
-
markers = [];
|
|
10
|
-
for (let i = 0; i < markers.length; i++) {
|
|
11
|
-
if (!markers[i] || markers[i] === '')
|
|
12
|
-
return {
|
|
13
|
-
newCompressedData: compressedCallData,
|
|
14
|
-
nbOfDuplicatedStrings: i,
|
|
15
|
-
};
|
|
16
|
-
const marker = markers[i];
|
|
17
|
-
let longestDuplicatedStringInCompressedData = (0, findLongestDuplicatedString_1.default)(compressedCallData);
|
|
18
|
-
// Checking if the length of the longest duplicated string is significant
|
|
19
|
-
// TODO: better check conditions to enter this (nb of occurences as well as length)
|
|
20
|
-
if (longestDuplicatedStringInCompressedData.length >= 8) {
|
|
21
|
-
// Creating regular expressions to find the longest duplicated string
|
|
22
|
-
const index = compressedCallData.indexOf(longestDuplicatedStringInCompressedData);
|
|
23
|
-
// If a match is found, surrounder the longest duplicated string with the marker in the compressed data
|
|
24
|
-
// and substitute the other occurences
|
|
25
|
-
if (index > -1) {
|
|
26
|
-
compressedCallData =
|
|
27
|
-
compressedCallData.substring(0, index) +
|
|
28
|
-
marker +
|
|
29
|
-
compressedCallData.substring(index, index + longestDuplicatedStringInCompressedData.length) +
|
|
30
|
-
marker +
|
|
31
|
-
compressedCallData.substring(index + longestDuplicatedStringInCompressedData.length);
|
|
32
|
-
let otherIndex = compressedCallData.indexOf(longestDuplicatedStringInCompressedData, index + 4 + longestDuplicatedStringInCompressedData.length);
|
|
33
|
-
while (otherIndex !== -1) {
|
|
34
|
-
if (otherIndex % 2 === 0) {
|
|
35
|
-
compressedCallData =
|
|
36
|
-
compressedCallData.substring(0, otherIndex) +
|
|
37
|
-
marker +
|
|
38
|
-
compressedCallData.substring(otherIndex + longestDuplicatedStringInCompressedData.length);
|
|
39
|
-
otherIndex = compressedCallData.indexOf(longestDuplicatedStringInCompressedData, otherIndex + 2);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
otherIndex = compressedCallData.indexOf(longestDuplicatedStringInCompressedData, otherIndex + 1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else
|
|
47
|
-
return {
|
|
48
|
-
newCompressedData: compressedCallData,
|
|
49
|
-
nbOfDuplicatedStrings: i,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// If the longest duplicated string is not significant, return the current state of compressed data and count of duplicated strings
|
|
54
|
-
return {
|
|
55
|
-
newCompressedData: compressedCallData,
|
|
56
|
-
nbOfDuplicatedStrings: i,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// After processing for all markers, return the final compressed data and the total number of duplicated strings found
|
|
61
|
-
return {
|
|
62
|
-
newCompressedData: compressedCallData,
|
|
63
|
-
nbOfDuplicatedStrings: markers.length,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
exports.default = findLongestAndSubstitute;
|
|
67
|
-
//# sourceMappingURL=findLongestAndSubstitute.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findLongestAndSubstitute.js","sourceRoot":"","sources":["../../../../src/executor/compressor/compress_functions/findLongestAndSubstitute.ts"],"names":[],"mappings":";;;;;AAAA,uGAA+E;AAE/E,MAAM,wBAAwB,GAAG,CAAC,EAChC,kBAAkB,EAClB,OAAO,GAIR,EAAgE,EAAE;IACjE,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,EAAE,CAAC;IAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;YAClC,OAAO;gBACL,iBAAiB,EAAE,kBAAkB;gBACrC,qBAAqB,EAAE,CAAC;aACzB,CAAC;QAEJ,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE1B,IAAI,uCAAuC,GACzC,IAAA,qCAA2B,EAAC,kBAAkB,CAAC,CAAC;QAElD,yEAAyE;QACzE,mFAAmF;QACnF,IAAI,uCAAuC,CAAC,MAAM,IAAI,CAAC,EAAE;YACvD,qEAAqE;YACrE,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,CACtC,uCAAuC,CACxC,CAAC;YAEF,uGAAuG;YACvG,sCAAsC;YACtC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;gBACd,kBAAkB;oBAChB,kBAAkB,CAAC,SAAS,CAAC,CA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od) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const findLongestDuplicatedString_1 = __importDefault(require("../utils/findLongestDuplicatedString"));
|
|
7
|
-
const findLongestAndSubstitute = ({ compressedCallData, markers, }) => {
|
|
8
|
-
if (!markers)
|
|
9
|
-
markers = [];
|
|
10
|
-
for (let i = 0; i < markers.length; i++) {
|
|
11
|
-
if (!markers[i] || markers[i] === '')
|
|
12
|
-
return {
|
|
13
|
-
newCompressedData: compressedCallData,
|
|
14
|
-
nbOfDuplicatedStrings: i,
|
|
15
|
-
};
|
|
16
|
-
const marker = markers[i];
|
|
17
|
-
let longestDuplicatedStringInCompressedData = (0, findLongestDuplicatedString_1.default)(compressedCallData);
|
|
18
|
-
// Checking if the length of the longest duplicated string is significant
|
|
19
|
-
// TODO: better check conditions to enter this (nb of occurences as well as length)
|
|
20
|
-
if (longestDuplicatedStringInCompressedData.length >= 8) {
|
|
21
|
-
// Creating regular expressions to find the longest duplicated string
|
|
22
|
-
const regexLongest = new RegExp('((^[a-zA-Z0-9]{2})*)' + longestDuplicatedStringInCompressedData);
|
|
23
|
-
const match = regexLongest.exec(compressedCallData);
|
|
24
|
-
// If a match is found, surrounder the longest duplicated string with the marker in the compressed data
|
|
25
|
-
// and substitute the other occurences
|
|
26
|
-
if (match) {
|
|
27
|
-
const indexOfLongest = match.index + match[1].length;
|
|
28
|
-
const regexLongestGlobal = new RegExp('((^[a-zA-Z0-9]{2})*)' + longestDuplicatedStringInCompressedData, 'g');
|
|
29
|
-
compressedCallData =
|
|
30
|
-
compressedCallData.substring(0, indexOfLongest) +
|
|
31
|
-
marker +
|
|
32
|
-
compressedCallData.substring(indexOfLongest, indexOfLongest + longestDuplicatedStringInCompressedData.length) +
|
|
33
|
-
marker +
|
|
34
|
-
compressedCallData
|
|
35
|
-
.substring(indexOfLongest + longestDuplicatedStringInCompressedData.length)
|
|
36
|
-
.replace(regexLongestGlobal, function (m, p1) {
|
|
37
|
-
return p1 + marker;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else
|
|
41
|
-
return {
|
|
42
|
-
newCompressedData: compressedCallData,
|
|
43
|
-
nbOfDuplicatedStrings: i,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// If the longest duplicated string is not significant, return the current state of compressed data and count of duplicated strings
|
|
48
|
-
return {
|
|
49
|
-
newCompressedData: compressedCallData,
|
|
50
|
-
nbOfDuplicatedStrings: i,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// After processing for all markers, return the final compressed data and the total number of duplicated strings found
|
|
55
|
-
return {
|
|
56
|
-
newCompressedData: compressedCallData,
|
|
57
|
-
nbOfDuplicatedStrings: markers.length,
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
exports.default = findLongestAndSubstitute;
|
|
61
|
-
//# sourceMappingURL=findLongestAndSubstitute_old.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findLongestAndSubstitute_old.js","sourceRoot":"","sources":["../../../../src/executor/compressor/compress_functions/findLongestAndSubstitute_old.ts"],"names":[],"mappings":";;;;;AAAA,uGAA+E;AAE/E,MAAM,wBAAwB,GAAG,CAAC,EAChC,kBAAkB,EAClB,OAAO,GAIR,EAAgE,EAAE;IACjE,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,EAAE,CAAC;IAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;YAClC,OAAO;gBACL,iBAAiB,EAAE,kBAAkB;gBACrC,qBAAqB,EAAE,CAAC;aACzB,CAAC;QAEJ,MAAM,MAAM,GAAG,OAAO,CAAC,CA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