Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Web3 4x Upgrade #5393

Draft
wants to merge 475 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
475 commits
Select commit Hold shift + click to select a range
6228d20
keep track of unknown sources so we can display something useful in t…
eggplantzzz Mar 2, 2023
ef48764
add a couple of deps to useEffect callback to make React happy
eggplantzzz Mar 6, 2023
188e69f
add plumbing for keeping track of debugger breakpoints
eggplantzzz Mar 7, 2023
82784bb
add click handler on source lines to handle breakpoints and create Un…
eggplantzzz Mar 7, 2023
3eb9102
update UI when the user clicks on a line to set a breakpoint
eggplantzzz Mar 7, 2023
f05fabb
update debugger when setting breakpoints
eggplantzzz Mar 8, 2023
dc8f9bf
improve rendering of variables
eggplantzzz Mar 8, 2023
2e51b0d
update mantine packages to latest of version 5
eggplantzzz Mar 9, 2023
77451a9
WIP - work on the css for debugger view
eggplantzzz Mar 13, 2023
0484c02
when stepping, make content center in the scrollable container
eggplantzzz Mar 13, 2023
9dfd7c0
edit styles and component structure a little bit
eggplantzzz Mar 15, 2023
bc44b8f
start work on arranging for a way to set the current source manually
eggplantzzz Mar 16, 2023
a9224f1
move initDebugger into the utils folder
eggplantzzz Mar 16, 2023
86d2b11
use generic html element dom manipulation for jumping to source line
eggplantzzz Mar 17, 2023
ac2ef7d
remove unnecessary stuff from callback
eggplantzzz Mar 17, 2023
5b41b6d
correct bug with class construction and rename method
eggplantzzz Mar 17, 2023
dc30a91
create delete breakpoint method and use it in breakpoint section
eggplantzzz Mar 20, 2023
a962f40
give mouse pointer a hover state while over breakpoints
eggplantzzz Mar 21, 2023
e75b23a
add source text processing fully into the utils
eggplantzzz Mar 22, 2023
91eb328
add hacky method for fully supporting multiline comments
eggplantzzz Mar 22, 2023
3dd8981
update useEffects to better deal with autoscrolling as debugger steps
eggplantzzz Mar 22, 2023
4534f8f
optimize renders and add type predicate
eggplantzzz Mar 22, 2023
9aa2fa1
add some comments and pass etherscan api key to source-fetcher if it …
eggplantzzz Mar 29, 2023
adaa262
bump react-dom-router to ^6.10.0
eggplantzzz Mar 31, 2023
7576cb6
create simulate tx button and adjust some method signatures in sessio…
eggplantzzz Mar 31, 2023
4f9cc09
edit some css and fix a bug involving passing the provider
eggplantzzz Mar 31, 2023
5d4dd6e
add stack component, update useEffects, and start working on notifica…
eggplantzzz Apr 4, 2023
f99d8d4
rework layout leveraging mantine more
eggplantzzz Apr 7, 2023
208ad30
update html a bit and the scrolling algorithm
eggplantzzz Apr 12, 2023
ed7bf92
remove contracts module from dashboard
eggplantzzz Apr 12, 2023
2983502
dashboard: Debugger WIP
Feb 3, 2023
821be67
hack out the state for keeping track of sources and debugger session
eggplantzzz Feb 22, 2023
24d283a
get scroll working crudely and provide error message when tx hash not…
eggplantzzz Feb 27, 2023
dbb9fa5
add new inspect lib, create Variables component, and update operation…
eggplantzzz Mar 1, 2023
8a52dd2
only call scrollIntoView when the ref exists
eggplantzzz Mar 2, 2023
ec4fcf6
keep track of unknown sources so we can display something useful in t…
eggplantzzz Mar 2, 2023
801e124
add plumbing for keeping track of debugger breakpoints
eggplantzzz Mar 7, 2023
a7eeb6a
update debugger when setting breakpoints
eggplantzzz Mar 8, 2023
8150b38
WIP - work on the css for debugger view
eggplantzzz Mar 13, 2023
ed63127
when stepping, make content center in the scrollable container
eggplantzzz Mar 13, 2023
2c47057
start work on arranging for a way to set the current source manually
eggplantzzz Mar 16, 2023
4446d43
use generic html element dom manipulation for jumping to source line …
eggplantzzz Mar 17, 2023
b33dd95
create delete breakpoint method and use it in breakpoint section
eggplantzzz Mar 20, 2023
ada8f54
give mouse pointer a hover state while over breakpoints
eggplantzzz Mar 21, 2023
90429df
update useEffects to better deal with autoscrolling as debugger steps
eggplantzzz Mar 22, 2023
3fb2981
optimize renders
eggplantzzz Mar 22, 2023
d05f3ff
update html a bit, some styles, and the scrolling algorithm
eggplantzzz Apr 12, 2023
ac5e03f
keep werkin that design
eggplantzzz Apr 14, 2023
5258c8d
give individual panes nice, curvy corners and update stack
eggplantzzz Apr 14, 2023
da33613
update unknown source display, add more css, and try a different disp…
eggplantzzz Apr 17, 2023
0171537
update background color for uknown source in dark mode and update bre…
eggplantzzz Apr 17, 2023
937f8a3
reword message
eggplantzzz Apr 17, 2023
4b3ae70
set reasonable scroll amount
eggplantzzz Apr 17, 2023
3855ecd
refine breakpoint design
eggplantzzz Apr 18, 2023
d6d1a20
remove notification on error, text in header, and style header
eggplantzzz Apr 19, 2023
7ecbcef
move some css into component and tweak input stuff
eggplantzzz Apr 19, 2023
990e000
continue moving css to component files
eggplantzzz Apr 19, 2023
035dedc
move all debugger logic into the Debugger folder
eggplantzzz Apr 20, 2023
44a7ec0
add padding to breakpoints and tweak border radius for sources
eggplantzzz Apr 21, 2023
4bc185a
add component for displaying preparation progress
eggplantzzz Apr 21, 2023
ae4cae2
keep unknown addresses in the global state
eggplantzzz Apr 21, 2023
5ea5559
tighten up some more styling and add naive implementation of preparin…
eggplantzzz Apr 24, 2023
7836e68
rearrange some code and make active source tab a different color
eggplantzzz Apr 24, 2023
5db10f6
fix issue with debugger line numbering and breakpoint system
eggplantzzz Apr 24, 2023
232fa85
tweak colors for active/inactive tabs on sources
eggplantzzz Apr 25, 2023
0fae964
add tooltips to control buttons
eggplantzzz Apr 25, 2023
0d7efb6
add new inactive status for welcome page and add loading spinner
eggplantzzz Apr 25, 2023
d42346f
create home page for debugger and store etherscan api key in global s…
eggplantzzz Apr 26, 2023
0c5b193
use mantine hook for interacting with local storage and remove unnece…
eggplantzzz Apr 26, 2023
263a11e
tweak text for etherscan key and update styling
eggplantzzz Apr 26, 2023
d30653f
remove border from input
eggplantzzz Apr 26, 2023
d9ebf9c
further develop etherscan prompt
eggplantzzz Apr 26, 2023
2b900eb
adjust color of prompt container for dark mode
eggplantzzz Apr 26, 2023
22a5ba5
add background color change for active navbar item and update css for…
eggplantzzz Apr 27, 2023
af2922b
re-add disabled prop to nav buttons and make background color consist…
eggplantzzz Apr 27, 2023
725cda7
rework how ganache/provider options are passed through init functions
eggplantzzz Apr 27, 2023
f40df42
instead of passing provider, pass network id through init functions
eggplantzzz Apr 27, 2023
a452e50
group network id and etherscan key under one parameter named fetching…
eggplantzzz Apr 27, 2023
768b559
add simple error notification when there is an issue with debugger in…
eggplantzzz Apr 28, 2023
912fa71
slightly re-work design for tx signer dialogue
eggplantzzz Apr 28, 2023
812792a
add some more info to error notification
eggplantzzz Apr 28, 2023
50c67ea
tweak error notification design
eggplantzzz Apr 28, 2023
7253c0d
update etherscan message and tweak scrolling algorithm
eggplantzzz May 1, 2023
1dc0f2d
match active color for sidebar items to the bottom left button backgr…
eggplantzzz May 2, 2023
240fd52
hook up input field and use test tx hash as a backup
eggplantzzz May 2, 2023
c95282b
style to fix a bug where content went offscreen
eggplantzzz May 3, 2023
aa150e0
indent variable names in display
eggplantzzz May 3, 2023
08e0e8c
remove object-inspect from project and add fetch-and-compile to dashb…
eggplantzzz May 4, 2023
2c99384
use flex elements to alleviate weird scrolling issue and remove unnec…
eggplantzzz May 4, 2023
e3bf4d8
make another naive attempt at getting the stack information correct
eggplantzzz May 4, 2023
79b6d16
make tabs for sources scroll instead of stacking
eggplantzzz May 5, 2023
f87b41b
update ResultInspector to take options
eggplantzzz May 4, 2023
5e801eb
check to make sure an affected address is a contract and not an EOA
eggplantzzz May 5, 2023
8d660cf
save fetched compilations in the browser
eggplantzzz May 5, 2023
8a4d0a8
check to see if a session is loaded so a debugger session doesn't van…
eggplantzzz May 10, 2023
6bf8432
make block highlighting include whitespace at start of lines
eggplantzzz May 11, 2023
def7410
scroll only when debugger steps or current source changes
eggplantzzz May 11, 2023
aea3479
fix block highlighting issue
eggplantzzz May 11, 2023
322bf12
make continue until breakpoint button inactive until one is set
eggplantzzz May 11, 2023
eee78f3
Revert "fix block highlighting issue"
eggplantzzz May 12, 2023
98259e7
remove testing tx hashes
eggplantzzz May 12, 2023
c40ce67
disable submit button when no tx hash is in input and remove some css
eggplantzzz May 12, 2023
7f503cc
remove duplicate entries in dashboard package.json and update to curr…
eggplantzzz May 25, 2023
424d002
use vs code icons for debugger buttons
eggplantzzz May 26, 2023
4fcf7b0
improve block highlighting
eggplantzzz May 30, 2023
f59adcd
add some comments and correct property name
eggplantzzz Jun 1, 2023
9306afb
clean up some unnecessary code snippets
eggplantzzz Jun 1, 2023
3b3eb69
make some corrections based on react warnings
eggplantzzz Jun 1, 2023
4d31f7a
handle case when the source range has an undefined source id
eggplantzzz Jun 1, 2023
81bc2a0
highlight the line numbers on lines that have highlighting
eggplantzzz Jun 1, 2023
5eb54c7
make some refinements based on the design
eggplantzzz Jun 2, 2023
1e107c2
narrow error notification box, wrap text when too long, and remove im…
eggplantzzz Jun 5, 2023
d4a68dd
refine the etherscan api key message and move a line of code
eggplantzzz Jun 5, 2023
4539bda
adjust some types related to visual debugger state
eggplantzzz Jun 7, 2023
5bc2a1f
handle when the fetch request for source material is not ok
eggplantzzz Jun 8, 2023
a9d5502
clean up after rebase mistakes
eggplantzzz Jun 8, 2023
892f1d0
make Ganache fork the current block instead of 5 blocks behind the cu…
eggplantzzz Jun 9, 2023
ae08e9c
fix debug button that broke
eggplantzzz Jun 9, 2023
661d0cb
clean up another rebase mistake
eggplantzzz Jun 13, 2023
c4cd810
add emojis to the etherscan api key message
eggplantzzz Jun 13, 2023
53a62a0
make button icons larger
eggplantzzz Jun 13, 2023
116a7c7
add a check to make sure the source id is defined before setting
eggplantzzz Jun 13, 2023
3567359
limit ganache output in preparing screen to 6 lines
eggplantzzz Jun 14, 2023
7e2c88e
fix some spacing issues related to source material
eggplantzzz Jun 14, 2023
103f643
Use codec-components inside Dashboard Debugger
gnidan Jun 14, 2023
032c33a
dashboard: Import codec components styles
cliffoo Jun 14, 2023
6947fc1
complete html broken when we chop up the source code and use   f…
eggplantzzz Jun 20, 2023
546188b
separate source material into two panes: line number and source material
eggplantzzz Jun 21, 2023
e82fd48
remove some unnecessary imports, some unused libs, update some deps, …
eggplantzzz Jun 22, 2023
7c49879
Display variables in <ul> with <NameValuePair>
gnidan Jun 22, 2023
4af8dad
update preparing session message
eggplantzzz Jun 23, 2023
1d2afa9
add another step for preparation and put it in 'prep' mode earlier to…
eggplantzzz Jun 23, 2023
0c3d030
add comment about why we add highlighting tags at the end of html pro…
eggplantzzz Jun 26, 2023
39eb93c
add in hacky thing to deal with some instances of bad source maps
eggplantzzz Jun 26, 2023
2e455ed
update yarn.lock
eggplantzzz Jun 27, 2023
436c7d1
don't set breakpoints on source code but only the margin
eggplantzzz Jun 27, 2023
6bc63b8
make input responsive to enter key press
eggplantzzz Jun 29, 2023
3c01c3d
make syntax highlighting more Truffle-y
eggplantzzz Jul 5, 2023
8e2d2e7
bump ganache to 7.9.0 in dashboard and set some truffle deps to the c…
eggplantzzz Jul 6, 2023
8b38054
replace accidentally deleted dependency and update yarn.lock
eggplantzzz Jul 6, 2023
0d4eb17
dashboard: Improve contrast in debugger
cliffoo Jul 6, 2023
d1788b9
remove some unused styling
eggplantzzz Jul 7, 2023
674ae3b
get rid of border from mantine component
eggplantzzz Jul 7, 2023
015c057
remove argument from fetch and compile route
eggplantzzz Jul 7, 2023
780ec9b
set border-radius property properly
eggplantzzz Jul 7, 2023
ca529c9
remove unused styling classes
eggplantzzz Jul 7, 2023
5c8d20e
change name of button from 'SimulateTx' to 'Debug'
eggplantzzz Jul 7, 2023
9c63256
add type
eggplantzzz Jul 7, 2023
7d7e119
Update packages/dashboard/src/components/composed/Debugger/Variables.tsx
eggplantzzz Jul 7, 2023
26e5272
move etherscan api key name to constants
eggplantzzz Jul 7, 2023
345346b
cast window.ethereum as any to get rid of some ts-ignores
eggplantzzz Jul 7, 2023
cd85e97
get rid of unnecessary flex
eggplantzzz Jul 10, 2023
302d59f
Update packages/dashboard/src/components/composed/Debugger/PreparingS…
eggplantzzz Jul 10, 2023
38d82c5
remove unnecessary escapes
eggplantzzz Jul 10, 2023
cfb5e82
re-add flex
eggplantzzz Jul 10, 2023
d62e289
use constant
eggplantzzz Jul 10, 2023
5b992d1
move some styles into the component file and remove unused class
eggplantzzz Jul 10, 2023
5790e42
Update packages/dashboard/src/components/composed/Debugger/Sources/in…
eggplantzzz Jul 10, 2023
56f3652
change type of variable and get rid of some ts-ignores
eggplantzzz Jul 10, 2023
8f03e27
remove method that was replaced and never removed
eggplantzzz Jul 10, 2023
de87506
re-add hover state for inactive navbar tabs
eggplantzzz Jul 10, 2023
f5f704e
add two methods to session type and remove some ts-ignores
eggplantzzz Jul 11, 2023
f3407cf
use non-null assertion instead of conditional logic and use createSty…
eggplantzzz Jul 11, 2023
a252e2c
revert changes to the try in fetch-and-compile route
eggplantzzz Jul 11, 2023
93f9991
get rid of method
eggplantzzz Jul 11, 2023
4b27f79
correct type for operations
eggplantzzz Jul 11, 2023
4b50b1b
move string constants next to the others
eggplantzzz Jul 11, 2023
5853638
update mantine-related classes and add eslint ignore comment
eggplantzzz Jul 12, 2023
2edaf43
update one more mantine-related class and use empty string instead of…
eggplantzzz Jul 12, 2023
98febed
eslint ignore entire file, cast window.ethereum as any, and remove un…
eggplantzzz Jul 12, 2023
4738552
get rid of some unnecessary css stuff
eggplantzzz Jul 12, 2023
e3d9e67
change how highlighted class is stored in constants and update code u…
eggplantzzz Jul 12, 2023
f7db450
narrow the scope of the eslint ignore
eggplantzzz Jul 12, 2023
67d2df9
remove console.log
eggplantzzz Jul 12, 2023
66312c4
conditionally add tooltip to fix an issue where it won't disappear wh…
eggplantzzz Jul 12, 2023
173ff9d
re-work Variables component to store raw data in state and calculate …
eggplantzzz Jul 13, 2023
5fc03f7
store stack report data in state and use that for the render
eggplantzzz Jul 13, 2023
fed824d
dashboard: Fix debug button styles
cliffoo Jul 14, 2023
ad652e7
dashboard: Clean up ganache indexeddb on start
cliffoo Jul 14, 2023
8ed677d
Publish
eggplantzzz Jul 14, 2023
a29a32f
Bump word-wrap from 1.2.3 to 1.2.4
dependabot[bot] Jul 19, 2023
2ef6fb0
add a tooltip for the debug button in the tx signer for dashboard
eggplantzzz Jul 18, 2023
383b7b5
correct typo to etherscan message
eggplantzzz Jul 20, 2023
addd02f
use global state directly in components rather than passing them as p…
eggplantzzz Jul 19, 2023
6201d52
get rid of currentStep variable
eggplantzzz Jul 19, 2023
78825fa
move source range data into Sources component and make it state
eggplantzzz Jul 20, 2023
48513f5
Publish
eggplantzzz Jul 25, 2023
450c459
Add more networks to etherscan fetcher (including linea)
haltman-at Jul 26, 2023
b945e24
Update Solidity version in truffle init to 0.8.21
haltman-at Jul 26, 2023
b0fad97
Update solc dependencies to 0.8.21
haltman-at Jul 26, 2023
7bc3c9d
Update sourcify networks for sourcify 2.5.0
haltman-at Jul 27, 2023
c05cac6
Update debugger tests to 0.8.21; increase some timeouts
haltman-at Jul 26, 2023
a0ae578
Get Yul ASTs and work around id bug
haltman-at Jul 26, 2023
f9c1326
Allow getting source IDs from Yul ASTs
haltman-at Jul 26, 2023
a38df5d
Account for possibility of YulObject as top-level-node in debugger
haltman-at Jul 26, 2023
763ecd3
Add test of using Yul sources in debugger
haltman-at Jul 26, 2023
c2b13f2
Publish
haltman-at Aug 4, 2023
8d130c1
:art: Update references and add fixes
nazarhussain Aug 4, 2022
cea1936
:art: Fix the issues raised after merging base branch
nazarhussain Aug 4, 2022
4aa9ab1
:test_tube: Fix few failing tests"
nazarhussain Sep 15, 2022
339bbe3
Fix some issues
nazarhussain Dec 18, 2022
86c29ae
Changes in tests
nikoulai May 8, 2023
d5c6726
Unskip Project.contractInstances test
nikoulai May 10, 2023
888e956
Revert sha3 to keccak256
nikoulai May 10, 2023
00e843d
Add changes
nikoulai May 11, 2023
c1b4398
Add changes
nikoulai May 12, 2023
ae6f849
fix web3 upgrade multicall bug
mpetrunic Jun 2, 2023
84aee35
fix a test
Muhammad-Altabba Jul 24, 2023
3c06a64
fix some tests and add TODOs linked to issues
Muhammad-Altabba Jul 26, 2023
46d497a
un-skip a working test at packages/db
Muhammad-Altabba Jul 26, 2023
356fabc
fix tests at console.js inside core
Muhammad-Altabba Jul 26, 2023
f270888
un-skip running tests
Muhammad-Altabba Aug 1, 2023
13857f1
un-skip some tests and increase their timeouts
Muhammad-Altabba Aug 2, 2023
374b258
revert commenting some lines
Muhammad-Altabba Aug 9, 2023
4bf9d01
fix Quorum decodeParameters tests
Muhammad-Altabba Aug 11, 2023
d74a438
Merge branch 'nh/web3-4x-upgrade' into trufflesuite-egg/web3-upgrade
Muhammad-Altabba Aug 24, 2023
e455cd3
update yarn.lock
Muhammad-Altabba Aug 25, 2023
5fbd97d
Merge remote-tracking branch 'upstream/develop' into nh/web3-4x-upgrade
Muhammad-Altabba Aug 26, 2023
7ba2841
adding missed dependencies
Muhammad-Altabba Aug 26, 2023
4edc60e
update yarn.lock
Muhammad-Altabba Aug 26, 2023
08e1a59
add option to ignore node native modules while performing the depende…
eggplantzzz Sep 14, 2023
e879fa6
Merge remote-tracking branch 'upstream/master' into nh/web3-4x-upgrade
Muhammad-Altabba Sep 18, 2023
b76ebb6
update node versions in the CI
Muhammad-Altabba Sep 18, 2023
3b6da90
temporarily disable `git diff` at CI
Muhammad-Altabba Sep 18, 2023
40aada9
update node versions in the CI
Muhammad-Altabba Sep 18, 2023
df2447e
temporarily disable `git diff` at CI
Muhammad-Altabba Sep 18, 2023
fcfce6b
add back changes overridden when rebased
Muhammad-Altabba Sep 18, 2023
909acf7
try enable back `git diff` at CI
Muhammad-Altabba Sep 19, 2023
94f6a8d
fix a unit test for core console
Muhammad-Altabba Sep 19, 2023
6f1bfb8
increase timeout at some tests
Muhammad-Altabba Sep 19, 2023
6989d44
increase timeout at a test
Muhammad-Altabba Sep 19, 2023
7f65bf5
fix and un-skip tests at deployer
Muhammad-Altabba Sep 19, 2023
4f9f0e7
un-skip tests at provider
Muhammad-Altabba Sep 19, 2023
b858881
restore mocking files and empty lines at packages/truffle
Muhammad-Altabba Sep 20, 2023
2618ff7
restore mocking files and empty lines at packages/truffle
Muhammad-Altabba Sep 20, 2023
948ebc9
restore deleted files at resolver/test/fixtures
Muhammad-Altabba Sep 20, 2023
556812c
fix and un-skip tests at packages/resolver
Muhammad-Altabba Sep 20, 2023
3d9c450
un-skip passed test at packages/truffle
Muhammad-Altabba Sep 20, 2023
36abbd4
add a comment at a test and add modifiers at .sol file
Muhammad-Altabba Sep 20, 2023
4ace25c
set web3.js packages versions to `dev`
Muhammad-Altabba Sep 21, 2023
f8188f2
reject promiEvent on error
Muhammad-Altabba Sep 22, 2023
36f6591
allow sendTransaction and smart contract calls to process `options` p…
Muhammad-Altabba Sep 22, 2023
70250d8
resolve and un-skip issues: web3.js#6320 and web3.js#6317
Muhammad-Altabba Sep 22, 2023
a674046
remove web3-types from packages/contract
Muhammad-Altabba Sep 22, 2023
232be17
update dependencies
Muhammad-Altabba Sep 25, 2023
af140b2
fix and un-skip tests for events logs
Muhammad-Altabba Sep 26, 2023
4d25ae7
allow deploy to optionally accept transaction options
Muhammad-Altabba Sep 26, 2023
a66de71
resolve and un-skip issue: web3.js#6327
Muhammad-Altabba Sep 26, 2023
4a9c99f
modify for issue: web3.js#6345
Muhammad-Altabba Sep 26, 2023
df2a53a
remove comments related to issue: web3.js#6311
Muhammad-Altabba Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"private": true,
"scripts": {
"bootstrap": "yarn exec lerna bootstrap",
"build": "lerna run build --stream",
"docs": "lerna run docs --stream --concurrency=1",
"prepare": "lerna run prepare --stream --concurrency=1 && husky install && yarn docs",
"publish-release": "./scripts/publish-release.sh",
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"change-case": "3.0.2",
"fast-check": "3.1.1",
"web3-utils": "1.10.0"
"web3-utils": "4.0.5"
},
"devDependencies": {
"@fast-check/jest": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/artifactor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"tmp": "^0.2.1",
"ts-node": "10.7.0",
"typescript": "^4.9.5",
"web3": "1.10.0"
"web3": "4.1.1"
},
"publishConfig": {
"access": "public"
Expand Down
144 changes: 82 additions & 62 deletions packages/artifactor/test/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Config = require("@truffle/config");
const requireNoCache = require("require-nocache")(module);
const { Compile } = require("@truffle/compile-solidity");
const Ganache = require("ganache");
const Web3 = require("web3");
const { Web3 } = require("web3");
const { Shims } = require("@truffle/compile-common");
const tmp = require("tmp");
tmp.setGracefulCleanup();
Expand All @@ -20,8 +20,8 @@ describe("artifactor + require", () => {
instamine: "strict"
}
});
const web3 = new Web3();
web3.setProvider(provider);

