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 #432 from PureStake/develop
Browse files Browse the repository at this point in the history
Patch 1.9.3
  • Loading branch information
PureBrent authored Aug 12, 2022
2 parents 0c47530 + 218b757 commit 079dc81
Show file tree
Hide file tree
Showing 56 changed files with 643 additions and 1,210 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Developers working with dApps may also install directly from the release package

An interactive transition guide is available [here](https://purestake.github.io/algosigner-dapp-example/v1v2TransitionGuide.html).

## 1.9.2 Release
## 1.9.3 Release

### Main updates
This update adds supports for easier transfers with the new autocomplete feature. Start typing an account, contact name or name service alias on the destination field when sending Algos or ASAs and you'll be able to select the desired address from a dropdown. This also marks the end of the support of the older signing methods that were previously available.
Expand All @@ -26,6 +26,7 @@ This update adds supports for easier transfers with the new autocomplete feature

### Other updates
- Improved Account Importing and Cache Clearing
- Get to your Contacts more easily with dedicated access

## New Users

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.9.1",
"version": "1.9.3",
"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.9.2",
"version": "1.9.3",
"author": "https://developer.purestake.io",
"description": "Common library functions for AlgoSigner.",
"repository": "https://github.com/PureStake/algosigner",
Expand Down
34 changes: 26 additions & 8 deletions packages/common/src/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { extensionBrowser } from './chrome';
import { logging } from './logging';
import { isFromExtension } from './utils';
import { RequestError, Transaction, TAccount, Note, Amount } from './types';
import { Transaction, TAccount, Note, Amount } from './types';
import { RequestError } from './errors';

test('Test chrome reference', () => {
//@ts-ignore
Expand All @@ -17,13 +18,6 @@ test('Test extension parts', () => {
expect(isFromExtension('chrome-extension://12345')).toBe(true);
});

test('Type - RequestErrors undefined test', () => {
expect(RequestError.Undefined).toMatchObject({
message: '[RequestError.Undefined] An undefined error occurred.',
code: 4000,
});
});

test('Type - Transaction', () => {
expect({ amount: 1, from: 'AAA', to: 'BBB' } as Transaction).toBeInstanceOf(Object);
});
Expand All @@ -39,3 +33,27 @@ test('Type - Note', () => {
test('Type - Amount', () => {
expect(12345 as Amount).toBe(12345);
});

test('RequestError - Structure', () => {
const address = 'MTHFSNXBMBD4U46Z2HAYAOLGD2EV6GQBPXVTL727RR3G44AJ3WVFMZGSBE';
const ledger = 'MainNet';
const testError = RequestError.NoAccountMatch(address, ledger);

expect(testError).toMatchObject({
message: `No matching account found on AlgoSigner for address: "${address}" on network ${ledger}.`,
code: 4100,
});

expect(RequestError.SigningError(4000, [testError])).toMatchObject({
message: 'There was a problem signing the transaction(s).',
code: 4000,
data: [testError],
});
});

test('RequestError - Throwing', () => {
function throwError() {
throw RequestError.Undefined;
}
expect(() => throwError()).toThrow(RequestError.Undefined);
});
96 changes: 96 additions & 0 deletions packages/common/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
export class RequestError {
// Maximum amount of transactions supported on a single group
static MAX_GROUP_SIZE = 16;

message: string;
code: number;
name: string;
data?: any;

static None = new RequestError('', 0);
static Undefined = new RequestError(
'[RequestError.Undefined] An undefined error occurred.',
4000
);
static UserRejected = new RequestError(
'[RequestError.UserRejected] The extension user does not authorize the request.',
4001
);
static NotAuthorizedByUser = new RequestError(
'[RequestError.NotAuthorized] The extension user does not authorize the request.',
4100
);
static NoAccountMatch = (address: string, ledger: string): RequestError =>
new RequestError(
`No matching account found on AlgoSigner for address: "${address}" on network ${ledger}.`,
4100
);
static UnsupportedAlgod = new RequestError(
'[RequestError.UnsupportedAlgod] The provided method is not supported.',
4200
);
static UnsupportedLedger = new RequestError(
'[RequestError.UnsupportedLedger] The provided ledger is not supported.',
4200
);
static NotAuthorizedOnChain = new RequestError(
'The user does not possess the required private key to sign with this address.',
4200
);
static MultipleTxsRequireGroup = new RequestError(
'If signing multiple transactions, they need to belong to a same group.',
4200
);
static PendingTransaction = new RequestError('Another query processing', 4201);
static LedgerMultipleTransactions = new RequestError(
'Ledger hardware device signing not available for multiple transactions.',
4201
);
static TooManyTransactions = new RequestError(
`The ledger does not support signing more than ${RequestError.MAX_GROUP_SIZE} transactions at a time.`,
4201
);
static InvalidFields = (data?: any) =>
new RequestError('Validation failed for transaction due to invalid properties.', 4300, data);
static InvalidTransactionStructure = (data?: any) =>
new RequestError('Validation failed for transaction due to invalid structure.', 4300, data);
static InvalidFormat = new RequestError(
'[RequestError.InvalidFormat] Please provide an array of either valid transaction objects or nested arrays of valid transaction objects.',
4300
);
static InvalidSigners = new RequestError(
'Signers array should only be provided for multisigs (at least one signer) or for reference-only transactions belonging to a group (empty array).',
4300
);
static InvalidStructure = new RequestError(
"The provided transaction object doesn't adhere to the correct structure.",
4300
);
static InvalidMsigStructure = new RequestError(
"The provided multisig data doesn't adhere to the correct structure.",
4300
);
static IncompleteOrDisorderedGroup = new RequestError(
'The transaction group is incomplete or presented in a different order than when it was created.',
4300
);
static NonMatchingGroup = new RequestError(
'All transactions need to belong to the same group.',
4300
);
static NoDifferentLedgers = new RequestError(
'All transactions need to belong to the same ledger.',
4300
);
static SigningError = (code: number, data?: any) =>
new RequestError('There was a problem signing the transaction(s).', code, data);

protected constructor(message: string, code: number, data?: any) {
this.name = 'AlgoSignerRequestError';
this.message = message;
this.code = code;
this.data = data;

Error.captureStackTrace(this, RequestError);
}
}
3 changes: 1 addition & 2 deletions packages/common/src/messaging/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export enum JsonRpcMethod {
AuthorizationAllow = 'authorization-allow',
AuthorizationDeny = 'authorization-deny',
SignAllow = 'sign-allow',
SignAllowMultisig = 'sign-allow-multisig',
SignAllowWalletTx = 'sign-allow-wallet-tx',
SignDeny = 'sign-deny',
SignWalletTransaction = 'sign-wallet-transaction',
Expand All @@ -35,7 +34,6 @@ export enum JsonRpcMethod {
AssetDetails = 'asset-details',
AssetsAPIList = 'assets-api-list',
AssetsVerifiedList = 'assets-verified-list',
AssetOptOut = 'asset-opt-out',
SignSendTransaction = 'sign-send-transaction',
ChangeLedger = 'change-ledger',
SaveNetwork = 'save-network',
Expand All @@ -48,6 +46,7 @@ export enum JsonRpcMethod {
GetAliasedAddresses = 'get-aliased-addresses',
GetNamespaceConfigs = 'get-namespace-configs',
ToggleNamespaceConfig = 'toggle-namespace-config',
GetGovernanceAddresses = 'get-governance-addresses',

// Ledger Device Methods
LedgerSaveAccount = 'ledger-save-account',
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ they are rekeyed to another normal account also on AlgoSigner.`;
export const ALIAS_COLLISION_TOOLTIP: string = `Some of the aliases shown share the same name,
make sure to verify which Namespace you're using
by hovering on the alias before making a selection.`;

export const GOVERNANCE_WARNING: string =
'This is a Governance Address. You are not required to send funds in order to participate in Governance. Please see ';
44 changes: 0 additions & 44 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,4 @@
/* eslint-disable no-unused-vars */
export class RequestError {
message: string;
code: number;
name?: string;
data?: any;

static None = new RequestError('', 0);
static Undefined = new RequestError(
'[RequestError.Undefined] An undefined error occurred.',
4000
);
static UserRejected = new RequestError(
'[RequestError.UserRejected] The extension user does not authorize the request.',
4001
);
static NotAuthorizedByUser = new RequestError(
'[RequestError.NotAuthorized] The extension user does not authorize the request.',
4100
);
static UnsupportedAlgod = new RequestError(
'[RequestError.UnsupportedAlgod] The provided method is not supported.',
4200
);
static UnsupportedLedger = new RequestError(
'[RequestError.UnsupportedLedger] The provided ledger is not supported.',
4200
);
static NotAuthorizedOnChain = new RequestError(
'The user does not possess the required private key to sign with this address.',
4200
);
static InvalidFormat = new RequestError(
'[RequestError.InvalidFormat] Please provide an array of either valid transaction objects or nested arrays of valid transaction objects.',
4300
);

protected constructor(message: string, code: number, name?: string, data?: any) {
this.message = message;
this.code = code;
this.name = name;
this.data = data;
}
}

export type Field<T> = string | number;

export type TAccount = Field<string>;
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.9.2",
"version": "1.9.3",
"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.9.2",
"version": "1.9.3",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion packages/dapp/src/fn/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RequestError, WalletTransaction } from '@algosigner/common/types';
import { WalletTransaction } from '@algosigner/common/types';
import { RequestError } from '@algosigner/common/errors';
import { JsonPayload } from '@algosigner/common/messaging/types';

/* eslint-disable no-unused-vars */
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/fn/task.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Task } from './task';
import { MessageBuilder } from '../messaging/builder';
import { RequestError } from '@algosigner/common/types';
import { RequestError } from '@algosigner/common/errors';
import { JsonRpcMethod } from '@algosigner/common/messaging/types';

jest.mock('../messaging/builder');
Expand Down
18 changes: 7 additions & 11 deletions packages/dapp/src/fn/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { ITask } from './interfaces';

import { MessageBuilder } from '../messaging/builder';

import {
Transaction,
RequestError,
WalletTransaction,
} from '@algosigner/common/types';
import { Transaction, WalletTransaction } from '@algosigner/common/types';
import { RequestError } from '@algosigner/common/errors';
import { JsonRpcMethod, JsonPayload } from '@algosigner/common/messaging/types';
import { Runtime } from '@algosigner/common/runtime/runtime';

Expand Down Expand Up @@ -53,12 +50,11 @@ export class Task extends Runtime implements ITask {
if (
txOrGroup === null ||
txOrGroup === undefined ||
(!Array.isArray(txOrGroup) && typeof txOrGroup === 'object' &&
(!txOrGroup.txn || (txOrGroup.txn && !txOrGroup.txn.length))
) ||
(Array.isArray(txOrGroup) &&
(!txOrGroup.length || (txOrGroup.length && !txOrGroup.every((tx) => tx !== null)))
)
(!Array.isArray(txOrGroup) &&
typeof txOrGroup === 'object' &&
(!txOrGroup.txn || (txOrGroup.txn && !txOrGroup.txn.length))) ||
(Array.isArray(txOrGroup) &&
(!txOrGroup.length || (txOrGroup.length && !txOrGroup.every((tx) => tx !== null))))
)
throw formatError;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/messaging/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestError } from '@algosigner/common/types';
import { RequestError } from '@algosigner/common/errors';
import { JsonRpcMethod, JsonPayload } from '@algosigner/common/messaging/types';

import { JsonRpc } from '@algosigner/common/messaging/jsonrpc';
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/messaging/handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OnMessageListener } from './types';
import { RequestError } from '@algosigner/common/types';
import { RequestError } from '@algosigner/common/errors';

export class OnMessageHandler {
static promise(resolve: Function, reject: Function): OnMessageListener {
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.9.2",
"version": "1.9.3",
"description": "Algorand Wallet Extension | Send & Receive ALGOs | Sign dApp Transactions",
"icons": {
"48": "icon.png"
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner-extension",
"version": "1.9.2",
"version": "1.9.3",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
Expand All @@ -20,7 +20,7 @@
"webpack-cli": "^4.9.0"
},
"dependencies": {
"algosdk": "1.17.0",
"algosdk": "1.19.0",
"buffer": "^6.0.3"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/background/messaging/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MessageApi } from './api';
import { Task } from './task';
import encryptionWrap from '../encryptionWrap';
import { isFromExtension } from '@algosigner/common/utils';
import { RequestError } from '@algosigner/common/types';
import { RequestError } from '@algosigner/common/errors';
import { JsonRpcMethod, MessageSource } from '@algosigner/common/messaging/types';
import logging from '@algosigner/common/logging';

Expand Down
Loading

0 comments on commit 079dc81

Please sign in to comment.