Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-2058] Update token name in DB after token mutation. #298

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static function getEncodableParams(...$params): array
'collectionId' => gmp_init(Arr::get($params, 'collectionId', 0)),
'tokenId' => gmp_init(Arr::get($params, 'tokenId', 0)),
'mutation' => [
'behavior' => is_array($behavior) ? ['NoMutation' => null] : ['SomeMutation' => $behavior?->toEncodable()],
'behavior' => (is_array($behavior) || !isset($behavior)) ? ['NoMutation' => null] : ['SomeMutation' => $behavior?->toEncodable()],
'listingForbidden' => Arr::get($params, 'listingForbidden'),
'anyoneCanInfuse' => Arr::get($params, 'anyoneCanInfuse'),
'name' => ($name = Arr::get($params, 'name')) ? HexConverter::stringToHexPrefixed($name) : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function run(): void
$attributes['listing_forbidden'] = $this->event->listingForbidden;
}

if ($this->event->tokenName != null) {
$attributes['name'] = $this->event->tokenName;
}

if ($this->event->behavior === 'SomeMutation') {
$attributes['is_currency'] = $this->event->isCurrency;
$attributes['royalty_wallet_id'] = null;
Expand Down
19 changes: 17 additions & 2 deletions tests/Unit/EncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public function test_it_can_encode_mutate_token()

$callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true);
$this->assertEquals(
"0x{$callIndex}b67a0300fd030100000000",
"0x{$callIndex}b67a0300fd0300000000",
$data
);
}
Expand Down Expand Up @@ -511,7 +511,7 @@ public function test_it_can_encode_mutate_token_with_listing_true()

$callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true);
$this->assertEquals(
"0x{$callIndex}b67a0300fd03010001010000",
"0x{$callIndex}b67a0300fd030001010000",
$data
);
}
Expand All @@ -531,6 +531,21 @@ public function test_it_can_encode_mutate_token_with_is_currency_true()
);
}

public function test_it_can_encode_mutate_token_with_name()
{
$data = TransactionSerializer::encode('MutateToken', MutateTokenMutation::getEncodableParams(
collectionId: '57005',
tokenId: '255',
name: 'test_name',
));

$callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true);
$this->assertEquals(
"0x{$callIndex}b67a0300fd030000000124746573745f6e616d65",
$data
);
}

public function test_it_can_encode_batch_create_token()
{
$recipient = [
Expand Down
Loading