/
class.ts
40 lines (35 loc) · 1.23 KB
/
class.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { logging, rpc, u, wallet } from "@cityofzion/neon-core";
import { PastTransaction, Provider } from "../common";
import { getBalance, getClaims, getMaxClaimAmount } from "./core";
const log = logging.default("api");
export class NeoCli implements Provider {
public get name() {
return `NeoCli[${this.url}]`;
}
private url: string;
private rpc: rpc.RPCClient;
public constructor(url: string) {
this.url = url;
this.rpc = new rpc.RPCClient(url);
log.info(`Created NeoCli Provider: ${this.url}`);
}
public getRPCEndpoint(noCache?: boolean | undefined): Promise<string> {
return Promise.resolve(this.url);
}
public getBalance(address: string): Promise<wallet.Balance> {
return getBalance(this.url, address);
}
public getClaims(address: string): Promise<wallet.Claims> {
return getClaims(this.url, address);
}
public getMaxClaimAmount(address: string): Promise<u.Fixed8> {
return getMaxClaimAmount(this.url, address);
}
public getHeight(): Promise<number> {
return this.rpc.getBlockCount();
}
public getTransactionHistory(address: string): Promise<PastTransaction[]> {
throw new Error("Method not implemented.");
}
}
export default NeoCli;