Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Conversation

@aeharvlee
Copy link
Contributor

Proposed changes

This PR is for improving SDK usability of KCT Layer in Common Architecture

Improving SDK usability means providing users with a similar development experience
no matter what programming language the SDK is implemented in.

Each layer declared in Common Architecture should be accessed via caver.
KCT Layer in Common Architecture should be accessed via caver.kct.

In caver-js, all of static methods declared in KIP* classes are accessed via caver.kct.kip*
e.g., caver.kct.kip7.detectInterface(), caver.kct.kip17.deploy(), etc…

To make similar development experiences in caver-java, I added some wrapper classes.

1. Add Wrappers for KIP7, KIP17, KIP37
By adding wrapper classes for KIP7, KIP17, KIP37, we can use
the static methods defined in the KIP of that type through caver.kct.kip*.

Each wrapper classes has a Caver instance as a member variable.
This allows SDK users to call static methods defined in the KIP*
without passing a Caver type instance and IWallet type instance as method parameters.

This member variable caver should be injected from KCTWrapper.

2. Add KCTWrapper and add this as a member variable of Caver class
KCTWrapper contains wrapper classes of KIP* which have static methods.

By adding this class and adding this as a member variable of Caver class,
we can use static methods declared in the KIP* through caver.kct.kip*
e.g., caver.kct.kip7.detectInterface()

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

This commit is for improving SDK usability of KCT Layer in Common Architecture

Improving SDK usability means providing users with a similar development experience
no matter what programming language the SDK is implemented in.

Each layer declared in Common Architecture should be accessed via caver.
KCT Layer in Common Architecture should be accessed via `caver.kct`.

In caver-js, all of static methods declared in `KIP*` classes are accessed via `caver.kct.kip*`
e.g., `caver.kct.kip7.detectInterface()`, `caver.kct.kip17.deploy()`, etc…

To make similar development experiences in caver-java, I added some wrapper classes.

1. Add Wrappers for KIP7, KIP17, KIP37
By adding wrapper classes for KIP7, KIP17, KIP37, we can use
the static methods defined in the KIP of that type through `caver.kct.kip*`.

Each wrapper classes has a Caver instance as a member variable.
This allows SDK users to call static methods defined in the KIP*
without passing a Caver type instance and IWallet type instance as method parameters.

This member variable caver should be injected from KCTWrapper.

2. Add KCTWrapper and add this as a member variable of Caver class
KCTWrapper contains wrapper classes of KIP* which have static methods.

By adding this class and adding this as a member variable of Caver class,
we can use static methods declared in the KIP* through `caver.kct.kip*`
e.g., `caver.kct.kip7.detectInterface()`
@aeharvlee aeharvlee requested a review from sirano11 April 30, 2021 09:59
@aeharvlee aeharvlee self-assigned this Apr 30, 2021
* }</pre>
*
* @param contractAddress
* @return
Copy link

Choose a reason for hiding this comment

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

Suggested change
* @return
* @return Map&lt;String, Boolean&gt;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sirano11
Thanks for your feedback.
I'll check whether there are other missing types at @return and if there are, I'll update missed types.


/**
* Deploy a KIP-17 contract.
* It must add deployer's keyring in caver.wallet.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* It must add deployer's keyring in caver.wallet.
* The deployer's keyring should be existed in `caver.wallet`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jimni1222
Thanks for your feedback.
I'll update comments of KIP*Wrappers.

public KIP17Wrapper(Caver caver) {
this.caver = caver;
}

Copy link

Choose a reason for hiding this comment

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

@aeharvlee Don't we need to add a create()?

public KIP37Wrapper(Caver caver) {
this.caver = caver;
}

Copy link

Choose a reason for hiding this comment

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

@aeharvlee Don't we need to add a create()?

public KIP7Wrapper(Caver caver) {
this.caver = caver;
}

Copy link

Choose a reason for hiding this comment

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

@aeharvlee Don't we need to add a create()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sirano11
I checked the KCT Layer in Common Architecture and yeah there was create().
I think we need to add create() for KIP7, KIP17, and KIP37.
Sorry to missed it T_T.

I'll add implementation about it.
Thanks for your feedback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sirano11
Hi, I added create() methods for KIP*Wrapper classes based on your feedback and KCT Layer Reference.

Here is the related commit :)
Add create methods in KIP*Wrapper

Thanks for your feedback again.

aeharvlee added 2 commits May 3, 2021 10:23
KIP7, KIP17, and KIP37 have `create()` methods in Common Architecture Design.
Because The Wrapper classes were added for implementing Common Architecture, they must have `create()` method in them.
Copy link
Contributor

@jimni1222 jimni1222 left a comment

Choose a reason for hiding this comment

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

LGTM =)!!!

@aeharvlee aeharvlee merged commit e2d5167 into klaytn:dev May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants