-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension): add sandbox for running smart contracts
- Loading branch information
Showing
170 changed files
with
564 additions
and
463 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
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
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,3 +1,3 @@ | ||
import postcssConfig from "@palladxyz/features/postcss.config.mjs" | ||
import postcssConfig from "@palladco/features/postcss.config.mjs" | ||
|
||
export default postcssConfig |
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Pallad</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/sandbox/index.ts"></script> | ||
</body> | ||
</html> |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Add } from "@palladco/contracts" | ||
import { match } from "ts-pattern" | ||
|
||
window.addEventListener("message", async (event) => { | ||
return match(event.data.type) | ||
.with("compile", async () => { | ||
await Add.compile() | ||
window.parent.postMessage({ type: "compiled" }, "*") | ||
}) | ||
.run() | ||
}) |
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
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
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
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,3 +1,3 @@ | ||
# @palladxyz/template | ||
# @palladco/template | ||
|
||
This is a boilerplate for creating new modules of the wallet. |
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
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,3 +1,3 @@ | ||
{ | ||
"extends": "@palladxyz/common/tsconfig.json" | ||
"extends": "@palladco/common/tsconfig.json" | ||
} |
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
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,3 +1,3 @@ | ||
# @palladxyz/common | ||
# @palladco/common | ||
|
||
The proto-package for shareable common configuration. |
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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "@palladco/contracts", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "bunx --bun tsc", | ||
"test:unit": "bun test", | ||
"coverage": "bun test --coverage", | ||
"cleanup": "bunx --bun rimraf node_modules dist .turbo" | ||
}, | ||
"dependencies": { | ||
"o1js": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@palladco/common": "workspace:*" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { beforeAll, describe, expect, it } from "bun:test" | ||
import { AccountUpdate, Field, Mina, PrivateKey } from "o1js" | ||
import { Add } from "./add" | ||
|
||
describe("Add", () => { | ||
beforeAll(async () => { | ||
await Add.compile() | ||
}) | ||
|
||
it("works lol", async () => { | ||
const Local = await Mina.LocalBlockchain({ proofsEnabled: true }) | ||
Mina.setActiveInstance(Local) | ||
const [deployerAccount] = Local.testAccounts | ||
const zkAppPrivateKey = PrivateKey.random() | ||
const zkAppAddress = zkAppPrivateKey.toPublicKey() | ||
const zkApp = new Add(zkAppAddress) | ||
const txn = await Mina.transaction(deployerAccount, async () => { | ||
AccountUpdate.fundNewAccount(deployerAccount) | ||
await zkApp.deploy() | ||
}) | ||
await txn.prove() | ||
await txn.sign([deployerAccount.key, zkAppPrivateKey]).send() | ||
const num = zkApp.num.get() | ||
expect(num).toEqual(Field(1)) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Field, SmartContract, State, method, state } from "o1js" | ||
|
||
/** | ||
* Basic Example | ||
* See https://docs.minaprotocol.com/zkapps for more info. | ||
* | ||
* The Add contract initializes the state variable 'num' to be a Field(1) value by default when deployed. | ||
* When the 'update' method is called, the Add contract adds Field(2) to its 'num' contract state. | ||
* | ||
* This file is safe to delete and replace with your own contract. | ||
*/ | ||
export class Add extends SmartContract { | ||
@state(Field) num = State<Field>() | ||
|
||
init() { | ||
super.init() | ||
this.num.set(Field(1)) | ||
} | ||
|
||
@method async update() { | ||
const currentState = this.num.getAndRequireEquals() | ||
const newState = currentState.add(2) | ||
this.num.set(newState) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Add } from "./add/add" |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"extends": "@palladco/common/tsconfig.json", | ||
"compilerOptions": { | ||
// "experimentalDecorators": true, | ||
// "noImplicitOverride": false, | ||
// "strictPropertyInitialization": false, | ||
// "skipLibCheck": true, | ||
// "emitDecoratorMetadata": true, | ||
// "useDefineForClassFields": false, | ||
"target": "es2020", | ||
"module": "es2022", | ||
"strictPropertyInitialization": false, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"allowJs": true, | ||
"declaration": true, | ||
"sourceMap": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"allowSyntheticDefaultImports": true, | ||
"useDefineForClassFields": false, | ||
"noImplicitOverride": false, | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { baseTsupConfig } from "@palladco/common" | ||
import { defineConfig } from "tsup" | ||
|
||
import packageJson from "./package.json" | ||
|
||
export default defineConfig([ | ||
{ | ||
...baseTsupConfig, | ||
name: packageJson.name, | ||
splitting: false, | ||
}, | ||
]) |
Oops, something went wrong.