Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
arjanjohan committed Jul 10, 2024
1 parent 6adeb12 commit c40f9f3
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 38 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<a href="https://scaffold-move-chi.vercel.app/">Website</a>
</h4>

🧪 An open-source, up-to-date toolkit for building decentralized applications (dapps) on Move blockchains like Aptos and Movement M1. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts.
🧪 An open-source, up-to-date toolkit for building decentralized applications (dapps) on Move blockchains like Aptos and Movement M1. It's designed to make it easier for developers to create and deploy Move modules and build user interfaces that interact with those modules.

⚙️ Built using NextJS, Tailwind and Typescript.

-**Contract Hot Reload**: Your frontend auto-adapts to your smart contract as you edit it.
-**Module Hot Reload**: Your frontend auto-adapts to your Move modules as you edit it.
- 🪝 **[Custom hooks](https://docs.scaffoldeth.io/hooks/)**: Collection of React hooks to simplify interactions with Move modules .
- 🧱 [**Components**](https://docs.scaffoldeth.io/components/): Collection of common web3 components to quickly build your frontend.
- 🔐 **Integration with Wallet Providers**: Connect your Petra Wallet and interact with the Aptos or Movement M1 network.

![Debug Contracts tab](assets/debug.png)
![Debug Modules tab](assets/debug.png)

## Requirements

Expand Down Expand Up @@ -58,21 +58,21 @@ This command overwrites `packages/move/.aptos/config.yaml` with a new Aptos acco
yarn deploy
```

This command deploys the move modules to the selected network. The contract is located in `packages/move/sources` and can be modified to suit your needs. The `yarn deploy` command uses `movement aptos move publish` to publish the modules to the network. After this is executes the script located in `scripts/loadContracts.js` to make the new contracts available in the nextjs frontend.
This command deploys the move modules to the selected network. The contract is located in `packages/move/sources` and can be modified to suit your needs. The `yarn deploy` command uses `movement aptos move publish` to publish the modules to the network. After this is executes the script located in `scripts/loadContracts.js` to make the new modules available in the nextjs frontend.

5. On a third terminal, start your NextJS app:

```
yarn start
```

Visit your app on: `http://localhost:3000`. You can interact with your smart contract using the `Debug Contracts` page. You can tweak the app config in `packages/nextjs/scaffold.config.ts`.
Visit your app on: `http://localhost:3000`. You can interact with your Move modules using the `Debug Modules` page. You can tweak the app config in `packages/nextjs/scaffold.config.ts`.

**What's next**:

- Edit your smart contract `OnchainBio.move` in `packages/move/sources`
- Edit your Move module `OnchainBio.move` in `packages/move/sources`
- Edit your frontend homepage at `packages/nextjs/app/page.tsx`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation.
<!-- - Edit your smart contract test in: `packages/hardhat/test`. To run test use `yarn hardhat:test` -->
<!-- - Edit your Move modules test in: `packages/hardhat/test`. To run test use `yarn hardhat:test` -->

## Next steps

Expand All @@ -84,7 +84,7 @@ For this hackathon I kept the scope small due to the time constraints. I build o
- Styling for Resources tab
- Group contracts under address in liss
- Fix colors for dark mode
- Ensure export default deployedContracts satisfies GenericContractsDeclaration
- Ensure export default deployedModules satisfies GenericContractsDeclaration
- Add block explorer page

## Links
Expand Down
4 changes: 2 additions & 2 deletions packages/move/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ git = 'https://github.com/aptos-labs/aptos-core.git'
rev = 'main'
subdir = 'aptos-move/framework/aptos-framework'
[addresses]
OnchainBio='0x3f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b'
lottery_addr="0x40311704088e14867deda2e4cb49a2606e4fc21df6d7a51226a91ddbd0ba4e78"
OnchainBio='0x4db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752'
lottery_addr='0x40311704088e14867deda2e4cb49a2606e4fc21df6d7a51226a91ddbd0ba4e78'
8 changes: 4 additions & 4 deletions packages/nextjs/app/debug/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import type { NextPage } from "next";
import { getMetadata } from "~~/utils/scaffold-move/getMetadata";

export const metadata = getMetadata({
title: "Debug Contracts",
description: "Debug your deployed 🏗 Scaffold-Move contracts in an easy way",
title: "Debug Modules",
description: "Debug your deployed 🏗 Scaffold-Move modules in an easy way",
});

const Debug: NextPage = () => {
return (
<>
<DebugContracts />
<div className="text-center mt-8 bg-secondary p-10">
<h1 className="text-4xl my-0">Debug Contracts</h1>
<h1 className="text-4xl my-0">Debug Modules</h1>
<p className="text-neutral">
You can debug & interact with your deployed contracts here.
You can debug & interact with your deployed modules here.
<br /> Check{" "}
<code className="italic bg-base-300 text-base font-bold [word-spacing:-0.5rem] px-1">
packages / nextjs / app / debug / page.tsx
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Home: NextPage = () => {
<p>
Tinker with your smart contract using the{" "}
<Link href="/debug" passHref className="link">
Debug Contracts
Debug Modules
</Link>{" "}
tab.
</p>
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const menuLinks: HeaderMenuLink[] = [
href: "/bio",
},
{
label: "Debug Contracts",
label: "Debug Modules",
href: "/debug",
icon: <BugAntIcon className="h-4 w-4" />,
},
Expand Down
17 changes: 8 additions & 9 deletions packages/nextjs/contracts/deployedModules.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { GenericContractsDeclaration } from "~~/utils/scaffold-move/contract";

const deployedContracts = {
const deployedModules = {
"devnet": {
"onchain_bio": {
"bytecode": "0xa11ceb0b060000000a010006020608030e0f051d1307304a087a4010ba01220adc01090ce501340d99020200000101010200030e0002040700000500010000060203000109050000010501080103060c080108010001080001060c0b6f6e636861696e5f62696f067369676e657206737472696e670342696f06537472696e67076765745f62696f087265676973746572046e616d650362696f0a616464726573735f6f663f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b0000000000000000000000000000000000000000000000000000000000000001126170746f733a3a6d657461646174615f76310e000001076765745f62696f010100000202070801080801000100010003050b002b0010001402010104010004100a001102290004080a0011022c00010b010b0212000c030b000b032d0002000100",
"abi": {"address":"0x3f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b","name":"onchain_bio","friends":[],"exposed_functions":[{"name":"get_bio","visibility":"public","is_entry":false,"is_view":true,"generic_type_params":[],"params":["address"],"return":["0x1::string::String"]},{"name":"register","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String"],"return":[]}],"structs":[{"name":"Bio","is_native":false,"abilities":["drop","store","key"],"generic_type_params":[],"fields":[{"name":"name","type":"0x1::string::String"},{"name":"bio","type":"0x1::string::String"}]}]}
"bytecode": "0xa11ceb0b060000000a010006020608030e0f051d1307304a087a4010ba01220adc01090ce501340d99020200000101010200030e0002040700000500010000060203000109050000010501080103060c080108010001080001060c0b6f6e636861696e5f62696f067369676e657206737472696e670342696f06537472696e67076765745f62696f087265676973746572046e616d650362696f0a616464726573735f6f664db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a187520000000000000000000000000000000000000000000000000000000000000001126170746f733a3a6d657461646174615f76310e000001076765745f62696f010100000202070801080801000100010003050b002b0010001402010104010004100a001102290004080a0011022c00010b010b0212000c030b000b032d0002000100",
"abi": {"address":"0x4db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752","name":"onchain_bio","friends":[],"exposed_functions":[{"name":"get_bio","visibility":"public","is_entry":false,"is_view":true,"generic_type_params":[],"params":["address"],"return":["0x1::string::String"]},{"name":"register","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String"],"return":[]}],"structs":[{"name":"Bio","is_native":false,"abilities":["drop","store","key"],"generic_type_params":[],"fields":[{"name":"name","type":"0x1::string::String"},{"name":"bio","type":"0x1::string::String"}]}]}
},
"onchain_poems": {
"bytecode": "0xa11ceb0b060000000b010004020408030c0a05161207284c08744006b4010a10be013a0af8010c0c8402260daa02020000010100020e000103070000040001000005020300010501080104060c080108010801000108000d6f6e636861696e5f706f656d7306737472696e670b496e736372697074696f6e06537472696e67086765745f706f656d08726567697374657204706f656d057469746c6506617574686f723f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f7631260101000000000000000d455f414c52454144595f484153000001086765745f706f656d010100000203060801070801080801000100010003050b002b00100014020101040004090b010b020b0312000c040b000b042d0002000000",
"abi": {"address":"0x3f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b","name":"onchain_poems","friends":[],"exposed_functions":[{"name":"get_poem","visibility":"public","is_entry":false,"is_view":true,"generic_type_params":[],"params":["address"],"return":["0x1::string::String"]},{"name":"register","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String"],"return":[]}],"structs":[{"name":"Inscription","is_native":false,"abilities":["drop","store","key"],"generic_type_params":[],"fields":[{"name":"poem","type":"0x1::string::String"},{"name":"title","type":"0x1::string::String"},{"name":"author","type":"0x1::string::String"}]}]}
"bytecode": "0xa11ceb0b060000000b010004020408030c0a05161207284c08744006b4010a10be013a0af8010c0c8402260daa02020000010100020e000103070000040001000005020300010501080104060c080108010801000108000d6f6e636861696e5f706f656d7306737472696e670b496e736372697074696f6e06537472696e67086765745f706f656d08726567697374657204706f656d057469746c6506617574686f724db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f7631260101000000000000000d455f414c52454144595f484153000001086765745f706f656d010100000203060801070801080801000100010003050b002b00100014020101040004090b010b020b0312000c040b000b042d0002000000",
"abi": {"address":"0x4db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752","name":"onchain_poems","friends":[],"exposed_functions":[{"name":"get_poem","visibility":"public","is_entry":false,"is_view":true,"generic_type_params":[],"params":["address"],"return":["0x1::string::String"]},{"name":"register","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String"],"return":[]}],"structs":[{"name":"Inscription","is_native":false,"abilities":["drop","store","key"],"generic_type_params":[],"fields":[{"name":"poem","type":"0x1::string::String"},{"name":"title","type":"0x1::string::String"},{"name":"author","type":"0x1::string::String"}]}]}
},
"onchain_poems_with_table": {
"bytecode": "0xa11ceb0b060000000c01000a020a14031e23044106054739078001bb0108bb024006fb020a1085033a0abf031c0cdb036f0dca0404000001010102010301040005070000060800030707000410040203010001000800010000090201000212020400041306010203020114080101060415010a02030403050407050504060c0802080208020001060c040308000708010501050203080003070b03020900090109000901010800010900010801010b030209000901186f6e636861696e5f706f656d735f776974685f7461626c65056576656e74067369676e657206737472696e67057461626c6504506f656d08506f656d4c69737406537472696e670b6372656174655f706f656d106372656174655f706f656d5f6c69737407706f656d5f6964076164647265737304706f656d057469746c6506617574686f7205706f656d73055461626c650c706f656d5f636f756e7465720a616464726573735f6f660675707365727404656d6974036e65773f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f76312601010000000000000011455f4e4f545f494e495449414c495a4544000104506f656d010400000002050a030b050c08020d08020e08020102020f0b03020308001103000104010103250b0011020c070a072901040705090700270a072a010c060a06100014060100000000000000160c040a040b070b010b020b0312000c050a060f010a040a0538000b040b060f00150b05380102010104000908380206000000000000000012010c010b000b012d01020101010000",
"abi": {"address":"0x3f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b","name":"onchain_poems_with_table","friends":[],"exposed_functions":[{"name":"create_poem","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String"],"return":[]},{"name":"create_poem_list","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer"],"return":[]}],"structs":[{"name":"Poem","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"poem_id","type":"u64"},{"name":"address","type":"address"},{"name":"poem","type":"0x1::string::String"},{"name":"title","type":"0x1::string::String"},{"name":"author","type":"0x1::string::String"}]},{"name":"PoemList","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"poems","type":"0x1::table::Table<u64, 0x3f32da4435bc9112127ea9823ae5bd788a0f42993b3f025fcdfad05b8fb2bc4b::onchain_poems_with_table::Poem>"},{"name":"poem_counter","type":"u64"}]}]}
"bytecode": "0xa11ceb0b060000000c01000a020a14031e23044106054739078001bb0108bb024006fb020a1085033a0abf031c0cdb036f0dca0404000001010102010301040005070000060800030707000410040203010001000800010000090201000212020400041306010203020114080101060415010a02030403050407050504060c0802080208020001060c040308000708010501050203080003070b03020900090109000901010800010900010801010b030209000901186f6e636861696e5f706f656d735f776974685f7461626c65056576656e74067369676e657206737472696e67057461626c6504506f656d08506f656d4c69737406537472696e670b6372656174655f706f656d106372656174655f706f656d5f6c69737407706f656d5f6964076164647265737304706f656d057469746c6506617574686f7205706f656d73055461626c650c706f656d5f636f756e7465720a616464726573735f6f660675707365727404656d6974036e65774db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f76312601010000000000000011455f4e4f545f494e495449414c495a4544000104506f656d010400000002050a030b050c08020d08020e08020102020f0b03020308001103000104010103250b0011020c070a072901040705090700270a072a010c060a06100014060100000000000000160c040a040b070b010b020b0312000c050a060f010a040a0538000b040b060f00150b05380102010104000908380206000000000000000012010c010b000b012d01020101010000",
"abi": {"address":"0x4db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752","name":"onchain_poems_with_table","friends":[],"exposed_functions":[{"name":"create_poem","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String"],"return":[]},{"name":"create_poem_list","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer"],"return":[]}],"structs":[{"name":"Poem","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"poem_id","type":"u64"},{"name":"address","type":"address"},{"name":"poem","type":"0x1::string::String"},{"name":"title","type":"0x1::string::String"},{"name":"author","type":"0x1::string::String"}]},{"name":"PoemList","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"poems","type":"0x1::table::Table<u64, 0x4db9deb83301bbd2192e6627444fb2c85fda167d830e6548d209653816a18752::onchain_poems_with_table::Poem>"},{"name":"poem_counter","type":"u64"}]}]}
}
}
} as const;

export default deployedContracts;
// satisfies GenericContractsDeclaration;
export default deployedModules satisfies GenericContractsDeclaration;
Loading

0 comments on commit c40f9f3

Please sign in to comment.