@caict/bop-typescript-sdk 1.0.1 → 1.0.3

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 (269) hide show
  1. package/CHANGELOG.md +10 -10
  2. package/README.md +7 -1
  3. package/base.tsconfig.json +14 -0
  4. package/dist/bop/bop-base/base.d.ts +24 -0
  5. package/dist/bop/bop-base/base.js +253 -0
  6. package/dist/bop/bop-base/base.js.map +1 -0
  7. package/dist/bop/bop-base/index.d.ts +18 -0
  8. package/dist/bop/bop-base/index.js +69 -0
  9. package/dist/bop/bop-base/index.js.map +1 -0
  10. package/dist/bop/bop-base/permit.d.ts +11 -0
  11. package/dist/bop/bop-base/permit.js +104 -0
  12. package/dist/bop/bop-base/permit.js.map +1 -0
  13. package/dist/bop/bop-base/test/base.test.d.ts +1 -0
  14. package/dist/bop/bop-base/test/base.test.js +772 -0
  15. package/dist/bop/bop-base/test/base.test.js.map +1 -0
  16. package/dist/bop/bop-base/test/index.test.d.ts +1 -0
  17. package/dist/bop/bop-base/test/index.test.js +89 -0
  18. package/dist/bop/bop-base/test/index.test.js.map +1 -0
  19. package/dist/bop/bop-base/test/permit.test.d.ts +1 -0
  20. package/dist/bop/bop-base/test/permit.test.js +140 -0
  21. package/dist/bop/bop-base/test/permit.test.js.map +1 -0
  22. package/dist/bop/bop-proto/bop-ws.d.ts +325 -0
  23. package/dist/bop/bop-proto/bop-ws.js +3599 -0
  24. package/dist/bop/bop-proto/bop-ws.js.map +1 -0
  25. package/dist/bop/bop-proto/bop.d.ts +903 -0
  26. package/dist/bop/bop-proto/bop.js +10421 -0
  27. package/dist/bop/bop-proto/bop.js.map +1 -0
  28. package/dist/bop/bop-ws/index.d.ts +43 -0
  29. package/dist/bop/bop-ws/index.js +265 -0
  30. package/dist/bop/bop-ws/index.js.map +1 -0
  31. package/dist/bop/bop-ws/sample/sample.d.ts +1 -0
  32. package/dist/bop/bop-ws/sample/sample.js +96 -0
  33. package/dist/bop/bop-ws/sample/sample.js.map +1 -0
  34. package/dist/bop/index.d.ts +5 -0
  35. package/dist/bop/index.js +37 -0
  36. package/dist/bop/index.js.map +1 -0
  37. package/dist/bop-sdk/index.d.ts +13 -0
  38. package/dist/bop-sdk/index.js +45 -0
  39. package/dist/bop-sdk/index.js.map +1 -0
  40. package/dist/bop-sdk/interface/abstract-service/abstract-account.d.ts +8 -0
  41. package/dist/bop-sdk/interface/abstract-service/abstract-account.js +7 -0
  42. package/dist/bop-sdk/interface/abstract-service/abstract-account.js.map +1 -0
  43. package/dist/bop-sdk/interface/abstract-service/abstract-chain.d.ts +5 -0
  44. package/dist/bop-sdk/interface/abstract-service/abstract-chain.js +7 -0
  45. package/dist/bop-sdk/interface/abstract-service/abstract-chain.js.map +1 -0
  46. package/dist/bop-sdk/interface/abstract-service/abstract-contract.d.ts +6 -0
  47. package/dist/bop-sdk/interface/abstract-service/abstract-contract.js +7 -0
  48. package/dist/bop-sdk/interface/abstract-service/abstract-contract.js.map +1 -0
  49. package/dist/bop-sdk/interface/abstract-service/abstract-ledger.d.ts +8 -0
  50. package/dist/bop-sdk/interface/abstract-service/abstract-ledger.js +7 -0
  51. package/dist/bop-sdk/interface/abstract-service/abstract-ledger.js.map +1 -0
  52. package/dist/bop-sdk/interface/abstract-service/abstract-provider.d.ts +12 -0
  53. package/dist/bop-sdk/interface/abstract-service/abstract-provider.js +7 -0
  54. package/dist/bop-sdk/interface/abstract-service/abstract-provider.js.map +1 -0
  55. package/dist/bop-sdk/interface/abstract-service/abstract-signer.d.ts +17 -0
  56. package/dist/bop-sdk/interface/abstract-service/abstract-signer.js +109 -0
  57. package/dist/bop-sdk/interface/abstract-service/abstract-signer.js.map +1 -0
  58. package/dist/bop-sdk/interface/abstract-service/abstract-transaction.d.ts +17 -0
  59. package/dist/bop-sdk/interface/abstract-service/abstract-transaction.js +7 -0
  60. package/dist/bop-sdk/interface/abstract-service/abstract-transaction.js.map +1 -0
  61. package/dist/bop-sdk/interface/provider-ws.d.ts +5 -0
  62. package/dist/bop-sdk/interface/provider-ws.js +12 -0
  63. package/dist/bop-sdk/interface/provider-ws.js.map +1 -0
  64. package/dist/bop-sdk/interface/provider.d.ts +7 -0
  65. package/dist/bop-sdk/interface/provider.js +23 -0
  66. package/dist/bop-sdk/interface/provider.js.map +1 -0
  67. package/dist/bop-sdk/interface/service/3rd.d.ts +12 -0
  68. package/dist/bop-sdk/interface/service/3rd.js +49 -0
  69. package/dist/bop-sdk/interface/service/3rd.js.map +1 -0
  70. package/dist/bop-sdk/interface/service/account.d.ts +12 -0
  71. package/dist/bop-sdk/interface/service/account.js +98 -0
  72. package/dist/bop-sdk/interface/service/account.js.map +1 -0
  73. package/dist/bop-sdk/interface/service/chain.d.ts +9 -0
  74. package/dist/bop-sdk/interface/service/chain.js +55 -0
  75. package/dist/bop-sdk/interface/service/chain.js.map +1 -0
  76. package/dist/bop-sdk/interface/service/contract.d.ts +10 -0
  77. package/dist/bop-sdk/interface/service/contract.js +67 -0
  78. package/dist/bop-sdk/interface/service/contract.js.map +1 -0
  79. package/dist/bop-sdk/interface/service/helper.d.ts +20 -0
  80. package/dist/bop-sdk/interface/service/helper.js +383 -0
  81. package/dist/bop-sdk/interface/service/helper.js.map +1 -0
  82. package/dist/bop-sdk/interface/service/ledger.d.ts +12 -0
  83. package/dist/bop-sdk/interface/service/ledger.js +89 -0
  84. package/dist/bop-sdk/interface/service/ledger.js.map +1 -0
  85. package/dist/bop-sdk/interface/service/offline/check/index.js +138 -0
  86. package/dist/bop-sdk/interface/service/offline/common/constant.js +6 -0
  87. package/dist/bop-sdk/interface/service/offline/common/snowFlakeUtils.js +192 -0
  88. package/dist/bop-sdk/interface/service/offline/common/util.js +511 -0
  89. package/dist/bop-sdk/interface/service/offline/exception/customErrors.js +29 -0
  90. package/dist/bop-sdk/interface/service/offline/exception/errors.js +90 -0
  91. package/dist/bop-sdk/interface/service/offline/exception/index.js +5 -0
  92. package/dist/bop-sdk/interface/service/offline/operation/accountCreateOperation.js +28 -0
  93. package/dist/bop-sdk/interface/service/offline/operation/accountSetMetadataOperation.js +44 -0
  94. package/dist/bop-sdk/interface/service/offline/operation/accountSetPrivilegeOperation.js +49 -0
  95. package/dist/bop-sdk/interface/service/offline/operation/contractCreateOperation.js +43 -0
  96. package/dist/bop-sdk/interface/service/offline/operation/contractInvokeOperation.js +42 -0
  97. package/dist/bop-sdk/interface/service/offline/operation/contractInvokeRequestOperation.js +69 -0
  98. package/dist/bop-sdk/interface/service/offline/operation/gasSendOperation.js +29 -0
  99. package/dist/bop-sdk/interface/service/offline/operation/gasSendRequestOperation.js +61 -0
  100. package/dist/bop-sdk/interface/service/offline/operation/index.js +20 -0
  101. package/dist/bop-sdk/interface/service/offline/proto/chain_pb.js +12079 -0
  102. package/dist/bop-sdk/interface/service/offline/proto/common_pb.js +2867 -0
  103. package/dist/bop-sdk/interface/service/offline/transaction/index.js +988 -0
  104. package/dist/bop-sdk/interface/service/offline/transaction/operations.js +188 -0
  105. package/dist/bop-sdk/interface/service/offline/validate/account.js +152 -0
  106. package/dist/bop-sdk/interface/service/offline/validate/contract.js +101 -0
  107. package/dist/bop-sdk/interface/service/offline/validate/index.js +10 -0
  108. package/dist/bop-sdk/interface/service/offline/validate/transaction.js +51 -0
  109. package/dist/bop-sdk/interface/service/transaction.d.ts +21 -0
  110. package/dist/bop-sdk/interface/service/transaction.js +591 -0
  111. package/dist/bop-sdk/interface/service/transaction.js.map +1 -0
  112. package/dist/bop-sdk/interface/signer.d.ts +12 -0
  113. package/dist/bop-sdk/interface/signer.js +53 -0
  114. package/dist/bop-sdk/interface/signer.js.map +1 -0
  115. package/dist/bop-sdk/interface/test/3rd.test.d.ts +1 -0
  116. package/dist/bop-sdk/interface/test/3rd.test.js +1524 -0
  117. package/dist/bop-sdk/interface/test/3rd.test.js.map +1 -0
  118. package/dist/bop-sdk/interface/test/account.test.d.ts +1 -0
  119. package/dist/bop-sdk/interface/test/account.test.js +225 -0
  120. package/dist/bop-sdk/interface/test/account.test.js.map +1 -0
  121. package/dist/bop-sdk/interface/test/chain.test.d.ts +1 -0
  122. package/dist/bop-sdk/interface/test/chain.test.js +72 -0
  123. package/dist/bop-sdk/interface/test/chain.test.js.map +1 -0
  124. package/dist/bop-sdk/interface/test/contract.test.d.ts +1 -0
  125. package/dist/bop-sdk/interface/test/contract.test.js +266 -0
  126. package/dist/bop-sdk/interface/test/contract.test.js.map +1 -0
  127. package/dist/bop-sdk/interface/test/ledger.test.d.ts +1 -0
  128. package/dist/bop-sdk/interface/test/ledger.test.js +167 -0
  129. package/dist/bop-sdk/interface/test/ledger.test.js.map +1 -0
  130. package/dist/bop-sdk/interface/test/provider.test.d.ts +1 -0
  131. package/dist/bop-sdk/interface/test/provider.test.js +295 -0
  132. package/dist/bop-sdk/interface/test/provider.test.js.map +1 -0
  133. package/dist/bop-sdk/interface/test/signer.test.d.ts +1 -0
  134. package/dist/bop-sdk/interface/test/signer.test.js +87 -0
  135. package/dist/bop-sdk/interface/test/signer.test.js.map +1 -0
  136. package/dist/bop-sdk/interface/test/transaction.test.d.ts +1 -0
  137. package/dist/bop-sdk/interface/test/transaction.test.js +663 -0
  138. package/dist/bop-sdk/interface/test/transaction.test.js.map +1 -0
  139. package/dist/bop-sdk/proto/bop-sdk-common.d.ts +225 -0
  140. package/dist/bop-sdk/proto/bop-sdk-common.js +831 -0
  141. package/dist/bop-sdk/proto/bop-sdk-common.js.map +1 -0
  142. package/dist/bop-sdk/proto/bop-sdk-interface.d.ts +623 -0
  143. package/dist/bop-sdk/proto/bop-sdk-interface.js +8623 -0
  144. package/dist/bop-sdk/proto/bop-sdk-interface.js.map +1 -0
  145. package/dist/bop-sdk/proto/bop-sdk-utils.d.ts +107 -0
  146. package/dist/bop-sdk/proto/bop-sdk-utils.js +1160 -0
  147. package/dist/bop-sdk/proto/bop-sdk-utils.js.map +1 -0
  148. package/dist/bop-sdk/utils/abi/abi-coder.d.ts +16 -0
  149. package/dist/bop-sdk/utils/abi/abi-coder.js +101 -0
  150. package/dist/bop-sdk/utils/abi/abi-coder.js.map +1 -0
  151. package/dist/bop-sdk/utils/abi/address.d.ts +8 -0
  152. package/dist/bop-sdk/utils/abi/address.js +116 -0
  153. package/dist/bop-sdk/utils/abi/address.js.map +1 -0
  154. package/dist/bop-sdk/utils/abi/bignumber.d.ts +39 -0
  155. package/dist/bop-sdk/utils/abi/bignumber.js +316 -0
  156. package/dist/bop-sdk/utils/abi/bignumber.js.map +1 -0
  157. package/dist/bop-sdk/utils/abi/bytes.d.ts +41 -0
  158. package/dist/bop-sdk/utils/abi/bytes.js +423 -0
  159. package/dist/bop-sdk/utils/abi/bytes.js.map +1 -0
  160. package/dist/bop-sdk/utils/abi/coders/abstract-coder.d.ts +52 -0
  161. package/dist/bop-sdk/utils/abi/coders/abstract-coder.js +164 -0
  162. package/dist/bop-sdk/utils/abi/coders/abstract-coder.js.map +1 -0
  163. package/dist/bop-sdk/utils/abi/coders/address.d.ts +7 -0
  164. package/dist/bop-sdk/utils/abi/coders/address.js +52 -0
  165. package/dist/bop-sdk/utils/abi/coders/address.js.map +1 -0
  166. package/dist/bop-sdk/utils/abi/coders/anonymous.d.ts +8 -0
  167. package/dist/bop-sdk/utils/abi/coders/anonymous.js +22 -0
  168. package/dist/bop-sdk/utils/abi/coders/anonymous.js.map +1 -0
  169. package/dist/bop-sdk/utils/abi/coders/array.d.ts +13 -0
  170. package/dist/bop-sdk/utils/abi/coders/array.js +220 -0
  171. package/dist/bop-sdk/utils/abi/coders/array.js.map +1 -0
  172. package/dist/bop-sdk/utils/abi/coders/boolean.d.ts +7 -0
  173. package/dist/bop-sdk/utils/abi/coders/boolean.js +20 -0
  174. package/dist/bop-sdk/utils/abi/coders/boolean.js.map +1 -0
  175. package/dist/bop-sdk/utils/abi/coders/bytes.d.ts +11 -0
  176. package/dist/bop-sdk/utils/abi/coders/bytes.js +33 -0
  177. package/dist/bop-sdk/utils/abi/coders/bytes.js.map +1 -0
  178. package/dist/bop-sdk/utils/abi/coders/fixed-bytes.d.ts +9 -0
  179. package/dist/bop-sdk/utils/abi/coders/fixed-bytes.js +28 -0
  180. package/dist/bop-sdk/utils/abi/coders/fixed-bytes.js.map +1 -0
  181. package/dist/bop-sdk/utils/abi/coders/null.d.ts +7 -0
  182. package/dist/bop-sdk/utils/abi/coders/null.js +24 -0
  183. package/dist/bop-sdk/utils/abi/coders/null.js.map +1 -0
  184. package/dist/bop-sdk/utils/abi/coders/number.d.ts +10 -0
  185. package/dist/bop-sdk/utils/abi/coders/number.js +45 -0
  186. package/dist/bop-sdk/utils/abi/coders/number.js.map +1 -0
  187. package/dist/bop-sdk/utils/abi/coders/string.d.ts +8 -0
  188. package/dist/bop-sdk/utils/abi/coders/string.js +21 -0
  189. package/dist/bop-sdk/utils/abi/coders/string.js.map +1 -0
  190. package/dist/bop-sdk/utils/abi/coders/tuple.d.ts +10 -0
  191. package/dist/bop-sdk/utils/abi/coders/tuple.js +60 -0
  192. package/dist/bop-sdk/utils/abi/coders/tuple.js.map +1 -0
  193. package/dist/bop-sdk/utils/abi/constants/addresses.d.ts +1 -0
  194. package/dist/bop-sdk/utils/abi/constants/addresses.js +5 -0
  195. package/dist/bop-sdk/utils/abi/constants/addresses.js.map +1 -0
  196. package/dist/bop-sdk/utils/abi/constants/bignumbers.d.ts +10 -0
  197. package/dist/bop-sdk/utils/abi/constants/bignumbers.js +21 -0
  198. package/dist/bop-sdk/utils/abi/constants/bignumbers.js.map +1 -0
  199. package/dist/bop-sdk/utils/abi/constants/hashes.d.ts +1 -0
  200. package/dist/bop-sdk/utils/abi/constants/hashes.js +5 -0
  201. package/dist/bop-sdk/utils/abi/constants/hashes.js.map +1 -0
  202. package/dist/bop-sdk/utils/abi/constants/index.d.ts +4 -0
  203. package/dist/bop-sdk/utils/abi/constants/index.js +19 -0
  204. package/dist/bop-sdk/utils/abi/constants/index.js.map +1 -0
  205. package/dist/bop-sdk/utils/abi/constants/strings.d.ts +1 -0
  206. package/dist/bop-sdk/utils/abi/constants/strings.js +6 -0
  207. package/dist/bop-sdk/utils/abi/constants/strings.js.map +1 -0
  208. package/dist/bop-sdk/utils/abi/fragments.d.ts +84 -0
  209. package/dist/bop-sdk/utils/abi/fragments.js +919 -0
  210. package/dist/bop-sdk/utils/abi/fragments.js.map +1 -0
  211. package/dist/bop-sdk/utils/abi/id.d.ts +1 -0
  212. package/dist/bop-sdk/utils/abi/id.js +10 -0
  213. package/dist/bop-sdk/utils/abi/id.js.map +1 -0
  214. package/dist/bop-sdk/utils/abi/index.d.ts +4 -0
  215. package/dist/bop-sdk/utils/abi/index.js +21 -0
  216. package/dist/bop-sdk/utils/abi/index.js.map +1 -0
  217. package/dist/bop-sdk/utils/abi/interface.d.ts +83 -0
  218. package/dist/bop-sdk/utils/abi/interface.js +663 -0
  219. package/dist/bop-sdk/utils/abi/interface.js.map +1 -0
  220. package/dist/bop-sdk/utils/abi/keccak256.d.ts +2 -0
  221. package/dist/bop-sdk/utils/abi/keccak256.js +13 -0
  222. package/dist/bop-sdk/utils/abi/keccak256.js.map +1 -0
  223. package/dist/bop-sdk/utils/abi/properties.d.ts +16 -0
  224. package/dist/bop-sdk/utils/abi/properties.js +141 -0
  225. package/dist/bop-sdk/utils/abi/properties.js.map +1 -0
  226. package/dist/bop-sdk/utils/abi/strings/bytes32.d.ts +3 -0
  227. package/dist/bop-sdk/utils/abi/strings/bytes32.js +36 -0
  228. package/dist/bop-sdk/utils/abi/strings/bytes32.js.map +1 -0
  229. package/dist/bop-sdk/utils/abi/strings/idna.d.ts +4 -0
  230. package/dist/bop-sdk/utils/abi/strings/idna.js +200 -0
  231. package/dist/bop-sdk/utils/abi/strings/idna.js.map +1 -0
  232. package/dist/bop-sdk/utils/abi/strings/index.d.ts +4 -0
  233. package/dist/bop-sdk/utils/abi/strings/index.js +17 -0
  234. package/dist/bop-sdk/utils/abi/strings/index.js.map +1 -0
  235. package/dist/bop-sdk/utils/abi/strings/utf8.d.ts +26 -0
  236. package/dist/bop-sdk/utils/abi/strings/utf8.js +265 -0
  237. package/dist/bop-sdk/utils/abi/strings/utf8.js.map +1 -0
  238. package/dist/bop-sdk/utils/encryption-address.d.ts +25 -0
  239. package/dist/bop-sdk/utils/encryption-address.js +426 -0
  240. package/dist/bop-sdk/utils/encryption-address.js.map +1 -0
  241. package/dist/bop-sdk/utils/encryption-crypto.d.ts +16 -0
  242. package/dist/bop-sdk/utils/encryption-crypto.js +406 -0
  243. package/dist/bop-sdk/utils/encryption-crypto.js.map +1 -0
  244. package/dist/bop-sdk/utils/encryption-mnemonics.d.ts +7 -0
  245. package/dist/bop-sdk/utils/encryption-mnemonics.js +129 -0
  246. package/dist/bop-sdk/utils/encryption-mnemonics.js.map +1 -0
  247. package/dist/bop-sdk/utils/index.d.ts +13 -0
  248. package/dist/bop-sdk/utils/index.js +22 -0
  249. package/dist/bop-sdk/utils/index.js.map +1 -0
  250. package/dist/bop-sdk/utils/logger.d.ts +52 -0
  251. package/dist/bop-sdk/utils/logger.js +377 -0
  252. package/dist/bop-sdk/utils/logger.js.map +1 -0
  253. package/dist/index.d.ts +4 -0
  254. package/dist/index.js +18 -0
  255. package/dist/index.js.map +1 -0
  256. package/package.json +92 -88
  257. package/src/bop/bop-base/test/base.test.ts +3 -1
  258. package/src/bop/bop-base/test/index.test.ts +3 -1
  259. package/src/bop/bop-base/test/permit.test.ts +3 -1
  260. package/src/bop-sdk/interface/test/3rd.test.ts +4 -1
  261. package/src/bop-sdk/interface/test/account.test.ts +4 -1
  262. package/src/bop-sdk/interface/test/chain.test.ts +3 -1
  263. package/src/bop-sdk/interface/test/contract.test.ts +4 -1
  264. package/src/bop-sdk/interface/test/ledger.test.ts +4 -1
  265. package/src/bop-sdk/interface/test/provider.test.ts +3 -1
  266. package/src/bop-sdk/interface/test/signer.test.ts +4 -1
  267. package/src/bop-sdk/interface/test/transaction.test.ts +4 -1
  268. package/tsconfig.json +24 -0
  269. package/NOTICE +0 -5
