adapters

package
v0.0.0-...-6fc5cde Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurseAdapter

type CurseAdapter struct {
	// contains filtered or unexported fields
}

CurseAdapter implements fastcurse.CurseAdapter and fastcurse.CurseSubjectAdapter for Sui.

Per-chain state is cached in a selector-keyed map so that initializing a second Sui selector on the shared adapter instance (the fastcurse registry stores one adapter per family+version) does not clobber the first — mirroring the EVM adapter's rmnAddressCache/routerAddressCache maps. Initialize is additive and idempotent; all stateful reads resolve state by selector.

Curse() routes through FastCurseCurseSequence and requires a registered CurserCap. Uncurse uses CCIP OwnerCap via UncurseSequence for slow MCMS proposals.

func NewCurseAdapter

func NewCurseAdapter() *CurseAdapter

NewCurseAdapter returns a new, uninitialized CurseAdapter.

func (*CurseAdapter) ChainState

func (c *CurseAdapter) ChainState(selector uint64) (SuiChainState, bool)

ChainState returns the cached state for selector and whether it was found.

func (*CurseAdapter) Curse

Curse returns a sequence that curses the given subjects via CurserCap on the fast MCMS path.

The adapter is only invoked by the generic fastcurse framework (fastcurse.CurseChangeset / fastcurse.GloballyCurseChainChangeset), which always builds an MCMS proposal via OutputBuilder.Build(cfg.MCMS). We therefore force ProposalOnly: true so the underlying operation never attempts direct execution — the CurserCap lives inside the fast MCMS Registry (registered via mint_and_register_curser_cap) and has no top-level owner, so direct PTB assembly against its object ID would fail with "Object not found".

State is resolved by in.ChainSelector at execution time (not captured at sequence-build time), so the shared adapter instance remains safe when multiple Sui selectors are cursed in one run.

func (*CurseAdapter) DeriveCurseAdapterVersion

func (c *CurseAdapter) DeriveCurseAdapterVersion(cldf.Environment, uint64) (*semver.Version, error)

DeriveCurseAdapterVersion returns the RMN adapter version for this Sui deployment.

func (*CurseAdapter) Initialize

func (c *CurseAdapter) Initialize(e cldf.Environment, selector uint64) error

Initialize populates the adapter's per-selector state from the on-chain state for the given selector. Chain metadata is resolved via LoadOnchainStatesui, which prefers datastore address refs (address_refs.json) and falls back to the legacy address book (addresses.json).

Initialize is additive and idempotent: a selector already cached is left untouched (a second init for a different selector does not clobber the first). This mirrors the EVM adapter and makes the shared adapter instance safe for any selector cardinality.

func (*CurseAdapter) IsChainConnectedToTargetChain

func (c *CurseAdapter) IsChainConnectedToTargetChain(e cldf.Environment, selector uint64, targetSelector uint64) (bool, error)

IsChainConnectedToTargetChain returns true if targetSelector is a configured destination on the Sui router for the chain identified by selector.

func (*CurseAdapter) IsCurseEnabledForChain

func (c *CurseAdapter) IsCurseEnabledForChain(cldf.Environment, uint64) (bool, error)

IsCurseEnabledForChain always returns true for Sui — cursing is always available.

func (*CurseAdapter) IsSubjectCursedOnChain

func (c *CurseAdapter) IsSubjectCursedOnChain(e cldf.Environment, selector uint64, subject fastcurse.Subject) (bool, error)

IsSubjectCursedOnChain returns true when subject is explicitly present in the on-chain cursed-subjects set. A global curse does not cause lane subjects to appear cursed here; call with GlobalCurseSubject() to test global curse state.

func (*CurseAdapter) ListConnectedChains

func (c *CurseAdapter) ListConnectedChains(e cldf.Environment, selector uint64) ([]uint64, error)

ListConnectedChains returns all destination chain selectors configured in the Sui router.

func (*CurseAdapter) SelectorToSubject

func (c *CurseAdapter) SelectorToSubject(selector uint64) fastcurse.Subject

SelectorToSubject converts a chain selector to a fastcurse.Subject using BigEndian encoding. Sui uses the same encoding as the generic (EVM-default) case.

func (*CurseAdapter) SetChainState

func (c *CurseAdapter) SetChainState(selector uint64, state SuiChainState)

SetChainState stores per-selector state directly, bypassing Initialize. It is intended for tests and integration suites that construct state without a real Environment.

func (*CurseAdapter) SubjectToSelector

func (c *CurseAdapter) SubjectToSelector(subject fastcurse.Subject) (uint64, error)

SubjectToSelector converts a fastcurse.Subject to a chain selector using BigEndian encoding.

func (*CurseAdapter) Uncurse

Uncurse returns a sequence that lifts the curse on given subjects on the specified Sui chain. Uncurse always uses OwnerCap via slow MCMS; fast MCMS cannot uncurse.

Like Curse, this adapter is only invoked by the generic fastcurse framework in MCMS-proposal mode, so we set ProposalOnly: true. In production the OwnerCap is owned by the slow MCMS timelock — the loaded Sui deployer signer cannot authorize direct execution anyway, so the only useful output here is an MCMS proposal leaf.

State is resolved by in.ChainSelector at execution time (not captured at sequence-build time), so the shared adapter instance remains safe when multiple Sui selectors are cursed in one run.

type MCMSReader

type MCMSReader struct{}

func (*MCMSReader) GetChainMetadata

func (r *MCMSReader) GetChainMetadata(e cldf.Environment, chainSelector uint64, input mcms_utils.Input) (mcmstypes.ChainMetadata, error)

func (*MCMSReader) GetMCMSRef

func (r *MCMSReader) GetMCMSRef(e cldf.Environment, chainSelector uint64, input mcms_utils.Input) (datastore.AddressRef, error)

func (*MCMSReader) GetTimelockRef

func (r *MCMSReader) GetTimelockRef(e cldf.Environment, chainSelector uint64, input mcms_utils.Input) (datastore.AddressRef, error)

type SuiChainState

type SuiChainState struct {
	CCIPAddress          string
	LatestCCIPPackageID  string
	CCIPObjectRef        string
	CCIPOwnerCapObjectID string
	CurserCapObjectID    string
	RouterAddress        string
	RouterStateObjectID  string
}

SuiChainState holds the per-chain on-chain state a CurseAdapter needs to curse/uncurse and verify curses for a single Sui chain selector. It is the selector-scoped counterpart of the flat fields the adapter previously held; exporting it lets tests and integration suites populate state directly via SetChainState without a real Environment.

type SuiFeeAdapter

type SuiFeeAdapter struct{}

SuiFeeAdapter implements fees.FeeAdapter for Sui CCIP 1.6.0.

On Sui the FeeQuoter is a module within the CCIP package (not a separate contract), so the FeeQuoter "address" is the CCIP package id, its state lives in the shared CCIPObjectRef, and it is authorized by the CCIPOwnerCap. Token transfer fee configs are keyed on-chain by the coin metadata object address. GetFeeContractRef returns the CCIP package ref versioned at 1.6.0 (the adapter version; Sui contract refs are stored at 1.0.0) and stashes the CCIPObjectRef / CCIPOwnerCap / latest package id as labels so the FQ ops and DevInspect reads have everything they need.

ApplyDestChainConfigUpdates and GetOnchainDestChainConfig return nil or an error until wired.

func (*SuiFeeAdapter) GetDefaultDestChainConfig

func (a *SuiFeeAdapter) GetDefaultDestChainConfig(_, _ uint64) lanes.FeeQuoterDestChainConfig

GetDefaultDestChainConfig returns the Sui FeeQuoter destination chain config defaults. It delegates to the Sui lane adapter so the defaults have a single source of truth.

func (*SuiFeeAdapter) GetDefaultTokenTransferFeeConfig

func (a *SuiFeeAdapter) GetDefaultTokenTransferFeeConfig(src uint64, dst uint64) fees.TokenTransferFeeArgs

GetDefaultTokenTransferFeeConfig returns the chain-agnostic default token transfer fee configuration, matching the EVM and Solana fee adapters.

func (*SuiFeeAdapter) GetFeeContractRef

GetFeeContractRef returns the FeeQuoter address ref for the source chain. On Sui the FeeQuoter is the CCIP package, so this resolves the CCIP package ref from the datastore (not via an OnRamp dynamic-config read like EVM/Solana), enriches it with the CCIPObjectRef, CCIPOwnerCap, and optional latest CCIP package id as labels, and versions it at 1.6.0 so the generic fee flow selects this adapter. The onRamp ref is validated for presence.

func (*SuiFeeAdapter) GetOnchainTokenTransferFeeConfig

func (a *SuiFeeAdapter) GetOnchainTokenTransferFeeConfig(b cldf_ops.Bundle, chains cldf_chain.BlockChains, feeRef datastore.AddressRef, src uint64, dst uint64, token string) (fees.TokenTransferFeeArgs, error)

GetOnchainTokenTransferFeeConfig reads a token's transfer fee config from the Sui FeeQuoter via DevInspect. The token arg is the coin metadata object address. Returns a zero config (matching the Move behavior) when no custom config is set on-chain.

func (*SuiFeeAdapter) SetTokenTransferFee

SetTokenTransferFee sets token transfer fee config on the Sui FeeQuoter as an MCMS proposal. Per destination chain it maps the generic Settings into add/remove token updates and invokes FeeQuoterApplyTokenTransferFeeConfigUpdates in proposal mode, bridging the encoded call into OnChainOutput.BatchOps. Token keys are coin metadata object addresses.

type SuiFeeResolver

type SuiFeeResolver struct{}

SuiFeeResolver implements fees.FeeResolver for Sui. The OnRamp is a separate Move package whose ref is resolved from the datastore. The generic fee flow selects the FeeAdapter by onRampRef.Version, and Sui contract refs are stored at 1.0.0 while the SuiFeeAdapter is registered at 1.6.0, so the returned ref is versioned at 1.6.0. Chain-family routing is handled upstream by the generic flow, so no chain sanity check is needed here.

func (*SuiFeeResolver) GetOnRampRef

GetOnRampRef returns the OnRamp address ref for the source chain, versioned at 1.6.0.

type SuiTokenAdapter

type SuiTokenAdapter struct{}

SuiTokenAdapter implements tokensapi.TokenAdapter and tokensapi.TokenRefResolver for Sui CCIP token pools.

Addressing model: on Sui a token is identified by its coin type string (0x<package>::<module>::<STRUCT>) and a token pool by its Move package ID (a hex object id). The generic TokenAdapter abstraction is address-string based, so this adapter maps:

  • token AddressRef.Address -> coin type string
  • pool AddressRef.Address -> pool package id; Qualifier -> token identity

Sui pool state and owner-cap objects are resolved by their explicit token qualifier. Labels are retained as display metadata only.

Sequence methods run in MCMS proposal mode: the Sui ops are invoked with Signer=nil so they return a TransactionCall, which is bridged into OnChainOutput.BatchOps for the generic changesets to assemble MCMS proposals. Methods that publish packages or execute reads are the exception.

func (*SuiTokenAdapter) AddressRefToBytes

func (a *SuiTokenAdapter) AddressRefToBytes(ref datastore.AddressRef) ([]byte, error)

AddressRefToBytes serializes a Sui AddressRef to bytes. Pool package ids and object ids are hex; coin type strings contain "::" and are returned as their raw UTF-8 bytes so the coin type round-trips through DeriveTokenDecimals.

func (*SuiTokenAdapter) ConfigureTokenForTransfersSequence

ConfigureTokenForTransfersSequence configures a Sui token pool for cross-chain transfers as an MCMS proposal. Per remote chain it applies the chain config (remote token + remote pool) and the default-lane rate limits, mirroring the Sui ConfigureBurnMintTokenPool flow. Sui has no router SetPool and the existing Sui configure flow does not register the pool in the TokenAdminRegistry, so this sequence only sets per-remote chain config + rate limits.

func (*SuiTokenAdapter) DeployToken

DeployToken is not supported for Sui through the generic token adapter. Sui token deployment publishes a fixed-kind Move package (managed token or BnM token) whose deploy op takes only MCMS config, not the symbol/decimals/supply/pre-mint/senders that the generic DeployTokenInput carries; the token identity is determined by the published package, so the generic input does not map cleanly. Sui tokens are deployed via the Sui-specific token deploy changesets instead. This returns a sequence that errors so a misconfigured Sui chain fails with a clear message rather than nil-panicking the generic flow (which calls it unguarded).

func (*SuiTokenAdapter) DeployTokenPoolForToken

DeployTokenPoolForToken deploys and initializes a Sui token pool for an existing token. It publishes a Move package, initializes the pool, and transfers pool ownership to MCMS (ownership step 1), so it executes directly with the chain signer (not as an MCMS proposal) and returns the deployed pool's AddressRefs.

PoolType accepts the Sui short form ("bnm"/"managed"/"lnr"), the Sui contract-type string ("SuiBnMTokenPool"/"SuiManagedTokenPool"/"SuiLnRTokenPool"), or the generic cross-family contract-type strings used by EVM/Solana ("BurnMintTokenPool"/"LockReleaseTokenPool"). The generic names let a single token_expansion YAML use one poolType across families. The token's coin type comes from TokenRef.Address, the qualifier is taken explicitly from TokenRef.Qualifier, and the display symbol is taken from its labels. CCIP/MCMS state is resolved from the datastore. The display symbol is used only for labels on the newly returned refs. For managed pools, the minter-cap ref held by the chain signer is used.

After initialize this calls transfer_ownership(To: MCMS) EOA-direct, setting a pending transfer that UpdateAuthorities' accept_ownership MCMS proposal (step 2) then accepts. The final execute_ownership_transfer_to_mcms (step 3) is EOA-direct and handled by the Sui cs_mcms_execute_ownership_transfer changeset after the accept proposal lands.

func (*SuiTokenAdapter) DeployTokenVerify

DeployTokenVerify validates a Sui token deployment input. Sui has no fixed decimal cap equivalent to EVM's 18 and the deployment is verified on-chain by the publish transaction, so this is a no-op for now, mirroring the Solana adapter.

func (*SuiTokenAdapter) DeriveTokenAddress

func (a *SuiTokenAdapter) DeriveTokenAddress(e deployment.Environment, chainSelector uint64, poolRef datastore.AddressRef) (string, error)

DeriveTokenAddress derives the Sui coin type from the explicitly qualified coin package ref. It is a fallback used when the caller does not provide a token ref; the primary path threads the coin type through the token ref. The package's module::STRUCT suffix is stored separately as a coinType= label.

func (*SuiTokenAdapter) DeriveTokenDecimals

func (a *SuiTokenAdapter) DeriveTokenDecimals(e deployment.Environment, chainSelector uint64, _ datastore.AddressRef, token []byte) (uint8, error)

DeriveTokenDecimals reads the token decimals from on-chain coin metadata. The token bytes carry the Sui coin type string (see AddressRefToBytes).

func (*SuiTokenAdapter) DeriveTokenPoolCounterpart

func (a *SuiTokenAdapter) DeriveTokenPoolCounterpart(_ deployment.Environment, _ uint64, tokenPool []byte, _ []byte) ([]byte, error)

DeriveTokenPoolCounterpart returns the token pool bytes unchanged. Sui token pools are objects addressed directly; there is no PDA-style derivation from the token like Solana.

func (*SuiTokenAdapter) ManualRegistration

ManualRegistration is a no-op on Sui. Unlike EVM/Solana, a Sui token pool self-registers in the TokenAdminRegistry during pool initialization: the Move `initialize` (burn-mint) and `initialize_with_managed_token` (managed) functions call `token_admin_registry::register_pool` themselves. DeployTokenPoolForToken triggers that init, so by the time a pool exists it is already registered. Calling register_pool again would abort with ETokenAlreadyRegistered, so this sequence logs and returns an empty output rather than re-registering. A nil return would crash the generic ManualRegistration changeset, so a no-op sequence is returned instead.

func (*SuiTokenAdapter) MigrateLockReleasePoolLiquiditySequence

MigrateLockReleasePoolLiquiditySequence is not supported on Sui. The lockbox-based v2.0 liquidity migration is an EVM-only flow; nil signals no support.

func (*SuiTokenAdapter) ResolveTokenPoolRef

