Skip to content

Commit

Permalink
v1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Sep 25, 2023
1 parent 6646bb5 commit 2966b95
Show file tree
Hide file tree
Showing 79 changed files with 777 additions and 306 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ postcss.config.js
coverage

trash
deploy

dist
65 changes: 55 additions & 10 deletions .github/workflows/package-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:

env:
APP_NAME: MyTonWallet
FIREFOX_EXT_ID: '{98fcdaee-2b58-4f71-8a3c-f0c66f24dede}'

jobs:
electron-release:
Expand Down Expand Up @@ -198,7 +199,7 @@ jobs:
extensions-package:
name: Build and package extensions
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -258,6 +259,9 @@ jobs:
runs-on: ubuntu-latest
if: vars.PUBLISH_REPO != ''
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -288,13 +292,54 @@ jobs:
with:
name: ${{ env.FIREFOX_FILE_NAME }}

- name: Publish to Firefox addons
env:
WEB_EXT_API_KEY: ${{ secrets.FIREFOX_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.FIREFOX_API_SECRET }}
if: ${{ env.WEB_EXT_API_KEY != '' }}
# - name: Publish to Firefox addons
# env:
# WEB_EXT_API_KEY: ${{ secrets.FIREFOX_API_KEY }}
# WEB_EXT_API_SECRET: ${{ secrets.FIREFOX_API_SECRET }}
# # App env
# TONHTTPAPI_MAINNET_URL: ${{ vars.TONHTTPAPI_MAINNET_URL }}
# TONAPIIO_MAINNET_URL: ${{ vars.TONAPIIO_MAINNET_URL }}
# TONHTTPAPI_TESTNET_URL: ${{ vars.TONHTTPAPI_TESTNET_URL }}
# TONAPIIO_TESTNET_URL: ${{ vars.TONAPIIO_TESTNET_URL }}
# 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
# web-ext-submit --source-dir=$UNZIP_DIR/dist
# echo "APP_NAME=\"${APP_NAME}\"
# TONHTTPAPI_MAINNET_URL=\"${TONHTTPAPI_MAINNET_URL}\"
# TONHTTPAPI_TESTNET_URL=\"${TONHTTPAPI_TESTNET_URL}\"
# TONAPIIO_MAINNET_URL=\"${TONAPIIO_MAINNET_URL}\"
# TONAPIIO_TESTNET_URL=\"${TONAPIIO_TESTNET_URL}\"
# PROXY_HOSTS=\"${PROXY_HOSTS}\"
# STAKING_POOLS=\"${STAKING_POOLS}\"" >.env
# bash deploy/firefox_pack_sources.sh
# node deploy/firefoxPatchVersion.js

calculate-hash:
name: Calculate sha256 hashes
env:
HASH_FILENAME: checksum.sha256
needs:
- electron-sign-for-windows
- extensions-package
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3

