Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Oct 15, 2024
1 parent 851712d commit c25df65
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ext-gmp": "*",
"ext-json": "*",
"ext-openssl": "*",
"enjin/platform-core": "dev-PLA-2038",
"enjin/platform-core": "*",
"phrity/websocket": "^1.0",
"rebing/graphql-laravel": "^9.2",
"rector/rector": "^1.0",
Expand Down Expand Up @@ -82,5 +82,5 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": false
}
5 changes: 1 addition & 4 deletions src/GraphQL/Mutations/DispatchMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public function resolve(
) {
DB::beginTransaction();
$encodedCall = static::getFuelTankCall($this->getMethodName(), $args);

$transaction = $this->storeTransaction($args, $encodedCall);

DB::commit();

return Transaction::lazyLoadSelectFields($transaction, $resolveInfo);
Expand Down Expand Up @@ -132,7 +130,6 @@ public static function getEncodedCall($args)

public static function getFuelTankCall($method, $args, ?string $rawCall = null): string
{
$method = isRunningLatest() ? "{$method}V1010" : $method;
$paysRemainingFee = Arr::get($args, 'paysRemainingFee');

$encodedCall = TransactionSerializer::encode($method, static::getEncodableParams(
Expand All @@ -143,7 +140,7 @@ public static function getFuelTankCall($method, $args, ?string $rawCall = null):
$encodedCall .= $rawCall ?: static::getEncodedCall($args);

return $encodedCall . TransactionSerializer::encodeRaw(
isRunningLatest() ? 'OptionDispatchSettingsV1010' : 'OptionDispatchSettings',
'OptionDispatchSettings',
['option' => $paysRemainingFee === null ? null :
[
'useNoneOrigin' => false,
Expand Down
3 changes: 2 additions & 1 deletion src/GraphQL/Mutations/MutateFuelTankMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Enjin\BlockchainTools\HexConverter;
use Enjin\Platform\FuelTanks\Enums\CoveragePolicy;
use Enjin\Platform\FuelTanks\GraphQL\Traits\HasFuelTankValidationRules;
use Enjin\Platform\FuelTanks\Rules\FuelTankExists;
use Enjin\Platform\FuelTanks\Services\Blockchain\Implemetations\Substrate;
Expand Down Expand Up @@ -103,7 +104,7 @@ public static function getEncodableParams(...$params): array
{
$tankId = Arr::get($params, 'tankId', Account::daemonPublicKey());
$userAccount = Arr::get($params, 'userAccount');
$coveragePolicy = Arr::get($params, 'coveragePolicy');
$coveragePolicy = is_string($coverage = Arr::get($params, 'coveragePolicy')) ? CoveragePolicy::getEnumCase($coverage) : $coverage;
$accountRules = Arr::get($params, 'accountRules');

return [
Expand Down
21 changes: 14 additions & 7 deletions src/GraphQL/Types/Input/FuelTankMutationInputType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,29 @@ public function attributes(): array
public function fields(): array
{
return [
'reservesExistentialDeposit' => [
'type' => GraphQL::type('Boolean'),
'description' => __('enjin-platform-fuel-tanks::type.fuel_tank.field.reservesExistentialDeposit'),
],
'reservesAccountCreationDeposit' => [
'type' => GraphQL::type('Boolean'),
'description' => __('enjin-platform-fuel-tanks::type.fuel_tank.field.reservesAccountCreationDeposit'),
],
'providesDeposit' => [
'type' => GraphQL::type('Boolean'),
'description' => __('enjin-platform-fuel-tanks::type.fuel_tank.field.providesDeposit'),
'coveragePolicy' => [
'type' => GraphQL::type('CoveragePolicy'),
'description' => __('enjin-platform-fuel-tanks::type.fuel_tank.field.coveragePolicy'),
],
'accountRules' => [
'type' => GraphQL::type('AccountRuleInputType'),
'description' => __('enjin-platform-fuel-tanks::input_type.account_rule.description'),
],
// Deprecated
'reservesExistentialDeposit' => [
'type' => GraphQL::type('Boolean'),
'description' => __('enjin-platform-fuel-tanks::type.fuel_tank.field.reservesExistentialDeposit'),
'deprecationReason' => '',
],
'providesDeposit' => [
'type' => GraphQL::type('Boolean'),
'description' => __('enjin-platform-fuel-tanks::type.fuel_tank.field.providesDeposit'),
'deprecationReason' => '',
],
];
}
}
2 changes: 1 addition & 1 deletion tests/Feature/GraphQL/Mutations/CreateFuelTankTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function test_it_will_fail_with_invalid_parameter_name(): void
FuelTank::factory()->create([
'name' => $data['name'],
'public_key' => $data['account'],
'owner_wallet_id' => $this->wallet->id
'owner_wallet_id' => $this->wallet->id,
]);

$response = $this->graphql($this->method, $data, true);
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/GraphQL/Mutations/MutateFuelTankTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function test_it_can_mutate_fuel_tank(): void

$blockchainService = resolve(Substrate::class);
$data['userAccount'] = $blockchainService->getUserAccountManagementParams(Arr::get($data, 'mutation'));
$data['providesDeposit'] = Arr::get($data, 'mutation.providesDeposit');
$data['coveragePolicy'] = Arr::get($data, 'mutation.coveragePolicy');
$data['accountRules'] = $blockchainService->getAccountRulesParams(Arr::get($data, 'mutation'));

$this->assertEquals(
Expand All @@ -43,7 +43,7 @@ public function test_it_can_skip_validation(): void

$blockchainService = resolve(Substrate::class);
$params['userAccount'] = $blockchainService->getUserAccountManagementParams(Arr::get($params, 'mutation'));
$params['providesDeposit'] = Arr::get($params, 'mutation.providesDeposit');
$params['coveragePolicy'] = Arr::get($params, 'mutation.coveragePolicy');
$params['accountRules'] = $blockchainService->getAccountRulesParams(Arr::get($params, 'mutation'));

$this->assertEquals(
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/GraphQL/Mutations/RemoveAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function test_it_can_remove_account(): void
$this->method,
$params = ['tankId' => $this->tank->public_key, 'userId' => $this->account]
);
ray($response);

$this->assertEquals(
$response['encodedData'],
Expand Down

0 comments on commit c25df65

Please sign in to comment.