@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.
Files changed (126) 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 +152 -24
  7. package/dist/src/api/api-alephium.js +163 -82
  8. package/dist/src/api/api-explorer.d.ts +192 -49
  9. package/dist/src/api/api-explorer.js +195 -34
  10. package/dist/src/api/index.d.ts +40 -5
  11. package/dist/src/api/index.js +115 -7
  12. package/dist/src/api/types.d.ts +23 -0
  13. package/dist/src/api/types.js +235 -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 +127 -80
  17. package/dist/src/contract/contract.js +425 -467
  18. package/dist/src/contract/events.d.ts +4 -4
  19. package/dist/src/contract/events.js +2 -1
  20. package/dist/src/contract/index.js +5 -1
  21. package/dist/src/contract/ralph.d.ts +5 -4
  22. package/dist/src/contract/ralph.js +27 -1
  23. package/dist/src/global.d.ts +7 -0
  24. package/dist/src/global.js +54 -0
  25. package/dist/src/index.d.ts +2 -0
  26. package/dist/src/index.js +23 -1
  27. package/dist/src/signer/index.d.ts +0 -1
  28. package/dist/src/signer/index.js +5 -2
  29. package/dist/src/signer/signer.d.ts +59 -60
  30. package/dist/src/signer/signer.js +99 -69
  31. package/dist/src/transaction/index.d.ts +0 -1
  32. package/dist/src/transaction/index.js +5 -2
  33. package/dist/src/transaction/status.d.ts +2 -1
  34. package/dist/src/transaction/status.js +2 -1
  35. package/dist/src/utils/bs58.d.ts +1 -0
  36. package/dist/src/utils/bs58.js +13 -1
  37. package/dist/src/utils/index.d.ts +0 -1
  38. package/dist/src/utils/index.js +5 -2
  39. package/dist/src/utils/subscription.d.ts +0 -3
  40. package/dist/src/utils/subscription.js +0 -1
  41. package/dist/src/utils/utils.d.ts +6 -11
  42. package/dist/src/utils/utils.js +22 -26
  43. package/jest-config.json +11 -0
  44. package/package.json +11 -47
  45. package/src/api/api-alephium.ts +219 -33
  46. package/src/api/api-explorer.ts +275 -52
  47. package/src/api/index.ts +140 -6
  48. package/src/api/types.ts +229 -0
  49. package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
  50. package/src/contract/contract.ts +663 -581
  51. package/src/contract/events.ts +8 -7
  52. package/src/contract/ralph.ts +29 -4
  53. package/src/global.ts +56 -0
  54. package/src/index.ts +7 -0
  55. package/src/signer/index.ts +0 -1
  56. package/src/signer/signer.ts +165 -134
  57. package/src/transaction/index.ts +0 -1
  58. package/src/transaction/status.ts +6 -3
  59. package/src/utils/bs58.ts +11 -0
  60. package/src/utils/index.ts +0 -1
  61. package/src/utils/subscription.ts +1 -5
  62. package/src/utils/utils.ts +15 -23
  63. package/webpack.config.js +3 -0
  64. package/.eslintrc.json +0 -21
  65. package/LICENSE +0 -165
  66. package/contracts/add/add.ral +0 -16
  67. package/contracts/greeter/greeter.ral +0 -7
  68. package/contracts/greeter/greeter_interface.ral +0 -3
  69. package/contracts/greeter_main.ral +0 -9
  70. package/contracts/main.ral +0 -6
  71. package/contracts/sub/sub.ral +0 -9
  72. package/dev/user.conf +0 -29
  73. package/dist/scripts/create-project.d.ts +0 -2
  74. package/dist/scripts/create-project.js +0 -124
  75. package/dist/scripts/rename-gitignore.d.ts +0 -1
  76. package/dist/scripts/start-devnet.d.ts +0 -1
  77. package/dist/scripts/start-devnet.js +0 -131
  78. package/dist/scripts/stop-devnet.d.ts +0 -1
  79. package/dist/scripts/stop-devnet.js +0 -32
  80. package/dist/src/signer/node-wallet.d.ts +0 -13
  81. package/dist/src/signer/node-wallet.js +0 -60
  82. package/dist/src/test/index.d.ts +0 -7
  83. package/dist/src/test/index.js +0 -41
  84. package/dist/src/test/privatekey-wallet.d.ts +0 -12
  85. package/dist/src/test/privatekey-wallet.js +0 -68
  86. package/dist/src/transaction/sign-verify.d.ts +0 -2
  87. package/dist/src/transaction/sign-verify.js +0 -58
  88. package/dist/src/utils/password-crypto.d.ts +0 -2
  89. package/dist/src/utils/password-crypto.js +0 -69
  90. package/gitignore +0 -10
  91. package/scripts/create-project.ts +0 -136
  92. package/scripts/start-devnet.js +0 -141
  93. package/scripts/stop-devnet.js +0 -32
  94. package/src/contract/ralph.test.ts +0 -178
  95. package/src/fixtures/address.json +0 -36
  96. package/src/fixtures/balance.json +0 -9
  97. package/src/fixtures/self-clique.json +0 -19
  98. package/src/fixtures/transaction.json +0 -13
  99. package/src/fixtures/transactions.json +0 -179
  100. package/src/signer/fixtures/genesis.json +0 -26
  101. package/src/signer/fixtures/wallets.json +0 -26
  102. package/src/signer/node-wallet.ts +0 -74
  103. package/src/test/index.ts +0 -32
  104. package/src/test/privatekey-wallet.ts +0 -58
  105. package/src/transaction/sign-verify.test.ts +0 -50
  106. package/src/transaction/sign-verify.ts +0 -39
  107. package/src/utils/address.test.ts +0 -47
  108. package/src/utils/djb2.test.ts +0 -35
  109. package/src/utils/password-crypto.test.ts +0 -27
  110. package/src/utils/password-crypto.ts +0 -77
  111. package/src/utils/utils.test.ts +0 -161
  112. package/templates/base/README.md +0 -34
  113. package/templates/base/package.json +0 -35
  114. package/templates/base/src/greeter.ts +0 -41
  115. package/templates/base/tsconfig.json +0 -19
  116. package/templates/react/README.md +0 -34
  117. package/templates/react/config-overrides.js +0 -18
  118. package/templates/react/package.json +0 -66
  119. package/templates/react/src/App.tsx +0 -42
  120. package/templates/react/src/artifacts/greeter.ral.json +0 -26
  121. package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
  122. package/templates/shared/.eslintrc.json +0 -12
  123. package/templates/shared/scripts/header.js +0 -0
  124. package/test/contract.test.ts +0 -178
  125. package/test/events.test.ts +0 -138
  126. package/test/transaction.test.ts +0 -72
@@ -85,6 +85,10 @@ export interface Banned {
85
85
  until: number;
86
86
  type: string;
87
87
  }
88
+ export interface BlockAndEvents {
89
+ block: BlockEntry;
90
+ events: ContractEventByBlockHash[];
91
+ }
88
92
  export interface BlockEntry {
89
93
  /** @format block-hash */
90
94
  hash: string;
@@ -121,6 +125,12 @@ export interface BlockHeaderEntry {
121
125
  height: number;
122
126
  deps: string[];
123
127
  }
128
+ export interface BlocksAndEventsPerTimeStampRange {
129
+ blocksAndEvents: BlockAndEvents[][];
130
+ }
131
+ export interface BlocksPerTimeStampRange {
132
+ blocks: BlockEntry[][];
133
+ }
124
134
  export interface BrokerInfo {
125
135
  /** @format clique-id */
126
136
  cliqueId: string;
@@ -148,6 +158,8 @@ export interface BuildDeployContractTx {
148
158
  gasAmount?: number;
149
159
  /** @format uint256 */
150
160
  gasPrice?: string;
161
+ /** @format block-hash */
162
+ targetBlockHash?: string;
151
163
  }
152
164
  export interface BuildDeployContractTxResult {
153
165
  /** @format int32 */
@@ -176,6 +188,8 @@ export interface BuildExecuteScriptTx {
176
188
  gasAmount?: number;
177
189
  /** @format uint256 */
178
190
  gasPrice?: string;
191
+ /** @format block-hash */
192
+ targetBlockHash?: string;
179
193
  }
180
194
  export interface BuildExecuteScriptTxResult {
181
195
  /** @format int32 */
@@ -224,6 +238,8 @@ export interface BuildSweepAddressTransactions {
224
238
  gasAmount?: number;
225
239
  /** @format uint256 */
226
240
  gasPrice?: string;
241
+ /** @format block-hash */
242
+ targetBlockHash?: string;
227
243
  }
228
244
  export interface BuildSweepAddressTransactionsResult {
229
245
  unsignedTxs: SweepAddressTransaction[];
@@ -241,6 +257,8 @@ export interface BuildTransaction {
241
257
  gasAmount?: number;
242
258
  /** @format uint256 */
243
259
  gasPrice?: string;
260
+ /** @format block-hash */
261
+ targetBlockHash?: string;
244
262
  }
245
263
  export interface BuildTransactionResult {
246
264
  unsignedTx: string;
@@ -297,17 +315,39 @@ export interface ChangeActiveAddress {
297
315
  address: string;
298
316
  }
299
317
  export interface CompileContractResult {
318
+ version: string;
319
+ name: string;
300
320
  bytecode: string;
321
+ bytecodeDebugPatch: string;
301
322
  /** @format 32-byte-hash */
302
323
  codeHash: string;
324
+ /** @format 32-byte-hash */
325
+ codeHashDebug: string;
303
326
  fields: FieldsSig;
304
327
  functions: FunctionSig[];
305
328
  events: EventSig[];
329
+ warnings: string[];
330
+ }
331
+ export interface CompileProjectResult {
332
+ contracts: CompileContractResult[];
333
+ scripts: CompileScriptResult[];
306
334
  }
307
335
  export interface CompileScriptResult {
336
+ version: string;
337
+ name: string;
308
338
  bytecodeTemplate: string;
339
+ bytecodeDebugPatch: string;
309
340
  fields: FieldsSig;
310
341
  functions: FunctionSig[];
342
+ warnings: string[];
343
+ }
344
+ export interface CompilerOptions {
345
+ ignoreUnusedConstantsWarnings?: boolean;
346
+ ignoreUnusedVariablesWarnings?: boolean;
347
+ ignoreUnusedFieldsWarnings?: boolean;
348
+ ignoreUnusedPrivateFunctionsWarnings?: boolean;
349
+ ignoreReadonlyCheckWarnings?: boolean;
350
+ ignoreExternalCallCheckWarnings?: boolean;
311
351
  }
312
352
  export interface Confirmed {
313
353
  /** @format block-hash */
@@ -324,6 +364,7 @@ export interface Confirmed {
324
364
  }
325
365
  export interface Contract {
326
366
  code: string;
367
+ compilerOptions?: CompilerOptions;
327
368
  }
328
369
  export interface ContractEvent {
329
370
  /** @format block-hash */
@@ -334,6 +375,15 @@ export interface ContractEvent {
334
375
  eventIndex: number;
335
376
  fields: Val[];
336
377
  }
378
+ export interface ContractEventByBlockHash {
379
+ /** @format 32-byte-hash */
380
+ txId: string;
381
+ /** @format address */
382
+ contractAddress: string;
383
+ /** @format int32 */
384
+ eventIndex: number;
385
+ fields: Val[];
386
+ }
337
387
  export interface ContractEventByTxId {
338
388
  /** @format block-hash */
339
389
  blockHash: string;
@@ -348,10 +398,11 @@ export interface ContractEvents {
348
398
  /** @format int32 */
349
399
  nextStart: number;
350
400
  }
401
+ export interface ContractEventsByBlockHash {
402
+ events: ContractEventByBlockHash[];
403
+ }
351
404
  export interface ContractEventsByTxId {
352
405
  events: ContractEventByTxId[];
353
- /** @format int32 */
354
- nextStart: number;
355
406
  }
356
407
  export interface ContractOutput {
357
408
  /** @format int32 */
@@ -377,6 +428,11 @@ export interface ContractState {
377
428
  fields: Val[];
378
429
  asset: AssetState;
379
430
  }
431
+ export interface DebugMessage {
432
+ /** @format address */
433
+ contractAddress: string;
434
+ message: string;
435
+ }
380
436
  export interface DecodeUnsignedTx {
381
437
  unsignedTx: string;
382
438
  }
@@ -401,17 +457,13 @@ export interface Destination {
401
457
  export declare type DiscoveryAction = Reachable | Unreachable;
402
458
  export interface EventSig {
403
459
  name: string;
404
- signature: string;
405
460
  fieldNames: string[];
406
461
  fieldTypes: string[];
407
462
  }
408
- export interface FetchResponse {
409
- blocks: BlockEntry[][];
410
- }
411
463
  export interface FieldsSig {
412
- signature: string;
413
464
  names: string[];
414
465
  types: string[];
466
+ isMutable: boolean[];
415
467
  }
416
468
  export interface FixedAssetOutput {
417
469
  /** @format int32 */
@@ -430,9 +482,12 @@ export interface FixedAssetOutput {
430
482
  }
431
483
  export interface FunctionSig {
432
484
  name: string;
433
- signature: string;
434
- argNames: string[];
435
- argTypes: string[];
485
+ usePreapprovedAssets: boolean;
486
+ useAssetsInContract: boolean;
487
+ isPublic: boolean;
488
+ paramNames: string[];
489
+ paramTypes: string[];
490
+ paramIsMutable: boolean[];
436
491
  returnTypes: string[];
437
492
  }
438
493
  export interface Group {
@@ -514,6 +569,10 @@ export interface Penalty {
514
569
  value: number;
515
570
  type: string;
516
571
  }
572
+ export interface Project {
573
+ code: string;
574
+ compilerOptions?: CompilerOptions;
575
+ }
517
576
  export interface Reachable {
518
577
  peers: string[];
519
578
  type: string;
@@ -534,6 +593,7 @@ export interface RevealMnemonicResult {
534
593
  }
535
594
  export interface Script {
536
595
  code: string;
596
+ compilerOptions?: CompilerOptions;
537
597
  }
538
598
  export interface SelfClique {
539
599
  /** @format clique-id */
@@ -580,6 +640,8 @@ export interface Sweep {
580
640
  gasPrice?: string;
581
641
  /** @format int32 */
582
642
  utxosLimit?: number;
643
+ /** @format block-hash */
644
+ targetBlockHash?: string;
583
645
  }
584
646
  export interface SweepAddressTransaction {
585
647
  /** @format 32-byte-hash */
@@ -621,6 +683,7 @@ export interface TestContractResult {
621
683
  txInputs: string[];
622
684
  txOutputs: Output[];
623
685
  events: ContractEventByTxId[];
686
+ debugMessages: DebugMessage[];
624
687
  }
625
688
  export interface TestInputAsset {
626
689
  /** @format address */
@@ -845,8 +908,8 @@ export declare class HttpClient<SecurityDataType = unknown> {
845
908
  }
846
909
  /**
847
910
  * @title Alephium API
848
- * @version 1.4.2
849
- * @baseUrl {protocol}://{host}:{port}
911
+ * @version 1.5.0
912
+ * @baseUrl ../
850
913
  */
851
914
  export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
852
915
  wallets: {
@@ -1003,8 +1066,8 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1003
1066
  * @request POST:/wallets/{wallet_name}/derive-next-address
1004
1067
  */
1005
1068
  postWalletsWalletNameDeriveNextAddress: (walletName: string, query?: {
1006
- group?: number | undefined;
1007
- } | undefined, params?: RequestParams) => Promise<AddressInfo>;
1069
+ group?: number;
1070
+ }, params?: RequestParams) => Promise<AddressInfo>;
1008
1071
  /**
1009
1072
  * @description Your wallet need to have been created with the miner flag set to true
1010
1073
  *
@@ -1136,22 +1199,34 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1136
1199
  * @request GET:/infos/current-hashrate
1137
1200
  */
1138
1201
  getInfosCurrentHashrate: (query?: {
1139
- timespan?: number | undefined;
1140
- } | undefined, params?: RequestParams) => Promise<string>;
1202
+ timespan?: number;
1203
+ }, params?: RequestParams) => Promise<string>;
1141
1204
  };
1142
1205
  blockflow: {
1143
1206
  /**
1144
1207
  * No description
1145
1208
  *
1146
1209
  * @tags Blockflow
1147
- * @name GetBlockflow
1210
+ * @name GetBlockflowBlocks
1148
1211
  * @summary List blocks on the given time interval
1149
- * @request GET:/blockflow
1212
+ * @request GET:/blockflow/blocks
1150
1213
  */
1151
- getBlockflow: (query: {
1214
+ getBlockflowBlocks: (query: {
1152
1215
  fromTs: number;
1153
1216
  toTs?: number;
1154
- }, params?: RequestParams) => Promise<FetchResponse>;
1217
+ }, params?: RequestParams) => Promise<BlocksPerTimeStampRange>;
1218
+ /**
1219
+ * No description
1220
+ *
1221
+ * @tags Blockflow
1222
+ * @name GetBlockflowBlocksWithEvents
1223
+ * @summary List blocks with events on the given time interval
1224
+ * @request GET:/blockflow/blocks-with-events
1225
+ */
1226
+ getBlockflowBlocksWithEvents: (query: {
1227
+ fromTs: number;
1228
+ toTs?: number;
1229
+ }, params?: RequestParams) => Promise<BlocksAndEventsPerTimeStampRange>;
1155
1230
  /**
1156
1231
  * No description
1157
1232
  *
@@ -1161,6 +1236,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1161
1236
  * @request GET:/blockflow/blocks/{block_hash}
1162
1237
  */
1163
1238
  getBlockflowBlocksBlockHash: (blockHash: string, params?: RequestParams) => Promise<BlockEntry>;
1239
+ /**
1240
+ * No description
1241
+ *
1242
+ * @tags Blockflow
1243
+ * @name GetBlockflowBlocksWithEventsBlockHash
1244
+ * @summary Get a block and events with hash
1245
+ * @request GET:/blockflow/blocks-with-events/{block_hash}
1246
+ */
1247
+ getBlockflowBlocksWithEventsBlockHash: (blockHash: string, params?: RequestParams) => Promise<BlockAndEvents>;
1164
1248
  /**
1165
1249
  * No description
1166
1250
  *
@@ -1282,6 +1366,18 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1282
1366
  * @request POST:/transactions/decode-unsigned-tx
1283
1367
  */
1284
1368
  postTransactionsDecodeUnsignedTx: (data: DecodeUnsignedTx, params?: RequestParams) => Promise<DecodeUnsignedTxResult>;
1369
+ /**
1370
+ * No description
1371
+ *
1372
+ * @tags Transactions
1373
+ * @name GetTransactionsDetailsTxid
1374
+ * @summary Get transaction details
1375
+ * @request GET:/transactions/details/{txId}
1376
+ */
1377
+ getTransactionsDetailsTxid: (txId: string, query?: {
1378
+ fromGroup?: number;
1379
+ toGroup?: number;
1380
+ }, params?: RequestParams) => Promise<Transaction>;
1285
1381
  /**
1286
1382
  * No description
1287
1383
  *
@@ -1324,6 +1420,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1324
1420
  * @request POST:/contracts/compile-contract
1325
1421
  */
1326
1422
  postContractsCompileContract: (data: Contract, params?: RequestParams) => Promise<CompileContractResult>;
1423
+ /**
1424
+ * No description
1425
+ *
1426
+ * @tags Contracts
1427
+ * @name PostContractsCompileProject
1428
+ * @summary Compile a project
1429
+ * @request POST:/contracts/compile-project
1430
+ */
1431
+ postContractsCompileProject: (data: Project, params?: RequestParams) => Promise<CompileProjectResult>;
1327
1432
  /**
1328
1433
  * No description
1329
1434
  *
@@ -1424,6 +1529,18 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1424
1529
  postMinersCpuMining: (query: {
1425
1530
  action: string;
1426
1531
  }, params?: RequestParams) => Promise<boolean>;
1532
+ /**
1533
+ * No description
1534
+ *
1535
+ * @tags Miners
1536
+ * @name PostMinersCpuMiningMineOneBlock
1537
+ * @summary Mine a block on CPU miner. !!! for test only !!!
1538
+ * @request POST:/miners/cpu-mining/mine-one-block
1539
+ */
1540
+ postMinersCpuMiningMineOneBlock: (query: {
1541
+ fromGroup: number;
1542
+ toGroup: number;
1543
+ }, params?: RequestParams) => Promise<boolean>;
1427
1544
  /**
1428
1545
  * No description
1429
1546
  *
@@ -1454,7 +1571,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1454
1571
  */
1455
1572
  getEventsContractContractaddress: (contractAddress: string, query: {
1456
1573
  start: number;
1457
- end?: number;
1574
+ limit?: number;
1458
1575
  group?: number;
1459
1576
  }, params?: RequestParams) => Promise<ContractEvents>;
1460
1577
  /**
@@ -1471,12 +1588,23 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1471
1588
  *
1472
1589
  * @tags Events
1473
1590
  * @name GetEventsTxIdTxid
1474
- * @summary Get events for a TxScript
1591
+ * @summary Get contract events for a transaction
1475
1592
  * @request GET:/events/tx-id/{txId}
1476
1593
  */
1477
1594
  getEventsTxIdTxid: (txId: string, query?: {
1478
- group?: number | undefined;
1479
- } | undefined, params?: RequestParams) => Promise<ContractEventsByTxId>;
1595
+ group?: number;
1596
+ }, params?: RequestParams) => Promise<ContractEventsByTxId>;
1597
+ /**
1598
+ * No description
1599
+ *
1600
+ * @tags Events
1601
+ * @name GetEventsBlockHashBlockhash
1602
+ * @summary Get contract events for a block
1603
+ * @request GET:/events/block-hash/{blockHash}
1604
+ */
1605
+ getEventsBlockHashBlockhash: (blockHash: string, query?: {
1606
+ group?: number;
1607
+ }, params?: RequestParams) => Promise<ContractEventsByBlockHash>;
1480
1608
  };
1481
1609
  }
1482
1610
  export {};