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

chore: release v1.224.0 [DO NOT MERGE] #3916

Merged
merged 9 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ jobs:
name: Call
uses: ./.github/workflows/pr.yml
needs: [install-and-cache]

call-cloudflare-workflow:
name: Call
uses: ./.github/workflows/cloudflare.yml
secrets: inherit # pass org/repo secrets to the called workflow
needs: [install-and-cache]
53 changes: 53 additions & 0 deletions .github/workflows/cloudflare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
workflow_call:

jobs:
deploy:
env:
# head_ref is current branch name
# https://docs.github.com/en/actions/learn-github-actions/contexts#example-contents-of-the-github-context
GITHUB_BRANCH_NAME: ${{ github.head_ref }}
PROJECT_NAME: web # cloudflare bug? our project name/alias is web-29e but wrangler wants just "web"
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
if: contains(fromJSON('["develop", "release", "yeet", "main", "private"]'), ${{ github.head_ref }})
runs-on: size-bertha
name: Build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Environment (PR)
if: ${{ github.event_name == 'pull_request' }}
# github actions run in the context of a special magical merge commit between the head of the PR
# and the base branch. this means that the commit hash is not the same as the head of the PR.
# we have to conditionally grab the head of the PR and truncate it to 7 characters.
run: |
echo "COMMIT_SHORT_HASH=`echo ${{ github.event.pull_request.head.sha }} | cut -c1-7`" >> ${GITHUB_ENV}
# in the case of a direct push to a branch, e.g. yoloing to develop or main, GITHUB_SHA is the head commit
# of the branch and we can use that directly.
- name: Setup Environment (Push)
if: ${{ github.event_name == 'push' }}
run: |
echo "COMMIT_SHORT_HASH=`echo ${GITHUB_SHA} | cut -c1-7`" >> ${GITHUB_ENV}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Cache
uses: actions/cache@v3
with:
path: |
node_modules
~/.cache/Cypress
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Yarn Install
run: yarn install --frozen-lockfile
- name: Build
run: yarn env && yarn build
# a poor mans extension of cloudflare/pages-action@1 https://github.com/cloudflare/pages-action/blob/main/src/index.ts
# passing more params directly to wrangler to control commit hash and message
# https://developers.cloudflare.com/workers/wrangler/commands/#publish-1
- name: Deploy
run: npx -y wrangler@2 pages publish build --project-name="${{ env.PROJECT_NAME }}" --branch="${{ env.GITHUB_BRANCH_NAME }}" --commit-hash="${{ env.COMMIT_SHORT_HASH }}" --commit-message="${{ env.GITHUB_BRANCH_NAME }}-${{ env.COMMIT_SHORT_HASH }}"
35 changes: 19 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,27 @@
"@metamask/detect-provider": "^1.2.0",
"@react-spring/web": "^9.5.2",
"@reduxjs/toolkit": "^1.8.2",
"@shapeshiftoss/asset-service": "^8.8.0",
"@shapeshiftoss/caip": "^8.13.0",
"@shapeshiftoss/chain-adapters": "11.1.0",
"@shapeshiftoss/asset-service": "^8.8.1",
"@shapeshiftoss/caip": "^8.14.0",
"@shapeshiftoss/chain-adapters": "11.1.2",
"@shapeshiftoss/errors": "^1.1.3",
"@shapeshiftoss/hdwallet-core": "^1.42.0",
"@shapeshiftoss/hdwallet-keepkey": "^1.42.0",
"@shapeshiftoss/hdwallet-keepkey-webusb": "^1.42.0",
"@shapeshiftoss/hdwallet-keplr": "^1.42.0",
"@shapeshiftoss/hdwallet-metamask": "^1.42.0",
"@shapeshiftoss/hdwallet-native": "^1.42.0",
"@shapeshiftoss/hdwallet-native-vault": "^1.42.0",
"@shapeshiftoss/hdwallet-portis": "^1.42.0",
"@shapeshiftoss/hdwallet-tallyho": "^1.42.0",
"@shapeshiftoss/hdwallet-walletconnect": "^1.42.0",
"@shapeshiftoss/hdwallet-xdefi": "^1.42.0",
"@shapeshiftoss/hdwallet-core": "^1.44.0",
"@shapeshiftoss/hdwallet-keepkey": "^1.44.0",
"@shapeshiftoss/hdwallet-keepkey-webusb": "^1.44.0",
"@shapeshiftoss/hdwallet-keplr": "^1.44.0",
"@shapeshiftoss/hdwallet-metamask": "^1.44.0",
"@shapeshiftoss/hdwallet-native": "^1.44.0",
"@shapeshiftoss/hdwallet-native-vault": "^1.44.0",
"@shapeshiftoss/hdwallet-portis": "^1.44.0",
"@shapeshiftoss/hdwallet-tallyho": "^1.44.0",
"@shapeshiftoss/hdwallet-walletconnect": "^1.44.0",
"@shapeshiftoss/hdwallet-xdefi": "^1.44.0",
"@shapeshiftoss/investor-foxy": "^7.1.0",
"@shapeshiftoss/investor-idle": "^2.5.0",
"@shapeshiftoss/investor-idle": "^2.6.0",
"@shapeshiftoss/investor-yearn": "^6.4.0",
"@shapeshiftoss/logger": "^1.1.3",
"@shapeshiftoss/market-service": "^7.7.0",
"@shapeshiftoss/swapper": "^17.3.0",
"@shapeshiftoss/swapper": "^17.3.4",
"@shapeshiftoss/types": "8.5.0",
"@shapeshiftoss/unchained-client": "^10.12.1",
"@uniswap/sdk": "^3.0.3",
Expand All @@ -124,6 +124,7 @@
"axios": "^0.26.1",
"bignumber.js": "^9.0.2",
"bip39": "^3.0.4",
"browserify-fs": "^1.0.0",
"browserify-zlib": "^0.2.0",
"bs58check": "^2.1.2",
"chakra-ui-steps": "^1.7.3",
Expand All @@ -136,6 +137,7 @@
"eth-url-parser": "^1.0.4",
"framer-motion": "^6.3.11",
"friendly-challenge": "0.9.2",
"grapheme-splitter": "^1.0.4",
"html-react-parser": "^1.4.14",
"html5-qrcode": "^2.2.1",
"https-browserify": "^1.0.0",
Expand All @@ -144,6 +146,7 @@
"lodash": "^4.17.21",
"match-sorter": "^6.3.0",
"node-polyglot": "^2.4.0",
"os-browserify": "^0.3.0",
"qr-image": "^3.2.0",
"qs": "^6.10.5",
"re-reselect": "^4.0.0",
Expand Down
2 changes: 2 additions & 0 deletions react-app-rewired/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const reactAppRewireConfig = {
crypto: require.resolve('crypto-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
fs: require.resolve('browserify-fs'),
os: require.resolve('os-browserify'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
zlib: require.resolve('browserify-zlib'),
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getSerializedEnvVars = (environment: Environment) => {
*/
const getSpecifiedEnvironment = (): Environment => {
const args = process.argv.slice(2)
const branch = process.env.CF_PAGES_BRANCH
const branch = process.env.CF_PAGES_BRANCH || process.env.GITHUB_BRANCH_NAME

// we're in a CI environment - we called the script as `yarn env` and hope the branch is set
if (branch) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const createDraftPR = async (): Promise<void> => {
const { messages } = await getCommits('release')
// TODO(0xdef1cafe): parse version bump from commit messages
const nextVersion = await getNextReleaseVersion('minor')
const title = `chore: release ${nextVersion} [DO NOT MERGE]`
const title = `chore: release ${nextVersion}`
const command = `gh pr create --draft --base "main" --title "${title}" --body "${messages}"`
console.log(chalk.green('Creating draft PR...'))
await pify(exec)(command)
Expand Down
1 change: 1 addition & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const getHeadShortCommitHash = async (): Promise<string> =>
export const getSemverTags = async (): Promise<string[]> => {
// safety in case we pick up other tags from other packages
const WEB_VERSION_RANGES = '>1.0.0 <2.0.0'
await git().fetch(['origin', '--tags', '--force'])
const tags = await git().tags()
const allTags: string[] = tags.all
const validTags: string[] = allTags
Expand Down
4 changes: 2 additions & 2 deletions scripts/writeBuildMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
import { writeFileSync } from 'fs'

import { getHeadShortCommitHash, getLatestSemverTag } from './utils'
import { getLatestSemverTag } from './utils';

const main = async () => {
const latestTag = await getLatestSemverTag()
const headShortCommitHash = await getHeadShortCommitHash()
const headShortCommitHash = process.env.COMMIT_SHORT_HASH // comes from cloudflare.yml
const payload = JSON.stringify({ latestTag, headShortCommitHash }, null, 2)
console.log(payload)
writeFileSync('./build/metadata.json', payload)
Expand Down
6 changes: 6 additions & 0 deletions src/components/Trade/hooks/useSwapper/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ export const isSupportedNonUtxoSwappingChain = (
chainId === KnownChainIds.ThorchainMainnet
)
}

export const isSupportedCosmosSdkSwappingChain = (
chainId: ChainId,
): chainId is SupportedSwappingChain => {
return chainId === KnownChainIds.OsmosisMainnet || chainId === KnownChainIds.CosmosMainnet
}
39 changes: 32 additions & 7 deletions src/components/Trade/hooks/useSwapper/useSwapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useAvailableSwappers } from 'components/Trade/hooks/useAvailableSwapper
import { useReceiveAddress } from 'components/Trade/hooks/useReceiveAddress'
import { getSwapperManager } from 'components/Trade/hooks/useSwapper/swapperManager'
import {
isSupportedCosmosSdkSwappingChain,
isSupportedNonUtxoSwappingChain,
isSupportedUtxoSwappingChain,
} from 'components/Trade/hooks/useSwapper/typeGuards'
Expand Down Expand Up @@ -39,6 +40,7 @@ export const useSwapper = () => {
const buyTradeAsset = useWatch({ control, name: 'buyTradeAsset' })
const quote = useWatch({ control, name: 'quote' })
const sellAssetAccountId = useWatch({ control, name: 'sellAssetAccountId' })
const buyAssetAccountId = useWatch({ control, name: 'buyAssetAccountId' })
const isSendMax = useWatch({ control, name: 'isSendMax' })
const isExactAllowance = useWatch({ control, name: 'isExactAllowance' })
const slippage = useWatch({ control, name: 'slippage' })
Expand Down Expand Up @@ -94,6 +96,18 @@ export const useSwapper = () => {
selectBIP44ParamsByAccountId(state, sellAccountFilter),
)

const buyAssetAccountIds = useAppSelector(state =>
selectPortfolioAccountIdsByAssetId(state, { assetId: buyAsset?.assetId ?? '' }),
)
const buyAccountFilter = useMemo(
() => ({ accountId: buyAssetAccountId ?? buyAssetAccountIds[0] }),
[buyAssetAccountId, buyAssetAccountIds],
)

const buyAccountBip44Params = useAppSelector(state =>
selectBIP44ParamsByAccountId(state, buyAccountFilter),
)

/*
Cross-account trading means trades that are either:
- Trades between assets on the same chain but different accounts
Expand Down Expand Up @@ -161,6 +175,7 @@ export const useSwapper = () => {
if (!receiveAddress) throw new Error('Missing receiveAddress')
if (!sellAssetAccountId) throw new Error('Missing sellAssetAccountId')
if (!sellAccountBip44Params) throw new Error('Missing sellAccountBip44Params')
if (!buyAccountBip44Params) throw new Error('Missing buyAccountBip44Params')
if (!sellAccountMetadata) throw new Error('Missing sellAccountMetadata')

const buildTradeCommonArgs: BuildTradeInputCommonArgs = {
Expand All @@ -176,7 +191,16 @@ export const useSwapper = () => {
slippage,
}
const sellAssetChainId = sellAsset.chainId
if (isSupportedNonUtxoSwappingChain(sellAssetChainId)) {
if (isSupportedCosmosSdkSwappingChain(sellAssetChainId)) {
const { accountNumber } = sellAccountBip44Params
const { accountNumber: receiveAccountNumber } = buyAccountBip44Params
return bestTradeSwapper.buildTrade({
...buildTradeCommonArgs,
chainId: sellAssetChainId,
accountNumber,
receiveAccountNumber,
})
} else if (isSupportedNonUtxoSwappingChain(sellAssetChainId)) {
const { accountNumber } = sellAccountBip44Params
return bestTradeSwapper.buildTrade({
...buildTradeCommonArgs,
Expand All @@ -201,18 +225,19 @@ export const useSwapper = () => {
})
}
}, [
sellAsset,
bestTradeSwapper,
sellTradeAsset?.amountCryptoPrecision,
sellTradeAsset?.asset,
buyTradeAsset?.asset,
isSendMax,
wallet,
receiveAddress,
sellAccountBip44Params,
sellAsset,
sellAssetAccountId,
sellAccountBip44Params,
buyAccountBip44Params,
sellAccountMetadata,
sellTradeAsset?.amountCryptoPrecision,
sellTradeAsset?.asset,
isSendMax,
slippage,
wallet,
])

// useEffects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import { CircularProgress } from 'components/CircularProgress/CircularProgress'
import type { DefiStepProps } from 'components/DeFi/components/Steps'
import { Steps } from 'components/DeFi/components/Steps'
import { useBrowserRouter } from 'hooks/useBrowserRouter/useBrowserRouter'
import { selectAssetById, selectMarketDataById } from 'state/slices/selectors'
import type { StakingId } from 'state/slices/opportunitiesSlice/types'
import {
selectAssetById,
selectMarketDataById,
selectStakingOpportunitiesById,
} from 'state/slices/selectors'
import { useAppSelector } from 'state/store'

import { ClaimContext } from './ClaimContext'
Expand Down Expand Up @@ -50,6 +55,12 @@ export const IdleClaim: React.FC<IdleClaimProps> = ({ accountId }) => {

const marketData = useAppSelector(state => selectMarketDataById(state, underlyingAssetId))

const opportunitiesMetadata = useAppSelector(state => selectStakingOpportunitiesById(state))
const opportunityMetadata = useMemo(
() => opportunitiesMetadata[assetId as StakingId],
[assetId, opportunitiesMetadata],
)

// user info
const handleBack = useCallback(() => {
history.push({
Expand Down Expand Up @@ -78,7 +89,7 @@ export const IdleClaim: React.FC<IdleClaimProps> = ({ accountId }) => {
// We only need this to update on symbol change
}, [accountId, translate, underlyingAsset.symbol])

if (!asset || !marketData)
if (!asset || !marketData || !opportunityMetadata)
return (
<Center minW='350px' minH='350px'>
<CircularProgress />
Expand All @@ -90,7 +101,7 @@ export const IdleClaim: React.FC<IdleClaimProps> = ({ accountId }) => {
<DefiModalContent>
<DefiModalHeader
title={translate('modals.claim.claimFrom', {
opportunity: `${underlyingAsset.symbol} Vault`,
opportunity: opportunityMetadata.name,
})}
onBack={handleBack}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const IdleDeposit: React.FC<IdleDepositProps> = ({

const value = useMemo(() => ({ state, dispatch }), [state])

if (loading || !asset || !marketData) {
if (loading || !asset || !marketData || !opportunityData) {
return (
<Center minW='350px' minH='350px'>
<CircularProgress />
Expand All @@ -154,7 +154,7 @@ export const IdleDeposit: React.FC<IdleDepositProps> = ({
<DepositContext.Provider value={value}>
<DefiModalContent>
<DefiModalHeader
title={translate('modals.deposit.depositInto', { opportunity: `${asset.symbol} Vault` })}
title={translate('modals.deposit.depositInto', { opportunity: opportunityData.name })}
onBack={handleBack}
/>
<Steps steps={StepConfig} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const IdleWithdraw: React.FC<WithdrawProps> = ({ accountId }) => {

const value = useMemo(() => ({ state, dispatch }), [state])

if (!asset || !marketData)
if (!asset || !marketData || !opportunityData)
return (
<Center minW='350px' minH='350px'>
<CircularProgress />
Expand All @@ -146,7 +146,7 @@ export const IdleWithdraw: React.FC<WithdrawProps> = ({ accountId }) => {
<DefiModalContent>
<DefiModalHeader
title={translate('modals.withdraw.withdrawFrom', {
opportunity: `${underlyingAsset.symbol} Vault`,
opportunity: opportunityData.name,
})}
onBack={handleBack}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type EstimatedFee = {
type WithdrawValues = {
underlyingAsset0: OsmosisToken
underlyingAsset1: OsmosisToken
shareOutAmountBaseUnit: string
shareInAmountBaseUnit: string
}

type OsmosisWithdrawValues = WithdrawValues &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const initialState: OsmosisWithdrawState = {
denom: '',
},
estimatedFeeCryptoBaseUnit: '',
shareOutAmountBaseUnit: '',
shareInAmountBaseUnit: '',
txStatus: 'pending',
usedGasFee: '',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const Confirm: React.FC<ConfirmProps> = ({ accountId, onNext }) => {
if (!(walletState && walletState.wallet)) return
return await chainAdapter.buildLPRemoveTransaction({
poolId: poolData.id,
shareOutAmount: state.withdraw.shareOutAmountBaseUnit,
shareInAmount: state.withdraw.shareInAmountBaseUnit,
tokenOutMins: [
{
amount: bnOrZero(state.withdraw.underlyingAsset0.amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export const Withdraw: React.FC<WithdrawProps> = ({
payload: {
underlyingAsset0: tokenOutMinsCryptoBaseUnit[0],
underlyingAsset1: tokenOutMinsCryptoBaseUnit[1],
shareOutAmountBaseUnit: bnOrZero(formValues.cryptoAmount)
shareInAmountBaseUnit: bnOrZero(formValues.cryptoAmount)
.multipliedBy(bn(10).pow(lpAsset.precision))
.toFixed(0, BigNumber.ROUND_DOWN)
.toString(),
Expand Down
Loading