@xelis/sdk 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.Permission = exports.RPCMethod = void 0;
3
+ exports.Permission = exports.RPCEvent = exports.RPCMethod = void 0;
4
4
  var RPCMethod;
5
5
  (function (RPCMethod) {
6
6
  RPCMethod["GetVersion"] = "get_version";
@@ -23,6 +23,16 @@ var RPCMethod;
23
23
  RPCMethod["SignData"] = "sign_data";
24
24
  RPCMethod["EstimateFees"] = "estimate_fees";
25
25
  })(RPCMethod = exports.RPCMethod || (exports.RPCMethod = {}));
26
+ var RPCEvent;
27
+ (function (RPCEvent) {
28
+ RPCEvent["NewTopoheight"] = "new_topoheight";
29
+ RPCEvent["NewAsset"] = "new_asset";
30
+ RPCEvent["NewTransaction"] = "";
31
+ RPCEvent["BalanceChanged"] = "balance_changed";
32
+ RPCEvent["Rescan"] = "rescan";
33
+ RPCEvent["Online"] = "online";
34
+ RPCEvent["Offline"] = "offline";
35
+ })(RPCEvent = exports.RPCEvent || (exports.RPCEvent = {}));
26
36
  var Permission;
27
37
  (function (Permission) {
28
38
  Permission[Permission["Ask"] = 0] = "Ask";
@@ -27,6 +27,27 @@ var WalletMethods = /** @class */ (function () {
27
27
  WalletMethods.prototype.dataCall = function (method, params) {
28
28
  return this.ws.dataCall(this.prefix + method, params);
29
29
  };
30
+ WalletMethods.prototype.onNewTopoheight = function (onData) {
31
+ return this.ws.listenEvent(types_1.RPCEvent.NewTopoheight, onData);
32
+ };
33
+ WalletMethods.prototype.onNewAsset = function (onData) {
34
+ return this.ws.listenEvent(types_1.RPCEvent.NewAsset, onData);
35
+ };
36
+ WalletMethods.prototype.onNewTransaction = function (onData) {
37
+ return this.ws.listenEvent(types_1.RPCEvent.NewTransaction, onData);
38
+ };
39
+ WalletMethods.prototype.onBalanceChanged = function (onData) {
40
+ return this.ws.listenEvent(types_1.RPCEvent.BalanceChanged, onData);
41
+ };
42
+ WalletMethods.prototype.onRescan = function (onData) {
43
+ return this.ws.listenEvent(types_1.RPCEvent.Rescan, onData);
44
+ };
45
+ WalletMethods.prototype.onOnline = function (onData) {
46
+ return this.ws.listenEvent(types_1.RPCEvent.Online, onData);
47
+ };
48
+ WalletMethods.prototype.onOffline = function (onData) {
49
+ return this.ws.listenEvent(types_1.RPCEvent.Offline, onData);
50
+ };
30
51
  WalletMethods.prototype.getVersion = function () {
31
52
  return this.dataCall(types_1.RPCMethod.GetVersion);
32
53
  };
@@ -20,6 +20,16 @@ export var RPCMethod;
20
20
  RPCMethod["SignData"] = "sign_data";
21
21
  RPCMethod["EstimateFees"] = "estimate_fees";
22
22
  })(RPCMethod || (RPCMethod = {}));
23
+ export var RPCEvent;
24
+ (function (RPCEvent) {
25
+ RPCEvent["NewTopoheight"] = "new_topoheight";
26
+ RPCEvent["NewAsset"] = "new_asset";
27
+ RPCEvent["NewTransaction"] = "";
28
+ RPCEvent["BalanceChanged"] = "balance_changed";
29
+ RPCEvent["Rescan"] = "rescan";
30
+ RPCEvent["Online"] = "online";
31
+ RPCEvent["Offline"] = "offline";
32
+ })(RPCEvent || (RPCEvent = {}));
23
33
  export var Permission;
24
34
  (function (Permission) {
25
35
  Permission[Permission["Ask"] = 0] = "Ask";
@@ -14,7 +14,7 @@ var __extends = (this && this.__extends) || (function () {
14
14
  };
15
15
  })();
16
16
  import { WS as BaseWS } from '../lib/websocket.js';
17
- import { RPCMethod } from './types.js';
17
+ import { RPCMethod, RPCEvent } from './types.js';
18
18
  var WalletMethods = /** @class */ (function () {
19
19
  function WalletMethods(ws, prefix) {
20
20
  if (prefix === void 0) { prefix = ""; }
@@ -24,6 +24,27 @@ var WalletMethods = /** @class */ (function () {
24
24
  WalletMethods.prototype.dataCall = function (method, params) {
25
25
  return this.ws.dataCall(this.prefix + method, params);
26
26
  };
27
+ WalletMethods.prototype.onNewTopoheight = function (onData) {
28
+ return this.ws.listenEvent(RPCEvent.NewTopoheight, onData);
29
+ };
30
+ WalletMethods.prototype.onNewAsset = function (onData) {
31
+ return this.ws.listenEvent(RPCEvent.NewAsset, onData);
32
+ };
33
+ WalletMethods.prototype.onNewTransaction = function (onData) {
34
+ return this.ws.listenEvent(RPCEvent.NewTransaction, onData);
35
+ };
36
+ WalletMethods.prototype.onBalanceChanged = function (onData) {
37
+ return this.ws.listenEvent(RPCEvent.BalanceChanged, onData);
38
+ };
39
+ WalletMethods.prototype.onRescan = function (onData) {
40
+ return this.ws.listenEvent(RPCEvent.Rescan, onData);
41
+ };
42
+ WalletMethods.prototype.onOnline = function (onData) {
43
+ return this.ws.listenEvent(RPCEvent.Online, onData);
44
+ };
45
+ WalletMethods.prototype.onOffline = function (onData) {
46
+ return this.ws.listenEvent(RPCEvent.Offline, onData);
47
+ };
27
48
  WalletMethods.prototype.getVersion = function () {
28
49
  return this.dataCall(RPCMethod.GetVersion);
29
50
  };
@@ -21,6 +21,8 @@ export interface Block {
21
21
  difficulty: string;
22
22
  supply?: number;
23
23
  reward?: number;
24
+ dev_reward?: number;
25
+ miner_reward?: number;
24
26
  cumulative_difficulty: string;
25
27
  total_fees?: number;
26
28
  total_size_in_bytes: number;
@@ -82,6 +82,16 @@ export interface EstimateFeesParams {
82
82
  transfers: TransferOut[];
83
83
  burn?: TxBurn;
84
84
  }
85
+ export interface BalanceChangedResult {
86
+ asset: string;
87
+ balance: number;
88
+ }
89
+ export interface NewTopoheightResult {
90
+ topoheight: number;
91
+ }
92
+ export interface RescanResult {
93
+ start_topoheight: number;
94
+ }
85
95
  export declare enum RPCMethod {
86
96
  GetVersion = "get_version",
87
97
  GetNetwork = "get_network",
@@ -103,6 +113,15 @@ export declare enum RPCMethod {
103
113
  SignData = "sign_data",
104
114
  EstimateFees = "estimate_fees"
105
115
  }
116
+ export declare enum RPCEvent {
117
+ NewTopoheight = "new_topoheight",
118
+ NewAsset = "new_asset",
119
+ NewTransaction = "",
120
+ BalanceChanged = "balance_changed",
121
+ Rescan = "rescan",
122
+ Online = "online",
123
+ Offline = "offline"
124
+ }
106
125
  export declare enum Permission {
107
126
  Ask = 0,
108
127
  AcceptAlways = 1,
@@ -1,11 +1,19 @@
1
1
  import { WS as BaseWS } from '../lib/websocket';
2
- import { GetAssetParams } from '../daemon/types';
3
- import { BuildTransactionParams, BuildTransactionResult, GetAddressParams, ListTransactionParams, SplitAddressParams, SplitAddressResult, Signature, TransactionEntry, RescanParams, SetOnlineModeParams, EstimateFeesParams } from './types';
2
+ import { MessageEvent } from 'ws';
3
+ import { AssetWithData, GetAssetParams, RPCEventResult } from '../daemon/types';
4
+ import { BuildTransactionParams, BuildTransactionResult, GetAddressParams, ListTransactionParams, SplitAddressParams, SplitAddressResult, Signature, RescanParams, SetOnlineModeParams, EstimateFeesParams, TransactionEntry, BalanceChangedResult, NewTopoheightResult, RescanResult } from './types';
4
5
  export declare class WalletMethods {
5
6
  ws: BaseWS;
6
7
  prefix: string;
7
8
  constructor(ws: BaseWS, prefix?: string);
8
9
  dataCall<T>(method: string, params?: any): Promise<T>;
10
+ onNewTopoheight(onData: (msgEvent: MessageEvent, data?: NewTopoheightResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
11
+ onNewAsset(onData: (msgEvent: MessageEvent, data?: AssetWithData & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
12
+ onNewTransaction(onData: (msgEvent: MessageEvent, data?: TransactionEntry & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
13
+ onBalanceChanged(onData: (msgEvent: MessageEvent, data?: BalanceChangedResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
14
+ onRescan(onData: (msgEvent: MessageEvent, data?: RescanResult & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
15
+ onOnline(onData: (msgEvent: MessageEvent, data?: RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
16
+ onOffline(onData: (msgEvent: MessageEvent, data?: RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
9
17
  getVersion(): Promise<string>;
10
18
  getNetwork(): Promise<string>;
11
19
  getNonce(): Promise<number>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.0",
2
+ "version": "0.9.1",
3
3
  "name": "@xelis/sdk",
4
4
  "description": "Xelis software development kit for JS",
5
5
  "exports": {