Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7fe20ab
- Used react's useMemo hook to cache the home page component. I hope …
supriyaamisshra Feb 23, 2022
65d4ef2
- Explicitly caching streams data (cap, balance).
supriyaamisshra Feb 26, 2022
fdd05c9
- Fixed stream data resolution function
supriyaamisshra Mar 1, 2022
382d37f
- Fixed typo
supriyaamisshra Mar 1, 2022
326298f
- Home component need not be memoized...
supriyaamisshra Mar 1, 2022
f9e12e8
- Fixed indentation for the Home component
supriyaamisshra Mar 1, 2022
64f2fef
- Bug: percent display was not loading due to missingn await
supriyaamisshra Mar 1, 2022
4e00a7b
- Fixes issue #38, by improving load time from ~30+ seconds to ~5 sec…
supriyaamisshra Mar 1, 2022
cbe5123
Merge pull request #37 from supriyaamisshra/home-page-caching
codenamejason Mar 2, 2022
f4f0980
Merge pull request #39 from supriyaamisshra/fix-issue-38
codenamejason Mar 2, 2022
f961e2a
- Added support for TTL based expiry of stream cached values.
supriyaamisshra Mar 9, 2022
d99ea44
- Added ability to cancel the processing of streams promise when stre…
supriyaamisshra Mar 9, 2022
1c1201e
Merge pull request #45 from moonshotcollective/rinkeby-deploy
codenamejason Mar 10, 2022
7cd52c3
Revert "Rinkeby deploy from Supriya"
codenamejason Mar 10, 2022
7587fef
Merge pull request #46 from moonshotcollective/revert-45-rinkeby-deploy
codenamejason Mar 10, 2022
c2a4045
Merge pull request #43 from supriyaamisshra/streams-cache-invalidation
codenamejason Mar 10, 2022
b4b73b5
update num of streams to show
codenamejason Mar 10, 2022
6cb0cd9
update the num of streams to render at
codenamejason Mar 10, 2022
036e710
Merge pull request #47 from moonshotcollective/develop
codenamejason Mar 10, 2022
70c6fe6
Merge pull request #48 from moonshotcollective/master
codenamejason Mar 10, 2022
1c19af0
Merge branch 'develop' into bug-fix-async-stream-loading
supriyaamisshra Mar 10, 2022
72d2a61
- created contract that can deploy stream factory for organizations b…
supriyaamisshra Mar 16, 2022
06dc522
Merge branch 'streams-cache-invalidation' into multiorg-streams
supriyaamisshra Mar 17, 2022
0c4f0c7
Merge branch 'bug-fix-async-stream-loading' into multiorg-streams
supriyaamisshra Mar 17, 2022
d1f425c
- Basic UI for org browse page
supriyaamisshra Mar 17, 2022
0d702b6
- Organization view, contract fixes & completed integration
supriyaamisshra Mar 17, 2022
a8538f8
- Added rinkeby config
supriyaamisshra Mar 17, 2022
43c210a
Merge branch 'rinkeby-deploy' into multiorg-streams
codenamejason Mar 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,6 @@ yarn install
yarn chain
```

> Make a copy of `.sample.env` and rename to `.env` in `packages/react-app`. Don't forget to fill in the variables.
<table>
<thead>
<th>Variable</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>REACT_APP_NETWORK</code></td>
<td>The ethereum network to run on, by default "mainnet"</td>
</tr>
<tr>
<td><code>REACT_APP_INFURA_ID</code></td>
<td>Your Infura project ID.</td>
</tr>
<tr>
<td><code>REACT_APP_ETHERSCAN_ID</code></td>
<td>Your Etherscan API key token.</td>
</tr>
<tr>
<td><code>REACT_APP_PROVIDER</code></td>
<td>Provider endpoint, typically Infura endpoint.</td>
</tr>
<tr>
<td><code>REACT_APP_MAINNET_RPC_ENDPOINT</code></td>
<td>Can be used to override the mainnet RPC provider endpoint (typically Alchemy endpoint).</td>
</tr>
</tbody>
</table>
> in a second terminal window, start your 📱 frontend:

```bash
Expand All @@ -57,30 +28,6 @@ yarn start
```

> Make a copy of `.sample.env` and rename to `.env` in `packages/hardhat`. Don't forget to fill in the variables.
<table>
<thead>
<th>Variable</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>STREAM_FACTORY_OWNER</code></td>
<td>Owner address of the stream factory contract <code>packages/hardhat/contracts/StreamFactory.sol</code></td>
</tr>
<tr>
<td><code>STREAM_FACTORY_ADMINS</code></td>
<td>Admin addresses of the stream factory contract constructor arg <code>packages/hardhat/contracts/StreamFactory.sol</code></td>
</tr>
<tr>
<td><code>DEPLOY_ENDPOINT_RINKEBY</code></td>
<td>Your Infura / Alchemy endpoint for tokenstream on Rinkeby network</td>
</tr>
<tr>
<td><code>DEPLOY_ACCOUNT_RINKEBY</code></td>
<td>Your wallet account. For metamask, the private key can be extracted by clicking on the three dots button next to the account icon, then on "Account Details" and then on "Export private key".</td>
</tr>
</tbody>
</table>
> in a third terminal window, 🛰 deploy your contract:

```bash
Expand Down
7 changes: 3 additions & 4 deletions packages/hardhat/.sample.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
STREAM_FACTORY_OWNER=0x0000000000000000000000000000000000000000
STREAM_FACTORY_ADMINS=["0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000"]
DEPLOY_ENDPOINT_RINKEBY=https://rinkeby.infura.io/v3/[YOUR_ID]
DEPLOY_ACCOUNT_RINKEBY=my super secret key that i promise never ever to share
DEVELOPER=0x0000000000000000000000000000000000000000
MANAGER1=0x0000000000000000000000000000000000000000
MANAGER2=0x0000000000000000000000000000000000000000
82 changes: 82 additions & 0 deletions packages/hardhat/contracts/OrgFactoryDeployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