const web3 = new Web3(provider);

before(() => web3.eth.net.getId().then(id => (networkID = id)));

Expand Down Expand Up @@ -138,7 +138,9 @@ describe("artifactor + require", () => {
})
.then(done)
.catch(done);
});
// TODO: investigate why timeout needed to be increased
// issue: https://github.com/web3/web3.js/issues/6311
}).timeout(3000);

it("shouldn't synchronize constant functions", done => {
let example;
Expand Down Expand Up @@ -186,42 +188,66 @@ describe("artifactor + require", () => {
})
.then(done)
.catch(done);
});

it("should return transaction hash, logs and receipt when using synchronised transactions", done => {
let example = null;
Example.new("1", { gas: 3141592 })
.then(instance => {
example = instance;
return example.triggerEvent();
})
.then(({ tx, logs, receipt }) => {
assert.isDefined(tx, "transaction hash wasn't returned");
assert.isDefined(
logs,
"synchronized transaction didn't return any logs"
);
assert.isDefined(
receipt,
"synchronized transaction didn't return a receipt"
);
assert.isOk(tx.length > 42, "Unexpected transaction hash"); // There has to be a better way to do this.
assert.equal(
tx,
receipt.transactionHash,
"Transaction had different hash than receipt"
);
assert.equal(logs.length, 1, "logs array expected to be 1");

const log = logs[0];

assert.equal("ExampleEvent", log.event);
assert.equal(accounts[0], log.args._from);
assert.equal(8, log.args.num); // 8 is a magic number inside Example.sol
})
.then(done)
.catch(done);
});
// TODO: investigate why timeout needed to be increased
// issue: https://github.com/web3/web3.js/issues/6311
}).timeout(3000);