- name: Calculate sha256 hashes
run: |
UNZIP_DIR=/tmp/${{ env.APP_NAME }}-firefox
mkdir $UNZIP_DIR
unzip ${{ env.FIREFOX_FILE_NAME }} -d $UNZIP_DIR
npx --yes web-ext-submit@7 --source-dir=$UNZIP_DIR/dist
mkdir release
mv */*.dmg */*.exe */*.AppImage release/
sha256sum release/* >${{ env.HASH_FILENAME }}
- name: Upload hash artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.HASH_FILENAME }}
path: ${{ env.HASH_FILENAME }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist
dist-electron
MyTonWallet-chrome.zip
MyTonWallet-firefox.zip
MyTonWallet-firefox-sources.tgz
MyTonWallet-opera.zip
.cache
.env*
Expand Down
104 changes: 104 additions & 0 deletions deploy/firefoxPatchVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
const jwt = require('jsonwebtoken');
const fs = require('fs');

const {
WEB_EXT_API_KEY,
WEB_EXT_API_SECRET,
FIREFOX_EXT_ID,
} = process.env;

if (!WEB_EXT_API_KEY || !WEB_EXT_API_SECRET || !FIREFOX_EXT_ID) {
throw new Error('Missing env vars!');
}

const extId = FIREFOX_EXT_ID;
const baseUrl = 'https://addons.mozilla.org';
const sourceFile = 'MyTonWallet-firefox-sources.tgz';

const token = getAuthToken(WEB_EXT_API_KEY, WEB_EXT_API_SECRET);
const headers = { Authorization: `JWT ${token}` };

async function main() {
const { lastId, approvalNotes } = await getLastVersionsInfo();

console.log('Version ID:', lastId);
console.log('Approval notes:', approvalNotes);

await uploadSource(lastId);
await uploadApprovalNotes(lastId, approvalNotes);
}

function getAuthToken(key, secret) {
const issuedAt = Math.floor(Date.now() / 1000);
const payload = {
iss: key,
jti: Math.random().toString(),
iat: issuedAt,
exp: issuedAt + 60,
};

return jwt.sign(payload, secret, {
algorithm: 'HS256',
});
}

async function getLastVersionsInfo() {
const res = await fetch(`${baseUrl}/api/v5/addons/addon/${extId}/versions/?filter=all_with_unlisted`, {
method: 'GET',
headers,
});
handleFetchErrors(res);
const { results } = await res.json();

const lastId = results[0].id;
let approvalNotes = '';
for (const version of results) {
if (version.approval_notes) {
approvalNotes = version.approval_notes;
break;
}
}

return { lastId, approvalNotes }
}

async function uploadSource(versionId) {
const blob = new Blob(
[await fs.promises.readFile(sourceFile)],
{ type: 'application/octet-stream' },
);

const form = new FormData();
form.append('source', blob, sourceFile);

const res = await fetch(`${baseUrl}/api/v5/addons/addon/${extId}/versions/${versionId}/`, {
method: 'PATCH',
body: form,
headers,
});
handleFetchErrors(res);
}

async function uploadApprovalNotes(versionId, approvalNotes) {
const res = await fetch(`${baseUrl}/api/v5/addons/addon/${extId}/versions/${versionId}/`, {
method: 'PATCH',
body: JSON.stringify({
approval_notes: approvalNotes,
}),
headers: {
...headers,
'Content-Type': 'application/json',
},
});
handleFetchErrors(res);
}

function handleFetchErrors(response) {
if (!response.ok) {
response.json().then(console.error);
throw new Error(response.statusText);
}
return response;
}

void main();
17 changes: 17 additions & 0 deletions deploy/firefox_pack_sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

rm -f MyTonWallet-firefox-sources.tgz

COPYFILE_DISABLE=1 tar \
--exclude='*.zip' \
--exclude='*.tgz' \
--exclude=./dist \
--exclude=./dist-electron \
--exclude=./node_modules \
--exclude=./trash \
--exclude=./.DS_Store \
--exclude=./.idea \
--exclude=./mobile \
"$@" -cvzf MyTonWallet-firefox-sources.tgz ./
4 changes: 3 additions & 1 deletion deploy/package_extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ rm -rf ./dist/statoscope-* \

rm -f "MyTonWallet-$TARGET.zip"

zip -r -X "MyTonWallet-$TARGET.zip" dist/*
cd dist

zip -r -X "../MyTonWallet-$TARGET.zip" ./*
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mytonwallet",
"version": "1.15.4",
"version": "1.16.0",
"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
Binary file added public/emoji/26a0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/get/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ body {
a:hover {
text-decoration: none;
}

.missing-signatures {
color: #FF7777;
}
2 changes: 1 addition & 1 deletion public/get/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h1>MyTonWallet</h1>
<a href="javascript:downloadDefault();" class="download-btn single">Download</a>
<div class="footer">
<span class="version"></span>
<div class="version">&nbsp;</div>
<a href="javascript:redirectToFullList();">Other platforms</a>
· <a href="https://mytonwallet.io">mytonwallet.io</a>
</div>
Expand Down
37 changes: 30 additions & 7 deletions public/get/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ const packagesPromise = fetch(LATEST_RELEASE_API_URL)
name,
browser_download_url,
}) => {
let key;

if (name.endsWith('.exe')) {
acc['win'] = browser_download_url;
key = 'win';
} else if (name.endsWith('.AppImage')) {
acc['linux'] = browser_download_url;
key = 'linux';
} else if (name.endsWith('.dmg')) {
acc[`mac-${name.includes('arm') ? 'arm' : 'x64'}`] = browser_download_url;
key = `mac-${name.includes('arm') ? 'arm' : 'x64'}`;
} else if (name.endsWith('.exe.asc')) {
key = 'win-signature';
} else if (name.endsWith('.AppImage.asc')) {
key = 'linux-signature';
} else if (name.endsWith('.dmg.asc')) {
key = `mac-${name.includes('arm') ? 'arm' : 'x64'}-signature`;
}

if (key) {
acc[key] = browser_download_url;
}

return acc;
Expand Down Expand Up @@ -89,9 +101,12 @@ function setupDownloadButton() {

function setupVersion() {
document.addEventListener('DOMContentLoaded', () => {
packagesPromise.then((packages) => {
Promise.all([packagesPromise, areSignaturesPresent()]).then(([packages, areSignaturesPresentResult]) => {
const versionEl = document.querySelector('.version');
versionEl.innerHTML = `v. ${packages.$version} · `;
const signaturesHtml = areSignaturesPresentResult
? '<a href="javascript:redirectToFullList();">Signatures</a>'
: '<span class="missing-signatures">Missing signatures!</span>';
versionEl.innerHTML = `v. ${packages.$version} · ${signaturesHtml}`;
});
});
}
Expand Down Expand Up @@ -124,8 +139,16 @@ function downloadDefault() {
}
}

function download(platform) {
function download(platformKey) {
packagesPromise.then((packages) => {
location.href = packages[platform];
location.href = packages[platformKey];
});
}

function areSignaturesPresent() {
return packagesPromise.then((packages) => {
if (platform === 'Windows') return !!packages['win-signature'];
if (platform === 'Linux') return !!packages['linux-signature'];
if (platform === 'macOS') return !!(packages['mac-arm-signature'] && packages['mac-x64-signature']);
});
}
2 changes: 1 addition & 1 deletion public/get/mac.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>MyTonWallet for your Mac</h1>
</div>
</div>
<div class="footer">
<span class="version"></span>
<div class="version">&nbsp;</div>
<a href="javascript:redirectToFullList();">Other platforms</a>
· <a href="https://mytonwallet.io">mytonwallet.io</a>
</div>
Expand Down
Loading

0 comments on commit 2966b95

Please sign in to comment.