Skip to content

Commit 7dac3ae

Browse files
authored
immutable connector package (#288)
* immutable connector package * immutable passport connector * passport configuration defined outside of connector; immutable callback route * fix isAutorized * connector fix * improve connection logic * imports renaming * regenerate pnpm lock * immutable updated keys * immutable conncetor * immutable conncetor * immutable conncetor * immutable conncetor * immutable connector fixed getProvider * immutable passport version * moved dependencies to peerdeps * documentation * added connect as a dependency to immutable-connector to fix the build * fixed multiple connector issues * immutable connector package version
1 parent 4dbc426 commit 7dac3ae

File tree

17 files changed

+3934
-83
lines changed

17 files changed

+3934
-83
lines changed

.changeset/config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
"changelog": ["@changesets/changelog-github", { "repo": "0xsequence/web-sdk" }],
44
"commit": false,
55
"linked": [],
6-
"fixed": [["@0xsequence/connect", "@0xsequence/checkout", "@0xsequence/wallet-widget", "@0xsequence/hooks"]],
6+
"fixed": [
7+
[
8+
"@0xsequence/connect",
9+
"@0xsequence/checkout",
10+
"@0xsequence/wallet-widget",
11+
"@0xsequence/hooks",
12+
"@0xsequence/immutable-connector"
13+
]
14+
],
715
"access": "public",
816
"baseBranch": "master",
917
"updateInternalDependencies": "patch",

examples/react/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
"@0xsequence/connect": "workspace:*",
1616
"@0xsequence/design-system": "2.0.12",
1717
"@0xsequence/network": ">= 2.2.13",
18-
"@0xsequence/waas": ">= 2.2.13",
1918
"@0xsequence/wallet-widget": "workspace:*",
19+
"@0xsequence/immutable-connector": "workspace:*",
20+
"@0xsequence/hooks": "workspace:*",
21+
"@0xsequence/waas": ">= 2.2.13",
22+
"@imtbl/config": "^2.1.2",
23+
"@imtbl/sdk": "^2.1.2",
2024
"@tanstack/react-query": "^5.62.0",
2125
"clsx": "^2.1.1",
2226
"example-shared-components": "workspace:*",
2327
"motion": "^12.3.1",
2428
"react": "^19.0.0",
2529
"react-dom": "^19.0.0",
30+
"react-router-dom": "^7.3.0",
2631
"tailwindcss": "^4.0.6",
2732
"typescript": "^5.8.2",
2833
"viem": "^2.23.10 ",

examples/react/src/App.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { SequenceCheckoutProvider } from '@0xsequence/checkout'
22
import { SequenceConnect } from '@0xsequence/connect'
33
import { ThemeProvider } from '@0xsequence/design-system'
44
import { SequenceWalletProvider } from '@0xsequence/wallet-widget'
5+
import { BrowserRouter, Routes, Route } from 'react-router-dom'
56

67
import { Homepage } from './components/Homepage'
8+
import { ImmutableCallback } from './components/ImmutableCallback'
79
import { config, checkoutConfig } from './config'
810

911
export const App = () => {
@@ -12,7 +14,12 @@ export const App = () => {
1214
<SequenceConnect config={config}>
1315
<SequenceWalletProvider>
1416
<SequenceCheckoutProvider config={checkoutConfig}>
15-
<Homepage />
17+
<BrowserRouter>
18+
<Routes>
19+
<Route path="/" element={<Homepage />} />
20+
<Route path="/auth/callback" element={<ImmutableCallback />} />
21+
</Routes>
22+
</BrowserRouter>
1623
</SequenceCheckoutProvider>
1724
</SequenceWalletProvider>
1825
</SequenceConnect>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Spinner, Text } from '@0xsequence/design-system'
2+
import { useEffect } from 'react'
3+
import { useNavigate } from 'react-router-dom'
4+
5+
import { passportInstance } from '../config'
6+
7+
export function ImmutableCallback() {
8+
const navigate = useNavigate()
9+
10+
useEffect(() => {
11+
const handleCallback = async () => {
12+
try {
13+
await passportInstance.loginCallback()
14+
navigate('/')
15+
} catch (error) {
16+
console.error('Immutable login callback failed:', error)
17+
navigate('/')
18+
}
19+
}
20+
21+
handleCallback()
22+
}, [navigate])
23+
24+
return (
25+
<div className="flex flex-col items-center justify-center min-h-screen">
26+
<Spinner size="lg" />
27+
<Text marginTop="4">Processing Immutable login...</Text>
28+
</div>
29+
)
30+
}

examples/react/src/config.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { SequenceCheckoutConfig } from '@0xsequence/checkout'
22
import { ConnectConfig, createConfig, WalletType } from '@0xsequence/connect'
3+
// import { immutable } from '@0xsequence/immutable-connector'
34
import { ChainId } from '@0xsequence/network'
5+
import { Environment } from '@imtbl/config'
6+
import { passport } from '@imtbl/sdk'
47
import { zeroAddress } from 'viem'
58

69
const searchParams = new URLSearchParams(location.search)
@@ -64,6 +67,17 @@ export const connectConfig: ConnectConfig = {
6467
: undefined
6568
}
6669

70+
export const passportInstance = new passport.Passport({
71+
baseConfig: {
72+
environment: Environment.SANDBOX,
73+
publishableKey: 'pk_imapik-test-VEMeW7wUX7hE7LHg3FxY'
74+
},
75+
clientId: 'ap8Gv3188GLFROiBFBNFz77DojRpqxnS',
76+
redirectUri: `${window.location.origin}/auth/callback`,
77+
audience: 'platform_api',
78+
scope: 'openid offline_access email transact'
79+
})
80+
6781
export const config =
6882
walletType === 'waas'
6983
? createConfig('waas', {
@@ -110,7 +124,14 @@ export const config =
110124

111125
walletConnect: {
112126
projectId: walletConnectProjectId
113-
}
127+
},
128+
additionalWallets: [
129+
// Uncomment to enable Immutable
130+
// immutable({
131+
// passportInstance,
132+
// environment: Environment.SANDBOX
133+
// })
134+
]
114135
})
115136

116137
export const getErc1155SaleContractConfig = (walletAddress: string) => ({

packages/connect/src/config/defaultConnectors.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface DefaultWaasConnectorOptions extends CommonConnectorOptions {
4747
| {
4848
projectId: string
4949
}
50+
additionalWallets?: Wallet[]
5051

5152
/**
5253
* @deprecated use connectors.walletConnect.projectId instead
@@ -84,7 +85,7 @@ export interface DefaultUniversalConnectorOptions extends CommonConnectorOptions
8485
| {
8586
projectId: string
8687
}
87-
88+
additionalWallets?: Wallet[]
8889
/**
8990
* @deprecated, use connectors.walletConnect.projectId instead
9091
*/
@@ -309,5 +310,9 @@ export const getDefaultUniversalConnectors = (options: DefaultUniversalConnector
309310
)
310311
}
311312

313+
if (options?.additionalWallets && options?.additionalWallets.length > 0) {
314+
wallets.push(...options.additionalWallets)
315+
}
316+
312317
return getConnectWallets(projectAccessKey, wallets)
313318
}

packages/connect/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export type {
1515
EthAuthSettings,
1616
ModalPosition,
1717
ConnectConfig,
18-
StorageItem
18+
StorageItem,
19+
LogoProps
1920
} from './types'
2021

2122
// Config

packages/connect/src/styles.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ export const styles = String.raw`
302302
.my-4 {
303303
margin-block: calc(var(--spacing) * 4);
304304
}
305+
.mt-0 {
306+
margin-top: calc(var(--spacing) * 0);
307+
}
305308
.mt-0\.5 {
306309
margin-top: calc(var(--spacing) * 0.5);
307310
}
@@ -383,6 +386,9 @@ export const styles = String.raw`
383386
.inline-flex {
384387
display: inline-flex;
385388
}
389+
.table {
390+
display: table;
391+
}
386392
.aspect-square {
387393
aspect-ratio: 1 / 1;
388394
}
@@ -476,6 +482,9 @@ export const styles = String.raw`
476482
.min-h-full {
477483
min-height: 100%;
478484
}
485+
.w-1 {
486+
width: calc(var(--spacing) * 1);
487+
}
479488
.w-1\/2 {
480489
width: calc(1/2 * 100%);
481490
}
@@ -551,6 +560,9 @@ export const styles = String.raw`
551560
.w-screen {
552561
width: 100vw;
553562
}
563+
.max-w-1 {
564+
max-width: calc(var(--spacing) * 1);
565+
}
554566
.max-w-1\/2 {
555567
max-width: calc(1/2 * 100%);
556568
}
@@ -575,12 +587,21 @@ export const styles = String.raw`
575587
.min-w-full {
576588
min-width: 100%;
577589
}
590+
.flex-shrink {
591+
flex-shrink: 1;
592+
}
578593
.shrink-0 {
579594
flex-shrink: 0;
580595
}
596+
.flex-grow {
597+
flex-grow: 1;
598+
}
581599
.grow {
582600
flex-grow: 1;
583601
}
602+
.border-collapse {
603+
border-collapse: collapse;
604+
}
584605
.origin-top {
585606
transform-origin: top;
586607
}
@@ -922,6 +943,9 @@ export const styles = String.raw`
922943
.pt-0 {
923944
padding-top: calc(var(--spacing) * 0);
924945
}
946+
.pt-1 {
947+
padding-top: calc(var(--spacing) * 1);
948+
}
925949
.pt-1\.5 {
926950
padding-top: calc(var(--spacing) * 1.5);
927951
}
@@ -1191,6 +1215,9 @@ export const styles = String.raw`
11911215
.ring-border-normal {
11921216
--tw-ring-color: var(--seq-color-border-normal);
11931217
}
1218+
.ring-white {
1219+
--tw-ring-color: var(--color-white);
1220+
}
11941221
.ring-white\/10 {
11951222
--tw-ring-color: color-mix(in oklab, var(--color-white) 10%, transparent);
11961223
}
@@ -1226,6 +1253,10 @@ export const styles = String.raw`
12261253
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
12271254
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
12281255
}
1256+
.backdrop-filter {
1257+
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
1258+
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
1259+
}
12291260
.transition {
12301261
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
12311262
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Immutable connector for Sequence Web-SDK
2+
3+
## Installation
4+
5+
To install this package:
6+
7+
```bash
8+
npm install @0xsequence/immutable-connector @imtbl/config @imtbl/sdk
9+
# or
10+
11+
pnpm install @0xsequence/immutable-connector @imtbl/config @imtbl/sdk
12+
# or
13+
yarn add @0xsequence/immutable-connector @imtbl/config @imtbl/sdk
14+
```
15+
16+
## Adding the connect
17+
18+
First, an Immutable Passport instance must be created with valid and correctly configured Immutable keys.
19+
20+
Note, that the application will need a callback route configured similarly to this example: https://github.com/immutable/ts-immutable-sdk/blob/main/examples/passport/login-with-nextjs/src/app/redirect/page.tsx
21+
22+
```js
23+
export const passportInstance = new passport.Passport({
24+
baseConfig: {
25+
environment: Environment.SANDBOX,
26+
publishableKey: 'my_publisheable_key'
27+
},
28+
clientId: 'my_client_id',
29+
redirectUri: `${window.location.origin}/auth/callback`,
30+
audience: 'platform_api',
31+
scope: 'openid offline_access email transact'
32+
})
33+
```
34+
35+
Finally, the wallet can be passed down to the web-sdk configuration similarly to other wallets,
36+
37+
```js
38+
immutable({
39+
passportInstance,
40+
environment: Environment.SANDBOX
41+
})
42+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@0xsequence/immutable-connector",
3+
"version": "5.0.9",
4+
"description": "Immutable connector for Sequence Kit",
5+
"repository": "https://github.com/0xsequence/web-sdk/tree/master/packages/immutable-connector",
6+
"author": "Horizon Blockchain Games",
7+
"license": "Apache-2.0",
8+
"type": "module",
9+
"main": "dist/cjs/index.js",
10+
"module": "dist/esm/index.js",
11+
"types": "dist/esm/index.d.ts",
12+
"exports": {
13+
"./package.json": "./package.json",
14+
".": {
15+
"require": "./dist/cjs/index.js",
16+
"import": "./dist/esm/index.js"
17+
}
18+
},
19+
"files": [
20+
"dist"
21+
],
22+
"scripts": {
23+
"build": "pnpm build:clean && pnpm build:esm && pnpm build:cjs",
24+
"build:cjs": "tsc --module commonjs --declaration --declarationMap --outDir dist/cjs && echo '{ \"type\": \"commonjs\" }' > dist/cjs/package.json",
25+
"build:esm": "tsc --module es2022 --declaration --declarationMap --outDir dist/esm",
26+
"build:clean": "rimraf -g ./dist",
27+
"build:check": "attw --pack .",
28+
"dev": "tsc --watch --module es2022 --declaration --declarationMap --outDir dist/esm",
29+
"test": "echo",
30+
"typecheck": "tsc --noEmit"
31+
},
32+
"dependencies": {
33+
"@0xsequence/connect": "workspace:*"
34+
},
35+
"peerDependencies": {
36+
"@0xsequence/connect": "workspace:*",
37+
"0xsequence": "^2.2.13",
38+
"@imtbl/config": ">=2.1.2",
39+
"@imtbl/sdk": ">=2.1.2",
40+
"ethers": "^6.13.0",
41+
"react": ">= 17 < 19",
42+
"react-dom": ">= 17 < 19",
43+
"viem": "^2.0.0",
44+
"wagmi": "^2.14.11"
45+
}
46+
}

0 commit comments

Comments
 (0)