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

feat: SDK Manager package #25

Merged
merged 73 commits into from
Dec 14, 2023
Merged

feat: SDK Manager package #25

merged 73 commits into from
Dec 14, 2023

Conversation

FSM1
Copy link
Contributor

@FSM1 FSM1 commented Oct 24, 2023

Description

Created minimal SDK Manager context to allow for execution of all SDK methods required to create a transfer

Related Issue Or Context

Closes: #6

How Has This Been Tested? Testing details.

Tested all state transitions using a sample widget app

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Checklist:

  • I have commented my code, particularly in hard-to-understand areas.
  • I have ensured that all acceptance criteria (or expected behavior) from issue are met
  • I have updated the documentation locally and in sygma-docs.
  • I have added tests to cover my changes.
  • I have ensured that all the checks are passing and green, I've signed the CLA bot

@FSM1 FSM1 marked this pull request as draft October 24, 2023 13:11
@FSM1 FSM1 requested review from wainola and sztok7 October 24, 2023 13:12
@FSM1 FSM1 changed the base branch from main to feat/wallet-manager-package October 24, 2023 20:50
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
@FSM1 FSM1 force-pushed the feat/sdk-manager-package branch from 1de67c8 to 3d9c8b4 Compare October 31, 2023 13:39
Copy link
Collaborator

@sztok7 sztok7 left a comment

Choose a reason for hiding this comment

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

also, is this branch branched from Nicolas' on purpose?

packages/sdk-manager/package.json Show resolved Hide resolved
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
.yarn/releases/yarn-3.6.3.cjs Outdated Show resolved Hide resolved
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
packages/sdk-manager/src/SdkManagerContext.ts Outdated Show resolved Hide resolved
packages/sdk-manager/src/types/SdkManagerState.ts Outdated Show resolved Hide resolved
sztok7
sztok7 previously requested changes Dec 7, 2023
packages/sdk-manager/src/SdkManagerContextProvider.ts Outdated Show resolved Hide resolved
packages/sdk-manager/src/interfaces/index.ts Outdated Show resolved Hide resolved
packages/widget/src/connect.ts Outdated Show resolved Hide resolved
</widget-root>
</body>

</html>
Copy link
Collaborator

Choose a reason for hiding this comment

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

empty line EOF por favor

Copy link
Collaborator

Choose a reason for hiding this comment

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

bump

packages/widget/src/connect.ts Show resolved Hide resolved
@FSM1 FSM1 requested review from wainola and sztok7 December 11, 2023 15:56
wainola
wainola previously approved these changes Dec 12, 2023
Release-As: 0.1.0
@FSM1 FSM1 dismissed sztok7’s stale review December 13, 2023 16:43

changes have been addressed

@FSM1 FSM1 merged commit f9a8793 into main Dec 14, 2023
4 checks passed
@FSM1 FSM1 deleted the feat/sdk-manager-package branch December 14, 2023 12:44
Copy link
Collaborator

@sztok7 sztok7 left a comment

Choose a reason for hiding this comment

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

same goes as for walletManager, currently this is all tightly coupled with EVM, so there'll be a refactor in Q1 2024

Comment on lines +32 to +37
if (!validEnvDomains.includes(providerChainId)) {
this.status = 'invalidSourceNetwork';
} else {
this.status = 'initialized';
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: negative logic adds a bit more cognitive load, so maybe it'd be a good idea to remove ! in the condition and switch clauses 🤷

Comment on lines +23 to +30
* <wallet-manager-context>
* <sdk-manager-context-provider>
* <your-component></your-component>
* </sdk-manager-context-provider>
* </wallet-manager-context>
*/

@customElement('sdk-manager-context-provider')
Copy link
Collaborator

Choose a reason for hiding this comment

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

it'd be good to have consistent naming with context (providers)

Comment on lines +34 to +38
walletManager?: WalletManagerController;

@provide({ context: SdkManagerContext })
@state()
sdkManager?: SdkManager;
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @wainola
when refactoring, it'd be good that both managers follow same naming convention

Comment on lines +60 to +62
if (!this.walletManager?.provider) {
throw new Error('No wallet connected');
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

currently this is repeated only twice, but if more methods will need to do these checks, it'd be good to extract them in a method

this.requestUpdate();
});

this.walletManager?.addChainChangedEventListener(async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need this async here?

</widget-root>
</body>

</html>
Copy link
Collaborator

Choose a reason for hiding this comment

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

bump

Comment on lines +20 to +24
walletManager?: WalletManagerController;

@consume({ context: SdkManagerContext, subscribe: true })
@state()
sdkManager?: SdkManager;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reason why these are optional everywhere?

Comment on lines +32 to +33
await this.walletManager?.evmWallet?.web3Provider?.getNetwork()
)?.chainId;
Copy link
Collaborator

Choose a reason for hiding this comment

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

all these optional props cause a looot of optional chaining which is a bit misleading (if they are redundant) or fragile (if everything is truly optional)

Comment on lines +110 to +120
${this.sdkManager && this.sdkManager.status === 'initialized'
? html`<button @click=${this.createTransfer}>create transfer</button>`
: undefined}
${this.sdkManager &&
this.sdkManager.status === 'transferCreated' &&
this.sdkManager.approvalTxs &&
this.sdkManager.approvalTxs.length > 0
? html`<button @click=${this.approveTokens}>approve</button>`
: undefined}
${this.sdkManager &&
this.sdkManager.status === 'approvalsCompleted' &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

all these can be shortened like previous one :/

@MakMuftic MakMuftic mentioned this pull request Jan 19, 2024
mpetrunic pushed a commit that referenced this pull request Apr 22, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>sygmaprotocol-react-widget: 0.1.0</summary>

## 0.1.0 (2024-04-19)


### Features

* base interface implementation for react package
([#61](#61))
([0f38d7c](0f38d7c))
* EmvWallet class base implementation
([74c9649](74c9649))


### Bug Fixes

* fix sygma namespace
([f9ab963](f9ab963))


### Miscellaneous Chores

* **main:** release 0.0.1
([8cff038](8cff038))
* release 0.1.0
([#101](#101))
([c8f1aed](c8f1aed))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @buildwithsygma/sygmaprotocol-widget bumped to 0.1.0
</details>

<details><summary>sygmaprotocol-widget: 0.1.0</summary>

##
[0.1.0](sygmaprotocol-widget-v0.1.0...sygmaprotocol-widget-v0.1.0)
(2024-04-19)


### Features

* action buttons v2
([#91](#91))
([5b2fbc5](5b2fbc5))
* add account balance refreshing for erc20 and evm native token
([#88](#88))
([e135edc](e135edc))
* adding token balance to amount component
([c7b6268](c7b6268))
* address to transfer
([#56](#56))
([9fa87ad](9fa87ad))
* allow bridge environment configuration
([#104](#104))
([7dd44e4](7dd44e4))
* amount input styles update
([#77](#77))
([6101005](6101005))
* base implementation of network selector for the widget component
([b04ac49](b04ac49))
* base interface implementation for react package
([#61](#61))
([0f38d7c](0f38d7c))
* base layout for widget + styles
([e259dca](e259dca))
* changes to properties names
([291e753](291e753))
* creation of mixin for property declaration and using component to
render view
([d22772e](d22772e))
* EmvWallet class base implementation
([74c9649](74c9649))
* evm and substrate wallet connection
([#72](#72))
([ccf2049](ccf2049))
* evm token transfer logic
([#95](#95))
([7ae8547](7ae8547))
* externalize wallet connect connection through props
([#94](#94))
([cc8617d](cc8617d))
* improvements on selector implementation and misc changes
([940317f](940317f))
* network selector component
([#70](#70))
([003416e](003416e))
* overlay
([#79](#79))
([751ddb1](751ddb1))
* remove wrong entrypoint for the widget
([9e0007e](9e0007e))
* removing abi definition, calling sdk function to get balance and
updating package.json file
([95b0653](95b0653))
* renaming files, improvements over style and adding the components into
the main layout
([edd4e35](edd4e35))
* reset fields after transfer is complete
([#163](#163))
([762e95a](762e95a)),
closes [#133](#133)
* SDK Manager package
([#25](#25))
([f9a8793](f9a8793))
* set destination address for EVM
([#129](#129))
([679346a](679346a))
* small modifications to amount component and connect component
([1fda019](1fda019))
* transfer status
([#89](#89))
([76c0265](76c0265))
* upon clicking on max, render max value and trigger change event
([24746f5](24746f5))
* utils functions, styles on diff file and rendering icons per chain id
([a2bc154](a2bc154))


### Bug Fixes

* add css reset
([#75](#75))
([d512f58](d512f58))
* address input not submitted on paste
([#108](#108))
([9acf7f0](9acf7f0))
* amount selector prefilled with zero
([#109](#109))
([b178429](b178429))
* bug where user could proceed with invalid destination address
([#176](#176))
([634a121](634a121)),
closes [#164](#164)
* clear wallet context on disconnect
([#152](#152))
([4a497e2](4a497e2))
* easier amount input
([#159](#159))
([8d6620e](8d6620e))
* error where start new transfer isn't working
([#126](#126))
([ca4ece0](ca4ece0))
* evm amount is now calculated as user input minus the fee
([#143](#143))
([d29771e](d29771e))
* fix sygma namespace
([f9ab963](f9ab963))
* incorrect transfer state when disconnecting wallet after transfer
completed
([#130](#130))
([359e6df](359e6df))
* input type and conditional render for token icon
([25d7db3](25d7db3))
* linter issue with style module
([edc34bb](edc34bb))
* max button rounds value
([#137](#137))
([01901e6](01901e6))
* misc fixes with icons
([#85](#85))
([fedbcd9](fedbcd9))
* prevent new lines and spaces in address input
([#81](#81))
([44a318e](44a318e))
* re-validate on account balance change
([#107](#107))
([7935f81](7935f81))
* removing log
([71f42d6](71f42d6))
* specific dispatchers either for network or token selector
([1ba9de3](1ba9de3))
* substrate address not validated bug
([#128](#128))
([74191b1](74191b1))
* switch networks and misc fixes
([#127](#127))
([db9ad8a](db9ad8a))
* Switching to a different TOKEN mapping for "From - TO" relationship is
not updated in UI if amount is inserted
([#160](#160))
([e2d16fd](e2d16fd))
* update sygma sdk version
([#82](#82))
([6d8447a](6d8447a))
* widget cloudflare deploy
([#68](#68))
([fe6c36f](fe6c36f))


### Miscellaneous Chores

* **main:** release 0.0.1
([8cff038](8cff038))
* release 0.1.0
([#101](#101))
([c8f1aed](c8f1aed))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
wainola pushed a commit that referenced this pull request Apr 22, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>sygmaprotocol-react-widget: 0.1.0</summary>

## 0.1.0 (2024-04-19)


### Features

* base interface implementation for react package
([#61](#61))
([0f38d7c](0f38d7c))
* EmvWallet class base implementation
([74c9649](74c9649))


### Bug Fixes

* fix sygma namespace
([f9ab963](f9ab963))


### Miscellaneous Chores

* **main:** release 0.0.1
([8cff038](8cff038))
* release 0.1.0
([#101](#101))
([c8f1aed](c8f1aed))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @buildwithsygma/sygmaprotocol-widget bumped to 0.1.0
</details>

<details><summary>sygmaprotocol-widget: 0.1.0</summary>

##
[0.1.0](sygmaprotocol-widget-v0.1.0...sygmaprotocol-widget-v0.1.0)
(2024-04-19)


### Features

* action buttons v2
([#91](#91))
([5b2fbc5](5b2fbc5))
* add account balance refreshing for erc20 and evm native token
([#88](#88))
([e135edc](e135edc))
* adding token balance to amount component
([c7b6268](c7b6268))
* address to transfer
([#56](#56))
([9fa87ad](9fa87ad))
* allow bridge environment configuration
([#104](#104))
([7dd44e4](7dd44e4))
* amount input styles update
([#77](#77))
([6101005](6101005))
* base implementation of network selector for the widget component
([b04ac49](b04ac49))
* base interface implementation for react package
([#61](#61))
([0f38d7c](0f38d7c))
* base layout for widget + styles
([e259dca](e259dca))
* changes to properties names
([291e753](291e753))
* creation of mixin for property declaration and using component to
render view
([d22772e](d22772e))
* EmvWallet class base implementation
([74c9649](74c9649))
* evm and substrate wallet connection
([#72](#72))
([ccf2049](ccf2049))
* evm token transfer logic
([#95](#95))
([7ae8547](7ae8547))
* externalize wallet connect connection through props
([#94](#94))
([cc8617d](cc8617d))
* improvements on selector implementation and misc changes
([940317f](940317f))
* network selector component
([#70](#70))
([003416e](003416e))
* overlay
([#79](#79))
([751ddb1](751ddb1))
* remove wrong entrypoint for the widget
([9e0007e](9e0007e))
* removing abi definition, calling sdk function to get balance and
updating package.json file
([95b0653](95b0653))
* renaming files, improvements over style and adding the components into
the main layout
([edd4e35](edd4e35))
* reset fields after transfer is complete
([#163](#163))
([762e95a](762e95a)),
closes [#133](#133)
* SDK Manager package
([#25](#25))
([f9a8793](f9a8793))
* set destination address for EVM
([#129](#129))
([679346a](679346a))
* small modifications to amount component and connect component
([1fda019](1fda019))
* transfer status
([#89](#89))
([76c0265](76c0265))
* upon clicking on max, render max value and trigger change event
([24746f5](24746f5))
* utils functions, styles on diff file and rendering icons per chain id
([a2bc154](a2bc154))


### Bug Fixes

* add css reset
([#75](#75))
([d512f58](d512f58))
* address input not submitted on paste
([#108](#108))
([9acf7f0](9acf7f0))
* amount selector prefilled with zero
([#109](#109))
([b178429](b178429))
* bug where user could proceed with invalid destination address
([#176](#176))
([634a121](634a121)),
closes [#164](#164)
* clear wallet context on disconnect
([#152](#152))
([4a497e2](4a497e2))
* easier amount input
([#159](#159))
([8d6620e](8d6620e))
* error where start new transfer isn't working
([#126](#126))
([ca4ece0](ca4ece0))
* evm amount is now calculated as user input minus the fee
([#143](#143))
([d29771e](d29771e))
* fix sygma namespace
([f9ab963](f9ab963))
* incorrect transfer state when disconnecting wallet after transfer
completed
([#130](#130))
([359e6df](359e6df))
* input type and conditional render for token icon
([25d7db3](25d7db3))
* linter issue with style module
([edc34bb](edc34bb))
* max button rounds value
([#137](#137))
([01901e6](01901e6))
* misc fixes with icons
([#85](#85))
([fedbcd9](fedbcd9))
* prevent new lines and spaces in address input
([#81](#81))
([44a318e](44a318e))
* re-validate on account balance change
([#107](#107))
([7935f81](7935f81))
* removing log
([71f42d6](71f42d6))
* specific dispatchers either for network or token selector
([1ba9de3](1ba9de3))
* substrate address not validated bug
([#128](#128))
([74191b1](74191b1))
* switch networks and misc fixes
([#127](#127))
([db9ad8a](db9ad8a))
* Switching to a different TOKEN mapping for "From - TO" relationship is
not updated in UI if amount is inserted
([#160](#160))
([e2d16fd](e2d16fd))
* update sygma sdk version
([#82](#82))
([6d8447a](6d8447a))
* widget cloudflare deploy
([#68](#68))
([fe6c36f](fe6c36f))


### Miscellaneous Chores

* **main:** release 0.0.1
([8cff038](8cff038))
* release 0.1.0
([#101](#101))
([c8f1aed](c8f1aed))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

Create SDK Manager package: Evm to Evm
3 participants