Skip to content

Commit 2bdcfba

Browse files
Updating react-solidity-remix template
* Deps upgrade * Importing contracts instead of exporting; this allows to drop monorepo and pnpm Fixes #28
1 parent e37d3bd commit 2bdcfba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6489
-90
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ npx create-polkadot-dapp@latest
1818
* [wagmi](https://wagmi.sh/) for smart contract interaction.
1919
* [Tailwind CSS](https://tailwindcss.com) + [Tailwind UI](https://tailwindui.com/).
2020
* [Vite](https://vite.dev/) for dev tooling.
21-
* [react-solidity](https://github.com/paritytech/create-polkadot-dapp/tree/master/templates/react-solidity) (deprecated) a monorepo for smart contracts for AssetHub and a React, [Tailwind CSS](https://tailwindcss.com) and [ethers](https://docs.ethers.org/v6/)
21+
* [react-solidity-remix](https://github.com/paritytech/create-polkadot-dapp/tree/master/templates/react-solidity) (deprecated) a monorepo for smart contracts for AssetHub and a React, [Tailwind CSS](https://tailwindcss.com) and [ethers](https://docs.ethers.org/v6/)
2222

2323
## Planned templates
2424
* papi-nodejs: pure server-side application with polkadot-api
@@ -40,4 +40,4 @@ Add new configuration to `src/templateConfigs/` and export it from `index.ts`. T
4040
### Back sync
4141
It can be more convenient to develop template code outside of `create-polkadot-dapp`.
4242
Use `yarn back-sync --source <spawned_repo_path> --template <template_name>` to sync files from a spawned repo back into the template.
43-
`backSyncPatterns` in template configuration defines an array of regexp for files that are synced.
43+
`back-sync` uses `.gitignore` to filter out files that need syncing.

src/scripts/backSync.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ const alwaysIgnorePatterns = [/^\.papi\/metadata.*/];
2525
const gitignoreContents = fs.readFileSync(path.join(options.source, ".gitignore"), "utf-8");
2626
const gitignoreIg = ignore().add(gitignoreContents);
2727

28+
if (!fs.existsSync(options.source)) {
29+
console.error(`Directory ${options.source} doesn't exist`);
30+
process.exit(1);
31+
}
32+
2833
const watcher = chokidar.watch(options.source, {
2934
persistent: true,
3035
cwd: options.source,
@@ -92,3 +97,5 @@ if (options.rm) {
9297
watcher.on("unlink", unlinkHandler);
9398
watcher.on("unlinkDir", unlinkHandler);
9499
}
100+
101+
watcher.on("error", (error) => console.error(`Watcher error: ${error}`));

src/templateConfigs/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import reactPapiTailwind from "./react-papi-tailwind";
2-
import reactSolidity from "./react-solidity";
32
import reactSolidityHardhat from "./react-solidity-hardhat";
3+
import reactSolidityRemix from "./react-solidity-remix";
44

55
export type TemplateConfig = {
66
setupPapi: boolean;
@@ -10,8 +10,8 @@ export type TemplateConfig = {
1010

1111
export const configs: Record<string, TemplateConfig> = {
1212
"react-papi-tailwind": reactPapiTailwind,
13-
"react-solidity": reactSolidity,
1413
"react-solidity-hardhat": reactSolidityHardhat,
14+
"react-solidity-remix": reactSolidityRemix,
1515
};
1616

1717
export type TemplateNames = keyof typeof configs;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { TemplateConfig } from "#src/templateConfigs/index";
2+
import { colors as c } from "#src/util/log";
3+
4+
const config: TemplateConfig = {
5+
setupPapi: false,
6+
npmRoots: ["contracts", "frontend"],
7+
instructions: `
8+
${c.primary("For Remix environment:")}
9+
${c.primary("1. ")}${c.secondary("install remixd globally: ")}${c.code("npm install -g @remix-project/remixd")}
10+
${c.primary("2. ")}${c.secondary("go to contracts dir: ")}${c.code("cd contracts")}
11+
${c.primary("3. ")}${c.secondary("start remixd environment: ")}${c.code("npm run remixd")}
12+
${c.primary("4. ")}${c.secondary("edit, deploying and pin smart contracts in Remix")}
13+
14+
${c.primary("For local environment:")}
15+
${c.primary("1. ")}${c.secondary("go to contracts dir: ")}${c.code("cd contracts")}
16+
${c.primary("2. ")}${c.secondary("edit and build smart contracts: ")}${c.code("npm run build")}
17+
${c.primary("3. ")}${c.secondary("deploy smart contracts to chain: ")}${c.code("npm run deploy-contracts")}
18+
19+
${c.primary("Use the contract in the frontend app:")}
20+
${c.primary("1. ")}${c.secondary("go to frontend dir: ")}${c.code("cd frontend")}
21+
${c.primary("2. ")}${c.secondary("import contracts: ")}${c.code("npm run import-contracts")}
22+
${c.primary("3. ")}${c.secondary("use smart contract address in ")}${c.code("src/App.tsx")}
23+
${c.primary("4. ")}${c.secondary("start frontend app: ")}${c.code("npm run dev")}
24+
`,
25+
};
26+
27+
export default config;

src/templateConfigs/react-solidity.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
# generated by npm run import-contracts
27+
frontend/src/contracts.js
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# react-solidity template
1+
# react-solidity-remix template
22

33
This template sets up a combination of Solidity smart contracts and a React front-end app that interacts with these
44
smart contracts.
@@ -10,35 +10,35 @@ This template includes
1010

1111
## Writing smart contracts
1212

13-
Currently, two ways of developing smart contracts are supported. Both are deploying to Westend Asset Hub.
13+
Currently, two ways of developing smart contracts are supported. Both are deploying to Passet Hub.
1414

1515
### Remix
1616

17-
1. Run `npm run remixd` in `contracts` dir to start remixd environment.
18-
2. Go to https://remix.polkadot.io and activate REMIXD plugin.
19-
3. Start hacking! Changes performed in Remix will be synced to local file system.
20-
4. After deploying and pinning a smart contract, it'll be saved on your file system, run `npm run export` to
21-
export contract data.
17+
1. Install remixd globally: `npm install -g @remix-project/remixd`
18+
2. Run `npm run remixd` in `contracts` dir to start remixd environment.
19+
3. Go to https://remix.polkadot.io and activate REMIXD plugin.
20+
4. Start hacking! Changes performed in Remix will be synced to local file system.
21+
5. Deploy **and pin** your smart contract; it'll be saved on your file system.
2222

2323
### Local development
2424

25-
1. Edit smart contracts in root directory
26-
2. Run `npm run contracts:build` to compile smart contracts
27-
3. Run `npm run contracts:deploy` to deploy them
25+
1. Edit smart contracts in `contracts` dir.
26+
2. Run `npm run build` to compile smart contracts.
27+
3. Run `npm run deploy-contracts` to deploy them.
2828
Required environment variables:
2929
* `ACCOUNT_SEED`: seed phrase for the account that will sign the deployment.
30-
* `RPC_URL`: for Westend Asset Hub, probably `https://westend-asset-hub-eth-rpc.polkadot.io`, for kitchensink, probably `http://localhost:8545`
31-
4. Run `npm run contracts:export` to export contract data.
30+
* `RPC_URL`: for Passet Hub, `https://testnet-passet-hub-eth-rpc.polkadot.io`, for kitchensink, probably `http://localhost:8545`.
3231

3332
## Interacting with smart contracts from frontend app
3433

35-
1. Run `npm run dev` to start `vite` environment
36-
2. You can import all exported contracts using `import { contracts } from "contracts"`
37-
3. You can call your contracts like this:
34+
1. Run `npm run import-contracts` to generate contracts data from deployed contracts
35+
2. Run `npm run dev` to start `vite` environment
36+
3. You can import all exported contracts using `import { contracts } from "./contracts"`
37+
4. You can call your contracts like this:
3838

3939
```ts
4040
import { Contract, formatEther } from "ethers";
41-
import { contracts, ContractData } from "contracts"
41+
import { contracts, ContractData } from "./contracts"
4242

4343
const contractData: ContractData = contracts["1b5b93a223026219f4f75e5b90c20970ab976451"];
4444
const contract = new Contract(contractData.address, contractData.abi, signer);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"abi": [
3+
{
4+
"inputs": [
5+
{
6+
"internalType": "uint256",
7+
"name": "num",
8+
"type": "uint256"
9+
}
10+
],
11+
"name": "addMoney",
12+
"outputs": [],
13+
"stateMutability": "payable",
14+
"type": "function"
15+
},
16+
{
17+
"inputs": [],
18+
"name": "retrieve",
19+
"outputs": [
20+
{
21+
"internalType": "uint256",
22+
"name": "",
23+
"type": "uint256"
24+
}
25+
],
26+
"stateMutability": "view",
27+
"type": "function"
28+
},
29+
{
30+
"inputs": [
31+
{
32+
"internalType": "uint256",
33+
"name": "num",
34+
"type": "uint256"
35+
}
36+
],
37+
"name": "store",
38+
"outputs": [],
39+
"stateMutability": "nonpayable",
40+
"type": "function"
41+
}
42+
],
43+
"bytecode": "0x50564d0000d506000000000000010700c13000c0008004808f08000000000e0000001c0000002a0000003500000040000000520000005d00000063616c6c5f646174615f636f707963616c6c5f646174615f6c6f616463616c6c5f646174615f73697a656765745f73746f726167657365616c5f72657475726e7365745f696d6d757461626c655f646174617365745f73746f7261676576616c75655f7472616e7366657272656405110285130463616c6c851a066465706c6f790686160d02854e3900bf01c401ea01540260029002ad0378049a0403051a052205390808000251084402330730000383770a052837029511d87b10207b15187b161082897b19088289087b198285108286183308205010023c016f686f59821a6faa821b086fbb787b18787a10787908787898bc38787c1f98bc30787c1e98bc28787c1d98bc20787c1c98bc18787c1b98bc10787c1a98bb08787b1998ab38787b1798ab30787b1698ab28787b1598ab20787b1498ab18787b1398ab10787b1298aa08787a11989a38787a0f989a30787a0e989a28787a0d989a20787a0c989a18787a0b989a10787a0a98990878790998893878790798893078790698892878790598892078790498891878790398891078790298880878780182102082151882161095112832009511a07b10587b15509515608411e08272827a08827b108277188283828908828c108288186f746fbb6faa6f276f826fcc6f996f387b17187b1a107b1b087b147b18387b19307b1c287b12208318831a203309ff330b2033070a069551a082105882155095116032008b7910520931c8780883881f8488e05638000001253309040002390a040002ae8a093d080400020133081000028377c887073200009511f07b10087b158475010a02013d0700000251050750100409501006a1009511a07b10587b15509515608411e049111849111049018000330740641849110850100830fe4911384911304911284911208317200a0701821730821838821928821a20d49808d4a707d4870751071633081000028388330701330933000c0a04283b390804000256187f0c2003040002800001330710000283778000330833090a28bafd33078000330850100a21ff83783307330933000c0a0401951140fe7b10b8017b15b0017b16a8019515c0018411e04911584911504911408000330740c8710849114850100e8afd330600000239070000025317046983176033080a010181177c5147881abcd0ae005147c1ce642e6c52471d3657604b4921d8004921d0004921c8004921c0008317c0000a07018217d0008218d8008219c800821ac000d49808d4a707d487075107dc003308100002838833070133090a04281c3308100002838833070133090a04280c838833070133090a040149219800492190004921880049218000831780000a0701821790008218980082198800821a8000d49808d4a707d48707510770330810000228be39070000025617230b330810000228ae831740013308040a01821740018218480182195001821a5801492178014921700149216801492160017b1a98017b1990017b1888017b17800195176001951880015010105ffd33081000028388330733090a042863ff81675617031e3308100002284bff3907000002561723ed0033081000022839ff4921b8004921b0004921a8004921a0009517209518a0003300129511a07b10587b15507b16489515608411e06476828718828910828a0882886f776f996faa6f887b18187b1a107b19087b17491138491130491128491120481140208318831a20831b403309ff33070a03821738821830821928821a206f776f886f996faa7b6a187b69107b68087b679551a08210588215508216489511603200821920821728821830821a387b1a187b18107b17083307800064187b1950101480fb390804000256289f000d2003040002a0000133071000028378800033092033070a04018317e0003308040a018217e0008218e8008219f000821af800492118014921100149210801492100017b1a38017b1930017b1828017b172001951700019518200150101609fc33081000028388330733090a04280dfe330750101890fc33070150101a88fc82ab7b1b1882ab087b1b2082ab107b1b2882aa187b1a308296829a087b1a829a107b1a088299187b19103202214225494a4a12aa529292244992244992244992244992244992244992244992a42449494a525595a424294925494992208484a134290d89902449222524499a2449124aa91081216aa250a511119124240921446a02028188886844449208a50aa52a3522221a119124a110a148111111111111112154a50809212422229124494a52559292244a52495295a424494992242a84101822355244444444444444085529249424494a491200"
44+
}

templates/react-solidity/contracts/.deploys/pinned-contracts/420420421/0x12d7b1015d6888edbeb19610cfe518310405c685.json renamed to templates/react-solidity-remix/contracts/.deploys/pinned-contracts/420420422/0xf7b90aa295bcf3b17e2ac37e881c50f4c8e7ee73.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Storage",
3-
"address": "0x12d7b1015d6888edbeb19610cfe518310405c685",
3+
"address": "0xf7b90aa295bcf3b17e2ac37e881c50f4c8e7ee73",
44
"abi": [
55
{
66
"inputs": [
@@ -43,5 +43,5 @@
4343
}
4444
],
4545
"filePath": " - connect to localhost - /Storage.sol",
46-
"pinnedAt": 1733225540743
46+
"pinnedAt": 1752525690151
4747
}
File renamed without changes.

0 commit comments

Comments
 (0)