Skip to content

Commit

Permalink
v1.17.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Dec 26, 2023
1 parent d1f8edb commit 2684381
Show file tree
Hide file tree
Showing 29 changed files with 277 additions and 103 deletions.
70 changes: 63 additions & 7 deletions .github/workflows/package-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
push:
branches:
- master
- mobile-release

concurrency:
group: ${{ github.ref }}
Expand Down Expand Up @@ -267,8 +266,8 @@ jobs:
name: ${{ env.APP_NAME }}-firefox.zip
path: ${{ env.APP_NAME }}-firefox.zip

extensions-publish:
name: Publish extensions
chrome-publish:
name: Publish Chrome extension
needs: extensions-package
runs-on: ubuntu-latest
timeout-minutes: 5
Expand Down Expand Up @@ -302,6 +301,27 @@ jobs:
REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }}
run: npx --yes chrome-webstore-upload-cli@2 upload --auto-publish --source ${{ env.CHROME_FILE_NAME }}

firefox-publish:
name: Publish Firefox extension
needs: extensions-package
runs-on: ubuntu-latest
timeout-minutes: 5
if: vars.PUBLISH_REPO != ''
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Set environment variables
id: variables
shell: bash
run: |
echo "FIREFOX_FILE_NAME=${{ env.APP_NAME }}-firefox.zip" >> "$GITHUB_ENV"
- name: Download Firefox extension artifact
uses: actions/download-artifact@v3
with:
Expand All @@ -314,19 +334,55 @@ jobs:
# App env
PROXY_HOSTS: ${{ vars.PROXY_HOSTS }}
STAKING_POOLS: ${{ vars.STAKING_POOLS }}
if: ${{ env.WEB_EXT_API_KEY != '' }}
run: |
npm i jsonwebtoken@9 web-ext-submit@7
UNZIP_DIR=/tmp/${{ env.APP_NAME }}-firefox
mkdir $UNZIP_DIR
unzip ${{ env.FIREFOX_FILE_NAME }} -d $UNZIP_DIR
npx web-ext-submit --source-dir=$UNZIP_DIR/dist
npx web-ext-submit --source-dir=$UNZIP_DIR
echo "APP_NAME=\"${APP_NAME}\"
PROXY_HOSTS=\"${PROXY_HOSTS}\"
STAKING_POOLS=\"${STAKING_POOLS}\"" >.env
bash deploy/firefox_pack_sources.sh
node deploy/firefoxPatchVersion.js
edge-publish:
name: Publish Edge extension
needs: extensions-package
runs-on: ubuntu-latest
if: vars.PUBLISH_REPO != ''
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Set environment variables
id: variables
shell: bash
run: |
echo "CHROME_FILE_NAME=${{ env.APP_NAME }}-chrome.zip" >> "$GITHUB_ENV"
- name: Download Chrome extension artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.CHROME_FILE_NAME }}

- name: Publish to Edge store
env:
EDGE_PRODUCT_ID: ${{ secrets.EDGE_PRODUCT_ID }}
EDGE_CLIENT_ID: ${{ secrets.EDGE_CLIENT_ID }}
EDGE_CLIENT_SECRET: ${{ secrets.EDGE_CLIENT_SECRET }}
EDGE_ACCESS_TOKEN_URL: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
run: |
npm i @plasmohq/[email protected]
export EDGE_FILE_PATH="./$CHROME_FILE_NAME"
node deploy/edgePublish.js
calculate-hash:
name: Calculate sha256 hashes
env:
Expand Down Expand Up @@ -355,7 +411,7 @@ jobs:
name: Build, package and publish mobile apps
runs-on: macos-latest
timeout-minutes: 30
if: vars.PUBLISH_REPO == '' && github.event_name != 'workflow_dispatch'
if: github.event_name != 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -388,7 +444,7 @@ jobs:
STAKING_POOLS: ${{ vars.STAKING_POOLS }}
PUBLISH_REPO: ${{ vars.PUBLISH_REPO }}
run: |
if [ "$GITHUB_REF_NAME" == "mobile-release" ]; then
if [ "$PUBLISH_REPO" != "" ]; then
npm run mobile:build:production
else
npm run mobile:build:staging
Expand Down
1 change: 1 addition & 0 deletions changelogs/1.17.5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bug fixes
44 changes: 44 additions & 0 deletions deploy/edgePublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const fs = require('fs');

const {
EDGE_PRODUCT_ID,
EDGE_CLIENT_ID,
EDGE_CLIENT_SECRET,
EDGE_ACCESS_TOKEN_URL,
EDGE_FILE_PATH = './MyTonWallet-chrome.zip',
EDGE_NOTES_PATH,
} = process.env;

if (
!EDGE_PRODUCT_ID
|| !EDGE_CLIENT_ID
|| !EDGE_CLIENT_SECRET
|| !EDGE_ACCESS_TOKEN_URL
|| !EDGE_FILE_PATH
) {
console.error('Missing env vars!')
process.exit(1);
}

