Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #266 from PureStake/master
Browse files Browse the repository at this point in the history
Release 1.6.0-b
  • Loading branch information
Jan Marcano authored Jul 14, 2021
2 parents a7ce6f8 + 9491658 commit c6b3618
Show file tree
Hide file tree
Showing 71 changed files with 2,051 additions and 809 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
**/packages/dapp/lib
.DS_Store
test*.png
**/coverage
**/coverage
**/test-project/results
41 changes: 11 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,20 @@ _This is the preferred solution for end-users, updates will be automatically ins

Developers working with dApps may also install directly from the release package, or by downloading the project and building it.

## 1.5.0 Release
## 1.6.0 Release

This release features the new v2 Signing functionality for dApp developers. Designed to meet the upcoming Algorand Foundation standards it will greatly simplifying complex signing scenarios like Multisignature and Atomic. Encoding is standardized and new helper functions simplify the complexity.
### Functionality
Added ability to use a Ledger device to add public addresses into AlgoSigner and for signing pay and asset transactions. For information about it how to use you can refer to the new readme.

[v2 AlgoSigner methods](docs/dApp-integration.md)
- [Ledger Readme](docs/ledger.md)

The v1 Atomic transaction functionality will start warning extension users in the next major release and be deprecated entirely in two releases.

### 1.5.1 Patch

Improved Application Transaction workflow:

- `AppOnComplete` now defaults to 0.
- Improved readability on `AppArgs` during signing. The base64-encoded version will be shown.

### 1.5.2 Patch

v2 Signing Improvements:

- Add informational tooltip on Multisig transactions.
- Correctly fetch Asset Unit Name and Decimals Display Amount for AxferTxs.
- `AppIndex` now defaults to 0.
- Improved readability on `AppApprovalProgram` && `AppClearProgram` during signing. The base64-encoded version will be shown.

Other Usability Improvements:

- Enabled the option to remove the last selected word when confirming the Mnemonic during Account Creation.
- Fixed bug that prevented Mnemonics with repeated words to be correctly confirmed during Account Creation.
- Added scrollbar to transaction overview section of all signing methods. This helps with better visualization of transactions with many fields, such as Application Transactions.
- UX Improvements for the Network Config screen:
- Added links to the documentation regarding custom networks.
- More responsive tooltip explaining the Network Headers field.
- UI Layout improvements.
### Various Fixes
- UI general improvements
- Improved validation handling in v2 signing
- Modified asset verification to use algod
- Fixed issue with 404's from asset lookups
- Modify transactions without an amount to default to 0
- Fixed issue with creating assets that have zero decimals

## New Users

Expand Down
66 changes: 66 additions & 0 deletions docs/ledger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# AlgoSigner Ledger Periphreral Hardware Actions

## Overview:<hr />
Allow the AlgoSigner extension to work with the primary Ledger device account via HID for transaction signing on pay and asset transactions. This includes transactions originating in the extension and from DApps.

It supports adding the account to your normal accounts tracking in the extension to supply both methods with the ability to sign.

## Common Errors:<hr />
During any action the ledger device may prompt to connect. If the device is not connected then the screen may be blank.

<br /><img src="./ledger_images/connect_err0.png" width="400" /><br />

If the device is connected, but the app is not open you may recieve a not supported error.

<br /><img src="./ledger_images/connect_err1.png" width="400" /><br />

## Adding an address:<hr />
Open AlgoSigner and go to the default account overview.
With the desired network selected click the "Add Account" button at the bottom of the page.
Then choose "Link hardware device account" from the options.

<br /><img src="./ledger_images/connect0.png" width="400" /><br />

The page will inform you that it must open AlgoSigner in a tab to connect to the device. Press "Continue".
A new tab should open in the window where AlgoSigner is active.

<br /><img src="./ledger_images/connect2.png" width="400" /><br />

Populate the Account name field with the value name of the new account.
Verify the device is connected, unlocked and that the Algorand application is installed and active then press "Add Address".
This will get the default account for the connected device.
Once this address is obtained it will be added to your AlgoSigner account and you are free to close the tab.

<br /><img src="./ledger_images/connect3.png" width="400" /><br />

## Signing with the extension:<hr />
First you must add an address to the appropriate network.
With the proper network added you can select the account from the list of accounts.
This will show you the normal account information and give you the option to "Send" as normal.
After entering your transaction information and choosing to send you will be prompted for your password.
Once your password is deemed correct and the address is internally determined to be a hardware account a new tab will automatically open. Here you will be presented with a similar transaction view to one seen from DApps in the extension.

<br /><img src="./ledger_images/sign_extension0.png" width="400" /><br />

You can review here, but you should verify ALL data thoroughly from the Ledger device.
Verify the device is connected, unlocked and that the Algorand application is installed and active then press "Send to device".
After signing you will be presented with the transaction id and the transaction will be sent to the network.
You are then free to close the tab.

<br /><img src="./ledger_images/sign_extension1.png" width="400" /><br />

