Skip to content

Commit

Permalink
Merge pull request #382 from permaweb/tillathehun0/weavedive-fetch
Browse files Browse the repository at this point in the history
fix(weavedrive): use fetch in lieu of arweave js client to make graphql calls. Fix graphql operations.
  • Loading branch information
TillaTheHun0 authored Oct 28, 2024
2 parents e821d36 + 44fda6e commit 3cb68d6
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 78 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/weavedrive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: 🧶💾 Build & Release WeaveDrive

on:
pull_request:
branches:
- main
paths:
- "extensions/weavedrive/**"
push:
branches:
- main
paths:
- "extensions/weavedrive/**"

# Perform a release using a workflow dispatch
workflow_dispatch:
inputs:
version:
description: "semver version to bump to"
required: true

defaults:
run:
shell: bash

jobs:
test:
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 22

- name: 📥 Download deps
working-directory: extensions/weavedrive
run: |
npm i
- name: ⚡ Run Tests
working-directory: extensions/weavedrive
run: |
npm test
env:
CI: true

release:
# Releases are performed via a workflow dispatch
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: release
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"

- name: 👀 Env
run: |
echo "Event name: ${{ github.event_name }}"
echo "Git ref: ${{ github.ref }}"
echo "GH actor: ${{ github.actor }}"
echo "SHA: ${{ github.sha }}"
VER=`node --version`; echo "Node ver: $VER"
VER=`npm --version`; echo "npm ver: $VER"
- name: 🤓 Set Git User
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: ✊ Bump
id: bump
uses: hyper63/[email protected]
with:
bump-to: ${{ github.event.inputs.version }}
package: weavedrive

- name: ⬆️ Push
run: |
git push
git push --tags
- name: 📥 Download deps
working-directory: extensions/weavedrive
run: |
npm i
# Build aos
- name: 🦠 Publish to NPM
working-directory: extensions/weavedrive
run: |
npm run build
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions extensions/weavedrive/package-lock.json

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

2 changes: 1 addition & 1 deletion extensions/weavedrive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"arweave": "^1.15.5"
},
"devDependencies": {
"@permaweb/ao-loader": "^0.0.39",
"@permaweb/ao-loader": "^0.0.43",
"esbuild": "^0.24.0"
}
}
15 changes: 8 additions & 7 deletions extensions/weavedrive/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ module.exports = function weaveDrive(mod, FS) {
const blockHeight = mod.blockHeight
const moduleExtensions = this.getTagValues("Extension", mod.module.tags)
const moduleHasWeaveDrive = moduleExtensions.includes("WeaveDrive")
const processExtensions = this.getTagValues("Extension", mod.module.tags)
const processExtensions = this.getTagValues("Extension", mod.spawn.tags)
const processHasWeaveDrive = moduleHasWeaveDrive || processExtensions.includes("WeaveDrive")

if (!processHasWeaveDrive) {
Expand Down Expand Up @@ -471,7 +471,7 @@ module.exports = function weaveDrive(mod, FS) {
[
this.getTagValue('Scheduler', mod.spawn.tags),
...this.getTagValues("Attestor", mod.spawn.tags)
]
].filter(t => !!t)
)

// Init a set of GraphQL queries to run in order to find a valid attestation
Expand Down Expand Up @@ -510,7 +510,7 @@ module.exports = function weaveDrive(mod, FS) {
owners: ${attestors},
block: {min: 0, max: ${blockHeight}},
tags: [
{ name: "Data-Protocol", values: ["WeaveDrive"],
{ name: "Data-Protocol", values: ["WeaveDrive"] },
{ name: "Type", values: ["Available"]},
{ name: "ID", values: ["${ID}"]}
]
Expand Down Expand Up @@ -564,10 +564,11 @@ module.exports = function weaveDrive(mod, FS) {
return values.pop()
},

async queryHasResult(query) {
const results = await mod.arweave.api.post('/graphql', query);
const json = JSON.parse(results)
return json.data.transactions.edges.length > 0
async queryHasResult(query, variables) {
const json = await this.gqlQuery(query, variables)
.then((res) => res.json())

return !!json?.data?.transactions?.edges?.length
},

async gqlExists() {
Expand Down
Loading

0 comments on commit 3cb68d6

Please sign in to comment.