Skip to content

Commit

Permalink
Merge branch 'develop' into sov-3013/voting-next-step
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickk137 committed Sep 28, 2023
2 parents 8d4e084 + 9ce7fbf commit cbce2d9
Show file tree
Hide file tree
Showing 199 changed files with 11,900 additions and 418 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/pinata_unpin_content/action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
name: 'Pinata Unpin Content'
description: 'Get a list of pinned content and unpin those content'
description: 'Get a list of all pinned content and unpin it'
inputs:
pinataKey:
description: "Pinata Key"
description: 'Pinata Key'
required: true
pinataSecret:
description: "Pinata Secret"
required: true
pinName:
description: 'Pin Name in metadata'
required: true
pinEndTimestamp:
description: 'Pin End Timestamp'
pinataSecret:
description: 'Pinata Secret'
required: true
runs:
using: 'node16'
main: 'index.js'
main: 'index.js'
18 changes: 4 additions & 14 deletions .github/workflows/pinata_unpin_content/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
const core = require('@actions/core');
const pinataSDK = require('@pinata/sdk');

function getPinList(pinata, pinName, pinEnd) {
console.log(
`Calling API to get pin list with pinName ${pinName} before ${pinEnd}`,
);
function getPinList(pinata) {
return pinata.pinList({
status: 'pinned',
pageLimit: 1000,
metadata: { name: pinName },
pinEnd: pinEnd,
});
}

Expand All @@ -25,15 +20,10 @@ try {
// inputs are defined in action metadata file
const pinataKey = core.getInput('pinataKey');
const pinataSecret = core.getInput('pinataSecret');
const pinName = core.getInput('pinName');
const pinEndTimestamp = core.getInput('pinEndTimestamp');
console.log('pinEndTimestamp');
console.log(pinEndTimestamp);
const pinEndDate = new Date(pinEndTimestamp * 1000);
const pinEnd = pinEndDate.toISOString();

const pinata = new pinataSDK(pinataKey, pinataSecret);
console.log(`Pin Name: ${pinName}`);
getPinList(pinata, pinName, pinEnd).then(pins => {

getPinList(pinata).then(pins => {
console.log(`Processing a total of ${pins.rows.length}`);
unpinList(pinata, pins);
});
Expand Down
46 changes: 22 additions & 24 deletions .github/workflows/release-frontend-build-ipfs.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
name: Release Frontend build to IPFS

on:
on:
workflow_dispatch:
inputs:
inputs:
require_unpin_previous_builds:
type: boolean
description: "Unpin previous builds"
description: 'Unpin previous builds'

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
unpin_previous_builds:
name: Unpin Previous Builds
if: ${{ inputs.require_unpin_previous_builds }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies
run: yarn install
- name: Call Pinata API to unpin previous builds
uses: ./.github/workflows/pinata_unpin_content
with:
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}
upload_build:
name: Upload Frontend Build To IPFS
name: Upload Frontend Build To IPFS
needs: unpin_previous_builds
runs-on: ubuntu-latest
outputs:
outputs:
commit_short_hash: ${{ steps.commit.outputs.short }}
build_timestamp: ${{ steps.get_build_timestamp.outputs.build_timestamp }}
cidv0: ${{ steps.upload_frontend_build.outputs.hash }}
cidv1: ${{ steps.cidv0_to_cidv1.outputs.cidv1 }}
cidv1: ${{ steps.cidv0_to_cidv1.outputs.cidv1 }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand All @@ -33,7 +48,7 @@ jobs:
id: get_build_timestamp
run: echo "build_timestamp=$(date +%s)" >> "$GITHUB_OUTPUT"
- name: Build
run: REACT_APP_IPFS_BUILD=true yarn build
run: REACT_APP_IPFS_BUILD=true yarn build
- name: Upload Frontend Build to IPFS via Pinata
id: upload_frontend_build
uses: aquiladev/ipfs-action@master
Expand All @@ -50,23 +65,6 @@ jobs:
uses: Uniswap/[email protected]
with:
cidv0: ${{ steps.upload_frontend_build.outputs.hash }}
unpin_previous_builds:
name: Unpin Previous Builds
needs: upload_build
if: ${{ inputs.require_unpin_previous_builds }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies
run: yarn install
- name: Call Pinata API to unpin previous builds
uses: ./.github/workflows/pinata_unpin_content
with:
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}
pinName: Sovryn DAPP Frontend
pinEndTimestamp: ${{ needs.upload_build.outputs.build_timestamp }}
pin_build_cidv1:
name: Pin Frontend Build CIDv1
needs: upload_build
Expand Down
60 changes: 60 additions & 0 deletions apps/frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
# frontend

## 1.0.28

### Patch Changes

- 26a9feb5: SOV-2756: Clean up Babelfish token config
- 774b032b: SOV-3021: Fix earned tooltip layout
- 2347b43c: SOV-2993: Vesting reward history
- 0b72c502: SOV-2992: lending withdraw with max amount issue
- df04edaa: SOV-2913: vesting delegate history
- aad41527: SOV-2942: fix adjust stake data refresh
- 0cd49a90: SOV-3077: Prevent reward SOV claiming and force user to withdraw unclaimed SOV if the LM vesting contracts has too many liquid stakes
- Updated dependencies [26a9feb5]
- @sovryn/contracts@1.0.15

## 1.0.27

### Patch Changes

- 8d9a3fd4: SOV-3171: borrow history export order
- 8d9a3fd4: SOV-2747: Borrow page skeleton
- 8d9a3fd4: SOV-2800: Borrow - Maintenance mode states
- 8d9a3fd4: SOV-3143: Fix repaying tiny position
- f88ff42b: SOV-2754: Update token amount output component
- 8d9a3fd4: SOV-3089: Fix Loan modal titles
- 8d9a3fd4: SOV-2747: Borrow page
- 8d9a3fd4: SOV-2829: Borrow page initial config
- 8d9a3fd4: SOV-2749: add adjust loan dialog
- 8d9a3fd4: SOV-2989: Develop D2 Borrow page - Extend loan modal
- 8d9a3fd4: SOV-3031: borrow ui tweaks
- 8d9a3fd4: SOV-2755: add fixed-interest notifications
- 8d9a3fd4: SOV-2747: Finalize Borrow page
- 8d9a3fd4: SOV-2748: Borrow page - New loan modal
- 8d9a3fd4: SOV-3145: Fix extend modal allowance
- 8d9a3fd4: SOV-3151: update createLoan label
- 8d9a3fd4: SOV-2750: Borrow Transaction History
- 8d9a3fd4: SOV-2941: Update Borrow history
- 8d9a3fd4: SOV-2995: update open loans table
- Updated dependencies [8d9a3fd4]
- Updated dependencies [8d9a3fd4]
- Updated dependencies [8d9a3fd4]
- Updated dependencies [f88ff42b]
- Updated dependencies [8d9a3fd4]
- Updated dependencies [8d9a3fd4]
- @sovryn/contracts@1.0.14
- @sovryn/ui@1.0.13
- @sovryn/sdk@0.0.6

## 1.0.26

### Patch Changes

- 7b207c2f: SOV-3025: fix reward link redirect on Stake page
- ba836902: SOV-3018/SOV-3020: Fix Funding CSV export fields
- 73fbbb9e: SOV-2921: improve zero redemption conversion route
- 629f39e3: SOV-2862: Fix delegate address display reset after extending Stake
- fdf82ac7: Update maintenance state ids
- 0af72eb9: SOV-3019: fix issue with total numbers
- Updated dependencies [73fbbb9e]
- @sovryn/sdk@0.0.5

## 1.0.25

### Patch Changes
Expand Down
6 changes: 4 additions & 2 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "frontend",
"version": "1.0.25",
"version": "1.0.28",
"homepage": ".",
"private": true,
"dependencies": {
"@apollo/client": "3.7.1",
"@apollo/react-hooks": "4.0.0",
"@loadable/component": "5.15.2",
"@sovryn-zero/lib-base": "0.2.1",
"@sovryn-zero/lib-ethers": "0.2.4",
"@sovryn-zero/lib-ethers": "0.2.5",
"@sovryn/contracts": "*",
"@sovryn/ethers-provider": "*",
"@sovryn/onboard-common": "1.0.0",
Expand All @@ -26,6 +26,7 @@
"bitcoin-address-validation": "2.2.1",
"chart.js": "4.1.1",
"classnames": "2.3.2",
"date-fns": "2.30.0",
"dayjs": "1.11.7",
"env-cmd": "10.1.0",
"ethers": "5.7.1",
Expand All @@ -40,6 +41,7 @@
"react": "18.2.0",
"react-chartjs-2": "5.1.0",
"react-countup": "6.4.0",
"react-day-picker": "8.8.0",
"react-dom": "18.2.0",
"react-helmet-async": "1.3.0",
"react-i18next": "12.0.0",
Expand Down
56 changes: 36 additions & 20 deletions apps/frontend/src/app/2_molecules/AmountRenderer/AmountRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import {
getLocaleSeparators,
decimalic,
} from '../../../utils/math';
import {
calculateDecimalPlaces,
isValueBetweenZeroAndOne,
} from './AmountRenderer.utils';

const { decimal, thousand } = getLocaleSeparators();

Expand Down Expand Up @@ -64,25 +68,6 @@ export const AmountRenderer: FC<AmountRendererProps> = ({
});
}, [addNotification, value]);

const countUpValues = useMemo(() => {
const endValue = decimalic(value).toString();

const [whole = '', decimals = ''] = endValue.split('.');
const end = parseFloat(
(whole ?? 0) + '.' + (decimals ?? 0).slice(0, precision),
);

return {
end,
decimals: getDecimalPartLength(end),
};
}, [precision, value]);

const localeFormattedValue = useMemo(
() => formatValue(value, precision),
[value, precision],
);

const valueIsRounded = useMemo(
() => getDecimalPartLength(value) > precision,
[precision, value],
Expand All @@ -98,6 +83,37 @@ export const AmountRenderer: FC<AmountRendererProps> = ({
[useTooltip, valueIsRounded],
);

const calculatedPrecision = useMemo(
() => calculateDecimalPlaces(value, precision),
[value, precision],
);

const countUpValues = useMemo(() => {
const endValue = decimalic(value).toString();
const [whole = '', decimals = ''] = endValue.split('.');
const checkPrecision =
Number(whole) < 1 && Number(whole) > 0 ? calculatedPrecision : precision;
const end = parseFloat(
(whole ?? 0) + '.' + (decimals ?? 0).slice(0, checkPrecision),
);

return {
end,
decimals: getDecimalPartLength(end),
};
}, [calculatedPrecision, value, precision]);

const localeFormattedValue = useMemo(
() =>
formatValue(
value,
isValueBetweenZeroAndOne(Number(value))
? calculatedPrecision
: precision,
),
[value, calculatedPrecision, precision],
);

return (
<Tooltip
content={
Expand All @@ -123,7 +139,7 @@ export const AmountRenderer: FC<AmountRendererProps> = ({
<CountUp
start={0}
end={countUpValues.end}
decimals={countUpValues.decimals}
decimals={calculatedPrecision}
duration={1} //do not set lower than 1 overwise it can cause a bug
separator={thousand}
decimal={decimal}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Decimalish } from '@sovryn/utils';

import { decimalic } from '../../../utils/math';

export const isValueBetweenZeroAndOne = (value: number) =>
value > 0 && value < 1;

export const calculateDecimalPlaces = (
value: Decimalish,
precision: number,
) => {
const decimalValue = decimalic(value).toString();
const [, decimals = ''] = decimalValue.split('.');
const nonZeroIndex = decimals.search(/[^0]/);
return nonZeroIndex !== -1
? Math.max(nonZeroIndex + 1, precision)
: precision;
};
Loading

0 comments on commit cbce2d9

Please sign in to comment.