diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index fa11bc135..cfc56c540 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -18,7 +18,6 @@ use App\Models\Scopes\ValidatorResignationScope; use App\Models\Scopes\VoteScope; use App\Services\BigNumber; -use App\Services\VendorField; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -40,7 +39,6 @@ * @property string $sender_public_key * @property int $block_height * @property resource|null $data - * @property resource|string|null $vendor_field * @property int $nonce * @property Wallet $sender * @method static \Illuminate\Database\Eloquent\Builder withScope(string $scope) @@ -110,8 +108,6 @@ final class Transaction extends Model 'receipt', ]; - private bool|string|null $vendorFieldContent = false; - /** * Get the indexable data array for the model. * @@ -225,15 +221,6 @@ public function recipient(): Wallet return Wallet::where('address', $vote)->firstOrFail(); } - public function vendorField(): string|null - { - if (is_bool($this->vendorFieldContent)) { - $this->vendorFieldContent = VendorField::parse($this->vendor_field); - } - - return $this->vendorFieldContent; - } - public function fee(): BigNumber { $gasPrice = clone $this->gas_price; diff --git a/app/Services/VendorField.php b/app/Services/VendorField.php deleted file mode 100644 index c19fa1943..000000000 --- a/app/Services/VendorField.php +++ /dev/null @@ -1,54 +0,0 @@ -transaction->vendorField(); - } -} diff --git a/app/ViewModels/TransactionViewModel.php b/app/ViewModels/TransactionViewModel.php index 8879629af..799ff8773 100644 --- a/app/ViewModels/TransactionViewModel.php +++ b/app/ViewModels/TransactionViewModel.php @@ -19,7 +19,6 @@ use App\ViewModels\Concerns\Transaction\InteractsWithMultiPayment; use App\ViewModels\Concerns\Transaction\InteractsWithMultiSignature; use App\ViewModels\Concerns\Transaction\InteractsWithUsernames; -use App\ViewModels\Concerns\Transaction\InteractsWithVendorField; use App\ViewModels\Concerns\Transaction\InteractsWithVotes; use App\ViewModels\Concerns\Transaction\InteractsWithWallets; use ArkEcosystem\Crypto\Utils\UnitConverter; @@ -35,7 +34,6 @@ final class TransactionViewModel implements ViewModel use InteractsWithMultiPayment; use InteractsWithMultiSignature; use InteractsWithUsernames; - use InteractsWithVendorField; use InteractsWithVotes; use InteractsWithWallets; diff --git a/resources/views/app/transaction.blade.php b/resources/views/app/transaction.blade.php index 2694d4988..53ac50801 100644 --- a/resources/views/app/transaction.blade.php +++ b/resources/views/app/transaction.blade.php @@ -15,10 +15,6 @@ - @if ($transaction->isTransfer() || $transaction->isMultiPayment()) - - @endif - @if ($transaction->isMultiPayment()) diff --git a/resources/views/components/transaction/page/memo.blade.php b/resources/views/components/transaction/page/memo.blade.php deleted file mode 100644 index 7b46c7bec..000000000 --- a/resources/views/components/transaction/page/memo.blade.php +++ /dev/null @@ -1,18 +0,0 @@ -@props(['transaction']) - -@php ($vendorField = $transaction->vendorField()) - - - @if (! $vendorField) - - @lang('general.na') - - @else -
- {{ $vendorField }} -
- @endif -
diff --git a/resources/views/components/transaction/page/more-details.blade.php b/resources/views/components/transaction/page/more-details.blade.php index 769f24345..2c691d14d 100644 --- a/resources/views/components/transaction/page/more-details.blade.php +++ b/resources/views/components/transaction/page/more-details.blade.php @@ -1,7 +1,5 @@ @props(['transaction']) -@php ($vendorField = $transaction->vendorField()) -
{{-- Mobile --}} recipient())->toEqual($validator->fresh()); }); -it('should get vendorfield value multiple times despite resource', function () { - $transaction = Transaction::factory()->transfer()->create([ - 'recipient_id' => 'DENGkAwEfRvhhHKZYdEfQ1P3MEoRvPkHYj', - 'fee' => 0.1 * 1e18, // 0.1 - 'amount' => 2 * 1e18, // 2 - 'vendor_field' => '0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0', - ]); - - expect($transaction->vendor_field)->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); - expect($transaction->vendorField())->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); - - $transaction = Transaction::find($transaction->id); - - expect(is_resource($transaction->vendor_field))->toBeTrue(); - expect($transaction->vendorField())->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); - expect($transaction->vendorField())->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); - expect($transaction->vendorField())->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); - expect($transaction->vendorField())->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); - expect($transaction->vendorField())->toBe('0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'); -}); - it('makes transactions searchable', function () { $transaction = Transaction::factory()->create(); diff --git a/tests/Unit/Services/VendorFieldTest.php b/tests/Unit/Services/VendorFieldTest.php deleted file mode 100644 index e9f8072bd..000000000 --- a/tests/Unit/Services/VendorFieldTest.php +++ /dev/null @@ -1,51 +0,0 @@ -toBe($expected); -})->with([ - ['0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0', '3078524b656f495a394b6832673448736c6765487235423979626c48626e77575967666546674f33366e30'], - ['1', '31'], - [21, '3231'], - [null, null], - [1.4, '312e34'], - [true, null], - ['', null], -]); - -it('should convert resource to hex', function () { - $resource = fopen('data:text/plain;base64,'.base64_encode('this is a test stream'), 'rb'); - - expect(VendorField::toHex($resource))->toBe('74686973206973206120746573742073747265616d'); -}); - -it('should parse vendor field value', function ($content, $expected) { - expect(VendorField::parse($content))->toBe($expected); -})->with([ - ['3078524b656f495a394b6832673448736c6765487235423979626c48626e77575967666546674f33366e30', '3078524b656f495a394b6832673448736c6765487235423979626c48626e77575967666546674f33366e30'], - ['31', '31'], - ['3231', '3231'], - [184, '184'], - ['0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0', '0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'], - ['Random vendorfield value', 'Random vendorfield value'], - [null, null], - [1.4, null], - ['1.4', '1.4'], - [true, null], - ['', null], -]); - -it('should parse resource', function ($content, $expected) { - $resource = fopen('data:text/plain;base64,'.base64_encode($content), 'rb'); - - expect(VendorField::parse($resource))->toBe($expected); -})->with([ - ['3078524b656f495a394b6832673448736c6765487235423979626c48626e77575967666546674f33366e30', '3078524b656f495a394b6832673448736c6765487235423979626c48626e77575967666546674f33366e30'], - ['31', '31'], - ['3231', '3231'], - ['0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0', '0xRKeoIZ9Kh2g4HslgeHr5B9yblHbnwWYgfeFgO36n0'], - ['Random vendorfield value', 'Random vendorfield value'], -]); diff --git a/tests/Unit/ViewModels/TransactionViewModelTest.php b/tests/Unit/ViewModels/TransactionViewModelTest.php index f9b70ab51..c25d8c7ea 100644 --- a/tests/Unit/ViewModels/TransactionViewModelTest.php +++ b/tests/Unit/ViewModels/TransactionViewModelTest.php @@ -989,34 +989,6 @@ expect($subject->username())->toBeNull(); }); -it('should get the vendor field', function () { - $transaction = Transaction::factory()->create([]); - - DB::connection('explorer')->update('UPDATE transactions SET vendor_field = ? WHERE id = ?', ['Hello World', $transaction->id]); - - $this->subject = new TransactionViewModel($transaction->fresh()); - - expect($this->subject->vendorField())->toBe('Hello World'); -}); - -it('should fail to get the vendor field if it is empty', function () { - $transaction = Transaction::factory()->create(['vendor_field' => null]); - - $this->subject = new TransactionViewModel($transaction->fresh()); - - expect($this->subject->vendorField())->toBeNull(); -}); - -it('should fail to get the vendor field if it is empty after reading it', function () { - $transaction = Transaction::factory()->create([]); - - DB::connection('explorer')->update('UPDATE transactions SET vendor_field = ? WHERE id = ?', ['', $transaction->id]); - - $this->subject = new TransactionViewModel($transaction->fresh()); - - expect($this->subject->vendorField())->toBeNull(); -}); - it('should get the address of legacy multi signature transactions', function () { $this->subject = new TransactionViewModel(Transaction::factory()->multiSignature()->create([ 'sender_public_key' => $this->sender->public_key,