.derupt-ext-reg

Derupt developers can deploy extension, the .derupt-ext-reg is used to announce new extensions.

General:

  • A distinct .derupt-ext contract should be deployed by developer(s).

  • .derupt-ext contract(s) are used integrate 3rd party Stacks Smart contracts into the Derupt user experience during Derupt Core Operations.

  • register-ext function must be called by the extension contract deployer.

Dev Warning:

  • deploy a single .derupt-ext contract to integrate w/ a single 3rd party contract function.

  • users use your .derupt-ext contract as an ext argument in Derupt core operation calls.

  • all extension arguments are passed as extras during core operation function calls. (* extension can use internal variables that do not require being passed if so desired)

  • to pass user input as extras during ExtensionModal presentation, simply define the applicable argsFromUser via your extension metadata.json description

Work in Progress

;; title: derupt-ext-reg
;; version: 1.3.1
;; summary: Extension Registry Contract
;; description: used to log extension registration

(use-trait derupt-ext-trait 'ST1ZK4MRVTQQJMVAAJQWBV2WPQ87QV2851YCTHD7X.derupt-ext-trait.derupt-ext)
;; (use-trait derupt-ext-trait 'MAINNETADDRESS.derupt-ext-trait.derupt-ext)

;; Error Constants
(define-constant ERR-UNAUTHORIZED (err u100))
(define-constant ERR-INVALID-PRINCIPAL (err u101))

(define-public (register-ext (ext-contract <derupt-ext-trait>))
    (let (
        (principal-data (unwrap! (principal-destruct? (contract-of ext-contract)) ERR-INVALID-PRINCIPAL))
        (version (get version principal-data))
        (hash-bytes (get hash-bytes principal-data))
        (ext-deployer (unwrap! (principal-construct? version hash-bytes) ERR-INVALID-PRINCIPAL))
    )
        (asserts! (is-eq tx-sender ext-deployer) ERR-UNAUTHORIZED)
        (print {ext-contract: (contract-of ext-contract)})
        (ok true)
    )
)

Last updated