@alephium/web3 0.2.0-rc.34 → 0.2.0-rc.36
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-explorer.d.ts +11 -11
- package/dist/src/api/api-explorer.js +7 -7
- package/dist/src/api/index.d.ts +27 -34
- package/dist/src/api/index.js +75 -18
- package/dist/src/api/types.d.ts +2 -2
- package/dist/src/api/types.js +1 -6
- package/dist/src/contract/contract.d.ts +1 -1
- package/dist/src/contract/contract.js +7 -10
- package/dist/src/global.d.ts +4 -1
- package/dist/src/global.js +17 -1
- package/dist/src/signer/signer.d.ts +5 -3
- package/dist/src/signer/signer.js +3 -1
- package/package.json +3 -3
- package/src/api/api-explorer.ts +11 -20
- package/src/api/index.ts +94 -50
- package/src/api/types.ts +3 -7
- package/src/contract/contract.ts +8 -13
- package/src/global.ts +19 -1
- package/src/signer/signer.ts +8 -3
|
@@ -207,7 +207,7 @@ export interface UnconfirmedTransaction {
|
|
|
207
207
|
/** @format int32 */
|
|
208
208
|
chainTo: number;
|
|
209
209
|
inputs?: Input[];
|
|
210
|
-
outputs?:
|
|
210
|
+
outputs?: Output[];
|
|
211
211
|
/** @format int32 */
|
|
212
212
|
gasAmount: number;
|
|
213
213
|
/** @format uint256 */
|
|
@@ -297,7 +297,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
297
297
|
*
|
|
298
298
|
* @tags Blocks
|
|
299
299
|
* @name GetBlocksBlockHash
|
|
300
|
-
* @request GET:/blocks/{
|
|
300
|
+
* @request GET:/blocks/{block_hash}
|
|
301
301
|
*/
|
|
302
302
|
getBlocksBlockHash: (blockHash: string, params?: RequestParams) => Promise<BlockEntryLite>;
|
|
303
303
|
/**
|
|
@@ -305,7 +305,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
305
305
|
*
|
|
306
306
|
* @tags Blocks
|
|
307
307
|
* @name GetBlocksBlockHashTransactions
|
|
308
|
-
* @request GET:/blocks/{
|
|
308
|
+
* @request GET:/blocks/{block_hash}/transactions
|
|
309
309
|
*/
|
|
310
310
|
getBlocksBlockHashTransactions: (blockHash: string, query?: {
|
|
311
311
|
page?: number;
|
|
@@ -319,7 +319,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
319
319
|
*
|
|
320
320
|
* @tags Transactions
|
|
321
321
|
* @name GetTransactionsTransactionHash
|
|
322
|
-
* @request GET:/transactions/{
|
|
322
|
+
* @request GET:/transactions/{transaction_hash}
|
|
323
323
|
*/
|
|
324
324
|
getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<ConfirmedTransaction | UnconfirmedTransaction>;
|
|
325
325
|
};
|
|
@@ -329,9 +329,9 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
329
329
|
*
|
|
330
330
|
* @tags Transactions
|
|
331
331
|
* @name GetTransactionByOutputRefKeyOutputRefKey
|
|
332
|
-
* @request GET:/transaction-by-output-ref-key/{
|
|
332
|
+
* @request GET:/transaction-by-output-ref-key/{output_ref_key}
|
|
333
333
|
*/
|
|
334
|
-
getTransactionByOutputRefKeyOutputRefKey: (outputRefKey: string, params?: RequestParams) => Promise<
|
|
334
|
+
getTransactionByOutputRefKeyOutputRefKey: (outputRefKey: string, params?: RequestParams) => Promise<Transaction>;
|
|
335
335
|
};
|
|
336
336
|
addresses: {
|
|
337
337
|
/**
|
|
@@ -369,7 +369,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
369
369
|
* @name GetAddressesAddressUnconfirmedTransactions
|
|
370
370
|
* @request GET:/addresses/{address}/unconfirmed-transactions
|
|
371
371
|
*/
|
|
372
|
-
getAddressesAddressUnconfirmedTransactions: (address: string, params?: RequestParams) => Promise<
|
|
372
|
+
getAddressesAddressUnconfirmedTransactions: (address: string, params?: RequestParams) => Promise<TransactionLike[]>;
|
|
373
373
|
/**
|
|
374
374
|
* @description Get address balance
|
|
375
375
|
*
|
|
@@ -391,7 +391,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
391
391
|
*
|
|
392
392
|
* @tags Addresses
|
|
393
393
|
* @name GetAddressesAddressTokensTokenIdTransactions
|
|
394
|
-
* @request GET:/addresses/{address}/tokens/{
|
|
394
|
+
* @request GET:/addresses/{address}/tokens/{token_id}/transactions
|
|
395
395
|
*/
|
|
396
396
|
getAddressesAddressTokensTokenIdTransactions: (address: string, tokenId: string, query?: {
|
|
397
397
|
page?: number;
|
|
@@ -403,7 +403,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
403
403
|
*
|
|
404
404
|
* @tags Addresses
|
|
405
405
|
* @name GetAddressesAddressTokensTokenIdBalance
|
|
406
|
-
* @request GET:/addresses/{address}/tokens/{
|
|
406
|
+
* @request GET:/addresses/{address}/tokens/{token_id}/balance
|
|
407
407
|
*/
|
|
408
408
|
getAddressesAddressTokensTokenIdBalance: (address: string, tokenId: string, params?: RequestParams) => Promise<AddressBalance>;
|
|
409
409
|
};
|
|
@@ -507,7 +507,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
507
507
|
page?: number;
|
|
508
508
|
limit?: number;
|
|
509
509
|
reverse?: boolean;
|
|
510
|
-
}, params?: RequestParams) => Promise<
|
|
510
|
+
}, params?: RequestParams) => Promise<TransactionLike[]>;
|
|
511
511
|
};
|
|
512
512
|
tokens: {
|
|
513
513
|
/**
|
|
@@ -527,7 +527,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
527
527
|
*
|
|
528
528
|
* @tags Tokens
|
|
529
529
|
* @name GetTokensTokenIdTransactions
|
|
530
|
-
* @request GET:/tokens/{
|
|
530
|
+
* @request GET:/tokens/{token_id}/transactions
|
|
531
531
|
*/
|
|
532
532
|
getTokensTokenIdTransactions: (tokenId: string, query?: {
|
|
533
533
|
page?: number;
|
|
@@ -174,7 +174,7 @@ class Api extends HttpClient {
|
|
|
174
174
|
*
|
|
175
175
|
* @tags Blocks
|
|
176
176
|
* @name GetBlocksBlockHash
|
|
177
|
-
* @request GET:/blocks/{
|
|
177
|
+
* @request GET:/blocks/{block_hash}
|
|
178
178
|
*/
|
|
179
179
|
getBlocksBlockHash: (blockHash, params = {}) => this.request({
|
|
180
180
|
path: `/blocks/${blockHash}`,
|
|
@@ -187,7 +187,7 @@ class Api extends HttpClient {
|
|
|
187
187
|
*
|
|
188
188
|
* @tags Blocks
|
|
189
189
|
* @name GetBlocksBlockHashTransactions
|
|
190
|
-
* @request GET:/blocks/{
|
|
190
|
+
* @request GET:/blocks/{block_hash}/transactions
|
|
191
191
|
*/
|
|
192
192
|
getBlocksBlockHashTransactions: (blockHash, query, params = {}) => this.request({
|
|
193
193
|
path: `/blocks/${blockHash}/transactions`,
|
|
@@ -203,7 +203,7 @@ class Api extends HttpClient {
|
|
|
203
203
|
*
|
|
204
204
|
* @tags Transactions
|
|
205
205
|
* @name GetTransactionsTransactionHash
|
|
206
|
-
* @request GET:/transactions/{
|
|
206
|
+
* @request GET:/transactions/{transaction_hash}
|
|
207
207
|
*/
|
|
208
208
|
getTransactionsTransactionHash: (transactionHash, params = {}) => this.request({
|
|
209
209
|
path: `/transactions/${transactionHash}`,
|
|
@@ -218,7 +218,7 @@ class Api extends HttpClient {
|
|
|
218
218
|
*
|
|
219
219
|
* @tags Transactions
|
|
220
220
|
* @name GetTransactionByOutputRefKeyOutputRefKey
|
|
221
|
-
* @request GET:/transaction-by-output-ref-key/{
|
|
221
|
+
* @request GET:/transaction-by-output-ref-key/{output_ref_key}
|
|
222
222
|
*/
|
|
223
223
|
getTransactionByOutputRefKeyOutputRefKey: (outputRefKey, params = {}) => this.request({
|
|
224
224
|
path: `/transaction-by-output-ref-key/${outputRefKey}`,
|
|
@@ -312,7 +312,7 @@ class Api extends HttpClient {
|
|
|
312
312
|
*
|
|
313
313
|
* @tags Addresses
|
|
314
314
|
* @name GetAddressesAddressTokensTokenIdTransactions
|
|
315
|
-
* @request GET:/addresses/{address}/tokens/{
|
|
315
|
+
* @request GET:/addresses/{address}/tokens/{token_id}/transactions
|
|
316
316
|
*/
|
|
317
317
|
getAddressesAddressTokensTokenIdTransactions: (address, tokenId, query, params = {}) => this.request({
|
|
318
318
|
path: `/addresses/${address}/tokens/${tokenId}/transactions`,
|
|
@@ -326,7 +326,7 @@ class Api extends HttpClient {
|
|
|
326
326
|
*
|
|
327
327
|
* @tags Addresses
|
|
328
328
|
* @name GetAddressesAddressTokensTokenIdBalance
|
|
329
|
-
* @request GET:/addresses/{address}/tokens/{
|
|
329
|
+
* @request GET:/addresses/{address}/tokens/{token_id}/balance
|
|
330
330
|
*/
|
|
331
331
|
getAddressesAddressTokensTokenIdBalance: (address, tokenId, params = {}) => this.request({
|
|
332
332
|
path: `/addresses/${address}/tokens/${tokenId}/balance`,
|
|
@@ -503,7 +503,7 @@ class Api extends HttpClient {
|
|
|
503
503
|
*
|
|
504
504
|
* @tags Tokens
|
|
505
505
|
* @name GetTokensTokenIdTransactions
|
|
506
|
-
* @request GET:/tokens/{
|
|
506
|
+
* @request GET:/tokens/{token_id}/transactions
|
|
507
507
|
*/
|
|
508
508
|
getTokensTokenIdTransactions: (tokenId, query, params = {}) => this.request({
|
|
509
509
|
path: `/tokens/${tokenId}/transactions`,
|
package/dist/src/api/index.d.ts
CHANGED
|
@@ -1,38 +1,11 @@
|
|
|
1
1
|
import { Api as NodeApi } from './api-alephium';
|
|
2
|
-
|
|
3
|
-
interface INodeProvider {
|
|
4
|
-
readonly wallets: NodeApi<string>['wallets'];
|
|
5
|
-
readonly infos: NodeApi<string>['infos'];
|
|
6
|
-
readonly blockflow: NodeApi<string>['blockflow'];
|
|
7
|
-
readonly addresses: NodeApi<string>['addresses'];
|
|
8
|
-
readonly transactions: NodeApi<string>['transactions'];
|
|
9
|
-
readonly contracts: NodeApi<string>['contracts'];
|
|
10
|
-
readonly multisig: NodeApi<string>['multisig'];
|
|
11
|
-
readonly utils: NodeApi<string>['utils'];
|
|
12
|
-
readonly miners: NodeApi<string>['miners'];
|
|
13
|
-
readonly events: NodeApi<string>['events'];
|
|
14
|
-
}
|
|
15
|
-
export declare class NodeProvider implements INodeProvider {
|
|
16
|
-
readonly wallets: NodeApi<string>['wallets'];
|
|
17
|
-
readonly infos: NodeApi<string>['infos'];
|
|
18
|
-
readonly blockflow: NodeApi<string>['blockflow'];
|
|
19
|
-
readonly addresses: NodeApi<string>['addresses'];
|
|
20
|
-
readonly transactions: NodeApi<string>['transactions'];
|
|
21
|
-
readonly contracts: NodeApi<string>['contracts'];
|
|
22
|
-
readonly multisig: NodeApi<string>['multisig'];
|
|
23
|
-
readonly utils: NodeApi<string>['utils'];
|
|
24
|
-
readonly miners: NodeApi<string>['miners'];
|
|
25
|
-
readonly events: NodeApi<string>['events'];
|
|
26
|
-
constructor(provider: INodeProvider);
|
|
27
|
-
constructor(baseUrl: string, apiKey?: string);
|
|
28
|
-
static Proxy(nodeProvider: NodeProvider): NodeProvider;
|
|
29
|
-
}
|
|
30
|
-
export interface RequestArguments {
|
|
2
|
+
export interface ApiRequestArguments {
|
|
31
3
|
path: string;
|
|
32
4
|
method: string;
|
|
33
|
-
params
|
|
5
|
+
params: any[];
|
|
34
6
|
}
|
|
35
|
-
export declare
|
|
7
|
+
export declare type ApiRequestHandler = (args: ApiRequestArguments) => Promise<any>;
|
|
8
|
+
export declare class NodeProvider {
|
|
36
9
|
readonly wallets: NodeApi<string>['wallets'];
|
|
37
10
|
readonly infos: NodeApi<string>['infos'];
|
|
38
11
|
readonly blockflow: NodeApi<string>['blockflow'];
|
|
@@ -43,10 +16,30 @@ export declare class RemoteNodeProvider implements INodeProvider {
|
|
|
43
16
|
readonly utils: NodeApi<string>['utils'];
|
|
44
17
|
readonly miners: NodeApi<string>['miners'];
|
|
45
18
|
readonly events: NodeApi<string>['events'];
|
|
46
|
-
constructor(
|
|
19
|
+
constructor(baseUrl: string, apiKey?: string);
|
|
20
|
+
constructor(provider: NodeProvider);
|
|
21
|
+
constructor(handler: ApiRequestHandler);
|
|
22
|
+
request: (args: ApiRequestArguments) => Promise<any>;
|
|
23
|
+
static Proxy(nodeProvider: NodeProvider): NodeProvider;
|
|
24
|
+
static Remote(handler: ApiRequestHandler): NodeProvider;
|
|
47
25
|
}
|
|
48
|
-
export declare class ExplorerProvider
|
|
49
|
-
|
|
26
|
+
export declare class ExplorerProvider {
|
|
27
|
+
readonly blocks: any;
|
|
28
|
+
readonly transactions: any;
|
|
29
|
+
readonly transactionByOutputRefKey: any;
|
|
30
|
+
readonly addresses: any;
|
|
31
|
+
readonly addressesActive: any;
|
|
32
|
+
readonly infos: any;
|
|
33
|
+
readonly unconfirmedTransactions: any;
|
|
34
|
+
readonly tokens: any;
|
|
35
|
+
readonly charts: any;
|
|
36
|
+
readonly utils: any;
|
|
37
|
+
constructor(baseUrl: string, apiKey?: string);
|
|
38
|
+
constructor(provider: ExplorerProvider);
|
|
39
|
+
constructor(handler: ApiRequestHandler);
|
|
40
|
+
request: (args: ApiRequestArguments) => Promise<any>;
|
|
41
|
+
static Proxy(explorerProvider: ExplorerProvider): ExplorerProvider;
|
|
42
|
+
static Remote(handler: ApiRequestHandler): ExplorerProvider;
|
|
50
43
|
}
|
|
51
44
|
export * as node from './api-alephium';
|
|
52
45
|
export * as explorer from './api-explorer';
|
package/dist/src/api/index.js
CHANGED
|
@@ -43,9 +43,23 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
43
43
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.explorer = exports.node = exports.ExplorerProvider = exports.
|
|
46
|
+
exports.explorer = exports.node = exports.ExplorerProvider = exports.NodeProvider = void 0;
|
|
47
47
|
const api_alephium_1 = require("./api-alephium");
|
|
48
48
|
const api_explorer_1 = require("./api-explorer");
|
|
49
|
+
function forwardRequests(api, handler) {
|
|
50
|
+
// Update class properties to forward requests
|
|
51
|
+
for (const [path, pathObject] of Object.entries(api)) {
|
|
52
|
+
for (const method of Object.keys(pathObject)) {
|
|
53
|
+
pathObject[`${method}`] = async (...params) => {
|
|
54
|
+
return handler({ path, method, params });
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function request(provider, args) {
|
|
60
|
+
const call = provider[`${args.path}`][`${args.method}`];
|
|
61
|
+
return call(...args.params);
|
|
62
|
+
}
|
|
49
63
|
function initializeNodeApi(baseUrl, apiKey) {
|
|
50
64
|
const nodeApi = new api_alephium_1.Api({
|
|
51
65
|
baseUrl: baseUrl,
|
|
@@ -57,10 +71,17 @@ function initializeNodeApi(baseUrl, apiKey) {
|
|
|
57
71
|
}
|
|
58
72
|
class NodeProvider {
|
|
59
73
|
constructor(param0, apiKey) {
|
|
74
|
+
this.request = (args) => {
|
|
75
|
+
return request(this, args);
|
|
76
|
+
};
|
|
60
77
|
let nodeApi;
|
|
61
78
|
if (typeof param0 === 'string') {
|
|
62
79
|
nodeApi = initializeNodeApi(param0, apiKey);
|
|
63
80
|
}
|
|
81
|
+
else if (typeof param0 === 'function') {
|
|
82
|
+
nodeApi = new NodeProvider('https://1.2.3.4:0');
|
|
83
|
+
forwardRequests(nodeApi, param0);
|
|
84
|
+
}
|
|
64
85
|
else {
|
|
65
86
|
nodeApi = param0;
|
|
66
87
|
}
|
|
@@ -79,27 +100,63 @@ class NodeProvider {
|
|
|
79
100
|
static Proxy(nodeProvider) {
|
|
80
101
|
return new NodeProvider(nodeProvider);
|
|
81
102
|
}
|
|
103
|
+
static Remote(handler) {
|
|
104
|
+
return new NodeProvider(handler);
|
|
105
|
+
}
|
|
82
106
|
}
|
|
83
107
|
exports.NodeProvider = NodeProvider;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
function initializeExplorerApi(baseUrl, apiKey) {
|
|
109
|
+
const explorerApi = new api_explorer_1.Api({
|
|
110
|
+
baseUrl: baseUrl,
|
|
111
|
+
baseApiParams: { secure: true },
|
|
112
|
+
securityWorker: (accessToken) => (accessToken !== null ? { headers: { 'X-API-KEY': `${accessToken}` } } : {})
|
|
113
|
+
});
|
|
114
|
+
explorerApi.setSecurityData(apiKey ?? null);
|
|
115
|
+
return explorerApi;
|
|
116
|
+
}
|
|
117
|
+
class ExplorerProvider {
|
|
118
|
+
constructor(param0, apiKey) {
|
|
119
|
+
this.blocks = api_explorer_1.Api['blocks'];
|
|
120
|
+
this.transactions = api_explorer_1.Api['transactions'];
|
|
121
|
+
this.transactionByOutputRefKey = api_explorer_1.Api['transactionByOutputRefKey'];
|
|
122
|
+
this.addresses = api_explorer_1.Api['addresses'];
|
|
123
|
+
this.addressesActive = api_explorer_1.Api['addressesActive'];
|
|
124
|
+
this.infos = api_explorer_1.Api['infos'];
|
|
125
|
+
this.unconfirmedTransactions = api_explorer_1.Api['unconfirmedTransactions'];
|
|
126
|
+
this.tokens = api_explorer_1.Api['tokens'];
|
|
127
|
+
this.charts = api_explorer_1.Api['charts'];
|
|
128
|
+
this.utils = api_explorer_1.Api['utils'];
|
|
129
|
+
this.request = (args) => {
|
|
130
|
+
return request(this, args);
|
|
131
|
+
};
|
|
132
|
+
let explorerApi;
|
|
133
|
+
if (typeof param0 === 'string') {
|
|
134
|
+
explorerApi = initializeExplorerApi(param0, apiKey);
|
|
135
|
+
}
|
|
136
|
+
else if (typeof param0 === 'function') {
|
|
137
|
+
explorerApi = new ExplorerProvider('https://1.2.3.4:0');
|
|
138
|
+
forwardRequests(explorerApi, param0);
|
|
95
139
|
}
|
|
140
|
+
else {
|
|
141
|
+
explorerApi = param0;
|
|
142
|
+
}
|
|
143
|
+
this.blocks = explorerApi.blocks;
|
|
144
|
+
this.transactions = explorerApi.transactions;
|
|
145
|
+
this.transactionByOutputRefKey = explorerApi.transactionByOutputRefKey;
|
|
146
|
+
this.addresses = explorerApi.addresses;
|
|
147
|
+
this.addressesActive = explorerApi.addressesActive;
|
|
148
|
+
this.infos = explorerApi.infos;
|
|
149
|
+
this.unconfirmedTransactions = explorerApi.unconfirmedTransactions;
|
|
150
|
+
this.tokens = explorerApi.tokens;
|
|
151
|
+
this.charts = explorerApi.charts;
|
|
152
|
+
this.utils = explorerApi.utils;
|
|
96
153
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
154
|
+
// This can prevent the proxied explorer provider from being modified
|
|
155
|
+
static Proxy(explorerProvider) {
|
|
156
|
+
return new ExplorerProvider(explorerProvider);
|
|
157
|
+
}
|
|
158
|
+
static Remote(handler) {
|
|
159
|
+
return new ExplorerProvider(handler);
|
|
103
160
|
}
|
|
104
161
|
}
|
|
105
162
|
exports.ExplorerProvider = ExplorerProvider;
|
package/dist/src/api/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as node from './api-alephium';
|
|
2
|
-
export declare type Number256 =
|
|
2
|
+
export declare type Number256 = bigint;
|
|
3
3
|
export declare type Val = Number256 | boolean | string | Val[];
|
|
4
4
|
export declare type NamedVals = Record<string, Val>;
|
|
5
5
|
export interface Token {
|
|
@@ -13,7 +13,7 @@ export declare function fromApiTokens(tokens?: node.Token[]): Token[] | undefine
|
|
|
13
13
|
export declare function toApiBoolean(v: Val): boolean;
|
|
14
14
|
export declare function toApiNumber256(v: Val): string;
|
|
15
15
|
export declare function toApiNumber256Optional(v?: Val): string | undefined;
|
|
16
|
-
export declare function fromApiNumber256(n: string):
|
|
16
|
+
export declare function fromApiNumber256(n: string): bigint;
|
|
17
17
|
export declare function toApiByteVec(v: Val): string;
|
|
18
18
|
export declare function toApiAddress(v: Val): string;
|
|
19
19
|
export declare function toApiArray(tpe: string, v: Val): node.Val;
|
package/dist/src/api/types.js
CHANGED
|
@@ -63,12 +63,7 @@ function toApiNumber256Optional(v) {
|
|
|
63
63
|
}
|
|
64
64
|
exports.toApiNumber256Optional = toApiNumber256Optional;
|
|
65
65
|
function fromApiNumber256(n) {
|
|
66
|
-
|
|
67
|
-
return Number(n);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
return BigInt(n);
|
|
71
|
-
}
|
|
66
|
+
return BigInt(n);
|
|
72
67
|
}
|
|
73
68
|
exports.fromApiNumber256 = fromApiNumber256;
|
|
74
69
|
// TODO: check hex string
|
|
@@ -213,7 +213,7 @@ export interface DeployContractTransaction {
|
|
|
213
213
|
export interface BuildDeployContractTx {
|
|
214
214
|
signerAddress: string;
|
|
215
215
|
initialFields?: Fields;
|
|
216
|
-
initialAttoAlphAmount?:
|
|
216
|
+
initialAttoAlphAmount?: Number256;
|
|
217
217
|
initialTokenAmounts?: Token[];
|
|
218
218
|
issueTokenAmount?: Number256;
|
|
219
219
|
gasAmount?: number;
|
|
@@ -587,11 +587,11 @@ class Contract extends Artifact {
|
|
|
587
587
|
const signerParams = {
|
|
588
588
|
signerAddress: (await signer.getSelectedAccount()).address,
|
|
589
589
|
bytecode: bytecode,
|
|
590
|
-
initialAttoAlphAmount:
|
|
591
|
-
issueTokenAmount:
|
|
592
|
-
initialTokenAmounts:
|
|
590
|
+
initialAttoAlphAmount: params.initialAttoAlphAmount,
|
|
591
|
+
issueTokenAmount: params.issueTokenAmount,
|
|
592
|
+
initialTokenAmounts: params.initialTokenAmounts,
|
|
593
593
|
gasAmount: params.gasAmount,
|
|
594
|
-
gasPrice:
|
|
594
|
+
gasPrice: params.gasPrice
|
|
595
595
|
};
|
|
596
596
|
return signerParams;
|
|
597
597
|
}
|
|
@@ -652,10 +652,10 @@ class Script extends Artifact {
|
|
|
652
652
|
const signerParams = {
|
|
653
653
|
signerAddress: (await signer.getSelectedAccount()).address,
|
|
654
654
|
bytecode: this.buildByteCodeToDeploy(params.initialFields ? params.initialFields : {}),
|
|
655
|
-
attoAlphAmount:
|
|
656
|
-
tokens:
|
|
655
|
+
attoAlphAmount: params.attoAlphAmount,
|
|
656
|
+
tokens: params.tokens,
|
|
657
657
|
gasAmount: params.gasAmount,
|
|
658
|
-
gasPrice:
|
|
658
|
+
gasPrice: params.gasPrice
|
|
659
659
|
};
|
|
660
660
|
return signerParams;
|
|
661
661
|
}
|
|
@@ -668,9 +668,6 @@ class Script extends Artifact {
|
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
exports.Script = Script;
|
|
671
|
-
function extractOptionalNumber256(v) {
|
|
672
|
-
return typeof v !== 'undefined' ? (0, api_1.toApiNumber256)(v) : undefined;
|
|
673
|
-
}
|
|
674
671
|
function fromApiFields(vals, fieldsSig) {
|
|
675
672
|
return (0, api_1.fromApiVals)(vals, fieldsSig.names, fieldsSig.types);
|
|
676
673
|
}
|
package/dist/src/global.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { NodeProvider } from './api';
|
|
1
|
+
import { ExplorerProvider, NodeProvider } from './api';
|
|
2
2
|
export declare function setCurrentNodeProvider(provider: NodeProvider): void;
|
|
3
3
|
export declare function setCurrentNodeProvider(baseUrl: string, apiKey?: string): void;
|
|
4
4
|
export declare function getCurrentNodeProvider(): NodeProvider;
|
|
5
|
+
export declare function setCurrentExplorerProvider(provider: ExplorerProvider): void;
|
|
6
|
+
export declare function setCurrentExplorerProvider(baseUrl: string, apiKey?: string): void;
|
|
7
|
+
export declare function getCurrentExplorerProvider(): ExplorerProvider | undefined;
|
package/dist/src/global.js
CHANGED
|
@@ -17,7 +17,7 @@ You should have received a copy of the GNU Lesser General Public License
|
|
|
17
17
|
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.getCurrentNodeProvider = exports.setCurrentNodeProvider = void 0;
|
|
20
|
+
exports.getCurrentExplorerProvider = exports.setCurrentExplorerProvider = exports.getCurrentNodeProvider = exports.setCurrentNodeProvider = void 0;
|
|
21
21
|
const api_1 = require("./api");
|
|
22
22
|
let _currentNodeProvider = undefined;
|
|
23
23
|
function setCurrentNodeProvider(provider, apiKey) {
|
|
@@ -36,3 +36,19 @@ function getCurrentNodeProvider() {
|
|
|
36
36
|
return _currentNodeProvider;
|
|
37
37
|
}
|
|
38
38
|
exports.getCurrentNodeProvider = getCurrentNodeProvider;
|
|
39
|
+
let _currentExplorerProvider = undefined;
|
|
40
|
+
function setCurrentExplorerProvider(provider, apiKey) {
|
|
41
|
+
if (typeof provider == 'string') {
|
|
42
|
+
_currentExplorerProvider = new api_1.ExplorerProvider(provider, apiKey);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
_currentExplorerProvider = provider;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.setCurrentExplorerProvider = setCurrentExplorerProvider;
|
|
49
|
+
// Different from `NodeProvider`, this may return `undefined`
|
|
50
|
+
// as ExplorerProvider is not necessary for all applications
|
|
51
|
+
function getCurrentExplorerProvider() {
|
|
52
|
+
return _currentExplorerProvider;
|
|
53
|
+
}
|
|
54
|
+
exports.getCurrentExplorerProvider = getCurrentExplorerProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeProvider, Number256, Token } from '../api';
|
|
1
|
+
import { ExplorerProvider, NodeProvider, Number256, Token } from '../api';
|
|
2
2
|
import { node } from '../api';
|
|
3
3
|
export declare type OutputRef = node.OutputRef;
|
|
4
4
|
export interface Account {
|
|
@@ -48,10 +48,10 @@ export interface SignDeployContractTxResult {
|
|
|
48
48
|
export interface SignExecuteScriptTxParams {
|
|
49
49
|
signerAddress: string;
|
|
50
50
|
bytecode: string;
|
|
51
|
-
attoAlphAmount?:
|
|
51
|
+
attoAlphAmount?: Number256;
|
|
52
52
|
tokens?: Token[];
|
|
53
53
|
gasAmount?: number;
|
|
54
|
-
gasPrice?:
|
|
54
|
+
gasPrice?: Number256;
|
|
55
55
|
}
|
|
56
56
|
export interface SignExecuteScriptTxResult {
|
|
57
57
|
fromGroup: number;
|
|
@@ -93,6 +93,7 @@ export interface SubmissionResult {
|
|
|
93
93
|
}
|
|
94
94
|
export interface SignerProvider {
|
|
95
95
|
get nodeProvider(): NodeProvider | undefined;
|
|
96
|
+
get explorerProvider(): ExplorerProvider | undefined;
|
|
96
97
|
getSelectedAccount(): Promise<Account>;
|
|
97
98
|
signAndSubmitTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
|
|
98
99
|
signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
|
|
@@ -103,6 +104,7 @@ export interface SignerProvider {
|
|
|
103
104
|
}
|
|
104
105
|
export declare abstract class SignerProviderSimple implements SignerProvider {
|
|
105
106
|
abstract get nodeProvider(): NodeProvider | undefined;
|
|
107
|
+
abstract get explorerProvider(): ExplorerProvider | undefined;
|
|
106
108
|
abstract getSelectedAccount(): Promise<Account>;
|
|
107
109
|
private getNodeProvider;
|
|
108
110
|
submitTransaction(params: SubmitTransactionParams): Promise<SubmissionResult>;
|
|
@@ -137,7 +137,9 @@ class SignerProviderSimple {
|
|
|
137
137
|
async buildScriptTx(params) {
|
|
138
138
|
const data = {
|
|
139
139
|
...(await this.usePublicKey(params)),
|
|
140
|
-
|
|
140
|
+
attoAlphAmount: (0, api_1.toApiNumber256Optional)(params.attoAlphAmount),
|
|
141
|
+
tokens: (0, api_1.toApiTokens)(params.tokens),
|
|
142
|
+
gasPrice: (0, api_1.toApiNumber256Optional)(params.gasPrice)
|
|
141
143
|
};
|
|
142
144
|
return this.getNodeProvider().contracts.postContractsUnsignedTxExecuteScript(data);
|
|
143
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephium/web3",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.36",
|
|
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,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"author": "Alephium dev <dev@alephium.org>",
|
|
29
29
|
"config": {
|
|
30
|
-
"alephium_version": "1.5.0-
|
|
31
|
-
"explorer_backend_version": "1.9.0-
|
|
30
|
+
"alephium_version": "1.5.0-rc12",
|
|
31
|
+
"explorer_backend_version": "1.9.0-rc2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rm -rf dist/* && npx tsc --build . && webpack",
|
package/src/api/api-explorer.ts
CHANGED
|
@@ -290,7 +290,7 @@ export interface UnconfirmedTransaction {
|
|
|
290
290
|
/** @format int32 */
|
|
291
291
|
chainTo: number
|
|
292
292
|
inputs?: Input[]
|
|
293
|
-
outputs?:
|
|
293
|
+
outputs?: Output[]
|
|
294
294
|
|
|
295
295
|
/** @format int32 */
|
|
296
296
|
gasAmount: number
|
|
@@ -540,7 +540,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
540
540
|
*
|
|
541
541
|
* @tags Blocks
|
|
542
542
|
* @name GetBlocksBlockHash
|
|
543
|
-
* @request GET:/blocks/{
|
|
543
|
+
* @request GET:/blocks/{block_hash}
|
|
544
544
|
*/
|
|
545
545
|
getBlocksBlockHash: (blockHash: string, params: RequestParams = {}) =>
|
|
546
546
|
this.request<BlockEntryLite, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -555,7 +555,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
555
555
|
*
|
|
556
556
|
* @tags Blocks
|
|
557
557
|
* @name GetBlocksBlockHashTransactions
|
|
558
|
-
* @request GET:/blocks/{
|
|
558
|
+
* @request GET:/blocks/{block_hash}/transactions
|
|
559
559
|
*/
|
|
560
560
|
getBlocksBlockHashTransactions: (
|
|
561
561
|
blockHash: string,
|
|
@@ -576,7 +576,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
576
576
|
*
|
|
577
577
|
* @tags Transactions
|
|
578
578
|
* @name GetTransactionsTransactionHash
|
|
579
|
-
* @request GET:/transactions/{
|
|
579
|
+
* @request GET:/transactions/{transaction_hash}
|
|
580
580
|
*/
|
|
581
581
|
getTransactionsTransactionHash: (transactionHash: string, params: RequestParams = {}) =>
|
|
582
582
|
this.request<TransactionLike, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -592,13 +592,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
592
592
|
*
|
|
593
593
|
* @tags Transactions
|
|
594
594
|
* @name GetTransactionByOutputRefKeyOutputRefKey
|
|
595
|
-
* @request GET:/transaction-by-output-ref-key/{
|
|
595
|
+
* @request GET:/transaction-by-output-ref-key/{output_ref_key}
|
|
596
596
|
*/
|
|
597
597
|
getTransactionByOutputRefKeyOutputRefKey: (outputRefKey: string, params: RequestParams = {}) =>
|
|
598
|
-
this.request<
|
|
599
|
-
ConfirmedTransaction,
|
|
600
|
-
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
601
|
-
>({
|
|
598
|
+
this.request<Transaction, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
602
599
|
path: `/transaction-by-output-ref-key/${outputRefKey}`,
|
|
603
600
|
method: 'GET',
|
|
604
601
|
format: 'json',
|
|
@@ -664,10 +661,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
664
661
|
* @request GET:/addresses/{address}/unconfirmed-transactions
|
|
665
662
|
*/
|
|
666
663
|
getAddressesAddressUnconfirmedTransactions: (address: string, params: RequestParams = {}) =>
|
|
667
|
-
this.request<
|
|
668
|
-
UnconfirmedTransaction[],
|
|
669
|
-
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
670
|
-
>({
|
|
664
|
+
this.request<TransactionLike[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
671
665
|
path: `/addresses/${address}/unconfirmed-transactions`,
|
|
672
666
|
method: 'GET',
|
|
673
667
|
format: 'json',
|
|
@@ -709,7 +703,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
709
703
|
*
|
|
710
704
|
* @tags Addresses
|
|
711
705
|
* @name GetAddressesAddressTokensTokenIdTransactions
|
|
712
|
-
* @request GET:/addresses/{address}/tokens/{
|
|
706
|
+
* @request GET:/addresses/{address}/tokens/{token_id}/transactions
|
|
713
707
|
*/
|
|
714
708
|
getAddressesAddressTokensTokenIdTransactions: (
|
|
715
709
|
address: string,
|
|
@@ -730,7 +724,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
730
724
|
*
|
|
731
725
|
* @tags Addresses
|
|
732
726
|
* @name GetAddressesAddressTokensTokenIdBalance
|
|
733
|
-
* @request GET:/addresses/{address}/tokens/{
|
|
727
|
+
* @request GET:/addresses/{address}/tokens/{token_id}/balance
|
|
734
728
|
*/
|
|
735
729
|
getAddressesAddressTokensTokenIdBalance: (address: string, tokenId: string, params: RequestParams = {}) =>
|
|
736
730
|
this.request<AddressBalance, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -904,10 +898,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
904
898
|
query?: { page?: number; limit?: number; reverse?: boolean },
|
|
905
899
|
params: RequestParams = {}
|
|
906
900
|
) =>
|
|
907
|
-
this.request<
|
|
908
|
-
UnconfirmedTransaction[],
|
|
909
|
-
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
910
|
-
>({
|
|
901
|
+
this.request<TransactionLike[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
911
902
|
path: `/unconfirmed-transactions`,
|
|
912
903
|
method: 'GET',
|
|
913
904
|
query: query,
|
|
@@ -937,7 +928,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
937
928
|
*
|
|
938
929
|
* @tags Tokens
|
|
939
930
|
* @name GetTokensTokenIdTransactions
|
|
940
|
-
* @request GET:/tokens/{
|
|
931
|
+
* @request GET:/tokens/{token_id}/transactions
|
|
941
932
|
*/
|
|
942
933
|
getTokensTokenIdTransactions: (
|
|
943
934
|
tokenId: string,
|