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

Javascript sdk migration #617

Closed
wants to merge 10 commits into from
Closed

Javascript sdk migration #617

wants to merge 10 commits into from

Conversation

tomijaga
Copy link

@tomijaga tomijaga commented Apr 12, 2021

Resolves: #585

@angle943 I've made all the necessary migrations using the js sdk

Tomi and others added 7 commits April 1, 2021 15:30
Migrated Account Functions to use Js SDK
Updated bank api calls to use the js sdk
* Validator Api calls made with js sdk, Fixed config types and test

* add memo

* memo to tables

* fixed all errors with updated sdk

* included comment for payment handler

Co-authored-by: Justin Kim <justinkim943@gmail.com>
@angle943
Copy link
Contributor

@tomijaga can you resolve the merge conflict?

@tomijaga
Copy link
Author

tomijaga commented Apr 13, 2021

@angle943 I already did that. I just don't have the rights to merge it.
Here's the PR: #618

tomijaga and others added 2 commits April 13, 2021 10:02
* Validator Api calls made with js sdk, Fixed config types and test

* add memo

* memo to tables

* fixed all errors with updated sdk

* included comment for payment handler

* add memo (#615)

* add memo

* memo to tables

* IP update

Co-authored-by: Bucky <buckyroberts@gmail.com>

* 1.0.0-alpha.45

Co-authored-by: Justin Kim <justinkim943@gmail.com>
Co-authored-by: Bucky <buckyroberts@gmail.com>
@zinoadidi
Copy link

Conflicts merged @angle943

@angle943
Copy link
Contributor

@zinoadidi @tomijaga thanks guys. Please give me about a week to review this. This week I will be very busy moving in to my new home. I will be free starting next week

Copy link

@sno2 sno2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, here's my comments on a few things.

Comment on lines 56 to 62
const checkPrivateSigningKey = (publicKey: string, privateKey: string): boolean => {
try {
const {publicKeyHex} = getKeyPairFromSigningKeyHex(privateKey);
return publicKeyHex === publicKey;
const {accountNumberHex} = new Account(privateKey);
return accountNumberHex === publicKey;
} catch (error) {
return false;
}
Copy link

@sno2 sno2 Apr 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly migrate to using Account.isValidPair static method as it does exactly as this helper does except you need the signing key first and the account number second. Although, the js SDK does not include a try-catch statement which should probably be added. https://github.com/thenewboston-developers/thenewboston-js/blob/development/src/account.ts#L49-L56

Update: sent an Issue and a PR to thenewboston-js repo to include a try-catch statement in Account.isValidPair.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a PR for this at #619

const {data: rawData} = await axios.get<RawBankConfig>(`${address}/config`, {timeout: AXIOS_TIMEOUT_MS});
const data = sanitizePortFieldFromRawBankConfig(rawData);
const rawData = await new Bank(address).getConfig();
const data = sanitizePortFieldFromRawBankConfig(rawData as RawBankConfig);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the as statement even necessary? I think TypeScript should be accepting the SDK's type also as long as no property types conflict and they shouldn't be.

Copy link
Author

@tomijaga tomijaga Apr 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's coz the NodeType in the account manager repo is an enum while in the js repo it a type that accepts multiple values ("Bank" | "Primary_Validator" )

Copy link
Author

@tomijaga tomijaga Apr 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make changes in the js repo to fix this problem

* Account.isValidPair method used in repo

* correct implementation of Account.isValidPair method

* Removed unnecessary use of 'as' keyword
@zinoadidi
Copy link

@tomijaga some conflicts in package lock. Try to fix locally and make a PR

@zinoadidi
Copy link

@angle943 still waiting

@mrbusysky
Copy link

Could likely close this now since the new wallet is being made currently for the beta.

@zinoadidi zinoadidi closed this Nov 23, 2021
@zinoadidi
Copy link

Closing in favour of beta

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

Successfully merging this pull request may close these issues.

Migrate over to using thenewboston-js repo
5 participants