Portkey-Wallet / react-native-sdk

1 stars 1 forks source link

Support to get token list #120

Open thiendangvan opened 4 months ago

thiendangvan commented 4 months ago

Hi, we need to show the list of tokens in our app, I've tried the getAssetsInfo API but get nothing. could u add an API to get tokens like below?

image

API log

url : https://aa-portkey.portkey.finance/api/app/user/assets/searchUserAssets;
response : <NSHTTPURLResponse: 0x600001a6f500> { URL:
https://aa-portkey.portkey.finance/api/app/user/assets/searchUserAssets } { Status Code: 200,
Headers {
"Access-Control-Allow-Origin" =     (
"*"
);
"Alt-Svc" =     (
"h3=\":443\"; ma=86400"
);
"Content-Encoding" =     (
br
);
"Content-Type" =     (
"application/json; charset=utf-8"
);
Date =     (
"Thu, 02 May 2024 12:42:37 GMT"
);
Server =     (
cloudflare
);
"Strict-Transport-Security" =     (
"max-age=15552000; includeSubDomains; preload"
);
Vary =     (
"Accept-Encoding"
);
Via =     (
"1.1 google"
);
"access-control-allow-credentials" =     (
true
);
"access-control-allow-headers" =     (
"recaptchatoken,version,Authorization,Accept,Origin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified
 LOG  {"val": {"data": [], "totalRecordCount": 0}}
[DEVFOD] url : https://aa-portkey.portkey.finance/api/app/user/assets/searchUserAssets; data
: {
data =     (
);
totalRecordCount = 0;
}
carbon-portkey commented 4 months ago

@thiendangvan Hi, that token info that you have seen in the Portkey APP is called defaultToken info, and will be shown even the balance is 0. But it is will not be included in our API response when balance is 0. You can refer to the NetworkControllerEntity.getNetworkInfo() function for more information. There's a few more issues involved in this problem. /api/app/user/assets/searchUserAssets is an API that needs header verification, you can refer to the NetworkControllerEntity.realExecute() function for more details.

thiendangvan commented 4 months ago

@thiendangvan Hi, that token info that you have seen in the Portkey APP is called defaultToken info, and will be shown even the balance is 0. But it is will not be included in our API response when balance is 0. You can refer to the NetworkControllerEntity.getNetworkInfo() function for more information. There's a few more issues involved in this problem. /api/app/user/assets/searchUserAssets is an API that needs header verification, you can refer to the NetworkControllerEntity.realExecute() function for more details.

got it thanks @carbon-portkey, can I get the document about 2 func u mentioned? or are they in the SDK source code?

carbon-portkey commented 4 months ago

@thiendangvan Hi, that token info that you have seen in the Portkey APP is called defaultToken info, and will be shown even the balance is 0. But it is will not be included in our API response when balance is 0. You can refer to the NetworkControllerEntity.getNetworkInfo() function for more information. There's a few more issues involved in this problem. /api/app/user/assets/searchUserAssets is an API that needs header verification, you can refer to the NetworkControllerEntity.realExecute() function for more details.

got it thanks @carbon-portkey, can I get the document about 2 func u mentioned? or are they in the SDK source code?

@thiendangvan Yes, it's in this repo, please search those keywords for result.

thiendangvan commented 4 months ago

@thiendangvan Yes, it's in this repo, please search those keywords for result.

got it, thanks @carbon-portkey

thiendangvan commented 4 months ago

hi @carbon-portkey, may i know how the openResultFromExternal passes the params to the target screen? I'm trying to pass an email to the LoginPortkey component but i don't know how to get the params in this component

image
FrankFeng1116 commented 4 months ago

LoginPortkey

@thiendangvan hi, i think you can find the email params from the SignInEntryPage component if you want to open the PortkeyEntries.SIGN_IN_ENTRY page.
Here is a screenshot of the code image

FrankFeng1116 commented 4 months ago

hi @carbon-portkey, may i know how the openResultFromExternal passes the params to the target screen? I'm trying to pass an email to the LoginPortkey component but i don't know how to get the params in this component image

image Here is the code for page registration, you should find the correct registration component. PortkeyEntries.SIGN_IN_ENTRY corresponds to the SignInEntryPage component, not the LoginPortkey component

thiendangvan commented 4 months ago

LoginPortkey

@thiendangvan hi, i think you can find the email params from the SignInEntryPage component if you want to open the PortkeyEntries.SIGN_IN_ENTRY page. Here is a screenshot of the code image

@FrankFeng1116, i've tried but can't get the email from props of the SignInEntryPage, below is what i got

image
FrankFeng1116 commented 4 months ago

openResultFromExternal @thiendangvan hi, you can try using this code

login(): Promise<UnlockedWallet | null> {
return new Promise((resolve, reject) => {
this.openResultFromExternal<LoginResult>(
PortkeyEntries.SIGN_IN_ENTRY,
async res => {
if (res) {
resolve(res?.data?.walletInfo ?? null);
} else {
reject(new AccountError(1004));
}
},
{ params: { email: 'example@gmail.com' } },
);
});
}
thiendangvan commented 4 months ago

openResultFromExternal @thiendangvan hi, you can try using this code

login(): Promise<UnlockedWallet | null> {
    return new Promise((resolve, reject) => {
      this.openResultFromExternal<LoginResult>(
        PortkeyEntries.SIGN_IN_ENTRY,
        async res => {
          if (res) {
            resolve(res?.data?.walletInfo ?? null);
          } else {
            reject(new AccountError(1004));
          }
        },
        { params: { email: 'example@gmail.com' } },
      );
    });
  }

it work, thank you very much @FrankFeng1116

image
thiendangvan commented 3 months ago

hi @FrankFeng1116 , @carbon-portkey i have some questions:

  1. can I have some Portkey accounts with some tokens and NFTs on the Testnet for testing?
  2. is feasible to customize the SDK to allow login to multi-account on 1 device?
  3. Which channel can we communicate for support on the AELF Official Discord? I found the -dev-support but it seems more about aelf