Skip to content

Conversation

@hlgltvnnk
Copy link
Collaborator

@hlgltvnnk hlgltvnnk commented Nov 26, 2025

Summary by CodeRabbit

  • New Features

    • Optional no_registration flag to control token registration behavior
    • Per-token full-access key management for tokens
    • Support for using global contracts during token deployment
    • Versioned contract state with upgrade/migration support
  • Chores

    • Bumped near-workspaces to v0.21
    • Consolidated and simplified build/test workflows; removed no-registration build variants and unified test initialization

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds versioned on‑chain state and explicit no‑registration control to poa‑token, exposes per‑token full‑access key APIs and optional global‑contract deployment in poa‑factory, updates build tasks/features and workspace deps, and simplifies tests by removing parameterized no_registration branches.

Changes

Cohort / File(s) Summary
Dependency Update
Cargo.toml
Bumps workspace dependency near-workspaces from 0.200.21.
Build & Reproducible Build Tasks
Makefile.toml, poa-token/Cargo.toml, .github/workflows/ci.yml
Removes no-registration build variants; consolidates build tasks (e.g., build-poa-factory-global), wires global_contracts feature into build commands, updates reproducible build config, and adds workspace/dev deps (defuse-borsh-utils, impl-tools, rstest, defuse-test-utils, arbitrary_with). CI build step now runs cargo make test-build.
Poa Factory: features & APIs
poa-factory/Cargo.toml, poa-factory/src/lib.rs, poa-factory/src/contract.rs
Adds global_contracts feature; introduces public trait TokenFullAccessKeys (add/delete per-token full-access keys) and exposes it via PoaFactory; changes deploy_token signature to accept no_registration: Option<bool>; adds conditional global vs local WASM deploy paths and cfg-based constants.
Poa Token: state & API refactor
poa-token/Cargo.toml, poa-token/src/lib.rs, poa-token/src/contract/mod.rs, poa-token/src/contract/state.rs
Introduces versioned state layer (State, StateV0, VersionedState, MaybeVersionedContractState, DEFAULT_NO_REGISTRATION); replaces token/metadata fields with state and custom (de)serialization; Contract::new gains no_registration; adds NoRegistration trait (no_registration, set_no_registration); adds migration path and related tests.
Factory & Account test helpers
tests/src/tests/poa/factory.rs, tests/src/tests/defuse/env/*
Adds no_registration parameter to test helper APIs (poa_factory_deploy_token, poa_deploy_token), renames EnvBuilder flag to no_registration, removes POA_TOKEN_WASM_NO_REGISTRATION, and simplifies token creation to call deploy_token(..., no_registration).
Test suite simplification (many tests)
tests/src/tests/defuse/intents/*.rs, tests/src/tests/defuse/tokens/*, tests/src/tests/defuse/storage/mod.rs, other tests/...
Removes parameterization over no_registration across many tests, simplifies Env construction to fixed builder chains (e.g., Env::builder().build().await), and removes branches tied to no-registration.
Tests: env builder & storage calls
tests/src/tests/defuse/env/storage.rs, tests/src/tests/defuse/env/builder.rs
Updated call sites to pass new boolean where required (poa_factory_deploy_token signature change) and renamed builder methods/fields for no_registration.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant PoAFactory as PoA Factory
    participant TokenAccount
    participant GlobalReg as Global Contract

    Caller->>PoAFactory: deploy_token(token, metadata, no_registration)
    activate PoAFactory
    PoAFactory->>TokenAccount: create account & transfer init balance

    alt global_contracts enabled
        PoAFactory->>GlobalReg: use_global_contract_by_account_id(account_id)
        GlobalReg-->>TokenAccount: token logic referenced (no WASM deploy)
    else
        PoAFactory->>TokenAccount: deploy POA_TOKEN_WASM to account
    end

    PoAFactory->>TokenAccount: call initialization (metadata, no_registration)
    PoAFactory-->>Caller: return Promise
    deactivate PoAFactory
Loading
sequenceDiagram
    participant User
    participant Token as poa-token Contract
    participant StateLayer as Versioned State Layer

    User->>Token: storage_deposit(account_id, ...)
    activate Token
    alt no_registration == true
        Token->>Token: require caller == owner or current_account
    end
    Token->>StateLayer: update balances / registrations
    StateLayer-->>Token: persisted
    Token-->>User: success
    deactivate Token
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Areas needing extra attention:
    • poa-token/src/contract/state.rs — versioned (de)serialization, magic-prefix handling, and upgrade tests.
    • poa-token/src/contract/mod.rs — migration, autoimpl Deref/DerefMut, storage_deposit access checks and NoRegistration semantics.
    • poa-factory/src/contract.rs — conditional global vs local deploy logic, cfg constants, and Promise init payload including no_registration.
    • Tests and helpers (tests/.../poa/factory.rs, env builder, many intent tests) — ensure all call sites/signatures match the new API.
    • Build tasks (Makefile.toml, Cargo.toml changes) — verify reproducible build adjustments and feature wiring.

Possibly related PRs

Suggested reviewers

  • pityjllk
  • mitinarseny

"🐰
I hop through bytes with careful cheer,
Versioned state and flags now clear,
Keys for tokens, global builds in sight,
Tests pruned neat — the forest feels light,
Carrots compiled; time for a snack tonight!"

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'WIP: Feat/global token contracts' is related to the changeset's core objective. The PR introduces global contracts functionality, though 'WIP' prefix and vague 'Feat/' phrasing reduce clarity about the specific feature being implemented.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
tests/src/tests/defuse/env/builder.rs (1)

33-33: Consider renaming Env.disable_registration for consistency.

The builder field has been renamed from disable_registration to no_registration, but Line 137 maps it back to disable_registration when constructing Env. For consistency with the NoRegistration trait naming, consider also renaming the Env struct field to no_registration.

Apply this pattern to the Env struct definition (in the file defining Env):

 pub struct Env {
     // ... other fields
-    pub disable_registration: bool,
+    pub no_registration: bool,
 }

And update Line 137:

-    disable_registration: self.no_registration,
+    no_registration: self.no_registration,

Also applies to: 80-83, 137-137

Makefile.toml (1)

100-107: Consider adding global contracts variant for reproducible builds.

The build-reproducible task uses build-poa-factory-reproducible which doesn't enable the global_contracts feature, unlike the non-reproducible default build. If production deployments require global contracts, the reproducible build should also enable this feature.

poa-token/src/contract/mod.rs (1)

120-120: Consider removing or making this log conditional.

The hardcoded log message "GLOBAL SMC LOG: ft_deposit called on global contract" will fire on every ft_deposit call. If this contract is used in both global and non-global scenarios, this message could be misleading. Consider:

  1. Removing the log if it's for temporary debugging, or
  2. Making it conditional based on deployment mode, or
  3. Using a more generic message if all deployments are global contracts
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed2c7d5 and b726deb.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (23)
  • Cargo.toml (1 hunks)
  • Makefile.toml (6 hunks)
  • poa-factory/Cargo.toml (2 hunks)
  • poa-factory/src/contract.rs (5 hunks)
  • poa-factory/src/lib.rs (1 hunks)
  • poa-token/Cargo.toml (1 hunks)
  • poa-token/src/contract/mod.rs (8 hunks)
  • poa-token/src/contract/state.rs (1 hunks)
  • poa-token/src/lib.rs (2 hunks)
  • tests/src/tests/defuse/env/builder.rs (3 hunks)
  • tests/src/tests/defuse/env/mod.rs (2 hunks)
  • tests/src/tests/defuse/env/storage.rs (1 hunks)
  • tests/src/tests/defuse/intents/ft_withdraw.rs (7 hunks)
  • tests/src/tests/defuse/intents/legacy_nonce.rs (1 hunks)
  • tests/src/tests/defuse/intents/mod.rs (3 hunks)
  • tests/src/tests/defuse/intents/public_key.rs (2 hunks)
  • tests/src/tests/defuse/intents/relayers.rs (1 hunks)
  • tests/src/tests/defuse/intents/simulate.rs (6 hunks)
  • tests/src/tests/defuse/intents/token_diff.rs (4 hunks)
  • tests/src/tests/defuse/storage/mod.rs (2 hunks)
  • tests/src/tests/defuse/tokens/nep141/mod.rs (6 hunks)
  • tests/src/tests/defuse/tokens/nep245/mod.rs (6 hunks)
  • tests/src/tests/poa/factory.rs (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (13)
tests/src/tests/defuse/intents/legacy_nonce.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/intents/public_key.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
poa-token/src/lib.rs (1)
tests/src/tests/defuse/env/builder.rs (1)
  • no_registration (80-83)
tests/src/tests/defuse/intents/simulate.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/storage/mod.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/intents/mod.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/intents/ft_withdraw.rs (3)
tests/src/tests/defuse/env/mod.rs (2)
  • builder (58-60)
  • new (62-64)
tests/src/utils/mt.rs (3)
  • mt_contract_balance_of (53-58)
  • mt_contract_balance_of (211-226)
  • mt_contract_balance_of (425-434)
tests/src/tests/defuse/intents/mod.rs (1)
  • new (34-41)
tests/src/tests/defuse/tokens/nep141/mod.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/tokens/nep245/mod.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/intents/relayers.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/poa/factory.rs (1)
tests/src/tests/defuse/env/builder.rs (1)
  • no_registration (80-83)
poa-factory/src/contract.rs (1)
poa-factory/src/lib.rs (3)
  • deploy_token (25-30)
  • add_token_full_access_key (14-14)
  • delete_token_full_access_key (18-18)
poa-token/src/contract/mod.rs (2)
tests/src/tests/defuse/env/storage.rs (1)
  • state (243-250)
tests/src/tests/defuse/env/builder.rs (1)
  • no_registration (80-83)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Check
  • GitHub Check: Shared / Static Analysis (intents-poa-factory, contract, near, poa-factory, 1, ., 1.18, false, --filter-pa...
  • GitHub Check: Shared / Static Analysis (intents-poa-token, contract, near, poa-token, 1, ., 1.18, false, --filter-paths ...
  • GitHub Check: Shared / Static Analysis (intents-contract, contract, near, defuse, 1, ., 1.18, false, --filter-paths "nod...
  • GitHub Check: Shared security analysis / Static Analysis (intents-contract, contract, near, defuse, 1, ., 1.18, false, --filter-paths "nod...
  • GitHub Check: Shared security analysis / Static Analysis (intents-poa-token, contract, near, poa-token, 1, ., 1.18, false, --filter-paths ...
  • GitHub Check: Shared security analysis / Static Analysis (intents-poa-factory, contract, near, poa-factory, 1, ., 1.18, false, --filter-pa...
  • GitHub Check: Security Audit - report
🔇 Additional comments (44)
tests/src/tests/defuse/intents/public_key.rs (1)

20-20: LGTM! Environment setup simplified.

The removal of .no_registration(true) aligns with the PR's goal to standardize environment initialization across tests.

Also applies to: 63-63

tests/src/tests/defuse/intents/ft_withdraw.rs (3)

21-21: LGTM! Test parameterization removed.

The function signatures have been simplified by removing the no_registration parameter, aligning with the PR's goal to standardize test flows.

Also applies to: 217-217


27-27: LGTM! Environment setup simplified.

The environment now uses default initialization without the no_registration flag.

Also applies to: 220-220


112-125: LGTM! Added wNEAR preparation steps.

The test now explicitly wraps NEAR and deposits wNEAR to prepare for storage deposit operations, making the test flow more explicit and deterministic.

poa-factory/src/contract.rs (3)

249-268: LGTM! Token full access key management implemented correctly.

The TokenFullAccessKeys trait implementation correctly delegates access key operations to individual token contracts using the appropriate external contract calls.


24-30: The balance reduction with global_contracts is intentional and correct—no issue exists.

When global_contracts is enabled (line 136-140), the token contract doesn't deploy its own WASM bytecode. Instead, it references a pre-deployed shared global contract via .use_global_contract_by_account_id(). Consequently, 5 milliNEAR is appropriate to cover only account creation and state storage (~500B as noted in the comment). Without global contracts (line 131-134), the full WASM is deployed per token account, requiring the higher 3 NEAR balance. The deposit validation at lines 119-122 correctly accounts for actual storage costs in both cases.


104-153: Based on my verification of the codebase, I can now provide the rewritten review comment:


The current implementation correctly handles both concerns raised.

The no_registration: Option<bool> parameter is intentional and idiomatic. It wraps a plain bool with a sensible default (DEFAULT_NO_REGISTRATION = true), allowing callers to either explicitly pass a value or rely on the default. This is the standard Rust pattern for optional initialization parameters, as demonstrated by the poa-token contract's new() function which accepts Option<bool> and unwraps it with a default.

Regarding the TODO comment about reverting on failure with use_global_contract_by_account_id: NEAR SDK's Promise model provides implicit transactional guarantees. The entire Promise chain (account creation, transfer, contract deployment, and function call) is atomic. If use_global_contract_by_account_id fails, the entire transaction reverts, making explicit revert handling unnecessary. The TODO is a valid design question but reflects the inherent guarantees of the NEAR protocol rather than a missing safety mechanism.

tests/src/tests/defuse/intents/legacy_nonce.rs (1)

18-18: LGTM! Environment setup simplified.

The removal of .no_registration(true) aligns with the PR's standardization of test environment initialization.

tests/src/tests/defuse/storage/mod.rs (1)

32-32: LGTM! More explicit test configuration.

Replacing .no_registration(false) with .disable_ft_storage_deposit() makes the test setup more explicit about disabling automatic storage deposits, which aligns better with the intent of these storage deposit tests.

Also applies to: 124-124

poa-factory/Cargo.toml (1)

24-24: LGTM! Global contracts feature added.

The new global_contracts feature is properly configured and wired to the near-sdk/global-contracts dependency feature. The build command correctly enables both contract and global_contracts features.

Also applies to: 39-40

tests/src/tests/defuse/env/storage.rs (1)

106-106: LGTM! Updated to match new factory API.

The addition of the true argument for no_registration correctly aligns with the expanded poa_factory_deploy_token signature that now accepts a no_registration parameter.

Cargo.toml (1)

94-94: No breaking changes between near-workspaces 0.20 and 0.21; upgrade is safe.

Based on verification of the near-workspaces CHANGELOG, version 0.21.0 (released 2025-08-15) contains no breaking changes. The only change is an internal dependency update from near-* 0.30 to 0.31. Your near-sdk 5.15 is compatible with near-* 0.31, and the extensive codebase usage of near-workspaces types and APIs (Account, Contract, Worker, call methods, etc.) requires no modifications.

poa-token/src/lib.rs (2)

15-22: LGTM! Well-designed trait addition.

The NoRegistration trait cleanly extends the token contract API with runtime configuration for registration behavior. The security requirement for 1 yⓃ attachment on set_no_registration is appropriately documented.


36-36: Public API extension looks good.

Adding NoRegistration to the PoaFungibleToken trait bounds appropriately extends the contract interface.

poa-token/Cargo.toml (2)

14-27: Build simplification aligns with runtime configuration approach.

Removing the separate no_registration reproducible build variant is appropriate since registration behavior is now configurable at runtime via the NoRegistration trait.


32-43: New dependencies support versioned state management.

The added dependencies (defuse-borsh-utils, impl-tools, rstest, defuse-test-utils, arbitrary_with) align with the PR's introduction of versioned state management and enhanced testing capabilities.

tests/src/tests/defuse/tokens/nep141/mod.rs (2)

35-36: Test simplification may affect NEP-141 coverage.

These NEP-141 token tests have been simplified to use default environment configuration. Verify that FT deposit, withdrawal, and transfer behaviors don't vary based on registration mode, especially around storage deposit handling.

Also applies to: 75-76, 108-111, 190-193


257-262: Appropriate use of deployer_as_super_admin for privileged operations.

These tests correctly retain deployer_as_super_admin() since they need to grant roles (Role::UnrestrictedWithdrawer) which requires admin permissions.

Also applies to: 373-380

tests/src/tests/defuse/env/mod.rs (1)

103-109: Deployment simplification looks good.

Consolidating token deployment into a single path with a boolean no_registration parameter improves maintainability and aligns with the runtime configuration approach.

tests/src/tests/defuse/intents/mod.rs (1)

217-220: Test simplification is consistent with PR objectives.

These intent tests have been appropriately simplified to use default environment configuration, aligning with the broader PR changes that move no_registration from a test-time parameter to a runtime configuration option.

Also applies to: 308-312, 367-368

tests/src/tests/defuse/intents/relayers.rs (1)

14-18: Test coverage reduction concern is unfounded—relayer key management does not depend on registration mode.

The no_registration flag affects token registration in POA token contracts and is completely independent of relayer key operations. The relayer key management functions (add_relayer_key and delete_relayer_key) have no logic or conditional behavior based on registration state—they only manage access keys and roles. The test running once with deployer_as_super_admin() is sufficient, as it covers all relevant relayer key scenarios. The parameterization concern reflects a misunderstanding of what no_registration controls within this codebase.

tests/src/tests/defuse/intents/simulate.rs (1)

45-45: The review comment raises a valid concern about test coverage, but the claimed code simplification cannot be verified in the current codebase.

The disable_registration mechanism does affect token behavior (when enabled, it restricts storage_deposit() calls to owner/contract only), so hypothetically, testing with different registration modes would provide different coverage. However:

  1. No evidence of the claimed simplification: All current simulate tests use Env::builder().build().await with default registration settings (allowing self-registration). No tests in the codebase currently use .no_registration(true).

  2. No git history of recent changes: The simulate.rs file shows no recent modifications removing explicit registration configuration.

  3. The mechanism is real: Registration mode DOES affect storage_deposit() behavior in poa-token contracts (lines 191-197 of poa-token/src/contract/mod.rs), and a simulate_storage_deposit_intent() test exists.

  4. Missing test variant: If coverage is a concern, there's no evidence of a parallel test using Env::builder().no_registration(true).build().await to verify simulation behavior with restricted registration.

To properly assess coverage impact, verify whether an earlier version of these tests explicitly used .no_registration(true) and what specific test assertions differed.

poa-factory/src/lib.rs (2)

11-19: LGTM! Well-documented trait for per-token access key management.

The TokenFullAccessKeys trait provides a clean interface for managing full access keys on individual token contracts. The security notes about requiring 1 yⓃ attachment are appropriate for preventing unauthorized key manipulation.


25-30: Review comment is accurate and verified.

All claims in the original review are substantiated:

  • ✅ The trait signature uses Option<bool> for no_registration (poa-factory/src/lib.rs:29)
  • ✅ The implementation handles None with an appropriate default: .unwrap_or(DEFAULT_NO_REGISTRATION) (poa-token/src/contract/mod.rs:69)
  • ✅ The default value is sensible: DEFAULT_NO_REGISTRATION = true (poa-token/src/contract/state.rs:14)
  • ✅ Backward compatibility is maintained: callers can omit the parameter and it applies the default
Makefile.toml (2)

19-26: Verify intentional difference between default and test builds.

The default build task uses build-poa-factory-global (with global_contracts feature), while test-build uses build-poa-factory (without the feature). Ensure this is intentional and tests don't require the global contracts functionality.


162-166: Good addition of dedicated test-build task.

Separating test build dependencies from test execution improves build clarity and allows for more granular control over what gets built for tests.

tests/src/tests/defuse/intents/token_diff.rs (2)

264-265: invariant_violated test now uses default environment.

The test no longer parameterizes no_registration, simplifying the test setup while retaining the core invariant violation logic.


20-23: The review comment's premise is incorrect—these tests never used no_registration parameterization.

Verification shows that swap_p2p, swap_many, invariant_violated, and solver_user_closure in token_diff.rs have no history of using a no_registration parameter. Git history and current code inspection confirm these tests only vary by the fee parameter via #[values(...)]. The no_registration option remains available in EnvBuilder for other tests (e.g., in poa/factory.rs and ft_withdraw.rs), so this is not a removal of a contract feature.

Likely an incorrect or invalid review comment.

tests/src/tests/defuse/tokens/nep245/mod.rs (2)

31-36: Test simplified to use default environment configuration.

The multitoken_enumeration test now uses a fixed environment setup with create_unique_users(), removing the no_registration parameter variation.


319-322: Consistent simplification pattern applied.

The multitoken_enumeration_with_ranges test follows the same simplification pattern, maintaining consistency across the test suite.

poa-token/src/contract/state.rs (3)

14-14: Default value for no_registration is documented clearly.

The constant DEFAULT_NO_REGISTRATION = true provides a clear default for legacy state migration and new deployments.


16-46: Well-structured versioned state migration pattern.

The VersionedState enum with Cow for zero-copy serialization and the conversion implementations provide a clean upgrade path from legacy (StateV0) to the current state format. The comment about Borsh always deserializing into Cow::Owned is helpful.


71-109: Robust versioned deserialization with magic prefix.

The magic prefix approach (u32::MAX) for distinguishing versioned vs legacy state is sound. The comment explaining why legacy contracts won't start with this prefix (due to LookupMap prefix bytes) provides good justification for the safety assumption.

tests/src/tests/poa/factory.rs (5)

30-43: LGTM!

The addition of the no_registration parameter to both trait methods is clean and consistent. The explicit boolean parameter forces callers to make a conscious decision about registration requirements.


102-132: LGTM!

The implementation correctly propagates the no_registration parameter through the JSON RPC call and forwards it appropriately in the convenience wrapper method.


195-216: LGTM!

The Contract implementation correctly delegates to the Account implementation while properly forwarding the no_registration parameter.


287-300: LGTM!

The existing test correctly maintains its original behavior by passing false for no_registration, ensuring backward compatibility and consistent test coverage for the standard registration flow.


328-397: Perfect! I have now completed a thorough verification of the storage_deposit access control test. Let me provide the final analysis:

Verification Summary:

After tracing through the code:

  1. Token Owner Assignment: When the factory deploys a token with no_registration=true, the factory calls the token's new() method WITHOUT passing an owner_id parameter. The token's new() method defaults the owner to PREDECESSOR_ACCOUNT_ID at that moment, which is the factory contract itself (factory.id()), NOT root.

  2. Storage Deposit Access Control: The token's storage_deposit method (lines 191-197 in poa-token/src/contract/mod.rs) requires:

    • When no_registration=true, only the owner (factory) or the token contract itself can call it
  3. Test Execution: In the test, root.ft_storage_deposit(&ft1, None) makes a call where:

    • PREDECESSOR_ACCOUNT_ID = root.id()
    • Token owner = factory.id()
    • Token contract = ft1
    • root.id() is neither the owner nor the contract itself
    • Therefore, the call correctly fails with "Method is private"

The review comment's analysis is incorrect. The test expectation at lines 376-383 is valid and correct.


Verify storage_deposit access control test expectation.

The test expectation at lines 376-383 is correct. When the factory deploys a token with no_registration=true, the token's owner is set to the factory contract (not root). Therefore, root.ft_storage_deposit(&ft1, None) correctly fails with "Method is private" because root is neither the owner nor the contract itself.

poa-token/src/contract/mod.rs (6)

1-24: LGTM!

The new imports are properly organized and support the state versioning and serialization refactoring introduced in this file.


34-43: LGTM!

The refactoring to use a versioned State wrapper with custom serialization and auto-deref is a solid pattern for enabling contract state migrations while maintaining backward compatibility.


47-86: LGTM!

The constructor correctly initializes the new State structure with the no_registration parameter, providing a sensible default via DEFAULT_NO_REGISTRATION when the parameter is not supplied.


88-101: LGTM!

The migration function correctly implements the pattern for upgrading from StateV0 to State, with appropriate security controls (private and assert_one_yocto). The init(ignore_state) attribute is essential for the migration to work properly.


186-199: LGTM!

The access control for storage_deposit correctly restricts the method to the owner or the contract itself when no_registration is enabled, which aligns with the design intent of preventing external registration in no-registration mode.


259-271: LGTM!

The NoRegistration trait implementation provides appropriate getter/setter methods with proper access control. The set_no_registration method correctly restricts changes to the owner and requires one yocto for security.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
poa-factory/src/contract.rs (1)

104-149: PoA token new signature mismatch: owner_id parameter missing from factory's JSON payload.

The factory's deploy_token function (lines 105-149) sends a JSON payload with only metadata and no_registration, but the PoA token's new initializer at poa-token/src/contract/mod.rs:49-53 expects owner_id as the first parameter:

// poa-token/src/contract/mod.rs:49-53
pub fn new(
    owner_id: Option<AccountId>,
    metadata: Option<FungibleTokenMetadata>,
    no_registration: Option<bool>,
) -> Self

The factory sends:

{
  "metadata": metadata,
  "no_registration": no_registration
}

The factory needs to include owner_id in the JSON payload passed to the new call (likely self.predecessor_account_id() or similar). Without it, deserialization will fail and initialization will panic.

🧹 Nitpick comments (2)
poa-factory/src/contract.rs (1)

4-4: Consider requiring known tokens before managing per‑token full‑access keys.

The new TokenFullAccessKeys impl and use of ext_full_access_keys are straightforward and mirror the global key APIs, but unlike set_metadata/ft_deposit you don’t currently assert that the token exists in self.tokens before calling out. If you want these methods to operate only on factory‑managed tokens and keep semantics consistent, you could add a require!(self.tokens.contains(&token), "token does not exist"); check to both methods before constructing the promise.

 fn add_token_full_access_key(&mut self, token: String, public_key: PublicKey) -> Promise {
     assert_one_yocto();
+    require!(self.tokens.contains(&token), "token does not exist");
     ext_full_access_keys::ext(Self::token_id(token))
         .with_attached_deposit(NearToken::from_yoctonear(1))
         .add_full_access_key(public_key)
 }

 fn delete_token_full_access_key(&mut self, token: String, public_key: PublicKey) -> Promise {
     assert_one_yocto();
+    require!(self.tokens.contains(&token), "token does not exist");
     ext_full_access_keys::ext(Self::token_id(token))
         .with_attached_deposit(NearToken::from_yoctonear(1))
         .delete_key(public_key)
 }

Also applies to: 22-22, 246-265

poa-token/src/lib.rs (1)

15-22: Consider clarifying the doc comment.

The doc comment "whether the token allows accounts initialize storage deposits by itself" is grammatically awkward. Consider rephrasing to clarify the meaning—e.g., "Returns whether the token requires users to register storage (false) or handles it internally (true)."

 pub trait NoRegistration {
-    /// Returns whether the token allows accounts initialize storage deposits by itself.
+    /// Returns whether user-initiated storage registration is disabled.
+    /// When `true`, only the owner or the contract itself can call `storage_deposit`.
     fn no_registration(&self) -> bool;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b726deb and 9f9cc4e.

📒 Files selected for processing (5)
  • poa-factory/src/contract.rs (5 hunks)
  • poa-token/src/contract/mod.rs (8 hunks)
  • poa-token/src/contract/state.rs (1 hunks)
  • poa-token/src/lib.rs (2 hunks)
  • tests/src/tests/defuse/intents/ft_withdraw.rs (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/src/tests/defuse/intents/ft_withdraw.rs
🧰 Additional context used
🧬 Code graph analysis (3)
poa-token/src/lib.rs (1)
poa-token/src/contract/mod.rs (2)
  • no_registration (259-261)
  • set_no_registration (265-268)
poa-factory/src/contract.rs (3)
poa-factory/src/lib.rs (1)
  • deploy_token (25-30)
poa-token/src/contract/mod.rs (1)
  • no_registration (259-261)
poa-token/src/lib.rs (1)
  • no_registration (17-17)
poa-token/src/contract/state.rs (1)
poa-token/src/contract/mod.rs (2)
  • ft_balance_of (162-164)
  • new (49-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Shared security analysis / Static Analysis (intents-poa-factory, contract, near, poa-factory, 1, ., 1.18, false, --filter-pa...
  • GitHub Check: Shared / Static Analysis (intents-poa-factory, contract, near, poa-factory, 1, ., 1.18, false, --filter-pa...
  • GitHub Check: Shared / Static Analysis (intents-poa-token, contract, near, poa-token, 1, ., 1.18, false, --filter-paths ...
  • GitHub Check: Shared / Static Analysis (intents-contract, contract, near, defuse, 1, ., 1.18, false, --filter-paths "nod...
  • GitHub Check: Security Audit - report
🔇 Additional comments (9)
poa-factory/src/contract.rs (1)

24-30: Confirm POA_TOKEN_INIT_BALANCE values and comment under global_contracts.

The cfg split between from_millinear(5) for global_contracts and from_near(3) otherwise looks reasonable, and gating POA_TOKEN_WASM behind not(global_contracts) is clean. It might be worth double‑checking that the 5 millinear initial balance still comfortably covers per‑token state for the global-contracts path, and updating the “size ~ 500B” comment if that assumption has changed.

Also applies to: 36-38

poa-token/src/contract/state.rs (3)

71-84: Well-designed magic prefix for version detection.

The use of u32::MAX as a magic prefix is a clever approach to distinguish between legacy and versioned contract state during deserialization. The comment correctly explains why this is safe—legacy contracts would have a different byte pattern in the first 4 bytes due to the LookupMap prefix.


86-110: Deserialization logic is sound.

The fallback path correctly prepends the already-consumed 4 bytes using buf.chain(reader) before deserializing as legacy StateV0. The chained .map(Into::into) calls properly convert through VersionedState to State.


231-241: Test correctly exercises the legacy upgrade path.

The test properly validates the upgrade flow: serialize StateV0 directly (simulating legacy format), then deserialize through Contract (which uses MaybeVersionedContractState), and verify data integrity. The drop(legacy_acc) is correctly placed to ensure near-sdk collections flush to storage before deserialization.

poa-token/src/lib.rs (1)

28-37: Adding supertrait is appropriate for the ext_contract pattern.

The addition of NoRegistration to PoaFungibleToken supertrait bounds is consistent with the contract's extended capabilities. Since this is an ext_contract, it primarily defines the cross-contract call interface rather than expecting external implementations.

poa-token/src/contract/mod.rs (4)

35-43: Clean pattern using autoimpl for state access.

The use of autoimpl(Deref using self.state) and autoimpl(DerefMut using self.state) combined with custom borsh serialization via MaybeVersionedContractState is a clean approach. This allows transparent access to State fields while maintaining versioned (de)serialization.


257-269: NoRegistration implementation looks correct.

The getter properly leverages the Deref autoimpl to access State.no_registration. The setter is appropriately protected with #[only(self, owner)], #[payable], and assert_one_yocto() to prevent accidental or unauthorized changes.


49-71: Constructor correctly handles the new no_registration parameter.

The constructor properly accepts an optional no_registration flag with a sensible default (DEFAULT_NO_REGISTRATION). The State initialization is clean and consistent.


88-101: I'll verify the concerns raised in this review comment about the migrate function. Let me start by exploring the codebase structure and examining the state management implementation.
<function_calls>

find . -name "mod.rs" -type f | head -10

</function_calls>
<function_calls>

find . -name "state.rs" -type f

</function_calls>
<function_calls>

find . -type f -name "*.rs" | grep -E "(contract|state)" | head -20

</function_calls>

Let me search more broadly for the contract file and state definitions:
<function_calls>

rg -l "migrate" --type rust | head -10

</function_calls>

Now let me examine the actual migrate function and related state structures:
<function_calls>

rg -n "fn migrate" -A 15 --type rust

</function_calls>

Let me also search for MaybeVersionedContractState and state versioning:
<function_calls>

rg -n "MaybeVersionedContractState|VERSIONED_MAGIC_PREFIX|StateV0|STATE" --type rust -C 2 | head -80

</function_calls>

Let me check the repository structure first:
<function_calls>

ls -la poa-token/src/contract/ 2>/dev/null || ls -la poa-token/ 2>/dev/null || find . -type d -name "poa-token" | head -5

</function_calls>

<function_calls>

git ls-files | grep -E "poa-token.*mod.rs|poa-token.*state.rs" | head -10

</function_calls>

<function_calls>

git ls-files | grep ".rs$" | head -30

</function_calls>

Let me check the PR context to find the actual file paths:
<function_calls>

rg -l "pub fn migrate" --type rust

</function_calls>

<function_calls>

rg -n "StateV0" --type rust -B 3 -A 3

</function_calls>

Let me try a broader search:
<function_calls>

find . -name "*.rs" -type f | head -40

</function_calls>

<function_calls>

cat -n poa-token/src/contract/mod.rs 2>/dev/null | sed -n '80,110p'

</function_calls>

Now let me examine the state structure:
<function_calls>

find . -path "poa-token" -name "*.rs" -type f

</function_calls>

<function_calls>

rg -l "struct State|pub enum MaybeVersioned" --type rust

</function_calls>

Let me search for the state definitions directly:
<function_calls>

rg -n "struct StateV0|struct State" --type rust -A 5

</function_calls>

Let me try to understand the file structure:
<function_calls>

ls -la poa-token/src/

</function_calls>

<function_calls>

cat poa-token/src/contract/mod.rs | head -120 | tail -40

</function_calls>

Now let me check if there's any state versioning mechanism:
<function_calls>

cat poa-token/src/state.rs 2>/dev/null | head -100

</function_calls>

<function_calls>

rg -n "env::state_read|env::storage_read" --type rust -B 2 -A 2

</function_calls>

Let me examine the full migrate function and surrounding context:
<function_calls>

cat poa-token/src/contract/mod.rs | head -150 | tail -70

</function_calls>

Now let me check the imports and the state definition:
<function_calls>

head -50 poa-token/src/contract/mod.rs

</function_calls>

<function_calls>

cat poa-token/src/state.rs

</function_calls>

Perfect! Now I have the full context. Let me search for any version checking or magic prefix patterns:
<function_calls>

rg -n "0xFFFFFFFF|MAGIC|VERSIONED" --type rust

</function_calls>

Let me check how near-sdk handles state versioning:
<function_calls>

cat poa-token/Cargo.toml | grep -A 5 near-sdk

</function_calls>

Now let me search for any initialization or migration patterns in the contract:
<function_calls>

rg -n "init|new|contract(" --type rust poa-token/src/contract/mod.rs | head -20

</function_calls>

Let me check if the code has any actual tests or usage patterns for migrate:
<function_calls>

find . -path "poa-token" -name "*.rs" -type f | xargs rg -l "migrate"

</function_calls>

<function_calls>

cat poa-token/src/contract/mod.rs | sed -n '1,200p' | tail -100

</function_calls>

Let me check what the #[init] decorator does:
<function_calls>

near-sdk #[init(ignore_state)] decorator rust contract migration

</function_calls>

Let me also check if there's existing state versioning in the codebase:
<function_calls>

rg -n "impl.*From.*StateV0|into|from_slice" --type rust poa-token/ -C 2

</function_calls>

Now let me understand the actual issue by looking at what happens when env::state_read is called:
<function_calls>

cat poa-token/src/contract/mod.rs | sed -n '85,105p'

</function_calls>

Perfect! Now let me verify the critical claim about the review comment - whether there actually is a MaybeVersionedContractState or any versioning mechanism:
<function_calls>

rg -n "MaybeVersioned|Versioned" --type rust poa-token/

</function_calls>

Let me check for any version handling in the From implementation:
<function_calls>

cat poa-token/src/state.rs | grep -n "From|impl" -A 10 | head -40

</function_calls>

Now let me understand the actual structure of the contract initialization:
<function_calls>

rg -n "#[contract]|pub struct|#[init]" --type rust poa-token/src/contract/mod.rs -B 1 -A 3

</function_calls>

Let me check if there are other places where state is read:
<function_calls>

rg -n "state_read|storage_read|"STATE"" --type rust poa-token/

</function_calls>

Let me verify the actual near-sdk version and understand how state management works:
<function_calls>

cat poa-token/Cargo.toml

</function_calls>

Now let me check how #[init(ignore_state)] actually works - does it prevent re-initialization:
<function_calls>

"ignore_state" near-sdk rust contract initialization

</function_calls>

Let me look for any test files or documentation:
<function_calls>

find . -path "poa-token" -type f ( -name ".md" -o -name ".txt" ) | head -10

</function_calls>

Let me check if there's any runtime state serialization/deserialization that would use a magic prefix:
<function_calls>

rg -n "borsh|serialize|deserialize" --type rust poa-token/src/ | head -20

</function_calls>

Now let me verify if the migrate function could actually be called twice:
<function_calls>

cat poa-token/src/contract/mod.rs | grep -n "migrate|#[payable]|#[private]|#[init" -B 2 -A 1

</function_calls>

Let me check if #[init] with ignore_state prevents double initialization:
<function_calls>

rg -n "impl.*Contract|pub fn.*new|pub fn.*init" --type rust poa-token/src/contract/mod.rs -B 2 -A 8 | head -50

</function_calls>

Let me examine the entire contract definition:
<function_calls>

wc -l poa-token/src/contract/mod.rs

</function_calls>

<function_calls>

cat poa-token/src/contract/mod.rs

</function_calls>

Perfect! Now I have the full picture. Let me verify key claims about the review comment:

Now let me verify one more time that MaybeVersionedContractState truly doesn't exist:
<function_calls>

rg -r "MaybeVersioned|0xFFFFFFFF" --type rust .

</function_calls>

Let me also check the near-sdk documentation to understand env::state_read behavior:
<function_calls>

near-sdk env::state_read borsh deserialization how it works

</function_calls>

Now let me verify if there's any actual risk with calling migrate twice:
<function_calls>

rg -n "assert|require|panic" --type rust poa-token/src/contract/mod.rs | head -20

</function_calls>

Let me check what happens when #[init(ignore_state)] is used:
<function_calls>

near-sdk rust "ignore_state" init decorator prevents double initialization

</function_calls>

Based on my thorough investigation of the codebase and verification of the claims made in the review comment, I can now provide my final assessment:

The review comment contains fundamental inaccuracies and references non-existent code constructs.

The core issue: The review comment proposes a fix that references MaybeVersionedContractState::VERSIONED_MAGIC_PREFIX and suggests using env::storage_read() with specific magic byte checking, but neither MaybeVersionedContractState nor any versioning mechanism with magic prefixes (0xFFFFFFFF) exists in this codebase. These are fabrications not present in the actual contract implementation.

Key findings from verification:

  1. Non-existent code references: MaybeVersionedContractState, VERSIONED_MAGIC_PREFIX, and the magic prefix pattern 0xFFFFFFFF do not exist anywhere in the codebase
  2. Incorrect understanding of near-sdk: The codebase uses standard near-sdk Borsh serialization, not a custom versioning adapter
  3. Misdiagnosed risk: The #[init(ignore_state)] decorator specifically allows custom state loading logic, and combined with #[private], provides adequate protection against misuse
  4. Non-compiling fix: The proposed code would not compile as it references undefined types and constants

Likely an incorrect or invalid review comment.

pityjllk
pityjllk previously approved these changes Nov 28, 2025
Copy link
Collaborator

@pityjllk pityjllk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, few minor comments

/// Copied from `near_contract_standards::fungible_token::core_impl::GAS_FOR_FT_TRANSFER_CALL`
const POA_TOKEN_FT_TRANSFER_CALL_MIN_GAS: Gas = Gas::from_tgas(30);

#[cfg(not(feature = "global_contracts"))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we even need to support non global contracts? maybe we should simply get rid of it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Near workspace does not support global contracts, so I have to add it as a feature for now - it is not used in tests to be compatible with near workspace (ci builds it also without this feature)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
poa-token/src/contract/mod.rs (1)

188-195: Avoid panic when ownership is renounced while no_registration is true

If ownership is renounced (owner_get() returns None) while no_registration is true, the current unwrap_or_else(|| unreachable!()) will panic instead of cleanly enforcing access control. Treating None as “only the contract itself may call” is safer and matches the intent.

Consider:

-        if self.no_registration {
-            require!(
-                *PREDECESSOR_ACCOUNT_ID == self.owner_get().unwrap_or_else(|| unreachable!())
-                    || *PREDECESSOR_ACCOUNT_ID == *CURRENT_ACCOUNT_ID,
-                "Method is private"
-            );
-        }
+        if self.no_registration {
+            require!(
+                self
+                    .owner_get()
+                    .map_or(false, |owner| *PREDECESSOR_ACCOUNT_ID == owner)
+                    || *PREDECESSOR_ACCOUNT_ID == *CURRENT_ACCOUNT_ID,
+                "Method is private"
+            );
+        }

This way, after ownership is renounced, only the contract itself can call storage_deposit when no_registration is enabled.

🧹 Nitpick comments (2)
poa-token/src/contract/mod.rs (2)

88-100: Migration flow from StateV0 to State looks standard; verify layout before running in prod

Reading the old state with env::state_read::<StateV0>(), converting into State, and explicitly setting no_registration is the usual NEAR upgrade pattern; just make sure StateV0’s Borsh layout matches the previous contract state and that migrate is only invoked once right after upgrading the code.


256-268: NoRegistration implementation is consistent; consider emitting an event on change

The getter correctly exposes the flag and the owner-gated, 1-yocto set_no_registration mutator updates the same field used in storage_deposit, so semantics are coherent; as an optional enhancement, you might emit a small config-change event from set_no_registration so indexers can track when registration is enabled/disabled.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3a3c5b and 4faeeb3.

📒 Files selected for processing (2)
  • poa-token/src/contract/mod.rs (8 hunks)
  • poa-token/src/contract/state.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • poa-token/src/contract/state.rs
🧰 Additional context used
🧬 Code graph analysis (1)
poa-token/src/contract/mod.rs (1)
poa-token/src/lib.rs (2)
  • no_registration (17-17)
  • set_no_registration (21-21)
🔇 Additional comments (4)
poa-token/src/contract/mod.rs (4)

2-4: Versioned state imports and module exposure look consistent

Bringing in the adapter/types and exposing the state module (NoRegistration, PoaFungibleToken, DEFAULT_NO_REGISTRATION, MaybeVersionedContractState, State, StateV0) matches the new versioned-state + no-registration design; nothing concerning here.

Also applies to: 19-24


35-42: Deref delegation to inner State plus custom serde is coherent

Forwarding Deref/DerefMut to self.state and annotating state: State with a custom (de)serializer cleanly centralizes persisted state while keeping the rest of the impls largely unchanged; this is a solid layout for future migrations.


49-53: Initializer now wires no_registration into persisted state cleanly

Extending new with no_registration: Option<bool> and defaulting via DEFAULT_NO_REGISTRATION when None makes the flag explicit in state without breaking callers; the State construction (token, metadata, no_registration) looks correct.

Also applies to: 66-70


118-125: No functional change in this hunk

This appears to be a whitespace-only tweak around the existing FtMint emission in ft_deposit; no behavioral differences to act on here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4faeeb3 and 1082d4e.

📒 Files selected for processing (1)
  • Makefile.toml (6 hunks)
🔇 Additional comments (1)
Makefile.toml (1)

78-93: Verify the manifest path for build-poa-token.

The AI summary states: "build-poa-token with manifest path ./poa-factory/Cargo.toml", but line 87 specifies ./poa-token/Cargo.toml. This discrepancy needs clarification—confirm whether the token should be built from the token crate or the factory crate.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/src/tests/defuse/intents/token_diff.rs (1)

262-266: Fix attribute order for consistency with other tests.

The attribute order here is #[tokio::test] followed by #[rstest], which is reversed compared to the other test functions in this file (lines 17-18, 85-86, 360-361). For consistency and to follow rstest best practices, #[rstest] should be the outermost attribute (first).

Additionally, since this test function has no parameters, the #[rstest] attribute is unnecessary and can be removed entirely.

Apply this diff to fix the attribute order:

-#[tokio::test]
-#[rstest]
+#[rstest]
+#[tokio::test]
 #[trace]
 async fn invariant_violated() {

Or alternatively, remove the unnecessary #[rstest] attribute:

 #[tokio::test]
-#[rstest]
 #[trace]
 async fn invariant_violated() {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1082d4e and cbcf62f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • Cargo.toml (1 hunks)
  • tests/src/tests/defuse/env/mod.rs (2 hunks)
  • tests/src/tests/defuse/env/storage.rs (1 hunks)
  • tests/src/tests/defuse/intents/ft_withdraw.rs (7 hunks)
  • tests/src/tests/defuse/intents/legacy_nonce.rs (1 hunks)
  • tests/src/tests/defuse/intents/mod.rs (3 hunks)
  • tests/src/tests/defuse/intents/public_key.rs (2 hunks)
  • tests/src/tests/defuse/intents/simulate.rs (6 hunks)
  • tests/src/tests/defuse/intents/token_diff.rs (4 hunks)
  • tests/src/tests/defuse/storage/mod.rs (2 hunks)
  • tests/src/tests/defuse/tokens/nep141/mod.rs (6 hunks)
  • tests/src/tests/defuse/tokens/nep245/mod.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • Cargo.toml
  • tests/src/tests/defuse/env/storage.rs
  • tests/src/tests/defuse/intents/mod.rs
  • tests/src/tests/defuse/intents/public_key.rs
  • tests/src/tests/defuse/intents/ft_withdraw.rs
  • tests/src/tests/defuse/tokens/nep245/mod.rs
  • tests/src/tests/defuse/storage/mod.rs
  • tests/src/tests/defuse/tokens/nep141/mod.rs
🧰 Additional context used
🧬 Code graph analysis (3)
tests/src/tests/defuse/intents/simulate.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/intents/legacy_nonce.rs (1)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
tests/src/tests/defuse/intents/token_diff.rs (2)
tests/src/tests/defuse/env/builder.rs (1)
  • fee (40-43)
tests/src/tests/defuse/env/mod.rs (1)
  • builder (58-60)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Security Audit - deny
  • GitHub Check: Build
  • GitHub Check: Build Reproducible
  • GitHub Check: Shared security analysis / Static Analysis (intents-poa-token, contract, near, poa-token, 1, ., 1.18, false, --filter-paths ...
  • GitHub Check: Shared security analysis / Static Analysis (intents-contract, contract, near, defuse, 1, ., 1.18, false, --filter-paths "nod...
  • GitHub Check: Shared security analysis / Static Analysis (intents-poa-factory, contract, near, poa-factory, 1, ., 1.18, false, --filter-pa...
  • GitHub Check: Shared / Static Analysis (intents-poa-token, contract, near, poa-token, 1, ., 1.18, false, --filter-paths ...
  • GitHub Check: Shared / Static Analysis (intents-contract, contract, near, defuse, 1, ., 1.18, false, --filter-paths "nod...
  • GitHub Check: Shared / Static Analysis (intents-poa-factory, contract, near, poa-factory, 1, ., 1.18, false, --filter-pa...
  • GitHub Check: Security Audit - report
🔇 Additional comments (6)
tests/src/tests/defuse/intents/token_diff.rs (1)

20-23: LGTM! Test parameterization and setup simplified correctly.

The function signature now uses rstest's #[values(...)] attribute to parameterize the fee, and the environment setup has been simplified by removing the no_registration branch. This aligns with the PR objectives to simplify test scaffolding.

tests/src/tests/defuse/intents/simulate.rs (2)

44-44: Unified Env initialization across simulate_ tests looks good*

Using Env::builder().build().await in these tests standardizes setup and removes the special-case no-registration plumbing without changing the test intent. No issues from this change.

Also applies to: 108-108, 176-176, 258-258, 489-489


568-568: Zero‑fee Env configuration for token‑diff simulation is preserved

Env::builder().fee(Pips::ZERO).build().await keeps the explicit zero‑fee configuration for simulate_token_diff_intent while aligning with the new Env builder API. The expected fees_collected: Amounts::default() assertions should still hold.

tests/src/tests/defuse/intents/legacy_nonce.rs (1)

18-18: Legacy nonce test now uses the standard Env builder path

Switching to Env::builder().build().await aligns this test with the rest of the suite and removes bespoke no‑registration wiring. Given Env::builder() is just EnvBuilder::default(), behavior now hinges on those defaults; as long as they match the previous expectations for legacy nonce handling, this looks correct.

tests/src/tests/defuse/env/mod.rs (2)

27-27: near_workspaces import narrowing is appropriate

Importing only Account and Contract matches this module’s usage and removes unused symbols; no functional change here.


107-110: create_named_token correctly forwards disable_registration into PoA factory

Routing self.disable_registration into poa_factory_deploy_token consolidates registration behavior at the factory level and replaces the old no‑registration deployment branch, in line with the PR’s goals. The .await.unwrap() pattern is consistent with the rest of the test harness. Please just confirm that EnvBuilder initializes disable_registration in a way that preserves prior defaults for tests that did or did not opt into no‑registration explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants