From e4667cd4dcd261a0a524726cee15dbef254d240a Mon Sep 17 00:00:00 2001 From: brkagithub Date: Wed, 25 Dec 2024 22:47:24 +0100 Subject: [PATCH 1/4] fix --- v8-data-migration/constants.js | 17 ++++++++--------- v8-data-migration/v8-data-migration.js | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/v8-data-migration/constants.js b/v8-data-migration/constants.js index b467e701d..53f84f4ef 100644 --- a/v8-data-migration/constants.js +++ b/v8-data-migration/constants.js @@ -39,55 +39,54 @@ export const ABIs = { ContentAssetStorageV2: require('./abi/ContentAssetStorageV2.json'), ContentAssetStorage: require('./abi/ContentAssetStorage.json'), }; - export const BLOCKCHAINS = { BASE_DEVNET: { ID: 'base:84532', ENV: 'devnet', NAME: 'base_devnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0xBe08A25dcF2B68af88501611e5456571f50327B4', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0xbe08a25dcf2b68af88501611e5456571f50327b4', }, BASE_TESTNET: { ID: 'base:84532', ENV: 'testnet', NAME: 'base_testnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x9e3071Dc0730CB6dd0ce42969396D716Ea33E7e1', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x9e3071dc0730cb6dd0ce42969396d716ea33e7e1', }, BASE_MAINNET: { ID: 'base:8453', ENV: 'mainnet', NAME: 'base_mainnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x3bdfA81079B2bA53a25a6641608E5E1E6c464597', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x3bdfa81079b2ba53a25a6641608e5e1e6c464597', }, GNOSIS_DEVNET: { ID: 'gnosis:10200', ENV: 'devnet', NAME: 'gnosis_devnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x3db64dD0Ac054610d1e2Af9Cca0fbCB1A7f4C2d8', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x3db64dd0ac054610d1e2af9cca0fbcb1a7f4c2d8', }, GNOSIS_TESTNET: { ID: 'gnosis:10200', ENV: 'testnet', NAME: 'gnosis_testnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0xeA3423e02c8d231532dab1BCE5D034f3737B3638', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0xea3423e02c8d231532dab1bce5d034f3737b3638', }, GNOSIS_MAINNET: { ID: 'gnosis:100', ENV: 'mainnet', NAME: 'gnosis_mainnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0xf81a8C0008DE2DCdb73366Cf78F2b178616d11DD', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0xf81a8c0008de2dcdb73366cf78f2b178616d11dd', }, NEUROWEB_TESTNET: { ID: 'otp:20430', ENV: 'testnet', NAME: 'neuroweb_testnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x1A061136Ed9f5eD69395f18961a0a535EF4B3E5f', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x1a061136ed9f5ed69395f18961a0a535ef4b3e5f', }, NEUROWEB_MAINNET: { ID: 'otp:2043', ENV: 'mainnet', NAME: 'neuroweb_mainnet', - CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x5cAC41237127F94c2D21dAe0b14bFeFa99880630', + CONTENT_ASSET_STORAGE_CONTRACT_ADDRESS: '0x5cac41237127f94c2d21dae0b14bfefa99880630', }, }; diff --git a/v8-data-migration/v8-data-migration.js b/v8-data-migration/v8-data-migration.js index 4eb43361c..7dff4b6b4 100644 --- a/v8-data-migration/v8-data-migration.js +++ b/v8-data-migration/v8-data-migration.js @@ -110,7 +110,7 @@ async function processAndInsertNewerAssertions( if (assertionsToCheck.length > 0) { const { tokenId, ual, privateAssertion } = assertionsToCheck[0]; - const knowledgeAssetUal = `${ual}/1`; + const knowledgeAssetUal = `${ual.toLowerCase()}/1`; logger.time(`GETTING KNOWLEDGE COLLECTION NAMED GRAPHS EXIST FOR 1 ASSERTION`); // eslint-disable-next-line no-await-in-loop const { exists } = await getKnowledgeCollectionNamedGraphsExist( @@ -182,7 +182,7 @@ async function processAndInsertAssertions( const promises = []; for (const assertion of assertionsToCheck) { const { tokenId, ual, privateAssertion } = assertion; - const knowledgeAssetUal = `${ual}/1`; + const knowledgeAssetUal = `${ual.toLowerCase()}/1`; promises.push( getKnowledgeCollectionNamedGraphsExist( From 0d240c7707ee7e0ba4079dfd2ee105d2b5807b64 Mon Sep 17 00:00:00 2001 From: brkagithub Date: Wed, 25 Dec 2024 23:23:23 +0100 Subject: [PATCH 2/4] insert ual in loer case always --- v8-data-migration/triple-store-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v8-data-migration/triple-store-utils.js b/v8-data-migration/triple-store-utils.js index 8e68989bd..ba499c647 100644 --- a/v8-data-migration/triple-store-utils.js +++ b/v8-data-migration/triple-store-utils.js @@ -607,7 +607,7 @@ export async function insertAssertionsIntoV8UnifiedRepository( continue; } - const knowledgeAssetUal = `${ual}/1`; + const knowledgeAssetUal = `${ual.toLower()}/1`; const publicNQuads = processContent(publicAssertion); insertQueries.push(` From f70916ee9883d81ae6e6fc72808912205ded1590 Mon Sep 17 00:00:00 2001 From: brkagithub Date: Wed, 25 Dec 2024 23:33:58 +0100 Subject: [PATCH 3/4] Random fix --- v8-data-migration/triple-store-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v8-data-migration/triple-store-utils.js b/v8-data-migration/triple-store-utils.js index ba499c647..14aa81294 100644 --- a/v8-data-migration/triple-store-utils.js +++ b/v8-data-migration/triple-store-utils.js @@ -607,7 +607,7 @@ export async function insertAssertionsIntoV8UnifiedRepository( continue; } - const knowledgeAssetUal = `${ual.toLower()}/1`; + const knowledgeAssetUal = `${ual.toLowerCase()}/1`; const publicNQuads = processContent(publicAssertion); insertQueries.push(` From 7d39c2a2c102cf9c6cdd8b27694e3fc65fd8f5a7 Mon Sep 17 00:00:00 2001 From: brkagithub Date: Thu, 26 Dec 2024 01:06:59 +0100 Subject: [PATCH 4/4] new intalster --- installer/installer.sh | 214 ++++++++++++++++++++++++++++------------- 1 file changed, 148 insertions(+), 66 deletions(-) diff --git a/installer/installer.sh b/installer/installer.sh index e13e7485c..c6f848ff9 100644 --- a/installer/installer.sh +++ b/installer/installer.sh @@ -294,17 +294,87 @@ install_node() { # Change directory to ot-node/current cd $OTNODE_DIR - # Set node environment to testnet - nodeEnv="testnet" - print_color $CYAN "🌐 Setting up node for Base Sepolia (Testnet) environment" + # Request node environment with strict input validation + while true; do + read -p "Please select node environment: (Default: Mainnet) [T]estnet [M]ainnet [E]xit " choice + case "$choice" in + [tT]* ) nodeEnv="testnet"; break;; + [mM]* ) nodeEnv="mainnet"; break;; + [eE]* ) text_color $RED "Installer stopped by user"; exit;; + * ) text_color $RED "Invalid choice. Please enter either [T]estnet, [M]ainnet, or [E]xit."; continue;; + esac + done echo "NODE_ENV=$nodeEnv" >> $OTNODE_DIR/.env - # Set blockchain options for testnet - blockchain_options=("Base-Sepolia") - base_blockchain_id=84532 + # Set blockchain options based on the selected environment + if [ "$nodeEnv" == "mainnet" ]; then + blockchain_options=("OriginTrail Parachain" "Gnosis" "Base") + otp_blockchain_id=2043 + gnosis_blockchain_id=100 + base_blockchain_id=8453 + else + blockchain_options=("OriginTrail Parachain" "Gnosis" "Base-Sepolia") + otp_blockchain_id=20430 + gnosis_blockchain_id=10200 + base_blockchain_id=84532 + fi + + # Ask user which blockchains to connect to + selected_blockchains=() + checkbox_states=() + for _ in "${blockchain_options[@]}"; do + checkbox_states+=("[ ]") + done + + while true; do + clear # Clear the screen for a cleaner display + echo "Please select the blockchains you want to connect your node to:" + for i in "${!blockchain_options[@]}"; do + echo " ${checkbox_states[$i]} $((i+1)). ${blockchain_options[$i]}" + done + echo " [ ] $((${#blockchain_options[@]}+1)). All Blockchains" + echo " Enter 'd' to finish selection" + + # Use read -n 1 to read a single character without requiring Enter + read -n 1 -p "Enter the number to toggle selection (1-$((${#blockchain_options[@]}+1))): " choice + echo # Add a newline after the selection + + if [[ "$choice" == "d" ]]; then + if [ ${#selected_blockchains[@]} -eq 0 ]; then + text_color $RED "You must select at least one blockchain. Please try again." + read -n 1 -p "Press any key to continue..." + continue + else + break + fi + elif [[ "$choice" =~ ^[1-${#blockchain_options[@]}]$ ]]; then + index=$((choice-1)) + if [[ "${checkbox_states[$index]}" == "[ ]" ]]; then + checkbox_states[$index]="[x]" + selected_blockchains+=("${blockchain_options[$index]}") + else + checkbox_states[$index]="[ ]" + selected_blockchains=(${selected_blockchains[@]/${blockchain_options[$index]}}) + fi + elif [[ "$choice" == "$((${#blockchain_options[@]}+1))" ]]; then + if [[ "${checkbox_states[-1]}" == "[ ]" ]]; then + for i in "${!checkbox_states[@]}"; do + checkbox_states[$i]="[x]" + done + selected_blockchains=("${blockchain_options[@]}") + else + for i in "${!checkbox_states[@]}"; do + checkbox_states[$i]="[ ]" + done + selected_blockchains=() + fi + else + text_color $RED "Invalid choice. Please enter a number between 1 and $((${#blockchain_options[@]}+1))." + read -n 1 -p "Press any key to continue..." + fi + done - print_color $CYAN "🔗 Connecting to Base-Sepolia (Testnet)" - selected_blockchains=("Base-Sepolia") + text_color $GREEN "Final blockchain selection: ${selected_blockchains[*]}" CONFIG_DIR=$OTNODE_DIR/.. perform_step touch $CONFIG_DIR/.origintrail_noderc "Configuring node config file" @@ -331,7 +401,7 @@ install_node() { validate_operator_fees() { local blockchain=$1 while true; do - read -p "$(print_color $CYAN "Enter your operator fee for Base Sepolia (0-100): ")" OPERATOR_FEE + read -p "$(print_color $CYAN "Enter your operator fee for $blockchain (0-100): ")" OPERATOR_FEE if [[ "$OPERATOR_FEE" =~ ^[0-9]+$ ]] && [ "$OPERATOR_FEE" -ge 0 ] && [ "$OPERATOR_FEE" -le 100 ]; then print_color $GREEN "✅ Operator fee for $blockchain: $OPERATOR_FEE" break @@ -346,39 +416,23 @@ install_node() { local blockchain=$1 local blockchain_id=$2 - print_color $CYAN "🔧 Configuring Base Sepolia (Testnet)..." + request_operational_wallet_keys $blockchain + local EVM_OP_WALLET_KEYS=$OP_WALLET_KEYS_JSON - print_color $YELLOW "You'll now be asked to input your operational wallets public and private keys (press ENTER to skip)" - - local EVM_OP_WALLET_KEYS='[]' - local wallet_index=1 - while true; do - read -p "$(print_color $YELLOW "Please insert your operational wallet public key no. $wallet_index: ")" wallet_address - if [ -z "$wallet_address" ]; then - break - fi - print_color $GREEN " EVM operational wallet public key no. $wallet_index: $wallet_address" - - read -p "$(print_color $YELLOW "Please insert private key for your operational wallet no. $wallet_index: ")" wallet_private_key - if [ -z "$wallet_private_key" ]; then - break - fi - print_color $GREEN " EVM operational wallet private key no. $wallet_index: $wallet_private_key" - - EVM_OP_WALLET_KEYS=$(echo $EVM_OP_WALLET_KEYS | jq '. += [{"address": "'$wallet_address'", "privateKey": "'$wallet_private_key'"}]') - wallet_index=$((wallet_index + 1)) - done - - read -p "$(print_color $YELLOW "Enter your EVM management wallet address : ")" EVM_MANAGEMENT_WALLET - print_color $GREEN "✅ EVM management wallet address : $EVM_MANAGEMENT_WALLET" + read -p "Enter your EVM management wallet address for $blockchain: " EVM_MANAGEMENT_WALLET + text_color $GREEN "EVM management wallet address for $blockchain: $EVM_MANAGEMENT_WALLET" read -p "$(print_color $YELLOW "Enter your profile node name : ")" NODE_NAME - print_color $GREEN "✅ Profile shares token name : $NODE_NAME" + print_color $GREEN "✅ Profile node name : $NODE_NAME" + validate_operator_fees $blockchain - read -p "$(print_color $YELLOW "Enter your RPC endpoint: ")" RPC_ENDPOINT - print_color $GREEN "✅ RPC endpoint: $RPC_ENDPOINT" + local RPC_ENDPOINT="" + if [ "$blockchain" == "gnosis" ] || [ "$blockchain" == "base" ]; then + read -p "Enter your $blockchain RPC endpoint: " RPC_ENDPOINT + text_color $GREEN "$blockchain RPC endpoint: $RPC_ENDPOINT" + fi local jq_filter=$(cat < $CONFIG_DIR/origintrail_noderc_tmp mv $CONFIG_DIR/origintrail_noderc_tmp $CONFIG_DIR/.origintrail_noderc - chmod 600 $CONFIG_DIR/.origintrail_noderc } - # Configure Base-Sepolia - configure_blockchain "base" $base_blockchain_id - # Function to configure blockchain events services configure_blockchain_events_services() { - local blockchain=$1 - local blockchain_id=$2 - - print_color $CYAN "🔧 Configuring Blockchain Events Service for Base Sepolia (Testnet)..." - - read -p "$(print_color $YELLOW "Enter your RPC endpoint: ")" RPC_ENDPOINT - print_color $GREEN "✅ RPC endpoint: $RPC_ENDPOINT" + local blockchain=$1 + local blockchain_id=$2 + + print_color $CYAN "🔧 Configuring Blockchain Events Service for $blockchain (ID: $blockchain_id)..." + + # Prompt the user for the RPC endpoint + read -p "$(print_color $YELLOW "Enter your RPC endpoint for $blockchain: ")" RPC_ENDPOINT + print_color $GREEN "✅ RPC endpoint: $RPC_ENDPOINT" + + # Correct `jq` usage to safely initialize and update the configuration + local jq_filter=' + .modules |= (if .blockchainEvents == null then .blockchainEvents = {implementation: {}} else . end) | + .modules.blockchainEvents.implementation |= (if .["ot-ethers"] == null then .["ot-ethers"] = {enabled: false, config: {}} else . end) | + .modules.blockchainEvents.implementation["ot-ethers"].enabled = true | + .modules.blockchainEvents.implementation["ot-ethers"].config |= (if .blockchains == null then .blockchains = [] else . end) | + .modules.blockchainEvents.implementation["ot-ethers"].config |= (if .rpcEndpoints == null then .rpcEndpoints = {} else . end) | + .modules.blockchainEvents.implementation["ot-ethers"].config.blockchains += ["'"$blockchain:$blockchain_id"'"] | + .modules.blockchainEvents.implementation["ot-ethers"].config.rpcEndpoints["'"$blockchain:$blockchain_id"'"] = ["'"$RPC_ENDPOINT"'"] + ' + + # Apply the configuration changes + if jq "$jq_filter" "$CONFIG_DIR/.origintrail_noderc" > "$CONFIG_DIR/.origintrail_noderc_tmp"; then + mv "$CONFIG_DIR/.origintrail_noderc_tmp" "$CONFIG_DIR/.origintrail_noderc" + chmod 600 "$CONFIG_DIR/.origintrail_noderc" + print_color $GREEN "✅ Successfully configured Blockchain Events Service for $blockchain (ID: $blockchain_id)." + else + print_color $RED "❌ Failed to configure Blockchain Events Service for $blockchain (ID: $blockchain_id)." + exit 1 + fi +} - local jq_filter=$(cat < $CONFIG_DIR/origintrail_noderc_tmp - mv $CONFIG_DIR/origintrail_noderc_tmp $CONFIG_DIR/.origintrail_noderc - chmod 600 $CONFIG_DIR/.origintrail_noderc - } # Configure blockchain events service for Base Sepolia - configure_blockchain_events_services "base" $base_blockchain_id + for blockchain in "${selected_blockchains[@]}"; do + case "$blockchain" in + "OriginTrail Parachain") + configure_blockchain "otp" $otp_blockchain_id + ;; + "Gnosis") + configure_blockchain "gnosis" $gnosis_blockchain_id + ;; + "Base" | "Base-Sepolia") + configure_blockchain "base" $base_blockchain_id + ;; + esac + done + for blockchain in "${selected_blockchains[@]}"; do + case "$blockchain" in + "Gnosis") + configure_blockchain_events_services "gnosis" $gnosis_blockchain_id + ;; + "Base" | "Base-Sepolia") + configure_blockchain_events_services "base" $base_blockchain_id + ;; + esac + done # Now execute npm install after configuring wallets print_color $CYAN "📦 Installing npm packages..." perform_step npm ci --omit=dev --ignore-scripts "Executing npm install"