@alephium/web3 0.2.0-test.0 → 0.2.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.
- package/.eslintignore +2 -2
- package/README.md +2 -135
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +152 -24
- package/dist/src/api/api-alephium.js +163 -82
- package/dist/src/api/api-explorer.d.ts +192 -49
- package/dist/src/api/api-explorer.js +195 -34
- package/dist/src/api/index.d.ts +40 -5
- package/dist/src/api/index.js +115 -7
- package/dist/src/api/types.d.ts +23 -0
- package/dist/src/api/types.js +235 -0
- package/dist/src/api/utils.d.ts +6 -0
- package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
- package/dist/src/contract/contract.d.ts +127 -80
- package/dist/src/contract/contract.js +425 -467
- package/dist/src/contract/events.d.ts +4 -4
- package/dist/src/contract/events.js +2 -1
- package/dist/src/contract/index.js +5 -1
- package/dist/src/contract/ralph.d.ts +5 -4
- package/dist/src/contract/ralph.js +27 -1
- package/dist/src/global.d.ts +7 -0
- package/dist/src/global.js +54 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +23 -1
- package/dist/src/signer/index.d.ts +0 -1
- package/dist/src/signer/index.js +5 -2
- package/dist/src/signer/signer.d.ts +59 -60
- package/dist/src/signer/signer.js +99 -69
- package/dist/src/transaction/index.d.ts +0 -1
- package/dist/src/transaction/index.js +5 -2
- package/dist/src/transaction/status.d.ts +2 -1
- package/dist/src/transaction/status.js +2 -1
- package/dist/src/utils/bs58.d.ts +1 -0
- package/dist/src/utils/bs58.js +13 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +5 -2
- package/dist/src/utils/subscription.d.ts +0 -3
- package/dist/src/utils/subscription.js +0 -1
- package/dist/src/utils/utils.d.ts +6 -11
- package/dist/src/utils/utils.js +22 -26
- package/jest-config.json +11 -0
- package/package.json +11 -47
- package/src/api/api-alephium.ts +219 -33
- package/src/api/api-explorer.ts +275 -52
- package/src/api/index.ts +140 -6
- package/src/api/types.ts +229 -0
- package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
- package/src/contract/contract.ts +663 -581
- package/src/contract/events.ts +8 -7
- package/src/contract/ralph.ts +29 -4
- package/src/global.ts +56 -0
- package/src/index.ts +7 -0
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +165 -134
- package/src/transaction/index.ts +0 -1
- package/src/transaction/status.ts +6 -3
- package/src/utils/bs58.ts +11 -0
- package/src/utils/index.ts +0 -1
- package/src/utils/subscription.ts +1 -5
- package/src/utils/utils.ts +15 -23
- package/webpack.config.js +3 -0
- package/.eslintrc.json +0 -21
- package/LICENSE +0 -165
- package/contracts/add/add.ral +0 -16
- package/contracts/greeter/greeter.ral +0 -7
- package/contracts/greeter/greeter_interface.ral +0 -3
- package/contracts/greeter_main.ral +0 -9
- package/contracts/main.ral +0 -6
- package/contracts/sub/sub.ral +0 -9
- package/dev/user.conf +0 -29
- package/dist/scripts/create-project.d.ts +0 -2
- package/dist/scripts/create-project.js +0 -124
- package/dist/scripts/rename-gitignore.d.ts +0 -1
- package/dist/scripts/start-devnet.d.ts +0 -1
- package/dist/scripts/start-devnet.js +0 -131
- package/dist/scripts/stop-devnet.d.ts +0 -1
- package/dist/scripts/stop-devnet.js +0 -32
- package/dist/src/signer/node-wallet.d.ts +0 -13
- package/dist/src/signer/node-wallet.js +0 -60
- package/dist/src/test/index.d.ts +0 -7
- package/dist/src/test/index.js +0 -41
- package/dist/src/test/privatekey-wallet.d.ts +0 -12
- package/dist/src/test/privatekey-wallet.js +0 -68
- package/dist/src/transaction/sign-verify.d.ts +0 -2
- package/dist/src/transaction/sign-verify.js +0 -58
- package/dist/src/utils/password-crypto.d.ts +0 -2
- package/dist/src/utils/password-crypto.js +0 -69
- package/gitignore +0 -10
- package/scripts/create-project.ts +0 -136
- package/scripts/start-devnet.js +0 -141
- package/scripts/stop-devnet.js +0 -32
- package/src/contract/ralph.test.ts +0 -178
- package/src/fixtures/address.json +0 -36
- package/src/fixtures/balance.json +0 -9
- package/src/fixtures/self-clique.json +0 -19
- package/src/fixtures/transaction.json +0 -13
- package/src/fixtures/transactions.json +0 -179
- package/src/signer/fixtures/genesis.json +0 -26
- package/src/signer/fixtures/wallets.json +0 -26
- package/src/signer/node-wallet.ts +0 -74
- package/src/test/index.ts +0 -32
- package/src/test/privatekey-wallet.ts +0 -58
- package/src/transaction/sign-verify.test.ts +0 -50
- package/src/transaction/sign-verify.ts +0 -39
- package/src/utils/address.test.ts +0 -47
- package/src/utils/djb2.test.ts +0 -35
- package/src/utils/password-crypto.test.ts +0 -27
- package/src/utils/password-crypto.ts +0 -77
- package/src/utils/utils.test.ts +0 -161
- package/templates/base/README.md +0 -34
- package/templates/base/package.json +0 -35
- package/templates/base/src/greeter.ts +0 -41
- package/templates/base/tsconfig.json +0 -19
- package/templates/react/README.md +0 -34
- package/templates/react/config-overrides.js +0 -18
- package/templates/react/package.json +0 -66
- package/templates/react/src/App.tsx +0 -42
- package/templates/react/src/artifacts/greeter.ral.json +0 -26
- package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
- package/templates/shared/.eslintrc.json +0 -12
- package/templates/shared/scripts/header.js +0 -0
- package/test/contract.test.ts +0 -178
- package/test/events.test.ts +0 -138
- package/test/transaction.test.ts +0 -72
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephium/web3",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
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.
|
|
31
|
-
"explorer_backend_version": "1.
|
|
30
|
+
"alephium_version": "1.5.0",
|
|
31
|
+
"explorer_backend_version": "1.9.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rm -rf dist/* && npx tsc --build . && webpack",
|
|
35
|
-
"
|
|
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
|
-
"@
|
|
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
|
|
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": ">=
|
|
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
|
}
|
package/src/api/api-alephium.ts
CHANGED
|
@@ -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
|
|
@@ -207,6 +220,9 @@ export interface BuildDeployContractTx {
|
|
|
207
220
|
|
|
208
221
|
/** @format uint256 */
|
|
209
222
|
gasPrice?: string
|
|
223
|
+
|
|
224
|
+
/** @format block-hash */
|
|
225
|
+
targetBlockHash?: string
|
|
210
226
|
}
|
|
211
227
|
|
|
212
228
|
export interface BuildDeployContractTxResult {
|
|
@@ -246,6 +262,9 @@ export interface BuildExecuteScriptTx {
|
|
|
246
262
|
|
|
247
263
|
/** @format uint256 */
|
|
248
264
|
gasPrice?: string
|
|
265
|
+
|
|
266
|
+
/** @format block-hash */
|
|
267
|
+
targetBlockHash?: string
|
|
249
268
|
}
|
|
250
269
|
|
|
251
270
|
export interface BuildExecuteScriptTxResult {
|
|
@@ -311,6 +330,9 @@ export interface BuildSweepAddressTransactions {
|
|
|
311
330
|
|
|
312
331
|
/** @format uint256 */
|
|
313
332
|
gasPrice?: string
|
|
333
|
+
|
|
334
|
+
/** @format block-hash */
|
|
335
|
+
targetBlockHash?: string
|
|
314
336
|
}
|
|
315
337
|
|
|
316
338
|
export interface BuildSweepAddressTransactionsResult {
|
|
@@ -334,6 +356,9 @@ export interface BuildTransaction {
|
|
|
334
356
|
|
|
335
357
|
/** @format uint256 */
|
|
336
358
|
gasPrice?: string
|
|
359
|
+
|
|
360
|
+
/** @format block-hash */
|
|
361
|
+
targetBlockHash?: string
|
|
337
362
|
}
|
|
338
363
|
|
|
339
364
|
export interface BuildTransactionResult {
|
|
@@ -410,19 +435,44 @@ export interface ChangeActiveAddress {
|
|
|
410
435
|
}
|
|
411
436
|
|
|
412
437
|
export interface CompileContractResult {
|
|
438
|
+
version: string
|
|
439
|
+
name: string
|
|
413
440
|
bytecode: string
|
|
441
|
+
bytecodeDebugPatch: string
|
|
414
442
|
|
|
415
443
|
/** @format 32-byte-hash */
|
|
416
444
|
codeHash: string
|
|
445
|
+
|
|
446
|
+
/** @format 32-byte-hash */
|
|
447
|
+
codeHashDebug: string
|
|
417
448
|
fields: FieldsSig
|
|
418
449
|
functions: FunctionSig[]
|
|
419
450
|
events: EventSig[]
|
|
451
|
+
warnings: string[]
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface CompileProjectResult {
|
|
455
|
+
contracts: CompileContractResult[]
|
|
456
|
+
scripts: CompileScriptResult[]
|
|
420
457
|
}
|
|
421
458
|
|
|
422
459
|
export interface CompileScriptResult {
|
|
460
|
+
version: string
|
|
461
|
+
name: string
|
|
423
462
|
bytecodeTemplate: string
|
|
463
|
+
bytecodeDebugPatch: string
|
|
424
464
|
fields: FieldsSig
|
|
425
465
|
functions: FunctionSig[]
|
|
466
|
+
warnings: string[]
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export interface CompilerOptions {
|
|
470
|
+
ignoreUnusedConstantsWarnings?: boolean
|
|
471
|
+
ignoreUnusedVariablesWarnings?: boolean
|
|
472
|
+
ignoreUnusedFieldsWarnings?: boolean
|
|
473
|
+
ignoreUnusedPrivateFunctionsWarnings?: boolean
|
|
474
|
+
ignoreReadonlyCheckWarnings?: boolean
|
|
475
|
+
ignoreExternalCallCheckWarnings?: boolean
|
|
426
476
|
}
|
|
427
477
|
|
|
428
478
|
export interface Confirmed {
|
|
@@ -445,6 +495,7 @@ export interface Confirmed {
|
|
|
445
495
|
|
|
446
496
|
export interface Contract {
|
|
447
497
|
code: string
|
|
498
|
+
compilerOptions?: CompilerOptions
|
|
448
499
|
}
|
|
449
500
|
|
|
450
501
|
export interface ContractEvent {
|
|
@@ -459,6 +510,18 @@ export interface ContractEvent {
|
|
|
459
510
|
fields: Val[]
|
|
460
511
|
}
|
|
461
512
|
|
|
513
|
+
export interface ContractEventByBlockHash {
|
|
514
|
+
/** @format 32-byte-hash */
|
|
515
|
+
txId: string
|
|
516
|
+
|
|
517
|
+
/** @format address */
|
|
518
|
+
contractAddress: string
|
|
519
|
+
|
|
520
|
+
/** @format int32 */
|
|
521
|
+
eventIndex: number
|
|
522
|
+
fields: Val[]
|
|
523
|
+
}
|
|
524
|
+
|
|
462
525
|
export interface ContractEventByTxId {
|
|
463
526
|
/** @format block-hash */
|
|
464
527
|
blockHash: string
|
|
@@ -478,11 +541,12 @@ export interface ContractEvents {
|
|
|
478
541
|
nextStart: number
|
|
479
542
|
}
|
|
480
543
|
|
|
544
|
+
export interface ContractEventsByBlockHash {
|
|
545
|
+
events: ContractEventByBlockHash[]
|
|
546
|
+
}
|
|
547
|
+
|
|
481
548
|
export interface ContractEventsByTxId {
|
|
482
549
|
events: ContractEventByTxId[]
|
|
483
|
-
|
|
484
|
-
/** @format int32 */
|
|
485
|
-
nextStart: number
|
|
486
550
|
}
|
|
487
551
|
|
|
488
552
|
export interface ContractOutput {
|
|
@@ -517,6 +581,12 @@ export interface ContractState {
|
|
|
517
581
|
asset: AssetState
|
|
518
582
|
}
|
|
519
583
|
|
|
584
|
+
export interface DebugMessage {
|
|
585
|
+
/** @format address */
|
|
586
|
+
contractAddress: string
|
|
587
|
+
message: string
|
|
588
|
+
}
|
|
589
|
+
|
|
520
590
|
export interface DecodeUnsignedTx {
|
|
521
591
|
unsignedTx: string
|
|
522
592
|
}
|
|
@@ -549,19 +619,14 @@ export type DiscoveryAction = Reachable | Unreachable
|
|
|
549
619
|
|
|
550
620
|
export interface EventSig {
|
|
551
621
|
name: string
|
|
552
|
-
signature: string
|
|
553
622
|
fieldNames: string[]
|
|
554
623
|
fieldTypes: string[]
|
|
555
624
|
}
|
|
556
625
|
|
|
557
|
-
export interface FetchResponse {
|
|
558
|
-
blocks: BlockEntry[][]
|
|
559
|
-
}
|
|
560
|
-
|
|
561
626
|
export interface FieldsSig {
|
|
562
|
-
signature: string
|
|
563
627
|
names: string[]
|
|
564
628
|
types: string[]
|
|
629
|
+
isMutable: boolean[]
|
|
565
630
|
}
|
|
566
631
|
|
|
567
632
|
export interface FixedAssetOutput {
|
|
@@ -587,9 +652,12 @@ export interface FixedAssetOutput {
|
|
|
587
652
|
|
|
588
653
|
export interface FunctionSig {
|
|
589
654
|
name: string
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
655
|
+
usePreapprovedAssets: boolean
|
|
656
|
+
useAssetsInContract: boolean
|
|
657
|
+
isPublic: boolean
|
|
658
|
+
paramNames: string[]
|
|
659
|
+
paramTypes: string[]
|
|
660
|
+
paramIsMutable: boolean[]
|
|
593
661
|
returnTypes: string[]
|
|
594
662
|
}
|
|
595
663
|
|
|
@@ -691,6 +759,11 @@ export interface Penalty {
|
|
|
691
759
|
type: string
|
|
692
760
|
}
|
|
693
761
|
|
|
762
|
+
export interface Project {
|
|
763
|
+
code: string
|
|
764
|
+
compilerOptions?: CompilerOptions
|
|
765
|
+
}
|
|
766
|
+
|
|
694
767
|
export interface Reachable {
|
|
695
768
|
peers: string[]
|
|
696
769
|
type: string
|
|
@@ -717,6 +790,7 @@ export interface RevealMnemonicResult {
|
|
|
717
790
|
|
|
718
791
|
export interface Script {
|
|
719
792
|
code: string
|
|
793
|
+
compilerOptions?: CompilerOptions
|
|
720
794
|
}
|
|
721
795
|
|
|
722
796
|
export interface SelfClique {
|
|
@@ -778,6 +852,9 @@ export interface Sweep {
|
|
|
778
852
|
|
|
779
853
|
/** @format int32 */
|
|
780
854
|
utxosLimit?: number
|
|
855
|
+
|
|
856
|
+
/** @format block-hash */
|
|
857
|
+
targetBlockHash?: string
|
|
781
858
|
}
|
|
782
859
|
|
|
783
860
|
export interface SweepAddressTransaction {
|
|
@@ -831,6 +908,7 @@ export interface TestContractResult {
|
|
|
831
908
|
txInputs: string[]
|
|
832
909
|
txOutputs: Output[]
|
|
833
910
|
events: ContractEventByTxId[]
|
|
911
|
+
debugMessages: DebugMessage[]
|
|
834
912
|
}
|
|
835
913
|
|
|
836
914
|
export interface TestInputAsset {
|
|
@@ -1043,16 +1121,7 @@ export interface WalletUnlock {
|
|
|
1043
1121
|
}
|
|
1044
1122
|
|
|
1045
1123
|
import 'cross-fetch/polyfill'
|
|
1046
|
-
|
|
1047
|
-
function convertHttpResponse<T>(
|
|
1048
|
-
response: HttpResponse<T, { detail: string }> | HttpResponse<T, { detail: string }>
|
|
1049
|
-
): T {
|
|
1050
|
-
if (response.error) {
|
|
1051
|
-
throw new Error(response.error.detail)
|
|
1052
|
-
} else {
|
|
1053
|
-
return response.data
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1124
|
+
import { convertHttpResponse } from './utils'
|
|
1056
1125
|
|
|
1057
1126
|
export type QueryParamsType = Record<string | number, any>
|
|
1058
1127
|
export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>
|
|
@@ -1099,7 +1168,7 @@ export enum ContentType {
|
|
|
1099
1168
|
}
|
|
1100
1169
|
|
|
1101
1170
|
export class HttpClient<SecurityDataType = unknown> {
|
|
1102
|
-
public baseUrl: string = '
|
|
1171
|
+
public baseUrl: string = '../'
|
|
1103
1172
|
private securityData: SecurityDataType | null = null
|
|
1104
1173
|
private securityWorker?: ApiConfig<SecurityDataType>['securityWorker']
|
|
1105
1174
|
private abortControllers = new Map<CancelToken, AbortController>()
|
|
@@ -1256,7 +1325,6 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1256
1325
|
this.abortControllers.delete(cancelToken)
|
|
1257
1326
|
}
|
|
1258
1327
|
|
|
1259
|
-
if (!response.ok) throw data
|
|
1260
1328
|
return data
|
|
1261
1329
|
})
|
|
1262
1330
|
}
|
|
@@ -1264,8 +1332,8 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1264
1332
|
|
|
1265
1333
|
/**
|
|
1266
1334
|
* @title Alephium API
|
|
1267
|
-
* @version 1.
|
|
1268
|
-
* @baseUrl
|
|
1335
|
+
* @version 1.5.0
|
|
1336
|
+
* @baseUrl ../
|
|
1269
1337
|
*/
|
|
1270
1338
|
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
|
1271
1339
|
wallets = {
|
|
@@ -1815,13 +1883,36 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1815
1883
|
* No description
|
|
1816
1884
|
*
|
|
1817
1885
|
* @tags Blockflow
|
|
1818
|
-
* @name
|
|
1886
|
+
* @name GetBlockflowBlocks
|
|
1819
1887
|
* @summary List blocks on the given time interval
|
|
1820
|
-
* @request GET:/blockflow
|
|
1888
|
+
* @request GET:/blockflow/blocks
|
|
1821
1889
|
*/
|
|
1822
|
-
|
|
1823
|
-
this.request<
|
|
1824
|
-
|
|
1890
|
+
getBlockflowBlocks: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
|
|
1891
|
+
this.request<
|
|
1892
|
+
BlocksPerTimeStampRange,
|
|
1893
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
1894
|
+
>({
|
|
1895
|
+
path: `/blockflow/blocks`,
|
|
1896
|
+
method: 'GET',
|
|
1897
|
+
query: query,
|
|
1898
|
+
format: 'json',
|
|
1899
|
+
...params
|
|
1900
|
+
}).then(convertHttpResponse),
|
|
1901
|
+
|
|
1902
|
+
/**
|
|
1903
|
+
* No description
|
|
1904
|
+
*
|
|
1905
|
+
* @tags Blockflow
|
|
1906
|
+
* @name GetBlockflowBlocksWithEvents
|
|
1907
|
+
* @summary List blocks with events on the given time interval
|
|
1908
|
+
* @request GET:/blockflow/blocks-with-events
|
|
1909
|
+
*/
|
|
1910
|
+
getBlockflowBlocksWithEvents: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
|
|
1911
|
+
this.request<
|
|
1912
|
+
BlocksAndEventsPerTimeStampRange,
|
|
1913
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
1914
|
+
>({
|
|
1915
|
+
path: `/blockflow/blocks-with-events`,
|
|
1825
1916
|
method: 'GET',
|
|
1826
1917
|
query: query,
|
|
1827
1918
|
format: 'json',
|
|
@@ -1844,6 +1935,22 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1844
1935
|
...params
|
|
1845
1936
|
}).then(convertHttpResponse),
|
|
1846
1937
|
|
|
1938
|
+
/**
|
|
1939
|
+
* No description
|
|
1940
|
+
*
|
|
1941
|
+
* @tags Blockflow
|
|
1942
|
+
* @name GetBlockflowBlocksWithEventsBlockHash
|
|
1943
|
+
* @summary Get a block and events with hash
|
|
1944
|
+
* @request GET:/blockflow/blocks-with-events/{block_hash}
|
|
1945
|
+
*/
|
|
1946
|
+
getBlockflowBlocksWithEventsBlockHash: (blockHash: string, params: RequestParams = {}) =>
|
|
1947
|
+
this.request<BlockAndEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1948
|
+
path: `/blockflow/blocks-with-events/${blockHash}`,
|
|
1949
|
+
method: 'GET',
|
|
1950
|
+
format: 'json',
|
|
1951
|
+
...params
|
|
1952
|
+
}).then(convertHttpResponse),
|
|
1953
|
+
|
|
1847
1954
|
/**
|
|
1848
1955
|
* No description
|
|
1849
1956
|
*
|
|
@@ -2061,6 +2168,27 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2061
2168
|
...params
|
|
2062
2169
|
}).then(convertHttpResponse),
|
|
2063
2170
|
|
|
2171
|
+
/**
|
|
2172
|
+
* No description
|
|
2173
|
+
*
|
|
2174
|
+
* @tags Transactions
|
|
2175
|
+
* @name GetTransactionsDetailsTxid
|
|
2176
|
+
* @summary Get transaction details
|
|
2177
|
+
* @request GET:/transactions/details/{txId}
|
|
2178
|
+
*/
|
|
2179
|
+
getTransactionsDetailsTxid: (
|
|
2180
|
+
txId: string,
|
|
2181
|
+
query?: { fromGroup?: number; toGroup?: number },
|
|
2182
|
+
params: RequestParams = {}
|
|
2183
|
+
) =>
|
|
2184
|
+
this.request<Transaction, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
2185
|
+
path: `/transactions/details/${txId}`,
|
|
2186
|
+
method: 'GET',
|
|
2187
|
+
query: query,
|
|
2188
|
+
format: 'json',
|
|
2189
|
+
...params
|
|
2190
|
+
}).then(convertHttpResponse),
|
|
2191
|
+
|
|
2064
2192
|
/**
|
|
2065
2193
|
* No description
|
|
2066
2194
|
*
|
|
@@ -2145,6 +2273,27 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2145
2273
|
...params
|
|
2146
2274
|
}).then(convertHttpResponse),
|
|
2147
2275
|
|
|
2276
|
+
/**
|
|
2277
|
+
* No description
|
|
2278
|
+
*
|
|
2279
|
+
* @tags Contracts
|
|
2280
|
+
* @name PostContractsCompileProject
|
|
2281
|
+
* @summary Compile a project
|
|
2282
|
+
* @request POST:/contracts/compile-project
|
|
2283
|
+
*/
|
|
2284
|
+
postContractsCompileProject: (data: Project, params: RequestParams = {}) =>
|
|
2285
|
+
this.request<
|
|
2286
|
+
CompileProjectResult,
|
|
2287
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
2288
|
+
>({
|
|
2289
|
+
path: `/contracts/compile-project`,
|
|
2290
|
+
method: 'POST',
|
|
2291
|
+
body: data,
|
|
2292
|
+
type: ContentType.Json,
|
|
2293
|
+
format: 'json',
|
|
2294
|
+
...params
|
|
2295
|
+
}).then(convertHttpResponse),
|
|
2296
|
+
|
|
2148
2297
|
/**
|
|
2149
2298
|
* No description
|
|
2150
2299
|
*
|
|
@@ -2336,6 +2485,23 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2336
2485
|
...params
|
|
2337
2486
|
}).then(convertHttpResponse),
|
|
2338
2487
|
|
|
2488
|
+
/**
|
|
2489
|
+
* No description
|
|
2490
|
+
*
|
|
2491
|
+
* @tags Miners
|
|
2492
|
+
* @name PostMinersCpuMiningMineOneBlock
|
|
2493
|
+
* @summary Mine a block on CPU miner. !!! for test only !!!
|
|
2494
|
+
* @request POST:/miners/cpu-mining/mine-one-block
|
|
2495
|
+
*/
|
|
2496
|
+
postMinersCpuMiningMineOneBlock: (query: { fromGroup: number; toGroup: number }, params: RequestParams = {}) =>
|
|
2497
|
+
this.request<boolean, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
2498
|
+
path: `/miners/cpu-mining/mine-one-block`,
|
|
2499
|
+
method: 'POST',
|
|
2500
|
+
query: query,
|
|
2501
|
+
format: 'json',
|
|
2502
|
+
...params
|
|
2503
|
+
}).then(convertHttpResponse),
|
|
2504
|
+
|
|
2339
2505
|
/**
|
|
2340
2506
|
* No description
|
|
2341
2507
|
*
|
|
@@ -2380,7 +2546,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2380
2546
|
*/
|
|
2381
2547
|
getEventsContractContractaddress: (
|
|
2382
2548
|
contractAddress: string,
|
|
2383
|
-
query: { start: number;
|
|
2549
|
+
query: { start: number; limit?: number; group?: number },
|
|
2384
2550
|
params: RequestParams = {}
|
|
2385
2551
|
) =>
|
|
2386
2552
|
this.request<ContractEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -2412,7 +2578,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2412
2578
|
*
|
|
2413
2579
|
* @tags Events
|
|
2414
2580
|
* @name GetEventsTxIdTxid
|
|
2415
|
-
* @summary Get events for a
|
|
2581
|
+
* @summary Get contract events for a transaction
|
|
2416
2582
|
* @request GET:/events/tx-id/{txId}
|
|
2417
2583
|
*/
|
|
2418
2584
|
getEventsTxIdTxid: (txId: string, query?: { group?: number }, params: RequestParams = {}) =>
|
|
@@ -2425,6 +2591,26 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2425
2591
|
query: query,
|
|
2426
2592
|
format: 'json',
|
|
2427
2593
|
...params
|
|
2594
|
+
}).then(convertHttpResponse),
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* No description
|
|
2598
|
+
*
|
|
2599
|
+
* @tags Events
|
|
2600
|
+
* @name GetEventsBlockHashBlockhash
|
|
2601
|
+
* @summary Get contract events for a block
|
|
2602
|
+
* @request GET:/events/block-hash/{blockHash}
|
|
2603
|
+
*/
|
|
2604
|
+
getEventsBlockHashBlockhash: (blockHash: string, query?: { group?: number }, params: RequestParams = {}) =>
|
|
2605
|
+
this.request<
|
|
2606
|
+
ContractEventsByBlockHash,
|
|
2607
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
2608
|
+
>({
|
|
2609
|
+
path: `/events/block-hash/${blockHash}`,
|
|
2610
|
+
method: 'GET',
|
|
2611
|
+
query: query,
|
|
2612
|
+
format: 'json',
|
|
2613
|
+
...params
|
|
2428
2614
|
}).then(convertHttpResponse)
|
|
2429
2615
|
}
|
|
2430
2616
|
}
|