import "./StreamFactory.sol";
import "./SimpleStream.sol";

contract OrgFactoryDeployer {

/// @dev emitted when a new org is created.
event OrganizationsDeployed(

address indexed tokenAddress,
address indexed ownerAddress,
string organizationName
);

address[] public organizations;

/// @dev deploys a stream factory contract for a specified organization.
function deployOrganization(
string memory _orgName,
string memory _logoURI,
string memory _orgDescription,
address owner,
address[] calldata admins

) public {
StreamFactory deployedOrganization = new StreamFactory(
_orgName,
_logoURI,
_orgDescription,
owner,
admins
);

organizations.push(address(deployedOrganization));

emit OrganizationsDeployed(
address(deployedOrganization),
msg.sender,
string(_orgName)
);

}

/// @dev gets a page of organizations
function getOrganizations(
uint256 _page,
uint256 _resultsPerPage
)
external
view
returns (address[] memory)
{
uint256 _orgIndex = _resultsPerPage * _page - _resultsPerPage;

if (
organizations.length == 0 ||
_orgIndex > organizations.length - 1
) {
return new address[](0);
}

address[] memory _orgs = new address[](_resultsPerPage);
uint256 _returnCounter = 0;

for (
_orgIndex;
_orgIndex < _resultsPerPage * _page;
_orgIndex++
) {
if (_orgIndex <= organizations.length - 1) {
_orgs[_returnCounter] = organizations[_orgIndex];
} else {
_orgs[_returnCounter] = address(0);
}
_returnCounter++;
}
return _orgs;
}

}
45 changes: 44 additions & 1 deletion packages/hardhat/contracts/StreamFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ contract StreamFactory is AccessControl, Ownable {
bool hasStream;
}

struct OrgInfo {
/// @dev name of organization
string orgName;
/// @dev discription of the organization
string orgDescription;
/// @dev github URI of organization
string orgGithubURI;
/// @dev twitter URI of the organization
string orgTwitterURI;
/// @dev the website URI of organization
string orgWebURI;
/// @dev discord URI organization
string orgDiscordURI;
/// @dev URI to the logo of organization
string logoURI;
/// @dev total streams in organization
uint256 streamsCount;
/// @dev total amount paid out by organization
uint256 totalPaidOut;
}

OrgInfo public orgInfo;

/// @dev StreamAdded event to track the streams after creation
event StreamAdded(address creator, address user, address stream);

Expand All @@ -34,11 +57,28 @@ contract StreamFactory is AccessControl, Ownable {
_;
}

