diff --git a/Clarinet.toml b/Clarinet.toml index 1a88fc9..f8d176e 100644 --- a/Clarinet.toml +++ b/Clarinet.toml @@ -5,47 +5,48 @@ authors = [] telemetry = false cache_dir = './.cache' -[[project.requirements]] -contract_id = 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2' - -[[project.requirements]] -contract_id = 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-ecc-v1' +[contracts.hk-cursor] +path = 'contracts/requirements/hk-cursor.clar' +clarity_version = 2 +epoch = 2.4 -[[project.requirements]] -contract_id = 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-merkle-tree-keccak160-v1' +[contracts.hk-merkle-tree-keccak160] +path = 'contracts/requirements/hk-merkle-tree-keccak160.clar' +clarity_version = 2 +epoch = 2.4 -[contracts.pyth-governance-v1] -path = 'contracts/pyth-governance-v1.clar' +[contracts.pyth-governance] +path = 'contracts/pyth-governance.clar' clarity_version = 2 epoch = 2.4 -[contracts.pyth-oracle-v2] -path = 'contracts/pyth-oracle-v2.clar' +[contracts.pyth-oracle] +path = 'contracts/pyth-oracle.clar' clarity_version = 2 epoch = 2.4 -[contracts.pyth-store-v1] -path = 'contracts/pyth-store-v1.clar' +[contracts.pyth-store] +path = 'contracts/pyth-store.clar' clarity_version = 2 epoch = 2.4 -[contracts.pyth-pnau-decoder-v1] -path = 'contracts/pyth-pnau-decoder-v1.clar' +[contracts.pyth-pnau-decoder] +path = 'contracts/pyth-pnau-decoder.clar' clarity_version = 2 epoch = 2.4 -[contracts.pyth-traits-v1] -path = 'contracts/pyth-traits-v1.clar' +[contracts.pyth-traits] +path = 'contracts/pyth-traits.clar' clarity_version = 2 epoch = 2.4 -[contracts.wormhole-core-v2] -path = 'contracts/wormhole/wormhole-core-v2.clar' +[contracts.wormhole-core] +path = 'contracts/wormhole/wormhole-core.clar' clarity_version = 2 epoch = 2.4 -[contracts.wormhole-traits-v1] -path = 'contracts/wormhole/wormhole-traits-v1.clar' +[contracts.wormhole-traits] +path = 'contracts/wormhole/wormhole-traits.clar' clarity_version = 2 epoch = 2.4 diff --git a/contracts/pyth-governance-v1.clar b/contracts/pyth-governance.clar similarity index 85% rename from contracts/pyth-governance-v1.clar rename to contracts/pyth-governance.clar index fbac19c..7a0c06c 100644 --- a/contracts/pyth-governance-v1.clar +++ b/contracts/pyth-governance.clar @@ -3,10 +3,10 @@ ;; Check for latest version: https://github.com/hirosystems/stacks-pyth-bridge#latest-version ;; Report an issue: https://github.com/hirosystems/stacks-pyth-bridge/issues -(use-trait pyth-proxy-trait .pyth-traits-v1.proxy-trait) -(use-trait pyth-decoder-trait .pyth-traits-v1.decoder-trait) -(use-trait pyth-storage-trait .pyth-traits-v1.storage-trait) -(use-trait wormhole-core-trait .wormhole-traits-v1.core-trait) +(use-trait pyth-proxy-trait .pyth-traits.proxy-trait) +(use-trait pyth-decoder-trait .pyth-traits.decoder-trait) +(use-trait pyth-storage-trait .pyth-traits.storage-trait) +(use-trait wormhole-core-trait .wormhole-traits.core-trait) (define-constant PTGM_MAGIC 0x5054474d) ;; 'PTGM': Pyth Governance Message @@ -72,10 +72,10 @@ pyth-storage-contract: principal, wormhole-core-contract: principal } { - pyth-oracle-contract: .pyth-oracle-v2, - pyth-decoder-contract: .pyth-pnau-decoder-v1, - pyth-storage-contract: .pyth-store-v1, - wormhole-core-contract: .wormhole-core-v2 + pyth-oracle-contract: .pyth-oracle, + pyth-decoder-contract: .pyth-pnau-decoder, + pyth-storage-contract: .pyth-store, + wormhole-core-contract: .wormhole-core }) (define-read-only (check-execution-flow @@ -349,15 +349,15 @@ (ok true))) (define-private (parse-and-verify-ptgm (ptgm-bytes (buff 8192)) (sequence uint)) - (let ((cursor-magic (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-4 { bytes: ptgm-bytes, pos: u0 }) + (let ((cursor-magic (unwrap! (contract-call? .hk-cursor read-buff-4 { bytes: ptgm-bytes, pos: u0 }) ERR_INVALID_PTGM)) - (cursor-module (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-1 (get next cursor-magic)) + (cursor-module (unwrap! (contract-call? .hk-cursor read-buff-1 (get next cursor-magic)) ERR_INVALID_PTGM)) - (cursor-action (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-1 (get next cursor-module)) + (cursor-action (unwrap! (contract-call? .hk-cursor read-buff-1 (get next cursor-module)) ERR_INVALID_PTGM)) - (cursor-target-chain-id (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-2 (get next cursor-action)) + (cursor-target-chain-id (unwrap! (contract-call? .hk-cursor read-buff-2 (get next cursor-action)) ERR_INVALID_PTGM)) - (cursor-body (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-8192-max (get next cursor-target-chain-id) none) + (cursor-body (unwrap! (contract-call? .hk-cursor read-buff-8192-max (get next cursor-target-chain-id) none) ERR_INVALID_PTGM))) ;; Check magic bytes (asserts! (is-eq (get value cursor-magic) PTGM_MAGIC) ERR_INVALID_PTGM) @@ -378,10 +378,10 @@ }))) (define-private (parse-and-verify-fee-value (ptgm-body (buff 8192))) - (let ((cursor-ptgm-body (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new ptgm-body none)) - (cursor-mantissa (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-ptgm-body)) + (let ((cursor-ptgm-body (contract-call? .hk-cursor new ptgm-body none)) + (cursor-mantissa (unwrap! (contract-call? .hk-cursor read-uint-64 (get next cursor-ptgm-body)) ERR_INVALID_ACTION_PAYLOAD)) - (cursor-exponent (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-mantissa)) + (cursor-exponent (unwrap! (contract-call? .hk-cursor read-uint-64 (get next cursor-mantissa)) ERR_INVALID_ACTION_PAYLOAD))) (ok { mantissa: (get value cursor-mantissa), @@ -389,16 +389,16 @@ }))) (define-private (parse-and-verify-stale-price-threshold (ptgm-body (buff 8192))) - (let ((cursor-ptgm-body (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new ptgm-body none)) - (cursor-stale-price-threshold (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-ptgm-body)) + (let ((cursor-ptgm-body (contract-call? .hk-cursor new ptgm-body none)) + (cursor-stale-price-threshold (unwrap! (contract-call? .hk-cursor read-uint-64 (get next cursor-ptgm-body)) ERR_INVALID_ACTION_PAYLOAD))) (ok (get value cursor-stale-price-threshold)))) (define-private (parse-and-verify-governance-data-source (ptgm-body (buff 8192))) - (let ((cursor-ptgm-body (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new ptgm-body none)) - (cursor-emitter-chain (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-16 (get next cursor-ptgm-body)) + (let ((cursor-ptgm-body (contract-call? .hk-cursor new ptgm-body none)) + (cursor-emitter-chain (unwrap! (contract-call? .hk-cursor read-uint-16 (get next cursor-ptgm-body)) ERR_INVALID_ACTION_PAYLOAD)) - (cursor-emitter-address (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-32 (get next cursor-emitter-chain)) + (cursor-emitter-address (unwrap! (contract-call? .hk-cursor read-buff-32 (get next cursor-emitter-chain)) ERR_INVALID_ACTION_PAYLOAD))) (ok { emitter-chain: (get value cursor-emitter-chain), @@ -406,16 +406,16 @@ }))) (define-private (parse-principal (ptgm-body (buff 8192))) - (let ((cursor-ptgm-body (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new ptgm-body none)) - (cursor-principal-len (try! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-ptgm-body)))) - (principal-bytes (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 slice (get next cursor-principal-len) (some (get value cursor-principal-len)))) + (let ((cursor-ptgm-body (contract-call? .hk-cursor new ptgm-body none)) + (cursor-principal-len (try! (contract-call? .hk-cursor read-uint-8 (get next cursor-ptgm-body)))) + (principal-bytes (contract-call? .hk-cursor slice (get next cursor-principal-len) (some (get value cursor-principal-len)))) (new-principal (unwrap! (from-consensus-buff? principal principal-bytes) ERR_UNEXPECTED_ACTION_PAYLOAD))) (ok new-principal))) (define-private (parse-and-verify-prices-data-sources (ptgm-body (buff 8192))) - (let ((cursor-ptgm-body (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new ptgm-body none)) - (cursor-num-data-sources (try! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-ptgm-body)))) - (cursor-data-sources-bytes (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 slice (get next cursor-num-data-sources) none)) + (let ((cursor-ptgm-body (contract-call? .hk-cursor new ptgm-body none)) + (cursor-num-data-sources (try! (contract-call? .hk-cursor read-uint-8 (get next cursor-ptgm-body)))) + (cursor-data-sources-bytes (contract-call? .hk-cursor slice (get next cursor-num-data-sources) none)) (data-sources (get result (fold parse-data-source cursor-data-sources-bytes { result: (list), cursor: { @@ -442,9 +442,9 @@ acc (if (is-eq (get index (get cursor acc)) (get next-update-index (get cursor acc))) ;; Parse update - (let ((buffer (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new (get bytes acc) (some (get index (get cursor acc))))) - (cursor-emitter-chain (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-16 (get next buffer)))) - (cursor-emitter-address (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-32 (get next cursor-emitter-chain))))) + (let ((buffer (contract-call? .hk-cursor new (get bytes acc) (some (get index (get cursor acc))))) + (cursor-emitter-chain (unwrap-panic (contract-call? .hk-cursor read-uint-16 (get next buffer)))) + (cursor-emitter-address (unwrap-panic (contract-call? .hk-cursor read-buff-32 (get next cursor-emitter-chain))))) ;; Perform assertions { cursor: { diff --git a/contracts/pyth-oracle-v2.clar b/contracts/pyth-oracle.clar similarity index 80% rename from contracts/pyth-oracle-v2.clar rename to contracts/pyth-oracle.clar index 06691c9..843d738 100644 --- a/contracts/pyth-oracle-v2.clar +++ b/contracts/pyth-oracle.clar @@ -3,9 +3,9 @@ ;; Check for latest version: https://github.com/hirosystems/stacks-pyth-bridge#latest-version ;; Report an issue: https://github.com/hirosystems/stacks-pyth-bridge/issues -(use-trait pyth-storage-trait .pyth-traits-v1.storage-trait) -(use-trait pyth-decoder-trait .pyth-traits-v1.decoder-trait) -(use-trait wormhole-core-trait .wormhole-traits-v1.core-trait) +(use-trait pyth-storage-trait .pyth-traits.storage-trait) +(use-trait pyth-decoder-trait .pyth-traits.decoder-trait) +(use-trait wormhole-core-trait .wormhole-traits.core-trait) ;; Generic error (define-constant ERR_PANIC (err u0)) @@ -17,7 +17,7 @@ (pyth-storage-address )) (begin ;; Check execution flow - (try! (contract-call? .pyth-governance-v1 check-storage-contract pyth-storage-address)) + (try! (contract-call? .pyth-governance check-storage-contract pyth-storage-address)) ;; Perform contract-call (contract-call? pyth-storage-address read price-feed-id))) @@ -30,14 +30,14 @@ })) (begin ;; Check execution flow - (try! (contract-call? .pyth-governance-v1 check-execution-flow contract-caller (some execution-plan))) + (try! (contract-call? .pyth-governance check-execution-flow contract-caller (some execution-plan))) ;; Perform contract-call (let ((pyth-decoder-contract (get pyth-decoder-contract execution-plan)) (wormhole-core-contract (get wormhole-core-contract execution-plan)) (pyth-storage-contract (get pyth-storage-contract execution-plan)) (decoded-prices (try! (contract-call? pyth-decoder-contract decode-and-verify-price-feeds price-feed-bytes wormhole-core-contract))) (updated-prices (try! (contract-call? pyth-storage-contract write decoded-prices))) - (fee-info (contract-call? .pyth-governance-v1 get-fee-info)) + (fee-info (contract-call? .pyth-governance get-fee-info)) (fee-amount (* (len updated-prices) (* (get mantissa fee-info) (pow u10 (get exponent fee-info)))))) ;; Charge fee (unwrap! (stx-transfer? fee-amount tx-sender (get address fee-info)) ERR_BALANCE_INSUFFICIENT) @@ -52,12 +52,12 @@ })) (begin ;; Check execution flow - (try! (contract-call? .pyth-governance-v1 check-execution-flow contract-caller (some execution-plan))) + (try! (contract-call? .pyth-governance check-execution-flow contract-caller (some execution-plan))) ;; Perform contract-call (let ((pyth-decoder-contract (get pyth-decoder-contract execution-plan)) (wormhole-core-contract (get wormhole-core-contract execution-plan)) (decoded-prices (try! (contract-call? pyth-decoder-contract decode-and-verify-price-feeds price-feed-bytes wormhole-core-contract))) - (fee-info (contract-call? .pyth-governance-v1 get-fee-info)) + (fee-info (contract-call? .pyth-governance get-fee-info)) (fee-amount (* (len decoded-prices) (* (get mantissa fee-info) (pow u10 (get exponent fee-info)))))) ;; Charge fee (unwrap! (stx-transfer? fee-amount tx-sender (get address fee-info)) ERR_BALANCE_INSUFFICIENT) diff --git a/contracts/pyth-p2wh-decoder-v1.clar b/contracts/pyth-p2wh-decoder.clar similarity index 100% rename from contracts/pyth-p2wh-decoder-v1.clar rename to contracts/pyth-p2wh-decoder.clar diff --git a/contracts/pyth-pnau-decoder-v1.clar b/contracts/pyth-pnau-decoder.clar similarity index 67% rename from contracts/pyth-pnau-decoder-v1.clar rename to contracts/pyth-pnau-decoder.clar index 6d1a3c8..eac2ec8 100644 --- a/contracts/pyth-pnau-decoder-v1.clar +++ b/contracts/pyth-pnau-decoder.clar @@ -4,8 +4,8 @@ ;; Report an issue: https://github.com/hirosystems/stacks-pyth-bridge/issues ;;;; Traits -(impl-trait .pyth-traits-v1.decoder-trait) -(use-trait wormhole-core-trait .wormhole-traits-v1.core-trait) +(impl-trait .pyth-traits.decoder-trait) +(use-trait wormhole-core-trait .wormhole-traits.core-trait) ;;;; Constants @@ -47,7 +47,7 @@ (define-public (decode-and-verify-price-feeds (pnau-bytes (buff 8192)) (wormhole-core-address )) (begin ;; Check execution flow - (try! (contract-call? .pyth-governance-v1 check-execution-flow contract-caller none)) + (try! (contract-call? .pyth-governance check-execution-flow contract-caller none)) ;; Proceed to update (let ((prices-updates (try! (decode-pnau-price-update pnau-bytes wormhole-core-address)))) (ok prices-updates)))) @@ -56,15 +56,15 @@ ;; #[filter(pnau-bytes, wormhole-core-address)] (define-private (decode-pnau-price-update (pnau-bytes (buff 8192)) (wormhole-core-address )) (let ((cursor-pnau-header (try! (parse-pnau-header pnau-bytes))) - (cursor-pnau-vaa-size (try! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-16 (get next cursor-pnau-header)))) - (cursor-pnau-vaa (try! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-8192-max (get next cursor-pnau-vaa-size) (some (get value cursor-pnau-vaa-size))))) + (cursor-pnau-vaa-size (try! (contract-call? .hk-cursor read-uint-16 (get next cursor-pnau-header)))) + (cursor-pnau-vaa (try! (contract-call? .hk-cursor read-buff-8192-max (get next cursor-pnau-vaa-size) (some (get value cursor-pnau-vaa-size))))) (vaa (try! (contract-call? wormhole-core-address parse-and-verify-vaa (get value cursor-pnau-vaa)))) (cursor-merkle-root-data (try! (parse-merkle-root-data-from-vaa-payload (get payload vaa)))) (decoded-prices-updates (try! (parse-and-verify-prices-updates - (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 slice (get next cursor-pnau-vaa) none) + (contract-call? .hk-cursor slice (get next cursor-pnau-vaa) none) (get merkle-root-hash (get value cursor-merkle-root-data))))) (prices-updates (map cast-decoded-price decoded-prices-updates)) - (authorized-prices-data-sources (contract-call? .pyth-governance-v1 get-authorized-prices-data-sources))) + (authorized-prices-data-sources (contract-call? .pyth-governance get-authorized-prices-data-sources))) ;; Ensure that update was published by an data source authorized by governance (unwrap! (index-of? authorized-prices-data-sources @@ -73,15 +73,15 @@ (ok prices-updates))) (define-private (parse-merkle-root-data-from-vaa-payload (payload-vaa-bytes (buff 8192))) - (let ((cursor-payload-type (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-4 { bytes: payload-vaa-bytes, pos: u0 }) + (let ((cursor-payload-type (unwrap! (contract-call? .hk-cursor read-buff-4 { bytes: payload-vaa-bytes, pos: u0 }) ERR_INVALID_AUWV)) - (cursor-wh-update-type (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-payload-type)) + (cursor-wh-update-type (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-payload-type)) ERR_INVALID_AUWV)) - (cursor-merkle-root-slot (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-wh-update-type)) + (cursor-merkle-root-slot (unwrap! (contract-call? .hk-cursor read-uint-64 (get next cursor-wh-update-type)) ERR_INVALID_AUWV)) - (cursor-merkle-root-ring-size (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-32 (get next cursor-merkle-root-slot)) + (cursor-merkle-root-ring-size (unwrap! (contract-call? .hk-cursor read-uint-32 (get next cursor-merkle-root-slot)) ERR_INVALID_AUWV)) - (cursor-merkle-root-hash (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-20 (get next cursor-merkle-root-ring-size)) + (cursor-merkle-root-hash (unwrap! (contract-call? .hk-cursor read-buff-20 (get next cursor-merkle-root-ring-size)) ERR_INVALID_AUWV))) ;; Check payload type (asserts! (is-eq (get value cursor-payload-type) AUWV_MAGIC) ERR_MAGIC_BYTES) @@ -98,15 +98,15 @@ }))) (define-private (parse-pnau-header (pf-bytes (buff 8192))) - (let ((cursor-magic (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-4 { bytes: pf-bytes, pos: u0 }) + (let ((cursor-magic (unwrap! (contract-call? .hk-cursor read-buff-4 { bytes: pf-bytes, pos: u0 }) ERR_MAGIC_BYTES)) - (cursor-version-maj (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-magic)) + (cursor-version-maj (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-magic)) ERR_VERSION_MAJ)) - (cursor-version-min (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-version-maj)) + (cursor-version-min (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-version-maj)) ERR_VERSION_MIN)) - (cursor-header-trailing-size (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-version-min)) + (cursor-header-trailing-size (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-version-min)) ERR_HEADER_TRAILING_SIZE)) - (cursor-proof-type (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 { + (cursor-proof-type (unwrap! (contract-call? .hk-cursor read-uint-8 { bytes: pf-bytes, pos: (+ (get pos (get next cursor-header-trailing-size)) (get value cursor-header-trailing-size))}) ERR_PROOF_TYPE))) @@ -130,8 +130,8 @@ }))) (define-private (parse-and-verify-prices-updates (bytes (buff 8192)) (merkle-root-hash (buff 20))) - (let ((cursor-num-updates (try! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 { bytes: bytes, pos: u0 }))) - (cursor-updates-bytes (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 slice (get next cursor-num-updates) none)) + (let ((cursor-num-updates (try! (contract-call? .hk-cursor read-uint-8 { bytes: bytes, pos: u0 }))) + (cursor-updates-bytes (contract-call? .hk-cursor slice (get next cursor-num-updates) none)) (updates (get result (fold parse-price-info-and-proof cursor-updates-bytes { result: (list), cursor: { @@ -170,7 +170,7 @@ { merkle-root-hash: (get merkle-root-hash acc), result: (and (get result acc) - (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-merkle-tree-keccak160-v1 check-proof + (contract-call? .hk-merkle-tree-keccak160 check-proof (get merkle-root-hash acc) (get leaf-bytes entry) (get proof entry))) @@ -202,21 +202,21 @@ acc (if (is-eq (get index (get cursor acc)) (get next-update-index (get cursor acc))) ;; Parse update - (let ((cursor-update (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new (get bytes acc) (some (get index (get cursor acc))))) - (cursor-message-size (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-16 (get next cursor-update)))) - (cursor-message-type (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-message-size)))) - (cursor-price-identifier (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-32 (get next cursor-message-type)))) - (cursor-price (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-int-64 (get next cursor-price-identifier)))) - (cursor-conf (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-price)))) - (cursor-expo (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-int-32 (get next cursor-conf)))) - (cursor-publish-time (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-expo)))) - (cursor-prev-publish-time (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-publish-time)))) - (cursor-ema-price (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-int-64 (get next cursor-prev-publish-time)))) - (cursor-ema-conf (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-ema-price)))) - (cursor-proof (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 advance (get next cursor-message-size) (get value cursor-message-size))) - (cursor-proof-size (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 cursor-proof))) - (proof-bytes (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 slice (get next cursor-proof-size) (some (* u20 (get value cursor-proof-size))))) - (leaf-bytes (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 slice (get next cursor-message-size) (some (get value cursor-message-size)))) + (let ((cursor-update (contract-call? .hk-cursor new (get bytes acc) (some (get index (get cursor acc))))) + (cursor-message-size (unwrap-panic (contract-call? .hk-cursor read-uint-16 (get next cursor-update)))) + (cursor-message-type (unwrap-panic (contract-call? .hk-cursor read-uint-8 (get next cursor-message-size)))) + (cursor-price-identifier (unwrap-panic (contract-call? .hk-cursor read-buff-32 (get next cursor-message-type)))) + (cursor-price (unwrap-panic (contract-call? .hk-cursor read-int-64 (get next cursor-price-identifier)))) + (cursor-conf (unwrap-panic (contract-call? .hk-cursor read-uint-64 (get next cursor-price)))) + (cursor-expo (unwrap-panic (contract-call? .hk-cursor read-int-32 (get next cursor-conf)))) + (cursor-publish-time (unwrap-panic (contract-call? .hk-cursor read-uint-64 (get next cursor-expo)))) + (cursor-prev-publish-time (unwrap-panic (contract-call? .hk-cursor read-uint-64 (get next cursor-publish-time)))) + (cursor-ema-price (unwrap-panic (contract-call? .hk-cursor read-int-64 (get next cursor-prev-publish-time)))) + (cursor-ema-conf (unwrap-panic (contract-call? .hk-cursor read-uint-64 (get next cursor-ema-price)))) + (cursor-proof (contract-call? .hk-cursor advance (get next cursor-message-size) (get value cursor-message-size))) + (cursor-proof-size (unwrap-panic (contract-call? .hk-cursor read-uint-8 cursor-proof))) + (proof-bytes (contract-call? .hk-cursor slice (get next cursor-proof-size) (some (* u20 (get value cursor-proof-size))))) + (leaf-bytes (contract-call? .hk-cursor slice (get next cursor-message-size) (some (get value cursor-message-size)))) (proof (get result (fold parse-proof proof-bytes { result: (list), cursor: { @@ -280,8 +280,8 @@ acc (if (is-eq (get index (get cursor acc)) (get next-update-index (get cursor acc))) ;; Parse update - (let ((cursor-hash (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 new (get bytes acc) (some (get index (get cursor acc))))) - (hash (get value (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-20 (get next cursor-hash)))))) + (let ((cursor-hash (contract-call? .hk-cursor new (get bytes acc) (some (get index (get cursor acc))))) + (hash (get value (unwrap-panic (contract-call? .hk-cursor read-buff-20 (get next cursor-hash)))))) ;; Perform assertions { cursor: { diff --git a/contracts/pyth-store-v1.clar b/contracts/pyth-store.clar similarity index 95% rename from contracts/pyth-store-v1.clar rename to contracts/pyth-store.clar index df14884..08dd652 100644 --- a/contracts/pyth-store-v1.clar +++ b/contracts/pyth-store.clar @@ -3,7 +3,7 @@ ;; Check for latest version: https://github.com/hirosystems/stacks-pyth-bridge#latest-version ;; Report an issue: https://github.com/hirosystems/stacks-pyth-bridge/issues -(impl-trait .pyth-traits-v1.storage-trait) +(impl-trait .pyth-traits.storage-trait) (define-constant ERR_NEWER_PRICE_AVAILABLE (err u5000)) (define-constant ERR_STALE_PRICE (err u5001)) @@ -37,7 +37,7 @@ }))) (let ((successful-updates (map unwrapped-entry (filter only-ok-entry (map write-batch-entry batch-updates))))) ;; Ensure that updates are always coming from the right contract - (try! (contract-call? .pyth-governance-v1 check-execution-flow contract-caller none)) + (try! (contract-call? .pyth-governance check-execution-flow contract-caller none)) ;; Ensure we have at least one entry (asserts! (> (len successful-updates) u0) ERR_INVALID_UPDATES) (ok successful-updates))) @@ -52,7 +52,7 @@ publish-time: uint, prev-publish-time: uint, })) - (let ((stale-price-threshold (contract-call? .pyth-governance-v1 get-stale-price-threshold)) + (let ((stale-price-threshold (contract-call? .pyth-governance get-stale-price-threshold)) (latest-bitcoin-timestamp (unwrap! (get-block-info? time (- block-height u1)) ERR_STALE_PRICE))) ;; Ensure that we have not processed a newer price (asserts! (is-price-update-more-recent (get price-identifier entry) (get publish-time entry)) ERR_NEWER_PRICE_AVAILABLE) diff --git a/contracts/pyth-traits-v1.clar b/contracts/pyth-traits.clar similarity index 96% rename from contracts/pyth-traits-v1.clar rename to contracts/pyth-traits.clar index f70bcda..dc4b211 100644 --- a/contracts/pyth-traits-v1.clar +++ b/contracts/pyth-traits.clar @@ -3,7 +3,7 @@ ;; Check for latest version: https://github.com/hirosystems/stacks-pyth-bridge#latest-version ;; Report an issue: https://github.com/hirosystems/stacks-pyth-bridge/issues -(use-trait wormhole-core-trait .wormhole-traits-v1.core-trait) +(use-trait wormhole-core-trait .wormhole-traits.core-trait) (define-trait decoder-trait ( diff --git a/contracts/requirements/hk-cursor.clar b/contracts/requirements/hk-cursor.clar new file mode 100644 index 0000000..32cdf77 --- /dev/null +++ b/contracts/requirements/hk-cursor.clar @@ -0,0 +1,133 @@ +;; Title: hiro-kit-cursor +;; Version: v1 + +(define-read-only (read-buff-1 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u1)) (err u1)) u1) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u1) } + })) + +(define-read-only (read-buff-2 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u2)) (err u1)) u2) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u2) } + })) + +(define-read-only (read-buff-4 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u4)) (err u1)) u4) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u4) } + })) + +(define-read-only (read-buff-8 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u8)) (err u1)) u8) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u8) } + })) + +(define-read-only (read-buff-16 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u16)) (err u1)) u16) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u16) } + })) + +(define-read-only (read-buff-20 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u20)) (err u1)) u20) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u20) } + })) + +(define-read-only (read-buff-32 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u32)) (err u1)) u32) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u32) } + })) + +(define-read-only (read-buff-64 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u64)) (err u1)) u64) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u64) } + })) + +(define-read-only (read-buff-65 (cursor { bytes: (buff 8192), pos: uint })) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) (get pos cursor) (+ (get pos cursor) u65)) (err u1)) u65) (err u1)), + next: { bytes: (get bytes cursor), pos: (+ (get pos cursor) u65) } + })) + +(define-read-only (read-buff-8192-max (cursor { bytes: (buff 8192), pos: uint }) (size (optional uint))) + (let ((min (get pos cursor)) + (max (match size value + (+ value (get pos cursor)) + (len (get bytes cursor))))) + (ok { + value: (unwrap! (as-max-len? (unwrap! (slice? (get bytes cursor) min max) (err u1)) u8192) (err u1)), + next: { bytes: (get bytes cursor), pos: max } + }))) + +(define-read-only (read-uint-8 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-1 cursor)))) + (ok (merge cursor-bytes { value: (buff-to-uint-be (get value cursor-bytes)) })))) + +(define-read-only (read-uint-16 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-2 cursor)))) + (ok (merge cursor-bytes { value: (buff-to-uint-be (get value cursor-bytes)) })))) + +(define-read-only (read-uint-32 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-4 cursor)))) + (ok (merge cursor-bytes { value: (buff-to-uint-be (get value cursor-bytes)) })))) + +(define-read-only (read-uint-64 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-8 cursor)))) + (ok (merge cursor-bytes { value: (buff-to-uint-be (get value cursor-bytes)) })))) + +(define-read-only (read-uint-128 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-16 cursor)))) + (ok (merge cursor-bytes { value: (buff-to-uint-be (get value cursor-bytes)) })))) + +(define-read-only (read-int-8 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-1 cursor)))) + (ok (merge + cursor-bytes + { value: (bit-shift-right (bit-shift-left (buff-to-int-be (get value cursor-bytes)) u120) u120) })))) + +(define-read-only (read-int-16 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-2 cursor)))) + (ok (merge + cursor-bytes + { value: (bit-shift-right (bit-shift-left (buff-to-int-be (get value cursor-bytes)) u112) u112) })))) + +(define-read-only (read-int-32 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-4 cursor)))) + (ok (merge + cursor-bytes + { value: (bit-shift-right (bit-shift-left (buff-to-int-be (get value cursor-bytes)) u96) u96) })))) + +(define-read-only (read-int-64 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-8 cursor)))) + (ok (merge + cursor-bytes + { value: (bit-shift-right (bit-shift-left (buff-to-int-be (get value cursor-bytes)) u64) u64) })))) + +(define-read-only (read-int-128 (cursor { bytes: (buff 8192), pos: uint })) + (let ((cursor-bytes (try! (read-buff-16 cursor)))) + (ok (merge + cursor-bytes + { value: (buff-to-int-be (get value cursor-bytes)) })))) + +(define-read-only (new (bytes (buff 8192)) (offset (optional uint))) + { + value: none, + next: { bytes: bytes, pos: (match offset value value u0) } + }) + +(define-read-only (advance (cursor { bytes: (buff 8192), pos: uint }) (offset uint)) + { bytes: (get bytes cursor), pos: (+ (get pos cursor) offset) }) + +(define-read-only (slice (cursor { bytes: (buff 8192), pos: uint }) (size (optional uint))) + (match (slice? (get bytes cursor) + (get pos cursor) + (match size value + (+ (get pos cursor) value) + (len (get bytes cursor)))) + bytes bytes 0x)) diff --git a/contracts/requirements/hk-merkle-tree-keccak160.clar b/contracts/requirements/hk-merkle-tree-keccak160.clar new file mode 100644 index 0000000..68bb25b --- /dev/null +++ b/contracts/requirements/hk-merkle-tree-keccak160.clar @@ -0,0 +1,27 @@ +;; Title: hiro-merkle-tree-keccak160 +;; Version: v1 + +(define-read-only (keccak160 (bytes (buff 1024))) + (unwrap-panic (as-max-len? (unwrap-panic (slice? (keccak256 bytes) u0 u20)) u20))) + +(define-read-only (buff-20-to-uint (bytes (buff 20))) + (buff-to-uint-be (unwrap-panic (as-max-len? (unwrap-panic (slice? bytes u0 u15)) u16)))) + +(define-read-only (hash-leaf (bytes (buff 255))) + (keccak160 (concat 0x00 bytes))) + +(define-read-only (hash-nodes (node-1 (buff 20)) (node-2 (buff 20))) + (let ((uint-1 (buff-20-to-uint node-1)) + (uint-2 (buff-20-to-uint node-2)) + (sequence (if (< uint-2 uint-1) + (concat (concat 0x01 node-2) node-1) + (concat (concat 0x01 node-1) node-2)))) + (keccak160 sequence))) + +(define-read-only (check-proof (root-hash (buff 20)) (leaf (buff 255)) (path (list 255 (buff 20)))) + (let ((hashed-leaf (hash-leaf leaf)) + (computed-root-hash (fold hash-path path hashed-leaf))) + (is-eq root-hash computed-root-hash))) + +(define-private (hash-path (entry (buff 20)) (acc (buff 20))) + (hash-nodes entry acc)) diff --git a/contracts/wormhole/wormhole-core-v2.clar b/contracts/wormhole/wormhole-core.clar similarity index 84% rename from contracts/wormhole/wormhole-core-v2.clar rename to contracts/wormhole/wormhole-core.clar index dcf5a3e..72ddbff 100644 --- a/contracts/wormhole/wormhole-core-v2.clar +++ b/contracts/wormhole/wormhole-core.clar @@ -6,7 +6,7 @@ ;;;; Traits ;; Implements trait specified in wormhole-core-trait contract -(impl-trait .wormhole-traits-v1.core-trait) +(impl-trait .wormhole-traits.core-trait) ;;;; Constants @@ -75,7 +75,7 @@ (define-constant GSU-EMITTING-CHAIN u1) -(define-constant hk-cursor-v2 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2) +(define-constant hk-cursor-v2 .hk-cursor) ;;;; Data vars @@ -112,11 +112,11 @@ ;; ;; @param vaa-bytes: (define-read-only (parse-vaa (vaa-bytes (buff 8192))) - (let ((cursor-version (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 { bytes: vaa-bytes, pos: u0 }) + (let ((cursor-version (unwrap! (contract-call? .hk-cursor read-uint-8 { bytes: vaa-bytes, pos: u0 }) ERR_VAA_PARSING_VERSION)) - (cursor-guardian-set-id (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-32 (get next cursor-version)) + (cursor-guardian-set-id (unwrap! (contract-call? .hk-cursor read-uint-32 (get next cursor-version)) ERR_VAA_PARSING_GUARDIAN_SET)) - (cursor-signatures-len (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-guardian-set-id)) + (cursor-signatures-len (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-guardian-set-id)) ERR_VAA_PARSING_SIGNATURES_LEN)) (cursor-signatures (fold batch-read-signatures (list u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0) @@ -125,21 +125,21 @@ value: (list), iter: (get value cursor-signatures-len) })) - (vaa-body-hash (keccak256 (keccak256 (get value (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-8192-max (get next cursor-signatures) none) + (vaa-body-hash (keccak256 (keccak256 (get value (unwrap! (contract-call? .hk-cursor read-buff-8192-max (get next cursor-signatures) none) ERR_VAA_HASHING_BODY))))) - (cursor-timestamp (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-32 (get next cursor-signatures)) + (cursor-timestamp (unwrap! (contract-call? .hk-cursor read-uint-32 (get next cursor-signatures)) ERR_VAA_PARSING_TIMESTAMP)) - (cursor-nonce (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-32 (get next cursor-timestamp)) + (cursor-nonce (unwrap! (contract-call? .hk-cursor read-uint-32 (get next cursor-timestamp)) ERR_VAA_PARSING_NONCE)) - (cursor-emitter-chain (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-16 (get next cursor-nonce)) + (cursor-emitter-chain (unwrap! (contract-call? .hk-cursor read-uint-16 (get next cursor-nonce)) ERR_VAA_PARSING_EMITTER_CHAIN)) - (cursor-emitter-address (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-32 (get next cursor-emitter-chain)) + (cursor-emitter-address (unwrap! (contract-call? .hk-cursor read-buff-32 (get next cursor-emitter-chain)) ERR_VAA_PARSING_EMITTER_ADDRESS)) - (cursor-sequence (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-64 (get next cursor-emitter-address)) + (cursor-sequence (unwrap! (contract-call? .hk-cursor read-uint-64 (get next cursor-emitter-address)) ERR_VAA_PARSING_SEQUENCE)) - (cursor-consistency-level (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-sequence)) + (cursor-consistency-level (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-sequence)) ERR_VAA_PARSING_CONSISTENCY_LEVEL)) - (cursor-payload (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-8192-max (get next cursor-consistency-level) none) + (cursor-payload (unwrap! (contract-call? .hk-cursor read-buff-8192-max (get next cursor-consistency-level) none) ERR_VAA_PARSING_PAYLOAD)) (public-keys-results (fold batch-recover-public-keys (get value cursor-signatures) @@ -293,8 +293,8 @@ (acc { next: { bytes: (buff 8192), pos: uint }, iter: uint, value: (list 19 { guardian-id: uint, signature: (buff 65) })})) (if (is-eq (get iter acc) u0) { iter: u0, next: (get next acc), value: (get value acc) } - (let ((cursor-guardian-id (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next acc)))) - (cursor-signature (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-65 (get next cursor-guardian-id))))) + (let ((cursor-guardian-id (unwrap-panic (contract-call? .hk-cursor read-uint-8 (get next acc)))) + (cursor-signature (unwrap-panic (contract-call? .hk-cursor read-buff-65 (get next cursor-guardian-id))))) { iter: (- (get iter acc) u1), next: (get next cursor-signature), @@ -315,7 +315,7 @@ (define-private (parse-guardian (cue-position uint) (acc { bytes: (buff 8192), result: (list 19 (buff 20))})) (let ( - (cursor-address-bytes (unwrap-panic (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-20 { bytes: (get bytes acc), pos: cue-position }))) + (cursor-address-bytes (unwrap-panic (contract-call? .hk-cursor read-buff-20 { bytes: (get bytes acc), pos: cue-position }))) ) { bytes: (get bytes acc), @@ -325,17 +325,17 @@ ;; @desc Parse and verify payload's VAA (define-private (parse-and-verify-guardians-set (bytes (buff 8192))) (let - ((cursor-module (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-32 { bytes: bytes, pos: u0 }) + ((cursor-module (unwrap! (contract-call? .hk-cursor read-buff-32 { bytes: bytes, pos: u0 }) ERR_GSU_PARSING_MODULE)) - (cursor-action (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-module)) + (cursor-action (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-module)) ERR_GSU_PARSING_ACTION)) - (cursor-chain (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-16 (get next cursor-action)) + (cursor-chain (unwrap! (contract-call? .hk-cursor read-uint-16 (get next cursor-action)) ERR_GSU_PARSING_CHAIN)) - (cursor-new-index (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-32 (get next cursor-chain)) + (cursor-new-index (unwrap! (contract-call? .hk-cursor read-uint-32 (get next cursor-chain)) ERR_GSU_PARSING_INDEX)) - (cursor-guardians-count (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-uint-8 (get next cursor-new-index)) + (cursor-guardians-count (unwrap! (contract-call? .hk-cursor read-uint-8 (get next cursor-new-index)) ERR_GSU_PARSING_GUARDIAN_LEN)) - (guardians-bytes (unwrap! (contract-call? 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2 read-buff-8192-max (get next cursor-guardians-count) (some (* (get value cursor-guardians-count) u20))) + (guardians-bytes (unwrap! (contract-call? .hk-cursor read-buff-8192-max (get next cursor-guardians-count) (some (* (get value cursor-guardians-count) u20))) ERR_GSU_PARSING_GUARDIANS_BYTES)) (guardians-cues (get result (fold is-guardian-cue (get value guardians-bytes) { cursor: u0, result: (list) }))) (eth-addresses (get result (fold parse-guardian guardians-cues { bytes: (get value guardians-bytes), result: (list) })))) diff --git a/contracts/wormhole/wormhole-traits-v1.clar b/contracts/wormhole/wormhole-traits.clar similarity index 100% rename from contracts/wormhole/wormhole-traits-v1.clar rename to contracts/wormhole/wormhole-traits.clar diff --git a/runbooks/README.md b/runbooks/README.md new file mode 100644 index 0000000..8550504 --- /dev/null +++ b/runbooks/README.md @@ -0,0 +1,49 @@ +# stacks-pyth Runbooks + +[![Txtx](https://img.shields.io/badge/Operated%20with-Txtx-gree?labelColor=gray)](https://txtx.sh) + +## Runbooks available + +### Pyth Deployment +deploy + +## Getting Started + +This repository is using [txtx](https://txtx.sh) for handling its on-chain operations. + +`txtx` takes its inspiration from a battle tested devops best practice named `infrastructure as code`, that have transformed cloud architectures. + +`txtx` simplifies and streamlines Smart Contract Infrastructure management across blockchains, focusing on robustness, reproducibility and composability. + +### Installation + +```console +$ curl -sL https://install.txtx.sh/ | bash +``` + +### Scaffold a new runbook + +```console +$ txtx new +``` + +Access tutorials and documentation at [docs.txtx.sh](https://docs.txtx.sh) to understand the syntax and discover the powerful features of txtx. + +Additionally, the [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=txtx.txtx) will make writing runbooks easier. + +### List runbooks available in this repository +```console +$ txtx ls +Name ID Description +BNS Multisig bns-multisig Register a BNS name using a multisig wallet +``` + +### Execute an existing runbook +```console +$ txtx run bns-multisig +``` + +### Update the README documentation +```console +$ txtx docs --update +``` diff --git a/runbooks/deployments/deploy/deploy-contracts.tx b/runbooks/deployments/deploy/deploy-contracts.tx new file mode 100644 index 0000000..35f1364 --- /dev/null +++ b/runbooks/deployments/deploy/deploy-contracts.tx @@ -0,0 +1,71 @@ +runtime "addon::stacks" { + defaults { + network_id = env.stacks_network_id + rpc_api_url = env.stacks_api_url + } +} + +wallet "operator" "stacks::mnemonic" { + mnemonic = env.operator_mnemonic +} + +action "wormhole_traits_deployment" "stacks::deploy_contract" { + description = "Deploy wormhole-traits contract" + contract = stacks::get_contract_from_clarinet_project("wormhole-traits", env.clarinet_manifest_path) + signer = wallet.operator + confirmations = 1 +} + +action "pyth_trait_deployment" "stacks::deploy_contract" { + description = "Deploy pyth-traits contract" + contract = stacks::get_contract_from_clarinet_project("pyth-traits", env.clarinet_manifest_path) + signer = wallet.operator + depends_on = [action.wormhole_core_deployment] +} + +action "pyth_governance_deployment" "stacks::deploy_contract" { + description = "Deploy pyth-governance contract" + contract = stacks::get_contract_from_clarinet_project("pyth-governance", env.clarinet_manifest_path) + signer = wallet.operator + depends_on = [action.pyth_trait_deployment, action.hk_cursor_deployment] +} + +action "pyth_oracle_deployment" "stacks::deploy_contract" { + description = "Deploy pyth-oracle contract" + contract = stacks::get_contract_from_clarinet_project("pyth-oracle", env.clarinet_manifest_path) + signer = wallet.operator + depends_on = [action.pyth_trait_deployment, action.pyth_governance_deployment] +} + +action "pyth_pnau_decoder_deployment" "stacks::deploy_contract" { + description = "Deploy pyth-pnau-decoder contract" + contract = stacks::get_contract_from_clarinet_project("pyth-pnau-decoder", env.clarinet_manifest_path) + signer = wallet.operator + depends_on = [action.pyth_trait_deployment, action.hk_merkle_tree_keccak160_deployment, action.pyth_governance_deployment] +} + +action "pyth_store_deployment" "stacks::deploy_contract" { + description = "Deploy pyth-store contract" + contract = stacks::get_contract_from_clarinet_project("pyth-store", env.clarinet_manifest_path) + signer = wallet.operator + depends_on = [action.pyth_trait_deployment, action.pyth_governance_deployment] +} + +action "wormhole_core_deployment" "stacks::deploy_contract" { + description = "Deploy wormhole-core contract" + contract = stacks::get_contract_from_clarinet_project("wormhole-core", env.clarinet_manifest_path) + signer = wallet.operator + depends_on = [action.wormhole_traits_deployment, action.hk_cursor_deployment] +} + +action "hk_cursor_deployment" "stacks::deploy_contract" { + description = "Deploy hk-cursor contract" + contract = stacks::get_contract_from_clarinet_project("hk-cursor", env.clarinet_manifest_path) + signer = wallet.operator +} + +action "hk_merkle_tree_keccak160_deployment" "stacks::deploy_contract" { + description = "Deploy hk-merkle-tree-keccak160 contract" + contract = stacks::get_contract_from_clarinet_project("hk-merkle-tree-keccak160", env.clarinet_manifest_path) + signer = wallet.operator +} diff --git a/runbooks/deployments/deploy/deploy-guardians-updates.tx b/runbooks/deployments/deploy/deploy-guardians-updates.tx new file mode 100644 index 0000000..cdcaae7 --- /dev/null +++ b/runbooks/deployments/deploy/deploy-guardians-updates.tx @@ -0,0 +1,70 @@ +input "update_guardian_set_1_vaa" { + description = "VAA for guardian rotation #1" + value = "0x010000000001007ac31b282c2aeeeb37f3385ee0de5f8e421d30b9e5ae8ba3d4375c1c77a86e77159bb697d9c456d6f8c02d22a94b1279b65b0d6a9957e7d3857423845ac758e300610ac1d2000000030001000000000000000000000000000000000000000000000000000000000000000400000000000005390000000000000000000000000000000000000000000000000000000000436f7265020000000000011358cc3ae5c097b213ce3c81979e1b9f9570746aa5ff6cb952589bde862c25ef4392132fb9d4a42157114de8460193bdf3a2fcf81f86a09765f4762fd1107a0086b32d7a0977926a205131d8731d39cbeb8c82b2fd82faed2711d59af0f2499d16e726f6b211b39756c042441be6d8650b69b54ebe715e234354ce5b4d348fb74b958e8966e2ec3dbd4958a7cdeb5f7389fa26941519f0863349c223b73a6ddee774a3bf913953d695260d88bc1aa25a4eee363ef0000ac0076727b35fbea2dac28fee5ccb0fea768eaf45ced136b9d9e24903464ae889f5c8a723fc14f93124b7c738843cbb89e864c862c38cddcccf95d2cc37a4dc036a8d232b48f62cdd4731412f4890da798f6896a3331f64b48c12d1d57fd9cbe7081171aa1be1d36cafe3867910f99c09e347899c19c38192b6e7387ccd768277c17dab1b7a5027c0b3cf178e21ad2e77ae06711549cfbb1f9c7a9d8096e85e1487f35515d02a92753504a8d75471b9f49edb6fbebc898f403e4773e95feb15e80c9a99c8348d" +} + +input "update_guardian_set_2_vaa" { + description = "VAA for guardian rotation #2" + value = "0x01000000010d0012e6b39c6da90c5dfd3c228edbb78c7a4c97c488ff8a346d161a91db067e51d638c17216f368aa9bdf4836b8645a98018ca67d2fec87d769cabfdf2406bf790a0002ef42b288091a670ef3556596f4f47323717882881eaf38e03345078d07a156f312b785b64dae6e9a87e3d32872f59cb1931f728cecf511762981baf48303668f0103cef2616b84c4e511ff03329e0853f1bd7ee9ac5ba71d70a4d76108bddf94f69c2a8a84e4ee94065e8003c334e899184943634e12043d0dda78d93996da073d190104e76d166b9dac98f602107cc4b44ac82868faf00b63df7d24f177aa391e050902413b71046434e67c770b19aecdf7fce1d1435ea0be7262e3e4c18f50ddc8175c0105d9450e8216d741e0206a50f93b750a47e0a258b80eb8fed1314cc300b3d905092de25cd36d366097b7103ae2d184121329ba3aa2d7c6cc53273f11af14798110010687477c8deec89d36a23e7948feb074df95362fc8dcbd8ae910ac556a1dee1e755c56b9db5d710c940938ed79bc1895a3646523a58bc55f475a23435a373ecfdd0107fb06734864f79def4e192497362513171530daea81f07fbb9f698afe7e66c6d44db21323144f2657d4a5386a954bb94eef9f64148c33aef6e477eafa2c5c984c01088769e82216310d1827d9bd48645ec23e90de4ef8a8de99e2d351d1df318608566248d80cdc83bdcac382b3c30c670352be87f9069aab5037d0b747208eae9c650109e9796497ff9106d0d1c62e184d83716282870cef61a1ee13d6fc485b521adcce255c96f7d1bca8d8e7e7d454b65783a830bddc9d94092091a268d311ecd84c26010c468c9fb6d41026841ff9f8d7368fa309d4dbea3ea4bbd2feccf94a92cc8a20a226338a8e2126cd16f70eaf15b4fc9be2c3fa19def14e071956a605e9d1ac4162010e23fcb6bd445b7c25afb722250c1acbc061ed964ba9de1326609ae012acdfb96942b2a102a2de99ab96327859a34a2b49a767dbdb62e0a1fb26af60fe44fd496a00106bb0bac77ac68b347645f2fb1ad789ea9bd76fb9b2324f25ae06f97e65246f142df717f662e73948317182c62ce87d79c73def0dba12e5242dfc038382812cfe00126da03c5e56cb15aeeceadc1e17a45753ab4dc0ec7bf6a75ca03143ed4a294f6f61bc3f478a457833e43084ecd7c985bf2f55a55f168aac0e030fc49e845e497101626e9d9a5d9e343f00010000000000000000000000000000000000000000000000000000000000000004c1759167c43f501c2000000000000000000000000000000000000000000000000000000000436f7265020000000000021358cc3ae5c097b213ce3c81979e1b9f9570746aa5ff6cb952589bde862c25ef4392132fb9d4a42157114de8460193bdf3a2fcf81f86a09765f4762fd1107a0086b32d7a0977926a205131d8731d39cbeb8c82b2fd82faed2711d59af0f2499d16e726f6b211b39756c042441be6d8650b69b54ebe715e234354ce5b4d348fb74b958e8966e2ec3dbd4958a7cd66b9590e1c41e0b226937bf9217d1d67fd4e91f574a3bf913953d695260d88bc1aa25a4eee363ef0000ac0076727b35fbea2dac28fee5ccb0fea768eaf45ced136b9d9e24903464ae889f5c8a723fc14f93124b7c738843cbb89e864c862c38cddcccf95d2cc37a4dc036a8d232b48f62cdd4731412f4890da798f6896a3331f64b48c12d1d57fd9cbe7081171aa1be1d36cafe3867910f99c09e347899c19c38192b6e7387ccd768277c17dab1b7a5027c0b3cf178e21ad2e77ae06711549cfbb1f9c7a9d8096e85e1487f35515d02a92753504a8d75471b9f49edb6fbebc898f403e4773e95feb15e80c9a99c8348d" +} + +input "update_guardian_set_3_vaa" { + description = "VAA for guardian rotation #3" + value = "0x01000000020d00ce45474d9e1b1e7790a2d210871e195db53a70ffd6f237cfe70e2686a32859ac43c84a332267a8ef66f59719cf91cc8df0101fd7c36aa1878d5139241660edc0010375cc906156ae530786661c0cd9aef444747bc3d8d5aa84cac6a6d2933d4e1a031cffa30383d4af8131e929d9f203f460b07309a647d6cd32ab1cc7724089392c000452305156cfc90343128f97e499311b5cae174f488ff22fbc09591991a0a73d8e6af3afb8a5968441d3ab8437836407481739e9850ad5c95e6acfcc871e951bc30105a7956eefc23e7c945a1966d5ddbe9e4be376c2f54e45e3d5da88c2f8692510c7429b1ea860ae94d929bd97e84923a18187e777aa3db419813a80deb84cc8d22b00061b2a4f3d2666608e0aa96737689e3ba5793810ff3a52ff28ad57d8efb20967735dc5537a2e43ef10f583d144c12a1606542c207f5b79af08c38656d3ac40713301086b62c8e130af3411b3c0d91b5b50dcb01ed5f293963f901fc36e7b0e50114dce203373b32eb45971cef8288e5d928d0ed51cd86e2a3006b0af6a65c396c009080009e93ab4d2c8228901a5f4525934000b2c26d1dc679a05e47fdf0ff3231d98fbc207103159ff4116df2832eea69b38275283434e6cd4a4af04d25fa7a82990b707010aa643f4cf615dfff06ffd65830f7f6cf6512dabc3690d5d9e210fdc712842dc2708b8b2c22e224c99280cd25e5e8bfb40e3d1c55b8c41774e287c1e2c352aecfc010b89c1e85faa20a30601964ccc6a79c0ae53cfd26fb10863db37783428cd91390a163346558239db3cd9d420cfe423a0df84c84399790e2e308011b4b63e6b8015010ca31dcb564ac81a053a268d8090e72097f94f366711d0c5d13815af1ec7d47e662e2d1bde22678113d15963da100b668ba26c0c325970d07114b83c5698f46097010dc9fda39c0d592d9ed92cd22b5425cc6b37430e236f02d0d1f8a2ef45a00bde26223c0a6eb363c8b25fd3bf57234a1d9364976cefb8360e755a267cbbb674b39501108db01e444ab1003dd8b6c96f8eb77958b40ba7a85fefecf32ad00b7a47c0ae7524216262495977e09c0989dd50f280c21453d3756843608eacd17f4fdfe47600001261025228ef5af837cb060bcd986fcfa84ccef75b3fa100468cfd24e7fadf99163938f3b841a33496c2706d0208faab088bd155b2e20fd74c625bb1cc8c43677a0163c53c409e0c5dfa000100000000000000000000000000000000000000000000000000000000000000046c5a054d7833d1e42000000000000000000000000000000000000000000000000000000000436f7265020000000000031358cc3ae5c097b213ce3c81979e1b9f9570746aa5ff6cb952589bde862c25ef4392132fb9d4a42157114de8460193bdf3a2fcf81f86a09765f4762fd1107a0086b32d7a0977926a205131d8731d39cbeb8c82b2fd82faed2711d59af0f2499d16e726f6b211b39756c042441be6d8650b69b54ebe715e234354ce5b4d348fb74b958e8966e2ec3dbd4958a7cd15e7caf07c4e3dc8e7c469f92c8cd88fb8005a2074a3bf913953d695260d88bc1aa25a4eee363ef0000ac0076727b35fbea2dac28fee5ccb0fea768eaf45ced136b9d9e24903464ae889f5c8a723fc14f93124b7c738843cbb89e864c862c38cddcccf95d2cc37a4dc036a8d232b48f62cdd4731412f4890da798f6896a3331f64b48c12d1d57fd9cbe7081171aa1be1d36cafe3867910f99c09e347899c19c38192b6e7387ccd768277c17dab1b7a5027c0b3cf178e21ad2e77ae06711549cfbb1f9c7a9d8096e85e1487f35515d02a92753504a8d75471b9f49edb6fbebc898f403e4773e95feb15e80c9a99c8348d" +} + +input "update_guardian_set_4_vaa" { + description = "VAA for guardian rotation #4" + value = "0x01000000030d03d4a37a6ff4361d91714730831e9d49785f61624c8f348a9c6c1d82bc1d98cadc5e936338204445c6250bb4928f3f3e165ad47ca03a5d63111168a2de4576856301049a5df10464ea4e1961589fd30fc18d1970a7a2ffaad617e56a0f7777f25275253af7d10a0f0f2494dc6e99fc80e444ab9ebbbee252ded2d5dcb50cbf7a54bb5a01055f4603b553b9ba9e224f9c55c7bca3da00abb10abd19e0081aecd3b352be061a70f79f5f388ebe5190838ef3cd13a2f22459c9a94206883b739c90b40d5d74640006a8fade3997f650a36e46bceb1f609edff201ab32362266f166c5c7da713f6a19590c20b68ed3f0119cb24813c727560ede086b3d610c2d7a1efa66f655bad90900080f5e495a75ea52241c59d145c616bfac01e57182ad8d784cbcc9862ed3afb60c0983ccbc690553961ffcf115a0c917367daada8e60be2cbb8b8008bac6341a8c010935ab11e0eea28b87a1edc5ccce3f1fac25f75b5f640fe6b0673a7cd74513c9dc01c544216cf364cc9993b09fda612e0cd1ced9c00fb668b872a16a64ebb55d27010ab2bc39617a2396e7defa24cd7c22f42dc31f3c42ffcd9d1472b02df8468a4d0563911e8fb6a4b5b0ce0bd505daa53779b08ff660967b31f246126ed7f6f29a7e000bdb6d3fd7b33bdc9ac3992916eb4aacb97e7e21d19649e7fa28d2dd6e337937e4274516a96c13ac7a8895da9f91948ea3a09c25f44b982c62ce8842b58e20c8a9000d3d1b19c8bb000856b6610b9d28abde6c35cb7705c6ca5db711f7be96d60eed9d72cfa402a6bfe8bf0496dbc7af35796fc768da51a067b95941b3712dce8ae1e7010ec80085033157fd1a5628fc0c56267469a86f0e5a66d7dede1ad4ce74ecc3dff95b60307a39c3bfbeedc915075070da30d0395def9635130584f709b3885e1bdc0010fc480eb9ee715a2d151b23722b48b42581d7f4001fc1696c75425040bfc1ffc5394fe418adb2b64bd3dc692efda4cc408163677dbe233b16bcdabb853a20843301118ee9e115e1a0c981f19d0772b850e666591322da742a9a12cce9f52a5665bd474abdd59c580016bee8aae67fdf39b315be2528d12eec3a652910e03cc4c6fa3801129d0d1e2e429e969918ec163d16a7a5b2c6729aa44af5dccad07d25d19891556a79b574f42d9adbd9e2a9ae5a6b8750331d2fccb328dd94c3bf8791ee1bfe85aa00661e99781981faea00010000000000000000000000000000000000000000000000000000000000000004fd4c6c55ec8dfd342000000000000000000000000000000000000000000000000000000000436f726502000000000004135893b5a76c3f739645648885bdccc06cd70a3cd3ff6cb952589bde862c25ef4392132fb9d4a42157114de8460193bdf3a2fcf81f86a09765f4762fd1107a0086b32d7a0977926a205131d8731d39cbeb8c82b2fd82faed2711d59af0f2499d16e726f6b211b39756c042441be6d8650b69b54ebe715e234354ce5b4d348fb74b958e8966e2ec3dbd4958a7cd15e7caf07c4e3dc8e7c469f92c8cd88fb8005a2074a3bf913953d695260d88bc1aa25a4eee363ef0000ac0076727b35fbea2dac28fee5ccb0fea768eaf45ced136b9d9e24903464ae889f5c8a723fc14f93124b7c738843cbb89e864c862c38cddcccf95d2cc37a4dc036a8d232b48f62cdd4731412f4890da798f6896a3331f64b48c12d1d57fd9cbe7081171aa1be1d36cafe3867910f99c09e347899c19c38192b6e7387ccd768277c17dab1b7a5027c0b3cf178e21ad2e77ae06711549cfbb1f9c7a9d8096e85e1487f35515d02a92753504a8d75471b9f49edb6fbebc898f403e4773e95feb15e80c9a99c8348d" +} + +action "update_guardian_set_1" "stacks::send_contract_call" { + // The address and identifier of the contract to invoke. + contract_id = action.wormhole_core_deployment.contract_id + // The contract method to invoke. + function_name = "update-guardians-set" + // The function arguments for the contract call. + function_args = [input.update_guardian_set_1_vaa, input.guardian_set_1] + // A reference to a wallet construct, which will be used to sign the transaction payload. + signer = wallet.operator + fee = 20000 +} + +action "update_guardian_set_2" "stacks::send_contract_call" { + // The address and identifier of the contract to invoke. + contract_id = action.wormhole_core_deployment.contract_id + // The contract method to invoke. + function_name = "update-guardians-set" + // The function arguments for the contract call. + function_args = [input.update_guardian_set_2_vaa, input.guardian_set_2] + // A reference to a wallet construct, which will be used to sign the transaction payload. + signer = wallet.operator + depends_on = [action.update_guardian_set_1] + fee = 20000 +} + +action "update_guardian_set_3" "stacks::send_contract_call" { + // The address and identifier of the contract to invoke. + contract_id = action.wormhole_core_deployment.contract_id + // The contract method to invoke. + function_name = "update-guardians-set" + // The function arguments for the contract call. + function_args = [input.update_guardian_set_3_vaa, input.guardian_set_3] + // A reference to a wallet construct, which will be used to sign the transaction payload. + signer = wallet.operator + depends_on = [action.update_guardian_set_2] + fee = 20000 +} + +action "update_guardian_set_4" "stacks::send_contract_call" { + // The address and identifier of the contract to invoke. + contract_id = action.wormhole_core_deployment.contract_id + // The contract method to invoke. + function_name = "update-guardians-set" + // The function arguments for the contract call. + function_args = [input.update_guardian_set_4_vaa, input.guardian_set_4] + // A reference to a wallet construct, which will be used to sign the transaction payload. + signer = wallet.operator + depends_on = [action.update_guardian_set_3] + fee = 20000 +} \ No newline at end of file diff --git a/runbooks/deployments/deploy/inputs.tx b/runbooks/deployments/deploy/inputs.tx new file mode 100644 index 0000000..263a93c --- /dev/null +++ b/runbooks/deployments/deploy/inputs.tx @@ -0,0 +1,209 @@ +input "public_key_certus_one" { + description = "Certus One public key" + value = "0x2a953a2e8b1052eb70c1d7b556b087deed598b55608396686c1c811b9796c763078687ce10459f4f25fb7a0fbf8727bb0fb51e00820e93a123f652ee843cf08d" +} + +input "public_key_staked" { + description = "Staked public key" + value = "0x2766db08820e311b22e109801ab8ea505b12e3df3d91ebc87c999ffb6929d1abb0ade987c74aa37db26eea4086ee738a2f34a5594edb8760da0eac5be356b731" +} + +input "public_key_figment" { + description = "Figment public key" + value = "0x54177ff4a8329520b76efd86f8bfce5c942554db16e673267dc1133b3f5e230b2d8cbf90fe274946045d4491de288d736680edc2ee9ee5b1b15416b0a34806c4" +} + +input "public_key_chainode_tech" { + description = "ChainodeTech public key" + value = "0x7fa3e98fcc2621337b217b61408a98facaabd25bad2b158438728ce863c14708cfcda1f3b50a16ca0211199079fb338d479a54546ec3c5f775af23a7d7f4fb24" +} + +input "public_key_inotel" { + description = "Inotel public key" + value = "0x0bdcbccc0297c2a4f92a7c39358c42f22a8ed700a78bd05c39c8b61aaf2338e825b6c0d26d1f2a2ae4129cd751201f73d7234c753bd0735212a5288b19748fd2" +} + +input "public_key_hash_quark" { + description = "HashQuark public key" + value = "0xcfd90084be68de514fe14a7c281f492223f045566f859ea5c166d6e60bc650c23940909a8e96c2fbffbd15a598b4e6a5b5aa14c126bf58cc1a9e396fe7771965" +} + +input "public_key_chain_layer" { + description = "Chain Layer public key" + value = "0x8edf3f9d997357a0e2c916ee090392c3a645ebac4f6cd8f826d3ecc0173b33bf06b7c14e8002fc9a5d01af9824a5cb3778472cd477e0ab378091448bca6f0417" +} + +input "public_key_dokia_capital" { + description = "Dokia Capital One public key" + value = "0x6200deeadd3b4e2cd0a168d42e720a3b88d3ce4769ff2808086e6fd36110fc05c591ccbf91368609dc3b21203e58c9883d4f580085469bef8d5bdcd26eb8ad69" +} + +input "public_key_forbole" { + description = "Forbole public key" + value = "0xd5225476d7849b362226952ffc561bab99832f3f8b99741f6d81bbeaffa8e7f6e54a85e5029a3b510707eaa9684df496e4b1268075ad0328693a30bf1b1e0033" +} + +input "public_key_staking_fund" { + description = "Stacking Fund public key" + value = "0xd9fa78b5b958bea1929080b8ad96dc555d34b051a27aebf711eb1186b807b0448316d994606ac807121838d6c41a58f308bc6307acdf69491fa4b17282f3e66f" +} + +input "public_key_moonlet_wallet" { + description = "Moonlet Wallet public key" + value = "0xcc64af75ec2e2741fb9af9f6191cb9ee187d6d26af4d1e96d7bab47e6ec09be12d3192030dc4bbf54d1da319a7a2acfc7a9dd4c644af6646a4aaa02b1024bbab" +} + +input "public_key_p2p_validator" { + description = "P2P Validator public key" + value = "0xb5943b6e284682ad2e011d6962d41febf86af2f5fc0c9c8f4b81358ff077f9c96ba0880eaf93541eae94b4fa41dba66dab7fb0201cc9af7c75681e5719b0c95f" +} + +input "public_key_01_node" { + description = "01node public key" + value = "0x0cfc9d5b5dcf702a1525f9d4ed1841e8eb8b34434cc82470dd35435f1dbdc73ffb51544b7500394eac9c7fa567868b495326075147a2d809ebbfd43273eeec91" +} + +input "public_key_mcfv2mainnet" { + description = "MCFV2MAINNET public key" + value = "0x0aa78894d894a15933969f5826347439e2c309f2049277a10066c9197840499498ad19ee3d1b291f932ec0890bbdafcec292c4f02a446670cd0084f997e25e2f" +} + +input "public_key_everstake" { + description = "Everstake public key" + value = "0x00f400e3fe40f64032485aad9240ead45a8e1fc83ec08c96db861c0eca155ac898df8673e778e3ccaae8a0f9e6af415fe40e99b0cbc88d7610e536b6041b07fb" +} + +input "public_key_chorus_one" { + description = "Chorus One public key" + value = "0x604f384174c7ed3a0dc5f476569a978266a7943bd775449d1b8b27f4eb8beb99cdf095f9200a2dabb1bc5d68c3d96ea3d47f4d34499d59953669b6c8c093d578" +} + +input "public_key_syncnode" { + description = "Syncnode public key" + value = "0x4881345cbb299fa7c60ab2d16cb7fe7bf8d14675506ef6eb6037038b5b7092ea0a9e4d0b53ba3904edd99f86717d6ba81dffe44eb5b23c6fd22c91ab73c33021" +} + +input "public_key_triton" { + description = "Triton public key" + value = "0xee3d4cc17633afe7e1794fcfd728e0643325e3d130eb1daa39c0c5cb05a200b43876117a182cabdcc3795632aa529473a0c8245f9e4f6e43e54c3f1da28bcb82" +} + +input "public_key_staking_facilities" { + description = "Staking Facilities public key" + value = "0x21f338444e96af31cf44958acf5764844efbddace3b823ed761c340c59ed2685d829818c83eebe8f00f783f1048a53515845536668a9e0c059ade7579a0f4204" +} + +input "public_key_ftx" { + description = "FTX public key" + value = "0x" +} + +input "public_key_x_labs" { + description = "xLabs public key" + value = "0x47b15c5039dcb2850b59bea323db662cc597dd7d48fe6b8dbb6cd8704c45854bf0e92fa267c844ba1a700105e157c8099d55c82316cb5e50c56a5d0920ff91c2" +} + +input "public_key_rockaway_x" { + description = "Rockaway X public key" + value = "0x9a1e801daa25d9808e70aae9981353086f958955cc94ef33a461b0e596feaef90a8474dd10cf6ae967143f86105c16d6304a3d268ea952fda9389139d4bb9da1" +} + +input "guardian_set_1" { + description = "Guardians Set #1" + value = [ + input.public_key_certus_one, + input.public_key_staked, + input.public_key_figment, + input.public_key_chainode_tech, + input.public_key_inotel, + input.public_key_hash_quark, + input.public_key_chain_layer, + input.public_key_dokia_capital, + input.public_key_forbole, + input.public_key_staking_fund, + input.public_key_moonlet_wallet, + input.public_key_p2p_validator, + input.public_key_01_node, + input.public_key_mcfv2mainnet, + input.public_key_everstake, + input.public_key_chorus_one, + input.public_key_syncnode, + input.public_key_triton, + input.public_key_staking_facilities, + ] +} + +input "guardian_set_2" { + description = "Guardians Set #2" + default = [ + input.public_key_certus_one, + input.public_key_staked, + input.public_key_figment, + input.public_key_chainode_tech, + input.public_key_inotel, + input.public_key_hash_quark, + input.public_key_chain_layer, + input.public_key_ftx, + input.public_key_forbole, + input.public_key_staking_fund, + input.public_key_moonlet_wallet, + input.public_key_p2p_validator, + input.public_key_01_node, + input.public_key_mcfv2mainnet, + input.public_key_everstake, + input.public_key_chorus_one, + input.public_key_syncnode, + input.public_key_triton, + input.public_key_staking_facilities, + ] +} + +input "guardian_set_3" { + description = "Guardians Set #3" + default = [ + input.public_key_certus_one, + input.public_key_staked, + input.public_key_figment, + input.public_key_chainode_tech, + input.public_key_inotel, + input.public_key_hash_quark, + input.public_key_chain_layer, + input.public_key_x_labs, + input.public_key_forbole, + input.public_key_staking_fund, + input.public_key_moonlet_wallet, + input.public_key_p2p_validator, + input.public_key_01_node, + input.public_key_mcfv2mainnet, + input.public_key_everstake, + input.public_key_chorus_one, + input.public_key_syncnode, + input.public_key_triton, + input.public_key_staking_facilities, + ] +} + +input "guardian_set_4" { + description = "Guardians Set #4" + default = [ + input.public_key_rockaway_x, + input.public_key_staked, + input.public_key_figment, + input.public_key_chainode_tech, + input.public_key_inotel, + input.public_key_hash_quark, + input.public_key_chain_layer, + input.public_key_x_labs, + input.public_key_forbole, + input.public_key_staking_fund, + input.public_key_moonlet_wallet, + input.public_key_p2p_validator, + input.public_key_01_node, + input.public_key_mcfv2mainnet, + input.public_key_everstake, + input.public_key_chorus_one, + input.public_key_syncnode, + input.public_key_triton, + input.public_key_staking_facilities, + ] +} diff --git a/runbooks/deployments/deploy/outputs.tx b/runbooks/deployments/deploy/outputs.tx new file mode 100644 index 0000000..f024fd4 --- /dev/null +++ b/runbooks/deployments/deploy/outputs.tx @@ -0,0 +1,20 @@ + +output "pyth_oracle_contract" { + description = "Pyth oracle contract_id" + value = action.pyth_oracle_deployment.contract_id +} + +output "pyth_storage_contract" { + description = "pyth-storage-contract" + value = action.pyth_store_deployment.contract_id +} + +output "pyth_decoder_contract" { + description = "pyth-decoder-contract" + value = action.pyth_pnau_decoder_deployment.contract_id +} + +output "wormhole_core_contract" { + description = "wormhole-core-contract" + value = action.wormhole_core_deployment.contract_id +} diff --git a/runbooks/usage/update-price-feed.tx b/runbooks/usage/update-price-feed.tx new file mode 100644 index 0000000..4030c8f --- /dev/null +++ b/runbooks/usage/update-price-feed.tx @@ -0,0 +1,61 @@ +runtime "addon::stacks" { + defaults { + network_id = env.stacks_network_id + rpc_api_url = env.stacks_api_url + } +} + +// wallet "operator" "stacks::connect" { +// expected_address = "ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNCc" +// } + +wallet "operator" "stacks::mnemonic" { + mnemonic = env.operator_mnemonic +} + +input "price_feed_id" { + description = "Price Feed to update (default: BTC)" + default = "ec7a775f46379b5e943c3526b1c8d54cd49749176b0b98e02dde68d1bd335c17" +} + +action "fetch_hermes_price" "std::send_http_request" { + description = "Retrieve a Pyth Network Accumulator Update (PNAU) price update from Pyth Hermes web service" + // The URL for the request. Supported schemes are http and https. + url = "https://hermes.pyth.network/api/latest_price_feeds?ids[]=${input.price_feed_id}&binary=true" + // A map of request header field names and values. + request_headers = { + Accept = "application/json" + } +} + +input "pyth_hermes_pnau_update" { + description = "Pyth Network Accumulator Update (PNAU) containing the price update" + value = base64_decode(index(jq(action.fetch_hermes_price.response_body, ".[0].vaa"), 0)) +} + +action "update_price" "stacks::send_contract_call" { + // Description of the transaction + description = "Verify and Update Price Feed" + // The address and identifier of the contract to invoke. + contract_id = env.pyth_oracle_contract + // The contract method to invoke. + function_name = "verify-and-update-price-feeds" + // The function arguments for the contract call. + function_args = [ + input.pyth_hermes_pnau_update, + { + "pyth-storage-contract": stacks::cv_principal(env.pyth_storage_contract), + "pyth-decoder-contract": stacks::cv_principal(env.pyth_decoder_contract), + "wormhole-core-contract": stacks::cv_principal(env.wormhole_core_contract), + } + ] + // A reference to a wallet construct, which will be used to sign the transaction payload. + signer = wallet.operator + // The post conditions to include to the transaction. + // post_conditions = +} + +output "price_update" { + description = "Price feed updated" + value = action.update_price.result +} \ No newline at end of file diff --git a/txtx.yml b/txtx.yml new file mode 100644 index 0000000..f3ac439 --- /dev/null +++ b/txtx.yml @@ -0,0 +1,37 @@ +--- +name: stacks-pyth +id: stacks-pyth +runbooks: + - name: Pyth Deployment + id: deploy + description: Deploy Pyth protocol on Stacks + location: runbooks/deployments/deploy + state: + file: pyth-deployment.devnet.json + - name: Update Price Feed + id: update-price + description: Update Price Feed + location: runbooks/usage/update-price-feed.tx +environments: + devnet: + stacks_network_id: devnet + stacks_api_url: http://localhost:3999 + stacks_operator_address: ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC + clarinet_manifest_path: ./Clarinet.toml + operator_mnemonic: "female adjust gallery certain visit token during great side clown fitness like hurt clip knife warm bench start reunion globe detail dream depend fortune" + pyth_oracle_contract: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP.pyth-oracle + pyth_storage_contract: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP.pyth-store + wormhole_core_contract: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP.wormhole-core + pyth_decoder_contract: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP.pyth-pnau-decoder + testnet: + stacks_network_id: testnet + stacks_api_url: https://api.testnet.hiro.so + stacks_operator_address: ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC + clarinet_manifest_path: ./Clarinet.toml + operator_mnemonic: "female adjust gallery certain visit token during great side clown fitness like hurt clip knife warm bench start reunion globe detail dream depend fortune" + mainnet: + stacks_network_id: mainnet + stacks_api_url: https://api.hiro.so + stacks_operator_address: SP2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1J5QKA2F + clarinet_manifest_path: ./Clarinet.toml + operator_mnemonic: "female adjust gallery certain visit token during great side clown fitness like hurt clip knife warm bench start reunion globe detail dream depend fortune" \ No newline at end of file diff --git a/unit-tests/pyth/oracle.test.ts b/unit-tests/pyth/oracle.test.ts index 2026d8a..745c07a 100644 --- a/unit-tests/pyth/oracle.test.ts +++ b/unit-tests/pyth/oracle.test.ts @@ -4,12 +4,12 @@ import { ParsedTransactionResult } from "@hirosystems/clarinet-sdk"; import { pnauMainnetVaas } from "./fixtures"; import { wormhole } from "../wormhole/helpers"; -const pythOracleContractName = "pyth-oracle-v2"; -const pythDecoderPnauContractName = "pyth-pnau-decoder-v1"; -const pythStorageContractName = "pyth-store-v1"; -const wormholeCoreContractName = "wormhole-core-v2"; +const pythOracleContractName = "pyth-oracle"; +const pythDecoderPnauContractName = "pyth-pnau-decoder"; +const pythStorageContractName = "pyth-store"; +const wormholeCoreContractName = "wormhole-core"; -describe("pyth-oracle-v2::decode-and-verify-price-feeds mainnet VAAs", () => { +describe("pyth-oracle::decode-and-verify-price-feeds mainnet VAAs", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; diff --git a/unit-tests/pyth/pnau.test.ts b/unit-tests/pyth/pnau.test.ts index ebb3147..10f81bc 100644 --- a/unit-tests/pyth/pnau.test.ts +++ b/unit-tests/pyth/pnau.test.ts @@ -3,13 +3,13 @@ import { beforeEach, describe, expect, it } from "vitest"; import { wormhole } from "../wormhole/helpers"; import { pyth } from "./helpers"; -const pythOracleContractName = "pyth-oracle-v2"; -const pythDecoderPnauContractName = "pyth-pnau-decoder-v1"; -const pythGovernanceContractName = "pyth-governance-v1"; -const pythStorageContractName = "pyth-store-v1"; -const wormholeCoreContractName = "wormhole-core-v2"; +const pythOracleContractName = "pyth-oracle"; +const pythDecoderPnauContractName = "pyth-pnau-decoder"; +const pythGovernanceContractName = "pyth-governance"; +const pythStorageContractName = "pyth-store"; +const wormholeCoreContractName = "wormhole-core"; -describe("pyth-pnau-decoder-v1::decode-and-verify-price-feeds success", () => { +describe("pyth-pnau-decoder::decode-and-verify-price-feeds success", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); @@ -130,7 +130,7 @@ describe("pyth-pnau-decoder-v1::decode-and-verify-price-feeds success", () => { }); }); -describe("pyth-pnau-decoder-v1::decode-and-verify-price-feeds failures", () => { +describe("pyth-pnau-decoder::decode-and-verify-price-feeds failures", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); diff --git a/unit-tests/pyth/ptgm.test.ts b/unit-tests/pyth/ptgm.test.ts index 8980613..654df12 100644 --- a/unit-tests/pyth/ptgm.test.ts +++ b/unit-tests/pyth/ptgm.test.ts @@ -2,18 +2,18 @@ import { Cl, ClarityType } from "@stacks/transactions"; import { beforeEach, describe, expect, it } from "vitest"; import { wormhole } from "../wormhole/helpers"; import { pyth } from "./helpers"; -import { bytesToHex, hexToBytes } from "@noble/hashes/utils"; +import { hexToBytes } from "@noble/hashes/utils"; import { ParsedTransactionResult } from "@hirosystems/clarinet-sdk"; import { ptgmTestnetVaas } from "./fixtures"; -const pythOracleContractName = "pyth-oracle-v2"; -const pythStorageContractName = "pyth-store-v1"; -const pythDecoderPnauContractName = "pyth-pnau-decoder-v1"; -const pythGovernanceContractName = "pyth-governance-v1"; -const wormholeCoreContractName = "wormhole-core-v2"; +const pythOracleContractName = "pyth-oracle"; +const pythStorageContractName = "pyth-store"; +const pythDecoderPnauContractName = "pyth-pnau-decoder"; +const pythGovernanceContractName = "pyth-governance"; +const wormholeCoreContractName = "wormhole-core"; const initialFeeRecipient = "ST3CRXBDXQ2N5P7E25Q39MEX1HSMRDSEAP1JST19D"; -describe("pyth-governance-v1::update-fee-value mainnet VAAs", () => { +describe("pyth-governance::update-fee-value mainnet VAAs", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; @@ -72,7 +72,7 @@ describe("pyth-governance-v1::update-fee-value mainnet VAAs", () => { }); -describe("pyth-governance-v1::update-fee-value", () => { +describe("pyth-governance::update-fee-value", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); @@ -158,7 +158,7 @@ describe("pyth-governance-v1::update-fee-value", () => { }); }); -describe("pyth-governance-v1::update-fee-recipient", () => { +describe("pyth-governance::update-fee-recipient", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); @@ -237,14 +237,14 @@ describe("pyth-governance-v1::update-fee-recipient", () => { }); }); -describe("pyth-governance-v1::update-wormhole-core-contract", () => { +describe("pyth-governance::update-wormhole-core-contract", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const deployer = accounts.get("deployer")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); let updateWormholeContract = { address: "ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG", - contractName: "wormhole-core-v3", + contractName: "wormhole-core-v2", }; let ptgmVaaPayload = pyth.buildPtgmVaaPayload({ updateWormholeContract }); @@ -353,7 +353,7 @@ describe("pyth-governance-v1::update-wormhole-core-contract", () => { }); }); -describe("pyth-governance-v1::update-pyth-decoder-contract", () => { +describe("pyth-governance::update-pyth-decoder-contract", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const deployer = accounts.get("deployer")!; @@ -482,7 +482,7 @@ describe("pyth-governance-v1::update-pyth-decoder-contract", () => { }); }); -describe("pyth-governance-v1::update-pyth-store-contract", () => { +describe("pyth-governance::update-pyth-store-contract", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const deployer = accounts.get("deployer")!; @@ -609,7 +609,7 @@ describe("pyth-governance-v1::update-pyth-store-contract", () => { }); }); -describe("pyth-governance-v1::update-pyth-oracle-contract", () => { +describe("pyth-governance::update-pyth-oracle-contract", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const deployer = accounts.get("deployer")!; @@ -715,7 +715,7 @@ describe("pyth-governance-v1::update-pyth-oracle-contract", () => { }); }); -describe("pyth-governance-v1::update-prices-data-sources", () => { +describe("pyth-governance::update-prices-data-sources", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); @@ -803,7 +803,7 @@ describe("pyth-governance-v1::update-prices-data-sources", () => { }); }); -describe("pyth-governance-v1::update-governance-data-source", () => { +describe("pyth-governance::update-governance-data-source", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); @@ -1047,7 +1047,7 @@ describe("pyth-governance-v1::update-governance-data-source", () => { }); }); -describe("pyth-governance-v1::update-stale-price-threshold", () => { +describe("pyth-governance::update-stale-price-threshold", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet = wormhole.generateGuardianSetKeychain(19); diff --git a/unit-tests/wormhole/vaa.test.ts b/unit-tests/wormhole/vaa.test.ts index d574024..1114879 100644 --- a/unit-tests/wormhole/vaa.test.ts +++ b/unit-tests/wormhole/vaa.test.ts @@ -5,10 +5,10 @@ import { wormhole } from "./helpers"; import { ParsedTransactionResult, tx } from "@hirosystems/clarinet-sdk"; import { hexToBytes } from "@noble/hashes/utils"; -const contractName = "wormhole-core-v2"; +const contractName = "wormhole-core"; const verbosity = 0; -describe("wormhole-core-v2::parse-vaa success", () => { +describe("wormhole-core::parse-vaa success", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const keychain = wormhole.generateGuardianSetKeychain(19); @@ -60,7 +60,7 @@ describe("wormhole-core-v2::parse-vaa success", () => { }); }); -describe("wormhole-core-v2::update-guardians-set failures", () => { +describe("wormhole-core::update-guardians-set failures", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const keychain = wormhole.generateGuardianSetKeychain(19); @@ -275,7 +275,7 @@ describe("wormhole-core-v2::update-guardians-set failures", () => { }); }); -describe("wormhole-core-v2::update-guardians-set success", () => { +describe("wormhole-core::update-guardians-set success", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet1Keys = wormhole.generateGuardianSetKeychain(19); @@ -439,7 +439,7 @@ describe("wormhole-core-v2::update-guardians-set success", () => { }); }); -describe("wormhole-core-v2::parse-and-verify-vaa success", () => { +describe("wormhole-core::parse-and-verify-vaa success", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet1Keys = wormhole.generateGuardianSetKeychain(19); @@ -525,7 +525,7 @@ describe("wormhole-core-v2::parse-and-verify-vaa success", () => { }); }); -describe("wormhole-core-v2::parse-and-verify-vaa failures", () => { +describe("wormhole-core::parse-and-verify-vaa failures", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; const guardianSet1Keys = wormhole.generateGuardianSetKeychain(19); @@ -662,7 +662,7 @@ describe("wormhole-core-v2::parse-and-verify-vaa failures", () => { }); }); -describe("wormhole-core-v2::update-guardians-set mainnet guardian rotations", () => { +describe("wormhole-core::update-guardians-set mainnet guardian rotations", () => { const accounts = simnet.getAccounts(); const sender = accounts.get("wallet_1")!; let block: ParsedTransactionResult[] | undefined = undefined;