Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vorujack committed Jan 7, 2024
2 parents 90fb5b3 + c84ccf3 commit dee4dc3
Show file tree
Hide file tree
Showing 9 changed files with 371 additions and 88 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,6 @@ jobs:
- name: Upload to snapstore
run: snapcraft upload --release candidate electron/dist/minotaur-wallet*.snap

release-mac:
runs-on: macos-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v1

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16.x

- name: Install app dependencies
run: npm install

- name: Extract version from tag
uses: damienaicheh/[email protected]

- name: Update package.json files
run: node cli/update_version.js '${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}'

- name: Build Minotaur JS app
run: CI=false npm run sync

- name: Build Electron
working-directory: ./electron
run: export PYTHON_PATH="$(which python2)"; CI=false; npm i; npm run build; npm run electron:pack; npm run electron:make

- name: Upload Executable File to release
uses: softprops/action-gh-release@v1
with:
files: electron/dist/minotaur-wallet*.dmg
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')

release-windows:
runs-on: windows-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions src/components/qrcode/QrCodeReaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SnackbarMessage, VariantType } from 'notistack';
import { MessageEnqueueService } from '../app/MessageHandler';
import Wallet from '../../db/entities/Wallet';
import { Action, Dispatch } from 'redux';
import { Toast } from '@capacitor/toast';

interface QrCodeReaderViewPropsType extends MessageEnqueueService {
success: (scanned: string) => unknown;
Expand Down Expand Up @@ -86,6 +87,9 @@ class QrCodeReaderView extends React.Component<
};