// TODO: un-skip the test to investigate the error:
// "AssertionError: expected 'ExampleEvent' to equal undefined"
// The issue seems to be that the returned logs are not of an event.
// (The returned log does not include the properties: `event` and `args`)
// logs: [
// {
// address: '0x608fcae953f6ecbb979bd670260fea9052a7e527',
// blockHash: '0x3a5f39352e0fd37c6a0b7870b16d585a10dde1fec30b0e1b64b6065caef5469a',
// blockNumber: 2n,
// logIndex: 0n,
// removed: false,
// transactionHash: '0xd9ad9f8a3d74c8bad000249977ec60d8313b2e4bbc389de06709a45cd5e0cb31',
// transactionIndex: 0n
// }
// ]
//
// issue: https://github.com/web3/web3.js/issues/6312
it.skip(
"should return transaction hash, logs and receipt when using synchronised transactions",
async done => {
let example = null;
Example.new("1", { gas: 3141592 })
.then(instance => {
example = instance;
return example.triggerEvent();
})
.then(({ tx, logs, receipt }) => {
assert.isDefined(tx, "transaction hash wasn't returned");
assert.isDefined(
logs,
"synchronized transaction didn't return any logs"
);
assert.isDefined(
receipt,
"synchronized transaction didn't return a receipt"
);
assert.isOk(tx.length > 42, "Unexpected transaction hash"); // There has to be a better way to do this.
assert.equal(
tx,
receipt.transactionHash,
"Transaction had different hash than receipt"
);
assert.equal(logs.length, 1, "logs array expected to be 1");

const log = logs[0];

assert.equal("ExampleEvent", log.event);
assert.equal(accounts[0], log.args._from);
assert.equal(8, log.args.num); // 8 is a magic number inside Example.sol
})
.then(done)
.catch(done);
// TODO: investigate why timeout needed to be increased
// issue: https://github.com/web3/web3.js/issues/6311
}
).timeout(3000);