## Signing with a DApp:<hr />
First the user must add an address to the appropriate network.
A transanction can be then be sent with the network and matching Ledger address.
The user will be presented with the normal sign page.
Once the password is deemed correct and the address is internally determined to be a hardware account a new tab will automatically open.
The new tab will show the same information the user just seen on the normal sign screen.
They are free to review here, but should verify ALL data thoroughly from the Ledger device.
Verify the device is connected, unlocked and that the Algorand application is installed and active then press "Send to device".
After signing the blob will be sent back to the DApp tab in the same way that a transaction sign normally does from AlgoSigner.

<br /><img src="./ledger_images/sign_dapp0.png" width="800" /><br />

The blob will also be presented to the user indicating they are free to close the tab.

<br /><img src="./ledger_images/sign_dapp1.png" width="400" /><br />
Binary file added docs/ledger_images/connect0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/connect1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/connect2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/connect3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/connect_err0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/connect_err1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/sign_dapp0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/sign_dapp1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/sign_extension0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ledger_images/sign_extension1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"name": "algosigner",
"version": "1.5.2",
"version": "1.6.0",
"author": "https://developer.purestake.io",
"description": "Sign Algorand transactions in your browser with PureStake.",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
"keywords": [
"Algorand",
"PureStake"
],
"scripts": {
"install:extension": "(cd ./packages/common && npm install); (cd ./packages/crypto && npm install); (cd ./packages/storage && npm install); (cd ./packages/ui && npm install); (cd ./packages/extension && npm install); (cd ./packages/dapp && npm install);",
"install:test": "(cd ./packages/test-project && npm install);",
"removelocks": "rm -rf ./package-lock.json && find -path \"./packages/*\" -name \"package-lock.json\" -not -path \"*/node_modules/*\" -exec rm -rf {} \\;",
"update": "npm update && find -maxdepth 2 -path \"./packages/*\" -exec npm update {} \\;",
"build": "(cd ./packages/common && npm run build); (cd ./packages/crypto && npm run build); (cd ./packages/dapp && npm run build); (cd ./packages/storage && npm run build); (cd ./packages/ui && npm run build); (cd ./packages/extension && npm run build);",
"build:ui": "cd ./packages/ui && npm run build && cp -r ./dist/* ../../dist/",
"build:extension": "cd ./packages/extension && npm run build && cp -r ./dist/* ../../dist/",
Expand All @@ -18,7 +22,8 @@
"prebuild": "rm -rf ./dist/*",
"postbuild": "npm run copy",
"postinstall": "npm run install:extension && npm run install:test",
"coveragetest": "cd ./packages/test-project && npm run coveragetest",
"rebuild": "npm run clean && npm run removelocks && npm install && npm run update && npm run build",
"coveragetest": "(cd ./packages/test-project && npm run coveragetest)",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "(cd ./packages/crypto && npm run test) && (cd ./packages/extension && npm run test) && (cd ./packages/ui && npm run test) && (cd ./packages/dapp && npm run test) && (cd ./packages/common && npm run test)",
"test:e2e": "(cd ./packages/test-project && npm run test)",
Expand All @@ -35,7 +40,6 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "npm run test:unit"
}
},
Expand Down
8 changes: 5 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "@algosigner/common",
"version": "1.5.2",
"version": "1.6.0",
"author": "https://developer.purestake.io",
"description": "Common library functions for AlgoSigner.",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
"devDependencies": {
"@types/jest": "^26.0.14",
"jest": "^26.4.1",
"jest": "27.0.0",
"jest-webextension-mock": "^3.6.1",
"ts-jest": "^26.3.0",
"ts-jest": "^27.0.0",
"ts-loader": "^8.0.3",
"typescript": "^3.7.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/interfaces/acfg_create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IBaseTx } from './baseTx';
export interface IAssetCreateTx extends IBaseTx {
type: string, //"acfg"
assetTotal: number, //uint64 "t" The total number of base units of the asset to create. This number cannot be changed.
assetDecimals: number, //uint32 "dc" The number of digits to use after the decimal point when displaying the asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in tenths. If 2, the base unit of the asset is in hundredths.
assetDecimals?: number, //uint32 "dc" The number of digits to use after the decimal point when displaying the asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in tenths. If 2, the base unit of the asset is in hundredths.
assetDefaultFrozen?: boolean, //bool "df" True to freeze holdings for this asset by default.
assetUnitName?: string, //string "un" The name of a unit of this asset. Supplied on creation. Example: USDT
assetName?: string, //string "an" The name of the asset. Supplied on creation. Example: Tether
Expand Down
22 changes: 20 additions & 2 deletions packages/common/src/logging.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
/* eslint-disable no-unused-vars */
///
// Central error handling.
///
export class Logging {
log(error: string): void {
export enum LogLevel {
None = 0,
Normal = 1,
Debug = 2,
}

class Logging {
// Raise to Debug to show additional messages, or lower to None to ignore all
logThreshold = LogLevel.Normal;

log(error: string, level?: LogLevel): void {
// Set the default to Normal for backwards compatibility
level = level || LogLevel.Normal;

// If we area below the current threshold then return
if (this.logThreshold === LogLevel.None || this.logThreshold < level) {
return;
}

// TODO: BC - How should we handle errors?
// Should likely use a logging packackage here to send errors to the user or backend logging.
try {
Expand Down
7 changes: 7 additions & 0 deletions packages/common/src/messaging/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export enum JsonRpcMethod {
SaveNetwork = 'save-network',
DeleteNetwork = 'delete-network',
GetLedgers = 'get-ledgers',

// Ledger Device Methods
LedgerSaveAccount = 'ledger-save-account',
LedgerLinkAddress = 'ledger-link-address',
LedgerGetSessionTxn = 'ledger-get-session-txn',
LedgerSendTxnResponse = 'ledger-send-txn-response',
LedgerSignTransaction = 'ledger-sign-transaction',
}

export type JsonPayload = {
Expand Down
10 changes: 10 additions & 0 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { extensionBrowser } from './chrome';
import { getBaseSupportedLedgers } from './types/ledgers';

export function isFromExtension(origin: string): boolean {
const s = origin.split('://');
Expand All @@ -18,3 +19,12 @@ export function removeEmptyFields(obj: { [index: string]: any }): any {
});
return obj;
}

/**
* Check if a ledger belongs to our base supported ledgers (e.g: links to GoalSeeker)
* @param ledger
* @returns boolean
*/
export function isLedgerBaseSupported(ledger: string): boolean {
return getBaseSupportedLedgers().map((l) => l.name.toLowerCase()).includes(ledger.toLowerCase());
}
8 changes: 4 additions & 4 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "algosigner-crypto",
"version": "1.5.2",
"version": "1.6.0",
"author": "https://developer.purestake.io",
"description": "Cryptographic wrapper for saving and retrieving extention information in Algosigner.",
"repository": {
"type": "git",
"url": "https://github.com/PureStake/algosigner/packages/crypto.git"
},
"license": "",
"license": "MIT",
"devDependencies": {
"@types/jest": "^26.0.14",
"jest": "^26.4.2",
"ts-jest": "^26.3.0",
"jest": "27.0.0",
"ts-jest": "^27.0.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
//devtool: 'source-map',
optimization: {
minimize: false,
namedModules: true
moduleIds: "named"
},
module: {
rules: [
Expand Down
10 changes: 6 additions & 4 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"name": "@algosigner/dapp",
"version": "1.5.2",
"version": "1.6.0",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
"description": "Sample DAPP for use with AlgoSigner.",
"scripts": {
"build": "npm run clean && webpack",
"clean": "rm -rf ./dist/",
"test": "jest"
},
"devDependencies": {
"jest": "^26.4.2",
"jest": "27.0.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"webpack-cli": "^3.3.11"
},
"dependencies": {
"@types/jest": "^26.0.14",
"ts-jest": "^26.3.0"
"ts-jest": "^27.0.0"
}
}
7 changes: 5 additions & 2 deletions packages/dapp/src/fn/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
// custom handler for different message types, etc..
import { MessageApi } from '../messaging/api';
import { Task } from './task';
import { MessageSource } from '@algosigner/common/messaging/types';
import logging from '@algosigner/common/logging';

export class Router {
handler: Function;
constructor() {
this.handler = this.default;
window.addEventListener('message', (event) => {
logging.log(`Router DApp message event: ${JSON.stringify(event)}`, 2);
const d = event.data;

try {
Expand All @@ -26,8 +29,8 @@ export class Router {
}
} else {
if (Object.prototype.toString.call(d) === '[object Object]' && 'source' in d) {
if (d.source == 'extension') {
d.source = 'router';
if (d.source == MessageSource.Extension) {
d.source = MessageSource.Router;
d.origin = window.location.origin;
this.handler(d);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
},
optimization: {
minimize: false,
namedModules: true,
moduleIds: 'named',
},
module: {
rules: [
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "AlgoSigner",
"author": "https://developer.purestake.io",
"version": "1.5.2",
"version": "1.6.0",
"description": "Algorand Wallet Extension | Send & Receive ALGOs | Sign dApp Transactions",
"icons": {
"48": "icon.png"
Expand Down
10 changes: 6 additions & 4 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"name": "algosigner-extension",
"version": "1.5.2",
"version": "1.6.0",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
"description": "Sign Algorand transactions in your browser with PureStake.",
"keywords": [
"Algorand",
"PureStake"
],
"devDependencies": {
"@types/jest": "^26.0.14",
"jest": "^26.4.2",
"jest": "27.0.0",
"jest-webextension-mock": "^3.6.1",
"ts-jest": "^26.3.0",
"ts-jest": "^27.0.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"webpack-cli": "^3.3.11"
},
"dependencies": {
"algosdk": "1.8.1"
Expand Down
Loading

0 comments on commit c6b3618

Please sign in to comment.