Skip to content

Commit 87fa891

Browse files
committed
v0.1.3-alpha
1 parent 7e6685f commit 87fa891

19 files changed

Lines changed: 1426 additions & 45 deletions

.npm-cache/_update-notifier-last-checked

Whitespace-only changes.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
---
1616

17+
## [0.1.3-alpha] - 2025-12-31
18+
19+
### 改进
20+
21+
- 与 WES v0.1.0 版本对齐
22+
- 更新依赖和文档
23+
24+
---
25+
1726
## [0.1.2-alpha] - 2025-11-26
1827

1928
### 修复

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import { Client, TokenService, Wallet } from '@weisyn/client-sdk-js';
7373

7474
// 1. 初始化客户端
7575
const client = new Client({
76-
endpoint: 'http://localhost:8545',
76+
endpoint: 'http://localhost:28680',
7777
protocol: 'http',
7878
});
7979

@@ -107,7 +107,7 @@ console.log(`转账成功!交易哈希: ${result.txHash}`);
107107
const { Client, TokenService, Wallet } = WESClientSDK;
108108
109109
const client = new Client({
110-
endpoint: 'http://localhost:8545',
110+
endpoint: 'http://localhost:28680',
111111
protocol: 'http',
112112
});
113113
@@ -151,7 +151,7 @@ import { WESClient } from '@weisyn/client-sdk-js';
151151

152152
// 初始化 WESClient
153153
const wesClient = new WESClient({
154-
endpoint: 'http://localhost:8545',
154+
endpoint: 'http://localhost:28680',
155155
protocol: 'http',
156156
});
157157

@@ -247,9 +247,9 @@ graph TB
247247
248248
subgraph API_GATEWAY["🌐 API 网关层"]
249249
direction LR
250-
JSONRPC["JSON-RPC 2.0<br/>:8545"]
250+
JSONRPC["JSON-RPC 2.0<br/>:28680"]
251251
HTTP["HTTP REST<br/>/api/v1/*"]
252-
WS["WebSocket<br/>:8081"]
252+
WS["WebSocket<br/>:28681"]
253253
end
254254
255255
subgraph BIZ_LAYER["💼 业务服务层"]

docs/DEVELOPER_GUIDE.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { Client, TokenService, Wallet } from '@weisyn/client-sdk-js';
4747

4848
// 1. 初始化客户端
4949
const client = new Client({
50-
endpoint: 'http://localhost:8545',
50+
endpoint: 'http://localhost:28680',
5151
protocol: 'http',
5252
});
5353

@@ -81,7 +81,7 @@ console.log(`转账成功!交易哈希: ${result.txHash}`);
8181
const { Client, TokenService, Wallet } = WESClientSDK;
8282
8383
const client = new Client({
84-
endpoint: 'http://localhost:8545',
84+
endpoint: 'http://localhost:28680',
8585
protocol: 'http',
8686
});
8787
@@ -102,14 +102,14 @@ SDK 支持两种传输协议(浏览器环境不支持 gRPC):
102102
```typescript
103103
// HTTP 客户端(最常用)
104104
const client = new Client({
105-
endpoint: 'http://localhost:8545',
105+
endpoint: 'http://localhost:28680',
106106
protocol: 'http',
107107
timeout: 30000,
108108
});
109109

110110
// WebSocket 客户端(用于事件订阅)
111111
const wsClient = new Client({
112-
endpoint: 'ws://localhost:8081',
112+
endpoint: 'ws://localhost:28681',
113113
protocol: 'websocket',
114114
});
115115
```
@@ -123,7 +123,7 @@ import { WESClient } from '@weisyn/client-sdk-js';
123123

124124
// 创建 WESClient
125125
const wesClient = new WESClient({
126-
endpoint: 'http://localhost:8545',
126+
endpoint: 'http://localhost:28680',
127127
protocol: 'http',
128128
});
129129

