Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Deploy to IPFS 2 #543

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 0 additions & 66 deletions .babelrc

This file was deleted.

21 changes: 6 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
version: 2
version: 2.1
jobs:
build:
docker:
- image: circleci/node:11.15.0

working_directory: ~/repo

steps:
- checkout

- deploy:
name: Deploy to Now
- run:
name: Build the static site with next js
command: |
GIT_HASH=$(git rev-parse --short HEAD)
SANITIZED_BRANCH=$(tr "/" "-" <<<$CIRCLE_BRANCH)
VERY_SANITIZED_BRANCH=$(tr "." "-" <<<$SANITIZED_BRANCH)
echo ${GIT_HASH} > version
cp CONTRIBUTORS contributors
BUILD_URL=$(npx now --name app.mybit.io -t $NOW_DEVELOPMENT_TOKEN --public)
npx now alias ${BUILD_URL} ${GIT_HASH}-app-mybit-io-dev -t $NOW_DEVELOPMENT_TOKEN
npx now alias ${BUILD_URL} ${VERY_SANITIZED_BRANCH}-app-mybit-io-dev -t $NOW_DEVELOPMENT_TOKEN
yarn install
yarn run build
yarn run export
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ typings/
# compiled server
lib

# nextjs
.next
out

bundles
20 changes: 9 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
os: linux
language: node_js
node_js:
- "11.15"
cache:
directories:
- node_modules
yarn: true
install: true
yarn: true
banches:
only:
- master
script:
- GIT_HASH=$(git rev-parse --short HEAD)
- echo ${GIT_HASH} > version
- cp CONTRIBUTORS contributors
- BUILD_URL=$(npx now --name app.mybit.io -t $NOW_PROD_TOKEN)
- if [ "$TRAVIS_BRANCH" = "develop" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npx now alias ${BUILD_URL} app-staging.mybit.io -t $NOW_PROD_TOKEN; fi
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npx now alias ${BUILD_URL} app.mybit.io -t $NOW_PROD_TOKEN; fi
- yarn install
- yarn run build
- yarn run export
- ./node_modules/.bin/ipfs-deploy --no-open -p pinata -d cloudflare out
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,13 @@ Not required but civic won't work in a development environment, only once your P
- REACT_APP_INFURA_API_KEY (Prefix `REACT_` so it can be used in react code)
Free to generate at infura's [website](https://infura.io/). Required.

- BUCKET_REGION | AWS_ACCESS_KEY | BUCKET_NAME | AWS_SECRET_KEY
Currently the application won't work without these.

- AIRTABLE_KEY
Create a free account at [airtable](https://airtable.com) and copy [our table](https://airtable.com/shrpZZvivqhhoUbWn), then use your own [API key](url). Required.

### Contexts
The application is built around a series of Contexts (See [React Context](https://reactjs.org/docs/context.html)) in conjunction with [HOCs](https://reactjs.org/docs/higher-order-components.html) to provide different data to different components across the appliacation.

The following Contexts are available:

- [Metamask](https://github.com/MyBitFoundation/MyBit-Go.app/tree/develop/components/MetamaskContext/index.js)
- [Blockchain](https://github.com/MyBitFoundation/MyBit-Go.app/tree/develop/components/BlockchainContext.js)
- [Airtable](https://github.com/MyBitFoundation/MyBit-Go.app/tree/develop/components/Airtable.js)
- [Kyber](https://github.com/MyBitFoundation/MyBit-Go.app/tree/develop/components/KyberContext.js)
- [Notifications](https://github.com/MyBitFoundation/MyBit-Go.app/tree/develop/components/NotificationsContext.js)
- [Civic](https://github.com/MyBitFoundation/MyBit-Go.app/tree/develop/components/UI/CivicContext.js)
Expand Down
90 changes: 9 additions & 81 deletions apis/brain.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import axios from 'axios';
import dayjs from 'dayjs';
import { ErrorTypes } from 'constants/errorTypes';
import {
InternalLinks,
ExternalLinks,
} from 'constants/links';
import {
Expand All @@ -24,6 +23,8 @@ import {
toWei,
} from '../utils/helpers';
import { CONTRACTS } from 'constants/supportedNetworks';
import { getTransactions } from 'utils/etherscan';
import { getNetworkName } from 'utils/web3';

import BN from 'bignumber.js';
BN.config({ EXPONENTIAL_AT: 80 });
Expand All @@ -45,19 +46,14 @@ export const fetchTransactionHistory = async userAddress =>
* than it is to keep converting it for every iteration
*/
const userAddressLowerCase = userAddress.toLowerCase();
const endpoint = ExternalLinks.ETHERSCAN_TX_BY_ADDR_ENDPOINT(userAddress);
const result = await fetch(endpoint);
const jsonResult = await result.json();
if (
!jsonResult.message ||
(jsonResult.message &&
jsonResult.message !== 'No transactions found' &&
jsonResult.message !== 'OK')
) {
throw new Error(jsonResult.result);
}
const network = await getNetworkName();
const res = await getTransactions({
network,
address: userAddressLowerCase
});
const result = res.data.result;

const ethTransactionHistory = jsonResult.result
const ethTransactionHistory = result
.filter(txResult =>
txResult.to === userAddressLowerCase || txResult.from === userAddressLowerCase)
.map((txResult, index) => {
Expand Down Expand Up @@ -204,74 +200,6 @@ export const createAsset = async (onCreateAsset, onApprove, params, network) =>
}
}

export const uploadFilesToAWS = async (
assetId,
fileList,
performInternalAction,
) => {
try{
let data = new FormData();
data.append('assetId', assetId);
for(const file of fileList){
data.append('file', file.originFileObj ? file.originFileObj : file.file ? file.file : file);
}
const result = await axios.post(InternalLinks.S3_UPLOAD,
data, {
headers: {
'Content-Type': 'multipart/form-data'
}
}
)
if(performInternalAction){
performInternalAction();
} else {
return result;
}
} catch(err){
setTimeout(() => uploadFilesToAWS(assetId, fileList, performInternalAction), 5000);
debug(err);
}
}

export const updateAirTableWithNewAsset = async (
data,
performInternalAction,
network,
) => {
try{
await axios.post(InternalLinks.updateAirtableAssets(network), {
...data,
});
performInternalAction();
} catch(err){
setTimeout(() =>
updateAirTableWithNewAsset(
data,
performInternalAction,
network,
), 5000);
debug(err);
}
}

export const updateAirTableWithNewOffChainData = async (
data,
network,
) => {
try{
await axios.post(InternalLinks.updateAirtableAssetListing(network), {
...data,
});
} catch(err){
setTimeout(() =>
updateAirTableWithNewOffChainData(
data,
network,
), 5000);
debug(err);
}
}

export const payoutAsset = ({
userAddress,
assetId,
Expand Down