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 #291 from PureStake/master
Browse files Browse the repository at this point in the history
 Patch v1.6.2
  • Loading branch information
Jan Marcano authored Sep 1, 2021
2 parents 14d6831 + 0d59d45 commit 275d67f
Show file tree
Hide file tree
Showing 37 changed files with 171 additions and 74 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Added ability to use a Ledger device to add public addresses into AlgoSigner and
- Algorand JS SDK `v1.9.1` support
- Various improvements regarding Transaction fields validations and Signing UI clarity

### 1.6.2 Patch
- Algorand JS SDK `v1.11.1` support
- Includes support for `extraPages` field on `Appl` txs
- Fix display for `Total` amount for `Pay` txs
- Network Config fix for local Sandbox nodes
- More descriptive `Appl` and `Axfer` txs on the Transactions list

## New Users

- Watch [Getting Started with AlgoSigner](https://youtu.be/tG-xzG8r770)
Expand Down
3 changes: 3 additions & 0 deletions docs/dApp-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ DApp users can trust AlgoSigner to:

With the release of v2 signing, developers coding to the standard will be able to use the same code with any Algorand Wallet.

- Examples of signing with v2 are available in the [dapp examples repo](https://purestake.github.io/algosigner-dapp-example/index.html).
- An interactive transition guide that demonstrates the differences between v1 and v2 signing is available as a link from the dapp examples repo or directly access the [transition guide](https://purestake.github.io/algosigner-dapp-example/v1v2TransitionGuide.html).

### Developing a dApp

- Read [v2 dApp Integration Guide](dApp-integration.md)
4 changes: 4 additions & 0 deletions docs/legacy-signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The initial, v1, transaction signing remains in place and is documented and supp

(v1 dApp integration)[legacy-dApp-integration.md]

### Transition to v2
- Examples of signing with v2 are available in the [dapp examples repo](https://purestake.github.io/algosigner-dapp-example/index.html).
- An interactive transition guide that demonstrates the differences between v1 and v2 signing is available as a link from the dapp examples repo or directly access the [transition guide](https://purestake.github.io/algosigner-dapp-example/v1v2TransitionGuide.html).

### Multisig Transactions

- Multisig transactions can be signed individually through AlgoSigner.
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.6.1",
"version": "1.6.2",
"author": "https://developer.purestake.io",
"description": "Sign Algorand transactions in your browser with PureStake.",
"repository": "https://github.com/PureStake/algosigner",
Expand Down
5 changes: 2 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"name": "@algosigner/common",
"version": "1.6.1",
"version": "1.6.2",
"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",
"@types/jest": "^27.0.0",
"jest": "27.0.0",
"jest-webextension-mock": "^3.6.1",
"ts-jest": "^27.0.0",
"ts-loader": "^8.0.3",
"typescript": "^3.7.5"
},
"dependencies": {},
"scripts": {
"build": "npm run clean && tsc",
"clean": "rm -rf ./dist/",
Expand Down
15 changes: 9 additions & 6 deletions packages/common/src/interfaces/appl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ export interface IApplTx extends IBaseTx {
//apas?: string, //Address "apas" Lists the assets whose AssetParams may be accessed by this application's approval-program and clear-state-program. The access is read-only.
appForeignAssets?: any;

//apgs?: any, //StateSchema "apgs" Holds the maximum number of global state values defined within a StateSchema object.
appGlobalInts?: any;
appGlobalByteSlices?: any;
//apgs?: number, //StateSchema "apgs" Holds the maximum number of global state values defined within a StateSchema object.
appGlobalInts?: number;
appGlobalByteSlices?: number;

//apls?: any, //StateSchema "apls" Holds the maximum number of local state values defined within a StateSchema object.
appLocalInts?: any;
appLocalByteSlices?: any;
//apls?: number, //StateSchema "apls" Holds the maximum number of local state values defined within a StateSchema object.
appLocalInts?: number;
appLocalByteSlices?: number;

//apep?: number //StateSchema "apep" Number of additional pages allocated to the application's approval and clear state programs. Each ExtraProgramPages is 2048 bytes. The sum of ApprovalProgram and ClearStateProgram may not exceed 2048*(1+ExtraProgramPages) bytes.
extraPages?: number;
}
2 changes: 1 addition & 1 deletion packages/common/src/interfaces/baseTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// prettier-ignore
export interface IBaseTx {
from: string, //Address "snd" The address of the account that pays the fee and amount. (Auto set by algosdk as the from.publicKey)
fee: number, //uint64 "fee" Paid by the sender to the FeeSink to prevent denial-of-service. The minimum fee on Algorand is currently 1000 microAlgos.
fee?: number, //uint64 "fee" Paid by the sender to the FeeSink to prevent denial-of-service. The minimum fee on Algorand is currently 1000 microAlgos.
firstRound: number, //uint64 "fv" The first round for when the transaction is valid. If the transaction is sent prior to this round it will be rejected by the network.
lastRound: number, //uint64 "lv" The ending round for which the transaction is valid. After this round, the transaction will be rejected by the network.
note?: string, //[]byte "note" Any data up to 1000 bytes. (Buffer is created from the provided value)
Expand Down
5 changes: 2 additions & 3 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner-crypto",
"version": "1.6.1",
"version": "1.6.2",
"author": "https://developer.purestake.io",
"description": "Cryptographic wrapper for saving and retrieving extention information in Algosigner.",
"repository": {
Expand All @@ -9,15 +9,14 @@
},
"license": "MIT",
"devDependencies": {
"@types/jest": "^26.0.14",
"@types/jest": "^27.0.0",
"jest": "27.0.0",
"ts-jest": "^27.0.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.11"
},
"dependencies": {},
"scripts": {
"build": "npm run clean && webpack",
"clean": "rm -rf ./dist/",
Expand Down
8 changes: 3 additions & 5 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algosigner/dapp",
"version": "1.6.1",
"version": "1.6.2",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
Expand All @@ -11,14 +11,12 @@
"test": "jest"
},
"devDependencies": {
"@types/jest": "^27.0.0",
"jest": "27.0.0",
"ts-jest": "^27.0.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"@types/jest": "^26.0.14",
"ts-jest": "^27.0.0"
}
}
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.6.1",
"version": "1.6.2",
"description": "Algorand Wallet Extension | Send & Receive ALGOs | Sign dApp Transactions",
"icons": {
"48": "icon.png"
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner-extension",
"version": "1.6.1",
"version": "1.6.2",
"author": "https://developer.purestake.io",
"repository": "https://github.com/PureStake/algosigner",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
"PureStake"
],
"devDependencies": {
"@types/jest": "^26.0.14",
"@types/jest": "^27.0.0",
"jest": "27.0.0",
"jest-webextension-mock": "^3.6.1",
"ts-jest": "^27.0.0",
Expand All @@ -20,7 +20,7 @@
"webpack-cli": "^3.3.11"
},
"dependencies": {
"algosdk": "1.9.1"
"algosdk": "1.11.1"
},
"scripts": {
"build": "npm run clean && npm run bundle && npm run copy",
Expand Down
28 changes: 25 additions & 3 deletions packages/extension/src/background/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging from '@algosigner/common/logging';
import { LedgerTemplate } from '@algosigner/common/types/ledgers';
import { Ledger, Backend, API } from './messaging/types';

Expand Down Expand Up @@ -88,17 +89,38 @@ export class Settings {
if (ledger.genesisId && ledger.genesisId.indexOf('testnet') > -1) {
defaultUrl = 'https://algosigner.api.purestake.io/testnet';
}

// Setup port splits for algod and indexer - used in sandbox installs
let algodUrlPort = '';
let indexerUrlPort = '';

try {
const algodUrlObj = new URL(ledger.algodUrl);
algodUrlPort = algodUrlObj.port;
}
catch {
logging.log(`Unable to parse the URL ${ledger.algodUrl}`)
}

try {
const indexerUrlObj = new URL(ledger.indexerUrl);
indexerUrlPort = indexerUrlObj.port;
}
catch {
logging.log(`Unable to parse the URL ${ledger.indexerUrl}`)
}

this.backend_settings.InjectedNetworks[ledger.name][API.Algod] = {
url: ledger.algodUrl || `${defaultUrl}/algod`,
port: '',
port: algodUrlPort,
apiKey: headersAlgod || headers,
headers: headersAlgod || headers,
};

// Add the indexer links
this.backend_settings.InjectedNetworks[ledger.name][API.Indexer] = {
url: ledger.indexerUrl || `${defaultUrl}/indexer`,
port: '',
port: indexerUrlPort,
apiKey: headersIndexer || headers,
headers: headersIndexer || headers,
};
Expand Down Expand Up @@ -141,7 +163,7 @@ export class Settings {
// Here we have to grab data from injected networks instead of the backend
return {
url: this.backend_settings.InjectedNetworks[ledger][api].url,
port: '',
port: this.backend_settings.InjectedNetworks[ledger][api].port,
apiKey: this.backend_settings.InjectedNetworks[ledger][api].apiKey,
headers: this.backend_settings.InjectedNetworks[ledger][api].headers,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AssetCreateTx implements IAssetCreateTx {
assetDecimals?: number = null;
type: string = undefined;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AssetDestroyTx implements IAssetDestroyTx {
type: string = undefined;
assetIndex: number = undefined;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AssetConfigTx implements IAssetConfigTx {
type: string = undefined;
assetIndex: number = undefined;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
6 changes: 0 additions & 6 deletions packages/extension/src/background/transaction/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ test('Validate pay transaction required fields', () => {
} catch (e) {
errorMessage = e.message;
}
expect(errorMessage).toContain('fee');
expect(errorMessage).toContain('firstRound');
expect(errorMessage).toContain('lastRound');
expect(errorMessage).toContain('genesisID');
Expand All @@ -135,7 +134,6 @@ test('Validate clawback transaction required fields', () => {
} catch (e) {
errorMessage = e.message;
}
expect(errorMessage).toContain('fee');
expect(errorMessage).toContain('firstRound');
expect(errorMessage).toContain('lastRound');
expect(errorMessage).toContain('genesisID');
Expand All @@ -154,7 +152,6 @@ test('Validate accept transaction required fields', () => {
} catch (e) {
errorMessage = e.message;
}
expect(errorMessage).toContain('fee');
expect(errorMessage).toContain('firstRound');
expect(errorMessage).toContain('lastRound');
expect(errorMessage).toContain('genesisID');
Expand All @@ -172,7 +169,6 @@ test('Validate create transaction required fields', () => {
} catch (e) {
errorMessage = e.message;
}
expect(errorMessage).toContain('fee');
expect(errorMessage).toContain('firstRound');
expect(errorMessage).toContain('lastRound');
expect(errorMessage).toContain('genesisID');
Expand All @@ -191,7 +187,6 @@ test('Validate destroy transaction required fields', () => {
console.log(e.message);
errorMessage = e.message;
}
expect(errorMessage).toContain('fee');
expect(errorMessage).toContain('firstRound');
expect(errorMessage).toContain('lastRound');
expect(errorMessage).toContain('genesisID');
Expand All @@ -209,7 +204,6 @@ test('Validate modify asset transaction required fields', () => {
} catch (e) {
errorMessage = e.message;
}
expect(errorMessage).toContain('fee');
expect(errorMessage).toContain('firstRound');
expect(errorMessage).toContain('lastRound');
expect(errorMessage).toContain('genesisID');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AssetFreezeTx implements IAssetFreezeTx {
freezeAccount: string = undefined;
freezeState?: boolean = null;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
11 changes: 6 additions & 5 deletions packages/extension/src/background/transaction/applTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BaseValidatedTxnWrap } from './baseValidatedTxnWrap';
export class ApplTx implements IApplTx {
type: string = undefined;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand All @@ -28,10 +28,11 @@ export class ApplTx implements IApplTx {
appClearProgram?: any = null;
appForeignApps?: any = null;
appForeignAssets?: any = null;
appGlobalInts?: any = null;
appGlobalByteSlices?: any = null;
appLocalInts?: any = null;
appLocalByteSlices?: any = null;
appGlobalInts?: number = null;
appGlobalByteSlices?: number = null;
appLocalInts?: number = null;
appLocalByteSlices?: number = null;
extraPages?: number = null;
}

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AssetAcceptTx implements IAssetAcceptTx {
type: string = undefined;
assetIndex: number = undefined;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
to: any = undefined;
firstRound: number = undefined;
lastRound: number = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AssetClawbackTx implements IAssetClawbackTx {
from: string = undefined;
to: string = undefined;
closeRemainderTo?: string = null;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AssetTransferTx implements IAssetTransferTx {
from: string = undefined;
to: string = undefined;
closeRemainderTo?: string = null;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class BaseValidatedTxnWrap {
this.transaction[prop] = params[prop];
// This is where conversion for different keys happens
// This could be done for validation purposes or improving readability on the UI
// Done more liberally on v2 since we use the unmodified transaction afterwards
if (
(prop === 'group' || prop === 'appApprovalProgram' || prop === 'appClearProgram') &&
!v1Validations
Expand All @@ -90,6 +91,11 @@ export class BaseValidatedTxnWrap {
if (Array.isArray(accArray) && accArray.every((accObj) => 'publicKey' in accObj)) {
this.transaction[prop] = accArray.map((a) => algosdk.encodeAddress(a.publicKey));
}
} else if (prop === 'freezeAccount' && !v1Validations) {
const account = params[prop];
if ('publicKey' in account) {
this.transaction[prop] = algosdk.encodeAddress(account.publicKey);
}
} else if (prop === 'note') {
this.transaction[prop] = Buffer.from(params[prop]).toString();
} else if (BIGINT_FIELDS.includes(prop)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class KeyRegistrationTx implements IKeyRegistrationTx {
voteLast: number = undefined;
voteKeyDilution?: number = null;
from: string = undefined;
fee: number = undefined;
fee?: number = 0;
firstRound: number = undefined;
lastRound: number = undefined;
note?: string = null;
Expand Down
Loading

0 comments on commit 275d67f

Please sign in to comment.