Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement XCallManager #6

Open
CyrusVorwald opened this issue Aug 4, 2024 · 0 comments
Open

Implement XCallManager #6

CyrusVorwald opened this issue Aug 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@CyrusVorwald
Copy link
Contributor

Overview

The XCallManager contract manages cross-chain protocols, whitelists actions, and handles cross-chain calls.

(define-trait xcall-manager-trait
  (
    ;; Only callable once, sets up the initial state of the contract
    (initialize 
      (principal principal (string-ascii 64) principal 
       (list 100 (string-ascii 64)) (list 100 (string-ascii 64)))
      (response bool uint)
    )

    ;; Set a new admin address
    ;; Can only be called by the current admin
    ;; The new admin must accept the role separately
    (set-admin (principal) (response bool uint))

    ;; Accept the admin role
    ;; Must be called by the address set as the new admin
    (accept-admin-role () (response bool uint))

    ;; Update the list of approved source and destination protocols
    ;; Can only be called by the admin or through a whitelisted cross-chain message
    (set-protocols 
      ((list 100 (string-ascii 64)) (list 100 (string-ascii 64))) 
      (response bool uint)
    )

    ;; Propose the removal of a specific protocol
    ;; Can only be called by the admin
    ;; Allows for a grace period before removal takes effect
    (propose-removal ((string-ascii 64)) (response bool uint))

    ;; Add an action to the whitelist
    ;; Can only be called by the admin
    ;; Whitelisted actions are allowed to be executed when received as cross-chain messages
    (whitelist-action ((buff 1024)) (response bool uint))

    ;; Remove an action from the whitelist
    ;; Can only be called by the admin
    ;; Prevents a previously approved action from being executed
    (remove-action ((buff 1024)) (response bool uint))

    ;; Process an incoming cross-chain message
    ;; Can only be called by the xCall service
    ;; Verifies the message source, protocols, and executes whitelisted actions
    (handle-call-message 
      ((string-ascii 64) (buff 1024) (list 100 (string-ascii 64)))
      (response bool uint)
    )

    ;; Retrieve the current list of approved protocols
    ;; Read-only function, can be called by anyone
    (get-protocols () 
      (response 
        (tuple 
          (sources (list 100 (string-ascii 64))) 
          (destinations (list 100 (string-ascii 64)))
        ) 
        uint
      )
    )

    ;; Check if a given list of protocols matches the approved list
    ;; Read-only function, used to validate protocol usage
    (verify-protocols ((list 100 (string-ascii 64))) (response bool uint))

    ;; Check if a specific action is currently whitelisted
    ;; Read-only function, can be used to verify action status before sending cross-chain
    (is-action-whitelisted ((buff 1024)) (response bool uint))

    ;; Get the current admin address
    ;; Read-only function, provides transparency on who controls admin functions
    (get-admin () (response principal uint))

    ;; Get the address of the xCall service contract
    ;; Read-only function, allows verification of the authorized caller for handle-call-message
    (get-x-call () (response principal uint))
  )
)
@CyrusVorwald CyrusVorwald added the enhancement New feature or request label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant