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

Update typescript examples #539

Merged
merged 11 commits into from
Dec 24, 2020
Merged

Update typescript examples #539

merged 11 commits into from
Dec 24, 2020

Conversation

segfaultxavi
Copy link
Collaborator

@segfaultxavi segfaultxavi commented Dec 1, 2020

Mostly adding epochAdjustment to all transaction.create() calls
but there are a few other tweaks too.

Fixes #538

@@ -28,11 +28,11 @@ const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const restrictionHttp = repositoryFactory.createRestrictionAccountRepository();

restrictionHttp.getAccountRestrictions(address)
.subscribe((accountRestrictions) => {
.subscribe((accountRestrictions: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be the actual type rather than any?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What is the actual type? Typescript is still a bit obscure to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

so it should be the method's return type. AccountRestrictions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm afraid my typescript is not strong enough. I have tried with AccountRestrictions and AccountRestrictions[] and both failed. Unless you give me more hints, I think I'll use any (which is what symbol-cli does).

Copy link
Contributor

Choose a reason for hiding this comment

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

it should be AccountRestrictions as the ts sdk defined. what errors have you got?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After changing any to AccountRestrictions and adding AccountRestrictions to the import line:

restriction/GettingAccountRestrictions.ts:32:29 - error TS2339: Property 'length' does not exist on type 'AccountRestrictions'.

32     if (accountRestrictions.length > 0) {
                               ~~~~~~

restriction/GettingAccountRestrictions.ts:34:10 - error TS2339: Property 'filter' does not exist on type 'AccountRestrictions'.

34         .filter((accountRestriction: any) => accountRestriction.values.length > 0)
            ~~~~~~

@segfaultxavi segfaultxavi force-pushed the update-ts-examples branch 9 times, most recently from 0c417f3 to 76a01e3 Compare December 11, 2020 09:43
@segfaultxavi segfaultxavi linked an issue Dec 23, 2020 that may be closed by this pull request
segfaultxavi and others added 7 commits December 24, 2020 10:09
Mostly adding epochAdjustment to all transaction.create() calls
but there are a few other tweaks too.
Using async await instead of observable's methods for simplicity
Removed hardcoded deadline, network type, generation hash, currency information
Added eslint and prettier (but not exectued yet)
This is just the result of running "npm run style:fix".
No functional changes.
Install node 12
Update sdk version to release 0.22.0
No functional changes.
So that all examples fit in the guides without requiring
scrollbars, for any screen layout.
Now this is enforced by Travis so there's no risk of
breaking it in the future.
These are autogenerated using tsc for now.
@segfaultxavi segfaultxavi merged commit 2956883 into main Dec 24, 2020
@segfaultxavi segfaultxavi deleted the update-ts-examples branch December 24, 2020 12:16
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.

[Guides] Add dynamic generationHash and networkType Typescript examples are outdated
3 participants