@@ -215,18 +215,18 @@ sequenceDiagram
215215
```typescript
216216
// 单客户端模式
217217
const client = new Client({
218-
endpoint: 'http://localhost:8545',
218+
endpoint: 'http://localhost:28680',
219219
protocol: 'http',
220220
});
221221

222222
// 多客户端模式(HTTP + WebSocket)
223223
const httpClient = new Client({
224-
endpoint: 'http://localhost:8545',
224+
endpoint: 'http://localhost:28680',
225225
protocol: 'http',
226226
});
227227

228228
const wsClient = new Client({
229-
endpoint: 'ws://localhost:8081',
229+
endpoint: 'ws://localhost:28681',
230230
protocol: 'websocket',
231231
});
232232
```
@@ -300,7 +300,7 @@ try {
300300
```typescript
301301
// 使用 WebSocket 客户端订阅事件
302302
const wsClient = new WESClient({
303-
endpoint: 'ws://localhost:8081',
303+
endpoint: 'ws://localhost:28681',
304304
protocol: 'websocket',
305305
});
306306

@@ -468,7 +468,7 @@ const result = await resourceService.deployContract({
468468
```typescript
469469
// 创建 WebSocket 客户端
470470
const wsClient = new WESClient({
471-
endpoint: 'ws://localhost:8081',
471+
endpoint: 'ws://localhost:28681',
472472
protocol: 'websocket',
473473
});
474474

@@ -524,7 +524,7 @@ type WESClientErrorCode =
524524
```typescript
525525
// HTTP 客户端自动管理连接
526526
const client = new Client({
527-
endpoint: 'http://localhost:8545',
527+
endpoint: 'http://localhost:28680',
528528
protocol: 'http',
529529
timeout: 30000,
530530
});
@@ -550,7 +550,7 @@ import { Client, TokenService, Wallet, WESClient } from '@weisyn/client-sdk-js';
550550

551551
// 类型安全
552552
const client: Client = new Client({
553-
endpoint: 'http://localhost:8545',
553+
endpoint: 'http://localhost:28680',
554554
protocol: 'http',
555555
});
556556

@@ -578,7 +578,7 @@ if (typeof window !== 'undefined') {
578578
```typescript
579579
// 确保节点 API 支持 CORS
580580
const client = new Client({
581-
endpoint: 'https://api.example.com:8545', // 使用 HTTPS
581+
endpoint: 'https://api.example.com:28680', // 使用 HTTPS
582582
protocol: 'http',
583583
});
584584
```

docs/LANGUAGE_AND_ENV_LIMITATIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ import { Client, TokenService, Wallet } from '@weisyn/client-sdk-js';
109109

110110
// 类型安全
111111
const client: Client = new Client({
112-
endpoint: 'http://localhost:8545',
112+
endpoint: 'http://localhost:28680',
113113
protocol: 'http',
114114
});
115115

docs/SCENARIOS_VISUAL_GUIDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ graph TB
8989
9090
subgraph API_GATEWAY["🌐 API 网关层"]
9191
direction LR
92-
JSONRPC["JSON-RPC 2.0<br/>:8545"]
92+
JSONRPC["JSON-RPC 2.0<br/>:28680"]
9393
HTTP["HTTP REST<br/>/api/v1/*"]
94-
WS["WebSocket<br/>:8081"]
94+
WS["WebSocket<br/>:28681"]
9595
end
9696
9797
subgraph BIZ_LAYER["💼 业务服务层"]

examples/simple-transfer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Client, TokenService, Wallet } from '@weisyn/client-sdk-js';
2020
async function main() {
2121
// 1. 初始化客户端
2222
const client = new Client({
23-
endpoint: 'http://localhost:8545',
23+
endpoint: 'http://localhost:28680',
2424
protocol: 'http',
2525
});
2626

examples/simple-transfer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function main() {
1616
// 1. 初始化客户端
1717
console.log('1️⃣ 初始化客户端...');
1818
const client = new Client({
19-
endpoint: 'http://localhost:8545',
19+
endpoint: 'http://localhost:28680',
2020
protocol: 'http',
2121
debug: true, // 启用调试日志
2222
});

mock/client.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ import type {
2121
Transaction,
2222
SubmitTxResult,
2323
EventSubscription,
24+
BlockInfo,
25+
TransactionReceipt,
26+
FeeEstimate,
27+
SyncStatus,
28+
TokenBalance,
29+
AIModelCallRequest,
30+
AIModelCallResult,
2431
} from '../src/client/wesclient-types';
2532

2633
/**
@@ -328,6 +335,103 @@ export class WESClientMock implements WESClient {
328335
};
329336
}
330337

338+
// ========== 新增 API 方法(用于满足最新 WESClient 接口) ==========
339+
340+
async getBlockByHeight(_height: number, _fullTx: boolean = false): Promise<BlockInfo | null> {
341+
await this.delay();
342+
if (this.errors.has('getBlockByHeight')) throw this.errors.get('getBlockByHeight')!;
343+
if (this.responses.has('getBlockByHeight')) return this.responses.get('getBlockByHeight') as BlockInfo | null;
344+
return null;
345+
}
346+
347+
async getBlockByHash(_hash: Uint8Array, _fullTx: boolean = false): Promise<BlockInfo | null> {
348+
await this.delay();
349+
if (this.errors.has('getBlockByHash')) throw this.errors.get('getBlockByHash')!;
350+
if (this.responses.has('getBlockByHash')) return this.responses.get('getBlockByHash') as BlockInfo | null;
351+
return null;
352+
}
353+
354+
async getTransactionReceipt(_txHash: string): Promise<TransactionReceipt | null> {
355+
await this.delay();
356+
if (this.errors.has('getTransactionReceipt')) throw this.errors.get('getTransactionReceipt')!;
357+
if (this.responses.has('getTransactionReceipt')) {
358+
return this.responses.get('getTransactionReceipt') as TransactionReceipt | null;
359+
}
360+
return null;
361+
}
362+
363+
async estimateFee(_tx: Transaction): Promise<FeeEstimate> {
364+
await this.delay();
365+
if (this.errors.has('estimateFee')) throw this.errors.get('estimateFee')!;
366+
if (this.responses.has('estimateFee')) return this.responses.get('estimateFee') as FeeEstimate;
367+
return {
368+
estimatedFee: 0n,
369+
feeRate: '',
370+
numInputs: 0,
371+
numOutputs: 0,
372+
};
373+
}
374+
375+
async getSyncStatus(): Promise<SyncStatus> {
376+
await this.delay();
377+
if (this.errors.has('getSyncStatus')) throw this.errors.get('getSyncStatus')!;
378+
if (this.responses.has('getSyncStatus')) return this.responses.get('getSyncStatus') as SyncStatus;
379+
return {
380+
syncing: false,
381+
currentHeight: 0,
382+
highestHeight: 0,
383+
startingBlock: 0,
384+
progress: 1,
385+
};
386+
}
387+
388+
async contractCall(
389+
_contractHash: Uint8Array,
390+
_method: string,
391+
_params?: number[],
392+
_payload?: Uint8Array
393+
): Promise<Uint8Array> {
394+
await this.delay();
395+
if (this.errors.has('contractCall')) throw this.errors.get('contractCall')!;
396+
if (this.responses.has('contractCall')) return this.responses.get('contractCall') as Uint8Array;
397+
return new Uint8Array(0);
398+
}
399+
400+
async unsubscribe(_subscriptionId: string): Promise<boolean> {
401+
await this.delay();
402+
if (this.errors.has('unsubscribe')) throw this.errors.get('unsubscribe')!;
403+
if (this.responses.has('unsubscribe')) return this.responses.get('unsubscribe') as boolean;
404+
return true;
405+
}
406+
407+
async getContractTokenBalance(
408+
_address: Uint8Array,
409+
_contractHash: Uint8Array,
410+
_tokenId?: string
411+
): Promise<TokenBalance> {
412+
await this.delay();
413+
if (this.errors.has('getContractTokenBalance')) throw this.errors.get('getContractTokenBalance')!;
414+
if (this.responses.has('getContractTokenBalance')) {
415+
return this.responses.get('getContractTokenBalance') as TokenBalance;
416+
}
417+
return {
418+
address: '',
419+
contractHash: '',
420+
contractAddress: '',
421+
tokenId: _tokenId || 'default',
422+
balance: '0',
423+
utxoCount: 0,
424+
height: 0,
425+
};
426+
}
427+
428+
async callAIModel(_request: AIModelCallRequest): Promise<AIModelCallResult> {
429+
await this.delay();
430+
if (this.errors.has('callAIModel')) throw this.errors.get('callAIModel')!;
431+
if (this.responses.has('callAIModel')) return this.responses.get('callAIModel') as AIModelCallResult;
432+
return { success: true };
433+
}
434+
331435

332436
async batchGetResources(resourceIds: Uint8Array[]): Promise<ResourceInfo[]> {
333437
return Promise.all(resourceIds.map((id) => this.getResource(id)));

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)