Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
bd06f74
Update config.json with new graphqlAPIURL for each network.
kirilligum Jan 25, 2024
9bc12de
Add SendInstruction component and update App layout.
kirilligum Jan 26, 2024
c244a05
Add contract ABIs and script to generate them.
kirilligum Jan 26, 2024
61e66b1
(no commit message provided)
kirilligum Jan 26, 2024
a55b057
Add TrustAndTeach and IInputBox ABIs and remove console log for contr…
kirilligum Jan 27, 2024
fe5823d
Add Interact component for interacting with the TrustAndTeach contract.
kirilligum Jan 27, 2024
28e61c1
Add contract address as a variable and use it in the contract instant…
kirilligum Jan 29, 2024
27e5d7d
Add inputString state and remove unnecessary comments and code.
kirilligum Jan 29, 2024
f8c55b8
Refactor SendInstruction component to Interact component and update p…
kirilligum Jan 29, 2024
b06a208
Add InteractionForm and SendCurlRequestButton components to Interact.
kirilligum Jan 29, 2024
564c02d
Add interaction form and old method for sending instructions.
kirilligum Jan 29, 2024
4e81afa
Set contract address state and input field in App component.
kirilligum Jan 29, 2024
8a755d2
Create InteractionForm component for interacting with Ethereum smart …
kirilligum Jan 29, 2024
22a0d02
Add SendCurlRequestButton component for sending curl requests.
kirilligum Jan 29, 2024
0af4bb7
Refactor Interact component to accept dappAddress and update Interact…
kirilligum Jan 29, 2024
105650a
aider: Added defaultInputUint256 to `src/InteractionForm.tsx` and upd…
kirilligum Feb 1, 2024
84b19af
aider: Fix the issue with `setInputUint256` missing in `src/Interacti…
kirilligum Feb 1, 2024
0fb1a4c
Remove duplicate transaction sent message in InteractionForm component.
kirilligum Feb 1, 2024
76389f1
aider: To fix the issue where the number input doesn't change in `src…
kirilligum Feb 1, 2024
6d430a0
aider: Modify `contractFunction` to take a third argument when `defau…
kirilligum Feb 1, 2024
07060e5
aider: Modified the `handleSubmit` function to correctly handle the B…
kirilligum Feb 1, 2024
b611327
Refactor contract function call to handle optional third argument.
kirilligum Feb 1, 2024
8bf95b4
aider: Fixed syntax error in `src/InteractionForm.tsx` by adding pare…
kirilligum Feb 1, 2024
c54e350
Add logging for successful transactions with transaction hash.
kirilligum Feb 1, 2024
c402461
Refactor Interact component to handle uint256 input correctly.
kirilligum Feb 1, 2024
d4a4d92
Fix contract function call with inputUint256 parameter.
kirilligum Feb 1, 2024
6255461
(no commit message provided)
kirilligum Feb 1, 2024
9dd212c
Refactored Interact and InteractionForm components to use interface p…
kirilligum Feb 1, 2024
3a87fa0
Add llmSteps parameter to sendInstructionPrompt and cartesiSubmitProm…
kirilligum Feb 1, 2024
0c8beeb
Add contract_rw_depexec.fish script for testing Cartesi voucher and i…
kirilligum Feb 1, 2024
81d6644
aider: Renamed defaultInputString to defaultInput01 and defaultInputU…
kirilligum Feb 1, 2024
17d977f
aider: Refactored the `src/Interact.tsx` and `src/InteractionForm.tsx…
kirilligum Feb 2, 2024
98c7836
aider: Modify `src/InteractionForm.tsx` to handle any number of inputs.
kirilligum Feb 2, 2024
429da25
Update default input description in InteractionForm component.
kirilligum Feb 2, 2024
d24a43f
aider: The `defaultInputs` in `src/Interact.tsx` and `src/Interaction…
kirilligum Feb 2, 2024
439a725
aider: The `contractFunction` calls in `src/Interact.tsx` now extract…
kirilligum Feb 2, 2024
2495b77
aider: The form elements and the submit button now appear on the same…
kirilligum Feb 2, 2024
018d0e7
aider: Remove the `alignSelf: 'stretch'` style from the button in `sr…
kirilligum Feb 2, 2024
30ddd9e
aider: Position the button at the bottom of the row.
kirilligum Feb 2, 2024
e169d33
Removed unused code and updated default input value for 'llmSteps' to…
kirilligum Feb 2, 2024
d4fda1f
aider: Added interaction for `announcePromptResponse` in `src/Interac…
kirilligum Feb 2, 2024
4fc2b45
aider: Added interaction for `getPromptByConversationId` in `src/Inte…
kirilligum Feb 2, 2024
6f8f7ca
Set default value for conversationId input to "0" in Interact component.
kirilligum Feb 2, 2024
15eb854
aider: Added interaction for getting prompt by conversation ID in `sr…
kirilligum Feb 2, 2024
52cd769
aider: Modify `src/InteractionForm.tsx` and `src/InteractionForm.tsx`…
kirilligum Feb 2, 2024
41b78d2
Remove InteractionForm for getting prompt by Conversation ID.
kirilligum Feb 2, 2024
d308f20
aider: Add isReadCall as an optional argument to InteractionForm in s…
kirilligum Feb 2, 2024
3da81cf
Remove duplicate isReadCall property in InteractionForm component.
kirilligum Feb 2, 2024
a6b69f8
aider: Display the output for read calls in `src/InteractionForm.tsx`.
kirilligum Feb 2, 2024
710f897
aider: Added interaction form for "Get Conversation by ID" in `src/In…
kirilligum Feb 2, 2024
51b8d0f
aider: Added interaction for "Get Conversation Response Count" in `sr…
kirilligum Feb 2, 2024
ecffd6d
aider: To address the issue with `getConversationResponseCount` retur…
kirilligum Feb 2, 2024
bb5644a
aider: Fixed TypeScript error TS7006 by explicitly typing 'result' as…
kirilligum Feb 2, 2024
591da49
aider: To convert the results from `getConversationById` to human-rea…
kirilligum Feb 2, 2024
2198df2
aider: Added interaction form for "Get Conversation Response by Index…
kirilligum Feb 2, 2024
573938e
Set default values for conversationId, iResponse, and iSplitResponse …
kirilligum Feb 2, 2024
05ece43
Set default input values to "0" for certain interaction forms.
kirilligum Feb 2, 2024
3b6f026
aider: Added interaction for submitting ranks in `src/Interact.tsx`.
kirilligum Feb 2, 2024
a796a58
Set default value for conversationId to "0" in Interact component.
kirilligum Feb 2, 2024
c31622a
aider: Added interaction for "Get Users Who Submitted Ranks" in `src/…
kirilligum Feb 2, 2024
d595a38
Refactor input field interfaces to use "I" prefix for consistency.
kirilligum Feb 2, 2024
83682d2
aider: Added type correctness to all contractFunction calls in Intera…
kirilligum Feb 2, 2024
1845e3b
aider: Implementing `getRankByUserAtIndex` in `src/Interact.tsx`.
kirilligum Feb 2, 2024
a5ff908
aider: Added "Get Conversation Response Length" interaction to `src/I…
kirilligum Feb 2, 2024
655cc4f
aider: Added interaction form for "Get Ranks By User" in `src/Interac…
kirilligum Feb 2, 2024
9dccd08
aider: Set the user address default value to the address of the curre…
kirilligum Feb 2, 2024
cdbce4d
Add useWallets hook to Interact component and set default value for u…
kirilligum Feb 3, 2024
902510b
aider: `src/InteractionForm.tsx` changed defaultInputs and set the ne…
kirilligum Feb 3, 2024
cea01aa
Refactored Interact component to use a separate state for dappAddress…
kirilligum Feb 3, 2024
30246ed
aider: Updated setDappAddress to the value from setInteractionInputsD…
kirilligum Feb 3, 2024
467986d
aider: Import useEffect from react in Interact.tsx to fix TS2304 error.
kirilligum Feb 3, 2024
d11f80d
Remove Dapp Address input and interaction form description from Inter…
kirilligum Feb 3, 2024
dd9d8c7
Add interactive elements for submitting, ranking, and dumping respons…
kirilligum Feb 9, 2024
0098c32
aider: Added new methods for interacting with the trust-and-teach con…
kirilligum Feb 9, 2024
bebf1d8
aider: Added interaction form for "Get Conversation Count" method in …
kirilligum Feb 9, 2024
0a34f61
Refactored App component to use SimpleInteract and updated comments.
kirilligum Feb 10, 2024
85d40b4
aider: Added a button to toggle the visibility of the `Interact` comp…
kirilligum Feb 10, 2024
8aa40c7
(no commit message provided)
kirilligum Feb 11, 2024
a495211
aider: Added functionality to download JSON data combining all conver…
kirilligum Feb 12, 2024
8e26a06
aider: Explicitly type the 'user' parameter as a string in the map fu…
kirilligum Feb 12, 2024
f6b391d
aider: Displayed a table with conversation details and responses base…
kirilligum Feb 12, 2024
87d4c1e
aider: Change the name of h3 tag from "Conversations" to "RLHF Data f…
kirilligum Feb 12, 2024
5684255
aider: Added functionality to download the "RLHF Data for DPO" table …
kirilligum Feb 12, 2024
edde900
Change download file format from TSV to CSV.
kirilligum Feb 12, 2024
6f6e6bc
aider: Added button to download the "RLHF Data for DPO" table as JSON.
kirilligum Feb 12, 2024
eb1d1fd
aider: Refactored `downloadRLHFDataAsTSV`, `downloadTableDataAsJSON`,…
kirilligum Feb 12, 2024
94571ac
aider: Fix accessing undefined properties in generateConversationData…
kirilligum Feb 12, 2024
b775e4c
Added download buttons for table data in SimpleInteract component.
kirilligum Feb 12, 2024
ea2e6d9
aider: Show only the first 3 rows of the table by default and add a b…
kirilligum Feb 12, 2024
5e4cdae
aider: Added manual and automatic data refresh mechanisms for ensurin…
kirilligum Feb 12, 2024
0024371
aider: Refactored code to use async function within useEffect for cor…
kirilligum Feb 12, 2024
df03d96
aider: Added manual refresh button and encapsulated data fetching log…
kirilligum Feb 12, 2024
a925dad
aider: Move the refresh button for conversations to the "RLHF Data fo…
kirilligum Feb 12, 2024
dd48162
Update conversation refresh interval to 3 seconds instead of 30 seconds.
kirilligum Feb 12, 2024
81d91b2
Added functionality to hide and show instructions in the SimpleIntera…
kirilligum Feb 12, 2024
ee53624
aider: Reverse the order of the rows in the table body by applying th…
kirilligum Feb 12, 2024
907d322
Update SendCurlRequestButton to use buttonText prop for button label.
kirilligum Feb 12, 2024
ccc8db5
Fix incorrect order of operations in generating conversation data.
kirilligum Feb 12, 2024
c9dc4bf
Added dynamic button text to SendCurlRequestButton component.
kirilligum Feb 12, 2024
c54eaec
Update RLHF data instructions to clarify N/A meaning.
kirilligum Feb 12, 2024
66d4118
aider: Set the default conversationId parameter to be the latest conv…
kirilligum Feb 12, 2024
affe6c1
Added logging of conversations length and content.
kirilligum Feb 12, 2024
5967dc6
aider: Updated InteractionForm to set inputs based on defaultInputs p…
kirilligum Feb 12, 2024
c2058f3
Add useEffect hook to InteractionForm component.
kirilligum Feb 12, 2024
08acaba
aider: Fixed the issue where input values in `InteractionForm` compon…
kirilligum Feb 12, 2024
6f3c2f7
Updated default input value for getting conversation by ID to a fixed…
kirilligum Feb 12, 2024
3be507c
aider: Add column to display users who submitted ranks in the table.
kirilligum Feb 12, 2024
ef063d9
aider: Refactored `generateConversationData` to display each user's r…
kirilligum Feb 12, 2024
42a89d6
aider: Resolved TypeScript errors by explicitly defining types for va…
kirilligum Feb 12, 2024
473c5df
Added back the IConversationData interface to SimpleInteract component.
kirilligum Feb 12, 2024
89022f1
aider: Adjust logic to display rows for users with no ranks in `gener…
kirilligum Feb 12, 2024
a6c3a67
Removed duplicate column header in SimpleInteract component.
kirilligum Feb 12, 2024
5a25666
Shorten user addresses in SimpleInteract component.
kirilligum Feb 12, 2024
2dc1c36
aider: Modify `generateConversationData` to conditionally format user…
kirilligum Feb 12, 2024
47a2e19
Update table headers in SimpleInteract component.
kirilligum Feb 12, 2024
ee9a35e
aider: Add new column to table "Action" with buttons for confirming a…
kirilligum Feb 12, 2024
70afc21
Added functionality to submit ranks and updated table column headers.
kirilligum Feb 12, 2024
e2723d5
aider: Display signer's address in bold when there are responses but …
kirilligum Feb 12, 2024
0fd92c0
aider: Fix the rendering of `<b>` tags by conditionally applying bold…
kirilligum Feb 12, 2024
d58786a
aider: Resolved compilation errors by defining the `UserDisplay` comp…
kirilligum Feb 12, 2024
6bdbb15
Refactored UserDisplay component to directly render bold user if needed.
kirilligum Feb 12, 2024
de37dee
aider: Render the `usersWhoSubmittedRanks` content as HTML to interpr…
kirilligum Feb 12, 2024
c3938fc
aider: Created AddressDisplay component to safely render user address…
kirilligum Feb 12, 2024
53457ff
Add AddressDisplay component and remove duplicate import.
kirilligum Feb 12, 2024
4b92bb3
aider: Replaced 'formattedUser' with 'AddressDisplay' components for …
kirilligum Feb 12, 2024
5bc5397
Refactor mapping function in SimpleInteract component to include type…
kirilligum Feb 12, 2024
23aa495
Deleted AddressDisplay component and updated user address formatting …
kirilligum Feb 12, 2024
a2c0050
Update usersWhoSubmittedRanks to be of type JSX.Element and format us…
kirilligum Feb 12, 2024
c263bdc
Refactor user address formatting logic in SimpleInteract component.
kirilligum Feb 12, 2024
fd2c3d3
Removed unused InteractionForm components for ranking responses in Si…
kirilligum Feb 13, 2024
6b9ce9b
Added VoucherButtons component and replaced button with VoucherButton…
kirilligum Feb 13, 2024
924f124
Created VoucherButtons component for handling vouchers.
kirilligum Feb 13, 2024
f6c628b
Refactored VoucherButtons component to accept conversationId and resp…
kirilligum Feb 14, 2024
fbf1370
Refactored voucher fetching logic and added preference actions based …
kirilligum Feb 14, 2024
642ef07
aider: Ensure calling refreshConversations triggers reload in Voucher…
kirilligum Feb 14, 2024
5cead9c
aider: Fixed type error and props usage in VoucherButtons component.
kirilligum Feb 14, 2024
07fe529
aider: Resolved compilation errors by fixing prop type mismatch and r…
kirilligum Feb 14, 2024
872941c
aider: Removed problematic usage of `VoucherButtons` component in `Si…
kirilligum Feb 14, 2024
91a2973
aider: Add reloadVouchers prop to VoucherButtons calls in SimpleInter…
kirilligum Feb 14, 2024
d5638c7
Refactored button text and added comments for reload function.
kirilligum Feb 14, 2024
f6b7acc
Remove commented out console log statement.
kirilligum Feb 14, 2024
a8be256
aider: Created a new component `NoticeResponse` to display responses …
kirilligum Feb 14, 2024
a394dd8
Refactored components to use `useNoticeQuery` and display notice payl…
kirilligum Feb 15, 2024
541df53
aider: Update console log in `src/NoticeResponse.tsx` to output only …
kirilligum Feb 15, 2024
0cb96df
Refactored NoticeResponse and SimpleInteract components to allow relo…
kirilligum Feb 15, 2024
7cbe899
Updated UI elements and text in SimpleInteract component.
kirilligum Feb 15, 2024
2ed1752
Refactored reload functions and passed specific references to Voucher…
kirilligum Feb 15, 2024
fdfd758
Added wallet connection and chain switching functionality.
kirilligum Feb 15, 2024
ef3c71b
Added functionality to show full addresses and updated button labels …
kirilligum Feb 17, 2024
c1ab1b9
Update the model name in the instructions for generating tokens.
kirilligum Feb 17, 2024
80dc0ac
aider: Instructions text color set to blue by applying inline styles.
kirilligum Feb 17, 2024
ea17fe5
Fix style issue in SimpleInteract component.
kirilligum Feb 17, 2024
0a5d7cb
Added functionality to display and interact with generated responses …
kirilligum Feb 17, 2024
c26df85
Updated input field description and download instructions for convers…
kirilligum Feb 17, 2024
5fa99ae
aider: Moved the "Hide Instructions" button to the App component and …
kirilligum Feb 17, 2024
7529e3e
aider: Moved hideInstructions state to App.tsx and passed it to Simpl…
kirilligum Feb 17, 2024
2dcc711
Updated components to show/hide instructions and added functionality …
kirilligum Feb 17, 2024
bf2ce8a
Added script to compile Solidity contract and generate ABI JSON file.
kirilligum Feb 19, 2024
397896a
(no commit message provided)
kirilligum Feb 19, 2024
460f399
(no commit message provided)
kirilligum Feb 19, 2024
61da088
Updated project to Trust-and-Teach AI DApp web front-end with new fea…
kirilligum Feb 21, 2024
2b6eb59
update
kirilligum Mar 19, 2024
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ dist

# Other
src/generated
.aider*
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
# Cartesi frontend web

```
Cartesi Rollups version: 1.0.x
```
# Trust-and-Teach AI DApp web front-end

## Features

With this project you can test some interactions with the Cartesi Rollups project:

1. Metamask integration
2. Send Inspect state Requests and Listing Reports response
3. Sending Dapp Address with the DApp Relay
4. Sending inputs
5. Depositing Ether
6. Depositing ERC20
7. Depositing ERC721
8. Depositing ERC1155 Single
9. Depositing ERC1155 Batch
10. Listing Notices
11. Listing Reports
12. Listing Vouchers
13. Executing Vouchers
- web3-onboard wallet integration
- simple and advanced interfaces with optional instructions
- sending a prompt to on-chain llm
- securly posting the responses of the llm on-chain
- submitting preferences for respnses on chain to create RLHF dataset
- downloading RLHF dataset as a csv or json table
- the advaned UI has inputs for all contract's functions and setting up the contract's and dApp's addresses
- interact's with cartesi graphql server

## Configurtion

Expand All @@ -43,6 +32,7 @@ yarn start

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
Click on "Show Instructions" button to see the instructions for the front-end.

## Voucher Notes

Expand Down
157 changes: 157 additions & 0 deletions contract_rw_depexec.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/usr/bin/env fish
# set -x
set fish_trace 1
source ../contract_rw_vars.fish

