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

Immutable Passport #81

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
89 changes: 89 additions & 0 deletions packages/connectors/src/connectors/immutable/ImmutableLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react'

import { LogoProps } from '../../types'

export const ImmutableLogo: React.FunctionComponent = (props: LogoProps) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" style={{ fill: 'none' }} id="svg1316" version="1.1" viewBox="0 0 181 48" {...props}>
<g data-testid="undefined__g">
<defs>
<radialGradient
id="paint0_radial_5638_80033"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(12.7405 12.6825) rotate(44.9817) scale(49.8653 105.753)"
>
<stop stop-color="#A3EEF8"></stop>
<stop offset="0.177083" stop-color="#A4DCF5"></stop>
<stop offset="0.380208" stop-color="#A6AEEC"></stop>
<stop offset="1" stop-color="#ECBEE1"></stop>
</radialGradient>
<radialGradient
id="paint1_radial_5638_80033"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(26.0816 45.0206) rotate(84.265) scale(25.828 49.4096)"
>
<stop stop-color="#FCF5EE"></stop>
<stop offset="0.715135" stop-color="#ECBEE1" stop-opacity="0"></stop>
</radialGradient>
<radialGradient
id="paint2_radial_5638_80033"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(12.7405 12.6825) rotate(44.9817) scale(49.8653 105.753)"
>
<stop stop-color="#A3EEF8"></stop>
<stop offset="0.177083" stop-color="#A4DCF5"></stop>
<stop offset="0.380208" stop-color="#A6AEEC"></stop>
<stop offset="1" stop-color="#ECBEE1"></stop>
</radialGradient>
<radialGradient
id="paint3_radial_5638_80033"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(26.0816 45.0206) rotate(84.265) scale(25.828 49.4096)"
>
<stop stop-color="#FCF5EE"></stop>
<stop offset="0.715135" stop-color="#ECBEE1" stop-opacity="0"></stop>
</radialGradient>
</defs>
<path d="M59 15.1602V36.7652H63.2614V29.1662H66.5096C71.4862 29.1662 75.8966 27.8252 75.8966 22.3122C75.8966 15.786 70.8306 15.1602 66.3904 15.1602H59ZM66.4798 18.4978C68.8042 18.4978 71.516 18.7958 71.516 22.342C71.516 25.2028 69.43 25.8584 66.7778 25.8584H63.2614V18.4978H66.4798Z"></path>
<path d="M86.85 30.239C86.85 32.8614 85.7474 34.3514 83.1846 34.3514C81.337 34.3514 80.4132 33.3978 80.4132 32.2356C80.4132 30.4476 82.2608 29.9112 86.85 29.4344V30.239ZM87.1778 34.709C87.2374 35.4838 87.3566 36.2586 87.4758 36.7652H91.2604C90.9624 35.4242 90.7836 33.9938 90.7836 31.4608C90.7836 30.0006 90.8432 27.855 90.8432 27.3484C90.8432 21.9248 87.7738 20.3156 83.8104 20.3156C79.7278 20.3156 76.9564 22.64 76.6584 25.7988H80.5026C80.592 24.0406 81.9032 23.2062 83.6614 23.2062C85.4196 23.2062 86.7308 24.0406 86.7308 26.514V26.812C80.443 27.5272 76.1816 28.6596 76.1816 32.474C76.1816 35.3646 78.8934 37.1526 81.9628 37.1526C84.3766 37.1526 86.0454 36.4076 87.1778 34.709Z"></path>
<path d="M107.262 25.5604C106.725 21.8652 103.537 20.3156 100.08 20.3156C96.504 20.3156 93.4048 22.193 93.4048 25.0836C93.4048 28.004 95.4014 29.2258 98.5304 29.8814L100.914 30.388C102.404 30.7158 103.656 31.1628 103.656 32.3548C103.656 33.517 102.524 34.1726 100.646 34.1726C98.4112 34.1726 97.3086 33.0104 97.0702 31.4608H93.1068C93.4942 35.1262 96.4742 37.1526 100.527 37.1526C104.282 37.1526 107.59 35.1858 107.59 31.9674C107.59 28.6596 104.878 27.8848 101.57 27.1398L99.4244 26.663C97.7854 26.3054 97.1596 25.6796 97.1596 24.8154C97.1596 23.832 98.2324 23.2658 99.8714 23.2658C101.868 23.2658 103.12 24.2194 103.418 25.5604H107.262Z"></path>
<path d="M123.035 25.5604C122.498 21.8652 119.31 20.3156 115.853 20.3156C112.277 20.3156 109.178 22.193 109.178 25.0836C109.178 28.004 111.174 29.2258 114.303 29.8814L116.687 30.388C118.177 30.7158 119.429 31.1628 119.429 32.3548C119.429 33.517 118.297 34.1726 116.419 34.1726C114.184 34.1726 113.082 33.0104 112.843 31.4608H108.88C109.267 35.1262 112.247 37.1526 116.3 37.1526C120.055 37.1526 123.363 35.1858 123.363 31.9674C123.363 28.6596 120.651 27.8848 117.343 27.1398L115.197 26.663C113.558 26.3054 112.933 25.6796 112.933 24.8154C112.933 23.832 114.005 23.2658 115.644 23.2658C117.641 23.2658 118.893 24.2194 119.191 25.5604H123.035Z"></path>
<path d="M133.533 33.9938C131.268 33.9938 129.778 32.027 129.778 28.749C129.778 25.5306 131.268 23.534 133.533 23.534C135.768 23.534 137.109 25.6498 137.109 28.7788C137.109 31.9078 135.768 33.9938 133.533 33.9938ZM129.927 41.9802V34.7388C130.941 36.497 132.848 37.1526 134.517 37.1526C138.45 37.1526 141.43 33.8746 141.43 28.749C141.43 23.7128 138.54 20.3752 134.546 20.3752C132.52 20.3752 130.792 21.299 129.927 22.789V20.7328H125.815V41.9802H129.927Z"></path>
<path d="M151.207 23.5936C153.591 23.5936 154.992 25.4114 154.992 28.7788C154.992 32.1164 153.591 33.9342 151.207 33.9342C148.823 33.9342 147.423 32.1164 147.423 28.7788C147.423 25.4114 148.823 23.5936 151.207 23.5936ZM151.207 37.1526C155.379 37.1526 159.164 34.411 159.164 28.7788C159.164 23.1466 155.379 20.3752 151.207 20.3752C147.035 20.3752 143.251 23.1466 143.251 28.7788C143.251 34.411 147.035 37.1526 151.207 37.1526Z"></path>
<path d="M173.642 20.7622H171.377V23.5638H173.642V32.4442C173.642 35.6328 174.357 36.7652 178.023 36.7652H181.033V33.815H179.781C178.321 33.815 177.755 33.4872 177.755 31.8482V23.5638H181.092V20.7328H177.755V16.382H173.642V20.7622Z"></path>
<path d="M165.837 23.5336C166.761 21.5668 168.221 20.7622 170.069 20.7622L169.264 24.6064C167.238 24.6064 165.897 25.3514 165.897 28.3612V36.7648H161.785V20.7324H165.837V23.5336Z"></path>
<path d="M173.774 20.7617H170.055L169.264 24.6011H174.375L173.774 20.7617Z"></path>
<circle cx="24" cy="24" r="24" fill="url(#paint0_radial_5638_80033)"></circle>
<circle cx="24" cy="24" r="24" fill="url(#paint1_radial_5638_80033)"></circle>
<path
d="M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24C48 10.7452 37.2548 0 24 0ZM23.0718 9.16608C23.7383 8.83951 24.4406 8.86188 25.087 9.2287C27.3282 10.5059 29.5627 11.7942 31.786 13.096C32.5018 13.5165 32.8686 14.1897 32.8708 15.0173C32.8843 17.9184 32.8798 20.8171 32.8708 23.7182C32.8708 23.8255 32.8015 23.9821 32.7143 24.0335C31.8531 24.548 30.9808 25.0423 30.0347 25.5881V25.1318C30.0347 22.148 30.0257 19.1664 30.0414 16.1827C30.0436 15.6101 29.8468 15.241 29.339 14.9525C26.7377 13.474 24.1499 11.9687 21.5575 10.4723C21.4457 10.4075 21.3361 10.3381 21.1661 10.2352C21.8326 9.85722 22.4321 9.47698 23.0673 9.16608H23.0718ZM22.5953 38.8451C22.45 38.7713 22.3426 38.7198 22.2375 38.6595C18.8041 36.68 15.3752 34.687 11.9307 32.7232C10.9644 32.173 10.5238 31.3879 10.5349 30.2852C10.5551 27.9411 10.5484 25.597 10.5372 23.2507C10.5327 22.1927 10.9622 21.4255 11.8926 20.8977C14.3105 19.5221 16.715 18.1264 19.1195 16.7284C19.3275 16.6076 19.4796 16.5875 19.6965 16.7172C20.5264 17.216 21.3719 17.6924 22.2554 18.2024C22.0876 18.3031 21.9601 18.3791 21.8304 18.4552C19.2268 19.9582 16.6278 21.4658 14.0175 22.9599C13.5903 23.2037 13.3912 23.5213 13.3957 24.0179C13.4091 25.8654 13.4114 27.713 13.3957 29.5605C13.3912 30.0705 13.5948 30.3948 14.0332 30.6453C16.7866 32.2199 19.5288 33.8125 22.28 35.3916C22.5126 35.5258 22.611 35.6645 22.6065 35.9418C22.5864 36.888 22.5998 37.8363 22.5998 38.8473L22.5953 38.8451ZM22.5953 33.553C22.356 33.4166 22.1838 33.3204 22.0116 33.2198C19.8285 31.9605 17.6477 30.6967 15.4602 29.4464C15.2231 29.3122 15.1359 29.1668 15.1381 28.8917C15.1538 27.4714 15.1471 26.0511 15.1426 24.6308C15.1426 24.4384 15.1717 24.3064 15.3618 24.1991C16.167 23.7495 16.9633 23.2798 17.7618 22.8212C17.8199 22.7877 17.8826 22.7631 17.9877 22.7116V24.3064C17.9877 25.1698 18.0011 26.0354 17.9832 26.8988C17.972 27.3909 18.1622 27.7241 18.5916 27.9657C19.8285 28.6636 21.0498 29.3883 22.2867 30.0839C22.5305 30.2203 22.6043 30.3724 22.5998 30.6408C22.5842 31.5847 22.5931 32.5308 22.5931 33.5508L22.5953 33.553ZM20.0746 14.91C19.6116 14.6371 19.2157 14.6393 18.7527 14.91C16.1581 16.4265 13.5523 17.9228 10.9487 19.4259C10.8391 19.4908 10.7251 19.5489 10.5305 19.6541C10.5998 18.6654 10.3873 17.7327 10.7251 16.8291C10.9085 16.3348 11.2529 15.9635 11.7092 15.6995C13.8811 14.4447 16.0507 13.1877 18.227 11.9396C19.0211 11.4833 19.8308 11.4945 20.6248 11.953C23.0964 13.3756 25.5657 14.8026 28.0306 16.2341C28.1357 16.2945 28.2677 16.4309 28.2677 16.5338C28.2856 17.5493 28.2788 18.567 28.2788 19.6563C27.3819 19.1396 26.5543 18.6609 25.7267 18.1823C23.8412 17.093 21.9512 16.0149 20.0746 14.91ZM37.4427 30.8779C37.3778 31.6764 36.9103 32.2423 36.2192 32.6404C33.5732 34.1614 30.9294 35.6913 28.2856 37.2168C27.4557 37.6954 26.6259 38.1741 25.7938 38.6527C25.6932 38.7109 25.5903 38.7601 25.4539 38.8317C25.4449 38.693 25.4337 38.5924 25.4337 38.4917C25.4337 37.6149 25.4382 36.7404 25.4293 35.8636C25.4293 35.6645 25.4762 35.5437 25.6596 35.4386C29.5157 33.2198 33.3696 30.9942 37.2212 28.7709C37.2794 28.7374 37.3443 28.7105 37.4539 28.6591C37.4539 29.4375 37.4986 30.1622 37.4427 30.8779ZM37.4628 25.3577C37.4561 26.2658 36.9663 26.9033 36.1901 27.3506C33.175 29.0841 30.1622 30.8265 27.1493 32.5666C26.5991 32.8843 26.0466 33.1996 25.4561 33.5396C25.4472 33.3897 25.436 33.2913 25.436 33.1907C25.436 32.3273 25.4449 31.4617 25.4293 30.5983C25.4248 30.3523 25.5075 30.2226 25.72 30.0995C28.46 28.5271 31.1911 26.9368 33.9355 25.3733C34.4231 25.096 34.6378 24.7538 34.6334 24.1812C34.6132 21.1974 34.6244 18.2136 34.6244 15.2298V14.7087C35.3402 15.1404 36.0112 15.496 36.624 15.9299C37.1832 16.3258 37.465 16.9253 37.4673 17.6164C37.4762 20.1976 37.4829 22.7787 37.465 25.3599L37.4628 25.3577Z"
fill="#0D0D0D"
></path>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24C48 10.7452 37.2548 0 24 0ZM24 2C11.8497 2 2 11.8497 2 24C2 36.1503 11.8497 46 24 46C36.1503 46 46 36.1503 46 24C46 11.8497 36.1503 2 24 2Z"
fill="url(#paint2_radial_5638_80033)"
></path>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24C48 10.7452 37.2548 0 24 0ZM24 2C11.8497 2 2 11.8497 2 24C2 36.1503 11.8497 46 24 46C36.1503 46 46 36.1503 46 24C46 11.8497 36.1503 2 24 2Z"
fill="url(#paint3_radial_5638_80033)"
></path>
</g>
</svg>
)
}
22 changes: 22 additions & 0 deletions packages/connectors/src/connectors/immutable/immutable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Wallet } from '@0xsequence/kit'

import { immutableConnector } from '../wagmiConnectors'

import { ImmutableLogo } from './ImmutableLogo'

export interface ImmutableOptions {}

export const immutable = (options: ImmutableOptions): Wallet => ({
id: 'immutable',
isSequenceBased: false,
logoDark: ImmutableLogo,
logoLight: ImmutableLogo,
name: 'Sequence',
createConnector: () => {
const connector = immutableConnector({
...options
})

return connector
}
})
1 change: 1 addition & 0 deletions packages/connectors/src/connectors/immutable/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './immutable'
155 changes: 155 additions & 0 deletions packages/connectors/src/defaultConnectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import { getKitConnectWallets } from '@0xsequence/kit'
import { CreateConnectorFn } from 'wagmi'

import { apple } from './connectors/apple'
import { appleWaas } from './connectors/apple/appleWaas'
import { coinbaseWallet } from './connectors/coinbaseWallet'
import { email } from './connectors/email'
import { emailWaas } from './connectors/email/emailWaas'
import { facebook } from './connectors/facebook'
import { google } from './connectors/google'
import { googleWaas } from './connectors/google/googleWaas'
import { immutable } from './connectors/immutable'
import { metamask } from './connectors/metamask'
import { sequence } from './connectors/sequence'
import { twitch } from './connectors/twitch'
import { walletConnect } from './connectors/walletConnect'

interface GetDefaultConnectors {
walletConnectProjectId: string
projectAccessKey: string
appName: string
defaultChainId?: number
}

export const getDefaultConnectors = ({
walletConnectProjectId,
defaultChainId,
projectAccessKey,
appName
}: GetDefaultConnectors): CreateConnectorFn[] => {
const connectors = getKitConnectWallets(projectAccessKey, [
immutable({}),
email({
defaultNetwork: defaultChainId,
connect: {
app: appName
}
}),
google({
defaultNetwork: defaultChainId,
connect: {
app: appName
}
}),
facebook({
defaultNetwork: defaultChainId,
connect: {
app: appName
}
}),
twitch({
defaultNetwork: defaultChainId,
connect: {
app: appName
}
}),
apple({
defaultNetwork: defaultChainId,
connect: {
app: appName
}
}),
sequence({
defaultNetwork: defaultChainId,
connect: {
app: appName
}
}),
walletConnect({
projectId: walletConnectProjectId
}),
metamask()
// coinbaseWallet({
// appName
// })
])

return connectors
}

interface GetDefaultWaasConnectors {
projectAccessKey: string
waasConfigKey: string
googleClientId?: string
appleClientId?: string
appleRedirectURI?: string

walletConnectProjectId: string

appName: string
defaultChainId?: number

enableConfirmationModal?: boolean

isDev?: boolean
}

export const getDefaultWaasConnectors = ({
projectAccessKey,
waasConfigKey,
googleClientId,
appleClientId,
appleRedirectURI,
walletConnectProjectId,
appName,
defaultChainId,
enableConfirmationModal,
isDev = false
}: GetDefaultWaasConnectors): CreateConnectorFn[] => {
const wallets: any[] = [
emailWaas({
projectAccessKey,
waasConfigKey,
enableConfirmationModal,
network: defaultChainId,
isDev
}),
coinbaseWallet({
appName
}),
metamask(),
walletConnect({
projectId: walletConnectProjectId
})
]
if (googleClientId) {
wallets.push(
googleWaas({
projectAccessKey,
googleClientId,
waasConfigKey,
enableConfirmationModal,
network: defaultChainId,
isDev
})
)
}
if (appleClientId && appleRedirectURI) {
wallets.push(
appleWaas({
projectAccessKey,
appleClientId,
appleRedirectURI,
waasConfigKey,
enableConfirmationModal,
network: defaultChainId,
isDev
})
)
}

const connectors = getKitConnectWallets(projectAccessKey, wallets)

return connectors
}
102 changes: 102 additions & 0 deletions packages/kit/src/connectors/wagmiConnectors/immutableConnector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { createConnector } from 'wagmi'

export interface BaseImmutableConnectorOptions {}

immutableConnector.type = 'immutable' as const

export function immutableConnector(params: BaseImmutableConnectorOptions) {
type Provider = any
type Properties = {
params: BaseImmutableConnectorOptions
}
type StorageItem = {}

let provider: any = undefined

return createConnector<Provider, Properties, StorageItem>(config => ({
id: 'immutable',
name: 'Immutable Passport',
type: immutableConnector.type,
params,

async setup() {
const provider = await this.getProvider()
},

async connect() {
const provider = await this.getProvider()

return { accounts: [], chainId: 1 }
},

async disconnect() {
const provider = await this.getProvider()

provider.disconnect()
},

async getAccounts() {
const provider = await this.getProvider()

return []
},

async getProvider() {
if (provider) {
return provider
}

// return the immutable passport provider
provider = {}
},

async isAuthorized() {
try {
const account = await this.getAccounts()
return !!account
} catch (e) {
return false
}
},

async switchChain({ chainId }) {
const provider = await this.getProvider()

const chain = config.chains.find(c => c.id === chainId) || config.chains[0]

config.emitter.emit('change', { chainId })

return chain
},

async getChainId() {
const provider = await this.getProvider()
const chainId = provider.getChainId()

return chainId
},

async onAccountsChanged(accounts) {
return { account: accounts[0] }
},

async onChainChanged(chain) {
const provider = await this.getProvider()

config.emitter.emit('change', { chainId: normalizeChainId(chain) })
},

async onConnect(_connectinfo) {},

async onDisconnect() {
config.emitter.emit('disconnect')
}
}))
}

function normalizeChainId(chainId: string | number | bigint | { chainId: string }) {
if (typeof chainId === 'object') return normalizeChainId(chainId.chainId)
if (typeof chainId === 'string') return Number.parseInt(chainId, chainId.trim().substring(0, 2) === '0x' ? 16 : 10)
if (typeof chainId === 'bigint') return Number(chainId)
return chainId
}
1 change: 1 addition & 0 deletions packages/kit/src/connectors/wagmiConnectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './sequenceConnector'
export * from './sequenceWaasConnector'
export * from './immutableConnector'