|
56 | 56 | // Get address book from localStorage |
57 | 57 | $scope.addressBook = JSON.parse(localStorage.getItem('addressBook') || '{}'); |
58 | 58 |
|
| 59 | + $scope.showSafeMigrationModal = function () { |
| 60 | + $uibModal.open({ |
| 61 | + templateUrl: 'partials/modals/safeMigration.html', |
| 62 | + size: 'lg', |
| 63 | + resolve: { |
| 64 | + wallet: walletCopy |
| 65 | + }, |
| 66 | + controller: function ($scope, $uibModalInstance, Wallet, wallet) { |
| 67 | + |
| 68 | + $scope.data = { |
| 69 | + hideMigrationModal: walletCopy.safeMigrated |
| 70 | + }; |
| 71 | + |
| 72 | + // Get number of confirmations |
| 73 | + Wallet |
| 74 | + .getRequired( |
| 75 | + wallet.address, |
| 76 | + function (e, confirmations) { |
| 77 | + $scope.data.threshold = confirmations.toNumber(); |
| 78 | + } |
| 79 | + ).call(); |
| 80 | + |
| 81 | + // Get owners |
| 82 | + Wallet.getOwners(wallet.address, function (e, owners) { |
| 83 | + if (e) { |
| 84 | + Utils.dangerAlert(e); |
| 85 | + return; |
| 86 | + } |
| 87 | + |
| 88 | + $scope.data.owners = owners.map(function (address) { return Web3Service.toChecksumAddress(address); }); |
| 89 | + }).call(); |
| 90 | + |
| 91 | + $scope.create = function () { |
| 92 | + |
| 93 | + var ownersAddresses = $scope.data.owners; // Object.keys(wallet.owners); |
| 94 | + var ownersNames = []; |
| 95 | + |
| 96 | + for (var address of ownersAddresses) { |
| 97 | + ownersNames.push(wallet.owners[address].name); |
| 98 | + } |
| 99 | + |
| 100 | + var url = 'https://gnosis-safe.io/open'; |
| 101 | + url += '?name=' + wallet.name; |
| 102 | + url += '&threshold=' + $scope.data.threshold; |
| 103 | + url += '&owneraddresses=' + ownersAddresses.join(','); |
| 104 | + url += '&ownernames=' + ownersNames.join(','); |
| 105 | + |
| 106 | + window.open(url); |
| 107 | + $scope.dismiss(); |
| 108 | + }; |
| 109 | + |
| 110 | + $scope.dismiss = function () { |
| 111 | + if ($scope.data.hideMigrationModal == true) { |
| 112 | + // Don't show this modal again |
| 113 | + wallet.safeMigrated = true; |
| 114 | + } else { |
| 115 | + wallet.safeMigrated = false; |
| 116 | + } |
| 117 | + Wallet.updateWallet(wallet); |
| 118 | + $uibModalInstance.dismiss(); |
| 119 | + }; |
| 120 | + } |
| 121 | + }); |
| 122 | + }; |
| 123 | + |
59 | 124 | $scope.updateParams = function () { |
60 | 125 |
|
61 | 126 | var batch = Web3Service.web3.createBatch(); |
|
80 | 145 | // Check if the owners are in the wallet.owners object |
81 | 146 | var walletOwnerskeys = $scope.wallet.owners ? Object.keys($scope.wallet.owners) : []; |
82 | 147 |
|
83 | | - if (!$scope.wallet.owners) { |
84 | | - $scope.wallet.owners = {}; |
| 148 | + if (!$scope.wallet.owners) { |
| 149 | + $scope.wallet.owners = {}; |
85 | 150 | $scope.owners.forEach(function (item, index) { |
86 | 151 | $scope.wallet.owners[item] = { |
87 | 152 | 'name': 'Owner ' + (index + 1), |
|
90 | 155 | if (index == $scope.owners.length-1) { // last item |
91 | 156 | Wallet.updateWallet($scope.wallet); |
92 | 157 | } |
93 | | - }); |
| 158 | + }); |
94 | 159 | } else { |
95 | 160 | for (var x = 0; x < $scope.owners.length; x++) { |
96 | 161 | // If owner not in list |
|
113 | 178 | ) |
114 | 179 | ); |
115 | 180 |
|
| 181 | + // Handle migration modal |
| 182 | + if (!walletCopy.safeMigrated) { |
| 183 | + $scope.showSafeMigrationModal(); |
| 184 | + } |
| 185 | + |
116 | 186 | // Get ETH Balance |
117 | 187 | batch.add( |
118 | 188 | Wallet.getBalance( |
|
415 | 485 | /*$scope.getOwners = function () { |
416 | 486 | var batch = Web3Service.web3.createBatch(); |
417 | 487 | $scope.owners = []; |
418 | | - |
| 488 | +
|
419 | 489 | function assignOwner (e, owner) { |
420 | 490 | if (owner) { |
421 | 491 | $scope.$apply(function () { |
422 | 492 | $scope.owners.push(owner); |
423 | 493 | }); |
424 | 494 | } |
425 | 495 | } |
426 | | - |
| 496 | +
|
427 | 497 | for(var i=0; i<$scope.ownersNum; i++){ |
428 | 498 | // Get owners |
429 | 499 | batch.add( |
|
0 commit comments