Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wallet-lib)!: connects to modified storage #232

Merged
merged 31 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4e16dcd
feat: KeyChain and KeyChainStore
Alex-Werner Jan 13, 2022
0078cd6
feat: rename KeyChain to DerivableKeyChain and reinstate old KeyChain
Alex-Werner Jan 31, 2022
130e670
Merge remote-tracking branch 'origin/v0.22-dev' into feat/improved-st…
Alex-Werner Jan 31, 2022
99100f0
feat: connect with KeyChainStore
Alex-Werner Jan 31, 2022
a69d654
tests: provide fixtures
Alex-Werner Jan 31, 2022
957623d
feat: integrate to Storage
Alex-Werner Jan 31, 2022
4490aa5
feat: remove unused KeyChain
Alex-Werner Jan 31, 2022
744b4bb
feat: change error message for injection
Alex-Werner Jan 31, 2022
35546ac
feat: integrate with ChainStore and WalletStore
Alex-Werner Jan 31, 2022
e933ac0
Fixes KeyChain import in SDK
markin-io Feb 4, 2022
30a41c0
Merge branch 'v0.23-dev' into feat/improved-storage
Alex-Werner Feb 14, 2022
dea2a3e
fix: missing integration of Storage
Alex-Werner Feb 14, 2022
7d015ea
fix: remove file from merge conflict
Alex-Werner Feb 14, 2022
8b73e48
docs: added typings
Alex-Werner Feb 15, 2022
8bb4206
fix: getAddressesToSync tests
Alex-Werner Feb 15, 2022
03e4f6e
fix: removed unused props
Alex-Werner Feb 15, 2022
578a1c4
fix: tests for HDPrivateKey on store mock
Alex-Werner Feb 15, 2022
6359fc4
Merge remote-tracking branch 'origin/v0.22-dev' into feat/improved-st…
Alex-Werner Feb 16, 2022
936aa16
Merge remote-tracking branch 'origin/v0.23-dev' into feat/improved-st…
Alex-Werner Feb 16, 2022
d377e61
test: update integration tests
Alex-Werner Feb 16, 2022
6752a48
tests: update dashjs import transactions test
Alex-Werner Feb 17, 2022
335701d
fix: update insertion of identity id for js-dash-sdk
Alex-Werner Feb 17, 2022
bfa30d5
docs: update typings definition
Alex-Werner Feb 17, 2022
ce65114
Fixes getIdentityIds.spec.js
markin-io Feb 20, 2022
7d5c276
Fixes test with incorrect order of identity ids
markin-io Feb 20, 2022
3f8c683
Fixes identity fixture index
markin-io Feb 20, 2022
5c81461
Fixes a broadcast of chain of transactions
markin-io Feb 28, 2022
eb6ee75
Fixes undefined bestBlockHeight and reverts breaking getTransactions …
markin-io Mar 1, 2022
3ba7213
Fixes getTransactionHistory.js and Identity.spec.js
markin-io Mar 1, 2022
9f528c5
Fixes auto-reconnection in case new addresses have been generated
markin-io Mar 8, 2022
cc6773b
Fix importInstantLock
markin-io Mar 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/js-dash-sdk/src/SDK/Client/Client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Dash - Client', function suite() {

