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 #193 from PureStake/master
Browse files Browse the repository at this point in the history
1.4.0-b
  • Loading branch information
purestaketdb authored Feb 26, 2021
2 parents 1d39528 + db4b0c4 commit 376ba87
Show file tree
Hide file tree
Showing 69 changed files with 2,800 additions and 1,285 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
.DS_Store
**/coverage
packages/crypto
packages/dapp
**/*.config.js
18 changes: 16 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
globals: {
browser: true,
page: true,
dappPage: true,
extensionPage: true,
AlgoSigner: true,
},
parser: '@typescript-eslint/parser',
Expand All @@ -18,10 +19,23 @@ module.exports = {
rules: {
'no-unused-vars': 'error',
'no-var': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'no-prototype-builtins': 'warn',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
Function: false,
Object: false,
},
extendDefaults: true,
},
],
},
overrides: [
{
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ![AlgoSigner](media/algosigner-wallet-banner-3.png)

An open-source Algorand wallet browser extension that permits dApp communication for signing Algorand transactions — available for Chrome initially.
An open-source, security audited, Algorand wallet browser extension that permits dApp communication for signing Algorand transactions — available for Chrome.

## Chrome Extension Store

Expand All @@ -10,15 +10,30 @@ _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.3.0 Update
## 1.4.0 Update

The latest release brings:

- Support for dApps to submit multisig transactions and retrieve the single associated address signature.
- Beta support for adding custom networks within AlgoSigner (development networks, BetaNet, etc.).
- Navigation menu improvements
- Logout!

### Custom Networks

- Network information can now be accessed by selecting "Network Configuration" in the options menu.
- This list shows the information needed by the dApp for connections.
- New networks can be added via the "New Network" button. Here is a brief overview of the fields:
- Display Name: Name that will be displayed which will also be used for dApps interacting with the network.
- Network ID: Genesis ID for the network. Transactions will be validated against the value here and must contain a matching value. Defaults to "mainnet-v1.0".
- Network Algod URL: The address which will be used for any Algod related calls. Defaults to the PureStake MainNet URL.
- Network Indexer URL: The address which will be used for any Indexer lookup calls. Defaults to the PureStake MainNet Indexer URL.
- Network Headers: Object stucture that will be used as replacement headers for calls. The object structure has an "Algod" and "Indexer" sub structure which will contain the headers the target api needs in order to function.

## Roadmap

The next feature release will be a feature release permitting the addition and configuration of networks, planned for early 2021.
Upcoming feature releases will focus on adding Ledger device support and a more streamlined approach to creating and interacting with transactions in AlgoSigner.

## Previously delivered

### Multisig Transactions

Expand Down
80 changes: 69 additions & 11 deletions docs/dApp-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ Proxied requests are passed through to an API service - currently set to the Pur

## Existing Methods

- [Connect to Extension](#algosignerconnect)
- [Request Wallet Accounts](#algosigneraccounts-ledger-mainnettestnet-)
- [Algod v2 API](#algosigneralgod-ledger-mainnettestnet-path-algod-v2-path--)
- [Indexer v2 API](#algosignerindexer-ledger-mainnettestnet-path-indexer-v2-path-)
- [Sign Transactions](#algosignersigntxnobject)
- [Send Transactions](#algosignersend-ledger-mainnettestnet-txblob-)
- [!AlgoSigner](#)
- [Integrating AlgoSigner to add Transaction Capabilities for dApps on Algorand](#integrating-algosigner-to-add-transaction-capabilities-for-dapps-on-algorand)
- [Existing Methods](#existing-methods)
- [AlgoSigner.connect()](#algosignerconnect)
- [AlgoSigner.accounts({ ledger: ‘MainNet|TestNet’ })](#algosigneraccounts-ledger-mainnettestnet-)
- [AlgoSigner.algod({ ledger: ‘MainNet|TestNet’, path: ‘algod v2 path’, ... })](#algosigneralgod-ledger-mainnettestnet-path-algod-v2-path--)
- [AlgoSigner.indexer({ ledger: ‘MainNet|TestNet’, path: ‘indexer v2 path’ })](#algosignerindexer-ledger-mainnettestnet-path-indexer-v2-path-)
- [AlgoSigner.sign(txnObject)](#algosignersigntxnobject)
- [Transaction Requirements](#transaction-requirements)
- [Atomic Transactions](#atomic-transactions)
- [AlgoSigner.signMultisig(txn)](#algosignersignmultisigtxn)
- [Custom Networks](#custom-networks)
- [AlgoSigner.send({ ledger: ‘MainNet|TestNet’, txBlob })](#algosignersend-ledger-mainnettestnet-txblob-)
- [Rejection Messages](#rejection-messages)

### AlgoSigner.connect()

Expand Down Expand Up @@ -190,18 +198,68 @@ Due to limitations in Chrome internal messaging, AlgoSigner encodes the transact
- [Python](https://github.com/PureStake/algosigner-dapp-example/blob/master/python/pythonTransaction.py)
- [NodeJS](https://github.com/PureStake/algosigner-dapp-example/blob/master/nodeJs/nodeJsTransaction.js)

#### Multisig Transactions
#### Atomic Transactions

- Grouped transactions intended for atomic transaction functionality need to be grouped outside of AlgoSigner, but can be signed individually.
- The grouped transactions need to have their binary components concatenated to be accepted in the AlgoSigner send method.
- An example of this can be seen in the [existing sample dApp group test](https://purestake.github.io/algosigner-dapp-example/tx-test/signTesting.html).

### AlgoSigner.signMultisig(txn)

- Multisig transactions can be signed individually through AlgoSigner.
- Using the associated msig for the transaction an available matching unsigned address will be selected if possible to sign the txn component.
- The resulting sign will return the a msig with only this signature in the blob and will need to be merged with other signatures before sending to the network.
- An example of this can be seen in the [existing sample dApp multisig test](https://purestake.github.io/algosigner-dapp-example/tx-test/signTesting.html).

#### Atomic Transactions
### Custom Networks

- Grouped transactions intended for atomic transaction functionality need to be grouped outside of AlgoSigner, but can be signed individually.
- The grouped transactions need to have their binary components concatenated to be accepted in the AlgoSigner send method.
- An example of this can be seen in the [existing sample dApp group test](https://purestake.github.io/algosigner-dapp-example/tx-test/signTesting.html).
- Custom networks beta support is now in AlgoSigner.
- AlgoSigner.accounts(ledger) has changed such that calls now accept names that have been added to the user's custom network list as valid ledger names.
- A non-matching ledger name will result in a error:
- [RequestErrors.UnsupportedLedger] The provided ledger is not supported.
- An empty request will result with an error:
- Ledger not provided. Please use a base ledger: [TestNet,MainNet] or an available custom one [{"name":"Theta","genesisId":"testnet-v1.0"}].
- Transaction requests will require a valid matching "genesisId", even for custom networks.

**Request**

```js
let msig = {
subsig: [
{
pk: ms.account1.addr,
},
{
pk: ms.account2.addr,
},
{
pk: ms.account3.addr,
},
],
thr: 2,
v: 1,
};

let mstx = {
msig: msig,
txn: {
type: 'pay',
from: ms.multisigAddr,
to: '7GBK5IJCWFPRWENNUEZI3K4CSE5KDIRSR55KWTSDDOBH3E3JJCKGCSFDGQ',
amount: amount,
fee: txParams['fee'],
firstRound: txParams['last-round'],
lastRound: txParams['last-round'] + 1000,
genesisID: txParams['genesis-id'],
genesisHash: txParams['genesis-hash'],
},
};
```

The merge is complex, review:

- [Multi-sig example](https://github.com/PureStake/algosigner-dapp-example/blob/master/tx-test/types/multisig.js)
- [Signing function](https://github.com/PureStake/algosigner-dapp-example/blob/master/tx-test/common/sign.js)

### AlgoSigner.send({ ledger: ‘MainNet|TestNet’, txBlob })

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner",
"version": "1.3.0",
"version": "1.4.0",
"author": "https://developer.purestake.io",
"description": "Sign Algorand transactions in your browser with PureStake.",
"keywords": [
Expand Down Expand Up @@ -36,11 +36,11 @@
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "echo '\nChecking for uncommited files\nMake sure to stash uncommited changes before pushing\n'; git diff HEAD --quiet && npm run test:unit"
"pre-push": "npm run test:unit"
}
},
"lint-staged": {
"*.{js,json,ts,scss,css,md,yaml}": "prettier --write",
"*.{js,json,ts}": "eslint --fix"
"*.{js,json,ts}": "eslint --quiet --fix"
}
}
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.3.0",
"version": "1.4.0",
"author": "https://developer.purestake.io",
"description": "Common library functions for AlgoSigner.",
"devDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/messaging/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const JSONRPC_VERSION: string = "2.0";

/* eslint-disable no-unused-vars */
export enum JsonRpcMethod {
Heartbeat = "heartbeat",
Authorization = "authorization",
Expand All @@ -23,13 +24,17 @@ export enum JsonRpcMethod {
DeleteAccount = "delete-account",
GetSession = "get-session",
Login = "login",
Logout = "logout",
AccountDetails = "account-details",
Transactions = "transactions",
AssetDetails = "asset-details",
AssetsAPIList = "assets-api-list",
AssetsVerifiedList = "assets-verified-list",
SignSendTransaction = "sign-send-transaction",
ChangeLedger = "change-ledger",
SaveNetwork = "save-network",
DeleteNetwork = "delete-network",
GetLedgers = "get-ledgers",

}

Expand Down
55 changes: 52 additions & 3 deletions packages/common/src/types/ledgers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
export function getSupportedLedgers(): Array<object>{
export class LedgerTemplate {
name: string;
readonly isEditable: boolean;
genesisId?: string;
genesisHash?: string;
symbol?: string;
algodUrl?: string;
indexerUrl?: string;
headers?: string;

public get uniqueName() : string {
return this.name.toLowerCase();
}

constructor({ name, genesisId, genesisHash, symbol, algodUrl, indexerUrl, headers }:
{
name: string,
genesisId?: string,
genesisHash?: string,
symbol?: string,
algodUrl?: string,
indexerUrl?: string,
headers?: string
}) {
if(!name){
throw Error('A name is required for ledgers.');
}

this.name = name;
this.genesisId = genesisId || 'mainnet-v1.0';
this.genesisHash = genesisHash;
this.symbol = symbol;
this.algodUrl = algodUrl;
this.indexerUrl = indexerUrl;
this.headers = headers;
this.isEditable = (name !== 'MainNet' && name !== 'TestNet')
}
}

export function getBaseSupportedLedgers(): Array<LedgerTemplate>{
// Need to add access to additional ledger types from import
return [{"name": "mainnet", "genesisId": 'mainnet-v1.0', "genesisHash": ""},
{"name": "testnet", "genesisId": 'testnet-v1.0', "genesisHash": ""}];
return [
new LedgerTemplate({
name: 'MainNet',
genesisId: 'mainnet-v1.0',
genesisHash: ''
}),
new LedgerTemplate({
name: 'TestNet',
genesisId: 'testnet-v1.0',
genesisHash: ''
})
];
}
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.3.0",
"version": "1.4.0",
"author": "https://developer.purestake.io",
"description": "Cryptographic wrapper for saving and retrieving extention information in Algosigner.",
"repository": {
Expand Down
25 changes: 10 additions & 15 deletions packages/dapp/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
module.exports = {
verbose: true,
moduleNameMapper: {
"^@algosigner/common(.*)$": "<rootDir>/../common/src$1"
},
"roots": [
"<rootDir>/src"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
}
}
verbose: true,
moduleNameMapper: {
'^@algosigner/common(.*)$': '<rootDir>/../common/src$1',
},
roots: ['<rootDir>/src'],
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
};
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.3.0",
"version": "1.4.0",
"author": "https://developer.purestake.io",
"description": "Sample DAPP for use with AlgoSigner.",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/dapp/src/fn/__clerk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import {IClerk} from './interfaces';

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

// import {Transaction,RequestErrors} from '@algosigner/common/types';
// import {JsonRpcMethod,JsonRpcResponse} from '@algosigner/common/messaging/types';
Expand All @@ -16,9 +16,9 @@
// error = RequestErrors.InvalidTransactionParams;
// }
// return MessageBuilder.promise(
// JsonRpcMethod.SignTransaction,
// JsonRpcMethod.SignTransaction,
// params,
// error
// );
// }
// }
// }
7 changes: 4 additions & 3 deletions packages/dapp/src/fn/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { RequestErrors, Transaction, MultisigTransaction } from '@algosigner/common/types';
import { JsonPayload } from '@algosigner/common/messaging/types';

/* eslint-disable no-unused-vars */
export interface ITask {
sign(p: Transaction, e: RequestErrors): Promise<JsonPayload>;
signMultisig(p: MultisigTransaction, e: RequestErrors): Promise<JsonPayload>;
}
sign(p: Transaction, e: RequestErrors): Promise<JsonPayload>;
signMultisig(p: MultisigTransaction, e: RequestErrors): Promise<JsonPayload>;
}
Loading

0 comments on commit 376ba87

Please sign in to comment.