Skip to content

Commit 22b64c7

Browse files
authored
feat: initial multichain (react) playground (#1331)
* fix: implement UI for multichain playground * fix: add lock * fix: improve useSDK * fix: install modal web show initial QRCode * fix: clean install modal after closing * fix: unload and re-launching modals * fix: linter fixes * fix: type module * fix: rollback to cjs config in multichain-react * fix: build fix * fix: convert craco to cjs
1 parent 1f44b88 commit 22b64c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3844
-105
lines changed

biome.json

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
3-
"vcs": {
4-
"enabled": false,
5-
"clientKind": "git",
6-
"useIgnoreFile": false
7-
},
8-
"files": {
9-
"includes": ["packages/sdk-multichain/src/**", "!**/node_modules/**", "!**/dist/**"],
10-
"ignoreUnknown": false
11-
},
12-
"formatter": {
13-
"enabled": true,
14-
"indentStyle": "tab",
15-
"lineWidth": 180
16-
},
17-
"linter": {
18-
"enabled": true,
19-
"rules": {
20-
"recommended": true
21-
}
22-
},
23-
"javascript": {
24-
"formatter": {
25-
"quoteStyle": "single"
26-
}
27-
},
28-
"assist": {
29-
"enabled": true,
30-
"actions": {
31-
"source": {
32-
"organizeImports": "on"
33-
}
34-
}
35-
}
2+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
3+
"vcs": {
4+
"enabled": false,
5+
"clientKind": "git",
6+
"useIgnoreFile": false
7+
},
8+
"files": {
9+
"includes": ["packages/sdk-multichain/src/**", "playground/multichain-node/src/**", "playground/multichain-react/src/**", "!**/node_modules/**", "!**/dist/**"],
10+
"ignoreUnknown": false
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "tab",
15+
"lineWidth": 180
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true
21+
}
22+
},
23+
"javascript": {
24+
"formatter": {
25+
"quoteStyle": "single"
26+
}
27+
},
28+
"assist": {
29+
"enabled": true,
30+
"actions": {
31+
"source": {
32+
"organizeImports": "on"
33+
}
34+
}
35+
}
3636
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"packages/deve2e",
2525
"packages/playground-next",
2626
"packages/sdk-multichain",
27-
"playground/multichain-node"
27+
"playground/multichain-node",
28+
"playground/multichain-react"
2829
],
2930
"scripts": {
3031
"build": "yarn install && cd packages/sdk-socket-server-next && yarn install && cd ../.. && yarn workspaces foreach --verbose run build:pre-tsc && yarn workspaces foreach --verbose --topological --parallel --no-private run build && yarn workspaces foreach --verbose run build:post-tsc ",

packages/sdk-multichain/src/multichain/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,10 @@ export class MultichainSDK extends MultichainCore {
305305
private async setupMWP() {
306306
const { adapter: kvstore } = this.options.storage;
307307
const dappClient = await this.createDappClient();
308+
this.__dappClient = dappClient;
309+
308310
const apiTransport = new MWPTransport(dappClient, kvstore);
309-
this.__dappClient ??= dappClient;
310-
this.__transport ??= apiTransport;
311+
this.__transport = apiTransport;
311312

312313
this.dappClient.once('connected', () => {
313314
const apiClient = getMultichainClient({ transport: this.transport });

packages/sdk-multichain/src/ui/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class ModalFactory<T extends FactoryModals = FactoryModals> {
108108
sessionRequest,
109109
sdkVersion: getVersion(),
110110
onClose: () => {
111-
this.unload(true);
111+
this.unload(false);
112112
},
113113
startDesktopOnboarding: () => {
114114
new MetaMaskOnboarding().startOnboarding();

packages/sdk-multichain/src/ui/modals/web/install.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class InstallModal extends AbstractInstallModal {
1111
modal.sdkVersion = options.sdkVersion;
1212
modal.addEventListener('close', ({ detail: { shouldTerminate } }) => options.onClose(shouldTerminate));
1313
modal.addEventListener('startDesktopOnboarding', options.startDesktopOnboarding);
14-
14+
modal.sessionRequest = options.sessionRequest;
1515
options.parentElement?.appendChild(modal);
1616

1717
this.instance = modal;
@@ -23,6 +23,7 @@ export class InstallModal extends AbstractInstallModal {
2323
this.stopExpirationCheck();
2424
if (modal && options.parentElement?.contains(modal)) {
2525
options.parentElement.removeChild(modal);
26+
this.instance = undefined;
2627
}
2728
}
2829

@@ -36,9 +37,10 @@ export class InstallModal extends AbstractInstallModal {
3637
}
3738

3839
const now = Date.now();
39-
if (now >= this.sessionRequest.expiresAt) {
40+
if (this.instance && now >= this.sessionRequest.expiresAt) {
4041
// Generate new session request
4142
const newSessionRequest = await this.options.createSessionRequest();
43+
this.instance.sessionRequest = newSessionRequest;
4244
this.sessionRequest = newSessionRequest;
4345
}
4446
}, 1000); // Check every second
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"ignores": [
3+
"@lavamoat/allow-scripts",
4+
"@lavamoat/preinstall-always-fail",
5+
"@metamask/auto-changelog",
6+
"@types/*",
7+
"@yarnpkg/types",
8+
"prettier-plugin-packagejson",
9+
"ts-node",
10+
"typedoc",
11+
"buffer"
12+
]
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Helius RPC API Configuration
2+
# Optional: Helius RPC API key for enhanced Solana RPC performance
3+
# If not provided, the app will fall back to public Solana RPC endpoints
4+
# Get your API key from: https://www.helius.dev/
5+
REACT_APP_HELIUS_API_KEY=your_helius_api_key_here
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text=auto
2+
3+
yarn.lock linguist-generated=false
4+
5+
# yarn v3
6+
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
7+
/.yarn/releases/** binary
8+
/.yarn/plugins/** binary
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
.DS_Store
2+
dist/
3+
coverage/
4+
docs/
5+
.env
6+
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# Diagnostic reports (https://nodejs.org/api/report.html)
16+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17+
18+
# Runtime data
19+
pids
20+
*.pid
21+
*.seed
22+
*.pid.lock
23+
24+
# Coverage directory used by tools like istanbul
25+
coverage
26+
*.lcov
27+
28+
# nyc test coverage
29+
.nyc_output
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (https://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules/
39+
40+
# TypeScript cache
41+
*.tsbuildinfo
42+
43+
# Optional npm cache directory
44+
.npm
45+
46+
# Optional eslint cache
47+
.eslintcache
48+
49+
# Microbundle cache
50+
.rpt2_cache/
51+
.rts2_cache_cjs/
52+
.rts2_cache_es/
53+
.rts2_cache_umd/
54+
55+
# Optional REPL history
56+
.node_repl_history
57+
58+
# Output of 'npm pack'
59+
*.tgz
60+
61+
# Yarn Integrity file
62+
.yarn-integrity
63+
64+
# dotenv environment variables file
65+
.env
66+
.env.test
67+
68+
# Stores VSCode versions used for testing VSCode extensions
69+
.vscode-test
70+
71+
# yarn v3 (w/o zero-install)
72+
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
73+
.pnp.*
74+
.yarn/*
75+
!.yarn/patches
76+
!.yarn/plugins
77+
!.yarn/releases
78+
!.yarn/sdks
79+
!.yarn/versions
80+
81+
build/

0 commit comments

Comments
 (0)