- Refactor HttpGetter function.
- Remove redundant asset files.
- Fix BlockSync dependency issues.
This commit is contained in:
Spencer Ofwiti 2021-02-25 13:46:24 +03:00
parent 857994fe8b
commit fbdfa54d9b
27 changed files with 138 additions and 1346 deletions

260
package-lock.json generated
View File

@ -302,6 +302,12 @@
"ms": "^2.1.1"
}
},
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"dev": true
},
"uuid": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz",
@ -1647,9 +1653,9 @@
}
},
"@ethereumjs/common": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-2.0.0.tgz",
"integrity": "sha512-yL0zA7Xwgz8IFHKW0VoXGjdZDVxUJg8BQ/muMHvYPW7zHJNNC80gQmvLH+MpvIg1TCXZkFXxrpYRAyCElSm+aw==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-2.1.0.tgz",
"integrity": "sha512-sY2yBKwZjlIM5Z+sBd9ZEEH5YDB5OsvSVCi5hzTqeMfv4307JfLH0MjM09whi4InLmqWRdJp/fmt/rQyP4qxKg==",
"requires": {
"crc-32": "^1.2.0"
}
@ -2007,6 +2013,14 @@
"pacote": "9.5.12",
"semver": "7.3.2",
"semver-intersect": "1.4.0"
},
"dependencies": {
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"dev": true
}
}
},
"@sindresorhus/is": {
@ -2160,14 +2174,6 @@
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
"dev": true
},
"@types/web3": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/web3/-/web3-1.2.2.tgz",
"integrity": "sha512-eFiYJKggNrOl0nsD+9cMh2MLk4zVBfXfGnVeRFbpiZzBE20eet4KLA3fXcjSuHaBn0RnQzwLAGdgzgzdet4C0A==",
"requires": {
"web3": "*"
}
},
"@types/webpack-sources": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.8.tgz",
@ -3348,15 +3354,6 @@
"tweetnacl": "^0.14.3"
}
},
"better-assert": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
"integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
"dev": true,
"requires": {
"callsite": "1.0.0"
}
},
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
@ -3416,6 +3413,11 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"bn": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/bn/-/bn-1.0.5.tgz",
"integrity": "sha512-7TvGbqbZb6lDzsBtNz1VkdXXV0BVmZKPPViPmo2IpvwaryF7P+QKYKACyVkwo2mZPr2CpFiz7EtgPEcc3o/JFQ=="
},
"bn.js": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.3.tgz",
@ -3832,12 +3834,6 @@
"caller-callsite": "^2.0.0"
}
},
"callsite": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=",
"dev": true
},
"callsites": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
@ -3956,14 +3952,16 @@
}
},
"cic-client": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/cic-client/-/cic-client-0.0.3.tgz",
"integrity": "sha512-PAgHs8O2W8zhH8vsAuHv2IWz/Ol8ZjYDLiNqLyIPRG7h457XY5IM5zfy8hEwSFpsXRYC9gFMnb8THR4HG17Oqg==",
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/cic-client/-/cic-client-0.1.1.tgz",
"integrity": "sha512-4eywf1VT8YaA4a+ap2gTsjmep/vmjWDMNoADOztOhua7uh/Jh0AR4446npmT3c7S3Hp1aailR2EJABbzpkePjA==",
"requires": {
"@types/web3": "^1.2.2",
"bn": "^1.0.5",
"lru-cache": "^6.0.0",
"path-browserify": "^1.0.1",
"ts-node": "^9.0.0",
"typescript": "^4.0.5",
"web3": "^1.3.0",
"web3": "^1.3.1",
"webpack": "^5.4.0"
},
"dependencies": {
@ -4145,6 +4143,11 @@
"yocto-queue": "^0.1.0"
}
},
"path-browserify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
"integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g=="
},
"schema-utils": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz",
@ -4234,9 +4237,9 @@
}
},
"webpack": {
"version": "5.24.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.24.1.tgz",
"integrity": "sha512-eg+6OIt6npUSwbhRQY6XffAixEUSARBf+WAWOxrZwOB4jRbbpMXlridFy/Yt7N0U20Ry1vp/nnDbtN7l1rUdIA==",
"version": "5.24.2",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.24.2.tgz",
"integrity": "sha512-uxxKYEY4kMNjP+D2Y+8aw5Vd7ar4pMuKCNemxV26ysr1nk0YDiQTylg9U3VZIdkmI0YHa0uC8ABxL+uGxGWWJg==",
"requires": {
"@types/eslint-scope": "^3.7.0",
"@types/estree": "^0.0.46",
@ -4275,9 +4278,9 @@
}
},
"cic-client-meta": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/cic-client-meta/-/cic-client-meta-0.0.5.tgz",
"integrity": "sha512-eWRzhZHA7/1/4dJB3gazzdtBWyEHjhUzIbfhW3eaGbCs7sW7m0Sj7nq/uzEC/bFxFMoVGx+3aiKrjLN8ocqcZA==",
"version": "0.0.7-alpha.3",
"resolved": "https://registry.npmjs.org/cic-client-meta/-/cic-client-meta-0.0.7-alpha.3.tgz",
"integrity": "sha512-4lnzx8Bz6iiIi0wuJL0vSnR+umvrTyDok3efQfafkUM4stNR4kBh6vpqZJiA0FE+oTOr1raiVvm2QyekyUx24A==",
"requires": {
"@ethereumjs/tx": "^3.0.0-beta.1",
"automerge": "^0.14.1",
@ -4383,9 +4386,9 @@
}
},
"yargs-parser": {
"version": "20.2.5",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.5.tgz",
"integrity": "sha512-jYRGS3zWy20NtDtK2kBgo/TlAoy5YUuhD9/LZ7z7W4j1Fdw2cqD0xEEclf8fxc8xjD6X5Qr+qQQwCEsP8iRiYg=="
"version": "20.2.6",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.6.tgz",
"integrity": "sha512-AP1+fQIWSM/sMiET8fyayjx/J+JmTPt2Mr0FkrgqB4todtfa53sOsrSAcIrJRD5XS20bKUwaDIuMkWKCEiQLKA=="
}
}
},
@ -5832,23 +5835,23 @@
}
},
"engine.io": {
"version": "3.4.2",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.4.2.tgz",
"integrity": "sha512-b4Q85dFkGw+TqgytGPrGgACRUhsdKc9S9ErRAXpPGy/CXKs4tYoHDkvIRdsseAF7NjfVwjRFIn6KTnbw7LwJZg==",
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.5.0.tgz",
"integrity": "sha512-21HlvPUKaitDGE4GXNtQ7PLP0Sz4aWLddMPw2VTyFz1FVZqu/kZsJUO8WNpKuE/OCL7nkfRaOui2ZCJloGznGA==",
"dev": true,
"requires": {
"accepts": "~1.3.4",
"base64id": "2.0.0",
"cookie": "0.3.1",
"cookie": "~0.4.1",
"debug": "~4.1.0",
"engine.io-parser": "~2.2.0",
"ws": "^7.1.2"
"ws": "~7.4.2"
},
"dependencies": {
"cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=",
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==",
"dev": true
},
"debug": {
@ -5861,17 +5864,17 @@
}
},
"ws": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz",
"integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==",
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.3.tgz",
"integrity": "sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==",
"dev": true
}
}
},
"engine.io-client": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.4.tgz",
"integrity": "sha512-iU4CRr38Fecj8HoZEnFtm2EiKGbYZcPn3cHxqNGl/tmdWRf60KhK+9vE0JeSjgnlS/0oynEfLgKbT9ALpim0sQ==",
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.5.0.tgz",
"integrity": "sha512-12wPRfMrugVw/DNyJk34GQ5vIVArEcVMXWugQGGuw2XxUSztFNmJggZmv8IZlLyEdnpO1QB9LkcjeWewO2vxtA==",
"dev": true,
"requires": {
"component-emitter": "~1.3.0",
@ -5882,7 +5885,7 @@
"indexof": "0.0.1",
"parseqs": "0.0.6",
"parseuri": "0.0.6",
"ws": "~6.1.0",
"ws": "~7.4.2",
"xmlhttprequest-ssl": "~1.5.4",
"yeast": "0.1.2"
},
@ -5902,26 +5905,11 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"parseqs": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz",
"integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w==",
"dev": true
},
"parseuri": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz",
"integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow==",
"dev": true
},
"ws": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
"integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
"dev": true,
"requires": {
"async-limiter": "~1.0.0"
}
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.3.tgz",
"integrity": "sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==",
"dev": true
}
}
},
@ -7724,9 +7712,9 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
},
"inquirer": {
"version": "7.3.3",
@ -10663,12 +10651,6 @@
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
},
"object-component": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz",
"integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=",
"dev": true
},
"object-copy": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz",
@ -11294,22 +11276,16 @@
}
},
"parseqs": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",
"integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=",
"dev": true,
"requires": {
"better-assert": "~1.0.0"
}
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz",
"integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w==",
"dev": true
},
"parseuri": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz",
"integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=",
"dev": true,
"requires": {
"better-assert": "~1.0.0"
}
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz",
"integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow==",
"dev": true
},
"parseurl": {
"version": "1.3.3",
@ -13826,16 +13802,16 @@
}
},
"socket.io": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.3.0.tgz",
"integrity": "sha512-2A892lrj0GcgR/9Qk81EaY2gYhCBxurV0PfmmESO6p27QPrUK1J3zdns+5QPqvUYK2q657nSj0guoIil9+7eFg==",
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.4.1.tgz",
"integrity": "sha512-Si18v0mMXGAqLqCVpTxBa8MGqriHGQh8ccEOhmsmNS3thNCGBwO8WGrwMibANsWtQQ5NStdZwHqZR3naJVFc3w==",
"dev": true,
"requires": {
"debug": "~4.1.0",
"engine.io": "~3.4.0",
"engine.io": "~3.5.0",
"has-binary2": "~1.0.2",
"socket.io-adapter": "~1.1.0",
"socket.io-client": "2.3.0",
"socket.io-client": "2.4.0",
"socket.io-parser": "~3.4.0"
},
"dependencies": {
@ -13857,71 +13833,24 @@
"dev": true
},
"socket.io-client": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.3.0.tgz",
"integrity": "sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.4.0.tgz",
"integrity": "sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ==",
"dev": true,
"requires": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "~4.1.0",
"engine.io-client": "~3.4.0",
"component-emitter": "~1.3.0",
"debug": "~3.1.0",
"engine.io-client": "~3.5.0",
"has-binary2": "~1.0.2",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"parseqs": "0.0.6",
"parseuri": "0.0.6",
"socket.io-parser": "~3.3.0",
"to-array": "0.1.4"
},
"dependencies": {
"base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
"dev": true
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
"dev": true
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dev": true,
"requires": {
"ms": "^2.1.1"
}
},
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=",
"dev": true
},
"socket.io-parser": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.1.tgz",
"integrity": "sha512-1QLvVAe8dTz+mKmZ07Swxt+LAo4Y1ff50rlyoEx00TQmDFVQYPfcqGvIDJLGaBdhdNCecXtyKpD+EgKGcmmbuQ==",
"dev": true,
"requires": {
"component-emitter": "~1.3.0",
"debug": "~3.1.0",
"isarray": "2.0.1"
},
"dependencies": {
"component-emitter": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
"integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==",
"dev": true
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
@ -13931,12 +13860,27 @@
"ms": "2.0.0"
}
},
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=",
"dev": true
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
}
},
"socket.io-parser": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.2.tgz",
"integrity": "sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg==",
"dev": true,
"requires": {
"component-emitter": "~1.3.0",
"debug": "~3.1.0",
"isarray": "2.0.1"
}
}
}

View File

@ -26,8 +26,8 @@
"block-syncer": "^0.2.4",
"bootstrap": "^4.5.3",
"chart.js": "^2.9.4",
"cic-client": "0.0.3",
"cic-client-meta": "0.0.5",
"cic-client": "^0.1.1",
"cic-client-meta": "0.0.7-alpha.3",
"datatables.net": "^1.10.22",
"datatables.net-dt": "^1.10.22",
"jquery": "^3.5.1",
@ -64,5 +64,6 @@
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
},
"author": "Spencer Ofwiti <maxspencer56@gmail.com>"
}

View File

@ -1,19 +1,18 @@
function HttpGetter(): void {}
class HttpGetter {
async get(filename: string): Promise<any> {
HttpGetter.prototype.get = filename => new Promise((whohoo, doh) => {
const xhr = new XMLHttpRequest();
xhr.addEventListener('load', (e) => {
if (xhr.status === 200) {
console.log(xhr.responseText);
whohoo(xhr.responseText);
return;
}
console.log('failed with status ' + xhr.status + ': ' + xhr.statusText);
doh('failed with status ' + xhr.status + ': ' + xhr.statusText);
});
xhr.open('GET', filename);
xhr.send();
}
}
});
export {
HttpGetter
};

View File

@ -7,4 +7,3 @@ export * from '@app/_helpers/array-sum';
export * from '@app/_helpers/accountIndex';
export * from '@app/_helpers/http-getter';
export * from '@app/_helpers/pgp-signer';

View File

@ -1,6 +1,6 @@
import { KeyStore } from 'cic-client-meta';
const openpgp = require('openpgp');
const keyring = new openpgp.Keyring();
import { KeyStore } from '@src/assets/js/cic-meta/auth';
interface MutableKeyStore extends KeyStore {
loadKeyring(): Promise<void>;

View File

@ -1,33 +1,32 @@
import {Injectable} from '@angular/core';
import {Settings} from '@app/_models';
import Web3 from 'web3';
import {abi, Registry, TransactionHelper} from 'cic-client';
import {CICRegistry, TransactionHelper} from 'cic-client';
import {first} from 'rxjs/operators';
import {TransactionService} from '@app/_services/transaction.service';
import {environment} from '@src/environments/environment';
const cic = require('@src/assets/js/block-sync/cic-client.web');
import {HttpGetter} from '@app/_helpers';
@Injectable({
providedIn: 'root'
})
export class BlockSyncService {
trustedDeclaratorAddress: string = '0x5567139c7a1C2977A391f51D8cA45B1D6700f5F6';
readyStateTarget: number = 2;
readyState: number = 0;
fileGetter = new HttpGetter();
constructor(private transactionService: TransactionService) { }
blockSync(): any {
const settings = new Settings(this.scan);
const provider = environment.web3Provider;
const readyStateElements = {
token: 1,
network: 2,
};
const readyStateElements = { network: 2 };
settings.w3.provider = provider;
settings.w3.engine = new Web3(provider);
settings.registry = new Registry(settings.w3.engine, environment.registryAddress, abi);
settings.txHelper = new TransactionHelper(settings.registry);
settings.registry = new CICRegistry(settings.w3.engine, environment.registryAddress, this.fileGetter,
['../../assets/js/block-sync/data']);
settings.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
settings.txHelper = new TransactionHelper(settings.w3.engine, settings.registry);
settings.txHelper.ontransfer = async (transaction: any): Promise<void> => {
window.dispatchEvent(this.newTransferEvent(transaction));
@ -35,12 +34,8 @@ export class BlockSyncService {
settings.txHelper.onconversion = async (transaction: any): Promise<any> => {
window.dispatchEvent(this.newConversionEvent(transaction));
};
settings.registry.ontokensload = (tokenCount: number): void => {
// console.debug('loaded tokens', tokenCount);
this.readyStateProcessor(settings, readyStateElements.token);
};
settings.registry.onregistryload = (addressReturned: number): void => {
// console.debug('loaded network contracts', addressReturned);
settings.registry.onload = (addressReturned: number): void => {
console.log('loaded network contracts', addressReturned);
this.readyStateProcessor(settings, readyStateElements.network);
};
@ -79,7 +74,7 @@ export class BlockSyncService {
}
async scan(settings, lo, hi, bloomBlockBytes, bloomBlocktxBytes, bloomRounds): Promise<void> {
const w = new Worker('./../assets/js/worker.js');
const w = new Worker('./../assets/js/block-sync/ondemand.js');
w.onmessage = (m) => {
settings.txHelper.processReceipt(m.data);
};
@ -114,14 +109,4 @@ export class BlockSyncService {
settings.scanFilter(settings, data.low, data.high, bOne, bTwo, data.filter_rounds);
});
}
headWorker(): void {
const wHeadSync = new Worker('./../assets/js/block-sync/head.js', {type: 'module'});
wHeadSync.onmessage = (m) => {
console.log(m.data);
};
wHeadSync.postMessage({
w3_provider: environment.web3Provider,
});
}
}

View File

@ -3,9 +3,8 @@ import {BehaviorSubject, Observable} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {environment} from '@src/environments/environment';
import {first} from 'rxjs/operators';
import {ArgPair, Envelope, Syncable} from '@src/assets/js/cic-meta/sync.js';
import {MutableKeyStore, MutablePgpKeyStore, PGPSigner, Signer} from '@app/_helpers';
import {User} from 'cic-client-meta';
import {ArgPair, Envelope, Syncable, User} from 'cic-client-meta';
@Injectable({
providedIn: 'root'
@ -64,8 +63,7 @@ export class UserService {
await this.updateMeta(syncableAccount, accountKey, this.headers);
}, async error => {
console.error('There is an error!', error);
const refName = accountKey + ':cic.person';
const syncableAccount: Syncable = new Syncable(refName, accountDetails);
const syncableAccount: Syncable = new Syncable(accountKey, accountDetails);
await this.updateMeta(syncableAccount, accountKey, this.headers);
});
return accountKey;

View File

@ -26,7 +26,6 @@ export class AppComponent implements OnInit {
}
ngOnInit(): void {
this.blockSyncService.headWorker();
this.mediaQuery.addListener(this.onResize);
this.onResize(this.mediaQuery);
this.queryAccountsIndex(20).then();

View File

@ -8,8 +8,7 @@ import {ActivatedRoute, Params, Router} from '@angular/router';
import {first} from 'rxjs/operators';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {CustomErrorStateMatcher} from '@app/_helpers';
import {User} from 'cic-client-meta';
import {Envelope} from '@src/assets/js/cic-meta/sync';
import {Envelope, User} from 'cic-client-meta';
@Component({
selector: 'app-account-details',

View File

@ -1,5 +1,5 @@
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {BlockSyncService, TransactionService} from '@app/_services';
import {TransactionService} from '@app/_services';
import {MatTableDataSource} from '@angular/material/table';
import {SelectionModel} from '@angular/cdk/collections';
import {MatPaginator} from '@angular/material/paginator';
@ -25,10 +25,7 @@ export class TransactionsComponent implements OnInit, AfterViewInit {
constructor(
private transactionService: TransactionService,
private blockSyncService: BlockSyncService
) {
this.blockSyncService.blockSync();
}
) { }
ngOnInit(): void {
this.transactionService.transactionsSubject.subscribe(transactions => {

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,6 @@ function sync_by_filter_block(block, count, buf, bloom_blocktx, result_callback)
}
function sync_by_filter(lo, hi, bloom_block, bloom_blocktx, tx_count_getter, result_callback) {
for (let i = lo; i <= hi; i++) {
let a = new ArrayBuffer(8);
let w = new DataView(a);
@ -33,7 +32,7 @@ function sync_by_filter(lo, hi, bloom_block, bloom_blocktx, tx_count_getter, res
sync_by_filter_block(i, n, a, bloom_blocktx, result_callback);
}).catch((e) => {
console.error('get count fail', e);
});;
});
}
});
}

View File

@ -1,199 +0,0 @@
import * as pgp from 'openpgp';
import * as crypto from 'crypto';
interface Signable {
digest(): string;
}
type KeyGetter = () => any;
type Signature = {
engine: string
algo: string
data: string
digest: string
};
interface Signer {
prepare(Signable): boolean;
onsign(Signature): void;
onverify(bool): void;
sign(digest: string): void;
verify(digest: string, signature: Signature): void;
fingerprint(): string;
}
interface Authoritative {
}
interface KeyStore {
getPrivateKey: KeyGetter;
getFingerprint: () => string;
getTrustedKeys: () => Array<any>;
getTrustedActiveKeys: () => Array<any>;
getEncryptKeys: () => Array<any>;
}
class PGPKeyStore implements KeyStore {
fingerprint: string;
pk: any;
pubk = {
active: [],
trusted: [],
encrypt: [],
};
loads = 0x00;
loadsTarget = 0x0f;
onload: (k: KeyStore) => void;
constructor(passphrase: string, pkArmor: string, pubkActiveArmor: string, pubkTrustedArmor: string, pubkEncryptArmor: string,
onload = (ks: KeyStore) => {
}) {
this._readKey(pkArmor, undefined, 1, passphrase);
this._readKey(pubkActiveArmor, 'active', 2);
this._readKey(pubkTrustedArmor, 'trusted', 4);
this._readKey(pubkEncryptArmor, 'encrypt', 8);
this.onload = onload;
}
private _readKey(a: string, x: any, n: number, pass?: string): void {
pgp.key.readArmored(a).then((k) => {
if (pass !== undefined) {
this.pk = k.keys[0];
this.pk.decrypt(pass).then(() => {
this.fingerprint = this.pk.getFingerprint();
console.log('private key (sign)', this.fingerprint);
this._registerLoad(n);
});
} else {
this.pubk[x] = k.keys;
k.keys.forEach((pubk) => {
console.log('public key (' + x + ')', pubk.getFingerprint());
});
this._registerLoad(n);
}
});
}
private _registerLoad(b: number): void {
this.loads |= b;
if (this.loads == this.loadsTarget) {
this.onload(this);
}
}
public getTrustedKeys(): Array<any> {
return this.pubk.trusted;
}
public getTrustedActiveKeys(): Array<any> {
return this.pubk.active;
}
public getEncryptKeys(): Array<any> {
return this.pubk.encrypt;
}
public getPrivateKey(): any {
return this.pk;
}
public getFingerprint(): string {
return this.fingerprint;
}
}
class PGPSigner implements Signer {
engine = 'pgp';
algo = 'sha256';
dgst: string;
signature: Signature;
keyStore: KeyStore;
onsign: (Signature) => void;
onverify: (bool) => void;
constructor(keyStore: KeyStore) {
this.keyStore = keyStore;
this.onsign = (string) => {
};
this.onverify = (boolean) => {
};
}
public fingerprint(): string {
return this.keyStore.getFingerprint();
}
public prepare(material: Signable): boolean {
this.dgst = material.digest();
return true;
}
public verify(digest: string, signature: Signature): void {
pgp.signature.readArmored(signature.data).then((s) => {
const opts = {
message: pgp.cleartext.fromText(digest),
publicKeys: this.keyStore.getTrustedKeys(),
signature: s,
};
pgp.verify(opts).then((v) => {
let i = 0;
for (i = 0; i < v.signatures.length; i++) {
const s = v.signatures[i];
if (s.valid) {
this.onverify(s);
return;
}
}
console.error('checked ' + i + ' signature(s) but none valid');
this.onverify(false);
});
}).catch((e) => {
console.error(e);
this.onverify(false);
});
}
public sign(digest: string): void {
const m = pgp.cleartext.fromText(digest);
const pk = this.keyStore.getPrivateKey();
const opts = {
message: m,
privateKeys: [pk],
detached: true,
};
pgp.sign(opts).then((s) => {
this.signature = {
engine: this.engine,
algo: this.algo,
data: s.signature,
// TODO: fix for browser later
digest: digest,
};
this.onsign(this.signature);
}).catch((e) => {
console.error(e);
this.onsign(undefined);
});
}
}
export {
Signature,
Authoritative,
Signer,
KeyGetter,
Signable,
KeyStore,
PGPSigner,
PGPKeyStore,
};

View File

@ -1,24 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.networkSpec = exports.cryptoSpec = exports.engineSpec = void 0;
var ENGINE_NAME = 'automerge';
var ENGINE_VERSION = '0.14.1';
var NETWORK_NAME = 'cic';
var NETWORK_VERSION = '1';
var CRYPTO_NAME = 'pgp';
var CRYPTO_VERSION = '2';
var engineSpec = {
name: ENGINE_NAME,
version: ENGINE_VERSION,
};
exports.engineSpec = engineSpec;
var cryptoSpec = {
name: CRYPTO_NAME,
version: CRYPTO_VERSION,
};
exports.cryptoSpec = cryptoSpec;
var networkSpec = {
name: NETWORK_NAME,
version: NETWORK_VERSION,
};
exports.networkSpec = networkSpec;

View File

@ -1,246 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Envelope = exports.ArgPair = exports.Syncable = void 0;
var Automerge = __importStar(require("automerge"));
var constants_1 = require("./constants");
var fullSpec = {
name: 'cic',
version: '1',
ext: {
network: constants_1.cryptoSpec,
engine: constants_1.engineSpec,
},
};
var Envelope = /** @class */ (function () {
function Envelope(payload) {
this.o = fullSpec;
this.set(payload);
}
Envelope.prototype.set = function (payload) {
this.o['payload'] = payload;
};
Envelope.prototype.get = function () {
return this.o['payload'];
};
Envelope.prototype.toJSON = function () {
return JSON.stringify(this.o);
};
Envelope.fromJSON = function (s) {
var e = new Envelope(undefined);
e.o = JSON.parse(s);
return e;
};
Envelope.prototype.unwrap = function () {
return Syncable.fromJSON(this.o['payload']);
};
return Envelope;
}());
exports.Envelope = Envelope;
var ArgPair = /** @class */ (function () {
function ArgPair(k, v) {
this.k = k;
this.v = v;
}
return ArgPair;
}());
exports.ArgPair = ArgPair;
var SignablePart = /** @class */ (function () {
function SignablePart(s) {
this.s = s;
}
SignablePart.prototype.digest = function () {
return this.s;
};
return SignablePart;
}());
function orderDict(src) {
var dst;
if (Array.isArray(src)) {
dst = [];
src.forEach(function (v) {
if (typeof (v) == 'object') {
v = orderDict(v);
}
dst.push(v);
});
}
else {
dst = {};
Object.keys(src).sort().forEach(function (k) {
var v = src[k];
if (typeof (v) == 'object') {
v = orderDict(v);
}
dst[k] = v;
});
}
return dst;
}
var Syncable = /** @class */ (function () {
// TODO: Move data to sub-object so timestamp, id, signature don't collide
function Syncable(id, v) {
this.id = id;
var o = {
'id': id,
'timestamp': Math.floor(Date.now() / 1000),
'data': v,
};
//this.m = Automerge.from(v)
this.m = Automerge.from(o);
}
Syncable.prototype.setSigner = function (signer) {
var _this = this;
this.signer = signer;
this.signer.onsign = function (s) {
_this.wrap(s);
};
};
// TODO: To keep integrity, the non-link key/value pairs for each step also need to be hashed
Syncable.prototype.digest = function () {
var links = [];
Automerge.getAllChanges(this.m).forEach(function (ch) {
var op = ch['ops'];
ch['ops'].forEach(function (op) {
if (op['action'] == 'link') {
//console.log('op link', op);
links.push([op['obj'], op['value']]);
}
});
});
//return JSON.stringify(links);
var j = JSON.stringify(links);
return Buffer.from(j).toString('base64');
};
Syncable.prototype.wrap = function (s) {
this.m = Automerge.change(this.m, 'sign', function (doc) {
doc['signature'] = s;
});
this.e = new Envelope(this.toJSON());
if (this.onwrap !== undefined) {
this.onwrap(this.e);
}
};
// private _verifyLoop(i:number, history:Array<any>, signable:Signable, result:boolean) {
// if (!result) {
// this.onauthenticate(false);
// return;
// } else if (history.length == 0) {
// this.onauthenticate(true);
// return;
// }
// const h = history.shift()
// if (i % 2 == 0) {
// i++;
// signable = {
// digest: () => {
// return Automerge.save(h.snapshot)
// },
// };
// this._verifyLoop(i, history, signable, true);
// } else {
// i++;
// const signature = h.snapshot['signature'];
// console.debug('signature', signature, signable.digest());
// this.signer.onverify = (v) => {
// this._verifyLoop(i, history, signable, v)
// }
// this.signer.verify(signable, signature);
// }
// }
//
// // TODO: This should replay the graph and check signatures on each step
// public _authenticate(full:boolean=false) {
// let h = Automerge.getHistory(this.m);
// h.forEach((m) => {
// //console.debug(m.snapshot);
// });
// const signable = {
// digest: () => { return '' },
// }
// if (!full) {
// h = h.slice(h.length-2);
// }
// this._verifyLoop(0, h, signable, true);
// }
Syncable.prototype.authenticate = function (full) {
var _this = this;
if (full === void 0) { full = false; }
if (full) {
console.warn('only doing shallow authentication for now, sorry');
}
//console.log('authenticating', signable.digest());
//console.log('signature', this.m.signature);
this.signer.onverify = function (v) {
//this._verifyLoop(i, history, signable, v)
_this.onauthenticate(v);
};
this.signer.verify(this.m.signature.digest, this.m.signature);
};
Syncable.prototype.sign = function () {
//this.signer.prepare(this);
this.signer.sign(this.digest());
};
Syncable.prototype.update = function (changes, changesDescription) {
this.m = Automerge.change(this.m, changesDescription, function (m) {
changes.forEach(function (c) {
var path = c.k.split('.');
var target = m['data'];
while (path.length > 1) {
var part = path.shift();
target = target[part];
}
target[path[0]] = c.v;
});
m['timestamp'] = Math.floor(Date.now() / 1000);
});
};
Syncable.prototype.replace = function (o, changesDescription) {
this.m = Automerge.change(this.m, changesDescription, function (m) {
Object.keys(o).forEach(function (k) {
m['data'][k] = o[k];
});
Object.keys(m).forEach(function (k) {
if (o[k] == undefined) {
delete m['data'][k];
}
});
m['timestamp'] = Math.floor(Date.now() / 1000);
});
};
Syncable.prototype.merge = function (s) {
this.m = Automerge.merge(s.m, this.m);
};
Syncable.prototype.toJSON = function () {
var s = Automerge.save(this.m);
var o = JSON.parse(s);
var oo = orderDict(o);
return JSON.stringify(oo);
};
Syncable.fromJSON = function (s) {
var doc = Automerge.load(s);
var y = new Syncable(doc['id'], {});
y.m = doc;
return y;
};
return Syncable;
}());
exports.Syncable = Syncable;

View File

@ -1 +0,0 @@
export { AccountRegistry } from './registry';

View File

@ -1,5 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountRegistry = void 0;
var registry_1 = require("./registry");
Object.defineProperty(exports, "AccountRegistry", { enumerable: true, get: function () { return registry_1.AccountRegistry; } });

View File

@ -1,10 +0,0 @@
declare class AccountRegistry {
contract: any;
signerAccount: any;
constructor(w3: any, abi: object, address: string, signerAddress?: string);
count(): Promise<number>;
have(address: string): Promise<boolean>;
last(n: number): Promise<Array<string>>;
add(address: string): Promise<boolean>;
}
export { AccountRegistry, };

View File

@ -1,109 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountRegistry = void 0;
var AccountRegistry = /** @class */ (function () {
function AccountRegistry(w3, abi, address, signerAddress) {
this.contract = new w3.eth.Contract(abi, address);
if (signerAddress) {
this.signerAccount = signerAddress;
}
else {
this.signerAccount = w3.eth.accounts[0];
}
}
AccountRegistry.prototype.count = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.contract.methods.count().call()];
});
});
};
AccountRegistry.prototype.have = function (address) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.contract.methods.accountsIndex(address).call()];
case 1: return [2 /*return*/, (_a.sent()) != 0];
}
});
});
};
AccountRegistry.prototype.last = function (n) {
return __awaiter(this, void 0, void 0, function () {
var c, lo, accounts, i, a;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.count()];
case 1:
c = _a.sent();
lo = c - n - 1;
if (lo < 0) {
lo = 0;
}
accounts = [];
i = c - 1;
_a.label = 2;
case 2:
if (!(i > lo)) return [3 /*break*/, 5];
return [4 /*yield*/, this.contract.methods.accounts(i).call()];
case 3:
a = _a.sent();
accounts.push(a);
_a.label = 4;
case 4:
i--;
return [3 /*break*/, 2];
case 5: return [2 /*return*/, accounts];
}
});
});
};
AccountRegistry.prototype.add = function (address) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.contract.methods.add(address).send({ from: this.signerAccount })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return AccountRegistry;
}());
exports.AccountRegistry = AccountRegistry;

