@caict/bop-typescript-sdk 1.0.0

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 (115) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +112 -0
  5. package/package.json +90 -0
  6. package/src/bop/bop-base/README.md +5 -0
  7. package/src/bop/bop-base/base.ts +366 -0
  8. package/src/bop/bop-base/index.ts +83 -0
  9. package/src/bop/bop-base/permit.ts +116 -0
  10. package/src/bop/bop-base/test/base.test.ts +867 -0
  11. package/src/bop/bop-base/test/index.test.ts +69 -0
  12. package/src/bop/bop-base/test/permit.test.ts +125 -0
  13. package/src/bop/bop-base/tsconfig.json +8 -0
  14. package/src/bop/bop-proto/README.md +2 -0
  15. package/src/bop/bop-proto/bop-ws.proto +266 -0
  16. package/src/bop/bop-proto/bop-ws.ts +4447 -0
  17. package/src/bop/bop-proto/bop.proto +898 -0
  18. package/src/bop/bop-proto/bop.ts +12890 -0
  19. package/src/bop/bop-proto/tsconfig.json +8 -0
  20. package/src/bop/bop-ws/index.ts +315 -0
  21. package/src/bop/bop-ws/sample/sample.ts +107 -0
  22. package/src/bop/bop-ws/tsconfig.json +8 -0
  23. package/src/bop/index.ts +14 -0
  24. package/src/bop-sdk/index.ts +22 -0
  25. package/src/bop-sdk/interface/abstract-service/abstract-account.ts +23 -0
  26. package/src/bop-sdk/interface/abstract-service/abstract-chain.ts +9 -0
  27. package/src/bop-sdk/interface/abstract-service/abstract-contract.ts +16 -0
  28. package/src/bop-sdk/interface/abstract-service/abstract-ledger.ts +15 -0
  29. package/src/bop-sdk/interface/abstract-service/abstract-provider.ts +13 -0
  30. package/src/bop-sdk/interface/abstract-service/abstract-signer.ts +133 -0
  31. package/src/bop-sdk/interface/abstract-service/abstract-transaction.ts +86 -0
  32. package/src/bop-sdk/interface/provider-ws.ts +10 -0
  33. package/src/bop-sdk/interface/provider.ts +22 -0
  34. package/src/bop-sdk/interface/service/3rd.ts +54 -0
  35. package/src/bop-sdk/interface/service/account.ts +86 -0
  36. package/src/bop-sdk/interface/service/chain.ts +27 -0
  37. package/src/bop-sdk/interface/service/contract.ts +51 -0
  38. package/src/bop-sdk/interface/service/helper.ts +426 -0
  39. package/src/bop-sdk/interface/service/ledger.ts +75 -0
  40. package/src/bop-sdk/interface/service/offline/check/index.js +138 -0
  41. package/src/bop-sdk/interface/service/offline/common/constant.js +6 -0
  42. package/src/bop-sdk/interface/service/offline/common/snowFlakeUtils.js +192 -0
  43. package/src/bop-sdk/interface/service/offline/common/util.js +511 -0
  44. package/src/bop-sdk/interface/service/offline/exception/customErrors.js +29 -0
  45. package/src/bop-sdk/interface/service/offline/exception/errors.js +90 -0
  46. package/src/bop-sdk/interface/service/offline/exception/index.js +5 -0
  47. package/src/bop-sdk/interface/service/offline/operation/accountCreateOperation.js +28 -0
  48. package/src/bop-sdk/interface/service/offline/operation/accountSetMetadataOperation.js +44 -0
  49. package/src/bop-sdk/interface/service/offline/operation/accountSetPrivilegeOperation.js +49 -0
  50. package/src/bop-sdk/interface/service/offline/operation/contractCreateOperation.js +43 -0
  51. package/src/bop-sdk/interface/service/offline/operation/contractInvokeOperation.js +42 -0
  52. package/src/bop-sdk/interface/service/offline/operation/contractInvokeRequestOperation.js +69 -0
  53. package/src/bop-sdk/interface/service/offline/operation/gasSendOperation.js +29 -0
  54. package/src/bop-sdk/interface/service/offline/operation/gasSendRequestOperation.js +61 -0
  55. package/src/bop-sdk/interface/service/offline/operation/index.js +20 -0
  56. package/src/bop-sdk/interface/service/offline/proto/chain_pb.js +12079 -0
  57. package/src/bop-sdk/interface/service/offline/proto/common_pb.js +2867 -0
  58. package/src/bop-sdk/interface/service/offline/transaction/index.js +988 -0
  59. package/src/bop-sdk/interface/service/offline/transaction/operations.js +188 -0
  60. package/src/bop-sdk/interface/service/offline/validate/account.js +152 -0
  61. package/src/bop-sdk/interface/service/offline/validate/contract.js +101 -0
  62. package/src/bop-sdk/interface/service/offline/validate/index.js +10 -0
  63. package/src/bop-sdk/interface/service/offline/validate/transaction.js +51 -0
  64. package/src/bop-sdk/interface/service/transaction.ts +731 -0
  65. package/src/bop-sdk/interface/signer.ts +46 -0
  66. package/src/bop-sdk/interface/test/3rd.test.ts +1571 -0
  67. package/src/bop-sdk/interface/test/account.test.ts +284 -0
  68. package/src/bop-sdk/interface/test/chain.test.ts +45 -0
  69. package/src/bop-sdk/interface/test/contract.test.ts +283 -0
  70. package/src/bop-sdk/interface/test/ledger.test.ts +166 -0
  71. package/src/bop-sdk/interface/test/provider.test.ts +407 -0
  72. package/src/bop-sdk/interface/test/signer.test.ts +105 -0
  73. package/src/bop-sdk/interface/test/transaction.test.ts +713 -0
  74. package/src/bop-sdk/proto/bop-sdk-common.proto +159 -0
  75. package/src/bop-sdk/proto/bop-sdk-common.ts +829 -0
  76. package/src/bop-sdk/proto/bop-sdk-interface.proto +581 -0
  77. package/src/bop-sdk/proto/bop-sdk-interface.ts +10839 -0
  78. package/src/bop-sdk/proto/bop-sdk-utils.proto +86 -0
  79. package/src/bop-sdk/proto/bop-sdk-utils.ts +1495 -0
  80. package/src/bop-sdk/utils/abi/abi-coder.ts +147 -0
  81. package/src/bop-sdk/utils/abi/address.ts +109 -0
  82. package/src/bop-sdk/utils/abi/bignumber.ts +403 -0
  83. package/src/bop-sdk/utils/abi/bytes.ts +565 -0
  84. package/src/bop-sdk/utils/abi/coders/abstract-coder.ts +239 -0
  85. package/src/bop-sdk/utils/abi/coders/address.ts +58 -0
  86. package/src/bop-sdk/utils/abi/coders/anonymous.ts +25 -0
  87. package/src/bop-sdk/utils/abi/coders/array.ts +275 -0
  88. package/src/bop-sdk/utils/abi/coders/boolean.ts +21 -0
  89. package/src/bop-sdk/utils/abi/coders/bytes.ts +36 -0
  90. package/src/bop-sdk/utils/abi/coders/fixed-bytes.ts +35 -0
  91. package/src/bop-sdk/utils/abi/coders/null.ts +25 -0
  92. package/src/bop-sdk/utils/abi/coders/number.ts +56 -0
  93. package/src/bop-sdk/utils/abi/coders/string.ts +24 -0
  94. package/src/bop-sdk/utils/abi/coders/tuple.ts +73 -0
  95. package/src/bop-sdk/utils/abi/constants/addresses.ts +1 -0
  96. package/src/bop-sdk/utils/abi/constants/bignumbers.ts +30 -0
  97. package/src/bop-sdk/utils/abi/constants/hashes.ts +2 -0
  98. package/src/bop-sdk/utils/abi/constants/index.ts +15 -0
  99. package/src/bop-sdk/utils/abi/constants/strings.ts +2 -0
  100. package/src/bop-sdk/utils/abi/fragments.ts +1243 -0
  101. package/src/bop-sdk/utils/abi/id.ts +6 -0
  102. package/src/bop-sdk/utils/abi/index.ts +46 -0
  103. package/src/bop-sdk/utils/abi/interface.ts +921 -0
  104. package/src/bop-sdk/utils/abi/keccak256.ts +9 -0
  105. package/src/bop-sdk/utils/abi/properties.ts +172 -0
  106. package/src/bop-sdk/utils/abi/strings/bytes32.ts +40 -0
  107. package/src/bop-sdk/utils/abi/strings/idna.ts +258 -0
  108. package/src/bop-sdk/utils/abi/strings/index.ts +28 -0
  109. package/src/bop-sdk/utils/abi/strings/utf8.ts +373 -0
  110. package/src/bop-sdk/utils/encryption-address.ts +501 -0
  111. package/src/bop-sdk/utils/encryption-crypto.ts +427 -0
  112. package/src/bop-sdk/utils/encryption-mnemonics.ts +120 -0
  113. package/src/bop-sdk/utils/index.ts +27 -0
  114. package/src/bop-sdk/utils/logger.ts +480 -0
  115. package/src/index.ts +35 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # bop-typescript-sdk changes
