@etherplay/delegation 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Ronan Sandford
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -434,23 +434,42 @@ library Delegation {
434
434
  ///
435
435
  /// Both addresses are rendered lowercase; see {StringUtils-toHexString}.
436
436
  /// The deadline is decimal unix seconds, or the word `never` for zero.
437
+ ///
438
+ /// BUILT IN TWO PARTS, AND IT HAS TO BE. Do not fold these back into one
439
+ /// `abi.encodePacked`, however much it wants to be one: with the optimizer
440
+ /// ENABLED, solc 0.8.28 encodes a packed tuple through a generated Yul
441
+ /// block that holds every argument on the stack at once, and at seven or
442
+ /// more dynamic arguments that block is stack-too-deep before any of this
443
+ /// library's own locals are counted. Eight arguments is what the fields
444
+ /// below come to, so the single-call form does not compile under any
445
+ /// optimizer setting at all - not at low `runs`, not at `runs: 1` - while
446
+ /// compiling fine with the optimizer off, which is the reverse of the usual
447
+ /// stack-too-deep and the reason this looks like a rewrite of working code.
448
+ /// Six arguments is the last that fits, so the field block is encoded on
449
+ /// its own and the prose is prepended to it.
450
+ ///
451
+ /// THE BYTES ARE UNCHANGED BY THE SPLIT. Every piece here is a `string`, so
452
+ /// packed encoding is plain concatenation with no length prefix and no
453
+ /// padding, and concatenation is associative: `A | (B | C)` is `A | B | C`.
454
+ /// `vectors.json` is what actually holds that claim down.
437
455
  function message(
438
456
  address delegate,
439
457
  uint256 deadline
440
458
  ) internal view returns (string memory) {
459
+ bytes memory fields = abi.encodePacked(
460
+ MESSAGE_CONTRACT,
461
+ StringUtils.toHexString(address(this)),
462
+ MESSAGE_CHAIN_ID,
463
+ StringUtils.toString(block.chainid),
464
+ MESSAGE_EXPIRES,
465
+ deadline == 0 ? MESSAGE_NO_EXPIRY : StringUtils.toString(deadline)
466
+ );
441
467
  return
442
468
  string(
443
469
  abi.encodePacked(
444
470
  MESSAGE_HEAD,
445
471
  StringUtils.toHexString(delegate),
446
- MESSAGE_CONTRACT,
447
- StringUtils.toHexString(address(this)),
448
- MESSAGE_CHAIN_ID,
449
- StringUtils.toString(block.chainid),
450
- MESSAGE_EXPIRES,
451
- deadline == 0
452
- ? MESSAGE_NO_EXPIRY
453
- : StringUtils.toString(deadline)
472
+ fields
454
473
  )
455
474
  );
456
475
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherplay/delegation",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Onchain delegation for Etherplay Accounts - Solidity library, the TypeScript builder for the message it verifies, and the ABI, kept in agreement by a shared vectors file",
5
5
  "keywords": [
6
6
  "ethereum",