@trustvc/eip7702 1.1.0-beta.5 → 1.1.0-beta.6

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/README.md CHANGED
@@ -50,7 +50,7 @@ Per-platform ERC-4337 paymaster cloned from a shared implementation.
50
50
 
51
51
  - `initialize(owner, dailyLimit, tdocDeployer)` — called once by the factory after clone; guarded by `owner() == address(0)`
52
52
  - `deployRegistry(impl, name, symbol)` — deploys a TradeTrust registry, consumes one credit, auto-authorizes it
53
- - `mintDocument(registry, beneficiary, holder, tokenId, remark)` — mints a document, auto-authorizes the title escrow. Escrow calls are sponsored only for the escrow's current holder/beneficiary (read live at validation), so sponsorship follows the document across transfers
53
+ - `mintDocument(registry, beneficiary, holder, tokenId, remark)` — mints a document, auto-authorizes the title escrow. Escrow calls are sponsored only for the escrow's current holder/beneficiary (read live at validation) or the platform owner, so sponsorship follows the document across transfers
54
54
  - `setUserWhitelist / removeUserFromWhitelist` — manage deployment credits (`onlyOwner`)
55
55
  - `addRegistry / removeRegistry` — manage authorized registries (`onlyOwner`)
56
56
  - `addTitleEscrow / removeTitleEscrow` — manage authorized title escrows (`onlyOwner`)
@@ -144,8 +144,10 @@ contract PlatformPaymaster is BasePaymaster {
144
144
 
145
145
  // Deploys a TDoc clone on behalf of a whitelisted user; consumes one credit.
146
146
  // Role setup (atomic, no follow-up txs needed):
147
- // - msg.sender (EOA) gets DEFAULT_ADMIN_ROLE
148
- // - paymaster gets MINTER_ROLE + RESTORER_ROLE + ACCEPTER_ROLE
147
+ // - msg.sender (EOA) gets DEFAULT_ADMIN_ROLE + MINTER_ROLE + RESTORER_ROLE + ACCEPTER_ROLE
148
+ // (MINTER_ROLE is checked by mintDocument; restore/accept are called on the registry directly)
149
+ // - paymaster keeps MINTER_ROLE + RESTORER_ROLE + ACCEPTER_ROLE from initialization
150
+ // and renounces DEFAULT_ADMIN_ROLE
149
151
  function deployRegistry(
150
152
  address implementation,
151
153
  string memory name,
@@ -160,6 +162,8 @@ contract PlatformPaymaster is BasePaymaster {
160
162
  // Paymaster is temporary admin so it can configure roles after deploy
161
163
  bytes memory params = abi.encode(name, symbol, address(this));
162
164
  deployed = tdocDeployer.deploy(implementation, params);
165
+ // Don't rely on the deployer: only configure/authorize a deployed contract (also rules out address(0))
166
+ require(deployed.code.length > 0, "invalid registry");
163
167
 
164
168
  IAccessControl(deployed).grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
165
169
  IAccessControl(deployed).grantRole(RESTORER_ROLE, msg.sender);
@@ -455,7 +459,11 @@ contract PlatformPaymaster is BasePaymaster {
455
459
  (bool ok, bytes memory ret) = target.staticcall(
456
460
  abi.encodeWithSelector(selector)
457
461
  );
458
- if (ok && ret.length >= 32) result = abi.decode(ret, (address));
462
+ if (ok && ret.length >= 32) {
463
+ // Decode as uint256: abi.decode to address reverts on dirty high bits
464
+ uint256 word = abi.decode(ret, (uint256));
465
+ if (word <= type(uint160).max) result = address(uint160(word));
466
+ }
459
467
  }
460
468
 
461
469
  // hasRole reads _roles[role][account] — storage associated with the sender (ERC-7562).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/eip7702",
3
- "version": "1.1.0-beta.5",
3
+ "version": "1.1.0-beta.6",
4
4
  "description": "EIP-7702 smart account, platform paymaster, and factory contracts for TrustVC",
5
5
  "author": "DexTech",
6
6
  "license": "MIT",