@etherplay/delegation 0.1.0 → 0.1.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.
@@ -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.1",
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",