@weblock-wallet/sdk 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -0
- package/dist/index.cjs +106468 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +491 -0
- package/dist/index.d.ts +491 -0
- package/dist/index.js +106439 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# 초기화
|
|
2
|
+
|
|
3
|
+
```typescript
|
|
4
|
+
import WeBlockSDK from '@weblock-wallet/sdk'
|
|
5
|
+
const sdk = new WeBlockSDK({
|
|
6
|
+
environment: 'dev', // 'local' | 'dev' | 'stage' | 'prod'
|
|
7
|
+
apiKey: 'YOUR_API_KEY',
|
|
8
|
+
orgHost: 'YOUR_ORG_HOST',
|
|
9
|
+
})
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
# 기능명세
|
|
13
|
+
|
|
14
|
+
## 1. 사용자(sdk.user)
|
|
15
|
+
|
|
16
|
+
### 로그인
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
const response = await sdk.user.signIn('google.com')
|
|
20
|
+
// response: SignInResponse
|
|
21
|
+
// {
|
|
22
|
+
// status: 'NEW_USER' | 'WALLET_READY' | 'NEEDS_PASSWORD'
|
|
23
|
+
// email: string
|
|
24
|
+
// photoURL: string | null
|
|
25
|
+
// wallet?: WalletInfo // WALLET_READY 상태일 때만
|
|
26
|
+
// }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 지갑 생성
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const response = await sdk.user.createWallet('password')
|
|
33
|
+
// response: { wallet: WalletInfo }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 지갑 복구
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const response = await sdk.user.recoverWallet('password')
|
|
40
|
+
// response: { wallet: WalletInfo }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 로그아웃
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
await sdk.user.signOut()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 2. 지갑(sdk.wallet)
|
|
50
|
+
|
|
51
|
+
### 지갑 정보 조회
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const info = await sdk.wallet.getInfo()
|
|
55
|
+
// WalletInfo {
|
|
56
|
+
// address: string
|
|
57
|
+
// network: {
|
|
58
|
+
// current: NetworkInfo
|
|
59
|
+
// available: NetworkInfo[]
|
|
60
|
+
// }
|
|
61
|
+
// assets: {
|
|
62
|
+
// native: {
|
|
63
|
+
// symbol: string
|
|
64
|
+
// balance: string
|
|
65
|
+
// decimals: number
|
|
66
|
+
// usdValue?: string
|
|
67
|
+
// }
|
|
68
|
+
// tokens: TokenInfo[]
|
|
69
|
+
// nfts: NFTCollection[]
|
|
70
|
+
// }
|
|
71
|
+
// recentTransactions: Transaction[]
|
|
72
|
+
// }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 네트워크 변경
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const response = await sdk.wallet.switchNetwork('ethereum-mainnet')
|
|
79
|
+
// response: {
|
|
80
|
+
// network: NetworkInfo
|
|
81
|
+
// assets: WalletInfo['assets']
|
|
82
|
+
// }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 이벤트 구독
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// 지갑 정보 업데이트
|
|
89
|
+
const unsubscribe = sdk.wallet.onWalletUpdate((wallet: WalletInfo) => {
|
|
90
|
+
console.log('지갑 업데이트:', wallet)
|
|
91
|
+
})
|
|
92
|
+
// 트랜잭션 업데이트
|
|
93
|
+
const unsubscribeTx = sdk.wallet.onTransactionUpdate((tx: Transaction) => {
|
|
94
|
+
console.log('새로운 트랜잭션:', tx)
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 3. 자산(sdk.asset)
|
|
99
|
+
|
|
100
|
+
### 토큰 전송
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const response = await sdk.asset.transfer({
|
|
104
|
+
networkId: 'ethereum-mainnet',
|
|
105
|
+
tokenAddress: '0x...', // NATIVE인 경우 필요 없음
|
|
106
|
+
to: '0x...',
|
|
107
|
+
amount: '1.0',
|
|
108
|
+
type: 'NATIVE' | 'ERC20' | 'NFT' | 'SECURITY',
|
|
109
|
+
})
|
|
110
|
+
// response: { transaction: Transaction }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 토큰 추가
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
await sdk.asset.addToken({
|
|
117
|
+
type: 'ERC20' | 'SECURITY',
|
|
118
|
+
networkId: 'ethereum-mainnet',
|
|
119
|
+
address: '0x...',
|
|
120
|
+
symbol?: 'TOKEN',
|
|
121
|
+
decimals?: 18,
|
|
122
|
+
name?: 'Token Name'
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### NFT 컬렉션 추가
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
await sdk.asset.addNFTCollection({
|
|
130
|
+
networkId: 'ethereum-mainnet',
|
|
131
|
+
address: '0x...',
|
|
132
|
+
name?: 'NFT Collection'
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 시큐리티 토큰 전송 가능 여부 확인
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const result = await sdk.asset.checkSecurityTokenCompliance({
|
|
140
|
+
networkId: 'ethereum-mainnet',
|
|
141
|
+
tokenAddress: '0x...',
|
|
142
|
+
from: '0x...',
|
|
143
|
+
to: '0x...',
|
|
144
|
+
amount: '1.0',
|
|
145
|
+
})
|
|
146
|
+
// result: {
|
|
147
|
+
// canTransfer: boolean
|
|
148
|
+
// reasons?: string[]
|
|
149
|
+
// }
|
|
150
|
+
```
|