View File

@ -1,165 +0,0 @@
let crypto = undefined;
(function() {
if (typeof module !== 'undefined' && typeof exports !== 'undefined') {
const nodeCrypto = require('crypto');
function hashWrapper(nodeCrypto, alg) {
this.alg = alg;
this.crypto = nodeCrypto.createHash(alg);
}
hashWrapper.prototype.update = function(d) {
this.crypto.update(d);
}
hashWrapper.prototype.digest = async function() {
const z = this.crypto.digest(this.data);
return new Uint8Array(z);
}
function cryptoWrapper(nodeCrypto) {
this.crypto = nodeCrypto
}
cryptoWrapper.prototype.createHash = function(alg) {
return new hashWrapper(this.crypto, alg);
}
module.exports = {
Bloom: Bloom,
fromBytes: fromBytes,
};
crypto = new cryptoWrapper(nodeCrypto);
} else {
function hashWrapper(webCrypto, alg) {
this.alg = alg;
this.crypto = webCrypto;
this.data = undefined;
}
hashWrapper.prototype.update = function(d) {
if (this.data != undefined) {
throw "cannot append";
}
this.data = d;
}
hashWrapper.prototype.digest = async function() {
const z = await this.crypto.subtle.digest('SHA-256', this.data);
return new Uint8Array(z);
}
function cryptoWrapper(webCrypto) {
this.crypto = webCrypto
}
cryptoWrapper.prototype.createHash = function(alg) {
return new hashWrapper(this.crypto, alg);
}
crypto = new cryptoWrapper(window.crypto);
window.Bloom = Bloom;
window.bloomFromBytes = fromBytes;
}
})()
// block numbers 6000000
// false positive probability 2%
//
// m = ceil((n * log(p)) / log(1 / pow(2, log(2))));
// m = ceil((6000000 * log(0.1)) / log(1 / pow(2, log(2))))
// = 3917675
// Creates a new bloom object.
// \param size of filter in bits, aligned to byte boundary
// \param number of rounds to hash
// \param hasher function, which must take two Uint8Array parameters 'data' and 'salt'. If not sef, hashBloomDefault will be used.
function Bloom(bits, rounds, hasher) {
this.bits = bits;
this.bytes = parseInt(bits / 8, 10);
this.rounds = rounds;
if (this.hasher === undefined) {
this.hasher = hashBloomDefault;
}
if (this.bytes * 8 != this.bits) {
console.error('number of bits must be on byte boundary');
return false;
} else {
this.filter = new Uint8Array(this.bytes);
}
}
// add entry to bloom filter
// \param value to add
Bloom.prototype.add = async function(v) {
let a = new ArrayBuffer(v.byteLength + 4);
let iw = new DataView(a);
for (let i = 0; i < v.byteLength; i++) {
iw.setUint8(i, v[i]);
}
//console.debug(iw, v);
for (var i = 0; i < this.rounds; i++) {
iw.setInt32(v.byteLength, i);
let result = await this.hasher(iw);
let resultHex = Array.prototype.map.call(new Uint8Array(result), x => ('00' + x.toString(16)).slice(-2)).join('');
let resultInt = parseInt(BigInt('0x'+resultHex) % BigInt(this.bits), 10);
let bytepos = parseInt(resultInt / 8, 10);
let bitpos = parseInt(resultInt, 10) % 8;
this.filter[bytepos] |= 1 << bitpos;
//console.log("setpos ", bytepos, bitpos);
}
};
// checks if the block number has been added to the bloom filter
// \param value to check for
// \return false if not found in filter
Bloom.prototype.check = async function(v) {
let a = new ArrayBuffer(v.byteLength + 4);
let iw = new DataView(a);
for (let i = 0; i < v.byteLength; i++) {
iw.setUint8(i, v[i]);
}
for (let j = 0; j < this.filter.byteLength; j++) {
if (v[3] == 20 && this.filter[j] > 0) {
// console.log('filter ', j, this.filter[j]);
}
}
for (let i = 0; i < this.rounds; i++) {
iw.setInt32(v.byteLength, i);
let result = await this.hasher(iw);
//console.log('result', result);
let resultHex = Array.prototype.map.call(new Uint8Array(result), x => ('00' + x.toString(16)).slice(-2)).join('');
let resultInt = parseInt(BigInt('0x'+resultHex) % BigInt(this.bits), 10);
let bytepos = parseInt(resultInt / 8, 10);
//console.log("setpos ", v, bytepos, resultInt % 8);
if (this.filter[bytepos] === undefined) {
// console.error('byte pos ' + bytepos + ' is undefined (filter length ' + this.filter.byteLength + ')');
return false;
} else {
let test = 1 << (0xff & (resultInt % 8));
if ((this.filter[bytepos] & test) == 0) {
return false;
}
}
}
return true;
};
// return the verbatim filter
// \return Uint8Array filter
Bloom.prototype.bytes = function() {
return this.filter;
};
// Default hashing function used in Bloom.add() - sha256
// \param data to insert in filter
// \param salt, typically a sequence number
// \return Uint8Array digest
async function hashBloomDefault(data, salt) {
const h = crypto.createHash('sha256');
h.update(data);
const z = await h.digest();
return Uint8Array.from(z);
}
function fromBytes(bytes, rounds, hasher) {
const bits = bytes.byteLength * 8;
let b = new Bloom(bits, rounds, hasher);
b.filter = bytes;
return b;
}

