Skip to content

Commit

Permalink
Merge pull request #179 from terra-money/staging
Browse files Browse the repository at this point in the history
7.2.8
  • Loading branch information
terran6 authored Jun 6, 2023
2 parents 1e5c419 + 94c797d commit 17dec6b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 87 deletions.
2 changes: 1 addition & 1 deletion public/firefox.manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Station Wallet",
"version": "7.2.7",
"version": "7.2.8",
"background": {
"scripts": ["background.js"],
"persistent": true
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Station Wallet",
"version": "7.2.7",
"version": "7.2.8",
"background": {
"service_worker": "background.js",
"type": "module"
Expand Down
2 changes: 1 addition & 1 deletion src/auth/scripts/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const decrypt = (transitmessage: string, pass: string) => {

const decoded = decrypted.toString(CryptoJS.enc.Utf8)

if (!decoded || decrypted.sigBytes < 16) throw new Error("Incorrect password")
if (!decoded || decrypted.sigBytes < 8) throw new Error("Incorrect password")

return decoded
}
Expand Down
82 changes: 2 additions & 80 deletions src/extension/modules/ConfirmTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ import ExtensionPage from "../components/ExtensionPage"
import ConfirmButtons from "../components/ConfirmButtons"
import TxDetails from "./TxDetails"
import OriginCard from "extension/components/OriginCard"
import { RefetchOptions, queryKey } from "data/query"
import { useQuery } from "react-query"
import { useInterchainAddresses } from "auth/hooks/useAddress"
import { useChainID, useNetwork } from "data/wallet"
import { useInterchainLCDClient } from "data/queries/lcdClient"
import { Fee } from "@terra-money/feather.js"

interface Values {
password: string
Expand All @@ -35,12 +29,6 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => {
const { wallet, ...auth } = useAuth()
const { actions } = useRequest()
const passwordRequired = isWallet.single(wallet)
const addresses = useInterchainAddresses()
const network = useNetwork()
const lcd = useInterchainLCDClient()
const terraChainID = useChainID()
const chainID =
"tx" in props ? props.tx.chainID ?? terraChainID : terraChainID

/* form */
const form = useForm<Values>({
Expand Down Expand Up @@ -72,69 +60,14 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => {
? t("Enter password")
: ""

const { data: estimatedGas, ...estimatedGasState } = useQuery(
[queryKey.tx.create, props, addresses?.[chainID], network[chainID]],
async () => {
if (!("tx" in props)) return 0
const { tx } = props

try {
if (!addresses || !addresses[tx.chainID] || !network[tx.chainID])
return 0
const { baseAsset, gasPrices } = network[tx.chainID]

const feeDenom =
baseAsset in gasPrices ? baseAsset : Object.keys(gasPrices)[0]

const unsignedTx = await lcd.tx.create(
[{ address: addresses[tx.chainID] }],
{
...tx,
feeDenoms: [feeDenom],
}
)

return unsignedTx.auth_info.fee.gas_limit
} catch (error) {
console.error(error)
return 200_000
}
},
{
...RefetchOptions.INFINITY,
// To handle sequence mismatch
retry: 3,
retryDelay: 1000,
refetchOnWindowFocus: false,
enabled:
"tx" in props && !props.tx.fee?.gas_limit && !!addresses?.[chainID],
}
)

let fee: Fee | undefined

if ("tx" in props && network[props.tx.chainID]) {
const { tx } = props
fee = tx.fee
if (!tx.fee?.gas_limit) {
const { baseAsset, gasPrices, gasAdjustment } = network[tx.chainID]
const gas = (estimatedGas ?? 0) * gasAdjustment

const feeDenom =
baseAsset in gasPrices ? baseAsset : Object.keys(gasPrices)[0]

fee = new Fee(gas, { [feeDenom]: gasPrices[feeDenom] * gas })
}
}

const navigate = useNavigate()
const toPostMultisigTx = useToPostMultisigTx()
const submit = async ({ password }: Values) => {
setSubmitting(true)

if ("tx" in props) {
const { requestType, tx, signMode } = props
const txOptions = { ...tx, fee }
const txOptions = tx

try {
if (disabled) throw new Error(disabled)
Expand Down Expand Up @@ -206,17 +139,6 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => {
const SIZE = { width: 100, height: 100 }
const label = props.requestType === "post" ? t("Post") : t("Sign")

if (estimatedGasState.isLoading) {
return (
<Overlay>
<FlexColumn gap={20}>
<img {...SIZE} src={animation} alt={t("Estimating fees...")} />
<p>{t("Estimating fees...")}</p>
</FlexColumn>
</Overlay>
)
}

return submitting ? (
<Overlay>
<FlexColumn gap={20}>
Expand All @@ -227,7 +149,7 @@ const ConfirmTx = (props: TxRequest | SignBytesRequest) => {
) : (
<ExtensionPage header={<OriginCard hostname={props.origin} />}>
<Grid gap={20}>
{"tx" in props && <TxDetails {...props} tx={{ ...props.tx, fee }} />}
{"tx" in props && <TxDetails {...props} />}

{warning && <FormWarning>{warning}</FormWarning>}
{error && <FormError>{error}</FormError>}
Expand Down
1 change: 0 additions & 1 deletion src/pages/custom/ManageCustomTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ const Component = ({ whitelist, keyword }: Props) => {

const ManageCustomTokens = () => {
const { data: cw20, ...cw20WhitelistState } = useCW20Whitelist()
console.log(cw20)
const { whitelist } = useWhitelist()
const networkName = useNetworkName()

Expand Down
4 changes: 1 addition & 3 deletions src/pages/wallet/IbcSendBackTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,10 @@ function IbcSendBackTx({ token, chainID }: Props) {
if (waitUntil) {
;(async () => {
while (maxIterations--) {
console.log(waitUntil)
const tokenBalance = await getBalance(
waitUntil.denom,
waitUntil.chainID
)
console.log(tokenBalance)

if (Number(tokenBalance) > waitUntil.balance) {
setWaitUntil(undefined)
Expand Down Expand Up @@ -318,7 +316,7 @@ function IbcSendBackTx({ token, chainID }: Props) {
{state.isLoading && <p>{t("Loading...")}</p>}
{isLoading && (
<>
<p>{t("Waiting fo on-chain confirmation...")}</p>
<p>{t("Waiting for on-chain confirmation...")}</p>
<p>{t("This may take a few minutes")}</p>
</>
)}
Expand Down

0 comments on commit 17dec6b

Please sign in to comment.