Files
Victorien Gauch f58c12a455 Feat/272 split sdk and postman (#381)
* feat: split postman and sdk

* fix: update postman client and sendMessage script

* fix: clean the sdk

* fix: update sdk dependencies

* fix: remove .env.sample file

* fix: remove testing helpers from the build

* fix: update gas provider in linea sdk and update postman client

* fix: update postman dependencies

* fix: update postman dockerfile and fix tests imports and types

* fix: remove unused code in the sdk + move typechain folder

* fix: remove unused code + fix imports in postman

* fix: pnpm lock file issue

* fix: import issue

* fix: case sensitive file issue

* fix: update sdk fees options and update exports

* fix: remove postman unused code and adjust imports and tests

* fix: update contracts abis + clean error parsing

* fix: update postman based on new SDk changes

* add readme + remove unused interface in postman

* fix: rename Base.ts file to BaseError.ts

* fix: rename Base.ts file to BaseError.ts in postman

* chore: update readme for the postman

* fix: rename maxFeePerGas to maxFeePerGasCap

* fix: update DefaultGasProvider fees check

* fix: default gas provider test issue

* fix: update main ci filter

* fix: issue in default gas provider
2024-12-09 12:12:45 +01:00

33 lines
917 B
TypeScript

const HEXADECIMAL_REGEX = new RegExp("^0[xX][0-9a-fA-F]+$");
const ADDRESS_HEX_STR_SIZE = 42;
const PRIVKEY_HEX_STR_SIZE = 66;
function sanitizeHexBytes(paramName: string, value: string, expectedSize: number) {
if (!value.startsWith("0x")) {
value = "0x" + value;
}
if (!HEXADECIMAL_REGEX.test(value)) {
throw new Error(`${paramName}: '${value}' is not a valid Hexadecimal notation!`);
}
if (value.length !== expectedSize) {
throw new Error(`${paramName} has size ${value.length} expected ${expectedSize}`);
}
return value;
}
function sanitizeAddress(argName: string) {
return (input: string) => {
return sanitizeHexBytes(argName, input, ADDRESS_HEX_STR_SIZE);
};
}
function sanitizePrivKey(argName: string) {
return (input: string) => {
return sanitizeHexBytes(argName, input, PRIVKEY_HEX_STR_SIZE);
};
}
export { sanitizeHexBytes, sanitizeAddress, sanitizePrivKey };