Skip to content

Commit f116292

Browse files
committed
update: exclude template file from configuration and remove serve script
1 parent 16f9d69 commit f116292

File tree

4 files changed

+235
-2
lines changed

4 files changed

+235
-2
lines changed

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ exclude:
214214
- LICENSE
215215
- "*.config.js"
216216
- package*.json
217+
- "_posts/TEMPLATE.md" # 排除模板文件
217218

218219
jekyll-archives:
219220
enabled: [categories, tags]

_posts/2025-9-6-MWA.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
title: What's MWA?
3+
date: 2025-09-06 18:25:14 +0800
4+
categories: [android, React Native]
5+
tags: [android, rn, mwa, dapp, crypto, solana, wallet] # TAG names should always be lowercase
6+
---
7+
Mobile Wallet Adapter (MWA) is a communication protocol that enables secure interactions between decentralized applications (dApps) and wallet applications on mobile devices. It serves as the bridge that makes Solana's mobile ecosystem work seamlessly.
8+
9+
## The Core Problem
10+
11+
On traditional web platforms:
12+
```
13+
Web dApp ←→ Browser Extension Wallet (e.g., MetaMask)
14+
```
15+
16+
Browser extensions can inject code into web pages through a shared JavaScript environment. However, mobile applications are isolated from each other, creating a communication gap:
17+
18+
```
19+
Mobile dApp ←→ ??? ←→ Standalone Wallet App
20+
```
21+
22+
MWA solves this by providing the missing communication layer:
23+
```
24+
Mobile dApp ←→ MWA Protocol ←→ Wallet Application
25+
```
26+
27+
## How MWA Works
28+
29+
### Connection Flow
30+
31+
1. **Intent Broadcasting**: dApp sends an MWA intent with `solana-wallet://` scheme
32+
2. **Wallet Selection**: Android system displays a chooser dialog for installed wallets
33+
3. **WebSocket Establishment**: Selected wallet app establishes a persistent connection
34+
4. **Secure Communication**: Encrypted message exchange using AES-128-GCM
35+
36+
### Technical Implementation
37+
38+
**Android Integration:**
39+
```xml
40+
<intent-filter>
41+
<action android:name="android.intent.action.VIEW" />
42+
<category android:name="android.intent.category.DEFAULT" />
43+
<data android:scheme="solana-wallet" />
44+
</intent-filter>
45+
```
46+
47+
**JavaScript API:**
48+
```javascript
49+
import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
50+
51+
const result = await transact(async (wallet) => {
52+
// Authorization
53+
const authResult = await wallet.authorize({
54+
cluster: 'solana:devnet',
55+
identity: {
56+
name: 'My dApp',
57+
uri: 'https://mydapp.com'
58+
}
59+
});
60+
61+
// Transaction signing
62+
const signedTx = await wallet.signAndSendTransactions({
63+
transactions: [myTransaction]
64+
});
65+
66+
return signedTx;
67+
});
68+
```
69+
70+
## Protocol Messages
71+
72+
MWA uses JSON-RPC 2.0 format:
73+
74+
**Authorization Request:**
75+
```json
76+
{
77+
"jsonrpc": "2.0",
78+
"id": 1,
79+
"method": "authorize",
80+
"params": {
81+
"identity": {
82+
"name": "My dApp",
83+
"uri": "https://mydapp.com"
84+
},
85+
"cluster": "solana:devnet"
86+
}
87+
}
88+
```
89+
90+
**Wallet Response:**
91+
```json
92+
{
93+
"jsonrpc": "2.0",
94+
"id": 1,
95+
"result": {
96+
"auth_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
97+
"accounts": [
98+
{
99+
"address": "DemoKeyPair111111111111111111111111111111111",
100+
"label": "My Account"
101+
}
102+
]
103+
}
104+
}
105+
```
106+
107+
## Why iOS Doesn't Support MWA
108+
109+
- **Background Limitations**: iOS suspends WebSocket connections when apps are backgrounded
110+
- **Intent System**: No equivalent to Android's intent disambiguation
111+
- **Sandbox Restrictions**: Stricter inter-app communication policies
112+
113+
## MWA Protocol Versions
114+
115+
**MWA 1.0**: Basic authorization and signing functionality
116+
117+
**MWA 2.0**: Current version featuring:
118+
- Sign-in with Solana (SIWS) support
119+
- Enhanced security
120+
- Better error handling
121+
- Multi-account support
122+
123+
## Example: Before vs After MWA
124+
125+
**Without MWA:**
126+
```javascript
127+
if (isPhantomWallet) {
128+
await phantom.connect();
129+
} else if (isSolflareWallet) {
130+
await solflare.authorize();
131+
} else if (isBackpackWallet) {
132+
await backpack.init();
133+
}
134+
```
135+
136+
**With MWA:**
137+
```javascript
138+
const result = await transact(async (wallet) => {
139+
// Same API regardless of wallet
140+
return await wallet.authorize(params);
141+
});
142+
```
143+
144+
## Benefits and Limitations
145+
146+
### Benefits
147+
- **Unified API** across different wallet applications
148+
- **Secure key management** without exposing private keys
149+
- **User-controlled wallet selection** via Android's intent system
150+
- **Persistent sessions** with auth token caching
151+
152+
### Limitations
153+
- **Android-only** (iOS lacks intent disambiguation)
154+
- **Requires MWA-compatible wallets** to be installed
155+
- **WebSocket dependency** for persistent connections
156+
157+
## Conclusion
158+
159+
MWA enables mobile Solana dApps to connect with wallets as seamlessly as web applications, but currently only works on Android due to platform limitations.

_posts/TEMPLATE.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: 文章标题
3+
date: 2025-01-XX XX:XX:XX +0800
4+
categories: [分类1, 分类2]
5+
tags: [标签1, 标签2, 标签3] # TAG names should always be lowercase
6+
published: false # 设置为 false 可以隐藏文章
7+
---
8+
9+
# 文章标题
10+
11+
## 简介
12+
在这里写文章的简介或摘要...
13+
14+
## 主要内容
15+
16+
### 章节1
17+
在这里写第一个章节的内容...
18+
19+
### 章节2
20+
在这里写第二个章节的内容...
21+
22+
## 代码示例
23+
```javascript
24+
// 在这里写代码示例
25+
function example() {
26+
console.log("Hello World!");
27+
}
28+
```
29+
30+
## 总结
31+
在这里写文章的总结...
32+
33+
---
34+
35+
## 模板使用说明
36+
37+
1. **复制此文件**:复制 `TEMPLATE.md` 并重命名为 `YYYY-MM-DD-你的标题.md`
38+
2. **修改 front matter**
39+
- 修改 `title` 为你的文章标题
40+
- 修改 `date` 为当前日期时间
41+
- 修改 `categories``tags` 为相关内容
42+
-`published: false` 改为 `published: true` 或直接删除此行
43+
3. **删除此说明部分**:删除从 "## 模板使用说明" 开始的所有内容
44+
4. **开始写作**:在 "## 简介" 部分开始写你的内容
45+
46+
## 常用 Markdown 语法
47+
48+
### 标题
49+
```markdown
50+
# 一级标题
51+
## 二级标题
52+
### 三级标题
53+
```
54+
55+
### 列表
56+
```markdown
57+
- 无序列表项1
58+
- 无序列表项2
59+
60+
1. 有序列表项1
61+
2. 有序列表项2
62+
```
63+
64+
### 链接和图片
65+
```markdown
66+
[链接文字](https://example.com)
67+
![图片描述](图片路径)
68+
```
69+
70+
### 代码
71+
```markdown
72+
`行内代码`
73+
```
74+
代码块
75+
```

serve.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)