File diff suppressed because one or more lines are too long

View File

@ -1,30 +0,0 @@
function sync_by_filter_block(block, count, buf, bloom_blocktx, result_callback) {
for (let j = 0; j < count; j++) {
let w = new DataView(buf);
w.setInt32(4, j);
const r = new Uint8Array(buf);
bloom_blocktx.check(r).then(function(ok) {
if (ok) {
// console.debug('match in block' + block + ' tx ' + j);
result_callback(block, j);
}
});
}
}
function sync_by_filter(caller, lo, hi, bloom_block, bloom_blocktx, tx_count_getter, result_callback) {
for (let i = lo; i <= hi; i++) {
let a = new ArrayBuffer(8);
let w = new DataView(a);
w.setInt32(0, i);
const r = new Uint8Array(a.slice(0, 4));
bloom_block.check(r).then(function(ok) {
if (ok) {
// console.debug('match in block ' + i);
tx_count_getter(i).then(function(n) {
sync_by_filter_block(i, n, a, bloom_blocktx, result_callback);
});
}
});
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,63 +0,0 @@
let window = self;
importScripts('moolb.js');
importScripts('sync.js');
importScripts('web3.min.js');
let s = undefined;
// TODO: as worker has its own scope we don't need the object
function Driver(messager, provider, lo, filters, syncer) {
this.w3 = new Web3(provider);
this.lo = lo;
this.hi = lo;
this.filters = filters;
this.syncer = syncer;
this.messager = messager;
}
Driver.prototype.start = function(hi) {
let self = this;
if (hi !== undefined) {
self.sync(hi);
return;
}
s.w3.eth.getBlockNumber().then(function(n) {
self.sync(n);
});
};
Driver.prototype.sync = function(n) {
this.hi = n;
this.syncer(this, this.lo, this.hi, this.filters[0], this.filters[1], this.getCount, this.process);
};
Driver.prototype.process = function(b, t) {
s.w3.eth.getTransactionFromBlock(b, t).then((t) => {
s.w3.eth.getTransactionReceipt(t.hash).then((r) => {
this.postMessage(r);
});
}).catch(function(e) {
//this.postMessage(['failed getTransactionFromBlock(' + b + ', ' + t + ')']);
console.error('failed getTransactionFromBlock(' + b + ', ' + t + ')');
});
}
Driver.prototype.getCount = async function (b) {
const n = s.w3.eth.getBlockTransactionCount(b);
return n;
};
onmessage = function(o) {
const filters = [
bloomFromBytes(o.data.filters[0], o.data.filter_rounds),
bloomFromBytes(o.data.filters[1], o.data.filter_rounds),
];
s = new Driver(postMessage, o.data.w3_provider, o.data.lo, filters, sync_by_filter);
let hi = undefined;
if (o.data.hi > 0) {
hi = o.data.hi;
}
s.start(hi);
};

View File

@ -9,5 +9,6 @@ export const environment = {
cicUssdUrl: 'http://localhost:63315',
cicEthUrl: 'http://localhost:63314',
contractAddress: '0xd0097a901AF4ac2E63A5b6E86be8Ad91f10b05d7',
registryAddress: '0xf374d7B507767101a4bf3bA2a6B99AC737A44f6d'
registryAddress: '0xf374d7B507767101a4bf3bA2a6B99AC737A44f6d',
trustedDeclaratorAddress: '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'
};

View File

@ -13,7 +13,8 @@ export const environment = {
cicUssdUrl: 'http://localhost:63315',
cicEthUrl: 'http://localhost:63314',
contractAddress: '0xd0097a901AF4ac2E63A5b6E86be8Ad91f10b05d7',
registryAddress: '0xf374d7B507767101a4bf3bA2a6B99AC737A44f6d'
registryAddress: '0xf374d7B507767101a4bf3bA2a6B99AC737A44f6d',
trustedDeclaratorAddress: '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'
};
/*

View File

@ -18,6 +18,5 @@
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script async src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script async src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
<script async src="assets/js/openpgp.min.js"></script>
</body>
</html>