Meriadec Pillet
6 years ago
committed by
GitHub
195 changed files with 5020 additions and 3067 deletions
@ -1,32 +1,62 @@ |
|||
const { NODE_ENV } = process.env |
|||
const { NODE_ENV, CLI } = process.env |
|||
|
|||
const __TEST__ = NODE_ENV === 'test' |
|||
const __CLI__ = !!CLI |
|||
|
|||
module.exports = () => ({ |
|||
presets: [ |
|||
[ |
|||
require('@babel/preset-env'), |
|||
{ |
|||
loose: true, |
|||
modules: __TEST__ ? 'commonjs' : false, |
|||
targets: { |
|||
electron: '1.8', |
|||
node: 'current', |
|||
module.exports = (api) => { |
|||
|
|||
if (api) { |
|||
api.cache(true); |
|||
} |
|||
|
|||
return { |
|||
presets: [ |
|||
[ |
|||
require('@babel/preset-env'), |
|||
{ |
|||
loose: true, |
|||
modules: __TEST__ || __CLI__ ? 'commonjs' : false, |
|||
targets: { |
|||
electron: '1.8', |
|||
node: 'current', |
|||
}, |
|||
}, |
|||
}, |
|||
], |
|||
require('@babel/preset-flow'), |
|||
require('@babel/preset-react'), |
|||
], |
|||
require('@babel/preset-flow'), |
|||
require('@babel/preset-react'), |
|||
require('@babel/preset-stage-0'), |
|||
], |
|||
plugins: [ |
|||
[require('babel-plugin-module-resolver'), { root: ['src'] }], |
|||
[ |
|||
require('babel-plugin-styled-components'), |
|||
{ |
|||
displayName: true, |
|||
ssr: __TEST__, |
|||
}, |
|||
plugins: [ |
|||
[require('babel-plugin-module-resolver'), { root: ['src'] }], |
|||
[ |
|||
require('babel-plugin-styled-components'), |
|||
{ |
|||
displayName: true, |
|||
ssr: __TEST__, |
|||
}, |
|||
], |
|||
// Stage 0
|
|||
"@babel/plugin-proposal-function-bind", |
|||
|
|||
// Stage 1
|
|||
"@babel/plugin-proposal-export-default-from", |
|||
"@babel/plugin-proposal-logical-assignment-operators", |
|||
["@babel/plugin-proposal-optional-chaining", { "loose": false }], |
|||
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], |
|||
["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], |
|||
"@babel/plugin-proposal-do-expressions", |
|||
|
|||
// Stage 2
|
|||
["@babel/plugin-proposal-decorators", { "legacy": true }], |
|||
"@babel/plugin-proposal-function-sent", |
|||
"@babel/plugin-proposal-export-namespace-from", |
|||
"@babel/plugin-proposal-numeric-separator", |
|||
"@babel/plugin-proposal-throw-expressions", |
|||
|
|||
// Stage 3
|
|||
"@babel/plugin-syntax-dynamic-import", |
|||
"@babel/plugin-syntax-import-meta", |
|||
["@babel/plugin-proposal-class-properties", { "loose": false }], |
|||
"@babel/plugin-proposal-json-strings" |
|||
], |
|||
], |
|||
}) |
|||
} |
|||
} |
|||
|
@ -0,0 +1,9 @@ |
|||
#!/bin/bash |
|||
|
|||
# TODO: os specific |
|||
export LEDGER_DATA_DIR="$HOME/.config/Electron" |
|||
export LEDGER_LOGS_DIRECTORY="$LEDGER_DATA_DIR/logs" |
|||
export LEDGER_LIVE_SQLITE_PATH="$LEDGER_DATA_DIR/sqlite" |
|||
export CLI=1 |
|||
|
|||
node -r @babel/register scripts/cli/txBetweenAccounts.js |
@ -0,0 +1,21 @@ |
|||
import CommNodeHid from '@ledgerhq/hw-transport-node-hid' |
|||
|
|||
export default function getDevice() { |
|||
return new Promise((resolve, reject) => { |
|||
const sub = CommNodeHid.listen({ |
|||
error: err => { |
|||
sub.unsubscribe() |
|||
reject(err) |
|||
}, |
|||
next: async e => { |
|||
if (!e.device) { |
|||
return |
|||
} |
|||
if (e.type === 'add') { |
|||
sub.unsubscribe() |
|||
resolve(e.device) |
|||
} |
|||
}, |
|||
}) |
|||
}) |
|||
} |
@ -0,0 +1,106 @@ |
|||
/* eslint-disable no-console */ |
|||
|
|||
import chalk from 'chalk' |
|||
import path from 'path' |
|||
import fs from 'fs' |
|||
import inquirer from 'inquirer' |
|||
import { createAccountModel } from '@ledgerhq/live-common/lib/models/account' |
|||
import { formatCurrencyUnit } from '@ledgerhq/live-common/lib/helpers/currencies' |
|||
|
|||
import 'globals' |
|||
import withLibcore from 'helpers/withLibcore' |
|||
import { doSignAndBroadcast } from 'commands/libcoreSignAndBroadcast' |
|||
|
|||
import getDevice from './getDevice' |
|||
|
|||
const accountModel = createAccountModel() |
|||
|
|||
async function main() { |
|||
try { |
|||
// GET ACCOUNTS
|
|||
const app = await parseAppFile() |
|||
const accounts = app.accounts.map(accountModel.decode) |
|||
|
|||
// GET SENDER ACCOUNT
|
|||
const senderAccount = await chooseAccount(accounts, 'Choose sender account') |
|||
|
|||
// GET RECIPIENT ACCOUNT
|
|||
const recipientAccount = await chooseAccount(accounts, 'Choose recipient account') |
|||
|
|||
// GET AMOUNT & FEE
|
|||
const { amount, feePerByte } = await inquirer.prompt([ |
|||
{ |
|||
type: 'input', |
|||
name: 'amount', |
|||
message: 'Amount', |
|||
default: 0, |
|||
}, |
|||
{ |
|||
type: 'input', |
|||
name: 'feePerByte', |
|||
message: 'Fee per byte', |
|||
default: 0, |
|||
}, |
|||
]) |
|||
|
|||
// GET DEVICE
|
|||
console.log(chalk.blue(`Waiting for device...`)) |
|||
const device = await getDevice() |
|||
console.log(chalk.blue(`Using device with path [${device.path}]`)) |
|||
|
|||
await withLibcore(async core => |
|||
doSignAndBroadcast({ |
|||
accountId: senderAccount.id, |
|||
currencyId: senderAccount.currency.id, |
|||
xpub: senderAccount.xpub, |
|||
freshAddress: senderAccount.freshAddress, |
|||
freshAddressPath: senderAccount.freshAddressPath, |
|||
index: senderAccount.index, |
|||
transaction: { |
|||
amount, |
|||
feePerByte, |
|||
recipient: recipientAccount.freshAddress, |
|||
}, |
|||
deviceId: device.path, |
|||
core, |
|||
isCancelled: () => false, |
|||
onSigned: () => { |
|||
console.log(`>> signed`) |
|||
}, |
|||
onOperationBroadcasted: operation => { |
|||
console.log(`>> broadcasted`, operation) |
|||
}, |
|||
}), |
|||
) |
|||
} catch (err) { |
|||
console.log(`[ERROR]`, err) |
|||
} |
|||
} |
|||
|
|||
async function parseAppFile() { |
|||
const appFilePath = path.resolve(process.env.LEDGER_DATA_DIR, 'app.json') |
|||
const appFileContent = fs.readFileSync(appFilePath, 'utf-8') |
|||
const parsedApp = JSON.parse(appFileContent) |
|||
return parsedApp.data |
|||
} |
|||
|
|||
async function chooseAccount(accounts, msg) { |
|||
const { account } = await inquirer.prompt([ |
|||
{ |
|||
type: 'list', |
|||
choices: accounts.map(account => ({ |
|||
name: `${account.name} | ${chalk.green( |
|||
formatCurrencyUnit(account.unit, account.balance, { |
|||
showCode: true, |
|||
}), |
|||
)}`,
|
|||
value: account, |
|||
})), |
|||
name: 'account', |
|||
message: msg, |
|||
}, |
|||
]) |
|||
return account |
|||
} |
|||
|
|||
main() |
@ -0,0 +1,49 @@ |
|||
#!/bin/bash |
|||
|
|||
# Patch .AppImage to address libcore crash on some |
|||
# distributions, due to loading system libraries |
|||
# instead of embedded ones. |
|||
# |
|||
# see https://github.com/LedgerHQ/ledger-live-desktop/issues/1010 |
|||
|
|||
set -e |
|||
|
|||
BASE_URL=http://mirrors.kernel.org/ubuntu/pool/main/k/krb5 |
|||
PACKAGE_SUFFIX=-2build1_amd64.deb |
|||
TMP_DIR=$(mktemp -d) |
|||
LEDGER_LIVE_VERSION=$(grep version package.json | sed -E 's/.*: "(.*)",/\1/g') |
|||
|
|||
cp "dist/ledger-live-desktop-$LEDGER_LIVE_VERSION-linux-x86_64.AppImage" "$TMP_DIR" |
|||
pushd "$TMP_DIR" |
|||
|
|||
declare -a LIBRARIES=( |
|||
"libgssapi-krb5-2_1.16" |
|||
"libk5crypto3_1.16" |
|||
"libkrb5-3_1.16" |
|||
"libkrb5support0_1.16" |
|||
) |
|||
|
|||
for PACKAGE in "${LIBRARIES[@]}"; do |
|||
curl -fOL "$BASE_URL/$PACKAGE$PACKAGE_SUFFIX" |
|||
ar p "$PACKAGE$PACKAGE_SUFFIX" data.tar.xz | tar xvJf >/dev/null - ./usr/lib/x86_64-linux-gnu/ |
|||
rm "$PACKAGE$PACKAGE_SUFFIX" |
|||
done |
|||
|
|||
curl -fOL "https://s3-eu-west-1.amazonaws.com/ledger-ledgerlive-resources-dev/public_resources/appimagetool-x86_64.AppImage" |
|||
|
|||
cp "$OLDPWD/scripts/shasums/patch-appimage-sums.txt" . |
|||
sha512sum --quiet --check patch-appimage-sums.txt || exit 1 |
|||
|
|||
./ledger-live-desktop-"$LEDGER_LIVE_VERSION"-linux-x86_64.AppImage --appimage-extract |
|||
cp -a usr/lib/x86_64-linux-gnu/*.so.* squashfs-root/usr/lib |
|||
|
|||
chmod +x appimagetool-x86_64.AppImage |
|||
./appimagetool-x86_64.AppImage squashfs-root "$OLDPWD/dist/ledger-live-desktop-$LEDGER_LIVE_VERSION-linux-x86_64.AppImage" |
|||
|
|||
popd |
|||
|
|||
MD5_SUM=$(sha512sum "dist/ledger-live-desktop-$LEDGER_LIVE_VERSION-linux-x86_64.AppImage" | cut -f1 -d\ | xxd -r -p | base64 | paste -sd "") |
|||
sed -i "s|sha512: .*|sha512: ${MD5_SUM}|g" dist/latest-linux.yml |
|||
|
|||
SIZE=$(stat --printf="%s" "dist/ledger-live-desktop-$LEDGER_LIVE_VERSION-linux-x86_64.AppImage") |
|||
sed -i "s|size: .*|size: ${SIZE}|g" dist/latest-linux.yml |
@ -0,0 +1,5 @@ |
|||
bebb42401a43971cfe3e31f2c9ee4efee352ce0d29a8ccc95ca1356a58463afd4876b133d9f4295697f96b76eb21b50c1909a073db753569e8969065eb40b306 usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2 |
|||
d7d2b38a46d65a06560241b226f61d81c4df28d56c6841dd34bb428802ace0fc80cf94de1e5117f0b85b2c69b550df61ac999184d5cfe8ecd3bea4d8394d1d21 usr/lib/x86_64-linux-gnu/libkrb5.so.3.3 |
|||
b025b755eb9a64f0d03a8e92c9e4b4f95c2c506bf070cf037841ef8cdb9013e16390d0e17330f2ce8c98c3b1f05b917a3018109acfde7aab50bc9d9fa70ea12b usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1 |
|||
f181e41f306819c10054ff8ceebf4943858f2cd34dea5206b51141877e2f651be3c6435bb02538cbde2cc0415f38e476423a9fd6a428ca9d425e9c662483b9af usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1 |
|||
dd8d81d4c1485209a65a1446225428a1b919478a74fd5698aff64cb8a67992544e62455f849ad73392505707cb94739de00af5ab340a22a87bb752c3808a55d2 appimagetool-x86_64.AppImage |
@ -0,0 +1,61 @@ |
|||
#!/usr/bin/env bash |
|||
# |
|||
# Author: Stefan Buck |
|||
# License: MIT |
|||
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 |
|||
# |
|||
# |
|||
# This script accepts the following parameters: |
|||
# |
|||
# * owner |
|||
# * repo |
|||
# * filename |
|||
# * github_api_token |
|||
# |
|||
# Script to upload a release asset using the GitHub API v3. |
|||
# |
|||
# Example: |
|||
# |
|||
# upload-github-release-asset.sh github_api_token=TOKEN owner=stefanbuck repo=playground filename=./build.zip |
|||
# |
|||
|
|||
# Check dependencies. |
|||
set -e |
|||
|
|||
# Validate settings. |
|||
[ "$TRACE" ] && set -x |
|||
|
|||
# shellcheck disable=SC2124 |
|||
CONFIG=$@ |
|||
|
|||
for line in $CONFIG; do |
|||
eval "$line" |
|||
done |
|||
|
|||
# Define variables. |
|||
GH_API="https://api.github.com" |
|||
|
|||
# shellcheck disable=SC2154 |
|||
GH_REPO="$GH_API/repos/$owner/$repo" |
|||
|
|||
# shellcheck disable=SC2154 |
|||
AUTH="Authorization: token $github_api_token" |
|||
|
|||
# github_api_token=$GH_TOKEN owner=LedgerHQ repo=ledger-live-desktop tag=v1.2.2 filename=./dist/electron-builder-debug.yml |
|||
LATEST_RELEASE_ID=$(curl -sH "$AUTH" "$GH_API/repos/LedgerHQ/ledger-live-desktop/releases" | grep '"id":' | head -n 1 | sed -E 's/.*: (.*),/\1/') |
|||
|
|||
# Validate token. |
|||
curl -o /dev/null -sH "$AUTH" "$GH_REPO" || { echo "Error: Invalid repo, token or network issue!"; exit 1; } |
|||
|
|||
# Get ID of the asset based on given filename. |
|||
# shellcheck disable=SC2154 |
|||
[ "$LATEST_RELEASE_ID" ] || { echo "Error: Failed to get release id"; exit 1; } |
|||
|
|||
# Upload asset |
|||
echo "Uploading asset... " |
|||
|
|||
# Construct url |
|||
# shellcheck disable=SC2154 |
|||
GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$LATEST_RELEASE_ID/assets?name=$(basename "$filename")" |
|||
|
|||
curl --data-binary @"$filename" -H "Authorization: token $github_api_token" -H "Content-Type: application/octet-stream" "$GH_ASSET" |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue