This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The v0 of the Funding Pool is in alpha. The feature is only available behind the isExperimental and fundingFeature flags. It operates using a local ethereum node. All relevant documentation can be found in FUNDING.md. This is the result of a joined effort of multiple people. A special thanks to @geigerzaehler, @CodeSandwich, and @brandonhaslegs.
- Loading branch information
1 parent
88fdbec
commit 5b4a327
Showing
82 changed files
with
6,842 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
### Overview | ||
|
||
Three moving pieces back the Radicle Funding experiences: | ||
|
||
- An Ethereum wallet, owned by the user | ||
- A connection between the Radicle Upstream (the app) and said Ethereum wallet | ||
- The Radicle Contracts (Ethereum smart-contracts) | ||
|
||
The funding experiences provided in the Radicle Upstream are Ethereum-based, | ||
meaning that actions such as adding users to the list of receivers, collect | ||
incoming support funds, and others, translate into ethereum transactions. | ||
|
||
For users to approve those transactions originated in the app, they need to | ||
establish a connection between an Ethereum wallet and the app. We provide this | ||
capability through a WalletConnect integration. A substantial number of Ethereum | ||
wallets support WalletConnect. [You can find the complete list here][wcw]. | ||
|
||
Once a wallet is connected to the app, the funding experiences become available | ||
to the user. The user can now set up and edit their support, receive funds, etc. | ||
All of these actions translate into transactions the user must review, (i.e., | ||
approve or reject) on their connected wallet. | ||
|
||
These same transactions are provided and ran by the [Radicle Contracts][rc], our | ||
custom Ethereum smart-contracts. | ||
|
||
|
||
#### Development environment | ||
|
||
In the development environment, we set up these three pieces as follows: | ||
|
||
- A local WalletConnect test wallet instance | ||
|
||
This instance will play the role of a real wallet: | ||
- It provides a couple of test accounts that we use in development. | ||
- The transactions triggered in the app will be prompted here for the user | ||
to approve or reject. | ||
|
||
- A local ganache instance | ||
|
||
Ganache provides a local Ethereum RPC client for testing and development. The | ||
Radicle Contracts are deployed to this instance. Here, we also set an initial | ||
balance of the account we choose for development purposes. | ||
|
||
For piece of mind, note that this instance has no connection to other networks | ||
such as mainnet or testnet. Therefore, no real assets are ever used. Feel free | ||
to play around! | ||
|
||
![Radicle Funding Development Set up][dev-setup] | ||
|
||
**Getting started** | ||
|
||
- Install [walletconnect-test-wallet][wctw] | ||
|
||
- `git clone git@github.com:radicle-dev/walletconnect-test-wallet.git` | ||
- `cd walletconnect-test-wallet` | ||
- `npm install` | ||
|
||
- Set up the local test ethereum account | ||
|
||
- Run `npm run start` within `walletconnect-test-wallet`. It should open the | ||
test wallet in your browser at `localhost:3000`. | ||
|
||
- Copy the full Ethereum address provided at the top of the page. | ||
|
||
- Now, in `radicle-upstream`, run: | ||
|
||
- `yarn install` | ||
- `mkdir sandbox` | ||
- `touch sandbox/.local-eth-account` | ||
- Finally, paste the copied address in the previous step into this file. | ||
|
||
**Running** | ||
|
||
With everything installed and set up, run the following commands in different | ||
tabs: | ||
|
||
- `npm run start` within `walletconnect-test-wallet` | ||
- `yarn ethereum:start` within `radicle-upstream` | ||
`RADICLE_UPSTREAM_EXPERIMENTAL=true yarn start` within `radicle-upstream` | ||
- Once the app is running, enable the funding feature in the Upstream settings | ||
|
||
|
||
[wcw]:https://walletconnect.org/wallets/ | ||
[wctw]:https://github.com/radicle-dev/walletconnect-test-wallet | ||
[rc]:https://github.com/radicle-dev/radicle-contracts | ||
[dev-setup]:./funding-dev-setup.svg "Radicle Funding Development Set up" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
#!/usr/bin/env node | ||
|
||
const { deployAll } = require("radicle-contracts"); | ||
const ethers = require("ethers"); | ||
const fs = require("fs"); | ||
|
||
main().catch(e => { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
|
||
async function main() { | ||
const provider = new ethers.providers.JsonRpcProvider( | ||
"http://localhost:8545" | ||
); | ||
const signer = provider.getSigner(0); | ||
const txCount = await signer.getTransactionCount(); | ||
if (txCount !== 0) { | ||
throw new Error( | ||
"Deployer account has non-zero transaction count. You need to reset your chain" | ||
); | ||
} | ||
|
||
console.log("\n### Deploying the Radicle Contracts...\n"); | ||
const contracts = await deployAll(signer); | ||
console.log(`Rad token deployed at ${contracts.rad.address.toLowerCase()}`); | ||
console.log(`ENS deployed at ${contracts.ens.address.toLowerCase()}`); | ||
console.log( | ||
`Eth Pool deployed at ${contracts.ethPool.address.toLowerCase()}` | ||
); | ||
console.log( | ||
`Erc20 Pool deployed at ${contracts.erc20Pool.address.toLowerCase()}` | ||
); | ||
console.log("Done.\n"); | ||
|
||
const devEthAccount = fs | ||
.readFileSync("sandbox/.local-eth-account", "utf-8") | ||
.trim(); | ||
|
||
// Set the initial balance of the used erc20 token for the development account. | ||
await (await contracts.rad.transfer(devEthAccount, 98765)).wait(); | ||
} |
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,30 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Run a local ethereum node and deploy the latest contracts to it. | ||
# | ||
|
||
set -eumo pipefail | ||
|
||
node_modules/.bin/ganache-cli \ | ||
--mnemonic "image napkin cruise dentist name plunge crisp muscle nest floor vessel blush" \ | ||
--defaultBalanceEther 1000 \ | ||
"$@" & | ||
|
||
function stop_ganache() { | ||
kill %1 2>/dev/null || true | ||
fg %1 2>/dev/null || true | ||
} | ||
|
||
trap stop_ganache SIGINT EXIT SIGTERM | ||
|
||
sleep 4 | ||
|
||
echo "Deploying the Radicle Dev Contracts..." | ||
./scripts/deploy-dev-contracts.js; | ||
echo "Done" | ||
|
||
echo "Adding funds to your account..." | ||
ethers --rpc http://localhost:8545 --account-rpc 0 --yes send $(< ./sandbox/.local-eth-account) 10 | ||
echo "Done" | ||
|
||
fg %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
Oops, something went wrong.