This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
186 changed files
with
12,180 additions
and
2,408 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
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,51 @@ | ||
name: RIF Marketplace UI deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
deploy-develop: | ||
name: RIF Marketplace UI - Develop | ||
runs-on: ubuntu-latest | ||
environment: develop | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm ci | ||
- name: Build site | ||
env: | ||
REACT_APP_CACHE_ADDR: ${{ secrets.DEVELOP_REACT_APP_CACHE_ADDR }} | ||
REACT_APP_UPLOAD_ADDR: ${{ secrets.DEVELOP_REACT_APP_UPLOAD_ADDR }} | ||
REACT_APP_LOG_LEVEL: error | ||
REACT_APP_NETWORK: rskdevnet | ||
REACT_APP_REQUIRED_NETWORK_ID: 33 | ||
REACT_APP_REQUIRED_NETWORK_NAME: RSK Regtest | ||
run: | | ||
npm run build:prod | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.DEVELOP_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.DEVELOP_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.DEVELOP_AWS_REGION }} | ||
|
||
- name: Deploy site to S3 | ||
run: | | ||
aws s3 sync --delete --only-show-errors build/ ${{ secrets.DEVELOP_S3_BUCKET }} | ||
- name: Invalidate CloudFront cache | ||
run: | | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.DEVELOP_CLOUDFRONT_DISTRIBUTION }} --paths "/*" |
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 |
---|---|---|
|
@@ -23,3 +23,4 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
.vscode/ | ||
tsconfig.json |
Large diffs are not rendered by default.
Oops, something went wrong.
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,30 @@ | ||
import { ContractABIEvent, ContractABIItem } from 'api/blockscout/interface' | ||
import { UIError } from 'models/UIMessage' | ||
|
||
const BLOCKSCOUT_API_ADDRESS = 'https://blockscout.com/rsk/mainnet/api?module=contract&action=getabi&address=' | ||
|
||
const getABIEvents = async (contract: string): Promise<ContractABIEvent[]> => { | ||
const response = await fetch(`${BLOCKSCOUT_API_ADDRESS}${contract}`) | ||
|
||
if (response.status !== 200) { | ||
throw new UIError({ | ||
error: new Error(await response.json()), | ||
text: 'could not get abi', | ||
id: 'service-fetch', | ||
}) | ||
} | ||
const { message, result } = await response.json() | ||
|
||
if (message !== 'OK') { | ||
throw new UIError({ | ||
error: new Error(message), | ||
text: `Invalid contract address: ${contract}`, | ||
id: 'service-fetch', | ||
}) | ||
} | ||
const abiItems: ContractABIItem[] = JSON.parse(result) | ||
return abiItems.filter((abiItem: ContractABIItem) => abiItem.type === 'event') | ||
.map((item) => item as ContractABIEvent) | ||
} | ||
|
||
export default getABIEvents |
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,18 @@ | ||
export type ContractABIEventParam = { | ||
name: string | ||
type: string | ||
indexed?: boolean | ||
} | ||
|
||
export type ContractABIItem = { | ||
name: string | ||
type: string | ||
inputs?: Array<ContractABIEventParam> | ||
constant?: boolean | ||
outputs?: any | ||
payable?: boolean | ||
stateMutability?: string | ||
anonymous?: boolean | ||
} | ||
|
||
export type ContractABIEvent = Pick<ContractABIItem, 'name' | 'inputs' | 'anonymous'> |
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,26 @@ | ||
import { AbstractAPIService } from './apiService' | ||
|
||
export default abstract class AbstractRestAPIService extends AbstractAPIService { | ||
abstract _create: <T, S, R>(data: T, params?: S) => Promise<R> | ||
|
||
create = async <T, S, R> (data: T, params?: S): Promise<R> => { | ||
if (!this.service) { | ||
this.errorReporter({ | ||
id: 'service-connection', | ||
text: 'Error while creating resource.', | ||
error: new Error(`The ${this.path} service is not connected`), | ||
}) | ||
} | ||
let response = {} | ||
try { | ||
response = await this._create(data, params) | ||
} catch (error) { | ||
this.errorReporter({ | ||
id: 'service-fetch', | ||
text: 'Error while creating resource.', | ||
error, | ||
}) | ||
} | ||
return response as R | ||
} | ||
} |
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
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 @@ | ||
import { SupportedTokenSymbol } from 'models/Token' | ||
import { parseToBigDecimal } from 'utils/parsers' | ||
|
||
export type StakeBalanceTransport = { | ||
account: string | ||
symbol: string | ||
token: string | ||
total: string | ||
} | ||
|
||
export interface StakeTransport { | ||
totalStakedFiat: string | ||
stakes: StakeBalanceTransport[] | ||
} | ||
|
||
export type StakeFilters = { | ||
account: string | ||
} | ||
|
||
export type StakedBalances = Record<SupportedTokenSymbol, string> | ||
|
||
export type Staked = { | ||
stakedBalances: StakedBalances | ||
totalStakedUSD: string | ||
} | ||
|
||
export const mapStakesListFromTransport = ( | ||
stakes, | ||
): StakedBalances => stakes.reduce((acc, { symbol, total }) => { | ||
acc[symbol] = parseToBigDecimal(total).toString() | ||
return acc | ||
}, {}) | ||
|
||
export const mapFromTransport = (stakeTransport: StakeTransport): Staked => { | ||
const { totalStakedFiat: totalStakedUSD, stakes } = stakeTransport | ||
const stakedBalances = mapStakesListFromTransport(stakes) | ||
|
||
return { | ||
stakedBalances, | ||
totalStakedUSD, | ||
} | ||
} |
Oops, something went wrong.