@alephium/web3 1.5.2 → 1.6.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.
@@ -790,6 +790,16 @@ export interface Project {
790
790
  code: string;
791
791
  compilerOptions?: CompilerOptions;
792
792
  }
793
+ /** RawBlock */
794
+ export interface RawBlock {
795
+ /** @format hex-string */
796
+ value: string;
797
+ }
798
+ /** RawTransaction */
799
+ export interface RawTransaction {
800
+ /** @format hex-string */
801
+ value: string;
802
+ }
793
803
  /** Reachable */
794
804
  export interface Reachable {
795
805
  peers: string[];
@@ -853,6 +863,12 @@ export interface StructSig {
853
863
  fieldTypes: string[];
854
864
  isMutable: boolean[];
855
865
  }
866
+ /** SubContracts */
867
+ export interface SubContracts {
868
+ subContracts: string[];
869
+ /** @format int32 */
870
+ nextStart: number;
871
+ }
856
872
  /** SubmitMultisig */
857
873
  export interface SubmitMultisig {
858
874
  unsignedTx: string;
@@ -1189,7 +1205,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
1189
1205
  }
1190
1206
  /**
1191
1207
  * @title Alephium API
1192
- * @version 3.5.2
1208
+ * @version 3.6.2
1193
1209
  * @baseUrl ../
1194
1210
  */
1195
1211
  export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -1624,6 +1640,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1624
1640
  * @request GET:/blockflow/headers/{block_hash}
1625
1641
  */
1626
1642
  getBlockflowHeadersBlockHash: (blockHash: string, params?: RequestParams) => Promise<BlockHeaderEntry>;
1643
+ /**
1644
+ * No description
1645
+ *
1646
+ * @tags Blockflow
1647
+ * @name GetBlockflowRawBlocksBlockHash
1648
+ * @summary Get raw block in hex format
1649
+ * @request GET:/blockflow/raw-blocks/{block_hash}
1650
+ */
1651
+ getBlockflowRawBlocksBlockHash: (blockHash: string, params?: RequestParams) => Promise<RawBlock>;
1627
1652
  };
1628
1653
  addresses: {
1629
1654
  /**
@@ -1716,6 +1741,20 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1716
1741
  /** @format int32 */
1717
1742
  toGroup?: number;
1718
1743
  }, params?: RequestParams) => Promise<Transaction>;
1744
+ /**
1745
+ * No description
1746
+ *
1747
+ * @tags Transactions
1748
+ * @name GetTransactionsRawTxid
1749
+ * @summary Get raw transaction in hex format
1750
+ * @request GET:/transactions/raw/{txId}
1751
+ */
1752
+ getTransactionsRawTxid: (txId: string, query?: {
1753
+ /** @format int32 */
1754
+ fromGroup?: number;
1755
+ /** @format int32 */
1756
+ toGroup?: number;
1757
+ }, params?: RequestParams) => Promise<RawTransaction>;
1719
1758
  /**
1720
1759
  * No description
1721
1760
  *
@@ -1732,6 +1771,20 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1732
1771
  /** @format int32 */
1733
1772
  toGroup?: number;
1734
1773
  }, params?: RequestParams) => Promise<Confirmed | MemPooled | TxNotFound>;
1774
+ /**
1775
+ * No description
1776
+ *
1777
+ * @tags Transactions
1778
+ * @name GetTransactionsTxIdFromOutputref
1779
+ * @summary Get transaction id from transaction output ref
1780
+ * @request GET:/transactions/tx-id-from-outputref
1781
+ */
1782
+ getTransactionsTxIdFromOutputref: (query: {
1783
+ /** @format int32 */
1784
+ hint: number;
1785
+ /** @format 32-byte-hash */
1786
+ key: string;
1787
+ }, params?: RequestParams) => Promise<string>;
1735
1788
  };
1736
1789
  mempool: {
1737
1790
  /**
@@ -1856,6 +1909,38 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1856
1909
  * @request POST:/contracts/multicall-contract
1857
1910
  */
1858
1911
  postContractsMulticallContract: (data: MultipleCallContract, params?: RequestParams) => Promise<MultipleCallContractResult>;
1912
+ /**
1913
+ * No description
1914
+ *
1915
+ * @tags Contracts
1916
+ * @name GetContractsAddressParent
1917
+ * @summary Get parent contract address
1918
+ * @request GET:/contracts/{address}/parent
1919
+ */
1920
+ getContractsAddressParent: (address: string, params?: RequestParams) => Promise<string>;
1921
+ /**
1922
+ * No description
1923
+ *
1924
+ * @tags Contracts
1925
+ * @name GetContractsAddressSubContracts
1926
+ * @summary Get sub-contract addresses
1927
+ * @request GET:/contracts/{address}/sub-contracts
1928
+ */
1929
+ getContractsAddressSubContracts: (address: string, query: {
1930
+ /** @format int32 */
1931
+ start: number;
1932
+ /** @format int32 */
1933
+ limit?: number;
1934
+ }, params?: RequestParams) => Promise<SubContracts>;
1935
+ /**
1936
+ * No description
1937
+ *
1938
+ * @tags Contracts
1939
+ * @name GetContractsAddressSubContractsCurrentCount
1940
+ * @summary Get current value of the sub-contracts counter for a contract
1941
+ * @request GET:/contracts/{address}/sub-contracts/current-count
1942
+ */
1943
+ getContractsAddressSubContractsCurrentCount: (address: string, params?: RequestParams) => Promise<number>;
1859
1944
  /**
1860
1945
  * No description
1861
1946
  *
@@ -151,7 +151,7 @@ class HttpClient {
151
151
  exports.HttpClient = HttpClient;
152
152
  /**
153
153
  * @title Alephium API
154
- * @version 3.5.2
154
+ * @version 3.6.2
155
155
  * @baseUrl ../
156
156
  */
157
157
  class Api extends HttpClient {
@@ -761,6 +761,20 @@ class Api extends HttpClient {
761
761
  method: 'GET',
762
762
  format: 'json',
763
763
  ...params
764
+ }).then(utils_1.convertHttpResponse),
765
+ /**
766
+ * No description
767
+ *
768
+ * @tags Blockflow
769
+ * @name GetBlockflowRawBlocksBlockHash
770
+ * @summary Get raw block in hex format
771
+ * @request GET:/blockflow/raw-blocks/{block_hash}
772
+ */
773
+ getBlockflowRawBlocksBlockHash: (blockHash, params = {}) => this.request({
774
+ path: `/blockflow/raw-blocks/${blockHash}`,
775
+ method: 'GET',
776
+ format: 'json',
777
+ ...params
764
778
  }).then(utils_1.convertHttpResponse)
765
779
  };
766
780
  this.addresses = {
@@ -904,6 +918,21 @@ class Api extends HttpClient {
904
918
  format: 'json',
905
919
  ...params
906
920
  }).then(utils_1.convertHttpResponse),
921
+ /**
922
+ * No description
923
+ *
924
+ * @tags Transactions
925
+ * @name GetTransactionsRawTxid
926
+ * @summary Get raw transaction in hex format
927
+ * @request GET:/transactions/raw/{txId}
928
+ */
929
+ getTransactionsRawTxid: (txId, query, params = {}) => this.request({
930
+ path: `/transactions/raw/${txId}`,
931
+ method: 'GET',
932
+ query: query,
933
+ format: 'json',
934
+ ...params
935
+ }).then(utils_1.convertHttpResponse),
907
936
  /**
908
937
  * No description
909
938
  *
@@ -918,6 +947,21 @@ class Api extends HttpClient {
918
947
  query: query,
919
948
  format: 'json',
920
949
  ...params
950
+ }).then(utils_1.convertHttpResponse),
951
+ /**
952
+ * No description
953
+ *
954
+ * @tags Transactions
955
+ * @name GetTransactionsTxIdFromOutputref
956
+ * @summary Get transaction id from transaction output ref
957
+ * @request GET:/transactions/tx-id-from-outputref
958
+ */
959
+ getTransactionsTxIdFromOutputref: (query, params = {}) => this.request({
960
+ path: `/transactions/tx-id-from-outputref`,
961
+ method: 'GET',
962
+ query: query,
963
+ format: 'json',
964
+ ...params
921
965
  }).then(utils_1.convertHttpResponse)
922
966
  };
923
967
  this.mempool = {
@@ -1119,6 +1163,49 @@ class Api extends HttpClient {
1119
1163
  format: 'json',
1120
1164
  ...params
1121
1165
  }).then(utils_1.convertHttpResponse),
1166
+ /**
1167
+ * No description
1168
+ *
1169
+ * @tags Contracts
1170
+ * @name GetContractsAddressParent
1171
+ * @summary Get parent contract address
1172
+ * @request GET:/contracts/{address}/parent
1173
+ */
1174
+ getContractsAddressParent: (address, params = {}) => this.request({
1175
+ path: `/contracts/${address}/parent`,
1176
+ method: 'GET',
1177
+ format: 'json',
1178
+ ...params
1179
+ }).then(utils_1.convertHttpResponse),
1180
+ /**
1181
+ * No description
1182
+ *
1183
+ * @tags Contracts
1184
+ * @name GetContractsAddressSubContracts
1185
+ * @summary Get sub-contract addresses
1186
+ * @request GET:/contracts/{address}/sub-contracts
1187
+ */
1188
+ getContractsAddressSubContracts: (address, query, params = {}) => this.request({
1189
+ path: `/contracts/${address}/sub-contracts`,
1190
+ method: 'GET',
1191
+ query: query,
1192
+ format: 'json',
1193
+ ...params
1194
+ }).then(utils_1.convertHttpResponse),
1195
+ /**
1196
+ * No description
1197
+ *
1198
+ * @tags Contracts
1199
+ * @name GetContractsAddressSubContractsCurrentCount
1200
+ * @summary Get current value of the sub-contracts counter for a contract
1201
+ * @request GET:/contracts/{address}/sub-contracts/current-count
1202
+ */
1203
+ getContractsAddressSubContractsCurrentCount: (address, params = {}) => this.request({
1204
+ path: `/contracts/${address}/sub-contracts/current-count`,
1205
+ method: 'GET',
1206
+ format: 'json',
1207
+ ...params
1208
+ }).then(utils_1.convertHttpResponse),
1122
1209
  /**
1123
1210
  * No description
1124
1211
  *
@@ -1260,7 +1260,7 @@ async function multicallMethods(contract, instance, callss, getContractByCodeHas
1260
1260
  });
1261
1261
  const result = await (0, global_1.getCurrentNodeProvider)().contracts.postContractsMulticallContract({ calls: callsParams.flat() });
1262
1262
  let callResultIndex = 0;
1263
- const results = callsParams.map((calls, index0) => {
1263
+ return callsParams.map((calls, index0) => {
1264
1264
  const callsResult = {};
1265
1265
  const entries = callEntries[`${index0}`];
1266
1266
  calls.forEach((call, index1) => {
@@ -1272,7 +1272,6 @@ async function multicallMethods(contract, instance, callss, getContractByCodeHas
1272
1272
  });
1273
1273
  return callsResult;
1274
1274
  });
1275
- return results.length === 1 ? results[0] : results;
1276
1275
  }
1277
1276
  exports.multicallMethods = multicallMethods;
1278
1277
  async function getContractEventsCurrentCount(contractAddress) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "1.5.2",
3
+ "version": "1.6.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",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "author": "Alephium dev <dev@alephium.org>",
35
35
  "config": {
36
- "alephium_version": "3.5.2",
36
+ "alephium_version": "3.6.2",
37
37
  "explorer_backend_version": "2.0.0"
38
38
  },
39
39
  "type": "commonjs",
@@ -892,6 +892,18 @@ export interface Project {
892
892
  compilerOptions?: CompilerOptions
893
893
  }
894
894
 
895
+ /** RawBlock */
896
+ export interface RawBlock {
897
+ /** @format hex-string */
898
+ value: string
899
+ }
900
+
901
+ /** RawTransaction */
902
+ export interface RawTransaction {
903
+ /** @format hex-string */
904
+ value: string
905
+ }
906
+
895
907
  /** Reachable */
896
908
  export interface Reachable {
897
909
  peers: string[]
@@ -966,6 +978,13 @@ export interface StructSig {
966
978
  isMutable: boolean[]
967
979
  }
968
980
 
981
+ /** SubContracts */
982
+ export interface SubContracts {
983
+ subContracts: string[]
984
+ /** @format int32 */
985
+ nextStart: number
986
+ }
987
+
969
988
  /** SubmitMultisig */
970
989
  export interface SubmitMultisig {
971
990
  unsignedTx: string
@@ -1493,7 +1512,7 @@ export class HttpClient<SecurityDataType = unknown> {
1493
1512
 
1494
1513
  /**
1495
1514
  * @title Alephium API
1496
- * @version 3.5.2
1515
+ * @version 3.6.2
1497
1516
  * @baseUrl ../
1498
1517
  */
1499
1518
  export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -2287,6 +2306,22 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2287
2306
  method: 'GET',
2288
2307
  format: 'json',
2289
2308
  ...params
2309
+ }).then(convertHttpResponse),
2310
+
2311
+ /**
2312
+ * No description
2313
+ *
2314
+ * @tags Blockflow
2315
+ * @name GetBlockflowRawBlocksBlockHash
2316
+ * @summary Get raw block in hex format
2317
+ * @request GET:/blockflow/raw-blocks/{block_hash}
2318
+ */
2319
+ getBlockflowRawBlocksBlockHash: (blockHash: string, params: RequestParams = {}) =>
2320
+ this.request<RawBlock, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2321
+ path: `/blockflow/raw-blocks/${blockHash}`,
2322
+ method: 'GET',
2323
+ format: 'json',
2324
+ ...params
2290
2325
  }).then(convertHttpResponse)
2291
2326
  }
2292
2327
  addresses = {
@@ -2474,6 +2509,32 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2474
2509
  ...params
2475
2510
  }).then(convertHttpResponse),
2476
2511
 
2512
+ /**
2513
+ * No description
2514
+ *
2515
+ * @tags Transactions
2516
+ * @name GetTransactionsRawTxid
2517
+ * @summary Get raw transaction in hex format
2518
+ * @request GET:/transactions/raw/{txId}
2519
+ */
2520
+ getTransactionsRawTxid: (
2521
+ txId: string,
2522
+ query?: {
2523
+ /** @format int32 */
2524
+ fromGroup?: number
2525
+ /** @format int32 */
2526
+ toGroup?: number
2527
+ },
2528
+ params: RequestParams = {}
2529
+ ) =>
2530
+ this.request<RawTransaction, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2531
+ path: `/transactions/raw/${txId}`,
2532
+ method: 'GET',
2533
+ query: query,
2534
+ format: 'json',
2535
+ ...params
2536
+ }).then(convertHttpResponse),
2537
+
2477
2538
  /**
2478
2539
  * No description
2479
2540
  *
@@ -2499,6 +2560,31 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2499
2560
  query: query,
2500
2561
  format: 'json',
2501
2562
  ...params
2563
+ }).then(convertHttpResponse),
2564
+
2565
+ /**
2566
+ * No description
2567
+ *
2568
+ * @tags Transactions
2569
+ * @name GetTransactionsTxIdFromOutputref
2570
+ * @summary Get transaction id from transaction output ref
2571
+ * @request GET:/transactions/tx-id-from-outputref
2572
+ */
2573
+ getTransactionsTxIdFromOutputref: (
2574
+ query: {
2575
+ /** @format int32 */
2576
+ hint: number
2577
+ /** @format 32-byte-hash */
2578
+ key: string
2579
+ },
2580
+ params: RequestParams = {}
2581
+ ) =>
2582
+ this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2583
+ path: `/transactions/tx-id-from-outputref`,
2584
+ method: 'GET',
2585
+ query: query,
2586
+ format: 'json',
2587
+ ...params
2502
2588
  }).then(convertHttpResponse)
2503
2589
  }
2504
2590
  mempool = {
@@ -2756,6 +2842,64 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2756
2842
  ...params
2757
2843
  }).then(convertHttpResponse),
2758
2844
 
2845
+ /**
2846
+ * No description
2847
+ *
2848
+ * @tags Contracts
2849
+ * @name GetContractsAddressParent
2850
+ * @summary Get parent contract address
2851
+ * @request GET:/contracts/{address}/parent
2852
+ */
2853
+ getContractsAddressParent: (address: string, params: RequestParams = {}) =>
2854
+ this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2855
+ path: `/contracts/${address}/parent`,
2856
+ method: 'GET',
2857
+ format: 'json',
2858
+ ...params
2859
+ }).then(convertHttpResponse),
2860
+
2861
+ /**
2862
+ * No description
2863
+ *
2864
+ * @tags Contracts
2865
+ * @name GetContractsAddressSubContracts
2866
+ * @summary Get sub-contract addresses
2867
+ * @request GET:/contracts/{address}/sub-contracts
2868
+ */
2869
+ getContractsAddressSubContracts: (
2870
+ address: string,
2871
+ query: {
2872
+ /** @format int32 */
2873
+ start: number
2874
+ /** @format int32 */
2875
+ limit?: number
2876
+ },
2877
+ params: RequestParams = {}
2878
+ ) =>
2879
+ this.request<SubContracts, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2880
+ path: `/contracts/${address}/sub-contracts`,
2881
+ method: 'GET',
2882
+ query: query,
2883
+ format: 'json',
2884
+ ...params
2885
+ }).then(convertHttpResponse),
2886
+
2887
+ /**
2888
+ * No description
2889
+ *
2890
+ * @tags Contracts
2891
+ * @name GetContractsAddressSubContractsCurrentCount
2892
+ * @summary Get current value of the sub-contracts counter for a contract
2893
+ * @request GET:/contracts/{address}/sub-contracts/current-count
2894
+ */
2895
+ getContractsAddressSubContractsCurrentCount: (address: string, params: RequestParams = {}) =>
2896
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2897
+ path: `/contracts/${address}/sub-contracts/current-count`,
2898
+ method: 'GET',
2899
+ format: 'json',
2900
+ ...params
2901
+ }).then(convertHttpResponse),
2902
+
2759
2903
  /**
2760
2904
  * No description
2761
2905
  *
@@ -1944,7 +1944,7 @@ export async function multicallMethods<I extends ContractInstance, F extends Fie
1944
1944
  })
1945
1945
  const result = await getCurrentNodeProvider().contracts.postContractsMulticallContract({ calls: callsParams.flat() })
1946
1946
  let callResultIndex = 0
1947
- const results = callsParams.map((calls, index0) => {
1947
+ return callsParams.map((calls, index0) => {
1948
1948
  const callsResult: Record<string, CallContractResult<any>> = {}
1949
1949
  const entries = callEntries[`${index0}`]
1950
1950
  calls.forEach((call, index1) => {
@@ -1961,7 +1961,6 @@ export async function multicallMethods<I extends ContractInstance, F extends Fie
1961
1961
  })
1962
1962
  return callsResult
1963
1963
  })
1964
- return results.length === 1 ? results[0] : results
1965
1964
  }
1966
1965
 
1967
1966
  export async function getContractEventsCurrentCount(contractAddress: Address): Promise<number> {