@alephium/web3 0.3.0-rc.4 → 0.3.0-rc.7
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/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +1 -1
- package/dist/src/api/api-alephium.js +1 -1
- package/dist/src/api/api-explorer.d.ts +91 -21
- package/dist/src/api/api-explorer.js +64 -31
- package/dist/src/api/index.d.ts +0 -1
- package/dist/src/api/index.js +0 -2
- package/dist/src/contract/contract.d.ts +21 -21
- package/dist/src/contract/contract.js +103 -108
- package/dist/src/signer/index.d.ts +2 -0
- package/dist/src/signer/index.js +2 -0
- package/dist/src/signer/signer.d.ts +30 -107
- package/dist/src/signer/signer.js +63 -68
- package/dist/src/signer/tx-builder.d.ts +17 -0
- package/dist/src/signer/tx-builder.js +93 -0
- package/dist/src/signer/types.d.ts +121 -0
- package/dist/src/signer/types.js +30 -0
- package/package.json +4 -3
- package/src/api/api-alephium.ts +1 -1
- package/src/api/api-explorer.ts +134 -36
- package/src/api/index.ts +0 -2
- package/src/contract/contract.ts +143 -121
- package/src/signer/index.ts +2 -0
- package/src/signer/signer.ts +112 -188
- package/src/signer/tx-builder.ts +121 -0
- package/src/signer/types.ts +155 -0
- package/webpack.config.js +1 -0
package/src/api/api-explorer.ts
CHANGED
|
@@ -96,6 +96,7 @@ export interface ConfirmedTransaction {
|
|
|
96
96
|
|
|
97
97
|
/** @format uint256 */
|
|
98
98
|
gasPrice: string
|
|
99
|
+
coinbase: boolean
|
|
99
100
|
type: string
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -116,6 +117,20 @@ export interface ContractOutput {
|
|
|
116
117
|
type: string
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
export interface Event {
|
|
121
|
+
/** @format block-hash */
|
|
122
|
+
blockHash: string
|
|
123
|
+
|
|
124
|
+
/** @format 32-byte-hash */
|
|
125
|
+
txHash: string
|
|
126
|
+
contractAddress: string
|
|
127
|
+
inputAddress?: string
|
|
128
|
+
|
|
129
|
+
/** @format int32 */
|
|
130
|
+
eventIndex: number
|
|
131
|
+
fields?: Val[]
|
|
132
|
+
}
|
|
133
|
+
|
|
119
134
|
export interface ExplorerInfo {
|
|
120
135
|
releaseVersion: string
|
|
121
136
|
commit: string
|
|
@@ -147,6 +162,11 @@ export interface InternalServerError {
|
|
|
147
162
|
detail: string
|
|
148
163
|
}
|
|
149
164
|
|
|
165
|
+
export enum IntervalType {
|
|
166
|
+
Daily = 'daily',
|
|
167
|
+
Hourly = 'hourly'
|
|
168
|
+
}
|
|
169
|
+
|
|
150
170
|
export interface ListBlocks {
|
|
151
171
|
/** @format int32 */
|
|
152
172
|
total: number
|
|
@@ -275,6 +295,7 @@ export interface Transaction {
|
|
|
275
295
|
|
|
276
296
|
/** @format uint256 */
|
|
277
297
|
gasPrice: string
|
|
298
|
+
coinbase: boolean
|
|
278
299
|
}
|
|
279
300
|
|
|
280
301
|
export type TransactionLike = ConfirmedTransaction | UnconfirmedTransaction
|
|
@@ -306,6 +327,42 @@ export interface UnconfirmedTransaction {
|
|
|
306
327
|
type: string
|
|
307
328
|
}
|
|
308
329
|
|
|
330
|
+
export type Val = ValAddress | ValArray | ValBool | ValByteVec | ValI256 | ValU256
|
|
331
|
+
|
|
332
|
+
export interface ValAddress {
|
|
333
|
+
/** @format address */
|
|
334
|
+
value: string
|
|
335
|
+
type: string
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface ValArray {
|
|
339
|
+
value: Val[]
|
|
340
|
+
type: string
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface ValBool {
|
|
344
|
+
value: boolean
|
|
345
|
+
type: string
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export interface ValByteVec {
|
|
349
|
+
/** @format hex-string */
|
|
350
|
+
value: string
|
|
351
|
+
type: string
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface ValI256 {
|
|
355
|
+
/** @format bigint */
|
|
356
|
+
value: string
|
|
357
|
+
type: string
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface ValU256 {
|
|
361
|
+
/** @format uint256 */
|
|
362
|
+
value: string
|
|
363
|
+
type: string
|
|
364
|
+
}
|
|
365
|
+
|
|
309
366
|
import 'cross-fetch/polyfill'
|
|
310
367
|
import { convertHttpResponse } from './utils'
|
|
311
368
|
|
|
@@ -587,21 +644,6 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
587
644
|
method: 'GET',
|
|
588
645
|
format: 'json',
|
|
589
646
|
...params
|
|
590
|
-
}).then(convertHttpResponse),
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* @description Get a transaction from a output reference key
|
|
594
|
-
*
|
|
595
|
-
* @tags Transactions
|
|
596
|
-
* @name GetTransactionsByOutputRefKeyOutputRefKey
|
|
597
|
-
* @request GET:/transactions/by/output-ref-key/{output_ref_key}
|
|
598
|
-
*/
|
|
599
|
-
getTransactionsByOutputRefKeyOutputRefKey: (outputRefKey: string, params: RequestParams = {}) =>
|
|
600
|
-
this.request<Transaction, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
601
|
-
path: `/transactions/by/output-ref-key/${outputRefKey}`,
|
|
602
|
-
method: 'GET',
|
|
603
|
-
format: 'json',
|
|
604
|
-
...params
|
|
605
647
|
}).then(convertHttpResponse)
|
|
606
648
|
}
|
|
607
649
|
addresses = {
|
|
@@ -778,6 +820,23 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
778
820
|
...params
|
|
779
821
|
}).then(convertHttpResponse),
|
|
780
822
|
|
|
823
|
+
/**
|
|
824
|
+
* @description Are the addresses used (at least 1 transaction)
|
|
825
|
+
*
|
|
826
|
+
* @tags Addresses, Addresses
|
|
827
|
+
* @name PostAddressesUsed
|
|
828
|
+
* @request POST:/addresses/used
|
|
829
|
+
*/
|
|
830
|
+
postAddressesUsed: (data?: string[], params: RequestParams = {}) =>
|
|
831
|
+
this.request<boolean[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
832
|
+
path: `/addresses/used`,
|
|
833
|
+
method: 'POST',
|
|
834
|
+
body: data,
|
|
835
|
+
type: ContentType.Json,
|
|
836
|
+
format: 'json',
|
|
837
|
+
...params
|
|
838
|
+
}).then(convertHttpResponse),
|
|
839
|
+
|
|
781
840
|
/**
|
|
782
841
|
* No description
|
|
783
842
|
*
|
|
@@ -797,24 +856,6 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
797
856
|
...params
|
|
798
857
|
}).then(convertHttpResponse)
|
|
799
858
|
}
|
|
800
|
-
addressesActive = {
|
|
801
|
-
/**
|
|
802
|
-
* @description Are the addresses active (at least 1 transaction)
|
|
803
|
-
*
|
|
804
|
-
* @tags Addresses
|
|
805
|
-
* @name PostAddressesActive
|
|
806
|
-
* @request POST:/addresses-active
|
|
807
|
-
*/
|
|
808
|
-
postAddressesActive: (data?: string[], params: RequestParams = {}) =>
|
|
809
|
-
this.request<boolean[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
810
|
-
path: `/addresses-active`,
|
|
811
|
-
method: 'POST',
|
|
812
|
-
body: data,
|
|
813
|
-
type: ContentType.Json,
|
|
814
|
-
format: 'json',
|
|
815
|
-
...params
|
|
816
|
-
}).then(convertHttpResponse)
|
|
817
|
-
}
|
|
818
859
|
infos = {
|
|
819
860
|
/**
|
|
820
861
|
* @description Get explorer informations
|
|
@@ -1016,7 +1057,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1016
1057
|
* @request GET:/charts/hashrates
|
|
1017
1058
|
*/
|
|
1018
1059
|
getChartsHashrates: (
|
|
1019
|
-
query: { fromTs: number; toTs: number; 'interval-type':
|
|
1060
|
+
query: { fromTs: number; toTs: number; 'interval-type': IntervalType },
|
|
1020
1061
|
params: RequestParams = {}
|
|
1021
1062
|
) =>
|
|
1022
1063
|
this.request<Hashrate[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -1036,7 +1077,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1036
1077
|
* @request GET:/charts/transactions-count
|
|
1037
1078
|
*/
|
|
1038
1079
|
getChartsTransactionsCount: (
|
|
1039
|
-
query: { fromTs: number; toTs: number; 'interval-type':
|
|
1080
|
+
query: { fromTs: number; toTs: number; 'interval-type': IntervalType },
|
|
1040
1081
|
params: RequestParams = {}
|
|
1041
1082
|
) =>
|
|
1042
1083
|
this.request<TimedCount[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -1056,7 +1097,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1056
1097
|
* @request GET:/charts/transactions-count-per-chain
|
|
1057
1098
|
*/
|
|
1058
1099
|
getChartsTransactionsCountPerChain: (
|
|
1059
|
-
query: { fromTs: number; toTs: number; 'interval-type':
|
|
1100
|
+
query: { fromTs: number; toTs: number; 'interval-type': IntervalType },
|
|
1060
1101
|
params: RequestParams = {}
|
|
1061
1102
|
) =>
|
|
1062
1103
|
this.request<
|
|
@@ -1070,6 +1111,63 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1070
1111
|
...params
|
|
1071
1112
|
}).then(convertHttpResponse)
|
|
1072
1113
|
}
|
|
1114
|
+
contractEvents = {
|
|
1115
|
+
/**
|
|
1116
|
+
* @description Get contract events by transaction id
|
|
1117
|
+
*
|
|
1118
|
+
* @tags Contract events
|
|
1119
|
+
* @name GetContractEventsTransactionIdTransactionId
|
|
1120
|
+
* @request GET:/contract-events/transaction-id/{transaction_id}
|
|
1121
|
+
*/
|
|
1122
|
+
getContractEventsTransactionIdTransactionId: (transactionId: string, params: RequestParams = {}) =>
|
|
1123
|
+
this.request<Event[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1124
|
+
path: `/contract-events/transaction-id/${transactionId}`,
|
|
1125
|
+
method: 'GET',
|
|
1126
|
+
format: 'json',
|
|
1127
|
+
...params
|
|
1128
|
+
}).then(convertHttpResponse),
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* @description Get contract events by contract address
|
|
1132
|
+
*
|
|
1133
|
+
* @tags Contract events
|
|
1134
|
+
* @name GetContractEventsContractAddressContractAddress
|
|
1135
|
+
* @request GET:/contract-events/contract-address/{contract_address}
|
|
1136
|
+
*/
|
|
1137
|
+
getContractEventsContractAddressContractAddress: (
|
|
1138
|
+
contractAddress: string,
|
|
1139
|
+
query?: { page?: number; limit?: number; reverse?: boolean },
|
|
1140
|
+
params: RequestParams = {}
|
|
1141
|
+
) =>
|
|
1142
|
+
this.request<Event[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1143
|
+
path: `/contract-events/contract-address/${contractAddress}`,
|
|
1144
|
+
method: 'GET',
|
|
1145
|
+
query: query,
|
|
1146
|
+
format: 'json',
|
|
1147
|
+
...params
|
|
1148
|
+
}).then(convertHttpResponse),
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* @description Get contract events by contract and input addresses
|
|
1152
|
+
*
|
|
1153
|
+
* @tags Contract events
|
|
1154
|
+
* @name GetContractEventsContractAddressContractAddressInputAddressInputAddress
|
|
1155
|
+
* @request GET:/contract-events/contract-address/{contract_address}/input-address/{input_address}
|
|
1156
|
+
*/
|
|
1157
|
+
getContractEventsContractAddressContractAddressInputAddressInputAddress: (
|
|
1158
|
+
contractAddress: string,
|
|
1159
|
+
inputAddress: string,
|
|
1160
|
+
query?: { page?: number; limit?: number; reverse?: boolean },
|
|
1161
|
+
params: RequestParams = {}
|
|
1162
|
+
) =>
|
|
1163
|
+
this.request<Event[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1164
|
+
path: `/contract-events/contract-address/${contractAddress}/input-address/${inputAddress}`,
|
|
1165
|
+
method: 'GET',
|
|
1166
|
+
query: query,
|
|
1167
|
+
format: 'json',
|
|
1168
|
+
...params
|
|
1169
|
+
}).then(convertHttpResponse)
|
|
1170
|
+
}
|
|
1073
1171
|
utils = {
|
|
1074
1172
|
/**
|
|
1075
1173
|
* @description Perform a sanity check
|
package/src/api/index.ts
CHANGED
|
@@ -118,7 +118,6 @@ export class ExplorerProvider {
|
|
|
118
118
|
readonly blocks = ExplorerApi['blocks']
|
|
119
119
|
readonly transactions = ExplorerApi['transactions']
|
|
120
120
|
readonly addresses = ExplorerApi['addresses']
|
|
121
|
-
readonly addressesActive = ExplorerApi['addressesActive']
|
|
122
121
|
readonly infos = ExplorerApi['infos']
|
|
123
122
|
readonly unconfirmedTransactions = ExplorerApi['unconfirmedTransactions']
|
|
124
123
|
readonly tokens = ExplorerApi['tokens']
|
|
@@ -142,7 +141,6 @@ export class ExplorerProvider {
|
|
|
142
141
|
this.blocks = { ...explorerApi.blocks }
|
|
143
142
|
this.transactions = { ...explorerApi.transactions }
|
|
144
143
|
this.addresses = { ...explorerApi.addresses }
|
|
145
|
-
this.addressesActive = { ...explorerApi.addressesActive }
|
|
146
144
|
this.infos = { ...explorerApi.infos }
|
|
147
145
|
this.unconfirmedTransactions = { ...explorerApi.unconfirmedTransactions }
|
|
148
146
|
this.tokens = { ...explorerApi.tokens }
|