beforeEach(async function beforeEach() {
testMnemonic = 'agree country attract master mimic ball load beauty join gentle turtle hover';
testHDKey = "xprv9s21ZrQH143K4PgfRZPuYjYUWRZkGfEPuWTEUESMoEZLC274ntC4G49qxgZJEPgmujsmY52eVggtwZgJPrWTMXmbYgqDVySWg46XzbGXrSZ";
testHDKey = "tprv8ZgxMBicQKsPeGi4CikhacVPz6UmErenu1PoD3S4XcEDSPP8auRaS8hG3DQtsQ2i9HACgohHwF5sgMVJNksoKqYoZbis8o75Pp1koCme2Yo";

client = new Client({
wallet: {
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('Dash - Client', function suite() {
const importedIdentityIds = account.identities.getIdentityIds();
// Check that we've imported identities properly
expect(importedIdentityIds.length).to.be.equal(accountIdentitiesCountBeforeTest + 1);
expect(importedIdentityIds[0]).to.be.equal(interceptedIdentityStateTransition.getIdentityId().toString());
expect(importedIdentityIds[1]).to.be.equal(interceptedIdentityStateTransition.getIdentityId().toString());
});

it('should throw TransitionBroadcastError when transport resolves error', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ export default async function register(
await broadcastStateTransition(this, identityCreateTransition);

// If state transition was broadcast without any errors, import identity to the account
account.storage.insertIdentityIdAtIndex(
account.walletId,
identity.getId().toString(),
identityIndex,
account.storage
.getWalletStore(account.walletId)
.insertIdentityIdAtIndex(
identity.getId().toString(),
identityIndex,
);

return identity;
Expand Down
2 changes: 1 addition & 1 deletion packages/js-dash-sdk/src/SDK/SDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { default as _DAPIClient } from '@dashevo/dapi-client';
import {
Wallet as _Wallet,
Account as _Account,
KeyChain as _KeyChain,
DerivableKeyChain as _KeyChain,
CONSTANTS as _WalletLibCONSTANTS,
EVENTS as _WalletLibEVENTS,
utils as _WalletLibUtils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFi

export function createIdentityFixtureInAccount(account) {
const identityFixture = getIdentityFixture();
const identityFixtureIndex = 10000;
const identityFixtureIndex = 0;
const { privateKey: identityPrivateKey } = account.identities.getIdentityHDKeyByIndex(identityFixtureIndex, 0);

identityFixture.publicKeys[0] = new IdentityPublicKey({
Expand All @@ -15,8 +15,9 @@ export function createIdentityFixtureInAccount(account) {
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER
});

account.storage.insertIdentityIdAtIndex(
account.walletId,
account.storage
.getWalletStore(account.walletId)
.insertIdentityIdAtIndex(
identityFixture.getId().toString(),
identityFixtureIndex,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function createTransactionInAccount(account) {
}])
.to(account.getAddress(10).address, 100000);

await account.importTransactions([walletTransaction.serialize(true)]);
await account.importTransactions([[walletTransaction.serialize(true)]]);

return walletTransaction;
}
}
14 changes: 9 additions & 5 deletions packages/platform-test-suite/test/e2e/wallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,17 @@ describe('e2e', () => {

restoredAccount = await restoredWallet.getWalletAccount();

// Due to the limitations of DAPI, we need to wait for a block to be mined if we connected
// in the moment when transaction already entered the mempool, but haven't been mined yet
await new Promise((resolve) => restoredAccount.once(EVENTS.BLOCKHEADER, resolve));

let transactions = restoredAccount.getTransactions();

if (Object.keys(transactions).length === 0) {
// Due to the limitations of DAPI, we need to wait for a block to be mined if we connected
// in the moment when transaction already entered the mempool, but haven't been mined yet
await new Promise((resolve) => restoredAccount.once(EVENTS.BLOCKHEADER, resolve));
transactions = restoredAccount.getTransactions();
}
await waitForBalanceToChange(restoredAccount);

const transactionIds = Object.keys(restoredAccount.getTransactions());
const transactionIds = Object.keys(transactions);

expect(transactionIds).to.have.lengthOf(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const BalanceIsNotEnoughError = require('@dashevo/dpp/lib/errors/consensus/fee/B
const DAPIClient = require('@dashevo/dapi-client/lib/DAPIClient');
const { hash } = require('@dashevo/dpp/lib/util/hash');
const Identifier = require('@dashevo/dpp/lib/identifier/Identifier');
const Transaction = require('@dashevo/dashcore-lib/lib/transaction');
const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet');
const wait = require('../../../lib/wait');
const getDAPISeeds = require('../../../lib/test/getDAPISeeds');
const Transaction = require('@dashevo/dashcore-lib/lib/transaction');

describe('Platform', () => {
describe('Identity', () => {
Expand Down Expand Up @@ -114,11 +114,12 @@ describe('Platform', () => {
await wait(5000);
}

walletAccount.storage.insertIdentityIdAtIndex(
walletAccount.walletId,
identityOne.getId().toString(),
identityOneIndex,
);
walletAccount.storage
.getWalletStore(walletAccount.walletId)
.insertIdentityIdAtIndex(
identityOne.getId().toString(),
identityOneIndex,
);

// Creating transition that tries to spend the same transaction
const {
Expand Down
Loading