@alephium/web3 0.2.0-rc.35 → 0.2.0-rc.37

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.
@@ -207,7 +207,7 @@ export interface UnconfirmedTransaction {
207
207
  /** @format int32 */
208
208
  chainTo: number;
209
209
  inputs?: Input[];
210
- outputs?: AssetOutput[];
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/{block-hash}
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/{block-hash}/transactions
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/{transaction-hash}
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/{output-ref-key}
332
+ * @request GET:/transaction-by-output-ref-key/{output_ref_key}
333
333
  */
334
- getTransactionByOutputRefKeyOutputRefKey: (outputRefKey: string, params?: RequestParams) => Promise<ConfirmedTransaction>;
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<UnconfirmedTransaction[]>;
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/{token-id}/transactions
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/{token-id}/balance
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<UnconfirmedTransaction[]>;
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/{token-id}/transactions
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/{block-hash}
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/{block-hash}/transactions
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/{transaction-hash}
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/{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/{token-id}/transactions
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/{token-id}/balance
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/{token-id}/transactions
506
+ * @request GET:/tokens/{token_id}/transactions
507
507
  */
508
508
  getTokensTokenIdTransactions: (tokenId, query, params = {}) => this.request({
509
509
  path: `/tokens/${tokenId}/transactions`,
@@ -1,38 +1,11 @@
1
1
  import { Api as NodeApi } from './api-alephium';
2
- import { Api as ExplorerApi } from './api-explorer';
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?: any;
5
+ params: any[];
34
6
  }
35
- export declare class RemoteNodeProvider implements INodeProvider {
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(request: (request: RequestArguments) => Promise<any>);
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 extends ExplorerApi<null> {
49
- constructor(baseUrl: string);
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';
@@ -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.RemoteNodeProvider = exports.NodeProvider = void 0;
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
- class RemoteNodeProvider {
85
- constructor(request) {
86
- const fakeNodeProvide = new NodeProvider('https://1.2.3.4:12973');
87
- Object.assign(this, fakeNodeProvide); // Initialize the class
88
- // Update class properties to forward requests
89
- for (const [path, pathObject] of Object.entries(this)) {
90
- for (const method of Object.keys(pathObject)) {
91
- pathObject[`${method}`] = async (params) => {
92
- return request({ path, method, params });
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
- exports.RemoteNodeProvider = RemoteNodeProvider;
99
- // TODO: use proxy provider once the endpoints are refined.
100
- class ExplorerProvider extends api_explorer_1.Api {
101
- constructor(baseUrl) {
102
- super({ baseUrl: baseUrl });
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;
@@ -1,5 +1,5 @@
1
1
  import { NamedVals, node, Number256, Token, Val } from '../api';
2
- import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerProvider } from '../signer';
2
+ import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerProvider, SignExecuteScriptTxResult, SignDeployContractTxResult } from '../signer';
3
3
  export declare type FieldsSig = node.FieldsSig;
4
4
  export declare type EventSig = node.EventSig;
5
5
  export declare type FunctionSig = node.FunctionSig;
@@ -116,13 +116,13 @@ export declare class Contract extends Artifact {
116
116
  getMethodIndex(funcName: string): number;
117
117
  toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
118
118
  toTestContract(funcName: string, params: TestContractParams): node.TestContract;
119
- fromApiContractState(state: node.ContractState): Promise<ContractState>;
119
+ fromApiContractState(state: node.ContractState): ContractState;
120
120
  static ContractCreatedEvent: EventSig;
121
121
  static ContractDestroyedEvent: EventSig;
122
- static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): Promise<ContractEventByTxId>;
123
- fromTestContractResult(methodIndex: number, result: node.TestContractResult): Promise<TestContractResult>;
122
+ static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): ContractEventByTxId;
123
+ fromTestContractResult(methodIndex: number, result: node.TestContractResult): TestContractResult;
124
124
  txParamsForDeployment(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<SignDeployContractTxParams>;
125
- deploy(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<DeployContractTransaction>;
125
+ deploy(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<SignDeployContractTxResult>;
126
126
  buildByteCodeToDeploy(initialFields: Fields): string;
127
127
  }
128
128
  export declare class Script extends Artifact {
@@ -135,7 +135,7 @@ export declare class Script extends Artifact {
135
135
  static fromArtifactFile(path: string, bytecodeDebugPatch: string): Promise<Script>;
136
136
  toString(): string;
137
137
  txParamsForExecution(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<SignExecuteScriptTxParams>;
138
- execute(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<BuildScriptTxResult>;
138
+ execute(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<SignExecuteScriptTxResult>;
139
139
  buildByteCodeToDeploy(initialFields: Fields): string;
140
140
  }
141
141
  export interface Asset {
@@ -241,7 +241,7 @@ class Project {
241
241
  return fs_2.promises.writeFile(artifactDir, compiled.artifact.toString());
242
242
  };
243
243
  for (const contract of this.contracts) {
244
- await saveToFile(contract);
244
+ saveToFile(contract);
245
245
  }
246
246
  for (const script of this.scripts) {
247
247
  await saveToFile(script);
@@ -526,7 +526,7 @@ class Contract extends Artifact {
526
526
  inputAssets: toApiInputAssets(params.inputAssets)
527
527
  };
528
528
  }
529
- async fromApiContractState(state) {
529
+ fromApiContractState(state) {
530
530
  const contract = Project.currentProject.contractByCodeHash(state.codeHash);
531
531
  return {
532
532
  address: state.address,
@@ -539,7 +539,7 @@ class Contract extends Artifact {
539
539
  asset: fromApiAsset(state.asset)
540
540
  };
541
541
  }
542
- static async fromApiEvent(event, codeHash) {
542
+ static fromApiEvent(event, codeHash) {
543
543
  let eventSig;
544
544
  if (event.eventIndex == -1) {
545
545
  eventSig = this.ContractCreatedEvent;
@@ -558,7 +558,7 @@ class Contract extends Artifact {
558
558
  fields: fromApiEventFields(event.fields, eventSig)
559
559
  };
560
560
  }
561
- async fromTestContractResult(methodIndex, result) {
561
+ fromTestContractResult(methodIndex, result) {
562
562
  const addressToCodeHash = new Map();
563
563
  addressToCodeHash.set(result.address, result.codeHash);
564
564
  result.contracts.forEach((contract) => addressToCodeHash.set(contract.address, contract.codeHash));
@@ -567,9 +567,9 @@ class Contract extends Artifact {
567
567
  contractAddress: result.address,
568
568
  returns: (0, api_1.fromApiArray)(result.returns, this.functions[`${methodIndex}`].returnTypes),
569
569
  gasUsed: result.gasUsed,
570
- contracts: await Promise.all(result.contracts.map((contract) => this.fromApiContractState(contract))),
570
+ contracts: result.contracts.map((contract) => this.fromApiContractState(contract)),
571
571
  txOutputs: result.txOutputs.map(fromApiOutput),
572
- events: await Promise.all(result.events.map((event) => {
572
+ events: result.events.map((event) => {
573
573
  const contractAddress = event.contractAddress;
574
574
  const codeHash = addressToCodeHash.get(contractAddress);
575
575
  if (typeof codeHash !== 'undefined' || event.eventIndex < 0) {
@@ -578,7 +578,7 @@ class Contract extends Artifact {
578
578
  else {
579
579
  throw Error(`Cannot find codeHash for the contract address: ${contractAddress}`);
580
580
  }
581
- })),
581
+ }),
582
582
  debugMessages: result.debugMessages
583
583
  };
584
584
  }
@@ -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;
@@ -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 {
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.2.0-rc.35",
3
+ "version": "0.2.0-rc.37",
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-rc11",
31
- "explorer_backend_version": "1.9.0-rc0"
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",
@@ -290,7 +290,7 @@ export interface UnconfirmedTransaction {
290
290
  /** @format int32 */
291
291
  chainTo: number
292
292
  inputs?: Input[]
293
- outputs?: AssetOutput[]
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/{block-hash}
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/{block-hash}/transactions
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/{transaction-hash}
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/{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/{token-id}/transactions
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/{token-id}/balance
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/{token-id}/transactions
931
+ * @request GET:/tokens/{token_id}/transactions
941
932
  */
942
933
  getTokensTokenIdTransactions: (
943
934
  tokenId: string,