-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
80 lines (68 loc) · 2.02 KB
/
deploy.js
File metadata and controls
80 lines (68 loc) · 2.02 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { createDataItemSigner, spawn, message } from "@permaweb/aoconnect";
import { bundle } from 'luabundle';
import fs from 'fs';
// Constants
const MODULE = "ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw";
const SCHEDULER = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
const AUTHORITY = "fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY";
// Load wallet
const pathToWallet = 'wallet.json';
// Check if wallet exists
if (!fs.existsSync(pathToWallet)) {
throw new Error('wallet.json not found in the root directory');
}
const walletData = fs.readFileSync(pathToWallet, 'utf-8');
const wallet = JSON.parse(walletData);
// Bundle Lua code
const bundledLua = bundle('./src/main.lua', {
luaVersion: '5.3',
force: true,
ignoredModuleNames: ["json"],
paths: [
'lib/share/lua/5.3/?.lua',
'?.lua',
'./.?lua',
'./**?.lua',
'./**/**?.lua',
'./**/**/**?.lua',
'./**/**/**/**?.lua',
'./**/**/**/**/**?.lua',
'?',
'./.?',
'./**?',
'./**/**?',
'./**/**/**?',
'./**/**/**/**?',
'./**/**/**/**/**?'
]
});
async function deploy() {
try {
// Spawn process
const processId = await spawn({
module: MODULE,
scheduler: SCHEDULER,
signer: createDataItemSigner(wallet),
tags: [
{ name: "Authority", value: AUTHORITY },
]
});
console.log('Process ID:', processId);
// Save process ID to file
fs.writeFileSync('process_id.log', `Process ID: ${processId}\n`);
// Send evaluation message
const messageId = await message({
process: processId,
signer: createDataItemSigner(wallet),
tags: [
{ name: "Action", value: "Eval" },
],
data: bundledLua
});
console.log('Message ID:', messageId);
} catch (error) {
console.error('Deployment failed:', error);
process.exit(1);
}
}
deploy();