@leofcoin/chain 1.0.4 → 1.0.5
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/_node.js +1 -1
- package/chain.js +13 -554
- package/dist/chain.browser.js +183 -201
- package/dist/chain.browser.min.js +1 -1
- package/dist/chain.js +13 -554
- package/dist/node.browser.js +1800 -1804
- package/dist/node.browser.min.js +1 -1
- package/dist/node.js +1 -1
- package/lib.js +1 -1
- package/package.json +2 -2
- package/src/chain.js +6 -5
- package/src/messages/block.js +1 -1
- package/src/messages/bw-request.js +1 -1
- package/src/messages/bw.js +1 -1
- package/src/messages/contract.js +1 -1
- package/src/messages/last-block-request.js +1 -1
- package/src/messages/last-block.js +1 -1
- package/src/messages/transaction.js +1 -1
package/dist/chain.browser.js
CHANGED
|
@@ -16635,6 +16635,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
16635
16635
|
"Z": function() { return /* binding */ Chain; }
|
|
16636
16636
|
});
|
|
16637
16637
|
|
|
16638
|
+
// NAMESPACE OBJECT: ./node_modules/@leofcoin/codec-format-interface/src/index.js
|
|
16639
|
+
var codec_format_interface_src_namespaceObject = {};
|
|
16640
|
+
__webpack_require__.r(codec_format_interface_src_namespaceObject);
|
|
16641
|
+
|
|
16638
16642
|
// EXTERNAL MODULE: ./node_modules/bn.js/lib/bn.js
|
|
16639
16643
|
var bn = __webpack_require__(3550);
|
|
16640
16644
|
var bn_default = /*#__PURE__*/__webpack_require__.n(bn);
|
|
@@ -18325,17 +18329,17 @@ const base = ALPHABET => {
|
|
|
18325
18329
|
;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base32/src/base32.js
|
|
18326
18330
|
|
|
18327
18331
|
|
|
18328
|
-
const
|
|
18332
|
+
const base32_base32 = 'abcdefghijklmnopqrstuvwxyz234567'
|
|
18329
18333
|
const base32Hex = '0123456789abcdefghijklmnopqrstuv'
|
|
18330
18334
|
|
|
18331
18335
|
const decode = (uint8Array, hex = false) => {
|
|
18332
|
-
const decoder = hex ? base_x(base32Hex) : base_x(
|
|
18336
|
+
const decoder = hex ? base_x(base32Hex) : base_x(base32_base32)
|
|
18333
18337
|
return decoder.decode(uint8Array)
|
|
18334
18338
|
}
|
|
18335
18339
|
|
|
18336
18340
|
/* harmony default export */ var src_base32 = ({
|
|
18337
18341
|
encode: (uint8Array, hex = false) => {
|
|
18338
|
-
const encoder = hex ? base_x(base32Hex) : base_x(
|
|
18342
|
+
const encoder = hex ? base_x(base32Hex) : base_x(base32_base32)
|
|
18339
18343
|
return encoder.encode(uint8Array)
|
|
18340
18344
|
},
|
|
18341
18345
|
decode,
|
|
@@ -18352,12 +18356,12 @@ const decode = (uint8Array, hex = false) => {
|
|
|
18352
18356
|
;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base58/src/base58.js
|
|
18353
18357
|
|
|
18354
18358
|
|
|
18355
|
-
const
|
|
18359
|
+
const base58_base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
|
18356
18360
|
|
|
18357
|
-
const base58_decode = uint8Array => base_x(
|
|
18361
|
+
const base58_decode = uint8Array => base_x(base58_base58).decode(uint8Array)
|
|
18358
18362
|
|
|
18359
18363
|
/* harmony default export */ var src_base58 = ({
|
|
18360
|
-
encode: uint8Array => base_x(
|
|
18364
|
+
encode: uint8Array => base_x(base58_base58).encode(uint8Array),
|
|
18361
18365
|
decode: base58_decode,
|
|
18362
18366
|
isBase58: uint8Array => {
|
|
18363
18367
|
try {
|
|
@@ -18372,10 +18376,136 @@ const base58_decode = uint8Array => base_x(base58).decode(uint8Array)
|
|
|
18372
18376
|
;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/is-hex/is-hex.js
|
|
18373
18377
|
/* harmony default export */ var is_hex = (string => /^[A-F0-9]+$/i.test(string));
|
|
18374
18378
|
|
|
18379
|
+
;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/basic-interface.js
|
|
18380
|
+
/* provided dependency */ var Buffer = __webpack_require__(8764)["Buffer"];
|
|
18381
|
+
|
|
18382
|
+
|
|
18383
|
+
|
|
18384
|
+
|
|
18385
|
+
class BasicInterface {
|
|
18386
|
+
#handleDecode() {
|
|
18387
|
+
if (!this.decode) throw new Error('bad implementation: needs decode func')
|
|
18388
|
+
this.decode()
|
|
18389
|
+
}
|
|
18390
|
+
|
|
18391
|
+
#handleEncode() {
|
|
18392
|
+
if (!this.encode) throw new Error('bad implementation: needs encode func')
|
|
18393
|
+
this.encode()
|
|
18394
|
+
}
|
|
18395
|
+
isHex(string) {
|
|
18396
|
+
return is_hex(string)
|
|
18397
|
+
}
|
|
18398
|
+
isBase32(string) {
|
|
18399
|
+
return base32.isBase32(string)
|
|
18400
|
+
}
|
|
18401
|
+
isBase58(string) {
|
|
18402
|
+
return base58.isBase32(string)
|
|
18403
|
+
}
|
|
18404
|
+
/**
|
|
18405
|
+
* @param {String} encoded
|
|
18406
|
+
*/
|
|
18407
|
+
fromBs32(encoded) {
|
|
18408
|
+
this.encoded = src_base32.decode(encoded)
|
|
18409
|
+
return this.#handleDecode()
|
|
18410
|
+
}
|
|
18411
|
+
|
|
18412
|
+
/**
|
|
18413
|
+
* @param {String} encoded
|
|
18414
|
+
*/
|
|
18415
|
+
fromBs58(encoded) {
|
|
18416
|
+
this.encoded = src_base58.decode(encoded)
|
|
18417
|
+
return this.#handleDecode()
|
|
18418
|
+
}
|
|
18419
|
+
|
|
18420
|
+
async toArray() {
|
|
18421
|
+
const array = []
|
|
18422
|
+
for await (const value of this.encoded.values()) {
|
|
18423
|
+
array.push(value)
|
|
18424
|
+
}
|
|
18425
|
+
return array
|
|
18426
|
+
}
|
|
18427
|
+
|
|
18428
|
+
fromString(string) {
|
|
18429
|
+
this.encoded = new Uint8Array(string.split(','))
|
|
18430
|
+
return this.#handleDecode()
|
|
18431
|
+
}
|
|
18432
|
+
|
|
18433
|
+
fromArray(array) {
|
|
18434
|
+
this.encoded = new Uint8Array([...array])
|
|
18435
|
+
return this.#handleDecode()
|
|
18436
|
+
}
|
|
18437
|
+
|
|
18438
|
+
/**
|
|
18439
|
+
* @param {Buffer} encoded
|
|
18440
|
+
*/
|
|
18441
|
+
fromEncoded(encoded) {
|
|
18442
|
+
this.encoded = encoded
|
|
18443
|
+
return this.#handleDecode()
|
|
18444
|
+
}
|
|
18445
|
+
|
|
18446
|
+
/**
|
|
18447
|
+
* @param {String} encoded
|
|
18448
|
+
*/
|
|
18449
|
+
fromHex(encoded) {
|
|
18450
|
+
this.encoded = Buffer.from(encoded, 'hex')
|
|
18451
|
+
return this.#handleDecode()
|
|
18452
|
+
}
|
|
18453
|
+
|
|
18454
|
+
toString(encoding = 'utf8') {
|
|
18455
|
+
if (!this.encoded) this.#handleEncode()
|
|
18456
|
+
return this.encoded.toString(encoding)
|
|
18457
|
+
}
|
|
18458
|
+
|
|
18459
|
+
/**
|
|
18460
|
+
* @return {String} encoded
|
|
18461
|
+
*/
|
|
18462
|
+
toHex() {
|
|
18463
|
+
return this.toString('hex')
|
|
18464
|
+
}
|
|
18465
|
+
|
|
18466
|
+
/**
|
|
18467
|
+
* @return {String} encoded
|
|
18468
|
+
*/
|
|
18469
|
+
toBs32() {
|
|
18470
|
+
if (!this.encoded) this.#handleEncode()
|
|
18471
|
+
return src_base32.encode(this.encoded)
|
|
18472
|
+
}
|
|
18473
|
+
|
|
18474
|
+
/**
|
|
18475
|
+
* @return {String} encoded
|
|
18476
|
+
*/
|
|
18477
|
+
toBs58() {
|
|
18478
|
+
if (!this.encoded) this.#handleEncode()
|
|
18479
|
+
return src_base58.encode(this.encoded)
|
|
18480
|
+
}
|
|
18481
|
+
|
|
18482
|
+
/**
|
|
18483
|
+
* @param {Object} data
|
|
18484
|
+
*/
|
|
18485
|
+
create(data) {
|
|
18486
|
+
const decoded = {}
|
|
18487
|
+
if (this.keys?.length > 0) {
|
|
18488
|
+
for (const key of this.keys) {
|
|
18489
|
+
Object.defineProperties(decoded, {
|
|
18490
|
+
[key]: {
|
|
18491
|
+
enumerable: true,
|
|
18492
|
+
configurable: true,
|
|
18493
|
+
set: (val) => value = data[key],
|
|
18494
|
+
get: () => data[key]
|
|
18495
|
+
}
|
|
18496
|
+
})
|
|
18497
|
+
}
|
|
18498
|
+
|
|
18499
|
+
this.decoded = decoded
|
|
18500
|
+
this.encode()
|
|
18501
|
+
}
|
|
18502
|
+
}
|
|
18503
|
+
}
|
|
18504
|
+
|
|
18375
18505
|
// EXTERNAL MODULE: ./node_modules/varint/index.js
|
|
18376
18506
|
var varint = __webpack_require__(4676);
|
|
18377
18507
|
var varint_default = /*#__PURE__*/__webpack_require__.n(varint);
|
|
18378
|
-
;// CONCATENATED MODULE: ./node_modules/@leofcoin/
|
|
18508
|
+
;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codecs.js
|
|
18379
18509
|
/* harmony default export */ var codecs = ({
|
|
18380
18510
|
// just a hash
|
|
18381
18511
|
'disco-hash': {
|
|
@@ -18456,19 +18586,17 @@ var varint_default = /*#__PURE__*/__webpack_require__.n(varint);
|
|
|
18456
18586
|
},
|
|
18457
18587
|
});
|
|
18458
18588
|
|
|
18459
|
-
;// CONCATENATED MODULE: ./node_modules/@leofcoin/
|
|
18460
|
-
/* provided dependency */ var Buffer = __webpack_require__(8764)["Buffer"];
|
|
18461
|
-
|
|
18589
|
+
;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec.js
|
|
18462
18590
|
|
|
18463
18591
|
|
|
18464
18592
|
|
|
18465
18593
|
|
|
18466
|
-
|
|
18467
|
-
class PeernetCodec {
|
|
18594
|
+
class PeernetCodec extends BasicInterface {
|
|
18468
18595
|
get codecs() {
|
|
18469
18596
|
return {...globalThis.peernet.codecs, ...codecs}
|
|
18470
18597
|
}
|
|
18471
18598
|
constructor(buffer) {
|
|
18599
|
+
super()
|
|
18472
18600
|
if (buffer) {
|
|
18473
18601
|
if (buffer instanceof Uint8Array) {
|
|
18474
18602
|
const codec = varint_default().decode(buffer);
|
|
@@ -18493,9 +18621,9 @@ class PeernetCodec {
|
|
|
18493
18621
|
}
|
|
18494
18622
|
if (typeof buffer === 'string') {
|
|
18495
18623
|
if (this.codecs[buffer]) this.fromName(buffer)
|
|
18496
|
-
else if (
|
|
18497
|
-
else if (
|
|
18498
|
-
else if (
|
|
18624
|
+
else if (this.isHex(buffer)) this.fromHex(buffer)
|
|
18625
|
+
else if (this.isBase32(buffer)) this.fromBs32(buffer)
|
|
18626
|
+
else if (this.isBase58(buffer)) this.fromBs58(buffer)
|
|
18499
18627
|
else throw new Error(`unsupported string ${buffer}`)
|
|
18500
18628
|
}
|
|
18501
18629
|
if (!isNaN(buffer)) if (this.codecs[this.getCodecName(buffer)]) this.fromCodec(buffer)
|
|
@@ -18510,21 +18638,6 @@ class PeernetCodec {
|
|
|
18510
18638
|
this.decode(encoded)
|
|
18511
18639
|
}
|
|
18512
18640
|
|
|
18513
|
-
fromHex(hex) {
|
|
18514
|
-
this.encoded = Buffer.from(hex, 'hex')
|
|
18515
|
-
this.decode()
|
|
18516
|
-
}
|
|
18517
|
-
|
|
18518
|
-
fromBs32(input) {
|
|
18519
|
-
this.encoded = src_base32.decode(input)
|
|
18520
|
-
this.decode()
|
|
18521
|
-
}
|
|
18522
|
-
|
|
18523
|
-
fromBs58(input) {
|
|
18524
|
-
this.encoded = src_base58.decode(input)
|
|
18525
|
-
this.decode()
|
|
18526
|
-
}
|
|
18527
|
-
|
|
18528
18641
|
getCodec(name) {
|
|
18529
18642
|
return this.codecs[name].codec
|
|
18530
18643
|
}
|
|
@@ -18557,20 +18670,6 @@ class PeernetCodec {
|
|
|
18557
18670
|
this.codecBuffer = varint_default().encode(codec)
|
|
18558
18671
|
}
|
|
18559
18672
|
|
|
18560
|
-
toBs32() {
|
|
18561
|
-
this.encode()
|
|
18562
|
-
return src_base32.encode(this.encoded)
|
|
18563
|
-
}
|
|
18564
|
-
|
|
18565
|
-
toBs58() {
|
|
18566
|
-
this.encode()
|
|
18567
|
-
return src_base58.encode(this.encoded)
|
|
18568
|
-
}
|
|
18569
|
-
|
|
18570
|
-
toHex() {
|
|
18571
|
-
return this.encoded.toString('hex')
|
|
18572
|
-
}
|
|
18573
|
-
|
|
18574
18673
|
decode() {
|
|
18575
18674
|
const codec = varint_default().decode(this.encoded);
|
|
18576
18675
|
this.fromCodec(codec)
|
|
@@ -18586,17 +18685,16 @@ class PeernetCodec {
|
|
|
18586
18685
|
// EXTERNAL MODULE: ./node_modules/keccak/js.js
|
|
18587
18686
|
var js = __webpack_require__(5811);
|
|
18588
18687
|
var js_default = /*#__PURE__*/__webpack_require__.n(js);
|
|
18589
|
-
;// CONCATENATED MODULE: ./node_modules/@leofcoin/
|
|
18590
|
-
/* provided dependency */ var
|
|
18688
|
+
;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec-hash.js
|
|
18689
|
+
/* provided dependency */ var codec_hash_Buffer = __webpack_require__(8764)["Buffer"];
|
|
18591
18690
|
|
|
18592
18691
|
|
|
18593
18692
|
|
|
18594
18693
|
|
|
18595
18694
|
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
class PeernetHash {
|
|
18695
|
+
class CodecHash extends BasicInterface {
|
|
18599
18696
|
constructor(buffer, options = {}) {
|
|
18697
|
+
super()
|
|
18600
18698
|
if (options.name) this.name = options.name
|
|
18601
18699
|
else this.name = 'disco-hash'
|
|
18602
18700
|
if (options.codecs) this.codecs = options.codecs
|
|
@@ -18614,9 +18712,9 @@ class PeernetHash {
|
|
|
18614
18712
|
}
|
|
18615
18713
|
|
|
18616
18714
|
if (typeof buffer === 'string') {
|
|
18617
|
-
if (
|
|
18618
|
-
if (
|
|
18619
|
-
else if (
|
|
18715
|
+
if (this.isHex(buffer)) this.fromHex(buffer)
|
|
18716
|
+
if (this.isBase32(buffer)) this.fromBs32(buffer)
|
|
18717
|
+
else if (this.isBase58(buffer)) this.fromBs58(buffer)
|
|
18620
18718
|
else throw new Error(`unsupported string ${buffer}`)
|
|
18621
18719
|
} else if (typeof buffer === 'object') this.fromJSON(buffer)
|
|
18622
18720
|
}
|
|
@@ -18636,39 +18734,15 @@ class PeernetHash {
|
|
|
18636
18734
|
}
|
|
18637
18735
|
|
|
18638
18736
|
get buffer() {
|
|
18639
|
-
return this.
|
|
18640
|
-
}
|
|
18641
|
-
|
|
18642
|
-
toHex() {
|
|
18643
|
-
return this.hash.toString('hex')
|
|
18737
|
+
return this.encoded
|
|
18644
18738
|
}
|
|
18645
18739
|
|
|
18646
|
-
|
|
18647
|
-
return this.
|
|
18740
|
+
get hash() {
|
|
18741
|
+
return this.encoded
|
|
18648
18742
|
}
|
|
18649
18743
|
|
|
18650
18744
|
fromJSON(json) {
|
|
18651
|
-
return this.encode(
|
|
18652
|
-
}
|
|
18653
|
-
|
|
18654
|
-
toBs32() {
|
|
18655
|
-
return src_base32.encode(this.hash)
|
|
18656
|
-
}
|
|
18657
|
-
|
|
18658
|
-
fromBs32(bs) {
|
|
18659
|
-
return this.decode(src_base32.decode(bs))
|
|
18660
|
-
}
|
|
18661
|
-
|
|
18662
|
-
toBs58() {
|
|
18663
|
-
return src_base58.encode(this.hash)
|
|
18664
|
-
}
|
|
18665
|
-
|
|
18666
|
-
fromBs58(bs) {
|
|
18667
|
-
return this.decode(src_base58.decode(bs))
|
|
18668
|
-
}
|
|
18669
|
-
|
|
18670
|
-
toString(encoding = 'utf8') {
|
|
18671
|
-
return this.hash.toString(encoding)
|
|
18745
|
+
return this.encode(codec_hash_Buffer.from(JSON.stringify(json)))
|
|
18672
18746
|
}
|
|
18673
18747
|
|
|
18674
18748
|
encode(buffer, name) {
|
|
@@ -18690,13 +18764,13 @@ class PeernetHash {
|
|
|
18690
18764
|
uint8Array.set(this.prefix)
|
|
18691
18765
|
uint8Array.set(this.digest, this.prefix.length)
|
|
18692
18766
|
|
|
18693
|
-
this.
|
|
18767
|
+
this.encoded = uint8Array
|
|
18694
18768
|
|
|
18695
|
-
return this.
|
|
18769
|
+
return this.encoded
|
|
18696
18770
|
}
|
|
18697
18771
|
|
|
18698
18772
|
validate(buffer) {
|
|
18699
|
-
if (
|
|
18773
|
+
if (codec_hash_Buffer.isBuffer(buffer)) {
|
|
18700
18774
|
const codec = varint_default().decode(buffer);
|
|
18701
18775
|
if (this.codecs[codec]) {
|
|
18702
18776
|
this.decode(buffer)
|
|
@@ -18705,14 +18779,14 @@ class PeernetHash {
|
|
|
18705
18779
|
}
|
|
18706
18780
|
}
|
|
18707
18781
|
if (typeof buffer === 'string') {
|
|
18708
|
-
if (
|
|
18709
|
-
if (
|
|
18782
|
+
if (this.isHex(buffer)) this.fromHex(buffer)
|
|
18783
|
+
if (this.isBase32(buffer)) this.fromBs32(buffer)
|
|
18710
18784
|
}
|
|
18711
18785
|
if (typeof buffer === 'object') this.fromJSON(buffer)
|
|
18712
18786
|
}
|
|
18713
18787
|
|
|
18714
18788
|
decode(buffer) {
|
|
18715
|
-
this.
|
|
18789
|
+
this.encoded = buffer
|
|
18716
18790
|
const codec = varint_default().decode(buffer);
|
|
18717
18791
|
|
|
18718
18792
|
this.discoCodec = new PeernetCodec(codec, this.codecs)
|
|
@@ -18721,7 +18795,7 @@ class PeernetHash {
|
|
|
18721
18795
|
this.size = varint_default().decode(buffer);
|
|
18722
18796
|
this.digest = buffer.slice((varint_default()).decode.bytes);
|
|
18723
18797
|
if (this.digest.length !== this.size) {
|
|
18724
|
-
throw new Error(`hash length inconsistent: 0x${this.
|
|
18798
|
+
throw new Error(`hash length inconsistent: 0x${this.encoded.toString('hex')}`)
|
|
18725
18799
|
}
|
|
18726
18800
|
|
|
18727
18801
|
// const discoCodec = new Codec(codec, this.codecs)
|
|
@@ -18741,21 +18815,19 @@ class PeernetHash {
|
|
|
18741
18815
|
}
|
|
18742
18816
|
}
|
|
18743
18817
|
|
|
18744
|
-
;// CONCATENATED MODULE: ./node_modules/@leofcoin/
|
|
18745
|
-
/* provided dependency */ var codec_format_interface_Buffer = __webpack_require__(8764)["Buffer"];
|
|
18818
|
+
;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec-format-interface.js
|
|
18746
18819
|
|
|
18747
18820
|
|
|
18748
18821
|
|
|
18749
18822
|
|
|
18750
|
-
|
|
18751
|
-
|
|
18752
|
-
class FormatInterface {
|
|
18823
|
+
class FormatInterface extends BasicInterface {
|
|
18753
18824
|
/**
|
|
18754
18825
|
* @param {Buffer|String|Object} buffer - data - The data needed to create the desired message
|
|
18755
18826
|
* @param {Object} proto - {encode, decode}
|
|
18756
18827
|
* @param {Object} options - {hashFormat, name}
|
|
18757
18828
|
*/
|
|
18758
18829
|
constructor(buffer, proto, options = {}) {
|
|
18830
|
+
super()
|
|
18759
18831
|
this.protoEncode = proto.encode
|
|
18760
18832
|
this.protoDecode = proto.decode
|
|
18761
18833
|
this.hashFormat = options.hashFormat || 'bs32'
|
|
@@ -18764,9 +18836,9 @@ class FormatInterface {
|
|
|
18764
18836
|
else if (buffer instanceof ArrayBuffer) this.fromArrayBuffer(buffer)
|
|
18765
18837
|
else if (buffer.name === options.name) return buffer
|
|
18766
18838
|
else if (buffer instanceof String) {
|
|
18767
|
-
if (
|
|
18768
|
-
else if (
|
|
18769
|
-
else if (
|
|
18839
|
+
if (this.isHex(buffer)) this.fromHex(buffer)
|
|
18840
|
+
else if (this.isBase32(buffer)) this.fromBs32(buffer)
|
|
18841
|
+
else if (this.isBase58(buffer)) this.fromBs58(buffer)
|
|
18770
18842
|
else throw new Error(`unsupported string ${buffer}`)
|
|
18771
18843
|
} else {
|
|
18772
18844
|
this.create(buffer)
|
|
@@ -18777,7 +18849,7 @@ class FormatInterface {
|
|
|
18777
18849
|
* @return {PeernetHash}
|
|
18778
18850
|
*/
|
|
18779
18851
|
get peernetHash() {
|
|
18780
|
-
return new
|
|
18852
|
+
return new CodecHash(this.decoded, {name: this.name})
|
|
18781
18853
|
}
|
|
18782
18854
|
|
|
18783
18855
|
/**
|
|
@@ -18836,114 +18908,23 @@ class FormatInterface {
|
|
|
18836
18908
|
)
|
|
18837
18909
|
else this.decode()
|
|
18838
18910
|
}
|
|
18911
|
+
}
|
|
18912
|
+
|
|
18913
|
+
;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/index.js
|
|
18839
18914
|
|
|
18840
|
-
toString() {
|
|
18841
|
-
return this.encoded.toString()
|
|
18842
|
-
}
|
|
18843
|
-
|
|
18844
|
-
async toArray() {
|
|
18845
|
-
const array = []
|
|
18846
|
-
for await (const value of this.encoded.values()) {
|
|
18847
|
-
array.push(value)
|
|
18848
|
-
}
|
|
18849
|
-
return array
|
|
18850
|
-
}
|
|
18851
|
-
|
|
18852
|
-
fromString(string) {
|
|
18853
|
-
this.encoded = new Uint8Array(string.split(','))
|
|
18854
|
-
this.decode()
|
|
18855
|
-
}
|
|
18856
|
-
|
|
18857
|
-
fromArray(array) {
|
|
18858
|
-
this.encoded = new Uint8Array([...array])
|
|
18859
|
-
this.decode()
|
|
18860
|
-
}
|
|
18861
|
-
|
|
18862
|
-
/**
|
|
18863
|
-
* @param {Buffer} encoded
|
|
18864
|
-
*/
|
|
18865
|
-
fromEncoded(encoded) {
|
|
18866
|
-
this.encoded = encoded
|
|
18867
|
-
this.decode()
|
|
18868
|
-
}
|
|
18869
|
-
|
|
18870
|
-
/**
|
|
18871
|
-
* @param {String} encoded
|
|
18872
|
-
*/
|
|
18873
|
-
fromHex(encoded) {
|
|
18874
|
-
this.encoded = codec_format_interface_Buffer.from(encoded, 'hex')
|
|
18875
|
-
this.decode()
|
|
18876
|
-
}
|
|
18877
|
-
|
|
18878
|
-
/**
|
|
18879
|
-
* @param {String} encoded
|
|
18880
|
-
*/
|
|
18881
|
-
fromBs32(encoded) {
|
|
18882
|
-
this.encoded = src_base32.decode(encoded)
|
|
18883
|
-
this.decode()
|
|
18884
|
-
}
|
|
18885
18915
|
|
|
18886
|
-
/**
|
|
18887
|
-
* @param {String} encoded
|
|
18888
|
-
*/
|
|
18889
|
-
fromBs58(encoded) {
|
|
18890
|
-
this.encoded = src_base58.decode(encoded)
|
|
18891
|
-
this.decode()
|
|
18892
|
-
}
|
|
18893
18916
|
|
|
18894
|
-
/**
|
|
18895
|
-
* @return {String} encoded
|
|
18896
|
-
*/
|
|
18897
|
-
toHex() {
|
|
18898
|
-
if (!this.encoded) this.encode()
|
|
18899
|
-
return this.encoded.toString('hex')
|
|
18900
|
-
}
|
|
18901
18917
|
|
|
18902
|
-
/**
|
|
18903
|
-
* @return {String} encoded
|
|
18904
|
-
*/
|
|
18905
|
-
toBs32() {
|
|
18906
|
-
if (!this.encoded) this.encode()
|
|
18907
|
-
return src_base32.encode(this.encoded)
|
|
18908
|
-
}
|
|
18909
18918
|
|
|
18910
|
-
/**
|
|
18911
|
-
* @return {String} encoded
|
|
18912
|
-
*/
|
|
18913
|
-
toBs58() {
|
|
18914
|
-
if (!this.encoded) this.encode()
|
|
18915
|
-
return src_base58.encode(this.encoded)
|
|
18916
|
-
}
|
|
18917
|
-
|
|
18918
|
-
/**
|
|
18919
|
-
* @param {Object} data
|
|
18920
|
-
*/
|
|
18921
|
-
create(data) {
|
|
18922
|
-
const decoded = {}
|
|
18923
|
-
if (this.keys?.length > 0) {
|
|
18924
|
-
for (const key of this.keys) {
|
|
18925
|
-
Object.defineProperties(decoded, {
|
|
18926
|
-
[key]: {
|
|
18927
|
-
enumerable: true,
|
|
18928
|
-
configurable: true,
|
|
18929
|
-
set: (val) => value = data[key],
|
|
18930
|
-
get: () => data[key]
|
|
18931
|
-
}
|
|
18932
|
-
})
|
|
18933
|
-
}
|
|
18934
18919
|
|
|
18935
|
-
|
|
18936
|
-
this.encode()
|
|
18937
|
-
}
|
|
18938
|
-
}
|
|
18939
|
-
}
|
|
18920
|
+
/* harmony default export */ var codec_format_interface_src = ({ codecs: codecs, Codec: PeernetCodec, CodecHash: CodecHash, FormatInterface: FormatInterface, BasicInterface: BasicInterface });
|
|
18940
18921
|
|
|
18941
18922
|
;// CONCATENATED MODULE: ./src/messages/contract.js
|
|
18942
18923
|
|
|
18943
18924
|
|
|
18944
18925
|
|
|
18945
18926
|
|
|
18946
|
-
class ContractMessage extends FormatInterface {
|
|
18927
|
+
class ContractMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
|
|
18947
18928
|
get keys() {
|
|
18948
18929
|
return ['creator', 'contract', 'constructorParameters']
|
|
18949
18930
|
}
|
|
@@ -18971,7 +18952,7 @@ message TransactionMessage {
|
|
|
18971
18952
|
|
|
18972
18953
|
|
|
18973
18954
|
|
|
18974
|
-
class TransactionMessage extends FormatInterface {
|
|
18955
|
+
class TransactionMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
|
|
18975
18956
|
get keys() {
|
|
18976
18957
|
return ['timestamp', 'from', 'to', 'nonce', 'method', 'params']
|
|
18977
18958
|
}
|
|
@@ -19015,7 +18996,7 @@ message BlockMessage {
|
|
|
19015
18996
|
|
|
19016
18997
|
|
|
19017
18998
|
|
|
19018
|
-
class BlockMessage extends FormatInterface {
|
|
18999
|
+
class BlockMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
|
|
19019
19000
|
get keys() {
|
|
19020
19001
|
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
19021
19002
|
}
|
|
@@ -19040,7 +19021,7 @@ message BWMessage {
|
|
|
19040
19021
|
|
|
19041
19022
|
|
|
19042
19023
|
|
|
19043
|
-
class BWMessage extends FormatInterface {
|
|
19024
|
+
class BWMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
|
|
19044
19025
|
get keys() {
|
|
19045
19026
|
return ['up', 'down']
|
|
19046
19027
|
}
|
|
@@ -19063,7 +19044,7 @@ message BWRequestMessage {
|
|
|
19063
19044
|
|
|
19064
19045
|
|
|
19065
19046
|
|
|
19066
|
-
class BWRequestMessage extends FormatInterface {
|
|
19047
|
+
class BWRequestMessage extends codec_format_interface_src_namespaceObject.FormatInterface {
|
|
19067
19048
|
get keys() {
|
|
19068
19049
|
return []
|
|
19069
19050
|
}
|
|
@@ -19563,11 +19544,12 @@ class Chain {
|
|
|
19563
19544
|
promises = await Promise.allSettled(promises)
|
|
19564
19545
|
|
|
19565
19546
|
// todo finish state
|
|
19566
|
-
for (const contract of contracts) {
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
}
|
|
19547
|
+
// for (const contract of contracts) {
|
|
19548
|
+
// const state = await this.#machine.get(contract, 'state')
|
|
19549
|
+
// // await stateStore.put(contract, state)
|
|
19550
|
+
// console.log(state);
|
|
19551
|
+
// }
|
|
19552
|
+
pubsub.publish('block-processed', blockMessage.decoded)
|
|
19571
19553
|
} catch (e) {
|
|
19572
19554
|
console.log(e);
|
|
19573
19555
|
}
|