func (a *SuiTokenAdapter) ResolveTokenPoolRef(_ cldf_ops.Bundle, _ cldf_chain.BlockChains, ds datastore.DataStore, chainSelector uint64, address string) (datastore.AddressRef, error)

ResolveTokenPoolRef resolves a Sui pool package id to its datastore AddressRef. The package id is looked up in the datastore to recover the pool contract type and token identity. The returned ref carries the token's semantic qualifier so downstream adapter methods can resolve the pool's state and owner-cap objects without using the pool address as a key.

func (*SuiTokenAdapter) ResolveTokenRef

func (a *SuiTokenAdapter) ResolveTokenRef(b cldf_ops.Bundle, chains cldf_chain.BlockChains, ds datastore.DataStore, chainSelector uint64, address string) (datastore.AddressRef, error)

ResolveTokenRef resolves a Sui token reference to an AddressRef. The address may be either a bare package id or the full coin type string 0x<package>::<module>::<STRUCT>. A bare id is resolved against the datastore, deriving the full coin type from the matching coin ref's coinType= label and preserving that ref's explicit qualifier, so no on-chain call is needed. A full coin type is used verbatim, with the qualifier obtained from on-chain coin metadata. The returned Address always holds the full coin type (the canonical token identifier), and the Qualifier is the normalized token symbol (TokenQualifier) used to key token-scoped rows in the datastore. A token ref without a qualifier cannot be safely keyed, so it is returned as an error rather than silently producing a singleton-qualified token ref.

func (*SuiTokenAdapter) SetTokenPoolRateLimits

SetTokenPoolRateLimits sets the default-lane rate limits on a Sui token pool as an MCMS proposal. Sui pools have a single bucket per remote lane, so fastFinality buckets are not supported and only the default bucket is applied. A missing default bucket means no rate-limit update for this lane and the sequence no-ops.

func (*SuiTokenAdapter) UpdateAuthorities

UpdateAuthorities returns ownership step 2 of 3 as an MCMS proposal: the MCMS timelock calls accept_ownership on the pool, which asserts ctx.sender() == pending_transfer.to == MCMS.

The full Sui pool→MCMS ownership flow is EOA/MCMS/EOA:

  1. EOA transfer_ownership(To: MCMS) — performed by DeployTokenPoolForToken at deploy time, setting a pending (not-yet-accepted) transfer.
  2. MCMS accept_ownership — this method, returned as an MCMS proposal (Signer=nil → Call).
  3. EOA execute_ownership_transfer_to_mcms — consumes the OwnerCap and registers the MCMS entrypoint; run EOA-direct via the Sui cs_mcms_execute_ownership_transfer changeset after this accept proposal lands. ownable::execute_ownership_transfer_to_mcms asserts pending_transfer.is_some() (ENoPendingTransfer) and pending_transfer.accepted (ETransferNotAccepted), so it cannot run before steps 1-2.

OnChainOutput.BatchOps can only carry MCMS proposals, so only step 2 belongs here.

type SuiTokenAdminRegistryReader

type SuiTokenAdminRegistryReader struct{}

SuiTokenAdminRegistryReader reads the Sui TokenAdminRegistry for the generic token changesets. The Sui TAR is a shared object accessed through the CCIP package and the CCIP object ref, and is keyed by coin metadata object id. Sui pools self-register in the TAR during pool initialization, so a registered token maps to its deployed pool package id.

func (*SuiTokenAdminRegistryReader) GetActivePool

func (r *SuiTokenAdminRegistryReader) GetActivePool(
	e deployment.Environment, chainSelector uint64, tokenRef datastore.AddressRef, _ ...datastore.AddressRef,
) ([]byte, error)

GetActivePool returns the pool package id registered for tokenRef in the Sui TokenAdminRegistry, as raw bytes. Returns empty bytes with no error when no pool is registered for the token.

func (*SuiTokenAdminRegistryReader) GetTokenAdminRegistryRef

func (r *SuiTokenAdminRegistryReader) GetTokenAdminRegistryRef(
	e deployment.Environment, chainSelector uint64,
) (datastore.AddressRef, error)

GetTokenAdminRegistryRef returns the Sui CCIP object ref, which is the shared object the token_admin_registry module functions are invoked with.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL