Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0fffcab
RPC protect workflow acting as expected maybe some styling issues
Adamj1232 May 10, 2023
28d3959
Working as expected, added configs for rpc url and displaying protect…
Adamj1232 May 10, 2023
542e8e5
fix text color for dark mode
Adamj1232 May 10, 2023
1c3f375
Refine background colors
Adamj1232 May 10, 2023
5bb98ff
Refine verbiage and remove placeholder for link
Adamj1232 May 10, 2023
27651f1
Remove box shadow from AC section
Adamj1232 May 10, 2023
bc29036
Merge branch 'develop' into feat/private_rpc_flow
Adamj1232 May 11, 2023
4259110
Bump versions accordingly
Adamj1232 May 11, 2023
fa1d73c
Rename rpc update func
Adamj1232 May 11, 2023
6ab2884
Cleanup type prop comments
Adamj1232 May 11, 2023
bd37fa3
Refine state get in maximized
Adamj1232 May 11, 2023
6ef8c61
update modal styles
gesquinca May 12, 2023
3cc9566
Merge branch 'develop' into feat/private_rpc_flow
Adamj1232 May 12, 2023
0990e9d
Merge branch 'develop' into feat/private_rpc_flow
Adamj1232 May 12, 2023
a0ae002
Update packages/core/src/provider.ts
Adamj1232 May 12, 2023
7168c1b
Add disableProtectRPC to accountCenterInit validation
Adamj1232 May 15, 2023
e45c754
Update docs for AccountCenter diableProtectRPC
Adamj1232 May 15, 2023
25520d4
Merge in develop
Adamj1232 May 15, 2023
be704e1
Update packages/core/src/index.ts
Adamj1232 May 15, 2023
4e84d85
Add small null check for secondary tokens
Adamj1232 May 15, 2023
4e53292
Merge in develop and handle conflicts
Adamj1232 May 15, 2023
bc171b5
Merge in dev
Adamj1232 May 15, 2023
38e7f2f
Merge in dev and handle conflicts
Adamj1232 May 16, 2023
f47997f
Merge branch 'develop' into feat/private_rpc_flow
Adamj1232 May 16, 2023
6713655
Update rpc
Adamj1232 May 17, 2023
a7d272a
Update rpc again
Adamj1232 May 17, 2023
5b5d0a1
yarnit
Adamj1232 May 17, 2023
1ff5fdb
Update rpc url
Adamj1232 May 17, 2023
798a15b
Add localstore check if RPC has been added
Adamj1232 May 17, 2023
7431aac
Add dismissall of modal after confirm
Adamj1232 May 17, 2023
6b6c193
Update localstore call
Adamj1232 May 17, 2023
3c44739
Remove localstore check
Adamj1232 May 18, 2023
e062914
Update packages/core/src/views/connect/Index.svelte
Adamj1232 May 18, 2023
d62fcae
Merge branch 'develop' into feat/private_rpc_flow
Adamj1232 May 19, 2023
7bd94a5
Prettier
Adamj1232 May 19, 2023
a3ab4bb
Remove square brackets from docs
Adamj1232 May 19, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cede-store/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/cede-store",
"version": "2.0.1",
"version": "2.0.2-alpha.1",
"description": "cede.store SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -70,6 +70,6 @@
},
"dependencies": {
"@cedelabs/providers": "^0.0.7",
"@web3-onboard/common": "^2.3.2"
"@web3-onboard/common": "^2.3.3-alpha.1"
}
}
4 changes: 2 additions & 2 deletions packages/coinbase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/coinbase",
"version": "2.2.3",
"version": "2.2.4-alpha.1",
"description": "Coinbase SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -59,6 +59,6 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.6.0",
"@web3-onboard/common": "^2.3.2"
"@web3-onboard/common": "^2.3.3-alpha.1"
}
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/common",
"version": "2.3.2",
"version": "2.3.3-alpha.1",
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,11 @@ export interface Chain {
providerConnectionInfo?: ConnectionInfo
/* An optional public RPC used when adding a new chain config to the wallet */
publicRpcUrl?: string
/** An optional protected RPC URL - Defaults to Blocknative's private and
* protected RPC to allow users to update the chain RPC within their wallet,
* specifically for private RPCs that protect user transactions
*/
protectedRpcUrl?: string
/* Also used when adding a new config to the wallet */
blockExplorerUrl?: string
}
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const chainValidation = Joi.object({
icon: Joi.string(),
color: Joi.string(),
publicRpcUrl: Joi.string(),
protectedRpcUrl: Joi.string(),
blockExplorerUrl: Joi.string(),
providerConnectionInfoValidation
})
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.18.0",
"version": "2.19.0-alpha.1",
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -85,7 +85,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.3.2",
"@web3-onboard/common": "^2.3.3-alpha.1",
"bignumber.js": "^9.0.0",
"bnc-sdk": "^4.6.7",
"bowser": "^2.11.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export const STORAGE_KEYS = {
}

export const MOBILE_WINDOW_WIDTH = 768

export const BN_PROTECT_RPC_URL = 'https://www.api.blocknative.com/protect'
7 changes: 7 additions & 0 deletions packages/core/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@
"description": "Are you sure that you would like to disconnect all your wallets?",
"confirm": "Confirm",
"cancel": "Cancel"
},
"confirmTransactionProtection": {
"heading": "Enable Transaction Protection",
"description": "Protect RPC Endpoints hide your transactions from front-running and sandwich bots to reduce unfavorable transaction settlement from slippage.",
"enable": "Enable",
"dismiss": "Dismiss"
}
},
"accountCenter": {
"connectAnotherWallet": "Connect another Wallet",
"disconnectAllWallets": "Disconnect all Wallets",
"currentNetwork": "Current Network",
"enableTransactionProtection": "Enable Transaction Protection",
"appInfo": "App Info",
"learnMore": "Learn More",
"gettingStartedGuide": "Getting Started Guide",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/icons/shield-icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default `<svg width="14" height="18" viewBox="0 0 14 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.99998 17.3125C5.05553 16.8264 3.45831 15.6979 2.20831 13.9271C0.958313 12.1562 0.333313 10.2153 0.333313 8.10417V3.14583L6.99998 0.645833L13.6666 3.14583V8.10417C13.6666 10.2153 13.0416 12.1562 11.7916 13.9271C10.5416 15.6979 8.94442 16.8264 6.99998 17.3125ZM5.12498 12.3333H8.87498C9.05553 12.3333 9.20484 12.2743 9.3229 12.1562C9.44095 12.0382 9.49998 11.8889 9.49998 11.7083V8.79167C9.49998 8.61111 9.44095 8.46181 9.3229 8.34375C9.20484 8.22569 9.05553 8.16667 8.87498 8.16667H8.66665V7.33333C8.66665 6.875 8.50345 6.48264 8.17706 6.15625C7.85067 5.82986 7.45831 5.66667 6.99998 5.66667C6.54165 5.66667 6.14928 5.82986 5.8229 6.15625C5.49651 6.48264 5.33331 6.875 5.33331 7.33333V8.16667H5.12498C4.94442 8.16667 4.79512 8.22569 4.67706 8.34375C4.55901 8.46181 4.49998 8.61111 4.49998 8.79167V11.7083C4.49998 11.8889 4.55901 12.0382 4.67706 12.1562C4.79512 12.2743 4.94442 12.3333 5.12498 12.3333ZM5.95831 8.16667V7.33333C5.95831 7.05556 6.06248 6.82292 6.27081 6.63542C6.47915 6.44792 6.7222 6.35417 6.99998 6.35417C7.27776 6.35417 7.52081 6.44792 7.72915 6.63542C7.93748 6.82292 8.04165 7.05556 8.04165 7.33333V8.16667H5.95831Z" fill="#929BED"/>
</svg>
`
25 changes: 25 additions & 0 deletions packages/core/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,31 @@ export function addNewChain(
})
}

export function updateChainRPC(
provider: EIP1193Provider,
chain: Chain,
rpcUrl?: string
): Promise<unknown> {
return provider.request({
method: 'wallet_addEthereumChain',
params: [
{
chainId: chain.id,
chainName: chain.label,
nativeCurrency: {
name: chain.label,
symbol: chain.token,
decimals: 18
},
rpcUrls: [rpcUrl],
blockExplorerUrls: chain.blockExplorerUrl
? [chain.blockExplorerUrl]
: undefined
}
]
})
}

export async function getPermissions(
provider: EIP1193Provider
): Promise<WalletPermission[]> {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export type NotificationPosition = CommonPositions

export type AccountCenter = {
enabled: boolean
/**
* false by default - This allows removal of the
* Enable Transaction Protection' button within the Account Center
* expanded when set to true
*/
disableProtectedRpc?: boolean
position?: AccountCenterPosition
expanded?: boolean
minimal?: boolean
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const accountCenter = Joi.object({
position: commonPositions,
expanded: Joi.boolean(),
minimal: Joi.boolean(),
disableProtectedRpc: Joi.boolean(),
containerElement: Joi.string()
})

Expand Down Expand Up @@ -263,6 +264,7 @@ const setChainOptions = Joi.object({
rpcUrl: Joi.string(),
label: Joi.string(),
token: Joi.string(),
protectedRpcUrl: Joi.string(),
secondaryTokens: Joi.array().max(5).items(secondaryTokenValidation).optional()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<script lang="ts">
import { _ } from 'svelte-i18n'
import { Modal } from '../shared'
import en from '../../i18n/en.json'
import shieldIcon from '../../icons/shield-icon.js'

export let onEnable: () => void
export let onDismiss: () => void
</script>

<style>
.content {
--background-color: var(--w3o-background-color);
--text-color: var(--w3o-text-color);
--action-color: var(--w3o-action-color, var(--primary-500));

font-size: 1rem;
line-height: 1.5rem;

display: flex;
flex-flow: column;
gap: 1.5rem;
padding: 1rem;
max-width: 320px;

background: var(--background-color);
color: var(--text-color);
}

.icon-container {
position: relative;
overflow: hidden;
width: 3rem;
height: 3rem;
border-radius: 24px;
padding: .75rem;
background: none;
}
.icon-container::before {
content: '';
position: absolute;
height: 100%;
width: 100%;
opacity: 0.2;
background: var(--action-color);
}

.text-container {
display: flex;
flex-flow: column;
gap: 0.5rem;
padding: 0 0.5rem;
}

.actions-container {
display: flex;
flex-flow: row nowrap;
gap: 1rem;
}

.heading {
font-weight: 600;
}

button {
font-weight: 600;
}

button.primary {
background: var(--action-color);
}
</style>

<Modal close={onDismiss}>
<div class="content">
<div class="icon-container flex justify-center items-center">
{@html shieldIcon}
</div>

<div class="text-container">
<div class="heading">
{$_('modals.confirmTransactionProtection.heading', {
default: en.modals.confirmTransactionProtection.heading
})}
</div>
<div>
{$_('modals.confirmTransactionProtection.description')}
</div>
</div>

<div class="actions-container">
<button class="button-neutral-solid-b" on:click={onDismiss}>
{$_('modals.confirmTransactionProtection.dismiss', {
default: en.modals.confirmTransactionProtection.dismiss
})}
</button>
<button class="button-neutral-solid rounded primary" on:click={onEnable}>
{$_('modals.confirmTransactionProtection.enable', {
default: en.modals.confirmTransactionProtection.enable
})}
</button>
</div>
</div>
</Modal>
Loading