clawreum-sdk 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. package/README.md +36 -36
  2. package/package.json +1 -1
  3. package/src/index.js +25 -25
package/README.md CHANGED
@@ -15,24 +15,24 @@ const ClawreumMiner = require('clawreum-sdk');
15
15
 
16
16
  const miner = new ClawreumMiner({
17
17
  platform: 'telegram', // 'telegram' | 'discord' | 'whatsapp'
18
- botId: '123456789', // 플랫폼 ID
19
- botName: 'MyMiningBot' // 표시 이름
18
+ botId: '123456789', // Platform bot ID
19
+ botName: 'MyMiningBot' // Bot display name
20
20
  });
21
21
 
22
- // 이벤트 리스너
22
+ // Event listeners
23
23
  miner.on('reward', (data) => {
24
24
  console.log(`+${data.reward.toFixed(4)} CLAWREUM`);
25
25
  });
26
26
 
27
27
  miner.on('balance', (data) => {
28
- console.log(`정제중: ${data.refining}, 클레임 가능: ${data.claimable}`);
28
+ console.log(`Refining: ${data.refining}, Claimable: ${data.claimable}`);
29
29
  });
30
30
 
31
31
  miner.on('error', (err) => {
32
- console.error('에러:', err.message);
32
+ console.error('Error:', err.message);
33
33
  });
34
34
 
35
- // 채굴 시작
35
+ // Start mining
36
36
  miner.start();
37
37
  ```
38
38
 
@@ -40,41 +40,41 @@ miner.start();
40
40
 
41
41
  | Option | Type | Required | Default | Description |
42
42
  |--------|------|----------|---------|-------------|
43
- | `platform` | string | | - | 플랫폼 (`telegram`, `discord`, `whatsapp`) |
44
- | `botId` | string | | - | 플랫폼 ID |
45
- | `botName` | string | | - | 표시 이름 |
46
- | `server` | string | | `wss://api.clawreum.com` | WebSocket 서버 URL |
47
- | `ownerWallet` | string | | - | 보상 받을 지갑 주소 |
48
- | `autoReconnect` | boolean | | `true` | 자동 재연결 |
49
- | `miningInterval` | number | | `250` | 채굴 액션 간격 (ms) |
43
+ | `platform` | string | Yes | - | Bot platform (`telegram`, `discord`, `whatsapp`) |
44
+ | `botId` | string | Yes | - | Platform bot ID |
45
+ | `botName` | string | Yes | - | Bot display name |
46
+ | `server` | string | No | `wss://api.clawreum.com` | WebSocket server URL |
47
+ | `ownerWallet` | string | No | - | Wallet address for rewards |
48
+ | `autoReconnect` | boolean | No | `true` | Auto reconnect on disconnect |
49
+ | `miningInterval` | number | No | `250` | Mining action interval (ms) |
50
50
 
51
51
  ## Events
52
52
 
53
53
  | Event | Data | Description |
54
54
  |-------|------|-------------|
55
- | `registered` | `{ botId, characterName }` | 등록 완료 |
56
- | `authenticated` | `{ botName }` | 인증 성공 |
57
- | `joined` | `{ room, botId }` | 입장 |
58
- | `mining` | `{ started: true }` | 채굴 루프 시작 |
59
- | `progress` | `{ progress }` | 채굴 진행률 (0~1) |
60
- | `reward` | `{ reward, base, bonus, packId }` | 채굴 보상 |
61
- | `balance` | `{ refining, claimable, world, boost }` | 잔액 동기화 |
62
- | `block` | `{ block, pack, difficulty }` | 블록 업데이트 |
63
- | `disconnected` | `{ code, reason }` | 연결 종료 |
64
- | `stopped` | - | 채굴 중지 |
65
- | `error` | `Error` | 에러 발생 |
66
- | `log` | `string` | 로그 메시지 |
55
+ | `registered` | `{ botId, characterName }` | Bot registration complete |
56
+ | `authenticated` | `{ botName }` | Authentication successful |
57
+ | `joined` | `{ room, botId }` | Joined mining room |
58
+ | `mining` | `{ started: true }` | Mining loop started |
59
+ | `progress` | `{ progress }` | Mining progress (0~1) |
60
+ | `reward` | `{ reward, base, bonus, packId }` | Mining reward received |
61
+ | `balance` | `{ refining, claimable, world, boost }` | Balance sync |
62
+ | `block` | `{ block, pack, difficulty }` | Block update |
63
+ | `disconnected` | `{ code, reason }` | Connection closed |
64
+ | `stopped` | - | Mining stopped |
65
+ | `error` | `Error` | Error occurred |
66
+ | `log` | `string` | Log message |
67
67
 
68
68
  ## Methods
69
69
 
70
70
  ### `start()`
71
- 채굴을 시작합니다.
71
+ Start mining.
72
72
 
73
73
  ### `stop()`
74
- 채굴을 중지하고 연결을 종료합니다.
74
+ Stop mining and close connection.
75
75
 
76
76
  ### `getStatus()`
77
- 현재 상태를 반환합니다.
77
+ Get current status.
78
78
 
79
79
  ```javascript
80
80
  const status = miner.getStatus();
@@ -104,27 +104,27 @@ miner.on('log', console.log);
104
104
  miner.on('error', console.error);
105
105
 
106
106
  miner.on('registered', ({ botId }) => {
107
- console.log(`봇 등록됨: ${botId}`);
107
+ console.log(`Bot registered: ${botId}`);
108
108
  });
109
109
 
110
110
  miner.on('reward', ({ reward, bonus }) => {
111
- console.log(`채굴 성공! +${reward.toFixed(4)} (보너스: ${bonus.toFixed(4)})`);
111
+ console.log(`Mining success! +${reward.toFixed(4)} (bonus: ${bonus.toFixed(4)})`);
112
112
  });
113
113
 
114
114
  miner.on('balance', ({ refining, claimable }) => {
115
- console.log(`잔액 - 정제중: ${refining.toFixed(2)}, 클레임: ${claimable.toFixed(2)}`);
115
+ console.log(`Balance - Refining: ${refining.toFixed(2)}, Claimable: ${claimable.toFixed(2)}`);
116
116
  });
117
117
 
118
- // 시작
118
+ // Start
119
119
  miner.start();
120
120
 
121
- // 10분 상태 확인
121
+ // Check status after 10 minutes
122
122
  setTimeout(() => {
123
123
  const status = miner.getStatus();
124
- console.log(`총 채굴량: ${status.stats.totalMined.toFixed(4)} CLAWREUM`);
124
+ console.log(`Total mined: ${status.stats.totalMined.toFixed(4)} CLAWREUM`);
125
125
  }, 600000);
126
126
 
127
- // 종료 처리
127
+ // Graceful shutdown
128
128
  process.on('SIGINT', () => {
129
129
  miner.stop();
130
130
  process.exit();
@@ -134,7 +134,7 @@ process.on('SIGINT', () => {
134
134
  ## Requirements
135
135
 
136
136
  - Node.js 18+
137
- - 등록된 (Telegram/Discord/WhatsApp)
137
+ - Registered bot (Telegram/Discord/WhatsApp)
138
138
 
139
139
  ## License
140
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawreum-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Clawreum Mining SDK - Bot client for mining CLAWREUM tokens",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Clawreum Mining SDK
3
3
  *
4
- * 사용법:
4
+ * Usage:
5
5
  * const ClawreumMiner = require('clawreum-sdk');
6
6
  *
7
7
  * const miner = new ClawreumMiner({
@@ -25,18 +25,18 @@ class ClawreumMiner extends EventEmitter {
25
25
  /**
26
26
  * @param {Object} options
27
27
  * @param {string} options.platform - 'telegram' | 'discord' | 'whatsapp'
28
- * @param {string} options.botId - 플랫폼 ID
29
- * @param {string} options.botName - 표시 이름
30
- * @param {string} [options.server] - WebSocket 서버 URL (기본: wss://api.clawreum.com)
31
- * @param {string} [options.ownerWallet] - 보상 받을 지갑 주소
32
- * @param {boolean} [options.autoReconnect] - 자동 재연결 (기본: true)
33
- * @param {number} [options.miningInterval] - 채굴 액션 간격 ms (기본: 250)
28
+ * @param {string} options.botId - Platform bot ID
29
+ * @param {string} options.botName - Bot display name
30
+ * @param {string} [options.server] - WebSocket server URL (default: wss://api.clawreum.com)
31
+ * @param {string} [options.ownerWallet] - Wallet address for rewards
32
+ * @param {boolean} [options.autoReconnect] - Auto reconnect (default: true)
33
+ * @param {number} [options.miningInterval] - Mining action interval in ms (default: 250)
34
34
  */
35
35
  constructor(options = {}) {
36
36
  super();
37
37
 
38
38
  if (!options.platform || !options.botId || !options.botName) {
39
- throw new Error('필수 옵션: platform, botId, botName');
39
+ throw new Error('Required options: platform, botId, botName');
40
40
  }
41
41
 
42
42
  this.options = {
@@ -55,7 +55,7 @@ class ClawreumMiner extends EventEmitter {
55
55
  this.maxReconnectAttempts = 10;
56
56
  this.botId = null;
57
57
 
58
- // 통계
58
+ // Stats
59
59
  this.stats = {
60
60
  totalMined: 0,
61
61
  miningCount: 0,
@@ -65,15 +65,15 @@ class ClawreumMiner extends EventEmitter {
65
65
  }
66
66
 
67
67
  /**
68
- * 채굴 시작
68
+ * Start mining
69
69
  */
70
70
  async start() {
71
71
  if (this.isConnected) {
72
- this.emit('warn', '이미 연결되어 있습니다');
72
+ this.emit('warn', 'Already connected');
73
73
  return;
74
74
  }
75
75
 
76
- this.emit('log', `서버 연결 중: ${this.options.server}`);
76
+ this.emit('log', `Connecting to server: ${this.options.server}`);
77
77
 
78
78
  try {
79
79
  const wsToken = await this._registerBot();
@@ -87,7 +87,7 @@ class ClawreumMiner extends EventEmitter {
87
87
  }
88
88
 
89
89
  /**
90
- * 채굴 중지
90
+ * Stop mining
91
91
  */
92
92
  stop() {
93
93
  this._stopMiningLoop();
@@ -102,7 +102,7 @@ class ClawreumMiner extends EventEmitter {
102
102
  }
103
103
 
104
104
  /**
105
- * 현재 상태 조회
105
+ * Get current status
106
106
  */
107
107
  getStatus() {
108
108
  return {
@@ -147,7 +147,7 @@ class ClawreumMiner extends EventEmitter {
147
147
  const result = await response.json();
148
148
 
149
149
  if (!result.success) {
150
- throw new Error(result.message || ' 등록 실패');
150
+ throw new Error(result.message || 'Bot registration failed');
151
151
  }
152
152
 
153
153
  this.botId = result.botId;
@@ -162,13 +162,13 @@ class ClawreumMiner extends EventEmitter {
162
162
  this.ws = new WebSocket(wsUrl);
163
163
 
164
164
  const timeout = setTimeout(() => {
165
- reject(new Error('연결 타임아웃'));
165
+ reject(new Error('Connection timeout'));
166
166
  this.ws.close();
167
167
  }, 30000);
168
168
 
169
169
  this.ws.on('open', () => {
170
170
  clearTimeout(timeout);
171
- this.emit('log', 'WebSocket 연결됨');
171
+ this.emit('log', 'WebSocket connected');
172
172
  this.reconnectAttempts = 0;
173
173
  });
174
174
 
@@ -177,7 +177,7 @@ class ClawreumMiner extends EventEmitter {
177
177
  const msg = JSON.parse(data.toString());
178
178
  this._handleMessage(msg, resolve, reject);
179
179
  } catch (err) {
180
- this.emit('error', new Error(`메시지 파싱 실패: ${err.message}`));
180
+ this.emit('error', new Error(`Message parsing failed: ${err.message}`));
181
181
  }
182
182
  });
183
183
 
@@ -218,7 +218,7 @@ class ClawreumMiner extends EventEmitter {
218
218
  break;
219
219
 
220
220
  case 'attestFail':
221
- this.emit('error', new Error(`인증 실패: ${data.reason}`));
221
+ this.emit('error', new Error(`Authentication failed: ${data.reason}`));
222
222
  if (rejectConnect) rejectConnect(new Error(data.reason));
223
223
  break;
224
224
 
@@ -264,11 +264,11 @@ class ClawreumMiner extends EventEmitter {
264
264
 
265
265
  case 'reAttestSuccess':
266
266
  this.sessionSecret = data.sessionSecret;
267
- this.emit('log', '재인증 성공');
267
+ this.emit('log', 'Re-authentication successful');
268
268
  break;
269
269
 
270
270
  case 'sessionRevoked':
271
- this.emit('error', new Error(`세션 취소: ${data.reason}`));
271
+ this.emit('error', new Error(`Session revoked: ${data.reason}`));
272
272
  this.stop();
273
273
  break;
274
274
 
@@ -285,7 +285,7 @@ class ClawreumMiner extends EventEmitter {
285
285
  break;
286
286
 
287
287
  default:
288
- // 기타 메시지
288
+ // Other messages
289
289
  break;
290
290
  }
291
291
  }
@@ -293,7 +293,7 @@ class ClawreumMiner extends EventEmitter {
293
293
  _handleChallenge(challenge, isReAttest = false) {
294
294
  const { challengeId, nonce, difficulty } = challenge;
295
295
 
296
- this.emit('log', `${isReAttest ? '' : ''}인증 챌린지 (difficulty: ${difficulty})`);
296
+ this.emit('log', `${isReAttest ? 'Re-' : ''}Authentication challenge (difficulty: ${difficulty})`);
297
297
 
298
298
  const solution = this._solveChallenge(nonce, difficulty);
299
299
 
@@ -354,14 +354,14 @@ class ClawreumMiner extends EventEmitter {
354
354
 
355
355
  _scheduleReconnect() {
356
356
  if (this.reconnectAttempts >= this.maxReconnectAttempts) {
357
- this.emit('error', new Error('최대 재연결 시도 초과'));
357
+ this.emit('error', new Error('Max reconnection attempts exceeded'));
358
358
  return;
359
359
  }
360
360
 
361
361
  const delay = Math.min(1000 * Math.pow(2, this.reconnectAttempts), 30000);
362
362
  this.reconnectAttempts++;
363
363
 
364
- this.emit('log', `${delay / 1000} 후 재연결 시도 (${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
364
+ this.emit('log', `Reconnecting in ${delay / 1000}s (${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
365
365
 
366
366
  setTimeout(() => {
367
367
  this.start();