generated from twilson63/hypar
-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.mjs
34 lines (26 loc) · 1 KB
/
deploy.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Bundlr from '@bundlr-network/client'
import { WarpFactory, defaultCacheOptions } from 'warp-contracts/mjs'
import fs from 'fs'
import Arweave from 'arweave'
const ANT = 'tsHGCpmFMcvvc-aH7nbsP007PHkY00GmFHpKxDdcplA'
const arweave = Arweave.init({ host: 'arweave.net', port: 443, protocol: 'https' })
//const jwk = JSON.parse(fs.readFileSync('../wallet.json', 'utf-8'))
const jwk = JSON.parse(Buffer.from(process.env.ARNS, 'base64').toString('utf-8'))
const bundlr = new Bundlr.default('https://node2.bundlr.network', 'arweave', jwk)
const warp = WarpFactory.custom(
arweave,
defaultCacheOptions,
'mainnet'
).useArweaveGateway().build()
const contract = warp.contract(ANT).connect(jwk)
// upload folder
const result = await bundlr.uploadFolder('./dist', {
indexFile: 'index.html'
})
// update ANT
await contract.writeInteraction({
function: 'setRecord',
subDomain: '@',
transactionId: result.id
})
console.log('Deployed pst.arweave.dev, please wait 20 - 30 minutes for ArNS to update! ', result.id)