mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-04-16 14:03:19 -04:00
stuck at restoreAccount
This commit is contained in:
parent
6546534cee
commit
f607949973
@ -40,7 +40,113 @@ message RegisterDisputeAgentRequest {
|
||||
message RegisterDisputeAgentReply {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Account
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
message AccountExistsRequest {
|
||||
}
|
||||
|
||||
message AccountExistsReply {
|
||||
bool account_exists = 1;
|
||||
}
|
||||
|
||||
message IsAccountOpenRequest {
|
||||
}
|
||||
|
||||
message IsAccountOpenReply {
|
||||
bool is_account_open = 1;
|
||||
}
|
||||
|
||||
message CreateAccountRequest {
|
||||
string password = 1;
|
||||
}
|
||||
|
||||
message CreateAccountReply {
|
||||
}
|
||||
|
||||
message OpenAccountRequest {
|
||||
string password = 1;
|
||||
}
|
||||
|
||||
message OpenAccountReply {
|
||||
}
|
||||
|
||||
message CloseAccountRequest {
|
||||
}
|
||||
|
||||
message CloseAccountReply {
|
||||
}
|
||||
|
||||
message BackupAccountRequest {
|
||||
}
|
||||
|
||||
message BackupAccountReply {
|
||||
bytes data = 1;
|
||||
}
|
||||
|
||||
message DeleteAccountRequest {
|
||||
}
|
||||
|
||||
message DeleteAccountReply {
|
||||
}
|
||||
|
||||
//message MetaData {
|
||||
// string name = 1;
|
||||
// string type = 2;
|
||||
//}
|
||||
|
||||
//message Zip {
|
||||
// bytes content = 1;
|
||||
//}
|
||||
|
||||
//enum Status {
|
||||
// PENDING = 0;
|
||||
// IN_PROGRESS = 1;
|
||||
// SUCCESS = 2;
|
||||
// FAILED = 3;
|
||||
//}
|
||||
|
||||
message RestoreAccountRequest {
|
||||
// oneof request {
|
||||
// MetaData metadata = 1;
|
||||
// Zip zip = 2;
|
||||
// }
|
||||
string foo = 1;
|
||||
}
|
||||
|
||||
message RestoreAccountReply {
|
||||
string name = 1;
|
||||
// Status status = 2;
|
||||
}
|
||||
|
||||
message ChangePasswordRequest {
|
||||
string password = 1;
|
||||
}
|
||||
|
||||
message ChangePasswordReply {
|
||||
}
|
||||
|
||||
service Account {
|
||||
rpc AccountExists(AccountExistsRequest) returns (AccountExistsReply) {
|
||||
}
|
||||
rpc BackupAccount(BackupAccountRequest) returns (stream BackupAccountReply) {
|
||||
}
|
||||
rpc ChangePassword(ChangePasswordRequest) returns (ChangePasswordReply) {
|
||||
}
|
||||
rpc CloseAccount(CloseAccountRequest) returns (CloseAccountReply) {
|
||||
}
|
||||
rpc CreateAccount(CreateAccountRequest) returns (CreateAccountReply) {
|
||||
}
|
||||
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountReply) {
|
||||
}
|
||||
rpc IsAccountOpen (IsAccountOpenRequest) returns (IsAccountOpenReply) {
|
||||
}
|
||||
rpc RestoreAccount(RestoreAccountRequest) returns (stream RestoreAccountReply) {
|
||||
}
|
||||
rpc OpenAccount(OpenAccountRequest) returns (OpenAccountReply) {
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Help
|
||||
|
21475
package-lock.json
generated
21475
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@
|
||||
"@types/node": "^12.20.10",
|
||||
"@types/react": "^17.0.3",
|
||||
"@types/react-dom": "^17.0.3",
|
||||
"file-saver": "^2.0.5",
|
||||
"google-protobuf": "^3.0.0",
|
||||
"grpc-web": "^1.2.1",
|
||||
"react": "^17.0.2",
|
||||
@ -43,6 +44,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/file-saver": "^2.0.4",
|
||||
"monero-javascript": "^0.5.8"
|
||||
}
|
||||
}
|
||||
|
22
src/App.tsx
22
src/App.tsx
@ -1,5 +1,8 @@
|
||||
import React from 'react';
|
||||
import logo from './logo.png';
|
||||
|
||||
import { saveAs } from 'file-saver'
|
||||
|
||||
import './App.css';
|
||||
import {HavenoDaemon} from './HavenoDaemon';
|
||||
|
||||
@ -19,6 +22,8 @@ class App extends React.Component<{}, {daemonVersion: string, exists: string, ac
|
||||
this.daemon = new HavenoDaemon(HAVENO_DAEMON_URL, HAVENO_DAEMON_PASSWORD);
|
||||
}
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="App">
|
||||
@ -70,9 +75,12 @@ class App extends React.Component<{}, {daemonVersion: string, exists: string, ac
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button
|
||||
onClick={async(e) => await this.restoreAccount()}>Restore Account
|
||||
</button>
|
||||
<input accept=".zip" id="file" multiple={false} type="file" onChange={async(e) => await this.restoreAccount()}/>
|
||||
<label htmlFor="file">
|
||||
<button
|
||||
onClick={e => e.stopPropagation()}>Restore Account
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="password"></input>
|
||||
@ -146,7 +154,9 @@ class App extends React.Component<{}, {daemonVersion: string, exists: string, ac
|
||||
|
||||
async backupAccount() {
|
||||
try {
|
||||
await this.daemon.backupAccount();
|
||||
const result = await this.daemon.backupAccount();
|
||||
const blob = new Blob([result], {type: "application/octet-stream"});
|
||||
saveAs(blob, 'accountBackup.zip')
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@ -160,9 +170,9 @@ class App extends React.Component<{}, {daemonVersion: string, exists: string, ac
|
||||
}
|
||||
}
|
||||
|
||||
async restoreAccount() {
|
||||
async restoreAccount(file: File) {
|
||||
try {
|
||||
//await this.daemon.restoreAccount();
|
||||
await this.daemon.restoreAccount();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import {GetVersionRequest, GetVersionReply, MarketPriceRequest, MarketPriceReply
|
||||
CloseAccountRequest,
|
||||
CloseAccountReply,
|
||||
BackupAccountRequest,
|
||||
BackupAccountReply,
|
||||
BackupAccountReply,
|
||||
DeleteAccountRequest,
|
||||
DeleteAccountReply,
|
||||
ChangePasswordRequest,
|
||||
@ -394,18 +394,24 @@ class HavenoDaemon {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup an Account.
|
||||
*
|
||||
*/
|
||||
async backupAccount(): Promise<void> {
|
||||
async backupAccount(): Promise<Buffer> {
|
||||
let that = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
that._accountClient.backupAccount(new BackupAccountRequest(), {password: that._password}, function(err: grpcWeb.RpcError, response: BackupAccountReply) {
|
||||
if (err) reject(err);
|
||||
else resolve();
|
||||
});
|
||||
});
|
||||
const stream = that._accountClient.backupAccount(new BackupAccountRequest(), {password: that._password})
|
||||
let result: Buffer[] = []
|
||||
stream.on("data", (data)=> {
|
||||
let backupAccountReply = data as BackupAccountReply
|
||||
let chunk = Buffer.from(backupAccountReply.getData())
|
||||
result.push(chunk)
|
||||
})
|
||||
stream.on("end", () => {
|
||||
resolve(Buffer.concat(result))
|
||||
})
|
||||
|
||||
stream.on("error", (error) => {
|
||||
reject()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
2155
src/protobuf/grpc_pb.d.ts
vendored
2155
src/protobuf/grpc_pb.d.ts
vendored
File diff suppressed because it is too large
Load Diff
18126
src/protobuf/grpc_pb.js
18126
src/protobuf/grpc_pb.js
File diff suppressed because it is too large
Load Diff
7796
src/protobuf/pb_pb.d.ts
vendored
7796
src/protobuf/pb_pb.d.ts
vendored
File diff suppressed because it is too large
Load Diff
62482
src/protobuf/pb_pb.js
62482
src/protobuf/pb_pb.js
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user