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: display amount to be received on destination #168

Merged
merged 24 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7dd44e4
feat: allow bridge environment configuration (#104)
mpetrunic Feb 21, 2024
b178429
fix: amount selector prefilled with zero (#109)
mpetrunic Feb 21, 2024
9acf7f0
fix: address input not submitted on paste (#108)
mpetrunic Feb 22, 2024
7935f81
fix: re-validate on account balance change (#107)
mpetrunic Feb 22, 2024
cc8617d
feat: externalize wallet connect connection through props (#94)
wainola Feb 22, 2024
ca4ece0
fix: error where start new transfer isn't working (#126)
wainola Mar 4, 2024
74191b1
fix: substrate address not validated bug (#128)
wainola Mar 5, 2024
f65f372
chore: remove lit warnings (#131)
mpetrunic Mar 7, 2024
359e6df
fix: incorrect transfer state when disconnecting wallet after transfe…
mpetrunic Mar 11, 2024
9122c07
chore: add codeowners (#142)
mpetrunic Mar 13, 2024
db9ad8a
fix: switch networks and misc fixes (#127)
wainola Mar 13, 2024
679346a
feat: set destination address for EVM (#129)
Lykhoyda Mar 14, 2024
01901e6
fix: max button rounds value (#137)
Lykhoyda Mar 18, 2024
4a497e2
fix: clear wallet context on disconnect (#152)
Lykhoyda Mar 28, 2024
e2d16fd
fix: Switching to a different TOKEN mapping for "From - TO" relations…
saadahmsiddiqui Apr 3, 2024
ec154be
feat: Transfer UI page (#144)
mj52951 Apr 3, 2024
8d6620e
fix: easier amount input (#159)
mpetrunic Apr 3, 2024
d29771e
fix: evm amount is now calculated as user input minus the fee (#143)
mpetrunic Apr 4, 2024
762e95a
feat: reset fields after transfer is complete (#163)
Lykhoyda Apr 8, 2024
0e38bff
feat: base impl for amount to receive and flag to display only comput…
wainola Apr 12, 2024
9a9c93f
chore: pr review
wainola Apr 13, 2024
47e54ca
chore: fix conflicts and rebase with dev
wainola Apr 16, 2024
6a021cc
chore: correct amount when going from sub to evm
wainola Apr 18, 2024
ed21f8b
chore: addressing last comment from Saad
wainola Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Lykhoyda @wainola @saadjhk @mpetrunic
4 changes: 0 additions & 4 deletions .github/workflows/cf-deploy-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ on:
push:
branches:
- main
paths:
- 'packages/react/**'
pull_request:
branches:
- main
paths:
- 'packages/react/**'

jobs:
deploy:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/cf-deploy-widget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ on:
push:
branches:
- main
paths:
- 'packages/widget/**'
pull_request:
branches:
- main
paths:
- 'packages/widget/**'

jobs:
deploy:
Expand Down
117 changes: 117 additions & 0 deletions examples/react-widget-app/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@

body, html {
background-color: #F5F0E9;
margin: 0;
padding: 0;
font-family: 'Inter', sans-serif;
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 500;
src: url('https://fonts.googleapis.com/css2?family=Inter:[email protected]');
}

.page{
display: flex;
}

.main{
flex: 1;
overflow: auto;
height: 100vh;
}

.centered {
display: flex;
justify-content: center;
align-items: center;
}

.sidebar{
position: relative;
height: 100vh;
width: 20%;
background-color: rgba(254, 86, 20, 0.2);
display: none;
flex-direction: column;
}

.sidebar.open{
display: flex;
}

.sidebar-title{
font-size: 2rem;
text-align: center;
color: black;
margin-top: 10%;
}

.sidebar-button {
margin-top: 1.5rem;
width: 12rem;
font-size: 1.2rem;
border: 1;
border-color: #F5F0E9;
border-radius: 4rem;
background-color: #FE5614;
color: #F5F0E9;
cursor: pointer;
}

.icon-column{
display: flex;
height: 100%;
flex-direction: column;
}

.icon-wrapper {
padding-top: 1.8rem;
flex-direction: row;
display: flex;
align-items: center;
margin: 0 auto;
}

.icon-wrapper img {
width: 2.3rem;
height: 2.3rem;
}

.icon-wrapper a {
color: black;
text-decoration: none;
font-size: 1.3rem;
margin-left: 5%;
}

.icon-wrapper a:hover {
color: white;
font-weight: bold;
}

#open-sidebar-button {
position: fixed;
top: 2rem;
left: 2rem;
cursor: pointer;
}

#open-sidebar-button img {
height: 3.2rem;
width: 3.2rem;
}

#close-icon{
position: absolute;
top: 0.5rem;
right: 0.5rem;
cursor: pointer;
}

#close-icon img{
width: 0.8rem;
height: 0.8rem;
}
55 changes: 52 additions & 3 deletions examples/react-widget-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,59 @@
import { SygmaProtocolReactWidget } from '@buildwithsygma/sygmaprotocol-react-widget'
import './App.css';
import sygmaIcon from './public/sygmaIcon.svg'
import gitHubIcon from './public/githubIcon.png'
import docsIcon from './public/docsIcon.png'
import closeIcon from './public/closeIcon.png'
import sidebarIcon from './public/sidebarIcon.png'
import { useState } from 'react';

function App() {

const [sidebarOpen, setSidebarOpen] = useState(false);

const toggleSidebar = () => {
setSidebarOpen(!sidebarOpen);
};

const obtainTokensClick = () => {
window.open("https://docs.buildwithsygma.com/environments/testnet/obtain-testnet-tokens", "_blank");
};

return (
<SygmaProtocolReactWidget />
)
}

<div className="page">
<aside className={`sidebar centered ${sidebarOpen ? 'open' : ''}`}>
{sidebarOpen && (
<div id="close-icon" onClick={toggleSidebar}>
<img src={closeIcon} alt="Close Sidebar" className="icon" />
</div>
)}
<div className="sidebar-title">Sygma Widget</div>
<div className="icon-column">
<div className="icon-wrapper">
<a href="https://buildwithsygma.com/" target="_blank"><img src={sygmaIcon} alt="Main Page" /></a>
<a href="https://buildwithsygma.com/" target="_blank"><span>Website</span></a>
</div>
<div className="icon-wrapper">
<a href="https://docs.buildwithsygma.com/" target="_blank"><img src={docsIcon} alt="Documentation"/></a>
<a href="https://docs.buildwithsygma.com/" target="_blank"><span>Docs</span></a>
</div>
<div className="icon-wrapper">
<a href="https://github.com/sygmaprotocol" target="_blank"><img src={gitHubIcon} alt="GitHub" id="github-icon"/></a>
<a href="https://github.com/sygmaprotocol" target="_blank"><span>GitHub</span></a>
</div>
<button className="sidebar-button" onClick={obtainTokensClick}>Obtain Testnet Tokens</button>
</div>
</aside>
<main className={"main centered"}>
<SygmaProtocolReactWidget />
</main>
{!sidebarOpen && (
<div id="open-sidebar-button" onClick={toggleSidebar}>
<img src={sidebarIcon} alt="Toggle Sidebar" className="icon" />
</div>
)}
</div>
)
}
export default App
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react-widget-app/src/public/docsIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/react-widget-app/src/public/sygmaIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/widget/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_BRIDGE_ENV=testnet
1 change: 1 addition & 0 deletions packages/widget/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_BRIDGE_ENV=mainnet
7 changes: 4 additions & 3 deletions packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
],
"scripts": {
"start": "yarn run dev",
"dev": "vite",
"build": "yarn run lint:types && yarn run clean && vite build",
"dev": "VITE_BRIDGE_ENV=testnet vite",
"build": "yarn run lint:types && yarn run clean && vite build --mode development",
"build:production": "yarn run lint:types && yarn run clean && vite build",
"build:preview": "yarn run clean && vite build --config vite.preview.config.ts",
"serve": "vite preview --config vite.preview.config.ts",
"clean": "rm -rf ./build",
Expand All @@ -28,7 +29,7 @@
"author": "Sygmaprotocol Product Team",
"dependencies": {
"@buildwithsygma/sygma-contracts": "^2.5.1",
"@buildwithsygma/sygma-sdk-core": "^2.7.2",
"@buildwithsygma/sygma-sdk-core": "^2.10.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
Expand Down
20 changes: 12 additions & 8 deletions packages/widget/src/components/address-input/address-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { HTMLTemplateResult } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { when } from 'lit/directives/when.js';

import type { PropertyValues } from '@lit/reactive-element';
import { validateAddress } from '../../utils';
import { BaseComponent } from '../common/base-component/base-component';

Expand All @@ -24,7 +25,7 @@ export class AddressInput extends BaseComponent {
@property({
type: String
})
network: Network = Network.EVM;
networkType: Network = Network.EVM;

@state()
errorMessage: string | null = null;
Expand All @@ -46,15 +47,18 @@ export class AddressInput extends BaseComponent {
return;
}

this.errorMessage = validateAddress(trimedValue, this.network);
this.errorMessage = validateAddress(trimedValue, this.networkType);

if (!this.errorMessage) {
void this.onAddressChange(trimedValue);
} else {
void this.onAddressChange('');
}
this.onAddressChange(trimedValue);
};

protected updated(changedProperties: PropertyValues): void {
//revalidating address on network change
if (changedProperties.has('networkType')) {
this.handleAddressChange(this.address);
}
}

render(): HTMLTemplateResult {
return html` <section class="inputAddressSection">
<div class="inputAddressContainer">
Expand All @@ -74,7 +78,7 @@ export class AddressInput extends BaseComponent {
e.preventDefault();
}
}}
@change=${(evt: Event) =>
@input=${(evt: Event) =>
this.handleAddressChange((evt.target as HTMLInputElement).value)}
></textarea>
</div>
Expand Down
1 change: 0 additions & 1 deletion packages/widget/src/components/amount-selector/index.ts

This file was deleted.

20 changes: 10 additions & 10 deletions packages/widget/src/components/common/buttons/connect-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { html } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { when } from 'lit/directives/when.js';

import { configContext, walletContext } from '../../../context';
import type { ConfigContext, WalletContext } from '../../../context';
import greenCircleIcon from '../../../assets/icons/greenCircleIcon';
import plusIcon from '../../../assets/icons/plusIcon';
import type { WalletContext } from '../../../context';
import { walletContext } from '../../../context';
import { WalletController } from '../../../controllers';
import { shortAddress } from '../../../utils';
import { BaseComponent } from '../base-component/base-component';
Expand All @@ -28,15 +28,14 @@ export class ConnectWalletButton extends BaseComponent {
})
sourceNetwork?: Domain;

@property({
type: String
})
dappUrl?: string;

@consume({ context: walletContext, subscribe: true })
@state()
private wallets!: WalletContext;

@consume({ context: configContext, subscribe: true })
@state()
private configContext!: ConfigContext;

private walletController = new WalletController(this);

updated(changedProperties: PropertyValues): void {
Expand All @@ -48,9 +47,10 @@ export class ConnectWalletButton extends BaseComponent {

private onConnectClicked = (): void => {
if (this.sourceNetwork) {
this.walletController.connectWallet(this.sourceNetwork, {
dappUrl: this.dappUrl
});
this.walletController.connectWallet(
this.sourceNetwork,
this.configContext
);
}
};

Expand Down
Loading
Loading