(async () => {
const { EdgeAddonsAPI } = await import('@plasmohq/edge-addons-api');

const client = new EdgeAddonsAPI({
productId: EDGE_PRODUCT_ID,
clientId: EDGE_CLIENT_ID,
clientSecret: EDGE_CLIENT_SECRET,
accessTokenUrl: EDGE_ACCESS_TOKEN_URL,
});

let notes = undefined;
if (EDGE_NOTES_PATH && await fs.promises.access(file, fs.constants.F_OK)) {
notes = await fs.promises.readFile(EDGE_NOTES_PATH);
}

const operationId = await client.submit({
filePath: EDGE_FILE_PATH,
notes,
});

console.log('Publish operation ID:', operationId);
})();
13 changes: 13 additions & 0 deletions deploy/postversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -e

VERSION=$(node -p "require('./package.json').version")
DEFAULT_CHANGELOG="Bug fixes"

echo $VERSION > public/version.txt

echo $DEFAULT_CHANGELOG > changelogs/$VERSION.txt
git add changelogs/$VERSION.txt

git commit --amend --no-verify --no-edit public/version.txt changelogs/$VERSION.txt
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mytonwallet",
"version": "1.17.4",
"version": "1.17.5",
"description": "The most feature-rich web wallet and browser extension for TON – with support of multi-accounts, tokens (jettons), NFT, TON DNS, TON Sites, TON Proxy, and TON Magic.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -38,7 +38,7 @@
"test:record": "playwright codegen localhost:1235",
"prepare": "husky install",
"statoscope:validate-diff": "statoscope validate --input input.json --reference reference.json",
"postversion": "echo $(node -p \"require('./package.json').version\") > public/version.txt && git commit --amend --no-verify --no-edit public/version.txt"
"postversion": "./deploy/postversion.sh"
},
"engines": {
"node": "^18",
Expand Down
2 changes: 1 addition & 1 deletion public/electronVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.0
1.17.5
2 changes: 1 addition & 1 deletion public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.4
1.17.5
5 changes: 4 additions & 1 deletion src/api/blockchains/ton/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ export async function getStakingState(
let unstakeAmount = Big(0);

if (collection) {
const nfts = await apiDb.nfts.where({ collectionAddress: collection }).toArray();
const nfts = await apiDb.nfts.where({
accountId,
collectionAddress: collection,
}).toArray();

for (const nft of nfts) {
const billAmount = nft.name?.match(/Bill for (?<amount>[\d.]+) Pool Jetton/)?.groups?.amount;
Expand Down
15 changes: 11 additions & 4 deletions src/components/common/TokenSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {
} from '../../lib/teact/teact';
import { getActions, withGlobal } from '../../global';

import type { ApiBaseCurrency } from '../../api/types';
import type { ApiBaseCurrency, ApiToken } from '../../api/types';
import {
type AssetPairs,
SettingsState,
Expand All @@ -14,8 +14,8 @@ import {
import { ANIMATED_STICKER_MIDDLE_SIZE_PX, TON_BLOCKCHAIN } from '../../config';
import { Big } from '../../lib/big.js/index.js';
import {
selectAvailableUserForSwapTokens,
selectCurrentAccountState,
selectCurrentAccountTokens,
selectPopularTokens,
selectSwapTokens,
} from '../../global/selectors';
Expand Down Expand Up @@ -54,6 +54,7 @@ interface StateProps {
tokenInSlug?: string;
pairsBySlug?: Record<string, AssetPairs>;
balancesBySlug?: Record<string, string>;
tokenInfoBySlug?: Record<string, ApiToken>;
baseCurrency?: ApiBaseCurrency;
isLoading?: boolean;
}
Expand Down Expand Up @@ -87,6 +88,7 @@ function TokenSelector({
tokenInSlug,
pairsBySlug,
balancesBySlug,
tokenInfoBySlug,
isActive,
isLoading,
onBack,
Expand Down Expand Up @@ -293,7 +295,11 @@ function TokenSelector({
currentToken?.symbol.toLowerCase() as keyof typeof ASSET_LOGO_PATHS
] ?? currentToken?.image;
const blockchain = 'blockchain' in currentToken ? currentToken.blockchain : TON_BLOCKCHAIN;
const price = 'price' in currentToken ? currentToken.price : 1;
const price = 'price' in currentToken
? currentToken.price
: tokenInfoBySlug?.[currentToken.slug]
? tokenInfoBySlug?.[currentToken.slug].quote.price
: 0;

const isAvailable = !shouldFilter || currentToken.canSwap;
const descriptionText = isAvailable
Expand Down Expand Up @@ -506,7 +512,7 @@ export default memo(withGlobal<OwnProps>((global): StateProps => {
const { isLoading, token } = global.settings.importToken ?? {};
const { pairs, tokenInSlug } = global.currentSwap ?? {};

const userTokens = selectCurrentAccountTokens(global);
const userTokens = selectAvailableUserForSwapTokens(global);
const popularTokens = selectPopularTokens(global);
const swapTokens = selectSwapTokens(global);
const { baseCurrency } = global.settings;
Expand All @@ -521,6 +527,7 @@ export default memo(withGlobal<OwnProps>((global): StateProps => {
baseCurrency,
pairsBySlug: pairs?.bySlug,
balancesBySlug: balances?.bySlug,
tokenInfoBySlug: global.tokenInfo.bySlug,
};
})(TokenSelector));

Expand Down
32 changes: 8 additions & 24 deletions src/components/main/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BottomSheet } from 'native-bottom-sheet';
import React, {
memo, useEffect, useRef, useState,
} from '../../lib/teact/teact';
Expand All @@ -12,12 +11,10 @@ import buildClassName from '../../util/buildClassName';
import { getStatusBarHeight } from '../../util/capacitor';
import { captureEvents, SwipeDirection } from '../../util/captureEvents';
import { setStatusBarStyle } from '../../util/switchTheme';
import {
getSafeAreaTop, IS_DELEGATED_BOTTOM_SHEET, IS_TOUCH_ENV, REM,
} from '../../util/windowEnvironment';
import { IS_DELEGATED_BOTTOM_SHEET, IS_TOUCH_ENV, REM } from '../../util/windowEnvironment';
import windowSize from '../../util/windowSize';

import { useOpenFromMainBottomSheet } from '../../hooks/useDelegatedBottomSheet';
import { useOpenFromNativeBottomSheet } from '../../hooks/useDelegatingBottomSheet';
import { useDeviceScreen } from '../../hooks/useDeviceScreen';
import useFlag from '../../hooks/useFlag';
import useLastCallback from '../../hooks/useLastCallback';
Expand Down Expand Up @@ -50,7 +47,6 @@ type StateProps = {
};

const STICKY_CARD_INTERSECTION_THRESHOLD = -3.75 * REM;
const STICKY_CARD_WITH_SAFE_AREA_INTERSECTION_THRESHOLD = -5.5 * REM;

function Main({
isActive,
Expand Down Expand Up @@ -80,20 +76,10 @@ function Main({
const [canRenderStickyCard, setCanRenderStickyCard] = useState(false);
const [shouldRenderDarkStatusBar, setShouldRenderDarkStatusBar] = useState(false);
const [isReceiveModalOpened, openReceiveModal, closeReceiveModal] = useFlag();

useOpenFromMainBottomSheet('staking-info', openStakingInfo);
useOpenFromNativeBottomSheet('staking-info', openStakingInfo);
const safeAreaTop = IS_CAPACITOR ? getStatusBarHeight() : windowSize.get().safeAreaTop;

useOpenFromMainBottomSheet('receive', openReceiveModal);

const handleOpenStakingInfo = useLastCallback(() => {
if (IS_DELEGATED_BOTTOM_SHEET) {
BottomSheet.openInMain({ key: 'staking-info' });
} else {
openStakingInfo();
}
});

const { isPortrait } = useDeviceScreen();
const {
shouldRender: shouldRenderStickyCard,
Expand All @@ -118,19 +104,17 @@ function Main({
return undefined;
}

const safeAreaTop = IS_CAPACITOR ? getStatusBarHeight() : getSafeAreaTop();
const rootMarginTop = safeAreaTop > 0
? STICKY_CARD_WITH_SAFE_AREA_INTERSECTION_THRESHOLD
: STICKY_CARD_INTERSECTION_THRESHOLD;
const rootMarginTop = STICKY_CARD_INTERSECTION_THRESHOLD - safeAreaTop;
const observer = new IntersectionObserver((entries) => {
const { isIntersecting, boundingClientRect: { left, width } } = entries[0];
setCanRenderStickyCard(entries.length > 0 && !isIntersecting && left >= 0 && left < width);
}, { rootMargin: `${rootMarginTop}px 0px 0px` });

const cardTopSideObserver = new IntersectionObserver((entries) => {
const { isIntersecting } = entries[0];

setShouldRenderDarkStatusBar(!isIntersecting);
}, { rootMargin: `${rootMarginTop / 2}px 0px 0px`, threshold: [1] });
}, { rootMargin: `-${safeAreaTop}px 0px 0px`, threshold: [1] });
const cardElement = cardRef.current;

if (cardElement) {
Expand All @@ -144,7 +128,7 @@ function Main({
cardTopSideObserver.unobserve(cardElement);
}
};
}, [isActive, isPortrait]);
}, [isActive, isPortrait, safeAreaTop]);

const handleTokenCardClose = useLastCallback(() => {
selectToken({ slug: undefined });
Expand Down Expand Up @@ -233,7 +217,7 @@ function Main({
<>
{!IS_DELEGATED_BOTTOM_SHEET && (isPortrait ? renderPortraitLayout() : renderLandscapeLayout())}

<StakeModal onViewStakingInfo={handleOpenStakingInfo} />
<StakeModal />
<StakingInfoModal isOpen={isStakingInfoModalOpen} onClose={closeStakingInfo} />
<ReceiveModal isOpen={isReceiveModalOpened} onClose={closeReceiveModal} />
<UnstakingModal />
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/sections/Content/Content.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
justify-content: flex-start;

background: var(--color-background-first);
border-radius: 0 0 var(--border-radius-default) var(--border-radius-default);
Expand Down
Loading

0 comments on commit 2684381

Please sign in to comment.