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 #339 from PureStake/master
Browse files Browse the repository at this point in the history
Patch 1.7.1
  • Loading branch information
PureBrent authored Dec 15, 2021
2 parents 7eace71 + 735de19 commit e00c94e
Show file tree
Hide file tree
Showing 28 changed files with 1,006 additions and 319 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ As part of maintaining the standards set by the Algorand Foundation, we've begun
- v1 Signing (`AlgoSigner.sign()` && `AlgoSigner.multisign()`) will stop being supported in the next major release.
- Preliminary error codes were added to all of the errors that AlgoSigner could provide.

Also, a `Clear Cache` button was added to the Settings menu to help clear out issues mostly for developers.

### Other changes
Other changes
- A developer-oriented `Clear Cache` button was added to the Settings menu to help out with certain issues
- Fixed account name sometimes not being visible during signing.
- When signing more than one group of transactions, there's now an Indicator on which group you're currently signing.

### 1.7.1 Patch

- Added support for saving addresses as 'Contacts' for easier re-use
- Added support for importing more than one address from a same ledger device

## New Users

- Watch [Getting Started with AlgoSigner](https://youtu.be/tG-xzG8r770)
Expand Down
2 changes: 1 addition & 1 deletion docs/ledger.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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.
Allow the AlgoSigner extension to work with Ledger device accounts via HID for transaction signing on pay and asset transactions. This includes transactions originating in the extension and from DApps. It does not work with multiple transactions found in groups and multisig.

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner",
"version": "1.7.0",
"version": "1.7.1",
"author": "https://developer.purestake.io",
"description": "Sign Algorand transactions in your browser with PureStake.",
"repository": "https://github.com/PureStake/algosigner",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algosigner/common",
"version": "1.7.0",
"version": "1.7.1",
"author": "https://developer.purestake.io",
"description": "Common library functions for AlgoSigner.",
"repository": "https://github.com/PureStake/algosigner",
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/messaging/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export enum JsonRpcMethod {
CheckNetwork = 'check-network',
DeleteNetwork = 'delete-network',
GetLedgers = 'get-ledgers',
GetContacts = 'get-contacts',
SaveContact = 'save-contact',
DeleteContact = 'delete-contact',

// Ledger Device Methods
LedgerSaveAccount = 'ledger-save-account',
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner-crypto",
"version": "1.7.0",
"version": "1.7.1",
"author": "https://developer.purestake.io",
"description": "Cryptographic wrapper for saving and retrieving extention information in Algosigner.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algosigner/dapp",
"version": "1.7.0",
"version": "1.7.1",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
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.7.0",
"version": "1.7.1",
"description": "Algorand Wallet Extension | Send & Receive ALGOs | Sign dApp Transactions",
"icons": {
"48": "icon.png"
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner-extension",
"version": "1.7.0",
"version": "1.7.1",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
Expand Down
100 changes: 90 additions & 10 deletions packages/extension/src/background/messaging/internalMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export class InternalMethods {
}

public static [JsonRpcMethod.CreateWallet](request: any, sendResponse: Function) {
const extensionStorage = new ExtensionStorage();
extensionStorage.setStorage('contacts', [], null);
this._encryptionWrap = new encryptionWrap(request.body.params.passphrase);
const newWallet = {
TestNet: [],
Expand Down Expand Up @@ -325,14 +327,16 @@ export class InternalMethods {
public static [JsonRpcMethod.LedgerSendTxnResponse](request: any, sendResponse: Function) {
if (session.txnWrap && 'body' in session.txnWrap) {
const txnBuf = Buffer.from(request.body.params.txn, 'base64');
const decodedTxn = algosdk.decodeSignedTransaction(txnBuf) as any;
const decodedTxn = algosdk.decodeSignedTransaction(txnBuf);
const signedTxnEntries = Object.entries(decodedTxn.txn).sort();

// Get the session transaction
const sessTxn = session.txnWrap.body.params.transaction;

// Set the fee to the estimate we showed on the screen for validation.
sessTxn['fee'] = session.txnWrap.body.params.estimatedFee;
// Set the fee to the estimate we showed on the screen for validation if there is one.
if(session.txnWrap.body.params.estimatedFee) {
sessTxn['fee'] = session.txnWrap.body.params.estimatedFee;
}
const sessTxnEntries = Object.entries(sessTxn).sort();

// Update fields in the signed transaction that are not the same format
Expand Down Expand Up @@ -364,10 +368,21 @@ export class InternalMethods {
//Check the txnWrap for a dApp response and return the transaction
if (session.txnWrap.source === 'dapp') {
const message = session.txnWrap;
message.response = {
blob: request.body.params.txn,
};

// If v2 then it needs to return an array
if (session.txnWrap?.body?.params?.transactionsOrGroups) {
message.response = [{
blob: request.body.params.txn
}];
}
else {
message.response = {
blob: request.body.params.txn
};
}

sendResponse({ message: message });

}
// If this is a ui transaction then we need to also submit
else if (session.txnWrap.source === 'ui') {
Expand Down Expand Up @@ -867,14 +882,13 @@ export class InternalMethods {

public static [JsonRpcMethod.CheckNetwork](request: any, sendResponse: Function) {
try {
const networks = Settings.checkNetwork(request.body.params)
const networks = Settings.checkNetwork(request.body.params);
sendResponse(networks);
}
catch (e) {
} catch (e) {
sendResponse({ error: e.message });
}
}

public static [JsonRpcMethod.SaveNetwork](request: any, sendResponse: Function) {
try {
// If we have a passphrase then we are modifying.
Expand Down Expand Up @@ -955,4 +969,70 @@ export class InternalMethods {

return true;
}

public static [JsonRpcMethod.GetContacts](request: any, sendResponse: Function) {
const extensionStorage = new ExtensionStorage();
extensionStorage.getStorage('contacts', (response: any) => {
let contacts = [];
if (response) {
contacts = response;
}
sendResponse(contacts);
});
return true;
}

public static [JsonRpcMethod.SaveContact](request: any, sendResponse: Function) {
const { name, previousName, address } = request.body.params;

const extensionStorage = new ExtensionStorage();
extensionStorage.getStorage('contacts', (response: any) => {
let contacts = [];
if (response) {
contacts = response;
}
const newContact = {
name: name,
address: address,
};
const previousIndex = contacts.findIndex((contact) => contact.name === previousName);
if (previousIndex >= 0) {
contacts[previousIndex] = newContact;
} else {
contacts.push(newContact);
}

extensionStorage.setStorage('contacts', contacts, (isSuccessful: any) => {
if (isSuccessful) {
sendResponse(contacts);
} else {
sendResponse({ error: 'Lock failed' });
}
});
});
return true;
}

public static [JsonRpcMethod.DeleteContact](request: any, sendResponse: Function) {
const { name } = request.body.params;

const extensionStorage = new ExtensionStorage();
extensionStorage.getStorage('contacts', (response: any) => {
let contacts = [];
if (response) {
contacts = response;
}
const contactIndex = contacts.findIndex((contact) => contact.name === name);
contacts.splice(contactIndex, 1);

extensionStorage.setStorage('contacts', contacts, (isSuccessful: any) => {
if (isSuccessful) {
sendResponse(contacts);
} else {
sendResponse({ error: 'Lock failed' });
}
});
});
return true;
}
}
Loading

0 comments on commit e00c94e

Please sign in to comment.