Skip to content

Commit

Permalink
feat: cron to get aggregate deals
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Nov 10, 2023
1 parent dc4c898 commit 66ea4e0
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 119 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/get-aggregate-deals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Get Aggregate deals

on:
workflow_dispatch:
inputs:
piece:
required: true
description: PieceCID of the aggregate
type: string

jobs:
getDeals:
name: Get Aggregate deals
runs-on: ubuntu-latest
strategy:
matrix:
env: ['staging', 'production']
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: 18
cache: 'npm'
- run: npm ci
- name: Run job
env:
CF_API_TOKEN: ${{ secrets.CF_GATEWAY_TOKEN }}
run: pm run get-aggregate-deals -w packages/tools ${{ github.event.inputs.piece }}
185 changes: 66 additions & 119 deletions package-lock.json

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

22 changes: 22 additions & 0 deletions packages/tools/get-aggregate-deals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Piece } from '@web3-storage/data-segment'
import * as DID from '@ipld/dag-ucan/did'
import * as Signer from '@ucanto/principal/ed25519'
import { DealTracker } from '@web3-storage/filecoin-client'

const pieceString = process.argv[2]
if (!pieceString) {
throw new Error('no aggregate piece was provided')
}

const storefront = await Signer.generate()
const res = await DealTracker.dealInfo(
{
issuer: storefront,
with: storefront.did(),
audience: DID.parse('did:web:web3.storage'),
},
Piece.fromString(pieceString).link
)

console.log(`known information for aggregate ${pieceString}:`)
console.log(res.out.ok)
18 changes: 18 additions & 0 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@w3filecoin/tools",
"version": "0.0.0",
"type": "module",
"scripts": {
"get-aggregate-deals": "node get-aggregate-deals.js"
},
"dependencies": {},
"devDependencies": {
"@ipld/dag-ucan": "3.4.0",
"@ucanto/principal": "9.0.0",
"@web3-storage/data-segment": "5.0.0",
"@web3-storage/filecoin-client": "3.1.0"
},
"engines": {
"node": ">=18.16"
}
}

0 comments on commit 66ea4e0

Please sign in to comment.