constructor(address owner, address[] memory admins) {
constructor(
string memory _orgName,
string memory _logoURI,
string memory _orgDescription,
address owner,
address[] memory admins
) {
for (uint256 i = 0; i < admins.length; i++) {
_setupRole(DEFAULT_ADMIN_ROLE, admins[i]);
_setupRole(FACTORY_MANAGER, admins[i]);
}
orgInfo = OrgInfo(
_orgName,
_orgDescription,
'', // github URI
'', // twitter URI
'', // website URI
'', // discord URI
_logoURI,
0, // streams count
0 // total paid out
);
transferOwnership(owner);
}

Expand Down Expand Up @@ -72,6 +112,7 @@ contract StreamFactory is AccessControl, Ownable {
// map user to new stream
userStreams[_toAddress] = streamAddress;

orgInfo.streamsCount++;
emit StreamAdded(msg.sender, _toAddress, streamAddress);
}

Expand Down Expand Up @@ -115,6 +156,8 @@ contract StreamFactory is AccessControl, Ownable {
}

function releaseUserStream(address user) public isPermittedFactoryManager {

SimpleStream(userStreams[user]).transferOwnership(user);
orgInfo.streamsCount--;
}
}
21 changes: 8 additions & 13 deletions packages/hardhat/deploy/00_deploy_stream_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ module.exports = async ({ getNamedAccounts, getChainId, deployments }) => {

const GTC = { address: "0xde30da39c46104798bb5aa3fe8b9e0e1f348163f" };

const owner = process.env.STREAM_FACTORY_OWNER;
const admins = JSON.parse(process.env.STREAM_FACTORY_ADMINS);
admins.push(owner); // the owner is also an admin

//const owner = process.env.STREAM_FACTORY_OWNER;
// // deploy dummy GTC on non-mainnet networks
// if (chainId !== "1") {
// GTC = await deploy("GTC", {
Expand All @@ -21,26 +18,24 @@ module.exports = async ({ getNamedAccounts, getChainId, deployments }) => {
// });
// }

// deploy the stream factory
const streamFactory = await deploy("StreamFactory", {
// deploy the Org Factory
const orgFactory = await deploy("OrgFactoryDeployer", {
from: deployer,
args: [owner, admins],
log: true,
});

// log the GTC and StreamFactory addresses
// log the GTC and orgFactoryDeployer addresses
console.log({
GTC: GTC.address,
streamFactory: streamFactory.address,
orgFactory: orgFactory.address,
});

if (chainId !== "31337") {
await run("verify:verify", {
address: streamFactory.address,
contract: "contracts/StreamFactory.sol:StreamFactory",
constructorArguments: [owner, admins],
address: orgFactory.address,
contract: "contracts/OrgFactoryDeployer.sol:OrgFactoryDeployer",
});
}
};

module.exports.tags = ["GTC", "StreamFactory", "SimpleStream"];
module.exports.tags = ["GTC", "OrgFactoryDeployer"];
9 changes: 4 additions & 5 deletions packages/hardhat/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { utils } = require("ethers");
const fs = require("fs");
const chalk = require("chalk");

require("dotenv").config();
require("@nomiclabs/hardhat-waffle");
require("@tenderly/hardhat-tenderly");
require("hardhat-deploy");
Expand Down Expand Up @@ -35,11 +34,11 @@ module.exports = {
url: "http://localhost:8545",
},
rinkeby: {
url: process.env.DEPLOY_ENDPOINT_RINKEBY, // <---- YOUR INFURA ID! (or it won't work)
url: "https://rinkeby.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)
// url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/eth/rinkeby", // <---- YOUR MORALIS ID! (not limited to infura)
accounts: [
process.env.DEPLOY_ACCOUNT_RINKEBY
],
accounts: {
mnemonic: mnemonic(),
},
},
kovan: {
url: "https://kovan.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work)
Expand Down
3 changes: 2 additions & 1 deletion packages/react-app/.sample.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
REACT_APP_PROVIDER=https://rinkeby.infura.io/v3/2717afb6bf164045b5d5468031b93f87
REACT_APP_INFURA_ID=INFURA-PROJECT-ID
REACT_APP_RINKEBY_PROVIDER=https://rinkeby.infura.io/v3/INFURA-PROJECT-ID
REACT_APP_ETHERSCAN_ID=YOUR Etherscan API key token
REACT_APP_MAINNET_RPC_ENDPOINT=https://eth-mainnet.alchemyapi.io/v2/ALCHEMY-ID
REACT_APP_NETWORK=rinkeby
REACT_APP_NETWORK=rinkeby
2 changes: 1 addition & 1 deletion packages/react-app/public/dark-theme.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/react-app/public/light-theme.css

Large diffs are not rendered by default.

Loading