Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/8.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mwmerz committed Jan 11, 2024
2 parents 212fcaa + 63d9251 commit 1b3e534
Show file tree
Hide file tree
Showing 30 changed files with 304 additions and 166 deletions.
17 changes: 11 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@terra-money/log-finder-ruleset": "^3.0.3",
"@terra-money/msg-reader": "^3.0.1",
"@terra-money/station-connector": "^1.0.12",
"@terra-money/station-ui": "^1.0.1",
"@terra-money/station-ui": "^1.0.3",
"@terra-money/terra-utils": "^1.2.0-beta.7",
"@terra-money/terra.js": "^3.1.9",
"@terra-money/terra.proto": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 3,
"name": "Station Wallet",
"version": "8.0.3",
"version_name": "8.0.3",
"version": "8.0.4",
"version_name": "8.0.4",
"background": {
"service_worker": "background.js"
},
Expand Down
26 changes: 13 additions & 13 deletions scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const PortStream = require("extension-port-stream")
if (typeof importScripts !== "undefined") {
importScripts("browser-polyfill.js")
}
import PortStream from "extension-port-stream"
import browser from "webextension-polyfill"

const connectRemote = (remotePort) => {
if (remotePort.name !== "TerraStationExtension") {
Expand Down Expand Up @@ -113,8 +111,10 @@ const connectRemote = (remotePort) => {

const denied =
oldValue &&
oldValue.request.length - 1 === newValue.request.length &&
oldValue.allowed.length === newValue.allowed.length
(oldValue.request || []).length - 1 ===
(newValue.request || []).length &&
(oldValue.allowed || []).length ===
(newValue.allowed || []).length

if (!denied)
browser.storage.local
Expand All @@ -131,12 +131,12 @@ const connectRemote = (remotePort) => {
// - send back the response and close the popup.
// 2. If not,
// - store the address on the storage and open the popup to request it (only if it is not the requested address).
const isAllowed = connect.allowed.includes(origin)
const allowed = connect.allowed || []
const request = connect.request || []

const isAllowed = allowed.includes(origin)
const walletExists = wallet.address
const alreadyRequested = [
...connect.request,
...connect.allowed,
].includes(origin)
const alreadyRequested = [...request, ...allowed].includes(origin)

if (isAllowed && walletExists) {
sendResponse("onConnect", wallet)
Expand All @@ -145,7 +145,7 @@ const connectRemote = (remotePort) => {
} else {
!alreadyRequested &&
browser.storage.local.set({
connect: { ...connect, request: [origin, ...connect.request] },
connect: { ...connect, request: [origin, ...request] },
})

openPopup()
Expand Down Expand Up @@ -189,7 +189,7 @@ const connectRemote = (remotePort) => {
// - send back the response and close the popup.
// 2. If not,
// - store the address on the storage and open the popup to request it (only if it is not the requested address).
const isAllowed = connect.allowed.includes(origin)
const isAllowed = (connect.allowed || []).includes(origin)
const hasPubKey = wallet.pubkey

if (isAllowed && hasPubKey) {
Expand Down
35 changes: 13 additions & 22 deletions src/app/sections/DashboardButton.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import { DashboardIcon, Tooltip } from "@terra-money/station-ui"
import { useTranslation } from "react-i18next"
import { ForwardedRef, forwardRef } from "react"
import { DashboardIcon } from "@terra-money/station-ui"
import HeaderIconButton from "app/components/HeaderIconButton"
import { STATION } from "config/constants"

const DashboardButton = () => {
const openDashboard = () => window.open(STATION, "_blank")
const { t } = useTranslation()

return (
<Tooltip
content={t("Dashboard")}
children={
const DashboardButton = forwardRef(
(_, ref: ForwardedRef<HTMLButtonElement>) => {
const openDashboard = () => window.open(STATION, "_blank")
return (
<HeaderIconButton onClick={openDashboard} ref={ref}>
<DashboardIcon
width={18}
height={18}
onClick={openDashboard}
style={{
cursor: "pointer",
//margin: "24px 12px 16px 16px",
}}
fill={"var(--token-dark-900)"}
style={{ height: 18, width: 18, fill: "var(--token-dark-900)" }}
/>
}
/>
)
}
</HeaderIconButton>
)
}
)

export default DashboardButton
2 changes: 1 addition & 1 deletion src/auth/ledger/AccessWithLedger.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

.form {
height: 100%;
height: 80%;
}

.form__container {
Expand Down
23 changes: 17 additions & 6 deletions src/auth/modules/create/CreateMultisigWalletForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
InputWrapper,
Banner,
SubmitButton,
ButtonInlineWrapper,
} from "@terra-money/station-ui"
import { wordsFromAddress } from "utils/bech32"
import { truncate } from "@terra-money/terra-utils"
Expand All @@ -35,9 +36,10 @@ interface Props {
threshold: number
words: { "330": string }
}) => void
onBack?: () => void
}

const CreateMultisigWalletForm = ({ onCreated, onPubkey }: Props) => {
const CreateMultisigWalletForm = ({ onCreated, onPubkey, onBack }: Props) => {
const { t } = useTranslation()
const lcd = useInterchainLCDClient()

Expand Down Expand Up @@ -177,11 +179,20 @@ const CreateMultisigWalletForm = ({ onCreated, onPubkey }: Props) => {

{error && <Banner variant="error" title={error.message} />}

<SubmitButton
loading={submitting}
disabled={!isValid}
label={t("Create")}
/>
<ButtonInlineWrapper>
{!!onBack && (
<Button
variant="secondary"
label={t("Back")}
onClick={() => onBack()}
/>
)}
<SubmitButton
loading={submitting}
disabled={!isValid}
label={t("Create")}
/>
</ButtonInlineWrapper>
</Form>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/auth/modules/create/CreateWalletWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const CreateWalletWizard = ({ defaultMnemonic = "", beforeCreate }: Props) => {
const { name, mnemonic, coinType, index, seedPassword, legacySeedKey } =
values

console.log(seedPassword && legacyDecrypt(mnemonic, seedPassword ?? ""))
const seed = seedPassword
? legacySeedKey
? Buffer.from(legacyDecrypt(mnemonic, seedPassword), "hex")
Expand Down
4 changes: 3 additions & 1 deletion src/components/token/Read.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Props extends Partial<FormatConfig> {
amount?: Amount | Value
denom?: Denom
token?: Token
chainID?: string
currency?: boolean

approx?: boolean
Expand All @@ -34,6 +35,7 @@ const Read = forwardRef(
approx,
block,
comma = false,
chainID,
decimalSizeSecondary,
...props
}: Props,
Expand Down Expand Up @@ -84,7 +86,7 @@ const Read = forwardRef(
return (
<span className={styles.symbol}>
{" "}
<WithTokenItem token={token}>
<WithTokenItem token={token} chainID={chainID}>
{({ symbol }) =>
AccAddress.validate(symbol)
? truncate(symbol)
Expand Down
16 changes: 9 additions & 7 deletions src/data/queries/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useTxActivity = () => {
const addresses = useInterchainAddresses()
const cachedTxs = useCachedTx()

const LIMIT = 60
// const LIMIT = 60
const EVENTS = [
// any tx signed by the user
"message.sender",
Expand Down Expand Up @@ -104,7 +104,7 @@ export const useTxActivity = () => {
//order_by: "ORDER_BY_DESC",
[paginationKeys.offset]: 0 || undefined,
[paginationKeys.reverse]: isTerra ? 2 : true,
[paginationKeys.limit]: LIMIT,
// [paginationKeys.limit]: LIMIT,
},
})
} catch (e) {
Expand All @@ -123,10 +123,12 @@ export const useTxActivity = () => {
})
}

return result
.sort((a, b) => Number(b.height) - Number(a.height))
.slice(0, LIMIT)
.map((tx) => ({ ...tx, chain: chainID }))
return (
result
.sort((a, b) => Number(b.height) - Number(a.height))
// .slice(0, LIMIT)
.map((tx) => ({ ...tx, chain: chainID }))
)
},
...RefetchOptions.DEFAULT,
}
Expand Down Expand Up @@ -182,5 +184,5 @@ export const useTxActivity = () => {
activitySorted.push(tx)
})

return { activitySorted: activitySorted.reverse().slice(0, LIMIT), state }
return { activitySorted: activitySorted.reverse(), state }
}
29 changes: 25 additions & 4 deletions src/data/queries/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ export function useIBCChannels() {
// the destination netowrk does not need to be enabled in order to send tokens to it
const networks = useAllNetworks()

function getICS20(to: string, from: string, token: AccAddress) {
const channels = networks[from]?.ics20Channels?.[to]
return (
// ics20 channel specific for this token
channels?.find(({ tokens }) => !!tokens?.find((t) => t === token)) ||
// default ics channel for the chain
channels?.find(({ tokens }) => !tokens) ||
// fallback: ics channel from legacy assetlist | TODO: remove when this PR gets merged: https://github.com/terra-money/station-assets/pull/203
networks[from]?.icsChannels?.[to]
)
}

return {
getIBCChannel: ({
from,
Expand All @@ -87,14 +99,21 @@ export function useIBCChannels() {
const isCW20 = AccAddress.validate(tokenAddress)

if (isCW20) {
return networks[from]?.icsChannels?.[to]?.channel
return getICS20(to, from, tokenAddress)?.channel
}

if (
icsChannel &&
networks[to]?.icsChannels?.[from]?.channel === icsChannel
(networks[to]?.ics20Channels?.[from].find(
({ channel }) => channel === icsChannel
) ||
networks[to]?.icsChannels?.[from]?.channel === icsChannel)
) {
return networks[to]?.icsChannels?.[from]?.otherChannel
return (
networks[to]?.ics20Channels?.[from].find(
({ channel }) => channel === icsChannel
)?.otherChannel || networks[to]?.icsChannels?.[from]?.otherChannel
)
}

return networks[from]?.channels?.[to]
Expand All @@ -103,11 +122,13 @@ export function useIBCChannels() {
getICSContract: ({
from,
to,
tokenAddress,
}: {
from: string
to: string
tokenAddress: AccAddress
}): string | undefined => {
return networks[from]?.icsChannels?.[to]?.contract
return getICS20(to, from, tokenAddress)?.contract
},
}
}
6 changes: 3 additions & 3 deletions src/data/queries/swap/skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const skipApi = {
dest_asset_chain_id: askAsset.chainId,
address_list: route.chainIds.map((chainId) => addresses[chainId]),
operations: route.operations,
slippage_tolerance_percent: slippageTolerance,
slippage_tolerance_percent: slippageTolerance.toString(),
}
const res = await axios.post(SKIP_SWAP_API.routes.msgs, params, {
baseURL: SKIP_SWAP_API.baseUrl,
Expand All @@ -71,11 +71,11 @@ export const skipApi = {
},
})
if (!res?.data?.msgs) {
throw new Error("No messages returned from Skip API")
throw new Error("No available swap routes for this pair")
}
return res.data.msgs
} catch (err) {
throw new Error(`Unkown error`)
throw new Error(`Unknown error`)
}
},
queryRoute: async (swap: SwapState, network: IInterchainNetworks) => {
Expand Down
2 changes: 1 addition & 1 deletion src/data/queries/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useTxInfo = ({ txhash, queryKeys, chainID }: LatestTx) => {
})

queryClient.invalidateQueries(queryKey.History)
queryClient.invalidateQueries(queryKey.bank.balance)
queryClient.invalidateQueries(queryKey.bank.balances)
queryClient.invalidateQueries(queryKey.tx.create)
},
}
Expand Down
Loading

0 comments on commit 1b3e534

Please sign in to comment.