# print hello

function test_cartesi_voucher
argparse "p/path=" -- $argv
or return
echo "======== $_flag_p "
set logfile $_flag_path"test.log"
echo "**** logfile: $logfile" &|tee -a $logfile
git log -n 2 &|tee -a $logfile
if not docker version >/dev/null
echo "docker isn't running :-(" &| tee -a $logfile
return
end
docker image inspect trust-and-teach-contracts >/dev/null 2>&1; and docker image rm trust-and-teach-contracts; or true
if not docker buildx bake -f docker-bake.hcl -f docker-bake.override.hcl --load
echo "Error: docker buildx bake command failed" | tee -a $logfile
return
end
fish -c "docker compose -f docker-compose.yml -f docker-compose.override.yml up"&

set rpc_server_tries_count 0
set rpc_server_tries_count_cutoff 10


while true
echo "()()() while loop in: $logfile"

# Check if the response is empty (server might not be running)
set hex_response (curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' $RPC_URL 2>/dev/null)
if test -z "$hex_response"
set $rpc_server_tries_count (math $$rpc_server_tries_count + 1)
if test $$rpc_server_tries_count -eq $rpc_server_tries_count_cutoff
echo "RPC server check failed 10 times. Exiting..." &| tee -a $logfile
docker compose -f docker-compose.yml -f docker-compose.override.yml down -v
return
end
echo "RPC server not available. Retrying in $db_server_tries_count_cutoff seconds..."
sleep 10
continue
end

# Process response
set hex_number (echo $hex_response | jq -r .result)
set decimal_number (math $hex_number)
echo "Current block number is $decimal_number. log: $_flag_p"
set cut_off_block_load 28 # by this time, all should be loaded
if test $decimal_number -gt $cut_off_block_load
echo "Block number is $decimal_number, which is greater than $cut_off_block."
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast send --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"set_dapp_address(address)\" $DAPP_ADDRESS"
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast send --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"sendInstructionPrompt(string)\" \"When \""
# docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast send --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"sendInstructionPrompt(string)\" \"When Veritatis magni in ipsam, deserunt alias provident odit illo accusamus minus iusto, earum accusantium laboriosam officiis iste possimus nihil obcaecati? Voluptatum omnis rerum nisi adipisci qui nesciunt ad quidem repellat, molestias ea odit? Voluptas corrupti illum necessitatibus odio repudiandae nesciunt ipsam nisi itaque, laudantium optio cum sed corporis magnam, eius nostrum distinctio pariatur ad nihil ducimus sequi consectetur incidunt cupiditate quas. Omnis quos ab nisi officia consectetur fuga aspernatur officiis illo, assumenda voluptatem adipisci nam quaerat illum aliquam eum rem, sit ea quos sed natus officiis fugit nesciunt doloribus quia, voluptatem delectus unde optio magni ea? Dolore velit odit reprehenderit dolorum animi sed aperiam inventore, qui maxime voluptas illo, praesentium fugiat aliquid incidunt repellat repudiandae harum at aliquam voluptatibus, obcaecati sint velit itaque labore est odio sequi. Neque voluptatum qui impedit similique earum sequi, quo nesciunt veniam asperiores? Enim dolor numquam est explicabo, dolorum impedit perferendis natus quisquam, saepe earum quasi quis temporibus tempore necessitatibus. Explicabo aspernatur laudantium at sint mollitia quisquam eaque facilis, magni alias quos accusantium ab quidem illum non, eius ducimus velit a nisi quisquam at. \""
echo "+++++ conversations count: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"current_conversation_id()\"" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"current_conversation_id()\"" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
curl --data '{"id":1337,"jsonrpc":"2.0","method":"evm_increaseTime","params":[864010]}' http://localhost:8545
break
end
sleep 10
end

set db_server_tries_count 0
set db_server_tries_count_cutoff 10

while true
echo "()()() after send while loop in: $logfile"
set hex_response (curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' $RPC_URL 2>/dev/null)
# Check if the response is empty (server might not be running)
if test -z "$hex_response"
set $db_server_tries_count (math $$db_server_tries_count + 1)
if test $$db_server_tries_count -eq $db_server_tries_count_cutoff
echo "RPC server check failed $db_server_tries_count_cutoff times. Exiting..." &| tee -a $logfile
docker compose -f docker-compose.yml -f docker-compose.override.yml down -v
return
end
echo "front end RPC server not available. Retrying in 10 seconds..."
sleep 10
continue
end

# Process response
set hex_number (echo $hex_response | jq -r .result)
set decimal_number (math $hex_number)
echo "Current block number is $decimal_number."

set cut_off_block_interaction_wait 100 # by this time, all should be loaded
if test $decimal_number -gt $cut_off_block_interaction_wait
cd ../rollups-examples/frontend-console/
# yarn && yarn build
yarn start report list &| tee -a $logfile
yarn start notice list &| tee -a $logfile
# set notice_1st_payload (yarn start notice list | jq .[1]."payload" | jq -r)
# set responsesTotal (echo $notice_1st_payload | jq '.promptLLMResponseTotal')
# yarn start notice list | jq .[1:length] | jq .[]."payload" | jq -r | jq '{promptLLMResponseNumber, promptLLMResponseSplit} | map (tostring) | join(" ")' | tr -d \"
set responses_and_splits_filename (mktemp )
yarn start notice list | sed -n '4p' | jq .[1:length] | jq .[]."payload" | jq -r | jq '{promptLLMResponseNumber, promptLLMResponseSplit} | map (tostring) | join(" ")' | tr -d \" > $responses_and_splits_filename
yarn start voucher list &| tee -a $logfile
set voucherTotal ( yarn start voucher list &| tee -a $logfile | sed -n '4p' | jq ".| length")
for iVoucher in (seq 0 ( math $voucherTotal -1 ))
yarn start voucher execute --index $iVoucher --input 0 &| tee -a $logfile
end
cd -

curl --data '{"id":1337,"jsonrpc":"2.0","method":"evm_increaseTime","params":[864010]}' http://localhost:8545
curl --data '{"id":1337,"jsonrpc":"2.0","method":"evm_increaseTime","params":[864010]}' http://localhost:8545

echo "+++++ conversation by ID: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationById(uint256)\" 0" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationById(uint256)\" 0" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
echo "+++++ prompt for conversation 0: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getPromptByConversationId(uint256)\" 0" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getPromptByConversationId(uint256)\" 0" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
echo "+++++ conversation 0 responses count: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationResponseCount(uint256)\" 0" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationResponseCount(uint256)\" 0" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
echo "+++++ conversation 0 response 0 splits count: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationResponseLength(uint256,uint256)\" 0 0" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationResponseLength(uint256,uint256)\" 0 0" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile

echo "+++++ conversations responses splits " &| tee -a $logfile
cat $responses_and_splits_filename | while read l
echo "+++++ conversation 0 response split $l: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationResponseByIndex(uint256,uint256,uint256)\" 0 $l" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getConversationResponseByIndex(uint256,uint256,uint256)\" 0 $l" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
end

# Submitting ranks for conversation 0
echo "+++++ submitting ranks for conversation 0: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast send --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"submitRank(uint256,uint256[])\" 0 [1,0]" &| tee -a $logfile

# Retrieving and outputting users who submitted ranks for conversation 0
echo "+++++ retrieving users who submitted ranks for conversation 0: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getUsersWhoSubmittedRanks(uint256)\" 0" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getUsersWhoSubmittedRanks(uint256)\" 0" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile

# Retrieving ranks submitted by PLAYER1 for conversation 0
echo "+++++ retrieving ranks submitted by $PLAYER1 for conversation 0: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getRanksByUser(uint256,address)\" 0 $PLAYER1" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getRanksByUser(uint256,address)\" 0 $PLAYER1" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
echo "+++++ retrieving rank 1 submitted by $PLAYER1 for conversation 0: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getRankByUserAtIndex(uint256,address,uint256)\" 0 $PLAYER1 0" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getRankByUserAtIndex(uint256,address,uint256)\" 0 $PLAYER1 0" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
echo "+++++ retrieving rank 2 submitted by $PLAYER1 for conversation 0: " &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getRankByUserAtIndex(uint256,address,uint256)\" 0 $PLAYER1 1" &| tee -a $logfile
docker run --rm --net="host" ghcr.io/foundry-rs/foundry "cast call --private-key $PLAYER1_PRIVATE_KEY --rpc-url $RPC_URL $TRUST_AND_TEACH_ADDRESS \"getRankByUserAtIndex(uint256,address,uint256)\" 0 $PLAYER1 1" | tr -d '\n'| cut -c 3- | xxd -p -r &| tee -a $logfile
docker compose -f docker-compose.yml -f docker-compose.override.yml down -v
return
end

sleep 10
end
echo "**** logfile: $logfile" &|tee -a $logfile
end
Loading