This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (define-constant MAINNET_VERSION_BYTES 0x16) | |
| (define-constant ADDRESS 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM) | |
| (define-read-only (get-hash-bytes) | |
| (get hash-bytes (unwrap-err-panic (principal-destruct? ADDRESS))) | |
| ) | |
| (principal-construct? MAINNET_VERSION_BYTES (get-hash-bytes)) | |
| ;; (some 'SP1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRCBGD7R) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import type { ChainhookStructure } from '@/types/chainhooks-type'; | |
| import { db } from '@/utils/db'; // Assuming db is a module for database operations | |
| export async function handleChainhookEvent(chainhookData: ChainhookStructure) { | |
| const { apply, rollback } = chainhookData; | |
| // Check if there's a rollback action required | |
| if (rollback.length) { | |
| console.log(`Handling rollback for ${rollback.length} blocks`); | |
| for (const rollbackEvent of rollback) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { db } from '@/utils/db'; | |
| import { isDAOProposalTx } from '@/helpers'; | |
| import type { ChainhookStructure } from '@/types/chainhooks-type'; | |
| export async function processChainhookTransactions(chainhookData: ChainhookStructure) { | |
| const { apply } = chainhookData; | |
| const transactions = apply[0].transactions; | |
| // Loop through each transaction in the Chainhook payload | |
| for (const transaction of transactions) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (define-constant OWNER tx-sender) | |
| (define-constant ERR_UNAUTHORIZED (err u101000)) | |
| ;; Participants map stores each participant's stacked amount, cycle and their ticket ID. | |
| (define-map Participants | |
| { participant: principal } | |
| { ticketId: uint, amount: uint, cycle: uint, ticketExpirationAtCycle: uint, isWinner: bool } | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (use-trait sip10-token .sip-10.sip-10-trait) | |
| (define-public (swap (from-token <sip10-token>) (to-token <sip10-token>) (amount uint)) | |
| (begin | |
| (try! (contract-call? from-token transfer amount tx-sender (as-contract tx-sender) none)) | |
| (try! (contract-call? to-token transfer amount (as-contract tx-sender) tx-sender none)) | |
| (ok true) | |
| ) | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (impl-trait .sip-10.sip-10-trait) | |
| (define-fungible-token clarity-token) | |
| (define-constant ERR_OWNER_ONLY (err u100)) | |
| (define-constant ERR_NOT_TOKEN_OWNER (err u101)) | |
| (define-constant CONTRACT_OWNER tx-sender) | |
| (define-constant TOKEN_URI u"https://clarity-lang.org") | |
| (define-constant TOKEN_NAME "Clarity Token") | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (define-trait sip-10-trait | |
| ( | |
| (transfer (uint principal principal (optional (buff 34))) (response bool uint)) | |
| (get-name () (response (string-ascii 32) uint)) | |
| (get-symbol () (response (string-ascii 32) uint)) | |
| (get-decimals () (response uint uint)) | |
| (get-balance (principal) (response uint uint)) | |
| (get-total-supply () (response uint uint)) | |
| (get-token-uri () (response (optional (string-utf8 256)) uint)) | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * React Hooks for Stacks.js: useAuth | |
| * | |
| * Description: | |
| * This custom React hook integrates with Stacks blockchain authentication, | |
| * simplifying the sign-in and sign-out process within React applications. | |
| * | |
| * Features: | |
| * - Manages `UserSession` lifecycle from the `@stacks/auth` package. | |
| * - Exposes `signIn` method to initiate the authentication request. |