@alephium/web3 0.2.0-rc.2 → 0.2.0-rc.21

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 (121) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/dist/alephium-web3.min.js +1 -1
  4. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  5. package/dist/alephium-web3.min.js.map +1 -1
  6. package/dist/src/api/api-alephium.d.ts +126 -22
  7. package/dist/src/api/api-alephium.js +145 -79
  8. package/dist/src/api/api-explorer.d.ts +163 -48
  9. package/dist/src/api/api-explorer.js +157 -34
  10. package/dist/src/api/index.d.ts +3 -2
  11. package/dist/src/api/index.js +22 -3
  12. package/dist/src/api/types.d.ts +23 -0
  13. package/dist/src/api/types.js +240 -0
  14. package/dist/src/api/utils.d.ts +6 -0
  15. package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
  16. package/dist/src/contract/contract.d.ts +117 -69
  17. package/dist/src/contract/contract.js +401 -435
  18. package/dist/src/contract/events.d.ts +4 -4
  19. package/dist/src/contract/index.js +5 -1
  20. package/dist/src/contract/ralph.d.ts +5 -4
  21. package/dist/src/contract/ralph.js +27 -1
  22. package/dist/src/global.d.ts +4 -0
  23. package/dist/{scripts/stop-devnet.js → src/global.js} +17 -11
  24. package/dist/src/index.d.ts +2 -0
  25. package/dist/src/index.js +23 -1
  26. package/dist/src/signer/index.d.ts +0 -1
  27. package/dist/src/signer/index.js +5 -2
  28. package/dist/src/signer/signer.d.ts +21 -11
  29. package/dist/src/signer/signer.js +46 -9
  30. package/dist/src/transaction/index.d.ts +0 -1
  31. package/dist/src/transaction/index.js +5 -2
  32. package/dist/src/transaction/status.d.ts +2 -1
  33. package/dist/src/utils/bs58.d.ts +1 -0
  34. package/dist/src/utils/bs58.js +13 -1
  35. package/dist/src/utils/index.d.ts +0 -1
  36. package/dist/src/utils/index.js +5 -2
  37. package/dist/src/utils/subscription.d.ts +0 -1
  38. package/dist/src/utils/subscription.js +2 -1
  39. package/dist/src/utils/utils.d.ts +6 -11
  40. package/dist/src/utils/utils.js +21 -25
  41. package/jest-config.json +11 -0
  42. package/package.json +11 -47
  43. package/src/api/api-alephium.ts +178 -30
  44. package/src/api/api-explorer.ts +234 -51
  45. package/src/api/index.ts +14 -3
  46. package/src/api/types.ts +233 -0
  47. package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
  48. package/src/contract/contract.ts +602 -527
  49. package/src/contract/events.ts +6 -6
  50. package/src/contract/ralph.ts +29 -4
  51. package/src/{transaction/sign-verify.ts → global.ts} +14 -15
  52. package/src/index.ts +7 -0
  53. package/src/signer/index.ts +0 -1
  54. package/src/signer/signer.ts +70 -19
  55. package/src/transaction/index.ts +0 -1
  56. package/src/transaction/status.ts +4 -2
  57. package/src/utils/bs58.ts +11 -0
  58. package/src/utils/index.ts +0 -1
  59. package/src/utils/subscription.ts +3 -3
  60. package/src/utils/utils.ts +14 -22
  61. package/.eslintrc.json +0 -21
  62. package/LICENSE +0 -165
  63. package/contracts/add/add.ral +0 -16
  64. package/contracts/greeter/greeter.ral +0 -7
  65. package/contracts/greeter/greeter_interface.ral +0 -3
  66. package/contracts/greeter_main.ral +0 -9
  67. package/contracts/main.ral +0 -6
  68. package/contracts/sub/sub.ral +0 -9
  69. package/dev/user.conf +0 -29
  70. package/dist/scripts/create-project.d.ts +0 -2
  71. package/dist/scripts/create-project.js +0 -125
  72. package/dist/scripts/rename-gitignore.d.ts +0 -1
  73. package/dist/scripts/start-devnet.d.ts +0 -1
  74. package/dist/scripts/start-devnet.js +0 -131
  75. package/dist/scripts/stop-devnet.d.ts +0 -1
  76. package/dist/src/signer/node-wallet.d.ts +0 -13
  77. package/dist/src/signer/node-wallet.js +0 -60
  78. package/dist/src/test/index.d.ts +0 -7
  79. package/dist/src/test/index.js +0 -41
  80. package/dist/src/test/privatekey-wallet.d.ts +0 -12
  81. package/dist/src/test/privatekey-wallet.js +0 -68
  82. package/dist/src/transaction/sign-verify.d.ts +0 -2
  83. package/dist/src/transaction/sign-verify.js +0 -58
  84. package/dist/src/utils/password-crypto.d.ts +0 -2
  85. package/dist/src/utils/password-crypto.js +0 -69
  86. package/gitignore +0 -10
  87. package/scripts/create-project.ts +0 -137
  88. package/scripts/start-devnet.js +0 -141
  89. package/scripts/stop-devnet.js +0 -32
  90. package/src/contract/ralph.test.ts +0 -178
  91. package/src/fixtures/address.json +0 -36
  92. package/src/fixtures/balance.json +0 -9
  93. package/src/fixtures/self-clique.json +0 -19
  94. package/src/fixtures/transaction.json +0 -13
  95. package/src/fixtures/transactions.json +0 -179
  96. package/src/signer/fixtures/genesis.json +0 -26
  97. package/src/signer/fixtures/wallets.json +0 -26
  98. package/src/signer/node-wallet.ts +0 -74
  99. package/src/test/index.ts +0 -32
  100. package/src/test/privatekey-wallet.ts +0 -58
  101. package/src/transaction/sign-verify.test.ts +0 -50
  102. package/src/utils/address.test.ts +0 -47
  103. package/src/utils/djb2.test.ts +0 -35
  104. package/src/utils/password-crypto.test.ts +0 -27
  105. package/src/utils/password-crypto.ts +0 -77
  106. package/src/utils/utils.test.ts +0 -161
  107. package/templates/base/README.md +0 -34
  108. package/templates/base/package.json +0 -35
  109. package/templates/base/src/greeter.ts +0 -41
  110. package/templates/base/tsconfig.json +0 -19
  111. package/templates/react/README.md +0 -34
  112. package/templates/react/config-overrides.js +0 -18
  113. package/templates/react/package.json +0 -66
  114. package/templates/react/src/App.tsx +0 -42
  115. package/templates/react/src/artifacts/greeter.ral.json +0 -26
  116. package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
  117. package/templates/shared/.eslintrc.json +0 -12
  118. package/templates/shared/scripts/header.js +0 -0
  119. package/test/contract.test.ts +0 -178
  120. package/test/events.test.ts +0 -138
  121. package/test/transaction.test.ts +0 -72
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  return (mod && mod.__esModule) ? mod : { "default": mod };
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.assertType = exports.timeout = exports.hexToString = exports.stringToHex = exports.subContractId = exports.contractIdFromTx = exports.addressFromContractId = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.binToHex = exports.hexToBinUnsafe = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isHexString = exports.signatureDecode = exports.signatureEncode = exports.convertHttpResponse = void 0;
23
+ exports.assertType = exports.timeout = exports.hexToString = exports.stringToHex = exports.subContractId = exports.contractIdFromTx = exports.addressFromContractId = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.groupOfPrivateKey = exports.binToHex = exports.hexToBinUnsafe = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isHexString = exports.xorByte = exports.signatureDecode = exports.signatureEncode = void 0;
24
24
  const elliptic_1 = require("elliptic");
25
25
  const bn_js_1 = __importDefault(require("bn.js"));
26
26
  const blakejs_1 = __importDefault(require("blakejs"));
@@ -29,15 +29,6 @@ const buffer_1 = require("buffer/");
29
29
  const constants_1 = require("../constants");
30
30
  const djb2_1 = __importDefault(require("./djb2"));
31
31
  const ec = new elliptic_1.ec('secp256k1');
32
- function convertHttpResponse(response) {
33
- if (response.error) {
34
- throw new Error(response.error.detail);
35
- }
36
- else {
37
- return response.data;
38
- }
39
- }
40
- exports.convertHttpResponse = convertHttpResponse;
41
32
  function signatureEncode(signature) {
42
33
  let sNormalized = signature.s;
43
34
  if (ec.n && signature.s.cmp(ec.nh) === 1) {
@@ -49,7 +40,7 @@ function signatureEncode(signature) {
49
40
  }
50
41
  exports.signatureEncode = signatureEncode;
51
42
  // the signature should be in hex string format for 64 bytes
52
- const signatureDecode = (ec, signature) => {
43
+ function signatureDecode(ec, signature) {
53
44
  if (signature.length !== 128) {
54
45
  throw new Error('Invalid signature length');
55
46
  }
@@ -62,15 +53,16 @@ const signatureDecode = (ec, signature) => {
62
53
  else {
63
54
  throw new Error('The signature is not normalized');
64
55
  }
65
- };
56
+ }
66
57
  exports.signatureDecode = signatureDecode;
67
- const xorByte = (intValue) => {
58
+ function xorByte(intValue) {
68
59
  const byte0 = (intValue >> 24) & 0xff;
69
60
  const byte1 = (intValue >> 16) & 0xff;
70
61
  const byte2 = (intValue >> 8) & 0xff;
71
62
  const byte3 = intValue & 0xff;
72
63
  return (byte0 ^ byte1 ^ byte2 ^ byte3) & 0xff;
73
- };
64
+ }
65
+ exports.xorByte = xorByte;
74
66
  function isHexString(input) {
75
67
  return input.length % 2 === 0 && /[0-9a-f]*$/.test(input);
76
68
  }
@@ -82,7 +74,7 @@ var AddressType;
82
74
  AddressType[AddressType["P2SH"] = 2] = "P2SH";
83
75
  AddressType[AddressType["P2C"] = 3] = "P2C";
84
76
  })(AddressType || (AddressType = {}));
85
- const groupOfAddress = (address) => {
77
+ function groupOfAddress(address) {
86
78
  const decoded = bs58_1.default.decode(address);
87
79
  if (decoded.length == 0)
88
80
  throw new Error('Address string is empty');
@@ -100,32 +92,32 @@ const groupOfAddress = (address) => {
100
92
  else {
101
93
  throw new Error(`Invalid asset address type: ${addressType}`);
102
94
  }
103
- };
95
+ }
104
96
  exports.groupOfAddress = groupOfAddress;
105
- const groupOfAddressBytes = (bytes) => {
97
+ function groupOfAddressBytes(bytes) {
106
98
  const hint = (0, djb2_1.default)(bytes) | 1;
107
99
  const hash = xorByte(hint);
108
100
  const group = hash % constants_1.TOTAL_NUMBER_OF_GROUPS;
109
101
  return group;
110
- };
102
+ }
111
103
  // Pay to public key hash address
112
- const groupOfP2pkhAddress = (address) => {
104
+ function groupOfP2pkhAddress(address) {
113
105
  if (address.length != 32) {
114
106
  throw new Error(`Invalid p2pkh address length: ${address.length}`);
115
107
  }
116
108
  return groupOfAddressBytes(address);
117
- };
109
+ }
118
110
  // Pay to multiple public key hash address
119
- const groupOfP2mpkhAddress = (address) => {
111
+ function groupOfP2mpkhAddress(address) {
120
112
  if ((address.length - 2) % 32 != 0) {
121
113
  throw new Error(`Invalid p2mpkh address length: ${address.length}`);
122
114
  }
123
115
  return groupOfAddressBytes(address.slice(1, 33));
124
- };
116
+ }
125
117
  // Pay to script hash address
126
- const groupOfP2shAddress = (address) => {
118
+ function groupOfP2shAddress(address) {
127
119
  return groupOfAddressBytes(address);
128
- };
120
+ }
129
121
  function contractIdFromAddress(address) {
130
122
  return idFromAddress(address);
131
123
  }
@@ -155,6 +147,10 @@ function binToHex(bin) {
155
147
  return buffer_1.Buffer.from(bin).toString('hex');
156
148
  }
157
149
  exports.binToHex = binToHex;
150
+ function groupOfPrivateKey(privateKey) {
151
+ return groupOfAddress(addressFromPublicKey(publicKeyFromPrivateKey(privateKey)));
152
+ }
153
+ exports.groupOfPrivateKey = groupOfPrivateKey;
158
154
  function publicKeyFromPrivateKey(privateKey) {
159
155
  const key = ec.keyFromPrivate(privateKey);
160
156
  return key.getPublic(true, 'hex');
@@ -195,7 +191,7 @@ function stringToHex(str) {
195
191
  }
196
192
  exports.stringToHex = stringToHex;
197
193
  function hexToString(str) {
198
- return buffer_1.Buffer.from(str.toString(), 'hex').toString();
194
+ return buffer_1.Buffer.from(str, 'hex').toString();
199
195
  }
200
196
  exports.hexToString = hexToString;
201
197
  function timeout(ms) {
@@ -0,0 +1,11 @@
1
+ {
2
+ "testPathIgnorePatterns": [".*/node_modules/"],
3
+ "transform": {
4
+ "^.+\\.(t|j)sx?$": "ts-jest"
5
+ },
6
+ "testMatch": ["**/*.test.ts"],
7
+ "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
8
+ "collectCoverage": true,
9
+ "coverageDirectory": "./coverage/",
10
+ "collectCoverageFrom": ["src/**/*.ts"]
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.2.0-rc.2",
3
+ "version": "0.2.0-rc.21",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "main": "dist/src/index.js",
@@ -27,52 +27,28 @@
27
27
  },
28
28
  "author": "Alephium dev <dev@alephium.org>",
29
29
  "config": {
30
- "alephium_version": "1.5.0-rc2",
31
- "explorer_backend_version": "1.7.1"
30
+ "alephium_version": "1.5.0-rc10",
31
+ "explorer_backend_version": "1.9.0-rc0"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "rm -rf dist/* && npx tsc --build . && webpack",
35
- "bundle": "webpack",
35
+ "test": "jest -i --config ./jest-config.json",
36
36
  "update-schemas": "npm run update-schema:alephium && npm run update-schema:explorer",
37
- "update-schema:alephium": "npx swagger-typescript-api -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
38
- "update-schema:explorer": "npx swagger-typescript-api -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
39
- "check-versions": "node scripts/check-versions.js ${npm_package_config_alephium_version} ${npm_package_config_explorer_backend_version}",
40
- "dev": "tsnd --respawn lib/index.ts",
41
- "lint": "eslint . --ext ts",
42
- "lint:fix": "eslint . --fix --ext ts",
43
- "test": "jest -i --config ./configs/jest.config.ts",
44
- "test:client": "jest -i --config ./configs/jest-client.config.ts",
45
- "test:unit": "jest -i --config ./configs/jest-unit.config.ts",
46
- "test:watch": "npm run test -- --watch --coverage=false",
47
- "test:watch:unit": "npm run test:unit -- --watch --coverage=false",
48
- "test:watch:client": "npm run test:client -- --watch --coverage=false",
49
- "prepublishOnly": "npm run build",
50
- "prepack": "node scripts/rename-gitignore.js .gitignore gitignore",
51
- "postpack": "node scripts/rename-gitignore.js gitignore .gitignore",
52
- "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
53
- "start-devnet": "node scripts/start-devnet.js ${npm_package_config_alephium_version}",
54
- "restart-devnet": "npm run start-devnet",
55
- "stop-devnet": "node scripts/stop-devnet.js"
37
+ "update-schema:alephium": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
38
+ "update-schema:explorer": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
39
+ "check-versions": "node scripts/check-versions.js ${npm_package_config_alephium_version} ${npm_package_config_explorer_backend_version}"
56
40
  },
57
41
  "type": "commonjs",
58
- "bin": {
59
- "alephium": "dist/scripts/create-project.js"
60
- },
61
42
  "dependencies": {
62
43
  "base-x": "4.0.0",
63
44
  "blakejs": "1.2.1",
64
45
  "buffer": "^6.0.3",
65
- "commander": "^9.1.0",
66
46
  "cross-fetch": "^3.1.5",
67
- "crypto-js": "4.1.1",
68
47
  "elliptic": "6.5.4",
69
- "eventemitter3": "^4.0.7",
70
- "find-up": "^2.1.0",
71
- "fs-extra": "^10.0.1"
48
+ "eventemitter3": "^4.0.7"
72
49
  },
73
50
  "devDependencies": {
74
- "@types/crypto-js": "^4.1.1",
75
- "@types/elliptic": "^6.4.13",
51
+ "@babel/eslint-parser": "^7.18.9",
76
52
  "@types/find-up": "^2.1.0",
77
53
  "@types/fs-extra": "^9.0.13",
78
54
  "@types/jest": "^27.5.1",
@@ -81,14 +57,12 @@
81
57
  "@types/rewire": "^2.5.28",
82
58
  "@typescript-eslint/eslint-plugin": "^4.30.0",
83
59
  "@typescript-eslint/parser": "^4.30.0",
84
- "babel-eslint": "^10.1.0",
85
60
  "clean-webpack-plugin": "4.0.0",
86
61
  "crypto-browserify": "^3.12.0",
87
62
  "eslint": "^7.32.0",
88
63
  "eslint-config-prettier": "^8.5.0",
89
64
  "eslint-plugin-header": "^3.1.1",
90
65
  "eslint-plugin-prettier": "^4.0.0",
91
- "eslint-plugin-react": "^7.29.4",
92
66
  "eslint-plugin-security": "1.4.0",
93
67
  "html-webpack-plugin": "5.5.0",
94
68
  "jest": "^28.1.0",
@@ -98,7 +72,6 @@
98
72
  "mock-socket": "^9.0.8",
99
73
  "prettier": "^2.3.2",
100
74
  "process": "^0.11.10",
101
- "react-app-rewired": "^2.2.1",
102
75
  "rewire": "^6.0.0",
103
76
  "shelljs": "^0.8.5",
104
77
  "stream-browserify": "^3.0.0",
@@ -107,21 +80,12 @@
107
80
  "ts-jest": "^28.0.2",
108
81
  "ts-node": "^10.7.0",
109
82
  "tslib": "^2.3.1",
110
- "typescript": "^4.4.2",
83
+ "typescript": "4.7.4",
111
84
  "webpack": "^5.72.0",
112
85
  "webpack-cli": "^4.9.2"
113
86
  },
114
87
  "engines": {
115
- "node": ">=14.0.0",
88
+ "node": ">=16.0.0",
116
89
  "npm": ">=7.0.0"
117
- },
118
- "prettier": {
119
- "printWidth": 120,
120
- "tabWidth": 2,
121
- "useTabs": false,
122
- "semi": false,
123
- "singleQuote": true,
124
- "bracketSameLine": false,
125
- "trailingComma": "none"
126
90
  }
127
91
  }
@@ -124,6 +124,11 @@ export interface Banned {
124
124
  type: string
125
125
  }
126
126
 
127
+ export interface BlockAndEvents {
128
+ block: BlockEntry
129
+ events: ContractEventByBlockHash[]
130
+ }
131
+
127
132
  export interface BlockEntry {
128
133
  /** @format block-hash */
129
134
  hash: string
@@ -174,6 +179,14 @@ export interface BlockHeaderEntry {
174
179
  deps: string[]
175
180
  }
176
181
 
182
+ export interface BlocksAndEventsPerTimeStampRange {
183
+ blocksAndEvents: BlockAndEvents[][]
184
+ }
185
+
186
+ export interface BlocksPerTimeStampRange {
187
+ blocks: BlockEntry[][]
188
+ }
189
+
177
190
  export interface BrokerInfo {
178
191
  /** @format clique-id */
179
192
  cliqueId: string
@@ -422,19 +435,42 @@ export interface ChangeActiveAddress {
422
435
  }
423
436
 
424
437
  export interface CompileContractResult {
438
+ name: string
425
439
  bytecode: string
440
+ bytecodeDebugPatch: string
426
441
 
427
442
  /** @format 32-byte-hash */
428
443
  codeHash: string
444
+
445
+ /** @format 32-byte-hash */
446
+ codeHashDebug: string
429
447
  fields: FieldsSig
430
448
  functions: FunctionSig[]
431
449
  events: EventSig[]
450
+ warnings: string[]
451
+ }
452
+
453
+ export interface CompileProjectResult {
454
+ contracts: CompileContractResult[]
455
+ scripts: CompileScriptResult[]
432
456
  }
433
457
 
434
458
  export interface CompileScriptResult {
459
+ name: string
435
460
  bytecodeTemplate: string
461
+ bytecodeDebugPatch: string
436
462
  fields: FieldsSig
437
463
  functions: FunctionSig[]
464
+ warnings: string[]
465
+ }
466
+
467
+ export interface CompilerOptions {
468
+ ignoreUnusedConstantsWarnings?: boolean
469
+ ignoreUnusedVariablesWarnings?: boolean
470
+ ignoreUnusedFieldsWarnings?: boolean
471
+ ignoreUnusedPrivateFunctionsWarnings?: boolean
472
+ ignoreReadonlyCheckWarnings?: boolean
473
+ ignoreExternalCallCheckWarnings?: boolean
438
474
  }
439
475
 
440
476
  export interface Confirmed {
@@ -457,6 +493,7 @@ export interface Confirmed {
457
493
 
458
494
  export interface Contract {
459
495
  code: string
496
+ compilerOptions?: CompilerOptions
460
497
  }
461
498
 
462
499
  export interface ContractEvent {
@@ -471,6 +508,18 @@ export interface ContractEvent {
471
508
  fields: Val[]
472
509
  }
473
510
 
511
+ export interface ContractEventByBlockHash {
512
+ /** @format 32-byte-hash */
513
+ txId: string
514
+
515
+ /** @format address */
516
+ contractAddress: string
517
+
518
+ /** @format int32 */
519
+ eventIndex: number
520
+ fields: Val[]
521
+ }
522
+
474
523
  export interface ContractEventByTxId {
475
524
  /** @format block-hash */
476
525
  blockHash: string
@@ -490,11 +539,12 @@ export interface ContractEvents {
490
539
  nextStart: number
491
540
  }
492
541
 
542
+ export interface ContractEventsByBlockHash {
543
+ events: ContractEventByBlockHash[]
544
+ }
545
+
493
546
  export interface ContractEventsByTxId {
494
547
  events: ContractEventByTxId[]
495
-
496
- /** @format int32 */
497
- nextStart: number
498
548
  }
499
549
 
500
550
  export interface ContractOutput {
@@ -529,6 +579,12 @@ export interface ContractState {
529
579
  asset: AssetState
530
580
  }
531
581
 
582
+ export interface DebugMessage {
583
+ /** @format address */
584
+ contractAddress: string
585
+ message: string
586
+ }
587
+
532
588
  export interface DecodeUnsignedTx {
533
589
  unsignedTx: string
534
590
  }
@@ -561,19 +617,14 @@ export type DiscoveryAction = Reachable | Unreachable
561
617
 
562
618
  export interface EventSig {
563
619
  name: string
564
- signature: string
565
620
  fieldNames: string[]
566
621
  fieldTypes: string[]
567
622
  }
568
623
 
569
- export interface FetchResponse {
570
- blocks: BlockEntry[][]
571
- }
572
-
573
624
  export interface FieldsSig {
574
- signature: string
575
625
  names: string[]
576
626
  types: string[]
627
+ isMutable: boolean[]
577
628
  }
578
629
 
579
630
  export interface FixedAssetOutput {
@@ -599,9 +650,12 @@ export interface FixedAssetOutput {
599
650
 
600
651
  export interface FunctionSig {
601
652
  name: string
602
- signature: string
603
- argNames: string[]
604
- argTypes: string[]
653
+ usePreapprovedAssets: boolean
654
+ useAssetsInContract: boolean
655
+ isPublic: boolean
656
+ paramNames: string[]
657
+ paramTypes: string[]
658
+ paramIsMutable: boolean[]
605
659
  returnTypes: string[]
606
660
  }
607
661
 
@@ -703,6 +757,11 @@ export interface Penalty {
703
757
  type: string
704
758
  }
705
759
 
760
+ export interface Project {
761
+ code: string
762
+ compilerOptions?: CompilerOptions
763
+ }
764
+
706
765
  export interface Reachable {
707
766
  peers: string[]
708
767
  type: string
@@ -729,6 +788,7 @@ export interface RevealMnemonicResult {
729
788
 
730
789
  export interface Script {
731
790
  code: string
791
+ compilerOptions?: CompilerOptions
732
792
  }
733
793
 
734
794
  export interface SelfClique {
@@ -846,6 +906,7 @@ export interface TestContractResult {
846
906
  txInputs: string[]
847
907
  txOutputs: Output[]
848
908
  events: ContractEventByTxId[]
909
+ debugMessages: DebugMessage[]
849
910
  }
850
911
 
851
912
  export interface TestInputAsset {
@@ -1058,16 +1119,7 @@ export interface WalletUnlock {
1058
1119
  }
1059
1120
 
1060
1121
  import 'cross-fetch/polyfill'
1061
-
1062
- function convertHttpResponse<T>(
1063
- response: HttpResponse<T, { detail: string }> | HttpResponse<T, { detail: string }>
1064
- ): T {
1065
- if (response.error) {
1066
- throw new Error(response.error.detail)
1067
- } else {
1068
- return response.data
1069
- }
1070
- }
1122
+ import { convertHttpResponse } from './utils'
1071
1123
 
1072
1124
  export type QueryParamsType = Record<string | number, any>
1073
1125
  export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>
@@ -1271,7 +1323,6 @@ export class HttpClient<SecurityDataType = unknown> {
1271
1323
  this.abortControllers.delete(cancelToken)
1272
1324
  }
1273
1325
 
1274
- if (!response.ok) throw data
1275
1326
  return data
1276
1327
  })
1277
1328
  }
@@ -1830,13 +1881,36 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1830
1881
  * No description
1831
1882
  *
1832
1883
  * @tags Blockflow
1833
- * @name GetBlockflow
1884
+ * @name GetBlockflowBlocks
1834
1885
  * @summary List blocks on the given time interval
1835
- * @request GET:/blockflow
1886
+ * @request GET:/blockflow/blocks
1887
+ */
1888
+ getBlockflowBlocks: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
1889
+ this.request<
1890
+ BlocksPerTimeStampRange,
1891
+ BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
1892
+ >({
1893
+ path: `/blockflow/blocks`,
1894
+ method: 'GET',
1895
+ query: query,
1896
+ format: 'json',
1897
+ ...params
1898
+ }).then(convertHttpResponse),
1899
+
1900
+ /**
1901
+ * No description
1902
+ *
1903
+ * @tags Blockflow
1904
+ * @name GetBlockflowBlocksWithEvents
1905
+ * @summary List blocks with events on the given time interval
1906
+ * @request GET:/blockflow/blocks-with-events
1836
1907
  */
1837
- getBlockflow: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
1838
- this.request<FetchResponse, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
1839
- path: `/blockflow`,
1908
+ getBlockflowBlocksWithEvents: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
1909
+ this.request<
1910
+ BlocksAndEventsPerTimeStampRange,
1911
+ BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
1912
+ >({
1913
+ path: `/blockflow/blocks-with-events`,
1840
1914
  method: 'GET',
1841
1915
  query: query,
1842
1916
  format: 'json',
@@ -1859,6 +1933,22 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1859
1933
  ...params
1860
1934
  }).then(convertHttpResponse),
1861
1935
 
1936
+ /**
1937
+ * No description
1938
+ *
1939
+ * @tags Blockflow
1940
+ * @name GetBlockflowBlocksWithEventsBlockHash
1941
+ * @summary Get a block and events with hash
1942
+ * @request GET:/blockflow/blocks-with-events/{block_hash}
1943
+ */
1944
+ getBlockflowBlocksWithEventsBlockHash: (blockHash: string, params: RequestParams = {}) =>
1945
+ this.request<BlockAndEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
1946
+ path: `/blockflow/blocks-with-events/${blockHash}`,
1947
+ method: 'GET',
1948
+ format: 'json',
1949
+ ...params
1950
+ }).then(convertHttpResponse),
1951
+
1862
1952
  /**
1863
1953
  * No description
1864
1954
  *
@@ -2160,6 +2250,27 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2160
2250
  ...params
2161
2251
  }).then(convertHttpResponse),
2162
2252
 
2253
+ /**
2254
+ * No description
2255
+ *
2256
+ * @tags Contracts
2257
+ * @name PostContractsCompileProject
2258
+ * @summary Compile a project
2259
+ * @request POST:/contracts/compile-project
2260
+ */
2261
+ postContractsCompileProject: (data: Project, params: RequestParams = {}) =>
2262
+ this.request<
2263
+ CompileProjectResult,
2264
+ BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
2265
+ >({
2266
+ path: `/contracts/compile-project`,
2267
+ method: 'POST',
2268
+ body: data,
2269
+ type: ContentType.Json,
2270
+ format: 'json',
2271
+ ...params
2272
+ }).then(convertHttpResponse),
2273
+
2163
2274
  /**
2164
2275
  * No description
2165
2276
  *
@@ -2351,6 +2462,23 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2351
2462
  ...params
2352
2463
  }).then(convertHttpResponse),
2353
2464
 
2465
+ /**
2466
+ * No description
2467
+ *
2468
+ * @tags Miners
2469
+ * @name PostMinersCpuMiningMineOneBlock
2470
+ * @summary Mine a block on CPU miner. !!! for test only !!!
2471
+ * @request POST:/miners/cpu-mining/mine-one-block
2472
+ */
2473
+ postMinersCpuMiningMineOneBlock: (query: { fromGroup: number; toGroup: number }, params: RequestParams = {}) =>
2474
+ this.request<boolean, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2475
+ path: `/miners/cpu-mining/mine-one-block`,
2476
+ method: 'POST',
2477
+ query: query,
2478
+ format: 'json',
2479
+ ...params
2480
+ }).then(convertHttpResponse),
2481
+
2354
2482
  /**
2355
2483
  * No description
2356
2484
  *
@@ -2395,7 +2523,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2395
2523
  */
2396
2524
  getEventsContractContractaddress: (
2397
2525
  contractAddress: string,
2398
- query: { start: number; end?: number; group?: number },
2526
+ query: { start: number; limit?: number; group?: number },
2399
2527
  params: RequestParams = {}
2400
2528
  ) =>
2401
2529
  this.request<ContractEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
@@ -2427,7 +2555,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2427
2555
  *
2428
2556
  * @tags Events
2429
2557
  * @name GetEventsTxIdTxid
2430
- * @summary Get events for a TxScript
2558
+ * @summary Get contract events for a transaction
2431
2559
  * @request GET:/events/tx-id/{txId}
2432
2560
  */
2433
2561
  getEventsTxIdTxid: (txId: string, query?: { group?: number }, params: RequestParams = {}) =>
@@ -2440,6 +2568,26 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2440
2568
  query: query,
2441
2569
  format: 'json',
2442
2570
  ...params
2571
+ }).then(convertHttpResponse),
2572
+
2573
+ /**
2574
+ * No description
2575
+ *
2576
+ * @tags Events
2577
+ * @name GetEventsBlockHashBlockhash
2578
+ * @summary Get contract events for a block
2579
+ * @request GET:/events/block-hash/{blockHash}
2580
+ */
2581
+ getEventsBlockHashBlockhash: (blockHash: string, query?: { group?: number }, params: RequestParams = {}) =>
2582
+ this.request<
2583
+ ContractEventsByBlockHash,
2584
+ BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
2585
+ >({
2586
+ path: `/events/block-hash/${blockHash}`,
2587
+ method: 'GET',
2588
+ query: query,
2589
+ format: 'json',
2590
+ ...params
2443
2591
  }).then(convertHttpResponse)
2444
2592
  }
2445
2593
  }