Update Wallet to new Wallet Code (#4805)
* Update Wallet Version * Update Wallet Library * Update Wallets Bytecodes * Typo * Separate Deploy in Contract API * Use the new Wallet ABI // Update wallet code * WIP .// Deploy from Wallet * Update Wallet contract * Contract Deployment for Wallet * Working deployments for Single Owned Wallet contracts * Linting * Create a Wallet from a Wallet * Linting * Fix Signer transactions // Add Gas Used for transactions * Deploy wallet contract fix * Fix too high gas estimate for Wallet Contract Deploys * Final piece ; deploying from Wallet owned by wallet * Update Wallet Code * Updated the Wallet Codes * Fixing Wallet Deployments * Add Support for older wallets * Linting
This commit is contained in:
committed by
Jaco Greeff
parent
973bb63dca
commit
4d08e7b0ae
@@ -49,7 +49,7 @@ export default class Personal {
|
||||
.filter((address) => {
|
||||
const account = accountsInfo[address];
|
||||
|
||||
return !account.uuid && account.meta.deleted;
|
||||
return !account.uuid && account.meta && account.meta.deleted;
|
||||
})
|
||||
.map((address) => this._api.parity.removeAddress(address))
|
||||
);
|
||||
|
||||
@@ -26,7 +26,6 @@ import WalletsUtils from '~/util/wallets';
|
||||
import { wallet as WalletAbi } from '~/contracts/abi';
|
||||
|
||||
export function personalAccountsInfo (accountsInfo) {
|
||||
const addresses = [];
|
||||
const accounts = {};
|
||||
const contacts = {};
|
||||
const contracts = {};
|
||||
@@ -35,10 +34,9 @@ export function personalAccountsInfo (accountsInfo) {
|
||||
|
||||
Object.keys(accountsInfo || {})
|
||||
.map((address) => Object.assign({}, accountsInfo[address], { address }))
|
||||
.filter((account) => account.uuid || !account.meta.deleted)
|
||||
.filter((account) => account.meta && (account.uuid || !account.meta.deleted))
|
||||
.forEach((account) => {
|
||||
if (account.uuid) {
|
||||
addresses.push(account.address);
|
||||
accounts[account.address] = account;
|
||||
} else if (account.meta.wallet) {
|
||||
account.wallet = true;
|
||||
@@ -87,18 +85,45 @@ export function personalAccountsInfo (accountsInfo) {
|
||||
return [];
|
||||
})
|
||||
.then((_wallets) => {
|
||||
_wallets.forEach((wallet) => {
|
||||
const owners = wallet.owners.map((o) => o.address);
|
||||
// We want to separate owned wallets and other wallets
|
||||
// However, wallets can be owned by wallets, that can
|
||||
// be owned by an account...
|
||||
let otherWallets = [].concat(_wallets);
|
||||
let prevLength;
|
||||
let nextLength;
|
||||
|
||||
// Owners ∩ Addresses not null : Wallet is owned
|
||||
// by one of the accounts
|
||||
if (intersection(owners, addresses).length > 0) {
|
||||
accounts[wallet.address] = wallet;
|
||||
} else {
|
||||
contacts[wallet.address] = wallet;
|
||||
}
|
||||
// If no more other wallets, or if the size decreased, continue...
|
||||
do {
|
||||
prevLength = otherWallets.length;
|
||||
|
||||
otherWallets = otherWallets
|
||||
.map((wallet) => {
|
||||
const addresses = Object.keys(accounts);
|
||||
const owners = wallet.owners.map((o) => o.address);
|
||||
|
||||
// Owners ∩ Addresses not null : Wallet is owned
|
||||
// by one of the accounts
|
||||
if (intersection(owners, addresses).length > 0) {
|
||||
accounts[wallet.address] = wallet;
|
||||
return false;
|
||||
}
|
||||
|
||||
return wallet;
|
||||
})
|
||||
.filter((wallet) => wallet);
|
||||
|
||||
nextLength = otherWallets.length;
|
||||
} while (nextLength < prevLength);
|
||||
|
||||
// And other wallets to contacts...
|
||||
otherWallets.forEach((wallet) => {
|
||||
contacts[wallet.address] = wallet;
|
||||
});
|
||||
|
||||
// Cache the _real_ accounts for
|
||||
// WalletsUtils (used for sending transactions)
|
||||
WalletsUtils.cacheAccounts(accounts);
|
||||
|
||||
dispatch(_personalAccountsInfo({
|
||||
accountsInfo,
|
||||
accounts,
|
||||
|
||||
@@ -431,22 +431,7 @@ function parseLogs (logs) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { wallet } = getState();
|
||||
const { contract } = wallet;
|
||||
const walletInstance = contract.instance;
|
||||
|
||||
const signatures = {
|
||||
OwnerChanged: toHex(walletInstance.OwnerChanged.signature),
|
||||
OwnerAdded: toHex(walletInstance.OwnerAdded.signature),
|
||||
OwnerRemoved: toHex(walletInstance.OwnerRemoved.signature),
|
||||
RequirementChanged: toHex(walletInstance.RequirementChanged.signature),
|
||||
Confirmation: toHex(walletInstance.Confirmation.signature),
|
||||
Revoke: toHex(walletInstance.Revoke.signature),
|
||||
Deposit: toHex(walletInstance.Deposit.signature),
|
||||
SingleTransact: toHex(walletInstance.SingleTransact.signature),
|
||||
MultiTransact: toHex(walletInstance.MultiTransact.signature),
|
||||
ConfirmationNeeded: toHex(walletInstance.ConfirmationNeeded.signature)
|
||||
};
|
||||
const WalletSignatures = WalletsUtils.getWalletSignatures();
|
||||
|
||||
const updates = {};
|
||||
|
||||
@@ -459,25 +444,25 @@ function parseLogs (logs) {
|
||||
};
|
||||
|
||||
switch (eventSignature) {
|
||||
case signatures.OwnerChanged:
|
||||
case signatures.OwnerAdded:
|
||||
case signatures.OwnerRemoved:
|
||||
case WalletSignatures.OwnerChanged:
|
||||
case WalletSignatures.OwnerAdded:
|
||||
case WalletSignatures.OwnerRemoved:
|
||||
updates[address] = {
|
||||
...prev,
|
||||
[ UPDATE_OWNERS ]: true
|
||||
};
|
||||
return;
|
||||
|
||||
case signatures.RequirementChanged:
|
||||
case WalletSignatures.RequirementChanged:
|
||||
updates[address] = {
|
||||
...prev,
|
||||
[ UPDATE_REQUIRE ]: true
|
||||
};
|
||||
return;
|
||||
|
||||
case signatures.ConfirmationNeeded:
|
||||
case signatures.Confirmation:
|
||||
case signatures.Revoke:
|
||||
case WalletSignatures.ConfirmationNeeded:
|
||||
case WalletSignatures.Confirmation:
|
||||
case WalletSignatures.Revoke:
|
||||
const operation = bytesToHex(log.params.operation.value);
|
||||
|
||||
updates[address] = {
|
||||
@@ -489,9 +474,11 @@ function parseLogs (logs) {
|
||||
|
||||
return;
|
||||
|
||||
case signatures.Deposit:
|
||||
case signatures.SingleTransact:
|
||||
case signatures.MultiTransact:
|
||||
case WalletSignatures.Deposit:
|
||||
case WalletSignatures.SingleTransact:
|
||||
case WalletSignatures.MultiTransact:
|
||||
case WalletSignatures.Old.SingleTransact:
|
||||
case WalletSignatures.Old.MultiTransact:
|
||||
updates[address] = {
|
||||
...prev,
|
||||
[ UPDATE_TRANSACTIONS ]: true
|
||||
|
||||
Reference in New Issue
Block a user