@leofcoin/chain 1.8.8 → 1.8.9
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.
- package/exports/browser/chain.js +18 -12
- package/exports/browser/{flags-wmeqg14g.js → constants-ByuwyBVy.js} +772 -82
- package/exports/browser/node-browser.js +84 -4
- package/exports/chain.js +14 -7
- package/exports/constants-eo0U5-D_.js +12 -0
- package/exports/constants.d.ts +2 -0
- package/exports/node.js +2 -9
- package/package.json +4 -4
- package/exports/browser/browser-CfYI-6aD-DHRKebpJ.js +0 -132
- package/exports/browser/browser-Qcpp3EKK-DOtgsScX.js +0 -38
- package/exports/browser/client-CWkdUcxK-BEmg-tGc.js +0 -989
- package/exports/browser/identity-nIyW_Xm8-BU8xakCv.js +0 -17199
- package/exports/browser/index-ChRjMyiM-EjbBu23l.js +0 -36
- package/exports/browser/index-DTbjK0sK-BK_5FT46.js +0 -7580
- package/exports/browser/messages-C507MMRx-ypXoH7gN.js +0 -207
- package/exports/browser/networks-F1y7bMrB.js +0 -25
- package/exports/browser/node-browser-A1KVCavN.js +0 -9132
- package/exports/browser/password-oDixGC8h.js +0 -3
- package/exports/browser/qr-scanner-worker.min-Dy0qkKA4-Dy0qkKA4.js +0 -100
- package/exports/flags-DKVwPDLE.js +0 -3
- package/exports/flags.d.ts +0 -2
|
@@ -1,4 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
import './
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import Peernet from '@leofcoin/peernet/browser';
|
|
2
|
+
import { F as FormatInterface, T as TransactionMessage, C as ContractMessage, B as BlockMessage, b as BWMessage, c as BWRequestMessage, V as ValidatorMessage, D as DEFAULT_NODE_OPTIONS } from './constants-ByuwyBVy.js';
|
|
3
|
+
|
|
4
|
+
var proto = {
|
|
5
|
+
lastblock: Object(),
|
|
6
|
+
values: Object()
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
class StateMessage extends FormatInterface {
|
|
10
|
+
get messageName() {
|
|
11
|
+
return 'StateMessage';
|
|
12
|
+
}
|
|
13
|
+
constructor(buffer) {
|
|
14
|
+
if (buffer instanceof StateMessage)
|
|
15
|
+
return buffer;
|
|
16
|
+
const name = 'state-message';
|
|
17
|
+
super(buffer, proto, { name });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var nodeConfig = async (config = {
|
|
22
|
+
network: 'leofcoin:peach',
|
|
23
|
+
networkVersion: 'v1.0.0'
|
|
24
|
+
}) => {
|
|
25
|
+
const protos = [
|
|
26
|
+
{ name: 'transaction-message', handler: TransactionMessage },
|
|
27
|
+
{ name: 'contract-message', handler: ContractMessage },
|
|
28
|
+
{ name: 'block-message', handler: BlockMessage },
|
|
29
|
+
{ name: 'bw-message', handler: BWMessage },
|
|
30
|
+
{ name: 'bw-request-message', handler: BWRequestMessage },
|
|
31
|
+
{ name: 'validator-message', handler: ValidatorMessage },
|
|
32
|
+
{ name: 'state-message', handler: StateMessage }
|
|
33
|
+
];
|
|
34
|
+
for (const proto of protos) {
|
|
35
|
+
peernet.addProto(proto.name, proto.handler);
|
|
36
|
+
}
|
|
37
|
+
let name = `.${config.network}`;
|
|
38
|
+
const parts = config.network.split(':');
|
|
39
|
+
if (parts[1])
|
|
40
|
+
name = `.${parts[0]}/${parts[1]}`;
|
|
41
|
+
// optional namespace suffix to isolate multiple local nodes on same network
|
|
42
|
+
// e.g., '.leofcoin/peach/dev-validator-1'
|
|
43
|
+
if (typeof config.storeNamespace === 'string' && config.storeNamespace.length > 0) {
|
|
44
|
+
name = `${name}/${config.storeNamespace}`;
|
|
45
|
+
}
|
|
46
|
+
const stores = ['transactionPool', 'state', 'accounts', 'contract', { name: 'wallet', private: true }];
|
|
47
|
+
for (const store of stores) {
|
|
48
|
+
if (typeof store === 'string') {
|
|
49
|
+
await peernet.addStore(store, 'lfc', name, false);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
await peernet.addStore(store.name, 'lfc', name, store.private);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
stores,
|
|
57
|
+
protos
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// import config from './config/config'
|
|
62
|
+
class Node {
|
|
63
|
+
#node;
|
|
64
|
+
constructor(config, password) {
|
|
65
|
+
return this._init(config, password);
|
|
66
|
+
}
|
|
67
|
+
async _init(config = {}, password) {
|
|
68
|
+
config = { ...DEFAULT_NODE_OPTIONS, ...config };
|
|
69
|
+
this.#node = globalThis.Peernet
|
|
70
|
+
? await new globalThis.Peernet(config, password)
|
|
71
|
+
: await new Peernet(config, password);
|
|
72
|
+
await nodeConfig(config);
|
|
73
|
+
globalThis.pubsub.subscribe('chain:ready', async () => {
|
|
74
|
+
if (!this.#node.autoStart) {
|
|
75
|
+
await this.#node.start();
|
|
76
|
+
pubsub.publish('node:ready', true);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return this;
|
|
80
|
+
// this.config = await config()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { Node as default };
|
package/exports/chain.js
CHANGED
|
@@ -8,8 +8,9 @@ import { randombytes } from '@leofcoin/crypto';
|
|
|
8
8
|
import EasyWorker from '@vandeurenglenn/easy-worker';
|
|
9
9
|
import { ContractDeploymentError, ExecutionError, isResolveError, ResolveError, isExecutionError } from '@leofcoin/errors';
|
|
10
10
|
import { log } from 'console';
|
|
11
|
-
import {
|
|
11
|
+
import { P as PROTOCOL_VERSION, R as REACHED_ONE_ZERO_ZERO } from './constants-eo0U5-D_.js';
|
|
12
12
|
import { log as log$1 } from 'node:console';
|
|
13
|
+
import '@leofcoin/networks';
|
|
13
14
|
|
|
14
15
|
const limit = 1800;
|
|
15
16
|
const transactionLimit = 2500;
|
|
@@ -1409,14 +1410,20 @@ class State extends Contract {
|
|
|
1409
1410
|
}
|
|
1410
1411
|
try {
|
|
1411
1412
|
const block = await this.getAndPutBlock(hash);
|
|
1412
|
-
await Promise.all(block.decoded.transactions
|
|
1413
|
+
await Promise.all(block.decoded.transactions
|
|
1414
|
+
.filter((hash) => Boolean(hash))
|
|
1415
|
+
.map(async (hash) => {
|
|
1413
1416
|
// should be in a transaction store already
|
|
1414
|
-
|
|
1417
|
+
const exists = await transactionStore.has(hash);
|
|
1418
|
+
if (!exists) {
|
|
1415
1419
|
const data = await peernet.get(hash, 'transaction');
|
|
1420
|
+
if (!data)
|
|
1421
|
+
throw new Error(`missing transaction data for ${hash}`);
|
|
1416
1422
|
await transactionStore.put(hash, data);
|
|
1417
1423
|
}
|
|
1418
|
-
;
|
|
1419
|
-
|
|
1424
|
+
const inPool = await transactionPoolStore.has(hash);
|
|
1425
|
+
if (inPool)
|
|
1426
|
+
await transactionPoolStore.delete(hash);
|
|
1420
1427
|
}));
|
|
1421
1428
|
index = block.decoded.index;
|
|
1422
1429
|
const size = block.encoded.length > 0 ? block.encoded.length : block.encoded.byteLength;
|
|
@@ -1836,8 +1843,8 @@ class VersionControl extends State {
|
|
|
1836
1843
|
constructor(config) {
|
|
1837
1844
|
super(config);
|
|
1838
1845
|
}
|
|
1839
|
-
#currentVersion =
|
|
1840
|
-
#reachedOneZeroZero =
|
|
1846
|
+
#currentVersion = PROTOCOL_VERSION;
|
|
1847
|
+
#reachedOneZeroZero = REACHED_ONE_ZERO_ZERO;
|
|
1841
1848
|
async #setCurrentVersion() {
|
|
1842
1849
|
this.version = this.#currentVersion;
|
|
1843
1850
|
await globalThis.chainStore.put('version', this.version);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import networks from '@leofcoin/networks';
|
|
2
|
+
|
|
3
|
+
const PROTOCOL_VERSION = '0.1.1';
|
|
4
|
+
const REACHED_ONE_ZERO_ZERO = false; // set to true when protocol reaches v1.0.0
|
|
5
|
+
const DEFAULT_NODE_OPTIONS = {
|
|
6
|
+
network: 'leofcoin:peach',
|
|
7
|
+
networkVersion: 'peach',
|
|
8
|
+
version: PROTOCOL_VERSION,
|
|
9
|
+
stars: networks.leofcoin.peach.stars
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { DEFAULT_NODE_OPTIONS as D, PROTOCOL_VERSION as P, REACHED_ONE_ZERO_ZERO as R };
|
package/exports/constants.d.ts
CHANGED
package/exports/node.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import Peernet from '@leofcoin/peernet';
|
|
2
2
|
import nodeConfig from '@leofcoin/lib/node-config';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const DEFAULT_NODE_OPTIONS = {
|
|
7
|
-
network: 'leofcoin:peach',
|
|
8
|
-
networkVersion: 'peach',
|
|
9
|
-
version: currentVersion,
|
|
10
|
-
stars: networks.leofcoin.peach.stars
|
|
11
|
-
};
|
|
3
|
+
import { D as DEFAULT_NODE_OPTIONS } from './constants-eo0U5-D_.js';
|
|
4
|
+
import '@leofcoin/networks';
|
|
12
5
|
|
|
13
6
|
// import config from './config/config'
|
|
14
7
|
class Node {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
56
56
|
"@types/semver": "^7.7.1",
|
|
57
57
|
"@vandeurenglenn/debug": "^1.4.0",
|
|
58
|
-
"rollup": "^4.
|
|
58
|
+
"rollup": "^4.57.1",
|
|
59
59
|
"rollup-plugin-modify": "^3.0.0",
|
|
60
60
|
"tape": "^5.9.0",
|
|
61
61
|
"tslib": "^2.8.1"
|
|
@@ -69,12 +69,12 @@
|
|
|
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.2.
|
|
72
|
+
"@leofcoin/peernet": "^1.2.10",
|
|
73
73
|
"@leofcoin/storage": "^3.5.38",
|
|
74
74
|
"@leofcoin/utils": "^1.1.40",
|
|
75
75
|
"@leofcoin/workers": "^1.5.27",
|
|
76
76
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
77
77
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
78
|
-
"semver": "^7.7.
|
|
78
|
+
"semver": "^7.7.4"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { g as getDefaultExportFromCjs } from './identity-nIyW_Xm8-BU8xakCv.js';
|
|
2
|
-
|
|
3
|
-
var global;
|
|
4
|
-
var hasRequiredGlobal;
|
|
5
|
-
|
|
6
|
-
function requireGlobal () {
|
|
7
|
-
if (hasRequiredGlobal) return global;
|
|
8
|
-
hasRequiredGlobal = 1;
|
|
9
|
-
var naiveFallback = function () {
|
|
10
|
-
if (typeof self === "object" && self) return self;
|
|
11
|
-
if (typeof window === "object" && window) return window;
|
|
12
|
-
throw new Error("Unable to resolve global `this`");
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
global = (function () {
|
|
16
|
-
if (this) return this;
|
|
17
|
-
|
|
18
|
-
// Unexpected strict mode (may happen if e.g. bundled into ESM module)
|
|
19
|
-
|
|
20
|
-
// Fallback to standard globalThis if available
|
|
21
|
-
if (typeof globalThis === "object" && globalThis) return globalThis;
|
|
22
|
-
|
|
23
|
-
// Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
|
|
24
|
-
// In all ES5+ engines global object inherits from Object.prototype
|
|
25
|
-
// (if you approached one that doesn't please report)
|
|
26
|
-
try {
|
|
27
|
-
Object.defineProperty(Object.prototype, "__global__", {
|
|
28
|
-
get: function () { return this; },
|
|
29
|
-
configurable: true
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// Unfortunate case of updates to Object.prototype being restricted
|
|
33
|
-
// via preventExtensions, seal or freeze
|
|
34
|
-
return naiveFallback();
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
// Safari case (window.__global__ works, but __global__ does not)
|
|
38
|
-
if (!__global__) return naiveFallback();
|
|
39
|
-
return __global__;
|
|
40
|
-
} finally {
|
|
41
|
-
delete Object.prototype.__global__;
|
|
42
|
-
}
|
|
43
|
-
})();
|
|
44
|
-
return global;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var version$1 = "1.0.35";
|
|
48
|
-
var require$$0 = {
|
|
49
|
-
version: version$1};
|
|
50
|
-
|
|
51
|
-
var version;
|
|
52
|
-
var hasRequiredVersion;
|
|
53
|
-
|
|
54
|
-
function requireVersion () {
|
|
55
|
-
if (hasRequiredVersion) return version;
|
|
56
|
-
hasRequiredVersion = 1;
|
|
57
|
-
version = require$$0.version;
|
|
58
|
-
return version;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var browser$2;
|
|
62
|
-
var hasRequiredBrowser;
|
|
63
|
-
|
|
64
|
-
function requireBrowser () {
|
|
65
|
-
if (hasRequiredBrowser) return browser$2;
|
|
66
|
-
hasRequiredBrowser = 1;
|
|
67
|
-
var _globalThis;
|
|
68
|
-
if (typeof globalThis === 'object') {
|
|
69
|
-
_globalThis = globalThis;
|
|
70
|
-
} else {
|
|
71
|
-
try {
|
|
72
|
-
_globalThis = requireGlobal();
|
|
73
|
-
} catch (error) {
|
|
74
|
-
} finally {
|
|
75
|
-
if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; }
|
|
76
|
-
if (!_globalThis) { throw new Error('Could not determine global this'); }
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;
|
|
81
|
-
var websocket_version = requireVersion();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Expose a W3C WebSocket class with just one or two arguments.
|
|
86
|
-
*/
|
|
87
|
-
function W3CWebSocket(uri, protocols) {
|
|
88
|
-
var native_instance;
|
|
89
|
-
|
|
90
|
-
if (protocols) {
|
|
91
|
-
native_instance = new NativeWebSocket(uri, protocols);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
native_instance = new NativeWebSocket(uri);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 'native_instance' is an instance of nativeWebSocket (the browser's WebSocket
|
|
99
|
-
* class). Since it is an Object it will be returned as it is when creating an
|
|
100
|
-
* instance of W3CWebSocket via 'new W3CWebSocket()'.
|
|
101
|
-
*
|
|
102
|
-
* ECMAScript 5: http://bclary.com/2004/11/07/#a-13.2.2
|
|
103
|
-
*/
|
|
104
|
-
return native_instance;
|
|
105
|
-
}
|
|
106
|
-
if (NativeWebSocket) {
|
|
107
|
-
['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'].forEach(function(prop) {
|
|
108
|
-
Object.defineProperty(W3CWebSocket, prop, {
|
|
109
|
-
get: function() { return NativeWebSocket[prop]; }
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Module exports.
|
|
116
|
-
*/
|
|
117
|
-
browser$2 = {
|
|
118
|
-
'w3cwebsocket' : NativeWebSocket ? W3CWebSocket : null,
|
|
119
|
-
'version' : websocket_version
|
|
120
|
-
};
|
|
121
|
-
return browser$2;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
var browserExports = requireBrowser();
|
|
125
|
-
var browser = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
126
|
-
|
|
127
|
-
var browser$1 = /*#__PURE__*/Object.freeze({
|
|
128
|
-
__proto__: null,
|
|
129
|
-
default: browser
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
export { browser$1 as b };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { g as getDefaultExportFromCjs } from './identity-nIyW_Xm8-BU8xakCv.js';
|
|
2
|
-
|
|
3
|
-
var browser$2 = {};
|
|
4
|
-
|
|
5
|
-
var hasRequiredBrowser;
|
|
6
|
-
|
|
7
|
-
function requireBrowser () {
|
|
8
|
-
if (hasRequiredBrowser) return browser$2;
|
|
9
|
-
hasRequiredBrowser = 1;
|
|
10
|
-
|
|
11
|
-
browser$2.MediaStream = window.MediaStream;
|
|
12
|
-
browser$2.MediaStreamTrack = window.MediaStreamTrack;
|
|
13
|
-
browser$2.RTCDataChannel = window.RTCDataChannel;
|
|
14
|
-
browser$2.RTCDataChannelEvent = window.RTCDataChannelEvent;
|
|
15
|
-
browser$2.RTCDtlsTransport = window.RTCDtlsTransport;
|
|
16
|
-
browser$2.RTCIceCandidate = window.RTCIceCandidate;
|
|
17
|
-
browser$2.RTCIceTransport = window.RTCIceTransport;
|
|
18
|
-
browser$2.RTCPeerConnection = window.RTCPeerConnection;
|
|
19
|
-
browser$2.RTCPeerConnectionIceEvent = window.RTCPeerConnectionIceEvent;
|
|
20
|
-
browser$2.RTCRtpReceiver = window.RTCRtpReceiver;
|
|
21
|
-
browser$2.RTCRtpSender = window.RTCRtpSender;
|
|
22
|
-
browser$2.RTCRtpTransceiver = window.RTCRtpTransceiver;
|
|
23
|
-
browser$2.RTCSctpTransport = window.RTCSctpTransport;
|
|
24
|
-
browser$2.RTCSessionDescription = window.RTCSessionDescription;
|
|
25
|
-
browser$2.getUserMedia = window.getUserMedia;
|
|
26
|
-
browser$2.mediaDevices = navigator.mediaDevices;
|
|
27
|
-
return browser$2;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var browserExports = requireBrowser();
|
|
31
|
-
var browser = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
32
|
-
|
|
33
|
-
var browser$1 = /*#__PURE__*/Object.freeze({
|
|
34
|
-
__proto__: null,
|
|
35
|
-
default: browser
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export { browser$1 as b };
|