Skip to content

Commit

Permalink
ci(dev-cli): update deploy to use ar.io sdk and ant process to update…
Browse files Browse the repository at this point in the history
… install undername
  • Loading branch information
TillaTheHun0 committed Aug 8, 2024
1 parent 59a4b36 commit b865897
Show file tree
Hide file tree
Showing 4 changed files with 1,458 additions and 643 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/dev-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ jobs:
fileName: wallet.json
encodedString: ${{ secrets.CI_WALLET }}

- name: 🔬 Decode ArNS Wallet JSON File
uses: timheuer/base64-to-file@v1
id: arns_wallet_file
with:
fileName: arns_wallet.json
encodedString: ${{ secrets.CI_AO_ARNS_WALLET }}

# The version in the manifest is used to set the version
# displayed for the CI. So we need to update version,
# prior to building the binaries
Expand Down Expand Up @@ -261,7 +268,8 @@ jobs:
echo "tx_id=${INSTALL_TRANSACTION_ID}" >> $GITHUB_OUTPUT
env:
WALLET: ${{ steps.wallet_file.outputs.filePath }}
# A seprate wallet controls the AO ANT, so we use it to update ArNS
WALLET: ${{ steps.arns_wallet_file.outputs.filePath }}
FOLDER_ID: ${{ steps.publish_binaries.outputs.folder_id }}
INSTALL_SCRIPT: ${{ steps.build_install_script.outputs.install_script }}

Expand Down
40 changes: 14 additions & 26 deletions dev-cli/tools/deploy/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { readFileSync } from 'node:fs'

import { WarpFactory, defaultCacheOptions } from 'warp-contracts'
import Arweave from 'arweave'
import { ANT, ArweaveSigner } from '@ar.io/sdk'
import { z } from 'zod'

function env (key) {
Expand All @@ -13,16 +12,6 @@ function env (key) {
return res.data
}

/**
* Add U Tags in order to Mint U as part of CI
*/
// const U_TAGS = [
// { name: 'App-Name', value: 'SmartWeaveAction' },
// { name: 'App-Version', value: '0.3.0' },
// { name: 'Input', value: JSON.stringify({ function: 'mint' }) },
// { name: 'Contract', value: 'KTzTXT_ANmF84fWEKHzWURD1LWd9QaFR9yfYUwH2Lxw' }
// ]

const actions = {
async UPDATE_ARNS () {
const WALLET = env('WALLET')
Expand All @@ -34,20 +23,19 @@ const actions = {
* The install_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: 'install',
transactionId: INSTALL_SCRIPT_ID
})

console.log('Updated ao ANT record', antUpdate.interactionTx)
// const ANT = 'uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg'
const ANT_PROCESS = 'YFbfeqZMbPVGFjQ-PHJY-Y99JQu7O3Jdet06pJnD5iI'

const signer = new ArweaveSigner(jwk)
const ant = ANT.init({ processId: ANT_PROCESS, signer })

await ant
.setRecord({
undername: 'install',
transactionId: INSTALL_SCRIPT_ID,
ttlSeconds: 3600
})
.then((res) => console.log('Updated ao install ANT record', res.id))

return INSTALL_SCRIPT_ID
}
Expand Down
Loading

0 comments on commit b865897

Please sign in to comment.