envio 2.22.0 → 2.22.1
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/package.json +7 -6
- package/src/Address.res.js +30 -0
- package/src/ChainMap.res.js +77 -0
- package/src/Envio.res.js +16 -0
- package/src/ErrorHandling.res.js +56 -0
- package/src/EventUtils.res.js +75 -0
- package/src/EvmTypes.res.js +16 -0
- package/src/FetchState.res.js +969 -0
- package/src/Hasura.res.js +245 -0
- package/src/Internal.res.js +50 -0
- package/src/LazyLoader.res.js +117 -0
- package/src/LoadManager.res.js +124 -0
- package/src/LogSelection.res.js +203 -0
- package/src/Logging.res.js +247 -0
- package/src/Persistence.res.js +90 -0
- package/src/PgStorage.res.js +125 -0
- package/src/Prometheus.res.js +750 -0
- package/src/ReorgDetection.res.js +223 -0
- package/src/Throttler.res.js +60 -0
- package/src/Time.res.js +41 -0
- package/src/TopicFilter.res.js +86 -0
- package/src/Utils.res.js +527 -0
- package/src/bindings/BigDecimal.res.js +41 -0
- package/src/bindings/BigInt.res.js +138 -0
- package/src/bindings/Ethers.res.js +109 -0
- package/src/bindings/Express.res.js +2 -0
- package/src/bindings/Hrtime.res.js +66 -0
- package/src/bindings/NodeJs.res.js +29 -0
- package/src/bindings/Pino.res.js +95 -0
- package/src/bindings/Postgres.res.js +16 -0
- package/src/bindings/PromClient.res.js +17 -0
- package/src/bindings/Promise.res.js +25 -0
- package/src/bindings/SDSL.res.js +8 -0
- package/src/bindings/Viem.res.js +45 -0
- package/src/db/EntityHistory.res.js +307 -0
- package/src/db/Schema.res.js +54 -0
- package/src/db/Table.res.js +365 -0
- package/src/sources/Fuel.res.js +28 -0
- package/src/sources/HyperFuel.res.js +193 -0
- package/src/sources/HyperFuelClient.res.js +19 -0
- package/src/sources/HyperSync.res.js +301 -0
- package/src/sources/HyperSyncClient.res.js +99 -0
- package/src/sources/HyperSyncJsonApi.res.js +259 -0
- package/src/sources/Rpc.res.js +198 -0
- package/src/sources/Source.res.js +9 -0
- package/src/sources/SourceManager.res.js +366 -0
- package/src/vendored/Rest.res.js +574 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var Js_exn = require("rescript/lib/js/js_exn.js");
|
|
5
|
+
var Js_dict = require("rescript/lib/js/js_dict.js");
|
|
6
|
+
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
7
|
+
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
8
|
+
|
|
9
|
+
function reorgDetectedToLogParams(reorgDetected, shouldRollbackOnReorg) {
|
|
10
|
+
var scannedBlock = reorgDetected.scannedBlock;
|
|
11
|
+
return {
|
|
12
|
+
msg: "Blockchain reorg detected. " + (
|
|
13
|
+
shouldRollbackOnReorg ? "Initiating indexer rollback" : "NOT initiating indexer rollback due to configuration"
|
|
14
|
+
) + ".",
|
|
15
|
+
blockNumber: scannedBlock.blockNumber,
|
|
16
|
+
indexedBlockHash: scannedBlock.blockHash,
|
|
17
|
+
receivedBlockHash: reorgDetected.receivedBlock.blockHash
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function makeWithData(blocks, confirmedBlockThreshold, detectedReorgBlock) {
|
|
22
|
+
var dataByBlockNumber = {};
|
|
23
|
+
Belt_Array.forEach(blocks, (function (block) {
|
|
24
|
+
dataByBlockNumber[block.blockNumber.toString()] = block;
|
|
25
|
+
}));
|
|
26
|
+
return {
|
|
27
|
+
confirmedBlockThreshold: confirmedBlockThreshold,
|
|
28
|
+
dataByBlockNumber: dataByBlockNumber,
|
|
29
|
+
detectedReorgBlock: detectedReorgBlock
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function empty(confirmedBlockThreshold) {
|
|
34
|
+
return {
|
|
35
|
+
confirmedBlockThreshold: confirmedBlockThreshold,
|
|
36
|
+
dataByBlockNumber: {},
|
|
37
|
+
detectedReorgBlock: undefined
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getDataByBlockNumberCopyInThreshold(param, currentBlockHeight) {
|
|
42
|
+
var dataByBlockNumber = param.dataByBlockNumber;
|
|
43
|
+
var ascBlockNumberKeys = Object.keys(dataByBlockNumber);
|
|
44
|
+
var thresholdBlockNumber = currentBlockHeight - param.confirmedBlockThreshold | 0;
|
|
45
|
+
var copy = {};
|
|
46
|
+
for(var idx = 0 ,idx_finish = ascBlockNumberKeys.length; idx < idx_finish; ++idx){
|
|
47
|
+
var blockNumberKey = ascBlockNumberKeys[idx];
|
|
48
|
+
var scannedBlock = dataByBlockNumber[blockNumberKey];
|
|
49
|
+
var isInReorgThreshold = scannedBlock.blockNumber >= thresholdBlockNumber;
|
|
50
|
+
if (isInReorgThreshold) {
|
|
51
|
+
copy[blockNumberKey] = scannedBlock;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
return copy;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function registerReorgGuard(self, reorgGuard, currentBlockHeight, shouldRollbackOnReorg) {
|
|
59
|
+
var confirmedBlockThreshold = self.confirmedBlockThreshold;
|
|
60
|
+
var dataByBlockNumberCopyInThreshold = getDataByBlockNumberCopyInThreshold(self, currentBlockHeight);
|
|
61
|
+
var prevRangeLastBlock = reorgGuard.prevRangeLastBlock;
|
|
62
|
+
var rangeLastBlock = reorgGuard.rangeLastBlock;
|
|
63
|
+
var scannedBlock = dataByBlockNumberCopyInThreshold[String(rangeLastBlock.blockNumber)];
|
|
64
|
+
var maybeReorgDetected;
|
|
65
|
+
var exit = 0;
|
|
66
|
+
if (scannedBlock !== undefined && scannedBlock.blockHash !== rangeLastBlock.blockHash) {
|
|
67
|
+
maybeReorgDetected = {
|
|
68
|
+
scannedBlock: scannedBlock,
|
|
69
|
+
receivedBlock: rangeLastBlock
|
|
70
|
+
};
|
|
71
|
+
} else {
|
|
72
|
+
exit = 1;
|
|
73
|
+
}
|
|
74
|
+
if (exit === 1) {
|
|
75
|
+
if (prevRangeLastBlock !== undefined) {
|
|
76
|
+
var scannedBlock$1 = dataByBlockNumberCopyInThreshold[String(prevRangeLastBlock.blockNumber)];
|
|
77
|
+
maybeReorgDetected = scannedBlock$1 !== undefined && scannedBlock$1.blockHash !== prevRangeLastBlock.blockHash ? ({
|
|
78
|
+
scannedBlock: scannedBlock$1,
|
|
79
|
+
receivedBlock: prevRangeLastBlock
|
|
80
|
+
}) : undefined;
|
|
81
|
+
} else {
|
|
82
|
+
maybeReorgDetected = undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (maybeReorgDetected !== undefined) {
|
|
86
|
+
return [
|
|
87
|
+
shouldRollbackOnReorg ? ({
|
|
88
|
+
confirmedBlockThreshold: self.confirmedBlockThreshold,
|
|
89
|
+
dataByBlockNumber: self.dataByBlockNumber,
|
|
90
|
+
detectedReorgBlock: maybeReorgDetected.scannedBlock
|
|
91
|
+
}) : empty(confirmedBlockThreshold),
|
|
92
|
+
{
|
|
93
|
+
TAG: "ReorgDetected",
|
|
94
|
+
_0: maybeReorgDetected
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
} else {
|
|
98
|
+
dataByBlockNumberCopyInThreshold[String(rangeLastBlock.blockNumber)] = rangeLastBlock;
|
|
99
|
+
if (prevRangeLastBlock !== undefined) {
|
|
100
|
+
dataByBlockNumberCopyInThreshold[String(prevRangeLastBlock.blockNumber)] = prevRangeLastBlock;
|
|
101
|
+
}
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
confirmedBlockThreshold: confirmedBlockThreshold,
|
|
105
|
+
dataByBlockNumber: dataByBlockNumberCopyInThreshold,
|
|
106
|
+
detectedReorgBlock: undefined
|
|
107
|
+
},
|
|
108
|
+
"NoReorg"
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getLatestValidScannedBlock(self, blockNumbersAndHashes, currentBlockHeight, skipReorgDuplicationCheckOpt) {
|
|
114
|
+
var skipReorgDuplicationCheck = skipReorgDuplicationCheckOpt !== undefined ? skipReorgDuplicationCheckOpt : false;
|
|
115
|
+
var verifiedDataByBlockNumber = {};
|
|
116
|
+
for(var idx = 0 ,idx_finish = blockNumbersAndHashes.length; idx < idx_finish; ++idx){
|
|
117
|
+
var blockData = blockNumbersAndHashes[idx];
|
|
118
|
+
verifiedDataByBlockNumber[String(blockData.blockNumber)] = blockData;
|
|
119
|
+
}
|
|
120
|
+
var isAlreadyReorgedResponse;
|
|
121
|
+
if (skipReorgDuplicationCheck) {
|
|
122
|
+
isAlreadyReorgedResponse = false;
|
|
123
|
+
} else {
|
|
124
|
+
var detectedReorgBlock = self.detectedReorgBlock;
|
|
125
|
+
if (detectedReorgBlock !== undefined) {
|
|
126
|
+
var verifiedBlockData = verifiedDataByBlockNumber[String(detectedReorgBlock.blockNumber)];
|
|
127
|
+
isAlreadyReorgedResponse = verifiedBlockData !== undefined ? verifiedBlockData.blockHash === detectedReorgBlock.blockHash : false;
|
|
128
|
+
} else {
|
|
129
|
+
isAlreadyReorgedResponse = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (isAlreadyReorgedResponse) {
|
|
133
|
+
return {
|
|
134
|
+
TAG: "Error",
|
|
135
|
+
_0: "AlreadyReorgedHashes"
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var dataByBlockNumber = getDataByBlockNumberCopyInThreshold(self, currentBlockHeight);
|
|
139
|
+
var ascBlockNumberKeys = Object.keys(dataByBlockNumber);
|
|
140
|
+
var getPrevScannedBlock = function (idx) {
|
|
141
|
+
var data = Belt_Option.flatMap(Belt_Array.get(ascBlockNumberKeys, idx - 1 | 0), (function (key) {
|
|
142
|
+
return verifiedDataByBlockNumber[key];
|
|
143
|
+
}));
|
|
144
|
+
if (data !== undefined) {
|
|
145
|
+
return {
|
|
146
|
+
TAG: "Ok",
|
|
147
|
+
_0: data
|
|
148
|
+
};
|
|
149
|
+
} else {
|
|
150
|
+
return {
|
|
151
|
+
TAG: "Error",
|
|
152
|
+
_0: "NotFound"
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var _idx = 0;
|
|
157
|
+
while(true) {
|
|
158
|
+
var idx$1 = _idx;
|
|
159
|
+
var blockNumberKey = Belt_Array.get(ascBlockNumberKeys, idx$1);
|
|
160
|
+
if (blockNumberKey === undefined) {
|
|
161
|
+
return getPrevScannedBlock(idx$1);
|
|
162
|
+
}
|
|
163
|
+
var scannedBlock = dataByBlockNumber[blockNumberKey];
|
|
164
|
+
var verifiedBlockData$1 = verifiedDataByBlockNumber[blockNumberKey];
|
|
165
|
+
if (verifiedBlockData$1 === undefined) {
|
|
166
|
+
return Js_exn.raiseError("Unexpected case. Couldn't find verified hash for block number " + blockNumberKey);
|
|
167
|
+
}
|
|
168
|
+
if (verifiedBlockData$1.blockHash !== scannedBlock.blockHash) {
|
|
169
|
+
return getPrevScannedBlock(idx$1);
|
|
170
|
+
}
|
|
171
|
+
_idx = idx$1 + 1 | 0;
|
|
172
|
+
continue ;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function rollbackToValidBlockNumber(param, blockNumber) {
|
|
177
|
+
var dataByBlockNumber = param.dataByBlockNumber;
|
|
178
|
+
var ascBlockNumberKeys = Object.keys(dataByBlockNumber);
|
|
179
|
+
var newDataByBlockNumber = {};
|
|
180
|
+
var loop = function (_idx) {
|
|
181
|
+
while(true) {
|
|
182
|
+
var idx = _idx;
|
|
183
|
+
var blockNumberKey = Belt_Array.get(ascBlockNumberKeys, idx);
|
|
184
|
+
if (blockNumberKey === undefined) {
|
|
185
|
+
return ;
|
|
186
|
+
}
|
|
187
|
+
var scannedBlock = dataByBlockNumber[blockNumberKey];
|
|
188
|
+
var shouldKeep = scannedBlock.blockNumber <= blockNumber;
|
|
189
|
+
if (!shouldKeep) {
|
|
190
|
+
return ;
|
|
191
|
+
}
|
|
192
|
+
newDataByBlockNumber[blockNumberKey] = scannedBlock;
|
|
193
|
+
_idx = idx + 1 | 0;
|
|
194
|
+
continue ;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
loop(0);
|
|
198
|
+
return {
|
|
199
|
+
confirmedBlockThreshold: param.confirmedBlockThreshold,
|
|
200
|
+
dataByBlockNumber: newDataByBlockNumber,
|
|
201
|
+
detectedReorgBlock: undefined
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function getThresholdBlockNumbers(self, currentBlockHeight) {
|
|
206
|
+
var dataByBlockNumberCopyInThreshold = getDataByBlockNumberCopyInThreshold(self, currentBlockHeight);
|
|
207
|
+
return Js_dict.values(dataByBlockNumberCopyInThreshold).map(function (v) {
|
|
208
|
+
return v.blockNumber;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
var LastBlockScannedHashes = {
|
|
213
|
+
makeWithData: makeWithData,
|
|
214
|
+
empty: empty,
|
|
215
|
+
registerReorgGuard: registerReorgGuard,
|
|
216
|
+
getLatestValidScannedBlock: getLatestValidScannedBlock,
|
|
217
|
+
getThresholdBlockNumbers: getThresholdBlockNumbers,
|
|
218
|
+
rollbackToValidBlockNumber: rollbackToValidBlockNumber
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
exports.reorgDetectedToLogParams = reorgDetectedToLogParams;
|
|
222
|
+
exports.LastBlockScannedHashes = LastBlockScannedHashes;
|
|
223
|
+
/* No side effect */
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var Pino = require("./bindings/Pino.res.js");
|
|
5
|
+
var Caml_js_exceptions = require("rescript/lib/js/caml_js_exceptions.js");
|
|
6
|
+
|
|
7
|
+
function make(intervalMillis, logger) {
|
|
8
|
+
return {
|
|
9
|
+
lastRunTimeMillis: 0,
|
|
10
|
+
isRunning: false,
|
|
11
|
+
isAwaitingInterval: false,
|
|
12
|
+
scheduled: undefined,
|
|
13
|
+
intervalMillis: intervalMillis,
|
|
14
|
+
logger: logger
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function startInternal(throttler) {
|
|
19
|
+
var match = throttler.isRunning;
|
|
20
|
+
if (match) {
|
|
21
|
+
return ;
|
|
22
|
+
}
|
|
23
|
+
var match$1 = throttler.isAwaitingInterval;
|
|
24
|
+
if (match$1) {
|
|
25
|
+
return ;
|
|
26
|
+
}
|
|
27
|
+
var fn = throttler.scheduled;
|
|
28
|
+
if (fn === undefined) {
|
|
29
|
+
return ;
|
|
30
|
+
}
|
|
31
|
+
var timeSinceLastRun = Date.now() - throttler.lastRunTimeMillis;
|
|
32
|
+
if (timeSinceLastRun >= throttler.intervalMillis) {
|
|
33
|
+
throttler.isRunning = true;
|
|
34
|
+
throttler.scheduled = undefined;
|
|
35
|
+
throttler.lastRunTimeMillis = Date.now();
|
|
36
|
+
try {
|
|
37
|
+
await fn();
|
|
38
|
+
}
|
|
39
|
+
catch (raw_exn){
|
|
40
|
+
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
41
|
+
throttler.logger.error(Pino.createPinoMessageWithError("Scheduled action failed in throttler", exn));
|
|
42
|
+
}
|
|
43
|
+
throttler.isRunning = false;
|
|
44
|
+
return await startInternal(throttler);
|
|
45
|
+
}
|
|
46
|
+
throttler.isAwaitingInterval = true;
|
|
47
|
+
setTimeout((function () {
|
|
48
|
+
throttler.isAwaitingInterval = false;
|
|
49
|
+
startInternal(throttler);
|
|
50
|
+
}), throttler.intervalMillis - timeSinceLastRun | 0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function schedule(throttler, fn) {
|
|
54
|
+
throttler.scheduled = fn;
|
|
55
|
+
startInternal(throttler);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.make = make;
|
|
59
|
+
exports.schedule = schedule;
|
|
60
|
+
/* Pino Not a pure module */
|
package/src/Time.res.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var Utils = require("./Utils.res.js");
|
|
5
|
+
var Logging = require("./Logging.res.js");
|
|
6
|
+
var Internal = require("./Internal.res.js");
|
|
7
|
+
var ErrorHandling = require("./ErrorHandling.res.js");
|
|
8
|
+
var Caml_js_exceptions = require("rescript/lib/js/caml_js_exceptions.js");
|
|
9
|
+
|
|
10
|
+
function resolvePromiseAfterDelay(delayMilliseconds) {
|
|
11
|
+
return Utils.delay(delayMilliseconds);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function retryAsyncWithExponentialBackOff(backOffMillisOpt, multiplicativeOpt, retryCountOpt, maxRetriesOpt, logger, f) {
|
|
15
|
+
var backOffMillis = backOffMillisOpt !== undefined ? backOffMillisOpt : 100;
|
|
16
|
+
var multiplicative = multiplicativeOpt !== undefined ? multiplicativeOpt : 4;
|
|
17
|
+
var retryCount = retryCountOpt !== undefined ? retryCountOpt : 0;
|
|
18
|
+
var maxRetries = maxRetriesOpt !== undefined ? maxRetriesOpt : 5;
|
|
19
|
+
try {
|
|
20
|
+
return await f();
|
|
21
|
+
}
|
|
22
|
+
catch (raw_exn){
|
|
23
|
+
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
24
|
+
if (retryCount < maxRetries) {
|
|
25
|
+
var nextRetryCount = retryCount + 1 | 0;
|
|
26
|
+
var log = retryCount === 0 ? Logging.childTrace : Logging.childWarn;
|
|
27
|
+
log(logger, {
|
|
28
|
+
msg: "Retrying query " + String(nextRetryCount) + "/" + String(maxRetries) + " in " + String(backOffMillis) + "ms - waiting for correct result.",
|
|
29
|
+
err: Internal.prettifyExn(exn)
|
|
30
|
+
});
|
|
31
|
+
await Utils.delay(backOffMillis);
|
|
32
|
+
return await retryAsyncWithExponentialBackOff(Math.imul(backOffMillis, multiplicative), multiplicative, nextRetryCount, maxRetries, logger, f);
|
|
33
|
+
}
|
|
34
|
+
ErrorHandling.log(ErrorHandling.make(exn, logger, "Failure. Max retries " + String(retryCount) + "/" + String(maxRetries) + " exceeded"));
|
|
35
|
+
return await Promise.reject(Caml_js_exceptions.internalToOCamlException(exn));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.resolvePromiseAfterDelay = resolvePromiseAfterDelay;
|
|
40
|
+
exports.retryAsyncWithExponentialBackOff = retryAsyncWithExponentialBackOff;
|
|
41
|
+
/* Utils Not a pure module */
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var Viem = require("viem");
|
|
5
|
+
var $$BigInt = require("./bindings/BigInt.res.js");
|
|
6
|
+
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
7
|
+
|
|
8
|
+
function toTwosComplement(num, bytesLen) {
|
|
9
|
+
var maxValue = $$BigInt.Bitwise.shift_left(1n, BigInt((bytesLen << 3)));
|
|
10
|
+
var mask = $$BigInt.sub(maxValue, 1n);
|
|
11
|
+
return $$BigInt.Bitwise.logand($$BigInt.add(num, maxValue), mask);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function fromSignedBigInt(val) {
|
|
15
|
+
var val$1 = val >= 0n ? val : toTwosComplement(val, 32);
|
|
16
|
+
return Viem.numberToHex(val$1, {
|
|
17
|
+
size: 32
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function keccak256(prim) {
|
|
22
|
+
return Viem.keccak256(prim);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function bytesToHex(prim0, prim1) {
|
|
26
|
+
return Viem.bytesToHex(prim0, prim1 !== undefined ? Caml_option.valFromOption(prim1) : undefined);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function concat(prim) {
|
|
30
|
+
return Viem.concat(prim);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function castToHexUnsafe(val) {
|
|
34
|
+
return val;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function fromBigInt(val) {
|
|
38
|
+
return Viem.numberToHex(val, {
|
|
39
|
+
size: 32
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function fromDynamicString(val) {
|
|
44
|
+
return Viem.keccak256(val);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function fromString(val) {
|
|
48
|
+
return Viem.stringToHex(val, {
|
|
49
|
+
size: 32
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function fromAddress(addr) {
|
|
54
|
+
return Viem.pad(addr);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function fromDynamicBytes(bytes) {
|
|
58
|
+
return Viem.keccak256(bytes);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function fromBytes(bytes) {
|
|
62
|
+
return Viem.bytesToHex(bytes, {
|
|
63
|
+
size: 32
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function fromBool(b) {
|
|
68
|
+
return Viem.boolToHex(b, {
|
|
69
|
+
size: 32
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.toTwosComplement = toTwosComplement;
|
|
74
|
+
exports.fromSignedBigInt = fromSignedBigInt;
|
|
75
|
+
exports.keccak256 = keccak256;
|
|
76
|
+
exports.bytesToHex = bytesToHex;
|
|
77
|
+
exports.concat = concat;
|
|
78
|
+
exports.castToHexUnsafe = castToHexUnsafe;
|
|
79
|
+
exports.fromBigInt = fromBigInt;
|
|
80
|
+
exports.fromDynamicString = fromDynamicString;
|
|
81
|
+
exports.fromString = fromString;
|
|
82
|
+
exports.fromAddress = fromAddress;
|
|
83
|
+
exports.fromDynamicBytes = fromDynamicBytes;
|
|
84
|
+
exports.fromBytes = fromBytes;
|
|
85
|
+
exports.fromBool = fromBool;
|
|
86
|
+
/* viem Not a pure module */
|