XRPL-Labs/XUMM-SDK-PHP

syntax error, unexpected 'XummClientInterface' (T_STRING), expecting variable (T_VARIABLE)

Closed this issue · 14 comments

I am implementing login by XUMM wallet.
Login was successfully done and I passed payload_uuidv4 of login to backend.
Here is my backend code to fetch payload by payload_uuidv4.

<?php
  // Signature is payload_uuidv4

    public function verify(string $signature, string $address): bool
    {
        
        $xumm_credential = config('payments.xrpl');

        if(!empty($xumm_credential['api_key']) && !empty($xumm_credential['api_secret']) && config('auth.web3.xumm.enabled')){
            $sdk = new XummSdk($xumm_credential['api_key'], $xumm_credential['api_secret']);
            $payload = $sdk->getPayload($signature);

            Log::error(print_r($payload, 1));
            if (!empty($payload->payload) && $payload->payload->txType == "SignIn"){
                return true;
            }
        }
        return false;
    }

this throws the error.

[2023-06-05 11:17:45] production.ERROR: syntax error, unexpected 'XummClientInterface' (T_STRING), expecting variable (T_VARIABLE) {"exception":"[object] (ParseError(code: 0): syntax error, unexpected 'XummClientInterface' (T_STRING), expecting variable (T_VARIABLE) at /vendor/xrpl/xumm-sdk-php/src/XummSdk.php:37)

Codeline issued at XummSdk.php:37 is:
use Xrpl\XummSdkPhp\Client\XummClient as XummClientInterface;

My current PHP version is. 8.1.19. and OS is MAC.

@paulinevos Do you have a suggestion? PHP version?

Yeah, line 37 is actually something else, namely:

private readonly XummClientInterface $client;

It looks like it's tripping over the readonly keyword followed by the interface. But that was introduced in PHP 8.1 so it should be supported. Are you sure your script is running on 8.1.19? Maybe you have another runtime somewhere at a lower version?

Yes I confirmed my machine default PHP version is 8.1.19.
I used my terminal. and run command "php -v"

jasenlee@Jasens-iMac ~ % php -v               
PHP 8.1.19 (cli) (built: May 12 2023 08:29:35) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.19, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.19, Copyright (c), by Zend Technologies

web framework: Laravel 8, Monterey,

And are you using Laravel Sail or otherwise Docker? Cause if so, you're running Laravel in a container that will (likely) run a different version of PHP than on your machine. I suspect that is the case.

Or... Quite possibly your web server may address a different PHP version than your command line PATH PHP version?

Can you host a <?php phpinfo(); ?> file to see what your webserver is using?

Yes @WietseWind, that's what I suspect. Especially since he's using Laravel, and their default "getting started" documentation uses Laravel sail (which is Docker).

Exactly, @WietseWind it is actually using 7.4.21. I will check once i update to 8.1

@lee-1980 If you're using sail, you can change the version like so:

https://laravel.com/docs/10.x/sail#sail-php-versions

Closing this as I consider it resolved.

Closing this as I consider it resolved.

Thank you so much, Yes it worked well

@lee-1980 no problem! Glad it worked out

@lee-1980 no problem! Glad it worked out

Hi @paulinevos Is there any example of signing the payload using private key using XUMM PHP SDK?
I need to implement the automatic withdrawal method ,so I want to sign all withdrawal request using my wallet private key automatically.
In one word, I want to implement payment transaction by script without any browser interaction

This one I think is better answered by @WietseWind probably as I think it might be more of an API question (afaik the SDK wraps all the current API behavior)

Hi @lee-1980,

The Xumm SDK doesn't sign the transaction, the end user does. The Xumm SDK is just the helper to allow Xumm to be the broker between you and the transaction to sign.

If you want to sign transactions yourself with code, instead of having a user sign every individual transaction with an XRPL account for which they use Xumm to manage their private keys, you're looking at using the NodeJS/Python/C++ libs. to sign.

https://github.com/WietseWind/xrpl-accountlib/

There is no signing lib. for PHP.

Yours,
Wietse