Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/cleanup-cache-automatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Cache Cleanup - Automatic"
on:
pull_request:
types:
- closed
defaults:
run:
shell: bash


jobs:

cache-purge:
name: "Purge Actions cache"
runs-on: ubuntu-latest

steps:

- name: "Delete Branch Cache Action"
uses: snnaplab/delete-branch-cache-action@v1.0.0
with:
# Specify explicitly because the ref at the time of merging will be a branch name such as 'main', 'develop'
ref: refs/pull/${{ github.event.number }}/merge
github-token: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Cleanup - Cache"
name: "Cache Cleanup - Manual"
on:
workflow_dispatch:
inputs:
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,3 @@ jobs:
WEBHOOK_URL
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}

cache-purge:
name: "Purge branch Actions cache"
needs: production-deploy
runs-on: ubuntu-latest

steps:

- name: "Delete Branch Cache Action"
uses: snnaplab/delete-branch-cache-action@v1.0.0
with:
# Specify explicitly because the ref at the time of merging will be a branch name such as 'main', 'develop'
ref: refs/pull/${{ github.event.number }}/merge
github-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ The application expects these environment variables to be set on Cloudflare:
Cached data for computationally-expensive queries are stored in [Cloudflare KV](https://developers.cloudflare.com/workers/learning/how-kv-works/).

1. `CIRCULATING_SUPPLY_WATCHLIST`: This KV is pre-populated with a list of addresses to monitor for circulating supply. Initially, the *value* portion of this can be set to anything, since it will get replaced when [periodic cron triggers](https://developers.cloudflare.com/workers/platform/cron-triggers) run to set the account balance breakdown for this account. In case you have a lot of accounts to monitor, we recommend prefixing the *key* with a `group_N` prefix which will stagger the API lookup across multiple cron executions.
2. `ACTIVE_VALIDATORS`: List of active validators, fetch from block explorer GraphQL API. When a cron trigger is executed, the total delegator count and update time is stored in this KV.

```jsonc
// Sample watchlist JSON file structure
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/handlers/webhookTriggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ export async function webhookTriggers(event: ScheduledEvent) {
console.log('Triggering webhook...');
await sendPriceDiscrepancies();

await updateCirculatingSupply(
getRandomGroup(Number(CIRCULATING_SUPPLY_GROUPS))
);
await updateCirculatingSupply(getHour());
}

export async function sendPriceDiscrepancies() {
Expand Down Expand Up @@ -39,6 +37,12 @@ export async function sendPriceDiscrepancies() {
}
}

function getHour(): number {
// This function only works when CIRCULATING_SUPPLY_GROUPS is set to 24
let hour = Number( (new Date().getHours()) + 1 ); // getHours() returns 0-23
return hour;
}

function getRandomGroup(group: number): number {
let min = 1;
let max = Math.floor(group);
Expand Down
2 changes: 1 addition & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ kv_namespaces = [

# Cron triggers for staging worker
[env.staging.triggers]
crons = [ "0 */2 * * *" ]
crons = [ "0 * * * *" ]

###############################################################
### OPTIONAL: Build Configuration ###
Expand Down