it("should trigger the fallback function when calling sendTransaction()", () => {
let example = null;
Expand All @@ -239,19 +265,16 @@ describe("artifactor + require", () => {
value: web3.utils.toWei("1", "ether")
});
})
.then(
() =>
new Promise((accept, reject) =>
web3.eth.getBalance(example.address, (err, balance) => {
if (err) return reject(err);
accept(balance);
})
)
)
.then(() => web3.eth.getBalance(example.address))
.then(balance => {
assert(balance === web3.utils.toWei("1", "ether"));
assert(
balance.toString() === web3.utils.toWei("1", "ether"),
"1 ether has been sent but the balance does not match that"
);
});
});
// TODO: investigate why timeout needed to be increased
// issue: https://github.com/web3/web3.js/issues/6311
}).timeout(3000);

it("should trigger the fallback function when calling send() (shorthand notation)", () => {
let example = null;
Expand All @@ -267,19 +290,16 @@ describe("artifactor + require", () => {
);
return example.send(web3.utils.toWei("1", "ether"));
})
.then(
() =>
new Promise((accept, reject) =>
web3.eth.getBalance(example.address, (err, balance) => {
if (err) return reject(err);
accept(balance);
})
)
)
.then(() => web3.eth.getBalance(example.address))
.then(balance => {
assert(balance === web3.utils.toWei("1", "ether"));
assert(
balance.toString() === web3.utils.toWei("1", "ether"),
"1 ether has been sent but the balance does not match that"
);
});
});
// TODO: investigate why timeout needed to be increased
// issue: https://github.com/web3/web3.js/issues/6311
}).timeout(3000);

