refactor bws control on import
This commit is contained in:
parent
f7eebf51ca
commit
4042d04f1b
2 changed files with 17 additions and 33 deletions
|
|
@ -23,14 +23,6 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var setBwsURL = function(walletId, cb) {
|
|
||||||
var opts = {
|
|
||||||
bws: {}
|
|
||||||
};
|
|
||||||
opts.bws[walletId] = $scope.bwsurl;
|
|
||||||
configService.set(opts, cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
var _importBlob = function(str, opts) {
|
var _importBlob = function(str, opts) {
|
||||||
var str2, err;
|
var str2, err;
|
||||||
try {
|
try {
|
||||||
|
|
@ -58,10 +50,8 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
self.error = err;
|
||||||
} else {
|
} else {
|
||||||
setBwsURL(walletId, function() {
|
$rootScope.$emit('Local/WalletImported', walletId);
|
||||||
$rootScope.$emit('Local/WalletImported', walletId);
|
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
@ -79,11 +69,8 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
$rootScope.$emit('Local/WalletImported', walletId);
|
||||||
setBwsURL(walletId, function() {
|
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||||
$rootScope.$emit('Local/WalletImported', walletId);
|
|
||||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
@ -100,10 +87,8 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setBwsURL(walletId, function() {
|
$rootScope.$emit('Local/WalletImported', walletId);
|
||||||
$rootScope.$emit('Local/WalletImported', walletId);
|
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
@ -211,9 +196,12 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lopts.externalSource = 'trezor';
|
lopts.externalSource = 'trezor';
|
||||||
|
lopts.bwsurl = $scope.bwsurl;
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
$log.debug('Import opts', lopts);
|
$log.debug('Import opts', lopts);
|
||||||
|
|
||||||
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
|
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -222,11 +210,9 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setBwsURL(walletId, function() {
|
$rootScope.$emit('Local/WalletImported', walletId);
|
||||||
$rootScope.$emit('Local/WalletImported', walletId);
|
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
go.walletHome();
|
||||||
go.walletHome();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
@ -249,9 +235,12 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lopts.externalSource = 'ledger';
|
lopts.externalSource = 'ledger';
|
||||||
|
lopts.bwsurl = $scope.bwsurl;
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
$log.debug('Import opts', lopts);
|
$log.debug('Import opts', lopts);
|
||||||
|
|
||||||
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
|
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -260,10 +249,8 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setBwsURL(walletId, function() {
|
$rootScope.$emit('Local/WalletImported', walletId);
|
||||||
$rootScope.$emit('Local/WalletImported', walletId);
|
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
||||||
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -441,9 +441,6 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.importLegacyWallet = function(username, password, blob, cb) {
|
root.importLegacyWallet = function(username, password, blob, cb) {
|
||||||
if (opts.bwsurl)
|
|
||||||
bwcService.setBaseUrl(opts.bwsurl);
|
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
|
|
||||||
walletClient.createWalletFromOldCopay(username, password, blob, function(err, existed) {
|
walletClient.createWalletFromOldCopay(username, password, blob, function(err, existed) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue