Skip to content

added single-source MAINNET_NETWORK_ID - #708

Merged
abayomicornelius merged 5 commits into
SO4-Markets:mainfrom
therealjhay:main
Sep 2, 2026
Merged

added single-source MAINNET_NETWORK_ID#708
abayomicornelius merged 5 commits into
SO4-Markets:mainfrom
therealjhay:main

Conversation

@therealjhay

Copy link
Copy Markdown
Contributor

Closes #567 libs/keys/src/lib.rs:13 — added single-source MAINNET_NETWORK_ID constant and is_mainnet / require_not_mainnet(env, error_code) helpers; contracts/test_token/src/lib.rs:1 and contracts/test_faucet/src/lib.rs:1 now import gmx_keys::MAINNET_NETWORK_ID and call gmx_keys::require_not_mainnet(&env, Error::MainnetNotAllowed as u32) instead of defining byte-identical copies. Cargo.toml:12 for both test contracts now depends on gmx-keys. Verification: grep MAINNET_NETWORK_ID in contracts shows no local definition, only the shared import.

Closes #576 contracts/adl_handler/src/lib.rs:37 — removed dead Error::MissingMaxPnlConfig =8 (ADL disabled is documented as return false when max_pnl_factor==0 in libs/market_utils/src/lib.rs:192); contracts/oracle/src/lib.rs:35 — removed dead Error::InvalidSignature =7 and documented that env.crypto().ed25519_verify panics host-level with no try_ helper in soroban-sdk 25.3.1 src/crypto.rs:45.

Closes #563 contracts/test_token/src/lib.rs:462 — ported market_token allowance-expiration coverage: allowance_reads_zero_after_expiration_ledger_passes, test_approve_and_transfer_from, transfer_from_after_expiration_reverts_with_allowance_expired, test_approve_and_burn_from, burn_from_after_expiration_reverts_with_allowance_expired, plus transfer_owner / non_owner_cannot_* / pause gate tests and 6 negative-amount rejection tests (transfer/approve/mint/burn/transfer_from/burn_from).

Closes #564 contracts/role_store/src/lib.rs:540 — added revoke-side bookkeeping tests: test_revoke_decrements_count_and_removes_member, test_revoke_one_of_many_leaves_others (removes middle entry to exercise vec_remove_addr), test_idempotent_revoke (double revoke no-op, count stays 0), and test_revoke_updates_account_roles_and_member_list_together.

)

Share MAINNET_NETWORK_ID and require_not_mainnet via gmx_keys to keep
a single source of truth for the test-only mainnet guard (issue SO4-Markets#400).
test_token and test_faucet now import the constant and call
gmx_keys::require_not_mainnet instead of defining byte-identical copies.
…ure (SO4-Markets#576)

adl_handler::MissingMaxPnlConfig was never raised — is_adl_required
returns false when max_pnl_factor == 0 (ADL disabled per
market_utils docs) instead of erroring, contradicting the variant's
own doc comment. Remove the dead variant and keep the silent-disable
behaviour as the documented one.

oracle::InvalidSignature was never raised — ed25519_verify is a host
function that panics with a generic host error on bad signature and
has no try_ helper in soroban-sdk 25 to map it to a contract error.
Remove the dead variant and document the host-level panic behaviour.
…ates (SO4-Markets#563)

Port market_token's allowance-expiration tests (allowance reads zero
after expiry, transfer_from/burn_from revert with AllowanceExpired,
approve_and_* flows) plus transfer_owner, pause/unpause owner-only
gates, and negative-amount rejections for transfer/approve/mint/burn.
Closes the coverage gap where test_token — used as collateral token
across many downstream handler tests — had only ~6 tests vs
market_token's 17.
…O4-Markets#564)

Grant-side bookkeeping was covered but revoke-side was not. Add
tests that grant 2-3 members, revoke one, and assert
get_role_member_count decremented by one and get_role_members no
longer contains the revoked account (including removing the middle
entry, not just tail). Add idempotent-revoke test mirroring
test_idempotent_grant, and a combined AccountRoles/RoleMembers
revoke consistency check.
@drips-wave

drips-wave Bot commented Sep 2, 2026

Copy link
Copy Markdown

@therealjhay Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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