-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
511 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,108 @@ | ||
import { connect, createDataItemSigner } from "@permaweb/aoconnect"; | ||
import { createDataItemSigner as nodeCDIS } from "@permaweb/aoconnect/node"; | ||
|
||
const AppVersion = "3.0.0"; | ||
export const AOModule = "nI_jcZgPd0rcsnjaHtaaJPpMCW847ou-3RGA5_W3aZg"; | ||
export const AOScheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"; | ||
|
||
export const APM_ID = "UdPDhw5S7pByV3pVqwyr1qzJ8mR8ktzi9olgsdsyZz4" | ||
export const APM_ID = "UdPDhw5S7pByV3pVqwyr1qzJ8mR8ktzi9olgsdsyZz4"; | ||
|
||
export const modules = { | ||
"Default (WASM64)": AOModule, | ||
"WASM32 (old)": "1PdCJiXhNafpJbvC-sjxWTeNzbf9Q_RfUNs84GYoPm0", | ||
"SQLite64": "z9iaKddl-rIBinPG7_3-oLAdgIujPPPCbUul5mBSIOk", | ||
"SQLite32 (old)": "GYrbbe0VbHim_7Hi6zrOpHQXrSQz07XNtwCnfbFo2I0" | ||
} | ||
|
||
"Default (WASM64)": AOModule, | ||
"WASM32 (old)": "1PdCJiXhNafpJbvC-sjxWTeNzbf9Q_RfUNs84GYoPm0", | ||
SQLite64: "z9iaKddl-rIBinPG7_3-oLAdgIujPPPCbUul5mBSIOk", | ||
"SQLite32 (old)": "GYrbbe0VbHim_7Hi6zrOpHQXrSQz07XNtwCnfbFo2I0", | ||
}; | ||
|
||
const CommonTags = [ | ||
{ name: "App-Name", value: "BetterIDEa" }, | ||
{ name: "App-Version", value: AppVersion }, | ||
{ name: "App-Name", value: "BetterIDEa" }, | ||
{ name: "App-Version", value: AppVersion }, | ||
]; | ||
|
||
type Tags = { name: string, value: string }[]; | ||
type Tags = { name: string; value: string }[]; | ||
|
||
export async function spawnProcess(name?: string, tags?: Tags, newProcessModule?: string) { | ||
const ao = connect(); | ||
|
||
if (tags) { | ||
tags = [...CommonTags, ...tags]; | ||
} else { | ||
tags = CommonTags; | ||
} | ||
tags = name ? [...tags, { name: "Name", value: name }] : tags; | ||
|
||
const result = await ao.spawn({ | ||
module: newProcessModule ? newProcessModule : AOModule, | ||
scheduler: AOScheduler, | ||
tags, | ||
signer: createDataItemSigner(window.arweaveWallet), | ||
}); | ||
|
||
return result; | ||
const ao = connect(); | ||
|
||
if (tags) { | ||
tags = [...CommonTags, ...tags]; | ||
} else { | ||
tags = CommonTags; | ||
} | ||
tags = name ? [...tags, { name: "Name", value: name }] : tags; | ||
|
||
console.log(window.arweaveWallet); | ||
const result = await ao.spawn({ | ||
module: newProcessModule ? newProcessModule : AOModule, | ||
scheduler: AOScheduler, | ||
tags, | ||
signer: window.arweaveWallet?.signDataItem ? createDataItemSigner(window.arweaveWallet) : nodeCDIS(window.arweaveWallet), | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
export async function runLua(code: string, process: string, tags?: Tags) { | ||
const ao = connect(); | ||
|
||
if (tags) { | ||
tags = [...CommonTags, ...tags]; | ||
} else { | ||
tags = CommonTags; | ||
} | ||
|
||
|
||
// if (!window.arweaveWallet) { | ||
// const dryMessage = await ao.dryrun({ | ||
// process, | ||
// data: code, | ||
// tags, | ||
// }); | ||
// return dryMessage | ||
// } | ||
|
||
tags = [...tags, { name: "Action", value: "Eval" }]; | ||
|
||
const message = await ao.message({ | ||
process, | ||
data: code, | ||
signer: createDataItemSigner(window.arweaveWallet), | ||
tags, | ||
}); | ||
|
||
const result = await ao.result({ process, message }); | ||
// console.log(result); | ||
return result; | ||
const ao = connect(); | ||
|
||
if (tags) { | ||
tags = [...CommonTags, ...tags]; | ||
} else { | ||
tags = CommonTags; | ||
} | ||
|
||
// if (!window.arweaveWallet) { | ||
// const dryMessage = await ao.dryrun({ | ||
// process, | ||
// data: code, | ||
// tags, | ||
// }); | ||
// return dryMessage | ||
// } | ||
|
||
tags = [...tags, { name: "Action", value: "Eval" }]; | ||
|
||
const message = await ao.message({ | ||
process, | ||
data: code, | ||
signer: window.arweaveWallet?.signDataItem ? createDataItemSigner(window.arweaveWallet) : nodeCDIS(window.arweaveWallet), | ||
tags, | ||
}); | ||
|
||
const result = await ao.result({ process, message }); | ||
// console.log(result); | ||
return result; | ||
} | ||
|
||
export async function getResults(process: string, cursor = "") { | ||
const ao = connect(); | ||
|
||
const r = await ao.results({ | ||
process, | ||
from: cursor, | ||
sort: "ASC", | ||
limit: 999999, | ||
}); | ||
|
||
if (r.edges.length > 0) { | ||
const newCursor = r.edges[r.edges.length - 1].cursor; | ||
const results = r.edges.map((e) => e.node); | ||
return { cursor: newCursor, results }; | ||
} else { | ||
return { cursor, results: [] }; | ||
} | ||
const ao = connect(); | ||
|
||
const r = await ao.results({ | ||
process, | ||
from: cursor, | ||
sort: "ASC", | ||
limit: 999999, | ||
}); | ||
|
||
if (r.edges.length > 0) { | ||
const newCursor = r.edges[r.edges.length - 1].cursor; | ||
const results = r.edges.map((e) => e.node); | ||
return { cursor: newCursor, results }; | ||
} else { | ||
return { cursor, results: [] }; | ||
} | ||
} | ||
|
||
export function parseOutupt(out: any) { | ||
if (!out.Output) return out; | ||
const data = out.Output.data; | ||
const { json, output } = data | ||
if (json != "undefined") { | ||
return json; | ||
} | ||
try { | ||
return JSON.parse(output); | ||
} catch (e) { | ||
return output; | ||
} | ||
if (!out.Output) return out; | ||
const data = out.Output.data; | ||
const { json, output } = data; | ||
if (json != "undefined") { | ||
return json; | ||
} | ||
try { | ||
return JSON.parse(output); | ||
} catch (e) { | ||
return output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.