Skip to content

Commit

Permalink
Merge branch 'main' into therealharpaljadeja/react-native-walletconne…
Browse files Browse the repository at this point in the history
…ct-v2
  • Loading branch information
viral-sangani authored Jul 11, 2023
2 parents c5ec0c9 + 7278b19 commit 58e2ac3
Show file tree
Hide file tree
Showing 98 changed files with 4,924 additions and 7,079 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
.env
packages/*/.env
packages/*/.env

# IntelliJ project files
*.iml
Expand Down
122 changes: 18 additions & 104 deletions bin/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const createAsync = async (command) => {
subgraphs: "subgraphs",
};

let fELibraries = {
rc: "react-celo",
rk: "rainbowkit-celo",
};

let selectedPackages = [];
let selectedFELibrary = "";

Expand Down Expand Up @@ -65,17 +60,6 @@ const createAsync = async (command) => {
]
);

if (fEFramework == availablePackages["react-app"]) {
let { fELibrary } = await inquirer.prompt({
type: "list",
name: "fELibrary",
message: "Choose web3 library for react app:",
default: fELibraries["rk"],
choices: [fELibraries["rc"], fELibraries["rk"]],
});
selectedFELibrary = fELibrary;
}

let { scFramework } = await inquirer.prompt({
type: "list",
name: "scFramework",
Expand Down Expand Up @@ -158,14 +142,12 @@ const createAsync = async (command) => {
};

for (let x = 0; x < selectedPackages.length; x++) {

let package = selectedPackages[x];

// clone to local only the projects user wants
shell.exec(
`git sparse-checkout add packages/${package}`,
{ silent: true }
);
shell.exec(`git sparse-checkout add packages/${package}`, {
silent: true,
});

// if project isn't web no need to netlify.toml
if (
Expand Down Expand Up @@ -199,79 +181,12 @@ const createAsync = async (command) => {
}

// update front-end web3 library
if (
package == packageNameMap["react-app"] &&
selectedFELibrary != ""
) {
shell.echo(`Customizing ${package} with ${selectedFELibrary}...\n`);
if (package == packageNameMap["react-app"]) {
let localPackageJson = shell.cat(
`packages/${package}/package.json`
);
let projectPackage = JSON.parse(localPackageJson);
switch (selectedFELibrary) {
// rainbowkit-celo
case fELibraries["rk"]:
shell.echo(`rainbowkit-celo`);
// remove react-celo libraries in packages.json file
delete projectPackage.dependencies[
"@celo/react-celo"
];
delete projectPackage.dependencies[
"@celo/contractkit"
];

// remove react-celo header component
shell.rm(
"packages/react-app/components/HeaderRC.tsx"
);
shell.rm("packages/react-app/pages/_appRC.tsx");
shell.mv(
"packages/react-app/components/HeaderRK.tsx",
"packages/react-app/components/Header.tsx"
);
shell.sed(
"-i",
'import Header from "./HeaderRK";',
'import Header from "./Header";',
"packages/react-app/components/Layout.tsx"
);
break;

// react-celo
case fELibraries["rc"]:
// remove rainbowkit-celo libraries in packages.json file
delete projectPackage["dependencies"][
"@celo/rainbowkit-celo"
];
delete projectPackage["dependencies"][
"@rainbow-me/rainbowkit"
];

// remove rainbowkit-celo header component
shell.rm(
"packages/react-app/components/HeaderRK.tsx"
);
shell.rm("packages/react-app/pages/_app.tsx");
shell.mv(
"packages/react-app/pages/_appRC.tsx",
"packages/react-app/pages/_app.tsx"
);
shell.mv(
"packages/react-app/components/HeaderRC.tsx",
"packages/react-app/components/Header.tsx"
);
shell.sed(
"-i",
'import Header from "./HeaderRK";',
'import Header from "./Header";',
"packages/react-app/components/Layout.tsx"
);
break;

default:
break;
}
// write back the changes to the package.json

shell
.echo(JSON.stringify(projectPackage, "", 4))
.to(`packages/${package}/package.json`);
Expand All @@ -282,7 +197,6 @@ const createAsync = async (command) => {
] = `yarn workspace @${projectName}/${package} ${key}`;
});
}

}
/**
* Getting all packages selected by the user
Expand All @@ -291,7 +205,7 @@ const createAsync = async (command) => {
* eg:- ["react-app", "hardhat"] etc...
*/
let packagesStdOut;
if(isWindows) {
if (isWindows) {
let { stdout } = shell.exec("dir packages /b", {
silent: true,
});
Expand All @@ -307,23 +221,23 @@ const createAsync = async (command) => {
* Node 14 and below doens't support replaceAll
*/
let packages;
if(isWindows) {
packages = packagesStdOut.replaceAll("\n", " ").replaceAll("\r", "").split(" ");
if (isWindows) {
packages = packagesStdOut
.replaceAll("\n", " ")
.replaceAll("\r", "")
.split(" ");
// remove empty strings from array
packages = packages.filter(function (el) {
return el != null && el != "";
});
} else {
// remove new line from packagesStdOut
packages = packagesStdOut
.replace(/packages\//g, "")
.replace(/\//g, "")
.replace(/\n/g, "")
.split(" ");

.replace(/packages\//g, "")
.replace(/\//g, "")
.replace(/\n/g, "")
.split(" ");
}



shell.exec("rm -rf .git");
shell.exec("git init --quiet --initial-branch=main");
Expand Down Expand Up @@ -356,10 +270,10 @@ const loading = (message) => {
return ora(message).start();
};

function isWindows() {
return Os.platform() === 'win32'
function isWindows() {
return Os.platform() === "win32";
}

module.exports = {
createAsync,
};
};
34 changes: 17 additions & 17 deletions packages/hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ This project demonstrates a basic Hardhat use case. It comes with a sample contr

1. Create a `.env` file similar to `.envexample`.
2. Paste the private key in `.env`.
> note: depending on how you generate your private key, you may have to prepend `0x` in the private key does not already have it prepended.

Alternatively, you can also run the following command to generate a new account

```sh
npx hardhat create-account
```

> **Note** : Depending on how you generate your private key, you may have to prepend `0x` in the private key does not already have it prepended.
3. Faucet your account with the Alfajores testnet faucet [here](https://celo.org/developers/faucet).

## Develop
Expand Down Expand Up @@ -71,6 +79,14 @@ You can get a local copy of mainnet by forking with Ganache. Learn more about [f

There is a script provided (`yarn fork-mainnet`) to fork mainnet and fund the same test accounts that come with Celo devchain. Sometimes sending transactions from the first account (which defaults to `0x5409ED021D9299bf6814279A6A1411A7e866A631`) is delayed and sending test transactions from the other accounts works better for some reason. :shrug: The private keys of the associated test accounts are printed in `account_keys.json`.

## Celo Core Contracts

You can easily import Celo Core contracts to be used by your contracts like so:

```solidity
import '@celo/contracts/common/Accounts.sol';
```

## Verify your contracts

### hardhat-celo
Expand Down Expand Up @@ -106,19 +122,3 @@ On Mainnet:
```bash
npx hardhat --network celo sourcify
```

## Deploy with [Figment Datahub](https://datahub.figment.io/)

Figment Datahub provides RPC & REST APIs for Celo network. To learn more about Datahub refer this doc - [https://docs.figment.io/introduction/what-is-datahub](https://docs.figment.io/introduction/what-is-datahub). Follow these steps to deploy your smart contract with Figment datahub's RPC.

- Create account on [Datahub](https://datahub.figment.io/).
- On the dashboard, click on `Create new app` and select **Celo** from the protocol list.
- Once you have created an app, copy the api key.
- Edit `hardhat.config.js` and update `alfajoresDatahub` and `celoDatahub` with the API Key.
- Run the test or deploy the contract with following commands.

```bash
npx hardhat run scripts/run.ts --network alfajoresDatahub

npx hardhat run scripts/deploy.ts --network celoDatahub
```
Loading

0 comments on commit 58e2ac3

Please sign in to comment.