success = (scanned: string) => {
Toast.show({
text: scanned,
}).then(() => null);
let selectedTypes = Types.filter((item) => item.detect(scanned) !== null);
if (this.props.allowedTypes) {
const allowedTypes: Array<string> = this.props.allowedTypes;
Expand Down Expand Up @@ -165,6 +169,7 @@ class QrCodeReaderView extends React.Component<
) : invalidChunkCount > 0 ? (
<QrCodeMoreChunk
chunks={this.state.chunks}
type={this.state.type}
close={this.props.close}
scanNext={() => this.setState({ scanning: true })}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/qrcode/qrcode-types/QrCodeMoreChunk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button, Container, Grid, Typography } from '@mui/material';
import qrcode from '../../../assets/qrcode.svg';
interface PropsType {
chunks: Array<string>;
type: string;
close: () => unknown;
scanNext: () => unknown;
}
Expand Down Expand Up @@ -35,6 +36,7 @@ const QrCodeMoreChunk = (props: PropsType) => {
<h3>
{completed} / {props.chunks.length}
</h3>
<h2>Qrcode Type is: {props.type}</h2>
<Button
variant="contained"
fullWidth
Expand Down
33 changes: 24 additions & 9 deletions src/components/qrcode/qrcode-types/TransactionPublishRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import BottomSheet from '../../../components/bottom-sheet/BottomSheet';
import { Inbox } from '@mui/icons-material';
import { Browser } from '@capacitor/browser';
import { getNetworkType, NetworkType } from '../../../util/network_type';
import { AddressDbAction } from '../../../action/db';
import { AddressDbAction, BoxDbAction } from '../../../action/db';
import TxView from '../../display-tx/TxView';
import openInBrowser from '../../../util/browser';
import Address from '../../../db/entities/Address';

interface PropsType {
closeQrcode: () => unknown;
Expand Down Expand Up @@ -52,6 +53,15 @@ class TransactionPublishRequest extends React.Component<PropsType, stateType> {
return bytes;
};

getTxAddress = async (addresses: Array<Address>, inputs: Array<string>) => {
for (const address of addresses) {
const boxes = await BoxDbAction.getAddressBoxes([address]);
if (boxes.filter((box) => inputs.indexOf(box.box_id) > -1).length > 0)
return address;
}
return undefined;
};

loadTx = () => {
if (!this.state.loading && this.state.loadedTx !== this.props.tx.signedTx) {
this.setState({ loading: true });
Expand All @@ -60,15 +70,20 @@ class TransactionPublishRequest extends React.Component<PropsType, stateType> {
AddressDbAction.getAllAddresses().then((addresses) => {
const txBytes = this._base64ToArrayBuffer(signedTx);
const tx = wasm.Transaction.sigma_parse_bytes(txBytes);
this.setState({
tx: tx,
loading: false,
loadedTx: signedTx,
addresses: addresses.map((item) => item.address),
network_type:
addresses.length > 0
? getNetworkType(addresses[0].network_type)
const inputs = Array(tx.inputs().len())
.fill('')
.map((item, index) => tx.inputs().get(index))
.map((item) => item.box_id().to_str());
this.getTxAddress(addresses, inputs).then((address) => {
this.setState({
tx: tx,
loading: false,
loadedTx: signedTx,
addresses: addresses.map((item) => item.address),
network_type: address
? getNetworkType(address.network_type)
: undefined,
});
});
});
}
Expand Down
85 changes: 51 additions & 34 deletions src/components/qrcode/qrcode-types/TransactionSignRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ class TransactionSignRequest extends React.Component<
walletAddress: undefined,
signed: '',
};
_base64ToArrayBuffer = (base64: string): Uint8Array => {
const binary_string = window.atob(base64);
const len = binary_string.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes;
};

loadTx = () => {
if (
Expand All @@ -70,35 +61,61 @@ class TransactionSignRequest extends React.Component<
this.setState({ loading: true });
// debugger
const { reducedTx, sender, inputs } = this.props.tx;
AddressDbAction.getAddressByAddressString(sender).then((address) => {
if (address && address.walletId) {
WalletDbAction.getWalletById(address.walletId).then((wallet) => {
AddressDbAction.getWalletAddresses(address.walletId).then(
(addresses) => {
const txBytes = this._base64ToArrayBuffer(reducedTx);
const reduced =
wasm.ReducedTransaction.sigma_parse_bytes(txBytes);
const boxes = inputs.map((item) =>
wasm.ErgoBox.sigma_parse_bytes(
this._base64ToArrayBuffer(item)
)
);
AddressDbAction.getAddressByAddressString(sender)
.then((address) => {
if (address && address.walletId) {
WalletDbAction.getWalletById(address.walletId)
.then((wallet) => {
AddressDbAction.getWalletAddresses(address.walletId)
.then((addresses) => {
const reduced = wasm.ReducedTransaction.sigma_parse_bytes(
Buffer.from(reducedTx, 'base64')
);
const boxes = inputs.map((item) =>
wasm.ErgoBox.sigma_parse_bytes(
Buffer.from(item, 'base64')
)
);
this.setState({
wallet: wallet ? wallet : undefined,
reducedTx: reduced,
boxes: boxes,
loading: false,
loadedSender: sender,
addresses: addresses.map((address) => address.address),
walletAddress: addresses[0],
});
})
.catch((e) => {
this.setState({
loading: false,
error: true,
loadedSender: `error fetching wallet addresses ${e}`,
});
});
})
.catch((e) => {
this.setState({
wallet: wallet ? wallet : undefined,
reducedTx: reduced,
boxes: boxes,
loading: false,
loadedSender: sender,
addresses: addresses.map((address) => address.address),
walletAddress: addresses[0],
error: true,
loadedSender: `error fetching wallet ${e}`,
});
}
);
});
} else {
this.setState({
loading: false,
error: true,
loadedSender: sender,
});
}
})
.catch((e) => {
this.setState({
loading: false,
error: true,
loadedSender: `error fetching addresses ${e}`,
});
} else {
this.setState({ loading: false, error: true, loadedSender: sender });
}
});
});
}
};

Expand Down
12 changes: 9 additions & 3 deletions src/components/qrcode/qrcode-types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const detectPageFromJson = (
return { payload, page, total };
}
} catch (e) {
console.log(e);
/* empty */
}
return null;
Expand Down Expand Up @@ -102,9 +103,14 @@ const Types = [
),
type: ErgoPayR,
detect: (value: string): DetectParam | null => {
return value.startsWith('ergopay://')
? { page: 1, total: 1, payload: value.replace('ergopay://', '') }
: null;
try {
return value.startsWith('ergopay://')
? { page: 1, total: 1, payload: value.replace('ergopay://', '') }
: null;
} catch (e) {
console.log(e);
}
return null;
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const RequestQrcodeDisplay = (props: RequestQrcodeDisplayPropsType) => {
chunks === 1
? `{"${props.requestType}": "${requestData}"}`
: `{"${props.requestType}": "` +
requestData.substring(chunk * chunkSize, chunkSize) +
`", "n": ${chunks}, "p": ${chunk + 1}`;
requestData.substring(chunk * chunkSize, (chunk + 1) * chunkSize) +
`", "n": ${chunks}, "p": ${chunk + 1}}`;
const gotoNext = () => {
if (chunk < chunks - 1) {
setChunk(chunk + 1);
Expand Down Expand Up @@ -78,7 +78,10 @@ const RequestQrcodeDisplay = (props: RequestQrcodeDisplayPropsType) => {
step={100}
marks
min={200}
max={Math.min(MAX_CHUNK_SIZE, requestData.length)}
max={Math.min(
MAX_CHUNK_SIZE,
Math.ceil(requestData.length / 100) * 100
)}
/>
</Grid>
</React.Fragment>
Expand Down
Loading

0 comments on commit dee4dc3

Please sign in to comment.