@@ -0,0 +1,772 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const chai_1 = require("chai");
36
+ const sinon = __importStar(require("sinon"));
37
+ const index_1 = require("../index");
38
+ const base_1 = require("../base");
39
+ const bop_1 = require("../../bop-proto/bop");
40
+ // 使用 Sinon 创建模拟对象
41
+ const sandbox = sinon.createSandbox();
42
+ const apiKey = "xxx";
43
+ const apiSecret = "xxx";
44
+ describe("BaseService", () => {
45
+ let config;
46
+ let baseService;
47
+ let baseServiceInvalidApiKey;
48
+ let baseServiceInvalidApiSecret;
49
+ let baseServiceMock;
50
+ beforeEach(() => {
51
+ config = new index_1.Config("https://bif-mainnet.bitfactory.cn", apiKey, apiSecret);
52
+ baseService = new base_1.BaseService(config.host, config.apiKey, config.apiSecret);
53
+ baseServiceInvalidApiKey = new base_1.BaseService(config.host, "xxxx", config.apiSecret);
54
+ baseServiceInvalidApiSecret = new base_1.BaseService(config.host, config.apiKey, "xxxx");
55
+ baseServiceMock = sandbox.mock(new base_1.BaseService(config.host, config.apiKey, config.apiSecret));
56
+ });
57
+ afterEach(() => {
58
+ // 重置模拟对象
59
+ sandbox.restore();
60
+ });
61
+ describe("invalid test", () => {
62
+ it("invalid api-key", () => __awaiter(void 0, void 0, void 0, function* () {
63
+ let response;
64
+ response = yield baseServiceInvalidApiKey.hello();
65
+ (0, chai_1.expect)(response.errorCode).to.equal(1122);
66
+ (0, chai_1.expect)(response.errorDesc).to.equal("API Key does not exist.");
67
+ }));
68
+ it("invalid api-secret", () => __awaiter(void 0, void 0, void 0, function* () {
69
+ let response;
70
+ response = yield baseServiceInvalidApiSecret.hello();
71
+ (0, chai_1.expect)(response.errorCode).to.equal(1208);
72
+ (0, chai_1.expect)(response.errorDesc).to.equal("The provided API Secret does not match the project");
73
+ }));
74
+ });
75
+ describe("api-test hello", () => {
76
+ //hello
77
+ it("normal hello", () => __awaiter(void 0, void 0, void 0, function* () {
78
+ let response;
79
+ response = yield baseService.hello();
80
+ console.log(response);
81
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
82
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
83
+ }));
84
+ });
85
+ //getAccount
86
+ describe("api-test getAccount", () => {
87
+ it("getAccount only address true", () => __awaiter(void 0, void 0, void 0, function* () {
88
+ const request = {
89
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
90
+ };
91
+ let response;
92
+ response = yield baseService.getAccount(request);
93
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
94
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
95
+ (0, chai_1.expect)(response.success).to.equal(true);
96
+ }));
97
+ it("getAccount address true with exist key", () => __awaiter(void 0, void 0, void 0, function* () {
98
+ var _a, _b;
99
+ const request = {
100
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
101
+ key: "layer_1_agent_did:bid:effvm1wrsYv4NHtyjvMGcPg1CWX9TW2a",
102
+ };
103
+ let response;
104
+ response = yield baseService.getAccount(request);
105
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
106
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
107
+ (0, chai_1.expect)(response.success).to.equal(true);
108
+ (0, chai_1.expect)((_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.metadatas[0]) === null || _b === void 0 ? void 0 : _b.key).to.equal("layer_1_agent_did:bid:effvm1wrsYv4NHtyjvMGcPg1CWX9TW2a");
109
+ }));
110
+ it("getAccount address true with not exist key", () => __awaiter(void 0, void 0, void 0, function* () {
111
+ var _c;
112
+ const request = {
113
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
114
+ key: "1",
115
+ };
116
+ let response;
117
+ response = yield baseService.getAccount(request);
118
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
119
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
120
+ (0, chai_1.expect)(response.success).to.equal(true);
121
+ (0, chai_1.expect)((_c = response === null || response === void 0 ? void 0 : response.result) === null || _c === void 0 ? void 0 : _c.metadatas).to.empty;
122
+ }));
123
+ it("getAccount only address and account not exist", () => __awaiter(void 0, void 0, void 0, function* () {
124
+ const request = {
125
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk",
126
+ };
127
+ let response;
128
+ response = yield baseService.getAccount(request);
129
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
130
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
131
+ (0, chai_1.expect)(response.success).to.equal(false);
132
+ }));
133
+ it("getAccount only address and account invalid", () => __awaiter(void 0, void 0, void 0, function* () {
134
+ const request = {
135
+ address: "xxx",
136
+ };
137
+ let response;
138
+ response = yield baseService.getAccount(request);
139
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
140
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
141
+ (0, chai_1.expect)(response.success).to.equal(false);
142
+ }));
143
+ it("getAccount address true with height(account not exist)", () => __awaiter(void 0, void 0, void 0, function* () {
144
+ const request = {
145
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
146
+ height: 1,
147
+ };
148
+ let response;
149
+ response = yield baseService.getAccount(request);
150
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
151
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
152
+ }));
153
+ it("getAccount address true with height(account exist)", () => __awaiter(void 0, void 0, void 0, function* () {
154
+ var _d;
155
+ const request = {
156
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
157
+ height: 5000000,
158
+ };
159
+ let response;
160
+ response = yield baseService.getAccount(request);
161
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
162
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
163
+ (0, chai_1.expect)(response.success).to.equal(true);
164
+ (0, chai_1.expect)((_d = response === null || response === void 0 ? void 0 : response.result) === null || _d === void 0 ? void 0 : _d.metadatas).to.be.an("array").that.is.not.empty;
165
+ }));
166
+ });
167
+ //getAccountBase
168
+ describe("api-test getAccountBase", () => {
169
+ it("getAccountBase address true", () => __awaiter(void 0, void 0, void 0, function* () {
170
+ const request = {
171
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
172
+ };
173
+ let response;
174
+ response = yield baseService.getAccountBase(request);
175
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
176
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
177
+ (0, chai_1.expect)(response.success).to.equal(true);
178
+ }));
179
+ it("getAccountBase address with invalid address", () => __awaiter(void 0, void 0, void 0, function* () {
180
+ const request = {
181
+ address: "xxx",
182
+ };
183
+ let response;
184
+ response = yield baseService.getAccountBase(request);
185
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
186
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
187
+ (0, chai_1.expect)(response.success).to.equal(false);
188
+ }));
189
+ it("getAccountBase address with not exist address", () => __awaiter(void 0, void 0, void 0, function* () {
190
+ const request = {
191
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk9",
192
+ };
193
+ let response;
194
+ response = yield baseService.getAccountBase(request);
195
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
196
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
197
+ (0, chai_1.expect)(response.success).to.equal(false);
198
+ }));
199
+ });
200
+ //getAccountMetaData
201
+ describe("api-test getAccountMetaData", () => {
202
+ it("getAccountMetaData address with no key", () => __awaiter(void 0, void 0, void 0, function* () {
203
+ const request = {
204
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
205
+ };
206
+ let response;
207
+ response = yield baseService.getAccountMetaData(request);
208
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
209
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
210
+ (0, chai_1.expect)(response.success).to.equal(true);
211
+ (0, chai_1.expect)(Object.keys(response.result).length).to.be.greaterThan(0);
212
+ }));
213
+ it("getAccountMetaData address with exist key", () => __awaiter(void 0, void 0, void 0, function* () {
214
+ const request = {
215
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
216
+ key: "layer_2_agent_did:bid:efGeHdgd1AwmtgUBKac3bGqrmPoNhA1k",
217
+ };
218
+ let response;
219
+ response = yield baseService.getAccountMetaData(request);
220
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
221
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
222
+ (0, chai_1.expect)(response.success).to.equal(true);
223
+ (0, chai_1.expect)(Object.keys(response.result).length).to.be.greaterThan(0);
224
+ }));
225
+ it("getAccountMetaData address with not exist key", () => __awaiter(void 0, void 0, void 0, function* () {
226
+ const request = {
227
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk8",
228
+ key: "1",
229
+ };
230
+ let response;
231
+ response = yield baseService.getAccountMetaData(request);
232
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
233
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
234
+ (0, chai_1.expect)(response.success).to.equal(true);
235
+ (0, chai_1.expect)(response.result).to.be.empty;
236
+ }));
237
+ it("getAccountMetaData with invalid address", () => __awaiter(void 0, void 0, void 0, function* () {
238
+ const request = {
239
+ address: "xxx",
240
+ };
241
+ let response;
242
+ response = yield baseService.getAccountMetaData(request);
243
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
244
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
245
+ (0, chai_1.expect)(response.success).to.equal(false);
246
+ (0, chai_1.expect)(response.result).to.be.empty;
247
+ }));
248
+ it("getAccountMetaData with not exist address", () => __awaiter(void 0, void 0, void 0, function* () {
249
+ const request = {
250
+ address: "did:bid:efEnXEGWYjHRw1CzK4KpWTdusnaRokk9",
251
+ };
252
+ let response;
253
+ response = yield baseService.getAccountMetaData(request);
254
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
255
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
256
+ (0, chai_1.expect)(response.success).to.equal(false);
257
+ (0, chai_1.expect)(response.result).to.be.empty;
258
+ }));
259
+ });
260
+ //getLedger
261
+ describe("api-test getLedger", () => {
262
+ it("getLedger with no params", () => __awaiter(void 0, void 0, void 0, function* () {
263
+ const request = {};
264
+ let response;
265
+ response = yield baseService.getLedger(request);
266
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
267
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
268
+ (0, chai_1.expect)(response.success).to.equal(true);
269
+ }));
270
+ it("getLedger with normal seq", () => __awaiter(void 0, void 0, void 0, function* () {
271
+ var _a, _b;
272
+ const request = {
273
+ seq: 1,
274
+ };
275
+ let response;
276
+ response = yield baseService.getLedger(request);
277
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
278
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
279
+ (0, chai_1.expect)(response.success).to.equal(true);
280
+ (0, chai_1.expect)((_b = (_a = response.result) === null || _a === void 0 ? void 0 : _a.header) === null || _b === void 0 ? void 0 : _b.seq).to.equal(1);
281
+ }));
282
+ it("getLedger with abnormal seq", () => __awaiter(void 0, void 0, void 0, function* () {
283
+ const request = {
284
+ seq: 0,
285
+ };
286
+ let response;
287
+ response = yield baseService.getLedger(request);
288
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
289
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
290
+ (0, chai_1.expect)(response.success).to.equal(false);
291
+ }));
292
+ it("getLedger with leader", () => __awaiter(void 0, void 0, void 0, function* () {
293
+ var _c;
294
+ const request = {
295
+ withLeader: true,
296
+ };
297
+ let response;
298
+ response = yield baseService.getLedger(request);
299
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
300
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
301
+ (0, chai_1.expect)(response.success).to.equal(true);
302
+ (0, chai_1.expect)((_c = response.result) === null || _c === void 0 ? void 0 : _c.leader.length).to.be.greaterThan(0);
303
+ }));
304
+ it("getLedger with validators", () => __awaiter(void 0, void 0, void 0, function* () {
305
+ var _d;
306
+ const request = {
307
+ withValidator: true,
308
+ };
309
+ let response;
310
+ response = yield baseService.getLedger(request);
311
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
312
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
313
+ (0, chai_1.expect)(response.success).to.equal(true);
314
+ (0, chai_1.expect)((_d = response.result) === null || _d === void 0 ? void 0 : _d.validators.length).to.be.greaterThan(0);
315
+ }));
316
+ });
317
+ //submitTransaction
318
+ describe("api-test submitTransaction", () => {
319
+ it("submitTransaction normal", () => __awaiter(void 0, void 0, void 0, function* () {
320
+ var _a, _b;
321
+ const request = {
322
+ items: [
323
+ {
324
+ signatures: [
325
+ {
326
+ publicKey: "b065665b6fa23dc1c00b17b8d2cd86093c86bbae4c011247310f9160351bd64bc580cc",
327
+ signData: "F62BA0BD3CC98EFBBA20DB540C6660BD4547390625AD4FF6CEB7B216985F6EFB3092E3F9E36299068D668D52CA92ABAD944D28342E0DD4D1ACEE06D700350702",
328
+ },
329
+ ],
330
+ transactionBlob: "0A286469643A6269643A6566433552456946657361427575315558624D4A577645737146526B514B6971103022D605080122D10512C305080112BE053630383036303430353233343830313536313030313035373630303038306664356235303631303133663830363130303230363030303339363030306633303036303830363034303532363030343336313036313030343135373630303033353763303130303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303930303436336666666666666666313638303633303331313533633231343631303034363537356236303030383066643562333438303135363130303532353736303030383066643562353036313030356236313030643635363562363034303531383038303630323030313832383130333832353238333831383135313831353236303230303139313530383035313930363032303031393038303833383336303030356238333831313031353631303039623537383038323031353138313834303135323630323038313031393035303631303038303536356235303530353035303930353039303831303139303630316631363830313536313030633835373830383230333830353136303031383336303230303336313031303030613033313931363831353236303230303139313530356235303932353035303530363034303531383039313033393066333562363036303630343038303531393038313031363034303532383036303062383135323630323030313766363836353663366336663230373736663732366336343030303030303030303030303030303030303030303030303030303030303030303030303030303030303831353235303930353039303536303061313635363237613761373233303538323033336431366230663863613362323334646363396233336139623533303063333630313561383838373732633761656565633965353733613537316437346338303032391A041A0208012880C2D72F2A0F63726561746520636F6E747261637430AC87E32F3864",
331
+ },
332
+ ],
333
+ };
334
+ let response;
335
+ response = yield baseService.submitTransaction(request);
336
+ (0, chai_1.expect)(response.successCount).to.equal(1);
337
+ (0, chai_1.expect)((_a = response.results[0]) === null || _a === void 0 ? void 0 : _a.hash).to.equal("d4c9eb33750d66dc471cfb276807c0f1b61ace6dd969fce9cc7ab2c49c69e40a");
338
+ (0, chai_1.expect)((_b = response.results[0]) === null || _b === void 0 ? void 0 : _b.errorCode).to.equal(0);
339
+ }));
340
+ it("submitTransaction empty transaction", () => __awaiter(void 0, void 0, void 0, function* () {
341
+ var _c, _d, _e;
342
+ const request = {
343
+ items: [],
344
+ };
345
+ let response;
346
+ response = yield baseService.submitTransaction(request);
347
+ (0, chai_1.expect)(response.successCount).to.equal(0);
348
+ (0, chai_1.expect)((_c = response.results[0]) === null || _c === void 0 ? void 0 : _c.hash).to.equal("");
349
+ (0, chai_1.expect)((_d = response.results[0]) === null || _d === void 0 ? void 0 : _d.errorCode).to.equal(-9);
350
+ (0, chai_1.expect)((_e = response.results[0]) === null || _e === void 0 ? void 0 : _e.errorDesc).to.equal("交易数据不能为空");
351
+ }));
352
+ it("submitTransaction empty request", () => __awaiter(void 0, void 0, void 0, function* () {
353
+ var _f, _g, _h;
354
+ const request = {};
355
+ let response;
356
+ response = yield baseService.submitTransaction(request);
357
+ (0, chai_1.expect)(response.successCount).to.equal(0);
358
+ (0, chai_1.expect)((_f = response.results[0]) === null || _f === void 0 ? void 0 : _f.hash).to.equal("");
359
+ (0, chai_1.expect)((_g = response.results[0]) === null || _g === void 0 ? void 0 : _g.errorCode).to.equal(-9);
360
+ (0, chai_1.expect)((_h = response.results[0]) === null || _h === void 0 ? void 0 : _h.errorDesc).to.equal("交易数据不能为空");
361
+ }));
362
+ it("submitTransaction missing transactionBlob", () => __awaiter(void 0, void 0, void 0, function* () {
363
+ var _j, _k, _l;
364
+ const request = {
365
+ items: [
366
+ {
367
+ signatures: [
368
+ {
369
+ publicKey: "b065665b6fa23dc1c00b17b8d2cd86093c86bbae4c011247310f9160351bd64bc580cc",
370
+ signData: "F62BA0BD3CC98EFBBA20DB540C6660BD4547390625AD4FF6CEB7B216985F6EFB3092E3F9E36299068D668D52CA92ABAD944D28342E0DD4D1ACEE06D700350702",
371
+ },
372
+ ],
373
+ },
374
+ ],
375
+ };
376
+ let response;
377
+ response = yield baseService.submitTransaction(request);
378
+ (0, chai_1.expect)(response.successCount).to.equal(0);
379
+ (0, chai_1.expect)((_j = response.results[0]) === null || _j === void 0 ? void 0 : _j.hash).to.equal("");
380
+ (0, chai_1.expect)((_k = response.results[0]) === null || _k === void 0 ? void 0 : _k.errorCode).to.equal(-9);
381
+ (0, chai_1.expect)((_l = response.results[0]) === null || _l === void 0 ? void 0 : _l.errorDesc).to.equal("Transaction blob cannot be empty");
382
+ }));
383
+ it("submitTransaction missing signatures", () => __awaiter(void 0, void 0, void 0, function* () {
384
+ var _m, _o, _p;
385
+ const request = {
386
+ items: [
387
+ {
388
+ transactionBlob: "0A286469643A6269643A6566433552456946657361427575315558624D4A577645737146526B514B6971103022D605080122D10512C305080112BE053630383036303430353233343830313536313030313035373630303038306664356235303631303133663830363130303230363030303339363030306633303036303830363034303532363030343336313036313030343135373630303033353763303130303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303930303436336666666666666666313638303633303331313533633231343631303034363537356236303030383066643562333438303135363130303532353736303030383066643562353036313030356236313030643635363562363034303531383038303630323030313832383130333832353238333831383135313831353236303230303139313530383035313930363032303031393038303833383336303030356238333831313031353631303039623537383038323031353138313834303135323630323038313031393035303631303038303536356235303530353035303930353039303831303139303630316631363830313536313030633835373830383230333830353136303031383336303230303336313031303030613033313931363831353236303230303139313530356235303932353035303530363034303531383039313033393066333562363036303630343038303531393038313031363034303532383036303062383135323630323030313766363836353663366336663230373736663732366336343030303030303030303030303030303030303030303030303030303030303030303030303030303030303831353235303930353039303536303061313635363237613761373233303538323033336431366230663863613362323334646363396233336139623533303063333630313561383838373732633761656565633965353733613537316437346338303032391A041A0208012880C2D72F2A0F63726561746520636F6E747261637430AC87E32F3864",
389
+ },
390
+ ],
391
+ };
392
+ let response;
393
+ response = yield baseService.submitTransaction(request);
394
+ (0, chai_1.expect)(response.successCount).to.equal(0);
395
+ (0, chai_1.expect)((_m = response.results[0]) === null || _m === void 0 ? void 0 : _m.hash).to.equal("");
396
+ (0, chai_1.expect)((_o = response.results[0]) === null || _o === void 0 ? void 0 : _o.errorCode).to.equal(-9);
397
+ (0, chai_1.expect)((_p = response.results[0]) === null || _p === void 0 ? void 0 : _p.errorDesc).to.equal("Operation list cannot be empty");
398
+ }));
399
+ });
400
+ //getTransactionHistory
401
+ describe("api-test getTransactionHistory", () => {
402
+ it("getTransactionHistory with no params", () => __awaiter(void 0, void 0, void 0, function* () {
403
+ const request = {};
404
+ let response;
405
+ response = yield baseService.getTransactionHistory(request);
406
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
407
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
408
+ (0, chai_1.expect)(response.success).to.equal(true);
409
+ }));
410
+ it("getTransactionHistory with exist hash(log)", () => __awaiter(void 0, void 0, void 0, function* () {
411
+ var _a, _b, _c;
412
+ const request = {
413
+ hash: "170761ce1ff9028d2855d6b0a1fd30e4324abe7847c8ff138b9aa770402c1fa8",
414
+ };
415
+ let response;
416
+ response = yield baseService.getTransactionHistory(request);
417
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
418
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
419
+ (0, chai_1.expect)(response.success).to.equal(true);
420
+ (0, chai_1.expect)((_a = response.result) === null || _a === void 0 ? void 0 : _a.totalCount).to.equal(1);
421
+ (0, chai_1.expect)((_c = (_b = response.result) === null || _b === void 0 ? void 0 : _b.transactions[0]) === null || _c === void 0 ? void 0 : _c.hash).to.equal("170761ce1ff9028d2855d6b0a1fd30e4324abe7847c8ff138b9aa770402c1fa8");
422
+ }));
423
+ it("getTransactionHistory with exist hash(pay_coin)", () => __awaiter(void 0, void 0, void 0, function* () {
424
+ var _d, _e, _f;
425
+ const request = {
426
+ hash: "5b677393143a29d92e6ef5fb551e839cd0833db2a695b0f0361873576728051d",
427
+ };
428
+ let response;
429
+ response = yield baseService.getTransactionHistory(request);
430
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
431
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
432
+ (0, chai_1.expect)(response.success).to.equal(true);
433
+ (0, chai_1.expect)((_d = response.result) === null || _d === void 0 ? void 0 : _d.totalCount).to.equal(1);
434
+ (0, chai_1.expect)((_f = (_e = response.result) === null || _e === void 0 ? void 0 : _e.transactions[0]) === null || _f === void 0 ? void 0 : _f.hash).to.equal("5b677393143a29d92e6ef5fb551e839cd0833db2a695b0f0361873576728051d");
435
+ }));
436
+ it("getTransactionHistory with not exist hash", () => __awaiter(void 0, void 0, void 0, function* () {
437
+ const request = {
438
+ hash: "170761ce1ff9028d2855d6b0a1fd30e4324abe7847c8ff138b9aa770402c1fa1",
439
+ };
440
+ let response;
441
+ response = yield baseService.getTransactionHistory(request);
442
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
443
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
444
+ (0, chai_1.expect)(response.success).to.equal(false);
445
+ }));
446
+ it("getTransactionHistory with ledger seq", () => __awaiter(void 0, void 0, void 0, function* () {
447
+ var _g;
448
+ const request = {
449
+ ledgerSeq: 1,
450
+ };
451
+ let response;
452
+ response = yield baseService.getTransactionHistory(request);
453
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
454
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
455
+ (0, chai_1.expect)(response.success).to.equal(true);
456
+ (0, chai_1.expect)((_g = response.result) === null || _g === void 0 ? void 0 : _g.totalCount).to.equal(1);
457
+ }));
458
+ it("getTransactionHistory with start", () => __awaiter(void 0, void 0, void 0, function* () {
459
+ var _h, _j, _k;
460
+ const request = {
461
+ ledgerSeq: 5722198,
462
+ start: 1,
463
+ };
464
+ let response;
465
+ response = yield baseService.getTransactionHistory(request);
466
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
467
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
468
+ (0, chai_1.expect)(response.success).to.equal(true);
469
+ (0, chai_1.expect)((_h = response.result) === null || _h === void 0 ? void 0 : _h.totalCount).to.equal(2);
470
+ (0, chai_1.expect)((_k = (_j = response.result) === null || _j === void 0 ? void 0 : _j.transactions[0]) === null || _k === void 0 ? void 0 : _k.hash).to.equal("2fcb276718da653f063f703f58ef4feac32a354de85442763e53e1a07ee7b115");
471
+ }));
472
+ it("getTransactionHistory with limit", () => __awaiter(void 0, void 0, void 0, function* () {
473
+ var _l, _m, _o;
474
+ const request = {
475
+ ledgerSeq: 5722198,
476
+ limit: 1,
477
+ };
478
+ let response;
479
+ response = yield baseService.getTransactionHistory(request);
480
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
481
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
482
+ (0, chai_1.expect)(response.success).to.equal(true);
483
+ (0, chai_1.expect)((_l = response.result) === null || _l === void 0 ? void 0 : _l.totalCount).to.equal(2);
484
+ (0, chai_1.expect)((_o = (_m = response.result) === null || _m === void 0 ? void 0 : _m.transactions[0]) === null || _o === void 0 ? void 0 : _o.hash).to.equal("7355af35bf1a841f75ef54edef160600cfbcaa3173a0024a1da8181348d54900");
485
+ }));
486
+ });
487
+ //testTransaction
488
+ describe("api-test testTransaction", () => {
489
+ it("testTransaction ", () => __awaiter(void 0, void 0, void 0, function* () {
490
+ var _a;
491
+ const request = {
492
+ items: [
493
+ {
494
+ transactionJson: {
495
+ feeLimit: 100000,
496
+ sourceAddress: "did:bid:efmHwsoavf2SWDkm4vwUJFwzZBWQnVV7",
497
+ gasPrice: 1,
498
+ nonce: "173",
499
+ operations: [
500
+ {
501
+ type: 1,
502
+ sourceAddress: "did:bid:efmHwsoavf2SWDkm4vwUJFwzZBWQnVV7",
503
+ createAccount: {
504
+ destAddress: "did:bid:efY72a55qY47gj2gSbvjLaLwdC439p4n",
505
+ initBalance: 1,
506
+ priv: {
507
+ masterWeight: 1,
508
+ thresholds: {
509
+ txThreshold: 1,
510
+ },
511
+ },
512
+ },
513
+ },
514
+ ],
515
+ },
516
+ signatureNumber: 1,
517
+ },
518
+ ],
519
+ };
520
+ let response;
521
+ response = yield baseService.testTransaction(request);
522
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
523
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
524
+ (0, chai_1.expect)(response.success).to.equal(true);
525
+ (0, chai_1.expect)((_a = response.result) === null || _a === void 0 ? void 0 : _a.hash).to.equal("0abe44d70d64a9147d60745dff4ecd51d2dc7ede960b6018329debbe70b697a9");
526
+ }));
527
+ });
528
+ //callContract
529
+ describe("api-test callContract", () => {
530
+ it("callContract contract address not exist", () => __awaiter(void 0, void 0, void 0, function* () {
531
+ const request = {
532
+ contractAddress: "",
533
+ feeLimit: 10000,
534
+ gasPrice: 1,
535
+ input: '{"method":"getsuperlist"}',
536
+ sourceAddress: "did:bid:ef56JqCtiFNBU7z8Y8Nd47QsNPVNbTu3",
537
+ };
538
+ let response;
539
+ response = yield baseService.callContract(request);
540
+ (0, chai_1.expect)(response.errorCode).to.equal(-9);
541
+ (0, chai_1.expect)(response.errorDesc).to.equal("Contract address cannot be empty");
542
+ (0, chai_1.expect)(response.success).to.equal(false);
543
+ }));
544
+ it("callContract systemContract dpos", () => __awaiter(void 0, void 0, void 0, function* () {
545
+ const request = {
546
+ contractAddress: "did:bid:efRH1Lbsuqwc6jRw3hK4H5Hp2RhHnryS",
547
+ feeLimit: 10000,
548
+ gasPrice: 1,
549
+ input: '{"method":"getsuperlist"}',
550
+ sourceAddress: "did:bid:ef56JqCtiFNBU7z8Y8Nd47QsNPVNbTu3",
551
+ };
552
+ let response;
553
+ response = yield baseService.callContract(request);
554
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
555
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
556
+ (0, chai_1.expect)(response.success).to.equal(true);
557
+ }));
558
+ it("callContract jsContract", () => __awaiter(void 0, void 0, void 0, function* () {
559
+ var _a, _b;
560
+ const request = {
561
+ contractAddress: "did:bid:ef2AAQSLB2YAuWJE8mHdUXncGWRVPkoJT",
562
+ feeLimit: 10000,
563
+ gasPrice: 1,
564
+ input: '{"method":"queryBid", "params":"did:bid:ef2AAQSLB2YAuWJE8mHdUXncGWRVPkoJT"}',
565
+ sourceAddress: "did:bid:ef56JqCtiFNBU7z8Y8Nd47QsNPVNbTu3",
566
+ };
567
+ let response;
568
+ response = yield baseService.callContract(request);
569
+ (0, chai_1.expect)((_b = (_a = response.result) === null || _a === void 0 ? void 0 : _a.queryRets[0]) === null || _b === void 0 ? void 0 : _b.error).to.equal('{"data":{"contract":"did:bid:ef2AAQSLB2YAuWJE8mHdUXncGWRVPkoJT","exception":"10706,The bid document is not existed","linenum":1}}');
570
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
571
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
572
+ (0, chai_1.expect)(response.success).to.equal(true);
573
+ }));
574
+ it("callContract evmContract", () => __awaiter(void 0, void 0, void 0, function* () {
575
+ var _c, _d;
576
+ const request = {
577
+ contractAddress: "did:bid:efBcAumwRYrESbpRVTo4J4vYqXXfqBzu",
578
+ feeLimit: 10000,
579
+ gasPrice: 1,
580
+ input: '{"function":"balanceOf(address)","args":"did:bid:efBcAumwRYrESbpRVTo4J4vYqXXfqBzu","return":"returns(uint256)"',
581
+ sourceAddress: "did:bid:ef56JqCtiFNBU7z8Y8Nd47QsNPVNbTu3",
582
+ };
583
+ let response;
584
+ response = yield baseService.callContract(request);
585
+ (0, chai_1.expect)((_d = (_c = response.result) === null || _c === void 0 ? void 0 : _c.queryRets[0]) === null || _d === void 0 ? void 0 : _d.result).to.equal('{"code":0,"data":"[0]","desc":"","evmcode":"0000000000000000000000000000000000000000000000000000000000000000","gasused":2767}');
586
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
587
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
588
+ (0, chai_1.expect)(response.success).to.equal(true);
589
+ }));
590
+ });
591
+ //query
592
+ describe("api-test query", () => {
593
+ it("query with no params", () => __awaiter(void 0, void 0, void 0, function* () {
594
+ const request = {};
595
+ let response;
596
+ response = yield baseService.query(request);
597
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
598
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
599
+ (0, chai_1.expect)(response.success).to.equal(true);
600
+ }));
601
+ it("query with hash", () => __awaiter(void 0, void 0, void 0, function* () {
602
+ var _a, _b, _c, _d;
603
+ const request = {
604
+ hash: "1b96779dab06c39c5a4d173bf0033000bd25076c7007dd03623a764ae60c9b48",
605
+ };
606
+ let response;
607
+ response = yield baseService.query(request);
608
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
609
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
610
+ (0, chai_1.expect)(response.success).to.equal(true);
611
+ (0, chai_1.expect)((_a = response.result) === null || _a === void 0 ? void 0 : _a.count).to.equal(1);
612
+ (0, chai_1.expect)((_b = response.result) === null || _b === void 0 ? void 0 : _b.totalPage).to.equal(1);
613
+ (0, chai_1.expect)((_d = (_c = response.result) === null || _c === void 0 ? void 0 : _c.transactionBases[0]) === null || _d === void 0 ? void 0 : _d.hash).to.equal("1b96779dab06c39c5a4d173bf0033000bd25076c7007dd03623a764ae60c9b48");
614
+ }));
615
+ it("query with bid and txtype", () => __awaiter(void 0, void 0, void 0, function* () {
616
+ var _e, _f, _g, _h;
617
+ const request = {
618
+ bid: "did:bid:efU9VvMvSydLUY5h1eEPDKJSWSXKVtKG",
619
+ txType: 0,
620
+ };
621
+ let response;
622
+ response = yield baseService.query(request);
623
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
624
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
625
+ (0, chai_1.expect)(response.success).to.equal(true);
626
+ (0, chai_1.expect)((_e = response.result) === null || _e === void 0 ? void 0 : _e.count).to.equal(16);
627
+ (0, chai_1.expect)((_f = response.result) === null || _f === void 0 ? void 0 : _f.totalPage).to.equal(2);
628
+ (0, chai_1.expect)((_h = (_g = response.result) === null || _g === void 0 ? void 0 : _g.transactionBases[0]) === null || _h === void 0 ? void 0 : _h.hash).to.equal("1b96779dab06c39c5a4d173bf0033000bd25076c7007dd03623a764ae60c9b48");
629
+ }));
630
+ it("query with ledger_seq", () => __awaiter(void 0, void 0, void 0, function* () {
631
+ var _j, _k, _l, _m;
632
+ const request = {
633
+ ledgerSeq: 5722974,
634
+ };
635
+ let response;
636
+ response = yield baseService.query(request);
637
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
638
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
639
+ (0, chai_1.expect)(response.success).to.equal(true);
640
+ (0, chai_1.expect)((_j = response.result) === null || _j === void 0 ? void 0 : _j.count).to.equal(1);
641
+ (0, chai_1.expect)((_k = response.result) === null || _k === void 0 ? void 0 : _k.totalPage).to.equal(1);
642
+ (0, chai_1.expect)((_m = (_l = response.result) === null || _l === void 0 ? void 0 : _l.transactionBases[0]) === null || _m === void 0 ? void 0 : _m.hash).to.equal("1b96779dab06c39c5a4d173bf0033000bd25076c7007dd03623a764ae60c9b48");
643
+ }));
644
+ it("query with start_time and end_time", () => __awaiter(void 0, void 0, void 0, function* () {
645
+ var _o, _p, _q, _r;
646
+ const request = {
647
+ startTime: "2024-12-26 14:52:09",
648
+ endTime: "2024-12-26 14:52:11",
649
+ };
650
+ let response;
651
+ response = yield baseService.query(request);
652
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
653
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
654
+ (0, chai_1.expect)(response.success).to.equal(true);
655
+ (0, chai_1.expect)((_o = response.result) === null || _o === void 0 ? void 0 : _o.count).to.equal(1);
656
+ (0, chai_1.expect)((_p = response.result) === null || _p === void 0 ? void 0 : _p.totalPage).to.equal(1);
657
+ (0, chai_1.expect)((_r = (_q = response.result) === null || _q === void 0 ? void 0 : _q.transactionBases[0]) === null || _r === void 0 ? void 0 : _r.hash).to.equal("1b96779dab06c39c5a4d173bf0033000bd25076c7007dd03623a764ae60c9b48");
658
+ }));
659
+ });
660
+ //getTransactionCache
661
+ describe("api-test getTransactionCache", () => {
662
+ it("getTransactionCacheChain with not exist hash", () => __awaiter(void 0, void 0, void 0, function* () {
663
+ const request = {
664
+ hash: "6eaaf19b9d73f646c051af7175a3c175410d2edfc1dad988cb6a6e171c4f902a",
665
+ };
666
+ let response;
667
+ response = yield baseService.getTransactionCacheChain(request);
668
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
669
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
670
+ (0, chai_1.expect)(response.success).to.equal(false);
671
+ }));
672
+ it("getTransactionCachePlat with not exist hash", () => __awaiter(void 0, void 0, void 0, function* () {
673
+ const request = {
674
+ hash: "6eaaf19b9d73f646c051af7175a3c175410d2edfc1dad988cb6a6e171c4f902a",
675
+ };
676
+ let response;
677
+ response = yield baseService.getTransactionCachePlat(request);
678
+ (0, chai_1.expect)(response.errorCode).to.equal(4);
679
+ (0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
680
+ (0, chai_1.expect)(response.success).to.equal(false);
681
+ }));
682
+ it("getTransactionCachePlat hash", () => __awaiter(void 0, void 0, void 0, function* () {
683
+ var _a, _b;
684
+ let platResponseJson = {
685
+ trace: "9d1450d34aac419b887b84567300050f",
686
+ result: {
687
+ total_count: 1,
688
+ transactions: [
689
+ {
690
+ blob: "0A286469643A6269643A6566433552456946657361427575315558624D4A577645737146526B514B697110F6880322330807522F0A296469643A6269643A65663262374A386141375044326D77535243754B4B4276423873726A4A7A32596F1080B51830C0843D3801",
691
+ hash: "e6366d3ae7231e8f59d44b710521dce671abd9d1c37c2e2b23736b12665e6547",
692
+ error_code: 1311,
693
+ signatures: [
694
+ {
695
+ sign_data: "4BAC56FCF51A90CDD9DC30D7E13072FCFD3181BB861FA34457FD47E4515AC168013E17A8887F1A8EAE8DD42D42447B0644043DAFCF5C007DECF62D05033B1B03",
696
+ public_key: "b065665b6fa23dc1c00b17b8d2cd86093c86bbae4c011247310f9160351bd64bc580cc",
697
+ },
698
+ ],
699
+ transaction: {
700
+ operations: [
701
+ {
702
+ type: 7,
703
+ pay_coin: {
704
+ dest_address: "did:bid:ef2b7J8aA7PD2mwSRCuKKBvB8srjJz2Yo",
705
+ amount: 400000,
706
+ },
707
+ },
708
+ ],
709
+ source_address: "did:bid:efC5REiFesaBuu1UXbMJWvEsqFRkQKiq",
710
+ nonce: 50294,
711
+ },
712
+ },
713
+ ],
714
+ },
715
+ success: true,
716
+ error_code: 0,
717
+ error_desc: "ok",
718
+ };
719
+ let response;
720
+ response = bop_1.GetTransactionCachePlatResponse.fromJSON(platResponseJson);
721
+ (0, chai_1.expect)((_a = response.result) === null || _a === void 0 ? void 0 : _a.transactions[0].hash).to.equal("e6366d3ae7231e8f59d44b710521dce671abd9d1c37c2e2b23736b12665e6547");
722
+ (0, chai_1.expect)((_b = response.result) === null || _b === void 0 ? void 0 : _b.totalCount).to.equal(1);
723
+ }));
724
+ });
725
+ //query/discard
726
+ describe("api-test query/discard", () => {
727
+ it("query/discard with no params", () => __awaiter(void 0, void 0, void 0, function* () {
728
+ var _a;
729
+ const request = {};
730
+ let response;
731
+ response = yield baseService.discard(request);
732
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
733
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
734
+ (0, chai_1.expect)(response.success).to.equal(true);
735
+ (0, chai_1.expect)((_a = response.result) === null || _a === void 0 ? void 0 : _a.count).to.be.greaterThan(0);
736
+ }));
737
+ it("query/discard with hash", () => __awaiter(void 0, void 0, void 0, function* () {
738
+ var _b, _c, _d;
739
+ const request = {
740
+ hash: "6eff3a70b7794578641ab7a5e56e3e14347a37b857174f3f92112e769b32f575",
741
+ };
742
+ let response;
743
+ response = yield baseService.discard(request);
744
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
745
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
746
+ (0, chai_1.expect)(response.success).to.equal(true);
747
+ (0, chai_1.expect)((_b = response.result) === null || _b === void 0 ? void 0 : _b.count).to.equal(1);
748
+ (0, chai_1.expect)((_d = (_c = response.result) === null || _c === void 0 ? void 0 : _c.transactionBases[0]) === null || _d === void 0 ? void 0 : _d.hash).to.equal("6eff3a70b7794578641ab7a5e56e3e14347a37b857174f3f92112e769b32f575");
749
+ }));
750
+ it("query/discard with not exist hash", () => __awaiter(void 0, void 0, void 0, function* () {
751
+ const request = {
752
+ hash: "6eff3a70b7794578641ab7a5e56e3e14347a37b857174f3f92112e769b32f576",
753
+ };
754
+ let response;
755
+ response = yield baseService.discard(request);
756
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
757
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
758
+ (0, chai_1.expect)(response.success).to.equal(true);
759
+ }));
760
+ });
761
+ //query/discard
762
+ describe("api-test getTxCacheSize", () => {
763
+ it("getTxCacheSize", () => __awaiter(void 0, void 0, void 0, function* () {
764
+ let response;
765
+ response = yield baseService.getTxCacheSize();
766
+ (0, chai_1.expect)(response.errorCode).to.equal(0);
767
+ (0, chai_1.expect)(response.errorDesc).to.equal("ok");
768
+ (0, chai_1.expect)(response.success).to.equal(true);
769
+ }));
770
+ });
771
+ });
772
+ //# sourceMappingURL=base.test.js.map