@leofcoin/chain 1.8.1 → 1.8.3

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.
@@ -3,17 +3,24 @@ import Contract from './contract.js';
3
3
  import Machine from './machine.js';
4
4
  import Jobber from './jobs/jobber.js';
5
5
  import { BlockHash } from './types.js';
6
+ declare type SyncState = 'syncing' | 'synced' | 'errored' | 'connectionless';
7
+ declare type ChainState = 'loading' | 'loaded';
6
8
  export default class State extends Contract {
7
9
  #private;
8
- jobber: Jobber;
9
10
  knownBlocks: BlockHash[];
11
+ jobber: Jobber;
10
12
  _wantList: any[];
11
13
  /**
12
14
  * contains transactions we need before we can successfully load
13
15
  */
14
16
  get wantList(): string[];
17
+ get state(): {
18
+ sync: SyncState;
19
+ chain: ChainState;
20
+ };
21
+ get blockHashMap(): MapIterator<[any, any]>;
15
22
  get loaded(): boolean;
16
- get isSyncing(): boolean;
23
+ get resolving(): boolean;
17
24
  get contracts(): Promise<any>;
18
25
  get totalContracts(): Promise<any>;
19
26
  get nativeCalls(): Promise<any>;
@@ -32,11 +39,10 @@ export default class State extends Contract {
32
39
  previousHash: string;
33
40
  };
34
41
  get lastBlockHeight(): Promise<any> | 0;
35
- get totalSize(): number;
36
- get machine(): Machine;
37
- get blockHashMap(): MapIterator<[any, any]>;
38
42
  getBlock(index: any): Promise<any>;
39
43
  getBlocks(from?: any, to?: any): Promise<[]>;
44
+ get totalSize(): number;
45
+ get machine(): Machine;
40
46
  constructor(config: any);
41
47
  clearPool(): Promise<void>;
42
48
  /**
@@ -47,12 +53,14 @@ export default class State extends Contract {
47
53
  updateState(message: BlockMessage): Promise<void>;
48
54
  getLatestBlock(): Promise<BlockMessage['decoded']>;
49
55
  getAndPutBlock(hash: string): Promise<BlockMessage>;
50
- resolveBlock(hash: string): Promise<void>;
51
- resolveBlocks(): Promise<void>;
52
- syncChain(lastBlock?: any): Promise<'syncing' | 'synced' | 'errored' | 'connectionless'>;
56
+ resolveBlock(hash: any): any;
57
+ resolveBlocks(): Promise<any>;
58
+ restoreChain(): any;
59
+ syncChain(lastBlock?: any): Promise<SyncState>;
53
60
  promiseRequests(promises: any): Promise<unknown>;
54
61
  get canSync(): boolean;
55
62
  get shouldSync(): boolean;
56
- triggerSync(): Promise<"syncing" | "synced" | "errored" | "connectionless">;
63
+ triggerSync(): Promise<SyncState>;
57
64
  triggerLoad(): Promise<void>;
58
65
  }
66
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -54,8 +54,8 @@
54
54
  "@rollup/plugin-node-resolve": "^16.0.3",
55
55
  "@rollup/plugin-typescript": "^12.3.0",
56
56
  "@types/semver": "^7.7.1",
57
- "@vandeurenglenn/debug": "^1.2.7",
58
- "rollup": "^4.53.4",
57
+ "@vandeurenglenn/debug": "^1.4.0",
58
+ "rollup": "^4.54.0",
59
59
  "rollup-plugin-modify": "^3.0.0",
60
60
  "tape": "^5.9.0",
61
61
  "tslib": "^2.8.1"
@@ -69,7 +69,7 @@
69
69
  "@leofcoin/messages": "^1.4.40",
70
70
  "@leofcoin/multi-wallet": "^3.1.8",
71
71
  "@leofcoin/networks": "^1.1.25",
72
- "@leofcoin/peernet": "^1.1.105",
72
+ "@leofcoin/peernet": "^1.2.0",
73
73
  "@leofcoin/storage": "^3.5.38",
74
74
  "@leofcoin/utils": "^1.1.40",
75
75
  "@leofcoin/workers": "^1.5.27",
@@ -1,36 +0,0 @@
1
- import { M as MultiWallet, f as encrypt, c as base58$1 } from './identity-nIyW_Xm8-BU8xakCv.js';
2
-
3
- /**
4
- * @params {String} network
5
- * @return {object} { identity, accounts, config }
6
- */
7
- var index = async (password, network) => {
8
- if (!password)
9
- throw new Error('wallets need to be password protected.');
10
- let wallet = new MultiWallet(network);
11
- /**
12
- * @type {string}
13
- */
14
- let mnemonic = await wallet.generate(password);
15
- wallet = new MultiWallet(network);
16
- await wallet.recover(mnemonic, password, network);
17
- mnemonic = new Uint8Array(await encrypt(password, mnemonic));
18
- const multiWIF = new Uint8Array(await encrypt(password, await wallet.multiWIF));
19
- /**
20
- * @type {object}
21
- */
22
- const external = await wallet.account(1).external(1);
23
- const externalAddress = await external.address;
24
- const internal = await wallet.account(1).internal(1);
25
- const internalAddress = await internal.address;
26
- return {
27
- identity: {
28
- mnemonic: base58$1.encode(mnemonic),
29
- multiWIF: base58$1.encode(multiWIF),
30
- walletId: await external.id
31
- },
32
- accounts: [['main account', externalAddress, internalAddress]]
33
- };
34
- };
35
-
36
- export { index as default };