Skip to main content

foundry_evm_traces/decoder/
base.rs

1//! Base precompile ABIs for trace decoding.
2//!
3//! `base-common-precompiles` declares these interfaces without `#[sol(abi)]`, so it exposes no
4//! [`JsonAbi`](alloy_json_abi::JsonAbi) for `register_address_abi` to consume. These declarations
5//! mirror the canonical ones so traces name Base precompile calls, events, and errors, following
6//! the same approach `super::monad` takes for its staking interfaces.
7//!
8//! The `abi_matches_canonical_selectors` tests below pin every selector against the canonical
9//! types, so an interface change in Base fails here instead of silently decoding traces wrong.
10
11use alloy_sol_types::sol;
12
13sol! {
14    /// Mirror of `base_common_precompiles::IActivationRegistry`.
15    #[sol(abi)]
16    interface IActivationRegistry {
17        event FeatureActivated(bytes32 indexed feature, address indexed caller);
18        event FeatureDeactivated(bytes32 indexed feature, address indexed caller);
19        event AdminChanged(
20            address indexed previousAdmin,
21            address indexed newAdmin,
22            address indexed caller
23        );
24
25        error Unauthorized(address caller);
26        error AlreadyActivated(bytes32 feature);
27        error FeatureNotActivated(bytes32 feature);
28        error DelegateCallNotAllowed();
29        error StaticCallNotAllowed();
30        error NonPayable();
31        error AdminStorageNotEnabled();
32        error ZeroAdminAddress();
33
34        function isActivated(bytes32 feature) external view returns (bool);
35        function checkActivated(bytes32 feature) external view;
36        function admin() external view returns (address);
37        function setAdmin(address newAdmin) external;
38        function activate(bytes32 feature) external;
39        function deactivate(bytes32 feature) external;
40    }
41}
42
43sol! {
44    /// Mirror of `base_common_precompiles::IB20Factory`, the surface frozen at Beryl.
45    #[sol(abi)]
46    interface IB20Factory {
47        enum B20Variant {
48            ASSET,
49            STABLECOIN
50        }
51
52        struct B20StablecoinCreateParams {
53            uint8 version;
54            string name;
55            string symbol;
56            address initialAdmin;
57            string currency;
58        }
59
60        struct B20AssetCreateParams {
61            uint8 version;
62            string name;
63            string symbol;
64            address initialAdmin;
65            uint8 decimals;
66        }
67
68        error NonPayable();
69        error TokenAlreadyExists(address token);
70        error InvalidVariant();
71        error UnsupportedVersion(uint8 version, B20Variant variant);
72        error MissingRequiredField(string field);
73        error InvalidCurrency(string code);
74        error InvalidDecimals(uint8 decimals);
75        error InitCallFailed(uint256 index);
76
77        event B20Created(
78            address indexed token,
79            B20Variant indexed variant,
80            string name,
81            string symbol,
82            uint8 decimals,
83            bytes variantParams
84        );
85
86        struct B20StablecoinEventParams {
87            uint8 version;
88            string currency;
89        }
90
91        function createB20(
92            B20Variant variant,
93            bytes32 salt,
94            bytes calldata params,
95            bytes[] calldata initCalls
96        ) external returns (address token);
97        function getB20Address(B20Variant variant, address sender, bytes32 salt) external view returns (address);
98        function isB20(address token) external view returns (bool);
99        function isB20Initialized(address token) external view returns (bool);
100    }
101}
102
103sol! {
104    /// **Deliberately partial** mirror of `base_common_precompiles::IB20`, the B-20 token surface.
105    ///
106    /// B-20 tokens are created by the factory at derived addresses, so they cannot be registered
107    /// per address like the fixed precompiles. These members are therefore available as a
108    /// Base-only fallback after address-scoped and caller-supplied metadata.
109    ///
110    /// Only Base-specific members belong here. The ERC-20, EIP-2612 and AccessControl portions are
111    /// omitted on purpose: the global function map is not network-scoped, so adding competing
112    /// candidates for `transfer`, `balanceOf`, `approve` or `permit` could change how ordinary
113    /// token traces decode in any Base-enabled build. Foundry already has to order
114    /// `IStorageCredits` against `ITIP20` to keep `balanceOf`'s return type stable, which is the
115    /// same hazard. `b20_surface_excludes_erc20_members` pins this boundary.
116    #[sol(abi)]
117    interface IB20Extensions {
118        enum PausableFeature {
119            TRANSFER,
120            MINT,
121            BURN,
122            SEIZE
123        }
124
125        event Memo(address indexed caller, bytes32 indexed memo);
126        event BurnedBlocked(address indexed caller, address indexed from, uint256 amount);
127        event Seized(address indexed caller, address indexed from, address indexed to, uint256 amount);
128        event LastAdminRenounced(address indexed previousAdmin);
129        event Paused(address indexed updater, PausableFeature[] features);
130        event Unpaused(address indexed updater, PausableFeature[] features);
131        event PolicyUpdated(bytes32 indexed policyScope, uint64 oldPolicyId, uint64 newPolicyId);
132
133        function mintWithMemo(address to, uint256 amount, bytes32 memo) external;
134        function burnWithMemo(uint256 amount, bytes32 memo) external;
135        function burnBlocked(address from, uint256 amount) external;
136        function transferWithMemo(address to, uint256 amount, bytes32 memo) external returns (bool);
137        function seizeWithMemo(address from, address to, uint256 amount, bytes32 memo) external;
138        function pausedFeatures() external view returns (PausableFeature[] memory);
139        function isPaused(PausableFeature feature) external view returns (bool);
140        function pause(PausableFeature[] calldata features) external;
141        function unpause(PausableFeature[] calldata features) external;
142        function policyId(bytes32 policyScope) external view returns (uint64);
143        function updatePolicy(bytes32 policyScope, uint64 newPolicyId) external;
144        function contractURI() external view returns (string);
145        function updateContractURI(string calldata newURI) external;
146    }
147}
148
149sol! {
150    /// Mirror of `base_common_precompiles::IPolicyRegistry`, the canonical Cobalt surface.
151    ///
152    /// Only this surface is mirrored: its call set is a strict superset of Beryl's V1, so it also
153    /// names Beryl-era policy traces. `policy_registry_covers_v1_selectors` pins that.
154    #[sol(abi)]
155    interface IPolicyRegistry {
156        enum PolicyType {
157            BLOCKLIST,
158            ALLOWLIST,
159            UNION,
160            INTERSECT
161        }
162
163        error NonPayable();
164        error Unauthorized();
165        error PolicyNotFound();
166        error IncompatiblePolicyType();
167        error ZeroAddress();
168        error BatchSizeTooLarge(uint256 maxBatchSize);
169        error NoPendingAdmin();
170        error ChildPoliciesOutsideOfRange();
171        error InvalidChildPolicy(uint64 childPolicyId);
172
173        event PolicyCreated(uint64 indexed policyId, address indexed creator, PolicyType policyType);
174        event PolicyAdminStaged(uint64 indexed policyId, address indexed currentAdmin, address indexed pendingAdmin);
175        event PolicyAdminUpdated(uint64 indexed policyId, address indexed previousAdmin, address indexed newAdmin);
176        event AllowlistUpdated(uint64 indexed policyId, address indexed updater, bool allowed, address[] accounts);
177        event BlocklistUpdated(uint64 indexed policyId, address indexed updater, bool blocked, address[] accounts);
178        event CompositePolicyUpdated(uint64 indexed policyId, address indexed updater, uint64[] childPolicyIds);
179
180        function createPolicy(address admin, PolicyType policyType) external returns (uint64);
181        function createPolicyWithAccounts(address admin, PolicyType policyType, address[] calldata accounts) external returns (uint64);
182        function createCompositePolicy(address admin, PolicyType policyType, uint64[] calldata childPolicyIds) external returns (uint64);
183        function updateComposite(uint64 policyId, uint64[] calldata childPolicyIds) external;
184        function stageUpdateAdmin(uint64 policyId, address newAdmin) external;
185        function finalizeUpdateAdmin(uint64 policyId) external;
186        function renounceAdmin(uint64 policyId) external;
187        function updateAllowlist(uint64 policyId, bool allowed, address[] calldata accounts) external;
188        function updateBlocklist(uint64 policyId, bool blocked, address[] calldata accounts) external;
189        function isAuthorized(uint64 policyId, address account) external view returns (bool);
190        function MIN_COMPOSITE_CHILD_POLICIES() external view returns (uint256);
191        function MAX_COMPOSITE_CHILD_POLICIES() external view returns (uint256);
192        function policyExists(uint64 policyId) external view returns (bool);
193        function policyAdmin(uint64 policyId) external view returns (address);
194        function pendingPolicyAdmin(uint64 policyId) external view returns (address);
195        function compositePolicyChildIds(uint64 policyId) external view returns (uint64[] memory);
196    }
197}
198
199sol! {
200    /// Mirror of `base_common_precompiles::INonceManager`.
201    #[sol(abi)]
202    interface INonceManager {
203        error DelegateCallNotAllowed();
204        error NonPayable();
205        error ProtocolNonceNotSupported();
206        error InvalidNonceKey();
207        error InvalidReplayId();
208        error NonceOverflow();
209        error InvalidExpiringNonceExpiry();
210        error ExpiringNonceReplay();
211        error ExpiringNonceSetFull();
212
213        function getNonce(address account, uint256 nonceKey) external view returns (uint64);
214    }
215}
216
217sol! {
218    /// Mirror of `base_common_precompiles::ITransactionContext`.
219    #[sol(abi)]
220    interface ITransactionContext {
221        error DelegateCallNotAllowed();
222        error NonPayable();
223
224        function getTransactionSender() external view returns (address);
225        function getTransactionPayer() external view returns (address);
226        function getTransactionSenderActorId() external view returns (bytes32);
227    }
228}
229
230#[cfg(test)]
231mod tests {
232    use crate::{CallTrace, CallTraceDecoderBuilder};
233    use alloy_dyn_abi::{DynSolValue, FunctionExt};
234    use alloy_primitives::{Address, B256, Bytes, U256};
235    use alloy_sol_types::{SolCall, SolEnum, SolError, SolEvent, SolInterface};
236    use base_common_precompiles::{
237        self as canonical, ActivationRegistryStorage, B20FactoryStorage, NonceManagerStorage,
238        TxContextStorage,
239    };
240    use evm2::interpreter::InstrStop;
241    use foundry_evm_hardforks::{BaseUpgrade, FoundryHardfork};
242    use foundry_evm_networks::NetworkConfigs;
243
244    #[tokio::test]
245    async fn registered_abis_decode_base_precompile_calls() {
246        let decoder = CallTraceDecoderBuilder::new()
247            .with_networks(NetworkConfigs::with_base())
248            .with_hardfork(Some(FoundryHardfork::Base(BaseUpgrade::Cobalt)))
249            .build();
250
251        let activate =
252            super::IActivationRegistry::activateCall { feature: B256::repeat_byte(0x11) };
253        let trace = CallTrace {
254            address: ActivationRegistryStorage::ADDRESS,
255            data: activate.abi_encode().into(),
256            success: true,
257            ..Default::default()
258        };
259        let decoded = decoder.decode_function(&trace).await;
260        assert_eq!(decoded.label.as_deref(), Some("ActivationRegistry"));
261        assert_eq!(
262            decoded.call_data.expect("activate should decode").signature,
263            "activate(bytes32)"
264        );
265
266        let get_nonce = super::INonceManager::getNonceCall {
267            account: Address::repeat_byte(0x22),
268            nonceKey: U256::from(7),
269        };
270        let trace = CallTrace {
271            address: NonceManagerStorage::ADDRESS,
272            data: get_nonce.abi_encode().into(),
273            success: true,
274            ..Default::default()
275        };
276        let decoded = decoder.decode_function(&trace).await;
277        assert_eq!(
278            decoded.call_data.expect("getNonce should decode").signature,
279            "getNonce(address,uint256)"
280        );
281
282        let create = super::IB20Factory::createB20Call {
283            variant: super::IB20Factory::B20Variant::ASSET,
284            salt: B256::repeat_byte(0x33),
285            params: Bytes::new(),
286            initCalls: Vec::new(),
287        };
288        let trace = CallTrace {
289            address: B20FactoryStorage::ADDRESS,
290            data: create.abi_encode().into(),
291            success: true,
292            ..Default::default()
293        };
294        let decoded = decoder.decode_function(&trace).await;
295        assert_eq!(decoded.label.as_deref(), Some("B20Factory"));
296        let signature = decoded.call_data.expect("createB20 should decode").signature;
297        assert!(signature.starts_with("createB20("), "{signature}");
298    }
299
300    #[tokio::test]
301    async fn b20_transfer_with_memo_decodes_bool_output() {
302        let call = super::IB20Extensions::transferWithMemoCall {
303            to: Address::repeat_byte(0x11),
304            amount: U256::ONE,
305            memo: B256::repeat_byte(0x22),
306        };
307        let abi = super::IB20Extensions::abi::contract();
308        let function = abi.functions.get("transferWithMemo").unwrap().first().unwrap();
309        let trace = CallTrace {
310            address: Address::repeat_byte(0x33),
311            data: call.abi_encode().into(),
312            output: function.abi_encode_output(&[DynSolValue::Bool(true)]).unwrap().into(),
313            success: true,
314            ..Default::default()
315        };
316
317        let base =
318            CallTraceDecoderBuilder::new().with_networks(NetworkConfigs::with_base()).build();
319        let decoded = base.decode_function(&trace).await;
320        assert_eq!(
321            decoded.call_data.unwrap().signature,
322            "transferWithMemo(address,uint256,bytes32)"
323        );
324        assert_eq!(decoded.return_data.as_deref(), Some("true"));
325
326        let custom_abi = alloy_json_abi::JsonAbi::parse([
327            "function transferWithMemo(address,uint256,bytes32) returns (uint256)",
328        ])
329        .unwrap();
330        let custom_base = CallTraceDecoderBuilder::new()
331            .with_networks(NetworkConfigs::with_base())
332            .with_abi(&custom_abi)
333            .build();
334        assert_eq!(custom_base.decode_function(&trace).await.return_data.as_deref(), Some("1"));
335
336        let tempo =
337            CallTraceDecoderBuilder::new().with_networks(NetworkConfigs::with_tempo()).build();
338        assert_eq!(tempo.decode_function(&trace).await.return_data, None);
339    }
340
341    #[tokio::test]
342    async fn base_precompile_errors_are_address_scoped() {
343        let trace = CallTrace {
344            address: ActivationRegistryStorage::ADDRESS,
345            output: super::IActivationRegistry::NonPayable {}.abi_encode().into(),
346            success: false,
347            status: Some(InstrStop::Revert),
348            ..Default::default()
349        };
350        let base = CallTraceDecoderBuilder::new()
351            .with_networks(NetworkConfigs::with_base())
352            .with_hardfork(Some(FoundryHardfork::Base(BaseUpgrade::Beryl)))
353            .build();
354        assert_eq!(base.decode_function(&trace).await.return_data.as_deref(), Some("NonPayable()"));
355
356        let ethereum = CallTraceDecoderBuilder::new()
357            .with_networks(NetworkConfigs::with_ethereum())
358            .with_hardfork(Some(FoundryHardfork::Base(BaseUpgrade::Beryl)))
359            .build();
360        assert_ne!(
361            ethereum.decode_function(&trace).await.return_data.as_deref(),
362            Some("NonPayable()")
363        );
364    }
365
366    /// The transaction-context precompile only exists from Cobalt, so a Beryl decoder must not
367    /// name its calls. This uses a Base-unique selector on purpose: generic names like
368    /// `getNonce(address,uint256)` also exist in Tempo's globally registered nonce ABI and would
369    /// decode regardless of the Base upgrade.
370    #[tokio::test]
371    async fn pre_cobalt_decoder_does_not_register_eip8130_surfaces() {
372        let call = super::ITransactionContext::getTransactionSenderActorIdCall {};
373        let trace = CallTrace {
374            address: TxContextStorage::ADDRESS,
375            data: call.abi_encode().into(),
376            success: true,
377            ..Default::default()
378        };
379
380        let beryl = CallTraceDecoderBuilder::new()
381            .with_networks(NetworkConfigs::with_base())
382            .with_hardfork(Some(FoundryHardfork::Base(BaseUpgrade::Beryl)))
383            .build();
384        assert!(
385            beryl.decode_function(&trace).await.call_data.is_none(),
386            "Beryl must not decode a Cobalt-only precompile"
387        );
388
389        let cobalt = CallTraceDecoderBuilder::new()
390            .with_networks(NetworkConfigs::with_base())
391            .with_hardfork(Some(FoundryHardfork::Base(BaseUpgrade::Cobalt)))
392            .build();
393        assert_eq!(
394            cobalt.decode_function(&trace).await.call_data.expect("Cobalt should decode").signature,
395            "getTransactionSenderActorId()"
396        );
397    }
398
399    #[test]
400    fn activation_registry_abi_matches_canonical_selectors() {
401        assert_eq!(
402            super::IActivationRegistry::activateCall::SELECTOR,
403            canonical::IActivationRegistry::activateCall::SELECTOR
404        );
405        assert_eq!(
406            super::IActivationRegistry::deactivateCall::SELECTOR,
407            canonical::IActivationRegistry::deactivateCall::SELECTOR
408        );
409        assert_eq!(
410            super::IActivationRegistry::isActivatedCall::SELECTOR,
411            canonical::IActivationRegistry::isActivatedCall::SELECTOR
412        );
413        assert_eq!(
414            super::IActivationRegistry::checkActivatedCall::SELECTOR,
415            canonical::IActivationRegistry::checkActivatedCall::SELECTOR
416        );
417        assert_eq!(
418            super::IActivationRegistry::adminCall::SELECTOR,
419            canonical::IActivationRegistry::adminCall::SELECTOR
420        );
421        assert_eq!(
422            super::IActivationRegistry::setAdminCall::SELECTOR,
423            canonical::IActivationRegistry::setAdminCall::SELECTOR
424        );
425        assert_eq!(
426            super::IActivationRegistry::Unauthorized::SELECTOR,
427            canonical::IActivationRegistry::Unauthorized::SELECTOR
428        );
429        assert_eq!(
430            super::IActivationRegistry::StaticCallNotAllowed::SELECTOR,
431            canonical::IActivationRegistry::StaticCallNotAllowed::SELECTOR
432        );
433        assert_eq!(
434            super::IActivationRegistry::NonPayable::SELECTOR,
435            canonical::IActivationRegistry::NonPayable::SELECTOR
436        );
437        assert_eq!(
438            super::IActivationRegistry::FeatureActivated::SIGNATURE_HASH,
439            canonical::IActivationRegistry::FeatureActivated::SIGNATURE_HASH
440        );
441        assert_eq!(
442            super::IActivationRegistry::AdminChanged::SIGNATURE_HASH,
443            canonical::IActivationRegistry::AdminChanged::SIGNATURE_HASH
444        );
445    }
446
447    /// Base pins this surface with an `AbiFingerprint`, but that type is only exported under its
448    /// `test-utils` feature, so this compares against the canonical types directly instead.
449    /// `B20Variant`'s ordinals are asserted explicitly because they are the one thing selectors
450    /// cannot catch: Solidity encodes enums as `uint8`, so a reorder moves no signature, yet the
451    /// ordinal is byte `[10]` of every token address the factory deploys.
452    #[test]
453    fn b20_factory_abi_matches_canonical_surface() {
454        assert_eq!(
455            super::IB20Factory::createB20Call::SELECTOR,
456            canonical::IB20Factory::createB20Call::SELECTOR
457        );
458        assert_eq!(
459            super::IB20Factory::getB20AddressCall::SELECTOR,
460            canonical::IB20Factory::getB20AddressCall::SELECTOR
461        );
462        assert_eq!(
463            super::IB20Factory::isB20Call::SELECTOR,
464            canonical::IB20Factory::isB20Call::SELECTOR
465        );
466        assert_eq!(
467            super::IB20Factory::isB20InitializedCall::SELECTOR,
468            canonical::IB20Factory::isB20InitializedCall::SELECTOR
469        );
470        assert_eq!(
471            super::IB20Factory::TokenAlreadyExists::SELECTOR,
472            canonical::IB20Factory::TokenAlreadyExists::SELECTOR
473        );
474        assert_eq!(
475            super::IB20Factory::UnsupportedVersion::SELECTOR,
476            canonical::IB20Factory::UnsupportedVersion::SELECTOR
477        );
478        assert_eq!(
479            super::IB20Factory::B20Created::SIGNATURE_HASH,
480            canonical::IB20Factory::B20Created::SIGNATURE_HASH
481        );
482
483        assert_eq!(
484            super::IB20Factory::B20Variant::COUNT,
485            canonical::IB20Factory::B20Variant::COUNT
486        );
487        assert_eq!(
488            super::IB20Factory::B20Variant::ASSET as u8,
489            canonical::IB20Factory::B20Variant::ASSET as u8
490        );
491        assert_eq!(
492            super::IB20Factory::B20Variant::STABLECOIN as u8,
493            canonical::IB20Factory::B20Variant::STABLECOIN as u8
494        );
495    }
496
497    /// `PolicyType` ordinals ride the top byte of every policy ID, so they are asserted alongside
498    /// the selectors for the same reason as `B20Variant`.
499    #[test]
500    fn policy_registry_abi_matches_canonical_surface() {
501        assert_eq!(
502            super::IPolicyRegistry::createPolicyCall::SELECTOR,
503            canonical::IPolicyRegistry::createPolicyCall::SELECTOR
504        );
505        assert_eq!(
506            super::IPolicyRegistry::createCompositePolicyCall::SELECTOR,
507            canonical::IPolicyRegistry::createCompositePolicyCall::SELECTOR
508        );
509        assert_eq!(
510            super::IPolicyRegistry::isAuthorizedCall::SELECTOR,
511            canonical::IPolicyRegistry::isAuthorizedCall::SELECTOR
512        );
513        assert_eq!(
514            super::IPolicyRegistry::updateAllowlistCall::SELECTOR,
515            canonical::IPolicyRegistry::updateAllowlistCall::SELECTOR
516        );
517        assert_eq!(
518            super::IPolicyRegistry::InvalidChildPolicy::SELECTOR,
519            canonical::IPolicyRegistry::InvalidChildPolicy::SELECTOR
520        );
521        assert_eq!(
522            super::IPolicyRegistry::PolicyCreated::SIGNATURE_HASH,
523            canonical::IPolicyRegistry::PolicyCreated::SIGNATURE_HASH
524        );
525        assert_eq!(
526            super::IPolicyRegistry::CompositePolicyUpdated::SIGNATURE_HASH,
527            canonical::IPolicyRegistry::CompositePolicyUpdated::SIGNATURE_HASH
528        );
529
530        assert_eq!(
531            super::IPolicyRegistry::PolicyType::COUNT,
532            canonical::IPolicyRegistry::PolicyType::COUNT
533        );
534        for (mirror, expected) in [
535            (
536                super::IPolicyRegistry::PolicyType::BLOCKLIST as u8,
537                canonical::IPolicyRegistry::PolicyType::BLOCKLIST as u8,
538            ),
539            (
540                super::IPolicyRegistry::PolicyType::ALLOWLIST as u8,
541                canonical::IPolicyRegistry::PolicyType::ALLOWLIST as u8,
542            ),
543            (
544                super::IPolicyRegistry::PolicyType::UNION as u8,
545                canonical::IPolicyRegistry::PolicyType::UNION as u8,
546            ),
547            (
548                super::IPolicyRegistry::PolicyType::INTERSECT as u8,
549                canonical::IPolicyRegistry::PolicyType::INTERSECT as u8,
550            ),
551        ] {
552            assert_eq!(mirror, expected);
553        }
554    }
555
556    /// Mirroring only the Cobalt surface is safe because it is a strict superset of Beryl's. If
557    /// Base ever diverges a shared signature, this fails and V1 needs its own mirror.
558    #[test]
559    fn policy_registry_covers_v1_selectors() {
560        let mirrored: Vec<[u8; 4]> =
561            super::IPolicyRegistry::IPolicyRegistryCalls::selectors().collect();
562        for selector in canonical::IPolicyRegistryV1::IPolicyRegistryCalls::selectors() {
563            assert!(
564                mirrored.contains(&selector),
565                "Beryl selector {selector:?} is absent from the mirrored Cobalt surface"
566            );
567        }
568    }
569
570    #[test]
571    fn b20_extensions_abi_matches_canonical_surface() {
572        assert_eq!(
573            super::IB20Extensions::mintWithMemoCall::SELECTOR,
574            canonical::IB20::mintWithMemoCall::SELECTOR
575        );
576        assert_eq!(
577            super::IB20Extensions::burnWithMemoCall::SELECTOR,
578            canonical::IB20::burnWithMemoCall::SELECTOR
579        );
580        assert_eq!(
581            super::IB20Extensions::burnBlockedCall::SELECTOR,
582            canonical::IB20::burnBlockedCall::SELECTOR
583        );
584        assert_eq!(
585            super::IB20Extensions::seizeWithMemoCall::SELECTOR,
586            canonical::IB20::seizeWithMemoCall::SELECTOR
587        );
588        assert_eq!(
589            super::IB20Extensions::policyIdCall::SELECTOR,
590            canonical::IB20::policyIdCall::SELECTOR
591        );
592        assert_eq!(
593            super::IB20Extensions::pauseCall::SELECTOR,
594            canonical::IB20::pauseCall::SELECTOR
595        );
596        assert_eq!(
597            super::IB20Extensions::contractURICall::SELECTOR,
598            canonical::IB20::contractURICall::SELECTOR
599        );
600        assert_eq!(
601            super::IB20Extensions::Seized::SIGNATURE_HASH,
602            canonical::IB20::Seized::SIGNATURE_HASH
603        );
604        assert_eq!(
605            super::IB20Extensions::Memo::SIGNATURE_HASH,
606            canonical::IB20::Memo::SIGNATURE_HASH
607        );
608        assert_eq!(
609            super::IB20Extensions::PolicyUpdated::SIGNATURE_HASH,
610            canonical::IB20::PolicyUpdated::SIGNATURE_HASH
611        );
612
613        // Pausable ordinals are load-bearing in `pause`/`unpause` calldata.
614        assert_eq!(
615            super::IB20Extensions::PausableFeature::COUNT,
616            canonical::IB20::PausableFeature::COUNT
617        );
618        assert_eq!(
619            super::IB20Extensions::PausableFeature::SEIZE as u8,
620            canonical::IB20::PausableFeature::SEIZE as u8
621        );
622    }
623
624    /// This surface is registered globally rather than per address, so it must never carry the
625    /// ERC-20, EIP-2612 or AccessControl members: a competing candidate for those selectors could
626    /// change how ordinary token traces decode on every network in a Base-enabled build.
627    #[test]
628    fn b20_surface_excludes_erc20_members() {
629        let mirrored: Vec<[u8; 4]> =
630            super::IB20Extensions::IB20ExtensionsCalls::selectors().collect();
631        for excluded in [
632            canonical::IB20::transferCall::SELECTOR,
633            canonical::IB20::transferFromCall::SELECTOR,
634            canonical::IB20::approveCall::SELECTOR,
635            canonical::IB20::balanceOfCall::SELECTOR,
636            canonical::IB20::allowanceCall::SELECTOR,
637            canonical::IB20::permitCall::SELECTOR,
638            canonical::IB20::hasRoleCall::SELECTOR,
639            canonical::IB20::grantRoleCall::SELECTOR,
640        ] {
641            assert!(
642                !mirrored.contains(&excluded),
643                "standard selector {excluded:?} must stay out of the global map"
644            );
645        }
646    }
647
648    #[test]
649    fn nonce_manager_abi_matches_canonical_selectors() {
650        assert_eq!(
651            super::INonceManager::getNonceCall::SELECTOR,
652            canonical::INonceManager::getNonceCall::SELECTOR
653        );
654        assert_eq!(
655            super::INonceManager::ExpiringNonceReplay::SELECTOR,
656            canonical::INonceManager::ExpiringNonceReplay::SELECTOR
657        );
658        assert_eq!(
659            super::INonceManager::InvalidExpiringNonceExpiry::SELECTOR,
660            canonical::INonceManager::InvalidExpiringNonceExpiry::SELECTOR
661        );
662        assert_eq!(
663            super::INonceManager::InvalidReplayId::SELECTOR,
664            canonical::INonceManager::InvalidReplayId::SELECTOR
665        );
666    }
667
668    #[test]
669    fn transaction_context_abi_matches_canonical_selectors() {
670        assert_eq!(
671            super::ITransactionContext::getTransactionSenderCall::SELECTOR,
672            canonical::ITransactionContext::getTransactionSenderCall::SELECTOR
673        );
674        assert_eq!(
675            super::ITransactionContext::getTransactionPayerCall::SELECTOR,
676            canonical::ITransactionContext::getTransactionPayerCall::SELECTOR
677        );
678        assert_eq!(
679            super::ITransactionContext::getTransactionSenderActorIdCall::SELECTOR,
680            canonical::ITransactionContext::getTransactionSenderActorIdCall::SELECTOR
681        );
682    }
683}