2
+
3
+ * * *
4
+
5
+ **Changes in 1.0.0**
6
+
7
+ 适用:bop-typescript-sdk版本v1.0.0
8
+
9
+ [add] 支持星火链相关查询接口
10
+
11
+ [add] 支持账户相关的有效性校验、创建与查询接口
12
+
13
+ [add] 支持合约相关的有效性校验、创建与查询接口
14
+
15
+ [add] 支持构建交易及交易查询接口
16
+
17
+ [add] 支持区块的查询接口
18
+
19
+ [add] 支持星火开放平台相关账号许可接口
20
+
21
+ [add] 支持公私钥地址创建、解析、验签与密钥存储器构建、解析接口
22
+
23
+ [add] 支持助记词生成与解析接口
24
+
25
+ 更新日期:2025-3-12
26
+
27
+ * * *
28
+
29
+ *注:*
30
+ [add]代表新增内容
31
+
32
+ [opt]代表优化内容
33
+
34
+ [bug]代表修复的bug
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025 Corporation CAICT All rights reserved.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Apache SkyWalking
2
+ Copyright 2025 The Apache Software Foundation
3
+
4
+ This product includes software developed at
5
+ The Apache Software Foundation (http://www.apache.org/).
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # bop-typescript-sdk
2
+
3
+ [bop] sdk to develop with Xinghuo BIF Open Platform
4
+
5
+ ## What
6
+
7
+ The current package is primarily designed to implement interfaces for the Xinghuo Open Platform. Up to now, it has already realized two major modules, namely, the [Basic Service API] and the [Message Subscription Service]. Through these modules, direct communication with the Xinghuo Open Platform is feasible. In addition, relevant protocol components are handled using Protocol Buffers (protobuf).
8
+
9
+ ## Installation
10
+
11
+ First, you need to install the sdk by running
12
+
13
+ ```bash
14
+ npm install @caict/bop-typescript-sdk
15
+ ```
16
+
17
+ And add the following statement to your file:
18
+
19
+ ```js
20
+ require("@caict/bop-typescript-sdk");
21
+ ```
22
+
23
+ Or, if you are using TypeScript, add this to your file:
24
+
25
+ ```ts
26
+ import "@caict/bop-typescript-sdk";
27
+ ```
28
+
29
+ ## Use example
30
+
31
+ ### https service
32
+
33
+ ```ts
34
+ import {
35
+ Config,
36
+ ProviderByBop,
37
+ BopInterface,
38
+ SignerByBop,
39
+ } from "@caict/bop-typescript-sdk";
40
+
41
+ (async () => {
42
+ let config = new Config("https://bif-mainnet.bitfactory.cn", "xxx", "xxx");
43
+ let provider = new ProviderByBop(new BopInterface(config));
44
+ console.log(await provider.chain.getChainInfo());
45
+
46
+ let signer = new SignerByBop("your enc private key");
47
+ let signerWithProvider = signer.connect(provider);
48
+ console.log(await signerWithProvider.getAccount());
49
+ })();
50
+ ```
51
+
52
+ ### ws service
53
+
54
+ ```ts
55
+ import {
56
+ WsProviderByBop,
57
+ BopWsInterface,
58
+ WsConfig,
59
+ bopwsprotocol,
60
+ } from "@caict/bop-typescript-sdk";
61
+
62
+ async function main() {
63
+ try {
64
+ // 创建 BopWsInterface 实例,这里假设已经有 bopWs 实例化代码,可根据实际情况修改
65
+ const config = new WsConfig("ws://bif-mainnet.bitfactory.cn/bif/subscribe"); // 替换为实际的 WebSocket 地址
66
+ const bopWs = new BopWsInterface(config.url, config.heartBeatInterval);
67
+
68
+ // 标志位,用于判断 BLOCK_HEADER 回调是否已经发生
69
+ let blockHeaderCallbackTriggered = false;
70
+
71
+ const subscriptionBlockHeaderId = await bopWs.bop.subscribe(
72
+ bopwsprotocol.MessageType.BLOCK_HEADER,
73
+ (data) => {
74
+ let message: LedgerHeaderMessage = {};
75
+ message = LedgerHeaderMessage.fromJSON(data);
76
+ console.log("dealBlockHeader ing...", message);
77
+
78
+ // 设置标志位为 true,表示回调已经发生
79
+ blockHeaderCallbackTriggered = true;
80
+ },
81
+ );
82
+ console.log("Subscription BlockHeader ID:", subscriptionBlockHeaderId);
83
+
84
+ if (subscriptionBlockHeaderId !== "-1") {
85
+ // 等待 BLOCK_HEADER 回调发生
86
+ await new Promise<void>((resolve) => {
87
+ const intervalId = setInterval(() => {
88
+ if (blockHeaderCallbackTriggered) {
89
+ clearInterval(intervalId);
90
+ resolve();
91
+ }
92
+ }, 100); // 每 100 毫秒检查一次标志位
93
+ });
94
+ // 取消订阅
95
+ await bopWs.bop.unsubscribe(
96
+ bopwsprotocol.MessageType.BLOCK_HEADER,
97
+ subscriptionBlockHeaderId,
98
+ );
99
+ console.log("Unsubscribed from BLOCK_HEADER");
100
+ }
101
+
102
+ // 断开连接
103
+ await bopWs.bop.disconnect();
104
+ console.log("Disconnected from WebSocket");
105
+ } catch (error) {
106
+ console.error("An error occurred:", error);
107
+ }
108
+ }
109
+
110
+ // 调用 main 函数
111
+ main();
112
+ ```
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@caict/bop-typescript-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Xinghuo bop sdk",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "src",
8
+ "dist",
9
+ "LICENSE",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "npm run test:compile",
14
+ "lint": "npx prettier --check . && npx eslint .",
15
+ "lint:fix": "npx prettier --write . && npx eslint --fix .",
16
+ "clean": "rm -rf ./dist",
17
+ "test": "npm run test:compile && npm run test-bop && npm run test-sdk",
18
+ "test:compile": "tsc --project tsconfig.json && copyfiles -u 4 src/bop-sdk/interface/service/offline/**/* dist/bop-sdk/interface/service/",
19
+ "test-bop": "npm run test:compile && mocha --recursive 'dist/bop/**/test/**/*.js' -c --exit --timeout 30000",
20
+ "test-sdk": "npm run test:compile && mocha --recursive 'dist/bop-sdk/**/test/**/*.js' -c --exit --timeout 30000",
21
+ "ws-demo": "npm run build && node dist/bop/bop-ws/sample/sample.js"
22
+ },
23
+ "keywords": [
24
+ "caict",
25
+ "bop"
26
+ ],
27
+ "author": {
28
+ "name": "maxufeng",
29
+ "email": "maxufeng@caict.ac.cn"
30
+ },
31
+ "license": "apache2.0",
32
+ "engines": {
33
+ "node": "18.20.4"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/caict-4iot-dev/bop-typescript-sdk"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "dependencies": {
46
+ "@bifproject/bs58": "^5.0.0",
47
+ "@bufbuild/protobuf": "^2.2.3",
48
+ "@caict/bif-encryption": "^1.0.1",
49
+ "@caict/bif-protocol": "^1.0.2",
50
+ "@types/chai": "^4.2.0",
51
+ "@types/mocha": ">=9.1.0",
52
+ "@types/node": "^18.0.0",
53
+ "@types/sinon": "^9.0.8",
54
+ "assert": "^2.1.0",
55
+ "bignumber.js": "^9.1.2",
56
+ "bn.js": "^5.2.1",
57
+ "brdc-sjcl": "^1.1.1",
58
+ "chalk": "^2.4.2",
59
+ "co-wrap-all": "^1.0.0",
60
+ "crypto": "^1.0.1",
61
+ "crypto-js": "^4.2.0",
62
+ "debug": "^4.1.1",
63
+ "eslint": "^9.5.0",
64
+ "fs-extra": "^7.0.1",
65
+ "io-ts": "^1.10.4",
66
+ "is-type-of": "^2.1.0",
67
+ "js-sha3": "^0.9.3",
68
+ "json-bigint": "^1.0.0",
69
+ "lodash": "^4.17.11",
70
+ "long": "^5.2.3",
71
+ "merge-descriptors": "^2.0.0",
72
+ "randombytes": "^2.1.0",
73
+ "reconnecting-websocket": "^4.4.0",
74
+ "request-promise": "^4.2.6",
75
+ "semver": "^6.3.0",
76
+ "sjcl": "^1.0.8",
77
+ "typescript": "~5.0.0",
78
+ "ws": "^8.18.0"
79
+ },
80
+ "devDependencies": {
81
+ "chai": "4.2.0",
82
+ "chai-as-promised": "^8.0.1",
83
+ "copyfiles": "^2.4.1",
84
+ "mocha": "^11.0.1",
85
+ "mocha-typescript": "^1.1.17",
86
+ "sinon": "^19.0.2",
87
+ "ts-node": "^10.9.2",
88
+ "ts-proto": "^2.6.0"
89
+ }
90
+ }
@@ -0,0 +1,5 @@
1
+ # bop-base
2
+
3
+ The basic APIs of Xinghuo BIF Open Platform
4
+
5
+ # API