@alephium/web3 0.3.0-rc.5 → 0.3.0-rc.8

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.
@@ -908,7 +908,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
908
908
  }
909
909
  /**
910
910
  * @title Alephium API
911
- * @version 1.6.1
911
+ * @version 1.6.4
912
912
  * @baseUrl ../
913
913
  */
914
914
  export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -149,7 +149,7 @@ class HttpClient {
149
149
  exports.HttpClient = HttpClient;
150
150
  /**
151
151
  * @title Alephium API
152
- * @version 1.6.1
152
+ * @version 1.6.4
153
153
  * @baseUrl ../
154
154
  */
155
155
  class Api extends HttpClient {
@@ -62,6 +62,7 @@ export interface ConfirmedTransaction {
62
62
  gasAmount: number;
63
63
  /** @format uint256 */
64
64
  gasPrice: string;
65
+ coinbase: boolean;
65
66
  type: string;
66
67
  }
67
68
  export interface ContractOutput {
@@ -77,6 +78,17 @@ export interface ContractOutput {
77
78
  spent?: string;
78
79
  type: string;
79
80
  }
81
+ export interface Event {
82
+ /** @format block-hash */
83
+ blockHash: string;
84
+ /** @format 32-byte-hash */
85
+ txHash: string;
86
+ contractAddress: string;
87
+ inputAddress?: string;
88
+ /** @format int32 */
89
+ eventIndex: number;
90
+ fields?: Val[];
91
+ }
80
92
  export interface ExplorerInfo {
81
93
  releaseVersion: string;
82
94
  commit: string;
@@ -101,6 +113,10 @@ export interface Input {
101
113
  export interface InternalServerError {
102
114
  detail: string;
103
115
  }
116
+ export declare enum IntervalType {
117
+ Daily = "daily",
118
+ Hourly = "hourly"
119
+ }
104
120
  export interface ListBlocks {
105
121
  /** @format int32 */
106
122
  total: number;
@@ -196,6 +212,7 @@ export interface Transaction {
196
212
  gasAmount: number;
197
213
  /** @format uint256 */
198
214
  gasPrice: string;
215
+ coinbase: boolean;
199
216
  }
200
217
  export declare type TransactionLike = ConfirmedTransaction | UnconfirmedTransaction;
201
218
  export interface Unauthorized {
@@ -218,6 +235,35 @@ export interface UnconfirmedTransaction {
218
235
  lastSeen: number;
219
236
  type: string;
220
237
  }
238
+ export declare type Val = ValAddress | ValArray | ValBool | ValByteVec | ValI256 | ValU256;
239
+ export interface ValAddress {
240
+ /** @format address */
241
+ value: string;
242
+ type: string;
243
+ }
244
+ export interface ValArray {
245
+ value: Val[];
246
+ type: string;
247
+ }
248
+ export interface ValBool {
249
+ value: boolean;
250
+ type: string;
251
+ }
252
+ export interface ValByteVec {
253
+ /** @format hex-string */
254
+ value: string;
255
+ type: string;
256
+ }
257
+ export interface ValI256 {
258
+ /** @format bigint */
259
+ value: string;
260
+ type: string;
261
+ }
262
+ export interface ValU256 {
263
+ /** @format uint256 */
264
+ value: string;
265
+ type: string;
266
+ }
221
267
  import 'cross-fetch/polyfill';
222
268
  export declare type QueryParamsType = Record<string | number, any>;
223
269
  export declare type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>;
@@ -324,14 +370,6 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
324
370
  * @request GET:/transactions/{transaction_hash}
325
371
  */
326
372
  getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<ConfirmedTransaction | UnconfirmedTransaction>;
327
- /**
328
- * @description Get a transaction from a output reference key
329
- *
330
- * @tags Transactions
331
- * @name GetTransactionsByOutputRefKeyOutputRefKey
332
- * @request GET:/transactions/by/output-ref-key/{output_ref_key}
333
- */
334
- getTransactionsByOutputRefKeyOutputRefKey: (outputRefKey: string, params?: RequestParams) => Promise<Transaction>;
335
373
  };
336
374
  addresses: {
337
375
  /**
@@ -432,6 +470,14 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
432
470
  * @request GET:/addresses/{address}/tokens/{token_id}/balance
433
471
  */
434
472
  getAddressesAddressTokensTokenIdBalance: (address: string, tokenId: string, params?: RequestParams) => Promise<AddressBalance>;
473
+ /**
474
+ * @description Are the addresses used (at least 1 transaction)
475
+ *
476
+ * @tags Addresses, Addresses
477
+ * @name PostAddressesUsed
478
+ * @request POST:/addresses/used
479
+ */
480
+ postAddressesUsed: (data?: string[], params?: RequestParams) => Promise<boolean[]>;
435
481
  /**
436
482
  * No description
437
483
  *
@@ -444,16 +490,6 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
444
490
  toTs: number;
445
491
  }, params?: RequestParams) => Promise<string>;
446
492
  };
447
- addressesActive: {
448
- /**
449
- * @description Are the addresses active (at least 1 transaction)
450
- *
451
- * @tags Addresses
452
- * @name PostAddressesActive
453
- * @request POST:/addresses-active
454
- */
455
- postAddressesActive: (data?: string[], params?: RequestParams) => Promise<boolean[]>;
456
- };
457
493
  infos: {
458
494
  /**
459
495
  * @description Get explorer informations
@@ -584,7 +620,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
584
620
  getChartsHashrates: (query: {
585
621
  fromTs: number;
586
622
  toTs: number;
587
- 'interval-type': string;
623
+ 'interval-type': IntervalType;
588
624
  }, params?: RequestParams) => Promise<Hashrate[]>;
589
625
  /**
590
626
  * @description `interval-type` query param: hourly, daily
@@ -597,7 +633,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
597
633
  getChartsTransactionsCount: (query: {
598
634
  fromTs: number;
599
635
  toTs: number;
600
- 'interval-type': string;
636
+ 'interval-type': IntervalType;
601
637
  }, params?: RequestParams) => Promise<TimedCount[]>;
602
638
  /**
603
639
  * @description `interval-type` query param: hourly, daily
@@ -610,9 +646,43 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
610
646
  getChartsTransactionsCountPerChain: (query: {
611
647
  fromTs: number;
612
648
  toTs: number;
613
- 'interval-type': string;
649
+ 'interval-type': IntervalType;
614
650
  }, params?: RequestParams) => Promise<PerChainTimedCount[]>;
615
651
  };
652
+ contractEvents: {
653
+ /**
654
+ * @description Get contract events by transaction id
655
+ *
656
+ * @tags Contract events
657
+ * @name GetContractEventsTransactionIdTransactionId
658
+ * @request GET:/contract-events/transaction-id/{transaction_id}
659
+ */
660
+ getContractEventsTransactionIdTransactionId: (transactionId: string, params?: RequestParams) => Promise<Event[]>;
661
+ /**
662
+ * @description Get contract events by contract address
663
+ *
664
+ * @tags Contract events
665
+ * @name GetContractEventsContractAddressContractAddress
666
+ * @request GET:/contract-events/contract-address/{contract_address}
667
+ */
668
+ getContractEventsContractAddressContractAddress: (contractAddress: string, query?: {
669
+ page?: number;
670
+ limit?: number;
671
+ reverse?: boolean;
672
+ }, params?: RequestParams) => Promise<Event[]>;
673
+ /**
674
+ * @description Get contract events by contract and input addresses
675
+ *
676
+ * @tags Contract events
677
+ * @name GetContractEventsContractAddressContractAddressInputAddressInputAddress
678
+ * @request GET:/contract-events/contract-address/{contract_address}/input-address/{input_address}
679
+ */
680
+ getContractEventsContractAddressContractAddressInputAddressInputAddress: (contractAddress: string, inputAddress: string, query?: {
681
+ page?: number;
682
+ limit?: number;
683
+ reverse?: boolean;
684
+ }, params?: RequestParams) => Promise<Event[]>;
685
+ };
616
686
  utils: {
617
687
  /**
618
688
  * @description Perform a sanity check
@@ -10,7 +10,12 @@
10
10
  * ---------------------------------------------------------------
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Api = exports.HttpClient = exports.ContentType = void 0;
13
+ exports.Api = exports.HttpClient = exports.ContentType = exports.IntervalType = void 0;
14
+ var IntervalType;
15
+ (function (IntervalType) {
16
+ IntervalType["Daily"] = "daily";
17
+ IntervalType["Hourly"] = "hourly";
18
+ })(IntervalType = exports.IntervalType || (exports.IntervalType = {}));
14
19
  require("cross-fetch/polyfill");
15
20
  const utils_1 = require("./utils");
16
21
  var ContentType;
@@ -210,19 +215,6 @@ class Api extends HttpClient {
210
215
  method: 'GET',
211
216
  format: 'json',
212
217
  ...params
213
- }).then(utils_1.convertHttpResponse),
214
- /**
215
- * @description Get a transaction from a output reference key
216
- *
217
- * @tags Transactions
218
- * @name GetTransactionsByOutputRefKeyOutputRefKey
219
- * @request GET:/transactions/by/output-ref-key/{output_ref_key}
220
- */
221
- getTransactionsByOutputRefKeyOutputRefKey: (outputRefKey, params = {}) => this.request({
222
- path: `/transactions/by/output-ref-key/${outputRefKey}`,
223
- method: 'GET',
224
- format: 'json',
225
- ...params
226
218
  }).then(utils_1.convertHttpResponse)
227
219
  };
228
220
  this.addresses = {
@@ -362,6 +354,21 @@ class Api extends HttpClient {
362
354
  format: 'json',
363
355
  ...params
364
356
  }).then(utils_1.convertHttpResponse),
357
+ /**
358
+ * @description Are the addresses used (at least 1 transaction)
359
+ *
360
+ * @tags Addresses, Addresses
361
+ * @name PostAddressesUsed
362
+ * @request POST:/addresses/used
363
+ */
364
+ postAddressesUsed: (data, params = {}) => this.request({
365
+ path: `/addresses/used`,
366
+ method: 'POST',
367
+ body: data,
368
+ type: ContentType.Json,
369
+ format: 'json',
370
+ ...params
371
+ }).then(utils_1.convertHttpResponse),
365
372
  /**
366
373
  * No description
367
374
  *
@@ -376,23 +383,6 @@ class Api extends HttpClient {
376
383
  ...params
377
384
  }).then(utils_1.convertHttpResponse)
378
385
  };
379
- this.addressesActive = {
380
- /**
381
- * @description Are the addresses active (at least 1 transaction)
382
- *
383
- * @tags Addresses
384
- * @name PostAddressesActive
385
- * @request POST:/addresses-active
386
- */
387
- postAddressesActive: (data, params = {}) => this.request({
388
- path: `/addresses-active`,
389
- method: 'POST',
390
- body: data,
391
- type: ContentType.Json,
392
- format: 'json',
393
- ...params
394
- }).then(utils_1.convertHttpResponse)
395
- };
396
386
  this.infos = {
397
387
  /**
398
388
  * @description Get explorer informations
@@ -601,6 +591,49 @@ class Api extends HttpClient {
601
591
  ...params
602
592
  }).then(utils_1.convertHttpResponse)
603
593
  };
594
+ this.contractEvents = {
595
+ /**
596
+ * @description Get contract events by transaction id
597
+ *
598
+ * @tags Contract events
599
+ * @name GetContractEventsTransactionIdTransactionId
600
+ * @request GET:/contract-events/transaction-id/{transaction_id}
601
+ */
602
+ getContractEventsTransactionIdTransactionId: (transactionId, params = {}) => this.request({
603
+ path: `/contract-events/transaction-id/${transactionId}`,
604
+ method: 'GET',
605
+ format: 'json',
606
+ ...params
607
+ }).then(utils_1.convertHttpResponse),
608
+ /**
609
+ * @description Get contract events by contract address
610
+ *
611
+ * @tags Contract events
612
+ * @name GetContractEventsContractAddressContractAddress
613
+ * @request GET:/contract-events/contract-address/{contract_address}
614
+ */
615
+ getContractEventsContractAddressContractAddress: (contractAddress, query, params = {}) => this.request({
616
+ path: `/contract-events/contract-address/${contractAddress}`,
617
+ method: 'GET',
618
+ query: query,
619
+ format: 'json',
620
+ ...params
621
+ }).then(utils_1.convertHttpResponse),
622
+ /**
623
+ * @description Get contract events by contract and input addresses
624
+ *
625
+ * @tags Contract events
626
+ * @name GetContractEventsContractAddressContractAddressInputAddressInputAddress
627
+ * @request GET:/contract-events/contract-address/{contract_address}/input-address/{input_address}
628
+ */
629
+ getContractEventsContractAddressContractAddressInputAddressInputAddress: (contractAddress, inputAddress, query, params = {}) => this.request({
630
+ path: `/contract-events/contract-address/${contractAddress}/input-address/${inputAddress}`,
631
+ method: 'GET',
632
+ query: query,
633
+ format: 'json',
634
+ ...params
635
+ }).then(utils_1.convertHttpResponse)
636
+ };
604
637
  this.utils = {
605
638
  /**
606
639
  * @description Perform a sanity check
@@ -27,7 +27,6 @@ export declare class ExplorerProvider {
27
27
  readonly blocks: any;
28
28
  readonly transactions: any;
29
29
  readonly addresses: any;
30
- readonly addressesActive: any;
31
30
  readonly infos: any;
32
31
  readonly unconfirmedTransactions: any;
33
32
  readonly tokens: any;
@@ -119,7 +119,6 @@ class ExplorerProvider {
119
119
  this.blocks = api_explorer_1.Api['blocks'];
120
120
  this.transactions = api_explorer_1.Api['transactions'];
121
121
  this.addresses = api_explorer_1.Api['addresses'];
122
- this.addressesActive = api_explorer_1.Api['addressesActive'];
123
122
  this.infos = api_explorer_1.Api['infos'];
124
123
  this.unconfirmedTransactions = api_explorer_1.Api['unconfirmedTransactions'];
125
124
  this.tokens = api_explorer_1.Api['tokens'];
@@ -142,7 +141,6 @@ 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 };
@@ -27,9 +27,10 @@ declare class SourceInfo {
27
27
  contractRelativePath: string;
28
28
  sourceCode: string;
29
29
  sourceCodeHash: string;
30
+ isExternal: boolean;
30
31
  getArtifactPath(artifactsRootDir: string): string;
31
- constructor(type: SourceKind, name: string, sourceCode: string, sourceCodeHash: string, contractRelativePath: string);
32
- static from(type: SourceKind, name: string, sourceCode: string, contractRelativePath: string): Promise<SourceInfo>;
32
+ constructor(type: SourceKind, name: string, sourceCode: string, sourceCodeHash: string, contractRelativePath: string, isExternal: boolean);
33
+ static from(type: SourceKind, name: string, sourceCode: string, contractRelativePath: string, isExternal: boolean): Promise<SourceInfo>;
33
34
  }
34
35
  declare class Compiled<T extends Artifact> {
35
36
  sourceInfo: SourceInfo;
@@ -62,6 +63,7 @@ export declare class Project {
62
63
  readonly contractsRootDir: string;
63
64
  readonly artifactsRootDir: string;
64
65
  static currentProject: Project;
66
+ static readonly importRegex: RegExp;
65
67
  static readonly abstractContractMatcher: TypedMatcher<SourceKind>;
66
68
  static readonly contractMatcher: TypedMatcher<SourceKind.Contract>;
67
69
  static readonly interfaceMatcher: TypedMatcher<SourceKind.Interface>;
@@ -76,11 +78,13 @@ export declare class Project {
76
78
  contractByCodeHash(codeHash: string): Contract;
77
79
  private static compile;
78
80
  private static loadArtifacts;
81
+ private static getImportSourcePath;
82
+ private static handleImports;
79
83
  private static loadSourceFile;
80
84
  private static loadSourceFiles;
81
85
  static readonly DEFAULT_CONTRACTS_DIR = "contracts";
82
86
  static readonly DEFAULT_ARTIFACTS_DIR = "artifacts";
83
- static build(compilerOptionsPartial?: Partial<CompilerOptions>, contractsRootDir?: string, artifactsRootDir?: string): Promise<void>;
87
+ static build(compilerOptionsPartial?: Partial<CompilerOptions>, projectRootDir?: string, contractsRootDir?: string, artifactsRootDir?: string): Promise<void>;
84
88
  }
85
89
  export declare abstract class Artifact {
86
90
  readonly version: string;
@@ -76,20 +76,39 @@ class TypedMatcher {
76
76
  this.type = type;
77
77
  }
78
78
  }
79
+ function removeParentsPrefix(parts) {
80
+ let index = 0;
81
+ for (let i = 0; i < parts.length; i++) {
82
+ if (parts[`${i}`] === '..') {
83
+ index += 1;
84
+ }
85
+ else {
86
+ break;
87
+ }
88
+ }
89
+ return path.join(...parts.slice(index));
90
+ }
79
91
  class SourceInfo {
80
- constructor(type, name, sourceCode, sourceCodeHash, contractRelativePath) {
92
+ constructor(type, name, sourceCode, sourceCodeHash, contractRelativePath, isExternal) {
81
93
  this.type = type;
82
94
  this.name = name;
83
95
  this.sourceCode = sourceCode;
84
96
  this.sourceCodeHash = sourceCodeHash;
85
97
  this.contractRelativePath = contractRelativePath;
98
+ this.isExternal = isExternal;
86
99
  }
87
100
  getArtifactPath(artifactsRootDir) {
101
+ if (this.isExternal) {
102
+ const relativePath = removeParentsPrefix(this.contractRelativePath.split(path.sep));
103
+ const externalPath = path.join('.external', relativePath);
104
+ return path.join(artifactsRootDir, externalPath) + '.json';
105
+ }
88
106
  return path.join(artifactsRootDir, this.contractRelativePath) + '.json';
89
107
  }
90
- static async from(type, name, sourceCode, contractRelativePath) {
108
+ static async from(type, name, sourceCode, contractRelativePath, isExternal) {
91
109
  const sourceCodeHash = await crypto_1.webcrypto.subtle.digest('SHA-256', buffer_1.Buffer.from(sourceCode));
92
- return new SourceInfo(type, name, sourceCode, buffer_1.Buffer.from(sourceCodeHash).toString('hex'), contractRelativePath);
110
+ const sourceCodeHashHex = buffer_1.Buffer.from(sourceCodeHash).toString('hex');
111
+ return new SourceInfo(type, name, sourceCode, sourceCodeHashHex, contractRelativePath, isExternal);
93
112
  }
94
113
  }
95
114
  class Compiled {
@@ -301,49 +320,91 @@ class Project {
301
320
  return Project.compile(provider, sourceInfos, contractsRootDir, artifactsRootDir, errorOnWarnings, compilerOptions);
302
321
  }
303
322
  }
304
- static async loadSourceFile(contractsRootDir, dirPath, filename) {
305
- const contractPath = path.join(dirPath, filename);
306
- const contractRelativePath = path.relative(contractsRootDir, contractPath);
307
- if (!filename.endsWith('.ral')) {
308
- throw new Error(`Invalid filename: ${contractPath}, smart contract file name should end with ".ral"`);
323
+ static getImportSourcePath(projectRootDir, importPath) {
324
+ const parts = importPath.split(path.sep);
325
+ if (parts.length > 1 && parts[0] === 'std') {
326
+ const currentDir = path.dirname(__filename);
327
+ return path.join(...[currentDir, '..', '..', '..', importPath]);
309
328
  }
310
- const sourceBuffer = await fs_2.promises.readFile(contractPath);
311
- const sourceStr = sourceBuffer.toString();
312
- const sourceInfos = [];
329
+ let moduleDir = projectRootDir;
330
+ while (true) {
331
+ const expectedPath = path.join(...[moduleDir, 'node_modules', importPath]);
332
+ if (fs_1.default.existsSync(expectedPath)) {
333
+ return expectedPath;
334
+ }
335
+ const oldModuleDir = moduleDir;
336
+ moduleDir = path.join(moduleDir, '..');
337
+ if (oldModuleDir === moduleDir) {
338
+ throw new Error(`Specified import file does not exist: ${importPath}`);
339
+ }
340
+ }
341
+ }
342
+ static async handleImports(projectRootDir, contractRootDir, sourceStr, importsCache) {
343
+ const localImportsCache = [];
344
+ const result = sourceStr.replace(Project.importRegex, (match) => {
345
+ localImportsCache.push(match);
346
+ return '';
347
+ });
348
+ const externalSourceInfos = [];
349
+ for (const myImport of localImportsCache) {
350
+ const originImportPath = myImport.slice(8, -1);
351
+ const importPath = originImportPath.endsWith('.ral') ? originImportPath : originImportPath + '.ral';
352
+ if (!importsCache.includes(importPath)) {
353
+ importsCache.push(importPath);
354
+ const sourcePath = Project.getImportSourcePath(projectRootDir, importPath);
355
+ const sourceInfos = await Project.loadSourceFile(projectRootDir, contractRootDir, sourcePath, importsCache, true);
356
+ externalSourceInfos.push(...sourceInfos);
357
+ }
358
+ }
359
+ return [result, externalSourceInfos];
360
+ }
361
+ static async loadSourceFile(projectRootDir, contractsRootDir, sourcePath, importsCache, isExternal) {
362
+ const contractRelativePath = path.relative(contractsRootDir, sourcePath);
363
+ if (!sourcePath.endsWith('.ral')) {
364
+ throw new Error(`Invalid filename: ${sourcePath}, smart contract file name should end with ".ral"`);
365
+ }
366
+ const sourceBuffer = await fs_2.promises.readFile(sourcePath);
367
+ const [sourceStr, externalSourceInfos] = await Project.handleImports(projectRootDir, contractsRootDir, sourceBuffer.toString(), importsCache);
368
+ if (sourceStr.match(new RegExp('^import "', 'mg')) !== null) {
369
+ throw new Error(`Invalid import statements, source: ${sourcePath}`);
370
+ }
371
+ const sourceInfos = externalSourceInfos;
313
372
  for (const matcher of this.matchers) {
314
373
  const results = sourceStr.matchAll(matcher.matcher);
315
374
  for (const result of results) {
316
- const sourceInfo = await SourceInfo.from(matcher.type, result[1], sourceStr, contractRelativePath);
375
+ const sourceInfo = await SourceInfo.from(matcher.type, result[1], sourceStr, contractRelativePath, isExternal);
317
376
  sourceInfos.push(sourceInfo);
318
377
  }
319
378
  }
320
379
  return sourceInfos;
321
380
  }
322
- static async loadSourceFiles(contractsRootDir) {
323
- const loadDir = async function (dirPath, results) {
381
+ static async loadSourceFiles(projectRootDir, contractsRootDir) {
382
+ const importsCache = [];
383
+ const sourceInfos = [];
384
+ const loadDir = async function (dirPath) {
324
385
  const dirents = await fs_2.promises.readdir(dirPath, { withFileTypes: true });
325
386
  for (const dirent of dirents) {
326
387
  if (dirent.isFile()) {
327
- const sourceInfos = await Project.loadSourceFile(contractsRootDir, dirPath, dirent.name);
328
- results.push(...sourceInfos);
388
+ const sourcePath = path.join(dirPath, dirent.name);
389
+ const infos = await Project.loadSourceFile(projectRootDir, contractsRootDir, sourcePath, importsCache, false);
390
+ sourceInfos.push(...infos);
329
391
  }
330
392
  else {
331
393
  const newPath = path.join(dirPath, dirent.name);
332
- await loadDir(newPath, results);
394
+ await loadDir(newPath);
333
395
  }
334
396
  }
335
397
  };
336
- const sourceInfos = [];
337
- await loadDir(contractsRootDir, sourceInfos);
398
+ await loadDir(contractsRootDir);
338
399
  const contractAndScriptSize = sourceInfos.filter((f) => f.type === SourceKind.Contract || f.type === SourceKind.Script).length;
339
400
  if (sourceInfos.length === 0 || contractAndScriptSize === 0) {
340
401
  throw new Error('Project have no source files');
341
402
  }
342
403
  return sourceInfos.sort((a, b) => a.type - b.type);
343
404
  }
344
- static async build(compilerOptionsPartial = {}, contractsRootDir = Project.DEFAULT_CONTRACTS_DIR, artifactsRootDir = Project.DEFAULT_ARTIFACTS_DIR) {
405
+ static async build(compilerOptionsPartial = {}, projectRootDir = '.', contractsRootDir = Project.DEFAULT_CONTRACTS_DIR, artifactsRootDir = Project.DEFAULT_ARTIFACTS_DIR) {
345
406
  const provider = (0, global_1.getCurrentNodeProvider)();
346
- const sourceFiles = await Project.loadSourceFiles(contractsRootDir);
407
+ const sourceFiles = await Project.loadSourceFiles(projectRootDir, contractsRootDir);
347
408
  const { errorOnWarnings, ...nodeCompilerOptions } = { ...exports.DEFAULT_COMPILER_OPTIONS, ...compilerOptionsPartial };
348
409
  const projectArtifact = await ProjectArtifact.from(artifactsRootDir);
349
410
  if (typeof projectArtifact === 'undefined' || projectArtifact.needToReCompile(nodeCompilerOptions, sourceFiles)) {
@@ -357,9 +418,10 @@ class Project {
357
418
  }
358
419
  }
359
420
  exports.Project = Project;
421
+ Project.importRegex = new RegExp('^import "[^"./]+/[^"]*[a-z][a-z_0-9]*(.ral)?"', 'mg');
360
422
  Project.abstractContractMatcher = new TypedMatcher('^Abstract Contract ([A-Z][a-zA-Z0-9]*)', SourceKind.AbstractContract);
361
423
  Project.contractMatcher = new TypedMatcher('^Contract ([A-Z][a-zA-Z0-9]*)', SourceKind.Contract);
362
- Project.interfaceMatcher = new TypedMatcher('^Interface ([A-Z][a-zA-Z0-9]*) \\{', SourceKind.Interface);
424
+ Project.interfaceMatcher = new TypedMatcher('^Interface ([A-Z][a-zA-Z0-9]*)', SourceKind.Interface);
363
425
  Project.scriptMatcher = new TypedMatcher('^TxScript ([A-Z][a-zA-Z0-9]*)', SourceKind.Script);
364
426
  Project.matchers = [
365
427
  Project.abstractContractMatcher,
@@ -1,2 +1,3 @@
1
1
  export * from './signer';
2
2
  export * from './types';
3
+ export * from './tx-builder';
@@ -33,3 +33,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  __exportStar(require("./signer"), exports);
35
35
  __exportStar(require("./types"), exports);
36
+ __exportStar(require("./tx-builder"), exports);
@@ -1,6 +1,7 @@
1
1
  import { ExplorerProvider, NodeProvider } from '../api';
2
2
  import { node } from '../api';
3
- import { Account, Address, EnableOptionsBase, Destination, SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignMessageParams, SignMessageResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult, SubmissionResult, SubmitTransactionParams } from './types';
3
+ import { Account, Address, EnableOptionsBase, Destination, SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignMessageParams, SignMessageResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult, SubmissionResult, SubmitTransactionParams, ExtSignTransferTxParams, ExtSignDeployContractTxParams, ExtSignExecuteScriptTxParams, ExtSignUnsignedTxParams, ExtSignMessageParams } from './types';
4
+ import { TransactionBuilder } from './tx-builder';
4
5
  export interface SignerProvider {
5
6
  get nodeProvider(): NodeProvider | undefined;
6
7
  get explorerProvider(): ExplorerProvider | undefined;
@@ -13,15 +14,19 @@ export interface SignerProvider {
13
14
  signMessage(params: SignMessageParams): Promise<SignMessageResult>;
14
15
  }
15
16
  export interface InteractiveSignerProvider<EnableOptions extends EnableOptionsBase = EnableOptionsBase> extends SignerProvider {
16
- enable(opt?: EnableOptions): Promise<void>;
17
+ enable(opt?: EnableOptions): Promise<Address>;
17
18
  disconnect(): Promise<void>;
19
+ signAndSubmitTransferTx(params: ExtSignTransferTxParams): Promise<SignTransferTxResult>;
20
+ signAndSubmitDeployContractTx(params: ExtSignDeployContractTxParams): Promise<SignDeployContractTxResult>;
21
+ signAndSubmitExecuteScriptTx(params: ExtSignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
22
+ signAndSubmitUnsignedTx(params: ExtSignUnsignedTxParams): Promise<SignUnsignedTxResult>;
23
+ signUnsignedTx(params: ExtSignUnsignedTxParams): Promise<SignUnsignedTxResult>;
24
+ signMessage(params: ExtSignMessageParams): Promise<SignMessageResult>;
18
25
  }
19
- export declare abstract class SignerProviderSimple implements SignerProvider {
20
- abstract get nodeProvider(): NodeProvider | undefined;
26
+ export declare abstract class SignerProviderSimple extends TransactionBuilder implements SignerProvider {
21
27
  abstract get explorerProvider(): ExplorerProvider | undefined;
22
28
  abstract getSelectedAccount(): Promise<Account>;
23
29
  getSelectedAddress(): Promise<Address>;
24
- private getNodeProvider;
25
30
  submitTransaction(params: SubmitTransactionParams): Promise<SubmissionResult>;
26
31
  signAndSubmitTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
27
32
  signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
@@ -30,11 +35,11 @@ export declare abstract class SignerProviderSimple implements SignerProvider {
30
35
  protected abstract getPublicKey(address: string): Promise<string>;
31
36
  private usePublicKey;
32
37
  signTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
33
- buildTransferTx(params: SignTransferTxParams): Promise<node.BuildTransactionResult>;
38
+ buildTransferTx(params: SignTransferTxParams): Promise<Omit<SignTransferTxResult, 'signature'>>;
34
39
  signDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
35
- buildContractCreationTx(params: SignDeployContractTxParams): Promise<node.BuildDeployContractTxResult>;
40
+ buildDeployContractTx(params: SignDeployContractTxParams): Promise<Omit<SignDeployContractTxResult, 'signature'>>;
36
41
  signExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
37
- buildScriptTx(params: SignExecuteScriptTxParams): Promise<node.BuildExecuteScriptTxResult>;
42
+ buildExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<Omit<SignExecuteScriptTxResult, 'signature'>>;
38
43
  signUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
39
44
  signMessage(params: SignMessageParams): Promise<SignMessageResult>;
40
45
  abstract signRaw(signerAddress: string, hexString: string): Promise<string>;