Skip to content

Commit

Permalink
ci: add step to update ArNS for cookbook_ao #1
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Jan 8, 2024
1 parent 70ae525 commit b580fbc
Show file tree
Hide file tree
Showing 4 changed files with 1,010 additions and 325 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ jobs:
| jq -r '.created[0].dataTxId'
)
echo "folder_id=${FOLDER_ID}" >> $GITHUB_OUTPUT
echo "tx_id=${MANIFEST_TRANSACTION_ID}" >> $GITHUB_OUTPUT
echo "Updating ArNS for cookbook_ao..."
MANIFEST_ID="${MANIFEST_TRANSACTION_ID}" npm run arns
env:
WALLET: ${{ steps.wallet_file.outputs.filePath }}
ARTIFACTS_HASH: ${{ steps.build_artifacts.outputs.artifacts_hash }}
Expand Down
52 changes: 52 additions & 0 deletions deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { readFileSync } from "node:fs";

import { WarpFactory, defaultCacheOptions } from "warp-contracts";
import Arweave from "arweave";

function env(key) {
if (!process.env[key]) {
throw new Error(`Error with ENV VAR: ${key}`);
}
return process.env[key];
}

const actions = {
async UPDATE_ARNS() {
const WALLET = env("WALLET");
const MANIFEST_ID = env("MANIFEST_ID");

const jwk = JSON.parse(readFileSync(WALLET));

/**
* The ao ANT Contract
* See https://sonar.warp.cc/?#/app/contract/uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg?network=mainnet%23
*/
const ANT = "uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg";

const arweave = Arweave.init({
host: "arweave.net",
port: 443,
protocol: "https",
});
const warp = WarpFactory.custom(arweave, defaultCacheOptions, "mainnet")
.useArweaveGateway()
.build();

// Update the ao ANT Contract to point to the new install script
const aoAntContract = warp.contract(ANT).connect(jwk);
const antUpdate = await aoAntContract.writeInteraction({
function: "setRecord",
subDomain: "cookbook",
transactionId: MANIFEST_ID,
});

console.log("Updated ao ANT record", antUpdate.interactionTx);

return MANIFEST_ID;
},
};

const ACTION = env("ACTION");
if (!actions[ACTION]) throw new Error(`'${ACTION}' is not a valid action`);

actions[ACTION]().catch(console.error);
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@
"name": "docs",
"version": "0.0.1",
"description": "ao Cookbook",
"type": "module",
"authors": {
"name": "Tyler Hall",
"email": "[email protected]"
},
"repository": "https://github.com/permaweb/ao-cookbook",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"prepare": "husky install",
"staged": "lint-staged --allow-empty --concurrent false",
"dev": "vitepress dev src",
"arns": "ACTION=UPDATE_ARNS node deploy.js",
"build": "vitepress build src",
"preview": "vitepress preview src"
"dev": "vitepress dev src",
"prepare": "husky install",
"preview": "vitepress preview src",
"staged": "lint-staged --allow-empty --concurrent false"
},
"license": "Apache-2.0",
"devDependencies": {
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"arweave": "^1.14.4",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"markdown-toc-gen": "^1.0.1",
"prettier": "^3.1.1",
"vitepress": "1.0.0-rc.36",
"vue": "^3.4.6"
"vue": "^3.4.6",
"warp-contracts": "^1.4.32"
},
"authors": {
"name": "Tyler Hall",
"email": "[email protected]"
}
}
Loading

0 comments on commit b580fbc

Please sign in to comment.