Skip to content

Commit

Permalink
merge resolve + mobile test
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushKun committed Jun 20, 2024
2 parents 2cb5530 + 3b9f9ad commit a6d4166
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 656 deletions.
3 changes: 2 additions & 1 deletion next_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@betteridea/codecell": "^1.4.0",
"@monaco-editor/react": "^4.6.0",
"@next/third-parties": "^14.2.3",
"@permaweb/aoconnect": "^0.0.52",
"@permaweb/aoconnect": "^0.0.56",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
Expand All @@ -39,6 +39,7 @@
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
"ansi-to-react": "^6.1.6",
"arweave": "^1.15.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^0.2.1",
Expand Down
25 changes: 14 additions & 11 deletions next_app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions next_app/public/icon-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
168 changes: 84 additions & 84 deletions next_app/src/lib/ao-vars.ts
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;
}
}
21 changes: 10 additions & 11 deletions next_app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@/styles/globals.css";
import 'katex/dist/katex.min.css';
import "@xterm/xterm/css/xterm.css"
import "katex/dist/katex.min.css";
import "@xterm/xterm/css/xterm.css";
import type { AppProps } from "next/app";
import { Toaster } from "@/components/ui/toaster";
import { Toaster as Sonner } from "@/components/ui/sonner";
Expand All @@ -9,16 +9,15 @@ import { GoogleAnalytics } from "@next/third-parties/google";
import { useEffect, useState } from "react";
// import { GoogleAnalytics } from "nextjs-google-analytics";



declare global {
interface Window {
arweaveWallet: {
connect: Function;
disconnect: Function;
getActiveAddress: Function;
};
}
interface Window {
arweaveWallet: {
connect: Function;
disconnect: Function;
getActiveAddress: Function;
signDataItem: Function;
};
}
}

export default function App({ Component, pageProps }: AppProps) {
Expand Down
Loading

0 comments on commit a6d4166

Please sign in to comment.