From 8eff7c78a9a696abca106da6b654510dd18b76b8 Mon Sep 17 00:00:00 2001 From: art-cmyk <14794711+art-cmyk@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:14:08 +0530 Subject: [PATCH] Upgrade php laravel (#106) * upgrade php * Update version.json --- scripts/setup-vasp.sh | 18 +++-- veriscope_ta_dashboard/app/Http/Kernel.php | 2 +- .../SystemChecks/Checks/EthSyncCheck.php | 9 ++- .../app/Providers/AuthServiceProvider.php | 27 +++---- .../app/Support/EthereumToolsUtils.php | 18 ++--- veriscope_ta_dashboard/app/Token.php | 2 +- .../app/Traits/PassportTokenGenerate.php | 2 +- veriscope_ta_dashboard/composer.json | 77 ++++++++++++------- ...18_08_02_184156_create_countries_table.php | 4 +- .../2018_08_02_184920_create_states_table.php | 4 +- ...02_074039_update_kyc_templates_columns.php | 35 +++++++++ ...te_smart_contract_transactions_columns.php | 33 ++++++++ .../storage/app/version.json | 2 +- 13 files changed, 168 insertions(+), 65 deletions(-) create mode 100644 veriscope_ta_dashboard/database/migrations/2024_05_02_074039_update_kyc_templates_columns.php create mode 100644 veriscope_ta_dashboard/database/migrations/2024_05_02_082806_update_smart_contract_transactions_columns.php diff --git a/scripts/setup-vasp.sh b/scripts/setup-vasp.sh index 4fd220a..fd74e55 100644 --- a/scripts/setup-vasp.sh +++ b/scripts/setup-vasp.sh @@ -144,8 +144,8 @@ function install_redis_bloom { mv /tmp/redis.conf /etc/redis/redis.conf systemctl restart redis-server - sed -i 's/^.*post_max_size.*/post_max_size = 128M/' /etc/php/8.0/fpm/php.ini - sed -i 's/^.*upload_max_filesize .*/upload_max_filesize = 128M/' /etc/php/8.0/fpm/php.ini + sed -i 's/^.*post_max_size.*/post_max_size = 128M/' /etc/php/8.2/fpm/php.ini + sed -i 's/^.*upload_max_filesize .*/upload_max_filesize = 128M/' /etc/php/8.2/fpm/php.ini if grep -q client_max_body_size $NGINX_CFG; then echo "NGINX config already has been already updated" else @@ -153,10 +153,18 @@ function install_redis_bloom { fi pushd >/dev/null $INSTALL_ROOT/veriscope_ta_dashboard + + # double confirm bloom filter folder permission + directory="storage/app/files" + if [ ! -d "$directory" ]; then + mkdir -p "$directory" + fi + + chmod 775 "$directory" chown -R $SERVICE_USER . su $SERVICE_USER -c "composer update" - systemctl restart php8.0-fpm + systemctl restart php8.2-fpm systemctl restart nginx else @@ -198,7 +206,7 @@ function refresh_dependencies() { DEBIAN_FRONTEND=noninteractive apt -y upgrade - DEBIAN_FRONTEND=noninteractive apt-get -qq -y -o Acquire::https::AllowRedirect=false install vim git libsnappy-dev libc6-dev libc6 unzip make jq ntpdate moreutils php8.0-fpm php8.0-dom php8.0-zip php8.0-mbstring php8.0-curl php8.0-dom php8.0-gd php8.0-imagick php8.0-pgsql php8.0-gmp php8.0-redis php8.0-mbstring nodejs build-essential postgresql nginx pwgen certbot + DEBIAN_FRONTEND=noninteractive apt-get -qq -y -o Acquire::https::AllowRedirect=false install vim git libsnappy-dev libc6-dev libc6 unzip make jq ntpdate moreutils php8.2-fpm php8.2-dom php8.2-zip php8.2-mbstring php8.2-curl php8.2-dom php8.2-gd php8.2-imagick php8.2-pgsql php8.2-gmp php8.2-redis php8.2-mbstring nodejs build-essential postgresql nginx pwgen certbot apt-get install -y protobuf-compiler libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \ libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk python3-pip \ libharfbuzz-dev libfribidi-dev libxcb1-dev @@ -410,7 +418,7 @@ function setup_nginx { } ' >$NGINX_CFG systemctl enable nginx - systemctl restart php8.0-fpm + systemctl restart php8.2-fpm systemctl restart nginx } diff --git a/veriscope_ta_dashboard/app/Http/Kernel.php b/veriscope_ta_dashboard/app/Http/Kernel.php index 611c4cf..2e3aea7 100644 --- a/veriscope_ta_dashboard/app/Http/Kernel.php +++ b/veriscope_ta_dashboard/app/Http/Kernel.php @@ -16,7 +16,7 @@ class Kernel extends HttpKernel protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, - \Fruitcake\Cors\HandleCors::class, + \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, diff --git a/veriscope_ta_dashboard/app/Plugins/SystemChecks/Checks/EthSyncCheck.php b/veriscope_ta_dashboard/app/Plugins/SystemChecks/Checks/EthSyncCheck.php index e0cc2d9..4ab654a 100644 --- a/veriscope_ta_dashboard/app/Plugins/SystemChecks/Checks/EthSyncCheck.php +++ b/veriscope_ta_dashboard/app/Plugins/SystemChecks/Checks/EthSyncCheck.php @@ -5,7 +5,6 @@ use App\Plugins\SystemChecks\Check; use GuzzleHttp\Client; use Illuminate\Support\Facades\File; -use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Config; class EthSyncCheck implements Check @@ -17,8 +16,9 @@ public function getId() public function run() { - - Config::set('database.redis.options.prefix', ''); + $redis = new \Redis(); + $redis->connect(env('REDIS_HOST'), env('REDIS_PORT')); + $redis->setOption(\Redis::OPT_PREFIX, ''); $result = ['success' => false, 'message' => '']; $path = base_path('../veriscope_ta_node/.env'); @@ -74,7 +74,7 @@ public function run() if ($currentBlockNumber >= ($highestBlockNumber - 2)) { // Check Redis key for startBlock value - $redisValue = Redis::get('keyv:startBlock'); + $redisValue = $redis->get('keyv:startBlock'); $decodedValue = json_decode($redisValue, true); if ($decodedValue && isset($decodedValue['value'])) { @@ -95,6 +95,7 @@ public function run() return $result; } + } catch (\Exception $e) { $result['message'] = 'Nethermind is not running due to an error: ' . $e->getMessage(); return $result; diff --git a/veriscope_ta_dashboard/app/Providers/AuthServiceProvider.php b/veriscope_ta_dashboard/app/Providers/AuthServiceProvider.php index cc0368e..721b051 100644 --- a/veriscope_ta_dashboard/app/Providers/AuthServiceProvider.php +++ b/veriscope_ta_dashboard/app/Providers/AuthServiceProvider.php @@ -27,8 +27,6 @@ public function boot() { $this->registerPolicies(); - // Passport::routes(); - Gate::define('grant-users', function ($user) { return $user->inGroup('admin'); }); @@ -38,24 +36,23 @@ public function boot() }); if (! $this->app->routesAreCached()) { - Passport::routes(); Passport::tokensCan([ - 'set_attestation' => 'Set Attestation', - 'create_shyft_user' => 'Create Shyft User', - 'get_jurisdictions' => 'Get Jurisdiction', - 'get_verified_trust_anchors' => 'Get Verified Trust Anchors', - 'get_trust_anchor_details' => 'Get Trust Anchor Details', - 'verify_trust_anchor' => 'Verify Trust Anchor' + 'set_attestation' => 'Set Attestation', + 'create_shyft_user' => 'Create Shyft User', + 'get_jurisdictions' => 'Get Jurisdiction', + 'get_verified_trust_anchors' => 'Get Verified Trust Anchors', + 'get_trust_anchor_details' => 'Get Trust Anchor Details', + 'verify_trust_anchor' => 'Verify Trust Anchor' ]); Passport::setDefaultScope([ - 'set_attestation', - 'create_shyft_user', - 'get_jurisdictions', - 'get_verified_trust_anchors', - 'get_trust_anchor_details', - 'verify_trust_anchor' + 'set_attestation', + 'create_shyft_user', + 'get_jurisdictions', + 'get_verified_trust_anchors', + 'get_trust_anchor_details', + 'verify_trust_anchor' ]); } } diff --git a/veriscope_ta_dashboard/app/Support/EthereumToolsUtils.php b/veriscope_ta_dashboard/app/Support/EthereumToolsUtils.php index dce3824..e769371 100644 --- a/veriscope_ta_dashboard/app/Support/EthereumToolsUtils.php +++ b/veriscope_ta_dashboard/app/Support/EthereumToolsUtils.php @@ -425,15 +425,15 @@ public static function toInt32Bits($value) * @return string */ public static function hexToStr($value) - { - $string=''; - for ($i=0; $i < strlen($value)-1; $i+=2) - { - if ( $value[$i] == ' ') continue; - $string .= chr(hexdec($value[$i].$value[$i+1])); - } - return $string; - } + { + $string=''; + for ($i=0; $i < strlen($value)-1; $i+=2) + { + if ( $value[$i] == ' ') continue; + $string .= chr(hexdec($value[$i].$value[$i+1])); + } + return $string; + } /** * Encrypt Data diff --git a/veriscope_ta_dashboard/app/Token.php b/veriscope_ta_dashboard/app/Token.php index 107e310..75103cf 100644 --- a/veriscope_ta_dashboard/app/Token.php +++ b/veriscope_ta_dashboard/app/Token.php @@ -26,7 +26,7 @@ public function getPersonalAccessTokenResult() ); $now = new DateTimeImmutable(); - $expiresAt = new DateTimeImmutable($this->expires_at->toDateTimeString()); + $expiresAt = new DateTimeImmutable($this->expires_at); $token = $configuration->builder() ->permittedFor($this->client_id) diff --git a/veriscope_ta_dashboard/app/Traits/PassportTokenGenerate.php b/veriscope_ta_dashboard/app/Traits/PassportTokenGenerate.php index d1378c8..45303fc 100644 --- a/veriscope_ta_dashboard/app/Traits/PassportTokenGenerate.php +++ b/veriscope_ta_dashboard/app/Traits/PassportTokenGenerate.php @@ -33,7 +33,7 @@ public function getPersonalAccessTokenResult($client_id, $token_id, $user_id, $e ); $now = new DateTimeImmutable(); - $expiresAt = new DateTimeImmutable($expires_at->toDateTimeString()); + $expiresAt = new DateTimeImmutable($expires_at); $token = $configuration->builder() ->permittedFor($client_id) diff --git a/veriscope_ta_dashboard/composer.json b/veriscope_ta_dashboard/composer.json index 539fcd7..558d822 100644 --- a/veriscope_ta_dashboard/composer.json +++ b/veriscope_ta_dashboard/composer.json @@ -6,62 +6,87 @@ "repositories":[ { "type": "git", - "url": "https://github.com/hackable/roles.git" + "url": "https://github.com/ShyftNetwork/roles.git" }, { "type": "git", - "url": "https://github.com/hackable/ethereum-address-validator.git" + "url": "https://github.com/ShyftNetwork/ethereum-address-validator.git" + }, + { + "type": "git", + "url": "https://github.com/ShyftNetwork/EloquentEncryption.git" + }, + { + "type": "git", + "url": "https://github.com/ShyftNetwork/laravel-eloquent-state-machines.git" + }, + { + "type": "git", + "url": "https://github.com/ShyftNetwork/laravel-websockets.git" + }, + { + "type": "git", + "url": "https://github.com/ShyftNetwork/html.git" + }, + { + "type": "git", + "url": "https://github.com/ShyftNetwork/Ratchet.git" + }, + { + "type": "git", + "url": "https://github.com/ShyftNetwork/glide-laravel.git" } ], "require": { - "php": "^7.3|^8.0", - "asantibanez/laravel-eloquent-state-machines": "^5.1", - "bayareawebpro/laravel-simple-csv": "^2.0", + "php": "^8.0", + "cboden/ratchet": "v0.6.1", + "asantibanez/laravel-eloquent-state-machines": "dev-master", + "bayareawebpro/laravel-simple-csv": "v2.2.0", "bacon/bacon-qr-code": "^2.0", - "beyondcode/laravel-websockets": "^1.13", + "beyondcode/laravel-websockets": "1.18.0", "digitaldonkey/ecverify": "^1.0", - "doctrine/dbal": "^3.1", - "firebase/php-jwt": "^5.5", - "fruitcake/laravel-cors": "^2.0", + "doctrine/dbal": "^3.0", + "firebase/php-jwt": "^6.10", "guzzlehttp/guzzle": "^7.0.1", - "httpoz/roles": "master", "kornrunner/ethereum-address": "^0.3.0", - "laravel/framework": "^8.54", + "laravel/framework": "^11.0", "laravel/horizon": "^5.8", "laravel/legacy-factories": "^1.1", - "laravel/passport": "^10.1", + "laravel/passport": "v12.2.0", "laravel/tinker": "^2.5", - "laravel/ui": "^3.3", - "laravelcollective/html": "^6.2", + "laravel/ui": "^4.5", + "laravelcollective/html": "v6.7.0", "league/csv": "^9.7", - "league/glide-laravel": "^1.0", + "league/glide-laravel": "^2.1", "opis/json-schema": "^2.2", "php-redis/bloom-filter": "^1.1", - "pragmarx/google2fa-laravel": "^1.4", - "psychob/ethereum-address-validator": "dev-master", - "pusher/pusher-php-server": "7.0.2", - "richardstyles/eloquentencryption": "v3.1.0", - "s-ichikawa/laravel-sendgrid-driver": "^3.0", + "pragmarx/google2fa-laravel": "^2.0", + "pusher/pusher-php-server": "7.2.4", + "richardstyles/eloquentencryption": "v3.4", + "s-ichikawa/laravel-sendgrid-driver": "^4.0", "sebdesign/laravel-state-machine": "^3.2", - "sentry/sentry-laravel": "^2.8", + "sentry/sentry-laravel": "^4.0", "simplesoftwareio/simple-qrcode": "^4.2", "simplito/elliptic-php": "^1.0", "spatie/laravel-activitylog": "^4.1", "spatie/laravel-webhook-server": "^3.1", "msztorc/laravel-env": "^1.2", "spatie/laravel-fractal": "^6.0", - "abagayev/laravel-migration-shortcuts": "*", "nelexa/zip": "^4.0", "web3p/web3.php": "0.2.1", - "laravel/slack-notification-channel": "^2.5" + "laravel/slack-notification-channel": "^3.0", + "abagayev/laravel-migration-shortcuts": "*", + "psychob/ethereum-address-validator": "dev-master", + "httpoz/roles": "dev-master", + "nesbot/carbon": "^2.72.2" }, "require-dev": { - "facade/ignition": "^2.5", + "spatie/laravel-ignition": "^2.0", "fakerphp/faker": "^1.9.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.2", - "nunomaduro/collision": "^5.0", - "phpunit/phpunit": "^9.3.3" + "nunomaduro/collision": "^v8.0.0", + "phpunit/phpunit": "^10.5.1" }, "autoload": { "psr-4": { diff --git a/veriscope_ta_dashboard/database/migrations/2018_08_02_184156_create_countries_table.php b/veriscope_ta_dashboard/database/migrations/2018_08_02_184156_create_countries_table.php index b358e98..969cee1 100644 --- a/veriscope_ta_dashboard/database/migrations/2018_08_02_184156_create_countries_table.php +++ b/veriscope_ta_dashboard/database/migrations/2018_08_02_184156_create_countries_table.php @@ -25,7 +25,9 @@ public function up() // next up, create the countries $path = 'app/SqlDumps/countries.sql'; DB::unprepared(file_get_contents($path)); - DB::unprepared(DB::raw('UPDATE countries SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';')); + // DB::unprepared(DB::raw('UPDATE countries SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';')); // this is used by laravel 8 & 9 + $now = Carbon::now()->toDateTimeString(); + DB::unprepared("UPDATE countries SET created_at='{$now}', updated_at='{$now}';"); //$this->command->info('Country table seeded!'); } diff --git a/veriscope_ta_dashboard/database/migrations/2018_08_02_184920_create_states_table.php b/veriscope_ta_dashboard/database/migrations/2018_08_02_184920_create_states_table.php index 892cbd8..13665a3 100644 --- a/veriscope_ta_dashboard/database/migrations/2018_08_02_184920_create_states_table.php +++ b/veriscope_ta_dashboard/database/migrations/2018_08_02_184920_create_states_table.php @@ -25,7 +25,9 @@ public function up() $path = 'app/SqlDumps/states.sql'; DB::unprepared(file_get_contents($path)); //DB::unprepared(DB::raw('UPDATE states SET created_at=NOW(), updated_at=NOW();')); - DB::unprepared(DB::raw('UPDATE states SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';')); + // DB::unprepared(DB::raw('UPDATE states SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';')); + $now = Carbon::now()->toDateTimeString(); + DB::unprepared("UPDATE states SET created_at='{$now}', updated_at='{$now}';"); //$this->command->info('State table seeded!'); } diff --git a/veriscope_ta_dashboard/database/migrations/2024_05_02_074039_update_kyc_templates_columns.php b/veriscope_ta_dashboard/database/migrations/2024_05_02_074039_update_kyc_templates_columns.php new file mode 100644 index 0000000..e0fef36 --- /dev/null +++ b/veriscope_ta_dashboard/database/migrations/2024_05_02_074039_update_kyc_templates_columns.php @@ -0,0 +1,35 @@ +longText('beneficiary_kyc')->change()->nullable(); + $table->longText('sender_kyc')->change()->nullable(); + $table->longText('beneficiary_user_address_crypto_proof')->change()->nullable(); + $table->longText('sender_user_address_crypto_proof')->change()->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('kyc_templates', function (Blueprint $table) { + $table->longText('beneficiary_kyc')->nullable()->change(); + $table->longText('sender_kyc')->nullable()->change(); + $table->longText('beneficiary_user_address_crypto_proof')->nullable()->change(); + $table->longText('sender_user_address_crypto_proof')->nullable()->change(); + }); + } +}; \ No newline at end of file diff --git a/veriscope_ta_dashboard/database/migrations/2024_05_02_082806_update_smart_contract_transactions_columns.php b/veriscope_ta_dashboard/database/migrations/2024_05_02_082806_update_smart_contract_transactions_columns.php new file mode 100644 index 0000000..b67524e --- /dev/null +++ b/veriscope_ta_dashboard/database/migrations/2024_05_02_082806_update_smart_contract_transactions_columns.php @@ -0,0 +1,33 @@ +bigInteger('gas_price')->change()->nullable(); + $table->bigInteger('gas')->change()->nullable(); + $table->bigInteger('value')->change()->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('smart_contract_transactions', function (Blueprint $table) { + $table->bigInteger('gas_price')->nullable()->change(); + $table->bigInteger('gas')->nullable()->change(); + $table->bigInteger('value')->nullable()->change(); + }); + } +}; \ No newline at end of file diff --git a/veriscope_ta_dashboard/storage/app/version.json b/veriscope_ta_dashboard/storage/app/version.json index 7c2a8f6..e69748d 100644 --- a/veriscope_ta_dashboard/storage/app/version.json +++ b/veriscope_ta_dashboard/storage/app/version.json @@ -1,3 +1,3 @@ { - "veriscopeVersion": "4.4.0" + "veriscopeVersion": "4.5.0" }