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

Support to get token list #120

Open
thiendangvan opened this issue May 2, 2024 · 11 comments
Open

Support to get token list #120

thiendangvan opened this issue May 2, 2024 · 11 comments

Comments

@thiendangvan
Copy link

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
Copy link
Collaborator

@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
Copy link
Author

thiendangvan commented May 6, 2024

@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
Copy link
Collaborator

@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
Copy link
Author

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

got it, thanks @carbon-portkey

@thiendangvan
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Collaborator

FrankFeng1116 commented May 9, 2024

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
Copy link
Author

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
Copy link
Collaborator

FrankFeng1116 commented May 9, 2024

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: '[email protected]' } },
      );
    });
  }

@thiendangvan
Copy link
Author

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: '[email protected]' } },
      );
    });
  }

it work, thank you very much @FrankFeng1116
image

@thiendangvan
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants