dequanto 0.1.99 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/lib/cjs/clients/ClientEventsStream.js +1 -2
  2. package/lib/cjs/clients/ClientEventsStream.js.map +1 -1
  3. package/lib/cjs/clients/handlers/RateLimitGuard.js +2 -0
  4. package/lib/cjs/clients/handlers/RateLimitGuard.js.map +1 -1
  5. package/lib/cjs/contracts/ContractBase.js +5 -2
  6. package/lib/cjs/contracts/ContractBase.js.map +1 -1
  7. package/lib/cjs/contracts/TxContract.js +2 -3
  8. package/lib/cjs/contracts/TxContract.js.map +1 -1
  9. package/lib/cjs/explorer/BlockchainExplorer.js +8 -5
  10. package/lib/cjs/explorer/BlockchainExplorer.js.map +1 -1
  11. package/lib/cjs/explorer/BlockchainExplorerFactory.js +1 -1
  12. package/lib/cjs/explorer/BlockchainExplorerFactory.js.map +1 -1
  13. package/lib/cjs/explorer/ContractVerifier.js +14 -5
  14. package/lib/cjs/explorer/ContractVerifier.js.map +1 -1
  15. package/lib/cjs/explorer/Etherscan.js +62 -4
  16. package/lib/cjs/explorer/Etherscan.js.map +1 -1
  17. package/lib/cjs/explorer/Evmscan.js +1 -4
  18. package/lib/cjs/explorer/Evmscan.js.map +1 -1
  19. package/lib/cjs/gen/GeneratorFromAbi.js +2 -2
  20. package/lib/cjs/gen/GeneratorFromAbi.js.map +1 -1
  21. package/lib/cjs/rpc/transports/RpcTransport.js +1 -1
  22. package/lib/cjs/rpc/transports/RpcTransport.js.map +1 -1
  23. package/lib/esm/clients/ClientEventsStream.js.map +1 -1
  24. package/lib/esm/clients/ClientEventsStream.mjs +1 -2
  25. package/lib/esm/clients/handlers/RateLimitGuard.js.map +1 -1
  26. package/lib/esm/clients/handlers/RateLimitGuard.mjs +2 -0
  27. package/lib/esm/contracts/ContractBase.js.map +1 -1
  28. package/lib/esm/contracts/ContractBase.mjs +5 -2
  29. package/lib/esm/contracts/TxContract.js.map +1 -1
  30. package/lib/esm/contracts/TxContract.mjs +2 -3
  31. package/lib/esm/explorer/BlockchainExplorer.js.map +1 -1
  32. package/lib/esm/explorer/BlockchainExplorer.mjs +8 -5
  33. package/lib/esm/explorer/BlockchainExplorerFactory.js.map +1 -1
  34. package/lib/esm/explorer/BlockchainExplorerFactory.mjs +1 -1
  35. package/lib/esm/explorer/ContractVerifier.js.map +1 -1
  36. package/lib/esm/explorer/ContractVerifier.mjs +14 -5
  37. package/lib/esm/explorer/Etherscan.js.map +1 -1
  38. package/lib/esm/explorer/Etherscan.mjs +62 -4
  39. package/lib/esm/explorer/Evmscan.js.map +1 -1
  40. package/lib/esm/explorer/Evmscan.mjs +1 -3
  41. package/lib/esm/gen/GeneratorFromAbi.js.map +1 -1
  42. package/lib/esm/gen/GeneratorFromAbi.mjs +2 -2
  43. package/lib/esm/rpc/transports/RpcTransport.js.map +1 -1
  44. package/lib/esm/rpc/transports/RpcTransport.mjs +1 -1
  45. package/lib/types/contracts/ContractBase.d.ts +2 -1
  46. package/lib/types/contracts/TxContract.d.ts +1 -1
  47. package/lib/types/explorer/BlockchainExplorerFactory.d.ts +4 -4
  48. package/lib/types/explorer/Etherscan.d.ts +46 -3
  49. package/lib/types/explorer/Evmscan.d.ts +1 -4
  50. package/package.json +2 -2
  51. package/src/clients/ClientEventsStream.ts +1 -2
  52. package/src/clients/handlers/RateLimitGuard.ts +2 -0
  53. package/src/contracts/ContractBase.ts +8 -2
  54. package/src/contracts/TxContract.ts +2 -3
  55. package/src/explorer/BlockchainExplorer.ts +8 -5
  56. package/src/explorer/BlockchainExplorerFactory.ts +6 -6
  57. package/src/explorer/ContractVerifier.ts +16 -5
  58. package/src/explorer/Etherscan.ts +64 -4
  59. package/src/explorer/Evmscan.ts +1 -3
  60. package/src/gen/GeneratorFromAbi.ts +2 -2
  61. package/src/rpc/transports/RpcTransport.ts +1 -1
@@ -1,14 +1,74 @@
1
1
  import di from 'a-di';
2
+ import memd from 'memd';
2
3
  import { $config } from '@dequanto/utils/$config';
3
4
  import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client';
4
5
  import { TPlatform } from '@dequanto/models/TPlatform';
6
+ import { IBlockchainExplorer, IBlockchainTransferEvent } from './IBlockchainExplorer';
5
7
  import { BlockchainExplorer } from './BlockchainExplorer';
8
+ import { IContractDetails } from '@dequanto/models/IContractDetails';
9
+ import { TAddress } from '@dequanto/models/TAddress';
10
+ import { TEth } from '@dequanto/models/TEth';
6
11
 
7
12
  const contracts = $config.get('contracts.eth', [])
8
- export class Etherscan extends BlockchainExplorer {
9
13
 
10
- constructor () {
11
- super({
14
+
15
+ export class Etherscan implements IBlockchainExplorer {
16
+ inMemoryDb: IContractDetails[];
17
+ getContractMeta(q: string) {
18
+ return this.getExplorer().getContractMeta(q);
19
+ }
20
+ getContractCreation(address: TEth.Address) {
21
+ return this.getExplorer().getContractCreation(address);
22
+ }
23
+ getContractAbi(address: TEth.Address, opts?) {
24
+ return this.getExplorer().getContractAbi(address, opts);
25
+ }
26
+ getContractSource(address: TEth.Address) {
27
+ return this.getExplorer().getContractSource(address);
28
+ }
29
+ submitContractVerification(contractData) {
30
+ return this.getExplorer().submitContractVerification(contractData);
31
+ }
32
+ checkContractVerificationSubmission(submission) {
33
+ return this.getExplorer().checkContractVerificationSubmission(submission);
34
+ }
35
+ submitContractProxyVerification(contractData) {
36
+ return this.getExplorer().submitContractProxyVerification(contractData);
37
+ }
38
+ checkContractProxyVerificationSubmission(submission: { guid: any; }): Promise<string> {
39
+ return this.getExplorer().checkContractProxyVerificationSubmission(submission);
40
+ }
41
+ getTransactions(address: TEth.Address, params?) {
42
+ return this.getExplorer().getTransactions(address, params);
43
+ }
44
+ getTransactionsAll(address: TEth.Address) {
45
+ return this.getExplorer().getTransactionsAll(address);
46
+ }
47
+ getInternalTransactions(address: TEth.Address, params) {
48
+ return this.getExplorer().getInternalTransactions(address, params);
49
+ }
50
+ getInternalTransactionsAll(address: TEth.Address): Promise<TEth.TxLike[]> {
51
+ return this.getExplorer().getInternalTransactionsAll(address);
52
+ }
53
+ getErc20Transfers(address: TEth.Address, fromBlockNumber?: number): Promise<IBlockchainTransferEvent[]> {
54
+ return this.getExplorer().getErc20Transfers(address);
55
+ }
56
+ getErc20TransfersAll(address: TEth.Address, fromBlockNumber?: number): Promise<IBlockchainTransferEvent[]> {
57
+ return this.getExplorer().getErc20TransfersAll(address);
58
+ }
59
+ registerAbi(abis: { name: any; address: any; abi: any; }[]) {
60
+ return this.getExplorer().registerAbi(abis);
61
+ }
62
+
63
+
64
+
65
+ @memd.deco.memoize()
66
+ private getExplorer () {
67
+ return new BlockchainExplorer(this.getConfig());
68
+ }
69
+
70
+ private getConfig () {
71
+ return {
12
72
  platform: 'eth',
13
73
  ABI_CACHE: `./cache/eth/abis.json`,
14
74
  CONTRACTS: contracts,
@@ -34,7 +94,7 @@ export class Etherscan extends BlockchainExplorer {
34
94
  www: config?.www,
35
95
  };
36
96
  }
37
- })
97
+ }
38
98
  }
39
99
  }
40
100
 
@@ -5,6 +5,4 @@ import { BlockchainExplorer } from './BlockchainExplorer';
5
5
  /**
6
6
  * @obsolete Use BlockchainExplorer class instead.
7
7
  */
8
- export function Evmscan (options: { platform: TPlatform }) {
9
- return new BlockchainExplorer(options);
10
- }
8
+ export const Evmscan = BlockchainExplorer;
@@ -616,7 +616,7 @@ namespace Gen {
616
616
  ts: `
617
617
  ${overrides}
618
618
  async ${abi.name} (...args): ${fnResult} {
619
- let abi = this.$getAbiItemOverload([ ${sigs} ], args);
619
+ let abi = this.$getAbiItemOverload('${abi.name}', args);
620
620
  return this.$read(abi, ...args);
621
621
  }
622
622
  `,
@@ -626,7 +626,7 @@ namespace Gen {
626
626
  `,
627
627
  js: `
628
628
  async ${abi.name} (...args) {
629
- let abi = this.$getAbiItemOverload([ ${sigs} ], args);
629
+ let abi = this.$getAbiItemOverload('${abi.name}', args);
630
630
  return this.$read(abi, ...args);
631
631
  }
632
632
  `
@@ -27,7 +27,7 @@ export namespace RpcTransport {
27
27
  }
28
28
  if (hasUrl(mix)) {
29
29
  let url = mix.url;
30
- let protocol = /^(?<protocol>\w+):\/\//.exec(url).groups?.protocol;
30
+ let protocol = /^(?<protocol>\w+):\/\//.exec(url)?.groups?.protocol;
31
31
  $require.notEmpty(protocol, `Invalid protocol: ${url}`);
32
32
 
33
33
  let Factory = factories[protocol];