Skip to content

Commit

Permalink
Merge pull request #1070 from input-output-hk/feature/ddw-321-v1-api-…
Browse files Browse the repository at this point in the history
…integration

[DDW-321] V1 API Integration
  • Loading branch information
nikolaglumac authored Sep 21, 2018
2 parents 32f46d6 + 4d97f01 commit 14072b7
Show file tree
Hide file tree
Showing 165 changed files with 3,363 additions and 2,700 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ Changelog

### Features

- Removes depreciated types, requests, and API methods associated with the V0 API. Within the /api directory, organizes requests, types, and errors into subdirectories based on the categories Accounts, Addresses, Common, Nodes, Transactions, and Wallets. ([PR 1088](https://github.com/input-output-hk/daedalus/pull/1088))
- Refactors and improves Network Status Store to use V1 API. ([PR 1081](https://github.com/input-output-hk/daedalus/pull/1081))
- Implemented the V1 API endpoints for redeeming ADA with all types of certificates. Updates ADA redemption API methods, flow types, and variable names to match the V1 nomenclature. ([PR 1080](https://github.com/input-output-hk/daedalus/pull/1080))
- Implements the missing V1 API endpoints for checking if a node update is available and responding to the update by either applying it or postponing it. Adds the V1 endpoint for adaTestReset.js. ([PR 1079](https://github.com/input-output-hk/daedalus/pull/1079))
- Implemented the V1 API specifications for 4 pieces of functionality and their associated API requests within Daedalus. These include: Setting a passphrase or changing an existing passphrase. Deleting an existing wallet and all its accounts. Checking for an available node update and displaying a notification about the update and versioning. Updating the name and/or assurance level of an existing wallet. ([PR 1042](https://github.com/input-output-hk/daedalus/pull/1042))
- Implemented a switch instead of a link for “hide used” addresses on the Receive screen ([PR 935](https://github.com/input-output-hk/daedalus/pull/935))
- Implemented forms submission on "Enter" key press ([PR 981](https://github.com/input-output-hk/daedalus/pull/981))
- Improved the loading UX ([PR 723](https://github.com/input-output-hk/daedalus/pull/723))
- Integrated the V1 API endpoint for Ada payments ([PR 1031](https://github.com/input-output-hk/daedalus/pull/1031))
- Integrated the V1 API endpoint for creating and restoring Wallets ([PR 1018](https://github.com/input-output-hk/daedalus/pull/1018))
- Integrated the V1 API endpoints for fetching all accounts associated with a wallet, fetching a single address, and creating a new address ([PR 1037](https://github.com/input-output-hk/daedalus/pull/1037))
- Send cert and key with api requests to support tls-auth ([PR 1072](https://github.com/input-output-hk/daedalus/pull/1072))

### Fixes
Expand Down
4 changes: 2 additions & 2 deletions cardano-sl-src.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"url": "https://github.com/input-output-hk/cardano-sl",
"rev": "6fa649355d93a1ebfaace3edbbfc54a7304ce5ff",
"sha256": "0xp6fl0pfcdvi54j3nvp5jp8q4q8vwr68zf4h6m1g755i9malbz1",
"rev": "515afc3fb6e8b9804a6c325defa95a778df8c8e8",
"sha256": "0f7djx171jvcp1wxnpy063xnqh28qhl701n9ldsy4bj89bj2iza2",
"fetchSubmodules": false
}
10 changes: 5 additions & 5 deletions features/import-wallet-via-sidebar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Feature: Import Wallet via Sidebar
And I select a valid wallet import key file
And I click on the import wallet button in import wallet dialog
Then I should not see the import wallet dialog anymore
And I should have newly created "Genesis wallet" wallet loaded
And I should be on the "Genesis wallet" wallet "summary" screen
And I should have newly created "Imported Wallet" wallet loaded
And I should be on the "Imported Wallet" wallet "summary" screen
And I should see the restore status notification while import is running
And I should not see the restore status notification once import is finished

Scenario: Wallet Already Imported Error
Given I have a "Genesis wallet" with funds
Given I have a "Imported Wallet" with funds
When I try to import the wallet with funds again
Then I see the import wallet dialog with an error that the wallet already exists

Expand All @@ -40,7 +40,7 @@ Feature: Import Wallet via Sidebar
| Secret123 | Secret123 |
And I click on the import wallet button in import wallet dialog
Then I should not see the import wallet dialog anymore
And I should have newly created "Genesis wallet" wallet loaded
And I should be on the "Genesis wallet" wallet "summary" screen
And I should have newly created "Imported Wallet" wallet loaded
And I should be on the "Imported Wallet" wallet "summary" screen
And I should see the restore status notification while import is running
And I should not see the restore status notification once import is finished
8 changes: 4 additions & 4 deletions features/paper-wallets-certificate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Paper Wallets Certificate generation

Background:
Given I have completed the basic setup
And I have a "Genesis wallet" with funds
And I have a "Imported Wallet" with funds

Scenario: Paper wallets certificate success generation
Given The sidebar shows the "wallets" category
Expand All @@ -24,16 +24,16 @@ Feature: Paper Wallets Certificate generation
And Cardano explorer link and wallet address should be valid
And I click on the finish button
And I should not see the create paper wallet certificate dialog anymore
When I click on the "Genesis wallet" wallet in the sidebar
And I am on the "Genesis wallet" wallet "send" screen
When I click on the "Imported Wallet" wallet in the sidebar
And I am on the "Imported Wallet" wallet "send" screen
And I fill out the send form:
| amount |
| 0.000010 |
And the transaction fees are calculated
And I click on the next button in the wallet send form
And I see send money confirmation dialog
And I submit the wallet send form
Then I should be on the "Genesis wallet" wallet "summary" screen
Then I should be on the "Imported Wallet" wallet "summary" screen
And the latest transaction should show:
| title | amountWithoutFees |
| wallet.transaction.sent | -0.000010 |
Expand Down
6 changes: 3 additions & 3 deletions features/receive-money.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Receive money

Background:
Given I have completed the basic setup
And I have a "Genesis wallet" with funds
And I have a "Imported Wallet" with funds
And I have the following wallets:
| name |
| TargetWallet |
Expand All @@ -11,8 +11,8 @@ Feature: Receive money
Given I am on the "TargetWallet" wallet "receive" screen
And I generate 1 addresses
And I have made the following transactions:
| sender | receiver | amount |
| Genesis wallet | TargetWallet | 1 |
| source | destination | amount |
| Imported Wallet | TargetWallet | 1 |
Then I should see 2 addresses
When I click the ShowUsed switch
Then I should see 1 addresses
Expand Down
12 changes: 6 additions & 6 deletions features/send-money-to-receiver.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Feature: Send Money to Receiver
| first |

Scenario: User Sends Money to Receiver
Given I have a "Genesis wallet" with funds
And I am on the "Genesis wallet" wallet "send" screen
Given I have a "Imported Wallet" with funds
And I am on the "Imported Wallet" wallet "send" screen
And I can see the send form
When I fill out the send form with a transaction to "first" wallet:
| amount |
Expand All @@ -17,7 +17,7 @@ Feature: Send Money to Receiver
And I click on the next button in the wallet send form
And I see send money confirmation dialog
And I submit the wallet send form
Then I should be on the "Genesis wallet" wallet "summary" screen
Then I should be on the "Imported Wallet" wallet "summary" screen
And the latest transaction should show:
| title | amountWithoutFees |
| wallet.transaction.sent | -0.000010 |
Expand All @@ -26,8 +26,8 @@ Feature: Send Money to Receiver
| 0.000010 |

Scenario: User Sends Money from wallet with spending password to Receiver
Given I have a "Genesis wallet" with funds and password
And I am on the "Genesis wallet" wallet "send" screen
Given I have a "Imported Wallet" with funds and password
And I am on the "Imported Wallet" wallet "send" screen
And I can see the send form
When I fill out the send form with a transaction to "first" wallet:
| amount |
Expand All @@ -37,7 +37,7 @@ Feature: Send Money to Receiver
And I see send money confirmation dialog
And I enter wallet spending password in confirmation dialog "Secret123"
And I submit the wallet send form
Then I should be on the "Genesis wallet" wallet "summary" screen
Then I should be on the "Imported Wallet" wallet "summary" screen
And the latest transaction should show:
| title | amountWithoutFees |
| wallet.transaction.sent | -0.000010 |
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/local-time-difference-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Given, Then } from 'cucumber';
Given(/^I set wrong local time difference$/, async function () {
await this.client.executeAsync((timeDifference, done) => {
daedalus.api.ada.setLocalTimeDifference(timeDifference)
.then(() => daedalus.stores.networkStatus._updateLocalTimeDifference())
.then(() => daedalus.stores.networkStatus._updateNetworkStatus())
.then(done)
.catch((error) => done(error));
}, 1511823600000);
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/settings-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Then(/^I should have wallet with "Strict" assurance level set$/, async function
.catch((error) => done(error));
});
const activeWallet = wallets.value.find((w) => w.name === activeWalletName);
expect(activeWallet.assurance).to.equal('CWAStrict');
expect(activeWallet.assurance).to.equal('strict');
});

Then(/^I should see new wallet name "([^"]*)"$/, async function (walletName) {
Expand Down
16 changes: 8 additions & 8 deletions features/step_definitions/transactions-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { getWalletByName } from '../support/helpers/wallets-helpers';
// use only when the order is important because it's slower!
Given(/^I have made the following transactions:$/, { timeout: 40000 }, async function (table) {
const txData = table.hashes().map((t) => ({
sender: getWalletByName.call(this, t.sender).id,
receiver: getWalletByName.call(this, t.receiver).id,
amount: new BigNumber(t.amount).times(LOVELACES_PER_ADA),
password: t.password || null,
walletId: getWalletByName.call(this, t.source).id,
destinationWalletId: getWalletByName.call(this, t.destination).id,
amount: parseInt(new BigNumber(t.amount).times(LOVELACES_PER_ADA), 10),
spendingPassword: t.password || null,
}));
this.transactions = [];
// Sequentially (and async) create transactions with for loop
Expand All @@ -21,12 +21,12 @@ Given(/^I have made the following transactions:$/, { timeout: 40000 }, async fun
new window.Promise((resolve) => (
// Need to fetch the wallets data async and wait for all results
window.Promise.all([
daedalus.stores.ada.addresses.getAccountIdByWalletId(transaction.sender),
daedalus.stores.ada.addresses.getAddressesByWalletId(transaction.receiver)
daedalus.stores.ada.addresses.getAccountIndexByWalletId(transaction.walletId),
daedalus.stores.ada.addresses.getAddressesByWalletId(transaction.destinationWalletId)
]).then(results => (
daedalus.api.ada.createTransaction(window.Object.assign(transaction, {
sender: results[0], // Account id of sender wallet
receiver: results[1][0].id // First address of receiving wallet
accountIndex: results[0], // Account index of sender wallet
address: results[1][0].id // First address of receiving wallet
})).then(resolve)
))
)).then(done)
Expand Down
21 changes: 14 additions & 7 deletions features/step_definitions/wallets-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@ import {
} from '../support/helpers/notifications-helpers';

const defaultWalletKeyFilePath = path.resolve(__dirname, '../support/default-wallet.key');
const defaultWalletJSONFilePath = path.resolve(__dirname, '../support/default-wallet.json');
// const defaultWalletJSONFilePath = path.resolve(__dirname, '../support/default-wallet.json');
// ^^ JSON wallet file import is currently not working due to missing JSON import V1 API endpoint

Given(/^I have a "Genesis wallet" with funds$/, async function () {
Given(/^I have a "Imported Wallet" with funds$/, async function () {
await importWalletWithFunds(this.client, {
keyFilePath: defaultWalletKeyFilePath,
password: null,
});
const wallet = await waitUntilWalletIsLoaded.call(this, 'Genesis wallet');
const wallet = await waitUntilWalletIsLoaded.call(this, 'Imported Wallet');
addOrSetWalletsForScenario.call(this, wallet);
});

Given(/^I have a "Genesis wallet" with funds and password$/, async function () {
Given(/^I have a "Imported Wallet" with funds and password$/, async function () {
await importWalletWithFunds(this.client, {
keyFilePath: defaultWalletKeyFilePath,
password: 'Secret123',
});
const wallet = await waitUntilWalletIsLoaded.call(this, 'Genesis wallet');
const wallet = await waitUntilWalletIsLoaded.call(this, 'Imported Wallet');
addOrSetWalletsForScenario.call(this, wallet);
});

Expand Down Expand Up @@ -99,7 +100,10 @@ When(/^I see the import wallet dialog$/, function () {
});

When(/^I select a valid wallet import key file$/, function () {
return importWalletDialog.selectFile(this.client, { filePath: defaultWalletJSONFilePath });
// return importWalletDialog.selectFile(this.client, { filePath: defaultWalletJSONFilePath });
// ^^ JSON wallet file import is currently not working due to missing JSON import V1 API endpoint
// so we have to use the KEY wallet file instead:
return importWalletDialog.selectFile(this.client, { filePath: defaultWalletKeyFilePath });
});

When(/^I toggle "Activate to create password" switch on the import wallet key dialog$/, function () {
Expand Down Expand Up @@ -310,7 +314,10 @@ When(/^I try to import the wallet with funds again$/, async function () {
await addWalletPage.waitForVisible(this.client);
await addWalletPage.clickImportButton(this.client);
await importWalletDialog.waitForDialog(this.client);
await importWalletDialog.selectFile(this.client, { filePath: defaultWalletJSONFilePath });
// await importWalletDialog.selectFile(this.client, { filePath: defaultWalletJSONFilePath });
// ^^ JSON wallet file import is currently not working due to missing JSON import V1 API endpoint
// so we have to use the KEY wallet file instead:
await importWalletDialog.selectFile(this.client, { filePath: defaultWalletKeyFilePath });
return importWalletDialog.clickImport(this.client);
});

Expand Down
2 changes: 1 addition & 1 deletion features/support/default-wallet.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"wallet":{"accounts":[{"name":"Genesis account","index":2147483648}],"walletSecretKey":"WIAwbsQgbz9X0WhvOnVeH+yRs7Ri93ESTdMspBHzeLnPUR6hLZL/NazfB40z2x8FZhLwNIt83DCuMR1nGG+ZqvsD/ouyzg3ec729fnrqEMO4A+qPTJmpiRgQZfYO2KDJDRxLtMyofXl90VVZOEke/QddnZ8CGHoR/lCemJgZuvzBpw==","walletMeta":{"name":"Genesis wallet","assurance":"normal","unit":"ADA"},"passwordHash":"WGQxNHw4fDF8V0NERGRHY0JGcThzelVyeFdza00wM1VjYnloeVBBQXBvdWtwdWFsUTExNGVFdz09fFJXMk5kUmVJYmg2REtsa2lsWG8rQ1lvTStRZmJkMzRmRVd0MG4rSy82YUU9"},"fileType":"WALLETS_EXPORT","fileVersion":"1.0.0"}
{"wallet":{"accounts":[{"name":"Genesis account","index":2147483648}],"walletSecretKey":"WIAwbsQgbz9X0WhvOnVeH+yRs7Ri93ESTdMspBHzeLnPUR6hLZL/NazfB40z2x8FZhLwNIt83DCuMR1nGG+ZqvsD/ouyzg3ec729fnrqEMO4A+qPTJmpiRgQZfYO2KDJDRxLtMyofXl90VVZOEke/QddnZ8CGHoR/lCemJgZuvzBpw==","walletMeta":{"name":"Imported Wallet","assurance":"normal","unit":"ADA"},"passwordHash":"WGQxNHw4fDF8V0NERGRHY0JGcThzelVyeFdza00wM1VjYnloeVBBQXBvdWtwdWFsUTExNGVFdz09fFJXMk5kUmVJYmg2REtsa2lsWG8rQ1lvTStRZmJkMzRmRVd0MG4rSy82YUU9"},"fileType":"WALLETS_EXPORT","fileVersion":"1.0.0"}
4 changes: 2 additions & 2 deletions features/support/helpers/notifications-helpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { syncStateTags } from '../../../source/renderer/app/domains/Wallet';
import { WalletSyncStateTags } from '../../../source/renderer/app/domains/Wallet';

export const isActiveWalletBeingRestored = async (client) => {
const result = await client.execute((expectedSyncTag) => (
daedalus.stores.ada.wallets.active.syncState.tag === expectedSyncTag
), syncStateTags.RESTORING);
), WalletSyncStateTags.RESTORING);
return result.value;
};

Expand Down
12 changes: 6 additions & 6 deletions features/support/helpers/wallets-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const fillOutWalletSendForm = async function (values) {
const formSelector = '.WalletSendForm_component';
await this.client.setValue(`${formSelector} .receiver .SimpleInput_input`, values.address);
await this.client.setValue(`${formSelector} .amount .SimpleInput_input`, values.amount);
if (values.walletPassword) {
await this.client.setValue(`${formSelector} .walletPassword .SimpleInput_input`, values.walletPassword);
if (values.spendingPassword) {
await this.client.setValue(`${formSelector} .spendingPassword .SimpleInput_input`, values.spendingPassword);
}
this.walletSendFormValues = values;
};
Expand Down Expand Up @@ -58,8 +58,8 @@ export const addOrSetWalletsForScenario = function (wallet) {
};

export const importWalletWithFunds = async (client, { keyFilePath, password }) => (
await client.executeAsync((filePath, walletPassword, done) => {
daedalus.api.ada.importWalletFromKey({ filePath, walletPassword })
await client.executeAsync((filePath, spendingPassword, done) => {
daedalus.api.ada.importWalletFromKey({ filePath, spendingPassword })
.then(() => (
daedalus.stores.ada.wallets.refreshWalletsData()
.then(done)
Expand All @@ -75,7 +75,7 @@ const createWalletsAsync = async (table, context) => {
daedalus.api.ada.createWallet({
name: wallet.name,
mnemonic: daedalus.utils.crypto.generateMnemonic(),
password: wallet.password || null,
spendingPassword: wallet.password || null,
})
)))
.then(() => (
Expand Down Expand Up @@ -104,7 +104,7 @@ const createWalletsSequentially = async (wallets, context) => {
daedalus.api.ada.createWallet({
name: wallet.name,
mnemonic: daedalus.utils.crypto.generateMnemonic(),
password: wallet.password || null,
spendingPassword: wallet.password || null,
}).then(() => (
daedalus.stores.ada.wallets.walletsRequest.execute()
.then((storeWallets) => (
Expand Down
16 changes: 8 additions & 8 deletions features/transactions-display.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Display wallet transactions

Background:
Given I have completed the basic setup
And I have a "Genesis wallet" with funds
And I have a "Imported Wallet" with funds
And I have the following wallets:
| name |
| TargetWallet |
Expand All @@ -22,13 +22,13 @@ Feature: Display wallet transactions

Scenario: More than five transactions
Given I have made the following transactions:
| sender | receiver | amount |
| Genesis wallet | TargetWallet | 1 |
| Genesis wallet | TargetWallet | 2 |
| Genesis wallet | TargetWallet | 3 |
| Genesis wallet | TargetWallet | 4 |
| Genesis wallet | TargetWallet | 5 |
| Genesis wallet | TargetWallet | 6 |
| source | destination | amount |
| Imported Wallet | TargetWallet | 1 |
| Imported Wallet | TargetWallet | 2 |
| Imported Wallet | TargetWallet | 3 |
| Imported Wallet | TargetWallet | 4 |
| Imported Wallet | TargetWallet | 5 |
| Imported Wallet | TargetWallet | 6 |
When I am on the "TargetWallet" wallet "summary" screen
Then I should see the following transactions:
| type | amount |
Expand Down
2 changes: 1 addition & 1 deletion installers/dhall/linux64.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ in
, logsPrefix = "${dataDir}/Logs"
, topology = "\${DAEDALUS_CONFIG}/wallet-topology.yaml"
, updateLatestPath = "${dataDir}/installer.sh"
, walletDBPath = "${dataDir}/Wallet/"
, walletDBPath = "${dataDir}/Wallet"
, tlsPath = "${dataDir}/tls"
}
, pass =
Expand Down
1 change: 1 addition & 0 deletions source/common/ipc-api/go-to-network-status-screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const GO_TO_NETWORK_STATUS_SCREEN_CHANNEL = 'GO_TO_NETWORK_STATUS_SCREEN';
Loading

0 comments on commit 14072b7

Please sign in to comment.