Skip to content

Commit

Permalink
remove vendorfield
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley committed Nov 14, 2024
1 parent 312f2c4 commit b5765fa
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 206 deletions.
13 changes: 0 additions & 13 deletions app/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -110,8 +108,6 @@ final class Transaction extends Model
'receipt',
];

private bool|string|null $vendorFieldContent = false;

/**
* Get the indexable data array for the model.
*
Expand Down Expand Up @@ -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;
Expand Down
54 changes: 0 additions & 54 deletions app/Services/VendorField.php

This file was deleted.

13 changes: 0 additions & 13 deletions app/ViewModels/Concerns/Transaction/InteractsWithVendorField.php

This file was deleted.

2 changes: 0 additions & 2 deletions app/ViewModels/TransactionViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,7 +34,6 @@ final class TransactionViewModel implements ViewModel
use InteractsWithMultiPayment;
use InteractsWithMultiSignature;
use InteractsWithUsernames;
use InteractsWithVendorField;
use InteractsWithVotes;
use InteractsWithWallets;

Expand Down
4 changes: 0 additions & 4 deletions resources/views/app/transaction.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

<x-transaction.page.summary :transaction="$transaction" />

@if ($transaction->isTransfer() || $transaction->isMultiPayment())
<x-transaction.page.memo :transaction="$transaction" />
@endif

<x-general.page-section.confirmations :model="$transaction" />

@if ($transaction->isMultiPayment())
Expand Down
18 changes: 0 additions & 18 deletions resources/views/components/transaction/page/memo.blade.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@props(['transaction'])

@php ($vendorField = $transaction->vendorField())

<div>
{{-- Mobile --}}
<x-general.page-section.container
Expand Down
21 changes: 0 additions & 21 deletions tests/Unit/Models/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,6 @@
expect($transaction->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();

Expand Down
51 changes: 0 additions & 51 deletions tests/Unit/Services/VendorFieldTest.php

This file was deleted.

28 changes: 0 additions & 28 deletions tests/Unit/ViewModels/TransactionViewModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b5765fa

Please sign in to comment.