-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Grant contract-call permission UI (#3082)
- Loading branch information
Showing
17 changed files
with
231 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
'@reown/appkit-experimental': patch | ||
'@reown/appkit-scaffold-ui': patch | ||
'@apps/laboratory': patch | ||
'@reown/appkit-core': patch | ||
'@reown/appkit-ui': patch | ||
'@apps/demo': patch | ||
'@apps/gallery': patch | ||
'@reown/appkit-adapter-ethers': patch | ||
'@reown/appkit-adapter-ethers5': patch | ||
'@reown/appkit-adapter-polkadot': patch | ||
'@reown/appkit-adapter-solana': patch | ||
'@reown/appkit-adapter-wagmi': patch | ||
'@reown/appkit': patch | ||
'@reown/appkit-utils': patch | ||
'@reown/appkit-cdn': patch | ||
'@reown/appkit-common': patch | ||
'@reown/appkit-polyfills': patch | ||
'@reown/appkit-siwe': patch | ||
'@reown/appkit-wallet': patch | ||
--- | ||
|
||
Adds wui-permission-contract-call to experimental package. Adds w3m-smart-session-created-view to experimental package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const PACKAGE_VERSION = '1.1.2' | ||
export const PACKAGE_VERSION = '1.1.3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/experimental/src/smart-session/ui/permissions/wui-permission-contract-call/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { customElement, UiHelperUtil } from '@reown/appkit-ui' | ||
import { LitElement, html } from 'lit' | ||
import styles from './styles.js' | ||
import { property } from 'lit/decorators.js' | ||
|
||
@customElement('wui-permission-contract-call') | ||
export class WuiPermissionContractCall extends LitElement { | ||
// -- State & Properties --------------------------------- // | ||
public static override styles = styles | ||
|
||
@property({ type: Array }) public functions?: { functionName: string }[] = [] | ||
@property({ type: String }) public contractAddress?: `0x${string}` | ||
@property({ type: Number }) public expiry?: number | ||
|
||
// -- Render -------------------------------------------- // | ||
public override render() { | ||
if (!this.contractAddress || !this.expiry) { | ||
return null | ||
} | ||
|
||
return html` | ||
<wui-flex flexDirection="column" padding=${['l', '0', '0', '0']} alignItems="center"> | ||
<wui-details-group> | ||
<wui-details-group-item name="Type"> | ||
<wui-text variant="paragraph-400" color="fg-100"> Contract Call </wui-text> | ||
</wui-details-group-item> | ||
<wui-details-group-item name="Contract"> | ||
<wui-text variant="paragraph-400" color="fg-100"> | ||
${UiHelperUtil.getTruncateString({ | ||
string: this.contractAddress, | ||
truncate: 'middle', | ||
charsStart: 4, | ||
charsEnd: 4 | ||
})} | ||
</wui-text> | ||
</wui-details-group-item> | ||
<wui-details-group-item name="Functions"> | ||
<wui-text variant="paragraph-400" color="fg-100"> | ||
${this.functions?.map(f => f.functionName).join(', ')} | ||
</wui-text> | ||
</wui-details-group-item> | ||
<wui-flex justifyContent="space-between"> | ||
<wui-text color="fg-200">Duration</wui-text> | ||
<wui-flex flexDirection="column" alignItems="flex-end" gap="s"> | ||
<wui-text variant="paragraph-400" color="fg-100"> | ||
~ ${Math.round((1000 * this.expiry - Date.now()) / 1000 / 3600)} hours | ||
</wui-text> | ||
<wui-text variant="tiny-600" color="fg-300"> | ||
Expiring ${new Date(1000 * this.expiry).toDateString()} | ||
</wui-text> | ||
</wui-flex> | ||
</wui-flex> | ||
</wui-details-group> | ||
</wui-flex> | ||
` | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'wui-permission-contract-call': WuiPermissionContractCall | ||
} | ||
|
||
namespace JSX { | ||
interface IntrinsicElements { | ||
'wui-permission-contract-call': Partial<WuiPermissionContractCall> | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ages/experimental/src/smart-session/ui/permissions/wui-permission-contract-call/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { css } from 'lit' | ||
|
||
// First wui-flex should be width: 100% | ||
export default css` | ||
:host { | ||
width: 100%; | ||
} | ||
wui-flex { | ||
width: 100%; | ||
} | ||
` |
82 changes: 82 additions & 0 deletions
82
packages/experimental/src/smart-session/ui/views/w3m-smart-session-created-view/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { customElement } from '@reown/appkit-ui' | ||
import { CoreHelperUtil, RouterController } from '@reown/appkit-core' | ||
import { LitElement, html } from 'lit' | ||
import styles from './styles.js' | ||
import { NavigationUtil } from '@reown/appkit-common' | ||
|
||
@customElement('w3m-smart-session-created-view') | ||
export class W3mSmartSessionCreatedView extends LitElement { | ||
public static override styles = styles | ||
|
||
// -- Render -------------------------------------------- // | ||
public override render() { | ||
return html` | ||
<wui-flex | ||
flexDirection="column" | ||
alignItems="center" | ||
gap="xxl" | ||
.padding=${['0', '0', 'l', '0'] as const} | ||
> | ||
${this.onboardingTemplate()} | ||
<wui-link | ||
@click=${() => { | ||
CoreHelperUtil.openHref(NavigationUtil.URLS.FAQ, '_blank') | ||
}} | ||
> | ||
What's a Smart Session? | ||
</wui-link> | ||
${this.buttonsTemplate()} | ||
</wui-flex> | ||
` | ||
} | ||
|
||
// -- Private ------------------------------------------- // | ||
private onboardingTemplate() { | ||
return html` <wui-flex | ||
flexDirection="column" | ||
gap="xxl" | ||
alignItems="center" | ||
.padding=${['0', 'xxl', '0', 'xxl'] as const} | ||
> | ||
<wui-flex gap="s" alignItems="center" justifyContent="center"> | ||
<wui-icon-box | ||
size="xl" | ||
iconcolor="fg-100" | ||
backgroundcolor="inverse-100" | ||
icon="clock" | ||
background="opaque" | ||
></wui-icon-box> | ||
</wui-flex> | ||
<wui-flex flexDirection="column" alignItems="center" gap="s"> | ||
<wui-text align="center" variant="medium-600" color="fg-100"> | ||
Smart Session created successfully | ||
</wui-text> | ||
<wui-text align="center" variant="paragraph-400" color="fg-100"> | ||
You can manage your session from your account settings. | ||
</wui-text> | ||
</wui-flex> | ||
</wui-flex>` | ||
} | ||
|
||
private buttonsTemplate() { | ||
return html`<wui-flex | ||
.padding=${['0', '2l', '0', '2l'] as const} | ||
gap="s" | ||
class="continue-button-container" | ||
> | ||
<wui-button fullWidth size="lg" borderRadius="xs" @click=${this.redirectToAccount.bind(this)}> | ||
Got it! | ||
</wui-button> | ||
</wui-flex>` | ||
} | ||
|
||
private redirectToAccount() { | ||
RouterController.replace('Account') | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'w3m-smart-session-created-view': W3mSmartSessionCreatedView | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/experimental/src/smart-session/ui/views/w3m-smart-session-created-view/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { css } from 'lit' | ||
|
||
export default css` | ||
.continue-button-container { | ||
width: 100%; | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.