version: 2
models:
  - name: silver__mint_actions
    description: table holding mint initialization or token minting events
    recent_date_filter: &recent_date_filter
      config:
        where: _inserted_timestamp >= current_date - 7
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
            - INDEX
            - INNER_INDEX
            - MINT
          where: block_timestamp::date > current_date - 7
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - not_null:
              where: block_id > 39824213 and _inserted_timestamp >= current_date - 7
          - dbt_expectations.expect_row_values_to_have_recent_data:
              datepart: day
              interval: 3
      - name: BLOCK_ID
        description: "{{ doc('block_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: TX_ID
        description: "{{ doc('tx_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}"
        tests:
          - not_null: *recent_date_filter
      - name: INDEX
        description: "{{ doc('event_index') }}"
        tests:
          - not_null: *recent_date_filter
      - name: INNER_INDEX
        description: Location of the inner instruction within an instruction
      - name: EVENT_TYPE 
        description: "{{ doc('event_type') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: MINT
        description: "{{ doc('mint') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: TOKEN_ACCOUNT
        description: The token's account - this can be used to join to the token account owners table. 
      - name: DECIMAL
        description: "{{ doc('decimal') }}"
        tests: 
          - not_null:
              where: event_type in ('initializeMint','initializeMint2') and _inserted_timestamp >= current_date - 7
      - name: MINT_AMOUNT
        description: "{{ doc('mint_amount') }}"
        tests: 
          - not_null:
              where: event_type in ('mintTo','mintToChecked') and _inserted_timestamp >= current_date - 7
      - name: MINT_AUTHORITY
        description: "Account address authorizing mint"
      - name: SIGNERS
        description: "Account address signing off on mint"
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests: 
          - not_null