Skip to content

Commit

Permalink
style: resolve style guide violations
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsobries authored and actions-user committed Jul 23, 2024
1 parent 9e88081 commit ba5071f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Transactions/Builder/VoteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function votes(array $votes): self

return $this;
}

/**
* Set the unvotes to cast.
*
Expand Down
19 changes: 10 additions & 9 deletions src/Transactions/Types/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,17 @@ public function hasVendorField(): bool
private function temporarySignerSign(Buffer $transaction, PrivateKey $keys)
{
$privateKey = $keys->getHex();
$message = $transaction->getHex();
$message = $transaction->getHex();

$scriptPath = __DIR__ . '/../../../scripts';
$scriptPath = __DIR__.'/../../../scripts';

$command = escapeshellcmd("npm start --prefix $scriptPath sign $privateKey $message");

exec($command, $output, $returnVar);

if ($returnVar !== 0) {
$errorOutput = implode("\n", $output);

throw new \RuntimeException("Error running signer script: $errorOutput");
}

Expand All @@ -200,33 +201,33 @@ private function temporarySignerSign(Buffer $transaction, PrivateKey $keys)
$result = json_decode($json, true);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Error parsing JSON output: ' . json_last_error_msg());
throw new \RuntimeException('Error parsing JSON output: '.json_last_error_msg());
}

if ($result['status'] === 'success') {
return $result['signature'];
}

throw new \RuntimeException('Error signing message: ' . $result['message']);
throw new \RuntimeException('Error signing message: '.$result['message']);
}

private function temporarySignerVerify(Buffer $transaction, string $signature, string $publicKey)
{
$messageHex = Hash::sha256($transaction)->getHex();
$scriptPath = __DIR__ . '/../../../scripts';

$scriptPath = __DIR__.'/../../../scripts';

$command = escapeshellcmd("npm start --prefix $scriptPath verify $publicKey $messageHex $signature");

exec($command, $output, $returnVar);

if ($returnVar !== 0) {
$errorOutput = implode("\n", $output);

throw new \RuntimeException("Error running verifier script: $errorOutput");
}

$jsonOutput = implode("\n", $output);


if (preg_match('/\{.*\}/s', $jsonOutput, $matches)) {
$json = $matches[0];
Expand All @@ -237,13 +238,13 @@ private function temporarySignerVerify(Buffer $transaction, string $signature, s
$result = json_decode($json, true);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Error parsing JSON output: ' . json_last_error_msg());
throw new \RuntimeException('Error parsing JSON output: '.json_last_error_msg());
}

if ($result['status'] === 'success') {
return $result['isValid'];
}

throw new \RuntimeException('Error verifying signature: ' . $result['message']);
throw new \RuntimeException('Error verifying signature: '.$result['message']);
}
}
2 changes: 1 addition & 1 deletion src/Transactions/Types/Vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function serialize(array $options = []): ByteBuffer
{
$buffer = ByteBuffer::new(24);

$votes = array_key_exists('votes', $this->data['asset']) ? $this->data['asset']['votes'] : [];
$votes = array_key_exists('votes', $this->data['asset']) ? $this->data['asset']['votes'] : [];
$unvotes = array_key_exists('unvotes', $this->data['asset']) ? $this->data['asset']['unvotes'] : [];

$buffer->writeUInt8(count($votes));
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Transactions/Builder/VoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function it_should_match_fixture_passphrase()
->withNonce($fixture['data']['nonce'])
->withNetwork($fixture['data']['network'])
->sign($this->passphrase);

$this->assertTrue($builder->verify());
$this->assertSame($fixture['serialized'], Serializer::new($builder->transaction)->serialize()->getHex());

Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Transactions/Deserializers/TransferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function it_should_deserialize_the_transaction_signed_with_a_passphrase()
$this->assertSame(0, $actual->data['expiration']);
}



/** @test */
public function it_should_deserialize_the_transaction_signed_with_a_passphrase_and_vendor_field()
{
Expand Down

0 comments on commit ba5071f

Please sign in to comment.