it("errors when setting an invalid provider", done => {
try {
Expand Down
6 changes: 0 additions & 6 deletions packages/artifactor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
"lib": [
"es2019"
],
"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
]
},
"rootDir": ".",
"types": ["node", "mocha"]
},
Expand Down
112 changes: 60 additions & 52 deletions packages/blockchain-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
import type { Provider, Callback, JsonRPCResponse } from "web3/providers";
import type {
Block,
HexString,
Web3BaseProvider as Provider,
Web3ProviderRequestCallback as Callback
} from "web3-types";
import type { parsedUriObject } from "typings";

const Blockchain = {
type BlockChainType = {
getBlockByNumber(
blockNumber: string,
provider: Provider,
callback: Callback<JsonRPCResponse>
callback: Callback<Block>
): void;
getBlockByHash(
blockHash: string,
provider: Provider,
callback: Callback<Block>
): void;
parse(uri: string): parsedUriObject;
asURI(provider: Provider): Promise<unknown>;
matches(uri: string, provider: Provider): Promise<unknown>;
};

const Blockchain: BlockChainType = {
getBlockByNumber(
blockNumber: string,
provider: Provider,
callback: Callback<Block>
) {
const params = [blockNumber, true];
const params: [string, boolean] = [blockNumber, true];
provider.send(
{
jsonrpc: "2.0",
Expand All @@ -22,9 +43,9 @@ const Blockchain = {
getBlockByHash(
blockHash: string,
provider: Provider,
callback: Callback<JsonRPCResponse>
callback: Callback<Block>
) {
const params = [blockHash, true];
const params: [string, boolean] = [blockHash, true];
provider.send(
{
jsonrpc: "2.0",
Expand All @@ -50,66 +71,53 @@ const Blockchain = {
return parsed;
},

asURI(provider: Provider) {
asURI(this: BlockChainType, provider: Provider) {
return new Promise((resolve, reject) => {
let genesis: any, latest;

this.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRPCResponse) => {
this.getBlockByNumber("0x0", provider, (err: Error, { result }) => {
if (err) return reject(err);
genesis = result;

this.getBlockByNumber("latest", provider, (err: Error, { result }) => {
if (err) return reject(err);
genesis = result;

this.getBlockByNumber(
"latest",
provider,
(err: Error, { result }: JsonRPCResponse) => {
if (err) return reject(err);
latest = result;
const url = `blockchain://${genesis.hash.replace(
"0x",
""
)}/block/${latest.hash.replace("0x", "")}`;
resolve(url);
}
);
}
);
latest = result;
const url = `blockchain://${genesis.hash.replace("0x", "")}/block/${(
latest.hash as HexString
).replace("0x", "")}`;
resolve(url);
});
});
});
},

matches(uri: string, provider: Provider) {
matches(this: BlockChainType, uri: string, provider: Provider) {
return new Promise((resolve, reject) => {
const parsedUri = this.parse(uri);

const expectedGenesis = parsedUri.genesis_hash;
const expectedBlock = parsedUri.block_hash;

this.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRPCResponse) => {
if (err) return reject(err);
const block = result;
if (block.hash !== expectedGenesis) return resolve(false);

this.getBlockByHash(
expectedBlock,
provider,
(err: Error, { result }: JsonRPCResponse) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
const block = result;
if (err || block == null) {
return resolve(false);
}

resolve(true);
this.getBlockByNumber("0x0", provider, (err: Error, { result }) => {
if (err) return reject(err);
const block = result;
if (block.hash !== expectedGenesis) return resolve(false);

this.getBlockByHash(
expectedBlock,
provider,
(err: Error, { result }) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
const block = result;
if (err || block == null) {
return resolve(false);
}
);
}
);

resolve(true);
}
);
});
});
}
};
Expand Down
4 changes: 3 additions & 1 deletion packages/blockchain-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"test": "mocha --exit -r ts-node/register test/**/*.test.ts"
},
"types": "./typings/index.d.ts",
"dependencies": {
"web3-types": "^1.1.1"
},
"devDependencies": {
"@types/assert": "^1.4.2",
"@types/mocha": "^5.2.7",
"@types/node": "~12.12.0",
"@types/web3": "1.0.20",
"mocha": "10.1.0",
"ts-node": "10.7.0",
"typescript": "^4.9.5"
Expand Down
Loading
Loading