magic-admin-js icon indicating copy to clipboard operation
magic-admin-js copied to clipboard

getMetadataByTokenAndWallet always returns empty

Open wiredmatt opened this issue 1 year ago • 1 comments

✅ Prerequisites

  • [x] Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • [x] Are you running the latest SDK version?
  • [x] Are you reporting to the correct repository (@magic-sdk/admin)?

🐛 Description

Using the SDK's getMetadataByTokenAndWallet will always return an empty array of wallets. The API request through a plain curl call works as expected though.

magic.token.validate(token); // returns void if valid, throws if not
req.magicUser = await magic.users.getMetadataByTokenAndWallet(
  token,
  "SUI" as any // use whatever here, wallets response will always be empty.
);

What the SDK returns: image

What the API returns:

curl --request GET \
  --url 'https://api.magic.link/v1/admin/auth/user/get?issuer=did%3Aethr%3A0x2B05D3f84BeEE532A0FD92B07586EfB141C78d6B&wallet_type=SUI' \
  --header 'X-Magic-Secret-key: sk_live_changeme'

image

{
  "data": {
    "email": "[email protected]",
    "issuer": "did:ethr:0x2B05D3f84BeEE532A0FD92B07586EfB141C78d6B",
    "oauth_provider": null,
    "phone_number": null,
    "public_address": "0x2B05D3f84BeEE532A0FD92B07586EfB141C78d6B",
    "wallets": [
      {
        "network": "MAINNET",
        "public_address": "0xa5d2e18eec61c5a2224e5512ca1cb5ba16c0749d1cfe3fc6c52264b887bfaf76",
        "wallet_type": "SUI"
      }
    ]
  },
  "error_code": "",
  "message": "",
  "status": "ok"
}

[Description of the bug.]

🧩 Steps to Reproduce

  1. run magic.users.getMetadataByTokenAndWallet in a nodejs application.

🤔 Expected behavior

It should return what the HTTP API does.

😮 Actual behavior

It didn't return what the HTTP API does.

💻 Code Sample

magic.token.validate(token); // returns void if valid, throws if not
req.magicUser = await magic.users.getMetadataByTokenAndWallet(
  token,
  "SUI" as any // use whatever here, wallets response will always be empty.
);

🌎 Environment

Software Version(s)
@magic-sdk/admin
Node
yarn
Operating System

wiredmatt avatar May 12 '24 00:05 wiredmatt