123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656 |
- // SPDX-License-Identifier: MIT
- // OpenZeppelin Contracts (last updated v5.1.0) (utils/Packing.sol)
- // This file was procedurally generated from scripts/generate/templates/Packing.js.
- pragma solidity ^0.8.20;
- /**
- * @dev Helper library packing and unpacking multiple values into bytesXX.
- *
- * Example usage:
- *
- * ```solidity
- * library MyPacker {
- * type MyType is bytes32;
- *
- * function _pack(address account, bytes4 selector, uint64 period) external pure returns (MyType) {
- * bytes12 subpack = Packing.pack_4_8(selector, bytes8(period));
- * bytes32 pack = Packing.pack_20_12(bytes20(account), subpack);
- * return MyType.wrap(pack);
- * }
- *
- * function _unpack(MyType self) external pure returns (address, bytes4, uint64) {
- * bytes32 pack = MyType.unwrap(self);
- * return (
- * address(Packing.extract_32_20(pack, 0)),
- * Packing.extract_32_4(pack, 20),
- * uint64(Packing.extract_32_8(pack, 24))
- * );
- * }
- * }
- * ```
- *
- * _Available since v5.1._
- */
- // solhint-disable func-name-mixedcase
- library Packing {
- error OutOfRangeAccess();
- function pack_1_1(bytes1 left, bytes1 right) internal pure returns (bytes2 result) {
- assembly ("memory-safe") {
- left := and(left, shl(248, not(0)))
- right := and(right, shl(248, not(0)))
- result := or(left, shr(8, right))
- }
- }
- function pack_2_2(bytes2 left, bytes2 right) internal pure returns (bytes4 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_2_4(bytes2 left, bytes4 right) internal pure returns (bytes6 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_2_6(bytes2 left, bytes6 right) internal pure returns (bytes8 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(208, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_2_8(bytes2 left, bytes8 right) internal pure returns (bytes10 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_2_10(bytes2 left, bytes10 right) internal pure returns (bytes12 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(176, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_2_20(bytes2 left, bytes20 right) internal pure returns (bytes22 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(96, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_2_22(bytes2 left, bytes22 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(240, not(0)))
- right := and(right, shl(80, not(0)))
- result := or(left, shr(16, right))
- }
- }
- function pack_4_2(bytes4 left, bytes2 right) internal pure returns (bytes6 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_4(bytes4 left, bytes4 right) internal pure returns (bytes8 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_6(bytes4 left, bytes6 right) internal pure returns (bytes10 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(208, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_8(bytes4 left, bytes8 right) internal pure returns (bytes12 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_12(bytes4 left, bytes12 right) internal pure returns (bytes16 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(160, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_16(bytes4 left, bytes16 right) internal pure returns (bytes20 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(128, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_20(bytes4 left, bytes20 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(96, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_24(bytes4 left, bytes24 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(64, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_4_28(bytes4 left, bytes28 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(224, not(0)))
- right := and(right, shl(32, not(0)))
- result := or(left, shr(32, right))
- }
- }
- function pack_6_2(bytes6 left, bytes2 right) internal pure returns (bytes8 result) {
- assembly ("memory-safe") {
- left := and(left, shl(208, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(48, right))
- }
- }
- function pack_6_4(bytes6 left, bytes4 right) internal pure returns (bytes10 result) {
- assembly ("memory-safe") {
- left := and(left, shl(208, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(48, right))
- }
- }
- function pack_6_6(bytes6 left, bytes6 right) internal pure returns (bytes12 result) {
- assembly ("memory-safe") {
- left := and(left, shl(208, not(0)))
- right := and(right, shl(208, not(0)))
- result := or(left, shr(48, right))
- }
- }
- function pack_6_10(bytes6 left, bytes10 right) internal pure returns (bytes16 result) {
- assembly ("memory-safe") {
- left := and(left, shl(208, not(0)))
- right := and(right, shl(176, not(0)))
- result := or(left, shr(48, right))
- }
- }
- function pack_6_16(bytes6 left, bytes16 right) internal pure returns (bytes22 result) {
- assembly ("memory-safe") {
- left := and(left, shl(208, not(0)))
- right := and(right, shl(128, not(0)))
- result := or(left, shr(48, right))
- }
- }
- function pack_6_22(bytes6 left, bytes22 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(208, not(0)))
- right := and(right, shl(80, not(0)))
- result := or(left, shr(48, right))
- }
- }
- function pack_8_2(bytes8 left, bytes2 right) internal pure returns (bytes10 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_8_4(bytes8 left, bytes4 right) internal pure returns (bytes12 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_8_8(bytes8 left, bytes8 right) internal pure returns (bytes16 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_8_12(bytes8 left, bytes12 right) internal pure returns (bytes20 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(160, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_8_16(bytes8 left, bytes16 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(128, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_8_20(bytes8 left, bytes20 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(96, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_8_24(bytes8 left, bytes24 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(192, not(0)))
- right := and(right, shl(64, not(0)))
- result := or(left, shr(64, right))
- }
- }
- function pack_10_2(bytes10 left, bytes2 right) internal pure returns (bytes12 result) {
- assembly ("memory-safe") {
- left := and(left, shl(176, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(80, right))
- }
- }
- function pack_10_6(bytes10 left, bytes6 right) internal pure returns (bytes16 result) {
- assembly ("memory-safe") {
- left := and(left, shl(176, not(0)))
- right := and(right, shl(208, not(0)))
- result := or(left, shr(80, right))
- }
- }
- function pack_10_10(bytes10 left, bytes10 right) internal pure returns (bytes20 result) {
- assembly ("memory-safe") {
- left := and(left, shl(176, not(0)))
- right := and(right, shl(176, not(0)))
- result := or(left, shr(80, right))
- }
- }
- function pack_10_12(bytes10 left, bytes12 right) internal pure returns (bytes22 result) {
- assembly ("memory-safe") {
- left := and(left, shl(176, not(0)))
- right := and(right, shl(160, not(0)))
- result := or(left, shr(80, right))
- }
- }
- function pack_10_22(bytes10 left, bytes22 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(176, not(0)))
- right := and(right, shl(80, not(0)))
- result := or(left, shr(80, right))
- }
- }
- function pack_12_4(bytes12 left, bytes4 right) internal pure returns (bytes16 result) {
- assembly ("memory-safe") {
- left := and(left, shl(160, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(96, right))
- }
- }
- function pack_12_8(bytes12 left, bytes8 right) internal pure returns (bytes20 result) {
- assembly ("memory-safe") {
- left := and(left, shl(160, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(96, right))
- }
- }
- function pack_12_10(bytes12 left, bytes10 right) internal pure returns (bytes22 result) {
- assembly ("memory-safe") {
- left := and(left, shl(160, not(0)))
- right := and(right, shl(176, not(0)))
- result := or(left, shr(96, right))
- }
- }
- function pack_12_12(bytes12 left, bytes12 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(160, not(0)))
- right := and(right, shl(160, not(0)))
- result := or(left, shr(96, right))
- }
- }
- function pack_12_16(bytes12 left, bytes16 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(160, not(0)))
- right := and(right, shl(128, not(0)))
- result := or(left, shr(96, right))
- }
- }
- function pack_12_20(bytes12 left, bytes20 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(160, not(0)))
- right := and(right, shl(96, not(0)))
- result := or(left, shr(96, right))
- }
- }
- function pack_16_4(bytes16 left, bytes4 right) internal pure returns (bytes20 result) {
- assembly ("memory-safe") {
- left := and(left, shl(128, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(128, right))
- }
- }
- function pack_16_6(bytes16 left, bytes6 right) internal pure returns (bytes22 result) {
- assembly ("memory-safe") {
- left := and(left, shl(128, not(0)))
- right := and(right, shl(208, not(0)))
- result := or(left, shr(128, right))
- }
- }
- function pack_16_8(bytes16 left, bytes8 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(128, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(128, right))
- }
- }
- function pack_16_12(bytes16 left, bytes12 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(128, not(0)))
- right := and(right, shl(160, not(0)))
- result := or(left, shr(128, right))
- }
- }
- function pack_16_16(bytes16 left, bytes16 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(128, not(0)))
- right := and(right, shl(128, not(0)))
- result := or(left, shr(128, right))
- }
- }
- function pack_20_2(bytes20 left, bytes2 right) internal pure returns (bytes22 result) {
- assembly ("memory-safe") {
- left := and(left, shl(96, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(160, right))
- }
- }
- function pack_20_4(bytes20 left, bytes4 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(96, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(160, right))
- }
- }
- function pack_20_8(bytes20 left, bytes8 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(96, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(160, right))
- }
- }
- function pack_20_12(bytes20 left, bytes12 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(96, not(0)))
- right := and(right, shl(160, not(0)))
- result := or(left, shr(160, right))
- }
- }
- function pack_22_2(bytes22 left, bytes2 right) internal pure returns (bytes24 result) {
- assembly ("memory-safe") {
- left := and(left, shl(80, not(0)))
- right := and(right, shl(240, not(0)))
- result := or(left, shr(176, right))
- }
- }
- function pack_22_6(bytes22 left, bytes6 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(80, not(0)))
- right := and(right, shl(208, not(0)))
- result := or(left, shr(176, right))
- }
- }
- function pack_22_10(bytes22 left, bytes10 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(80, not(0)))
- right := and(right, shl(176, not(0)))
- result := or(left, shr(176, right))
- }
- }
- function pack_24_4(bytes24 left, bytes4 right) internal pure returns (bytes28 result) {
- assembly ("memory-safe") {
- left := and(left, shl(64, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(192, right))
- }
- }
- function pack_24_8(bytes24 left, bytes8 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(64, not(0)))
- right := and(right, shl(192, not(0)))
- result := or(left, shr(192, right))
- }
- }
- function pack_28_4(bytes28 left, bytes4 right) internal pure returns (bytes32 result) {
- assembly ("memory-safe") {
- left := and(left, shl(32, not(0)))
- right := and(right, shl(224, not(0)))
- result := or(left, shr(224, right))
- }
- }
- function extract_2_1(bytes2 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 1) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_2_1(bytes2 self, bytes1 value, uint8 offset) internal pure returns (bytes2 result) {
- bytes1 oldValue = extract_2_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_4_1(bytes4 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 3) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_4_1(bytes4 self, bytes1 value, uint8 offset) internal pure returns (bytes4 result) {
- bytes1 oldValue = extract_4_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_4_2(bytes4 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_4_2(bytes4 self, bytes2 value, uint8 offset) internal pure returns (bytes4 result) {
- bytes2 oldValue = extract_4_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_6_1(bytes6 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 5) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_6_1(bytes6 self, bytes1 value, uint8 offset) internal pure returns (bytes6 result) {
- bytes1 oldValue = extract_6_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_6_2(bytes6 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_6_2(bytes6 self, bytes2 value, uint8 offset) internal pure returns (bytes6 result) {
- bytes2 oldValue = extract_6_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_6_4(bytes6 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_6_4(bytes6 self, bytes4 value, uint8 offset) internal pure returns (bytes6 result) {
- bytes4 oldValue = extract_6_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_8_1(bytes8 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 7) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_8_1(bytes8 self, bytes1 value, uint8 offset) internal pure returns (bytes8 result) {
- bytes1 oldValue = extract_8_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_8_2(bytes8 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 6) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_8_2(bytes8 self, bytes2 value, uint8 offset) internal pure returns (bytes8 result) {
- bytes2 oldValue = extract_8_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_8_4(bytes8 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_8_4(bytes8 self, bytes4 value, uint8 offset) internal pure returns (bytes8 result) {
- bytes4 oldValue = extract_8_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_8_6(bytes8 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_8_6(bytes8 self, bytes6 value, uint8 offset) internal pure returns (bytes8 result) {
- bytes6 oldValue = extract_8_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_10_1(bytes10 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 9) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_10_1(bytes10 self, bytes1 value, uint8 offset) internal pure returns (bytes10 result) {
- bytes1 oldValue = extract_10_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_10_2(bytes10 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_10_2(bytes10 self, bytes2 value, uint8 offset) internal pure returns (bytes10 result) {
- bytes2 oldValue = extract_10_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_10_4(bytes10 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 6) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_10_4(bytes10 self, bytes4 value, uint8 offset) internal pure returns (bytes10 result) {
- bytes4 oldValue = extract_10_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_10_6(bytes10 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_10_6(bytes10 self, bytes6 value, uint8 offset) internal pure returns (bytes10 result) {
- bytes6 oldValue = extract_10_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_10_8(bytes10 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_10_8(bytes10 self, bytes8 value, uint8 offset) internal pure returns (bytes10 result) {
- bytes8 oldValue = extract_10_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_12_1(bytes12 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 11) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_12_1(bytes12 self, bytes1 value, uint8 offset) internal pure returns (bytes12 result) {
- bytes1 oldValue = extract_12_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_12_2(bytes12 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 10) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_12_2(bytes12 self, bytes2 value, uint8 offset) internal pure returns (bytes12 result) {
- bytes2 oldValue = extract_12_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_12_4(bytes12 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_12_4(bytes12 self, bytes4 value, uint8 offset) internal pure returns (bytes12 result) {
- bytes4 oldValue = extract_12_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_12_6(bytes12 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 6) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_12_6(bytes12 self, bytes6 value, uint8 offset) internal pure returns (bytes12 result) {
- bytes6 oldValue = extract_12_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_12_8(bytes12 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_12_8(bytes12 self, bytes8 value, uint8 offset) internal pure returns (bytes12 result) {
- bytes8 oldValue = extract_12_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_12_10(bytes12 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_12_10(bytes12 self, bytes10 value, uint8 offset) internal pure returns (bytes12 result) {
- bytes10 oldValue = extract_12_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_1(bytes16 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 15) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_16_1(bytes16 self, bytes1 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes1 oldValue = extract_16_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_2(bytes16 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 14) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_16_2(bytes16 self, bytes2 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes2 oldValue = extract_16_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_4(bytes16 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 12) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_16_4(bytes16 self, bytes4 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes4 oldValue = extract_16_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_6(bytes16 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 10) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_16_6(bytes16 self, bytes6 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes6 oldValue = extract_16_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_8(bytes16 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_16_8(bytes16 self, bytes8 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes8 oldValue = extract_16_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_10(bytes16 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 6) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_16_10(bytes16 self, bytes10 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes10 oldValue = extract_16_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_16_12(bytes16 self, uint8 offset) internal pure returns (bytes12 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(160, not(0)))
- }
- }
- function replace_16_12(bytes16 self, bytes12 value, uint8 offset) internal pure returns (bytes16 result) {
- bytes12 oldValue = extract_16_12(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(160, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_1(bytes20 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 19) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_20_1(bytes20 self, bytes1 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes1 oldValue = extract_20_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_2(bytes20 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 18) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_20_2(bytes20 self, bytes2 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes2 oldValue = extract_20_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_4(bytes20 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 16) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_20_4(bytes20 self, bytes4 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes4 oldValue = extract_20_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_6(bytes20 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 14) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_20_6(bytes20 self, bytes6 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes6 oldValue = extract_20_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_8(bytes20 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 12) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_20_8(bytes20 self, bytes8 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes8 oldValue = extract_20_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_10(bytes20 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 10) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_20_10(bytes20 self, bytes10 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes10 oldValue = extract_20_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_12(bytes20 self, uint8 offset) internal pure returns (bytes12 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(160, not(0)))
- }
- }
- function replace_20_12(bytes20 self, bytes12 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes12 oldValue = extract_20_12(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(160, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_20_16(bytes20 self, uint8 offset) internal pure returns (bytes16 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(128, not(0)))
- }
- }
- function replace_20_16(bytes20 self, bytes16 value, uint8 offset) internal pure returns (bytes20 result) {
- bytes16 oldValue = extract_20_16(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(128, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_1(bytes22 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 21) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_22_1(bytes22 self, bytes1 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes1 oldValue = extract_22_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_2(bytes22 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 20) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_22_2(bytes22 self, bytes2 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes2 oldValue = extract_22_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_4(bytes22 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 18) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_22_4(bytes22 self, bytes4 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes4 oldValue = extract_22_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_6(bytes22 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 16) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_22_6(bytes22 self, bytes6 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes6 oldValue = extract_22_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_8(bytes22 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 14) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_22_8(bytes22 self, bytes8 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes8 oldValue = extract_22_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_10(bytes22 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 12) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_22_10(bytes22 self, bytes10 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes10 oldValue = extract_22_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_12(bytes22 self, uint8 offset) internal pure returns (bytes12 result) {
- if (offset > 10) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(160, not(0)))
- }
- }
- function replace_22_12(bytes22 self, bytes12 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes12 oldValue = extract_22_12(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(160, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_16(bytes22 self, uint8 offset) internal pure returns (bytes16 result) {
- if (offset > 6) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(128, not(0)))
- }
- }
- function replace_22_16(bytes22 self, bytes16 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes16 oldValue = extract_22_16(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(128, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_22_20(bytes22 self, uint8 offset) internal pure returns (bytes20 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(96, not(0)))
- }
- }
- function replace_22_20(bytes22 self, bytes20 value, uint8 offset) internal pure returns (bytes22 result) {
- bytes20 oldValue = extract_22_20(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(96, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_1(bytes24 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 23) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_24_1(bytes24 self, bytes1 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes1 oldValue = extract_24_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_2(bytes24 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 22) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_24_2(bytes24 self, bytes2 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes2 oldValue = extract_24_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_4(bytes24 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 20) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_24_4(bytes24 self, bytes4 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes4 oldValue = extract_24_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_6(bytes24 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 18) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_24_6(bytes24 self, bytes6 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes6 oldValue = extract_24_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_8(bytes24 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 16) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_24_8(bytes24 self, bytes8 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes8 oldValue = extract_24_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_10(bytes24 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 14) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_24_10(bytes24 self, bytes10 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes10 oldValue = extract_24_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_12(bytes24 self, uint8 offset) internal pure returns (bytes12 result) {
- if (offset > 12) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(160, not(0)))
- }
- }
- function replace_24_12(bytes24 self, bytes12 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes12 oldValue = extract_24_12(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(160, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_16(bytes24 self, uint8 offset) internal pure returns (bytes16 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(128, not(0)))
- }
- }
- function replace_24_16(bytes24 self, bytes16 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes16 oldValue = extract_24_16(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(128, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_20(bytes24 self, uint8 offset) internal pure returns (bytes20 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(96, not(0)))
- }
- }
- function replace_24_20(bytes24 self, bytes20 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes20 oldValue = extract_24_20(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(96, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_24_22(bytes24 self, uint8 offset) internal pure returns (bytes22 result) {
- if (offset > 2) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(80, not(0)))
- }
- }
- function replace_24_22(bytes24 self, bytes22 value, uint8 offset) internal pure returns (bytes24 result) {
- bytes22 oldValue = extract_24_22(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(80, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_1(bytes28 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 27) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_28_1(bytes28 self, bytes1 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes1 oldValue = extract_28_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_2(bytes28 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 26) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_28_2(bytes28 self, bytes2 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes2 oldValue = extract_28_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_4(bytes28 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 24) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_28_4(bytes28 self, bytes4 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes4 oldValue = extract_28_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_6(bytes28 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 22) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_28_6(bytes28 self, bytes6 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes6 oldValue = extract_28_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_8(bytes28 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 20) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_28_8(bytes28 self, bytes8 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes8 oldValue = extract_28_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_10(bytes28 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 18) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_28_10(bytes28 self, bytes10 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes10 oldValue = extract_28_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_12(bytes28 self, uint8 offset) internal pure returns (bytes12 result) {
- if (offset > 16) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(160, not(0)))
- }
- }
- function replace_28_12(bytes28 self, bytes12 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes12 oldValue = extract_28_12(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(160, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_16(bytes28 self, uint8 offset) internal pure returns (bytes16 result) {
- if (offset > 12) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(128, not(0)))
- }
- }
- function replace_28_16(bytes28 self, bytes16 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes16 oldValue = extract_28_16(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(128, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_20(bytes28 self, uint8 offset) internal pure returns (bytes20 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(96, not(0)))
- }
- }
- function replace_28_20(bytes28 self, bytes20 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes20 oldValue = extract_28_20(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(96, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_22(bytes28 self, uint8 offset) internal pure returns (bytes22 result) {
- if (offset > 6) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(80, not(0)))
- }
- }
- function replace_28_22(bytes28 self, bytes22 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes22 oldValue = extract_28_22(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(80, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_28_24(bytes28 self, uint8 offset) internal pure returns (bytes24 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(64, not(0)))
- }
- }
- function replace_28_24(bytes28 self, bytes24 value, uint8 offset) internal pure returns (bytes28 result) {
- bytes24 oldValue = extract_28_24(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(64, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_1(bytes32 self, uint8 offset) internal pure returns (bytes1 result) {
- if (offset > 31) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(248, not(0)))
- }
- }
- function replace_32_1(bytes32 self, bytes1 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes1 oldValue = extract_32_1(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(248, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_2(bytes32 self, uint8 offset) internal pure returns (bytes2 result) {
- if (offset > 30) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(240, not(0)))
- }
- }
- function replace_32_2(bytes32 self, bytes2 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes2 oldValue = extract_32_2(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(240, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_4(bytes32 self, uint8 offset) internal pure returns (bytes4 result) {
- if (offset > 28) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(224, not(0)))
- }
- }
- function replace_32_4(bytes32 self, bytes4 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes4 oldValue = extract_32_4(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(224, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_6(bytes32 self, uint8 offset) internal pure returns (bytes6 result) {
- if (offset > 26) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(208, not(0)))
- }
- }
- function replace_32_6(bytes32 self, bytes6 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes6 oldValue = extract_32_6(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(208, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_8(bytes32 self, uint8 offset) internal pure returns (bytes8 result) {
- if (offset > 24) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(192, not(0)))
- }
- }
- function replace_32_8(bytes32 self, bytes8 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes8 oldValue = extract_32_8(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(192, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_10(bytes32 self, uint8 offset) internal pure returns (bytes10 result) {
- if (offset > 22) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(176, not(0)))
- }
- }
- function replace_32_10(bytes32 self, bytes10 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes10 oldValue = extract_32_10(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(176, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_12(bytes32 self, uint8 offset) internal pure returns (bytes12 result) {
- if (offset > 20) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(160, not(0)))
- }
- }
- function replace_32_12(bytes32 self, bytes12 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes12 oldValue = extract_32_12(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(160, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_16(bytes32 self, uint8 offset) internal pure returns (bytes16 result) {
- if (offset > 16) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(128, not(0)))
- }
- }
- function replace_32_16(bytes32 self, bytes16 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes16 oldValue = extract_32_16(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(128, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_20(bytes32 self, uint8 offset) internal pure returns (bytes20 result) {
- if (offset > 12) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(96, not(0)))
- }
- }
- function replace_32_20(bytes32 self, bytes20 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes20 oldValue = extract_32_20(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(96, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_22(bytes32 self, uint8 offset) internal pure returns (bytes22 result) {
- if (offset > 10) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(80, not(0)))
- }
- }
- function replace_32_22(bytes32 self, bytes22 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes22 oldValue = extract_32_22(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(80, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_24(bytes32 self, uint8 offset) internal pure returns (bytes24 result) {
- if (offset > 8) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(64, not(0)))
- }
- }
- function replace_32_24(bytes32 self, bytes24 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes24 oldValue = extract_32_24(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(64, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- function extract_32_28(bytes32 self, uint8 offset) internal pure returns (bytes28 result) {
- if (offset > 4) revert OutOfRangeAccess();
- assembly ("memory-safe") {
- result := and(shl(mul(8, offset), self), shl(32, not(0)))
- }
- }
- function replace_32_28(bytes32 self, bytes28 value, uint8 offset) internal pure returns (bytes32 result) {
- bytes28 oldValue = extract_32_28(self, offset);
- assembly ("memory-safe") {
- value := and(value, shl(32, not(0)))
- result := xor(self, shr(mul(8, offset), xor(oldValue, value)))
- }
- }
- }
|