@airgap/ethereum 0.13.7-beta.11

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 (67) hide show
  1. package/LICENSE.md +7 -0
  2. package/airgap-coinlib-ethereum.min.js +106148 -0
  3. package/index.d.ts +12 -0
  4. package/index.js +24 -0
  5. package/index.js.map +1 -0
  6. package/package.json +67 -0
  7. package/protocol/BaseEthereumProtocol.d.ts +98 -0
  8. package/protocol/BaseEthereumProtocol.js +933 -0
  9. package/protocol/BaseEthereumProtocol.js.map +1 -0
  10. package/protocol/EthereumAddress.d.ts +8 -0
  11. package/protocol/EthereumAddress.js +38 -0
  12. package/protocol/EthereumAddress.js.map +1 -0
  13. package/protocol/EthereumChainIDs.d.ts +1 -0
  14. package/protocol/EthereumChainIDs.js +340 -0
  15. package/protocol/EthereumChainIDs.js.map +1 -0
  16. package/protocol/EthereumClassicProtocol.d.ts +6 -0
  17. package/protocol/EthereumClassicProtocol.js +28 -0
  18. package/protocol/EthereumClassicProtocol.js.map +1 -0
  19. package/protocol/EthereumCryptoClient.d.ts +12 -0
  20. package/protocol/EthereumCryptoClient.js +141 -0
  21. package/protocol/EthereumCryptoClient.js.map +1 -0
  22. package/protocol/EthereumProtocol.d.ts +10 -0
  23. package/protocol/EthereumProtocol.js +32 -0
  24. package/protocol/EthereumProtocol.js.map +1 -0
  25. package/protocol/EthereumProtocolOptions.d.ts +46 -0
  26. package/protocol/EthereumProtocolOptions.js +148 -0
  27. package/protocol/EthereumProtocolOptions.js.map +1 -0
  28. package/protocol/EthereumRopstenProtocol.d.ts +6 -0
  29. package/protocol/EthereumRopstenProtocol.js +28 -0
  30. package/protocol/EthereumRopstenProtocol.js.map +1 -0
  31. package/protocol/EthereumTypes.d.ts +14 -0
  32. package/protocol/EthereumTypes.js +3 -0
  33. package/protocol/EthereumTypes.js.map +1 -0
  34. package/protocol/clients/info-clients/EtherscanInfoClient.d.ts +8 -0
  35. package/protocol/clients/info-clients/EtherscanInfoClient.js +193 -0
  36. package/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -0
  37. package/protocol/clients/info-clients/InfoClient.d.ts +8 -0
  38. package/protocol/clients/info-clients/InfoClient.js +11 -0
  39. package/protocol/clients/info-clients/InfoClient.js.map +1 -0
  40. package/protocol/clients/node-clients/AirGapNodeClient.d.ts +41 -0
  41. package/protocol/clients/node-clients/AirGapNodeClient.js +351 -0
  42. package/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -0
  43. package/protocol/clients/node-clients/NodeClient.d.ts +17 -0
  44. package/protocol/clients/node-clients/NodeClient.js +11 -0
  45. package/protocol/clients/node-clients/NodeClient.js.map +1 -0
  46. package/protocol/erc20/ERC20.d.ts +3 -0
  47. package/protocol/erc20/ERC20.js +9 -0
  48. package/protocol/erc20/ERC20.js.map +1 -0
  49. package/protocol/erc20/GenericERC20.d.ts +32 -0
  50. package/protocol/erc20/GenericERC20.js +328 -0
  51. package/protocol/erc20/GenericERC20.js.map +1 -0
  52. package/protocol/utils/utils.d.ts +13 -0
  53. package/protocol/utils/utils.js +140 -0
  54. package/protocol/utils/utils.js.map +1 -0
  55. package/readme.md +121 -0
  56. package/types/signed-transaction-ethereum.d.ts +5 -0
  57. package/types/signed-transaction-ethereum.js +3 -0
  58. package/types/signed-transaction-ethereum.js.map +1 -0
  59. package/types/transaction-ethereum.d.ts +14 -0
  60. package/types/transaction-ethereum.js +3 -0
  61. package/types/transaction-ethereum.js.map +1 -0
  62. package/types/unsigned-transaction-ethereum-typed.d.ts +10 -0
  63. package/types/unsigned-transaction-ethereum-typed.js +3 -0
  64. package/types/unsigned-transaction-ethereum-typed.js.map +1 -0
  65. package/types/unsigned-transaction-ethereum.d.ts +14 -0
  66. package/types/unsigned-transaction-ethereum.js +3 -0
  67. package/types/unsigned-transaction-ethereum.js.map +1 -0
package/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { GenericERC20 } from './protocol/erc20/GenericERC20';
2
+ import { EthereumAddress } from './protocol/EthereumAddress';
3
+ import { EthereumClassicProtocol } from './protocol/EthereumClassicProtocol';
4
+ import { EthereumCryptoClient } from './protocol/EthereumCryptoClient';
5
+ import { EthereumProtocol } from './protocol/EthereumProtocol';
6
+ import { EthereumERC20ProtocolConfig, EthereumERC20ProtocolOptions, EthereumProtocolConfig, EthereumProtocolNetwork, EthereumProtocolNetworkExtras, EthereumProtocolOptions, EtherscanBlockExplorer } from './protocol/EthereumProtocolOptions';
7
+ import { EthereumRopstenProtocol } from './protocol/EthereumRopstenProtocol';
8
+ import { SignedEthereumTransaction } from './types/signed-transaction-ethereum';
9
+ import { RawEthereumTransaction } from './types/transaction-ethereum';
10
+ import { UnsignedEthereumTransaction } from './types/unsigned-transaction-ethereum';
11
+ import { UnsignedTypedEthereumTransaction } from './types/unsigned-transaction-ethereum-typed';
12
+ export { EthereumProtocol, EthereumRopstenProtocol, EthereumClassicProtocol, GenericERC20, EthereumCryptoClient, EthereumProtocolNetworkExtras, EtherscanBlockExplorer, EthereumProtocolNetwork, EthereumProtocolConfig, EthereumProtocolOptions, EthereumERC20ProtocolConfig, EthereumERC20ProtocolOptions, EthereumAddress, RawEthereumTransaction, UnsignedEthereumTransaction, UnsignedTypedEthereumTransaction, SignedEthereumTransaction };
package/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EthereumAddress = exports.EthereumERC20ProtocolOptions = exports.EthereumERC20ProtocolConfig = exports.EthereumProtocolOptions = exports.EthereumProtocolConfig = exports.EthereumProtocolNetwork = exports.EtherscanBlockExplorer = exports.EthereumProtocolNetworkExtras = exports.EthereumCryptoClient = exports.GenericERC20 = exports.EthereumClassicProtocol = exports.EthereumRopstenProtocol = exports.EthereumProtocol = void 0;
4
+ var GenericERC20_1 = require("./protocol/erc20/GenericERC20");
5
+ Object.defineProperty(exports, "GenericERC20", { enumerable: true, get: function () { return GenericERC20_1.GenericERC20; } });
6
+ var EthereumAddress_1 = require("./protocol/EthereumAddress");
7
+ Object.defineProperty(exports, "EthereumAddress", { enumerable: true, get: function () { return EthereumAddress_1.EthereumAddress; } });
8
+ var EthereumClassicProtocol_1 = require("./protocol/EthereumClassicProtocol");
9
+ Object.defineProperty(exports, "EthereumClassicProtocol", { enumerable: true, get: function () { return EthereumClassicProtocol_1.EthereumClassicProtocol; } });
10
+ var EthereumCryptoClient_1 = require("./protocol/EthereumCryptoClient");
11
+ Object.defineProperty(exports, "EthereumCryptoClient", { enumerable: true, get: function () { return EthereumCryptoClient_1.EthereumCryptoClient; } });
12
+ var EthereumProtocol_1 = require("./protocol/EthereumProtocol");
13
+ Object.defineProperty(exports, "EthereumProtocol", { enumerable: true, get: function () { return EthereumProtocol_1.EthereumProtocol; } });
14
+ var EthereumProtocolOptions_1 = require("./protocol/EthereumProtocolOptions");
15
+ Object.defineProperty(exports, "EthereumERC20ProtocolConfig", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EthereumERC20ProtocolConfig; } });
16
+ Object.defineProperty(exports, "EthereumERC20ProtocolOptions", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EthereumERC20ProtocolOptions; } });
17
+ Object.defineProperty(exports, "EthereumProtocolConfig", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EthereumProtocolConfig; } });
18
+ Object.defineProperty(exports, "EthereumProtocolNetwork", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EthereumProtocolNetwork; } });
19
+ Object.defineProperty(exports, "EthereumProtocolNetworkExtras", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EthereumProtocolNetworkExtras; } });
20
+ Object.defineProperty(exports, "EthereumProtocolOptions", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EthereumProtocolOptions; } });
21
+ Object.defineProperty(exports, "EtherscanBlockExplorer", { enumerable: true, get: function () { return EthereumProtocolOptions_1.EtherscanBlockExplorer; } });
22
+ var EthereumRopstenProtocol_1 = require("./protocol/EthereumRopstenProtocol");
23
+ Object.defineProperty(exports, "EthereumRopstenProtocol", { enumerable: true, get: function () { return EthereumRopstenProtocol_1.EthereumRopstenProtocol; } });
24
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8DAA4D;AAwB1D,6FAxBO,2BAAY,OAwBP;AAvBd,8DAA4D;AAgC1D,gGAhCO,iCAAe,OAgCP;AA/BjB,8EAA4E;AAqB1E,wGArBO,iDAAuB,OAqBP;AApBzB,wEAAsE;AAsBpE,qGAtBO,2CAAoB,OAsBP;AArBtB,gEAA8D;AAiB5D,iGAjBO,mCAAgB,OAiBP;AAhBlB,8EAQ2C;AAkBzC,4GAzBA,qDAA2B,OAyBA;AAC3B,6GAzBA,sDAA4B,OAyBA;AAH5B,uGArBA,gDAAsB,OAqBA;AADtB,wGAnBA,iDAAuB,OAmBA;AAFvB,8GAhBA,uDAA6B,OAgBA;AAI7B,wGAnBA,iDAAuB,OAmBA;AAHvB,uGAfA,gDAAsB,OAeA;AAbxB,8EAA4E;AAQ1E,wGARO,iDAAuB,OAQP"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@airgap/ethereum",
3
+ "version": "0.13.7-beta.11",
4
+ "description": "The @airgap/ethereum is an Ethereum implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
5
+ "keywords": [
6
+ "airgap",
7
+ "blockchain",
8
+ "crypto",
9
+ "ethereum"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://www.airgap.it",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/airgap-it/airgap-coin-lib"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "build": "rm -rf ./dist && node scripts/node-module-es-module-interop.js && tsc && node scripts/copy-files-after-build.js && node scripts/make-ts-declaration-files-backwards-compatible.js",
22
+ "build-scripts": "tsc scripts/*.ts",
23
+ "lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish --fix",
24
+ "lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
25
+ "lint-ci": "tslint -t json -o ../../lint-reports/ethereum.json --project . || true",
26
+ "lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
27
+ "test": "nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
28
+ "test-ci": "nyc --reporter=lcov npm test",
29
+ "test-legacy": "npm run build && mocha --full-trace --timeout 40000 ./test/**/**.spec.js",
30
+ "browserify": "browserify ./dist/index.js -p realpathify -s airgapCoinLibEthereum > ./dist/airgap-coinlib-ethereum.min.js"
31
+ },
32
+ "author": "Papers GmbH <contact@papers.ch> (https://papers.ch)",
33
+ "dependencies": {
34
+ "@ethereumjs/common": "2.6.0",
35
+ "@ethereumjs/tx": "3.4.0",
36
+ "@metamask/eth-sig-util": "4.0.0"
37
+ },
38
+ "peerDependencies": {
39
+ "@airgap/coinlib-core": "^0.13.7-beta.0"
40
+ },
41
+ "localDependencies": {
42
+ "ethereumjs-tx": "1.3.7",
43
+ "ethereumjs-util": "5.2.0"
44
+ },
45
+ "nyc": {
46
+ "include": [
47
+ "src/**/*.ts"
48
+ ],
49
+ "exclude": [
50
+ "test/**/*.spec.ts"
51
+ ],
52
+ "extension": [
53
+ ".ts"
54
+ ],
55
+ "require": [
56
+ "ts-node/register"
57
+ ],
58
+ "reporter": [
59
+ "text",
60
+ "text-summary"
61
+ ],
62
+ "report-dir": "../../coverage/ethereum",
63
+ "sourceMap": true,
64
+ "instrument": true
65
+ },
66
+ "gitHead": "8e8feb6788204501b7173aa825f5456c2a5f185b"
67
+ }
@@ -0,0 +1,98 @@
1
+ /// <reference types="node" />
2
+ import { UnsignedTransaction } from '@airgap/coinlib-core';
3
+ import { IAirGapSignedTransaction } from '@airgap/coinlib-core/interfaces/IAirGapSignedTransaction';
4
+ import { AirGapTransactionStatus, IAirGapTransaction } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
5
+ import { Network } from '@airgap/coinlib-core/networks';
6
+ import { CurrencyUnit, FeeDefaults, ICoinProtocol } from '@airgap/coinlib-core/protocols/ICoinProtocol';
7
+ import { ICoinSubProtocol } from '@airgap/coinlib-core/protocols/ICoinSubProtocol';
8
+ import { ProtocolSymbols } from '@airgap/coinlib-core/utils/ProtocolSymbols';
9
+ import { SignedEthereumTransaction } from '../types/signed-transaction-ethereum';
10
+ import { RawEthereumTransaction, RawTypedEthereumTransaction } from '../types/transaction-ethereum';
11
+ import { EthereumInfoClient } from './clients/info-clients/InfoClient';
12
+ import { EthereumNodeClient } from './clients/node-clients/NodeClient';
13
+ import { EthereumCryptoClient } from './EthereumCryptoClient';
14
+ import { EthereumProtocolOptions } from './EthereumProtocolOptions';
15
+ import { EthereumAddressCursor, EthereumAddressResult, EthereumTransactionCursor, EthereumTransactionResult } from './EthereumTypes';
16
+ export declare abstract class BaseEthereumProtocol<NodeClient extends EthereumNodeClient, InfoClient extends EthereumInfoClient> implements ICoinProtocol {
17
+ readonly options: EthereumProtocolOptions;
18
+ symbol: string;
19
+ name: string;
20
+ marketSymbol: string;
21
+ feeSymbol: string;
22
+ feeDefaults: FeeDefaults;
23
+ decimals: number;
24
+ feeDecimals: number;
25
+ identifier: ProtocolSymbols;
26
+ readonly MAX_GAS_ESTIMATE: string;
27
+ units: CurrencyUnit[];
28
+ supportsHD: boolean;
29
+ standardDerivationPath: string;
30
+ addressIsCaseSensitive: boolean;
31
+ addressValidationPattern: string;
32
+ addressPlaceholder: string;
33
+ network: Network;
34
+ readonly cryptoClient: EthereumCryptoClient;
35
+ constructor(options?: EthereumProtocolOptions);
36
+ getSymbol(): Promise<string>;
37
+ getName(): Promise<string>;
38
+ getMarketSymbol(): Promise<string>;
39
+ getFeeSymbol(): Promise<string>;
40
+ getFeeDefaults(): Promise<FeeDefaults>;
41
+ getDecimals(): Promise<number>;
42
+ getFeeDecimals(): Promise<number>;
43
+ getIdentifier(): Promise<ProtocolSymbols>;
44
+ getUnits(): Promise<CurrencyUnit[]>;
45
+ getSupportsHD(): Promise<boolean>;
46
+ getStandardDerivationPath(): Promise<string>;
47
+ getAddressIsCaseSensitive(): Promise<boolean>;
48
+ getAddressValidationPattern(): Promise<string>;
49
+ getAddressPlaceholder(): Promise<string>;
50
+ getOptions(): Promise<EthereumProtocolOptions>;
51
+ getBlockExplorerLinkForAddress(address: string): Promise<string>;
52
+ getBlockExplorerLinkForTxId(txId: string): Promise<string>;
53
+ getPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
54
+ getPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
55
+ getExtendedPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
56
+ getExtendedPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
57
+ getPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
58
+ getExtendedPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
59
+ getPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
60
+ getExtendedPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
61
+ getAddressFromPublicKey(publicKey: string | Buffer, cursor?: EthereumAddressCursor): Promise<EthereumAddressResult>;
62
+ getAddressesFromPublicKey(publicKey: string | Buffer, cursor?: EthereumAddressCursor): Promise<EthereumAddressResult[]>;
63
+ private getPublicKeyFromExtendedPublicKey;
64
+ getAddressFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressDerivationIndex: number): Promise<EthereumAddressResult>;
65
+ getAddressesFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressCount: number, offset: number): Promise<EthereumAddressResult[]>;
66
+ private getPrivateKeyFromExtendedPrivateKey;
67
+ signWithExtendedPrivateKey(extendedPrivateKey: string, untypedTransaction: RawTypedEthereumTransaction | RawEthereumTransaction, childDerivationPath?: string): Promise<IAirGapSignedTransaction>;
68
+ signWithPrivateKey(privateKey: string, transaction: RawEthereumTransaction): Promise<IAirGapSignedTransaction>;
69
+ getTransactionDetails(unsignedTx: UnsignedTransaction): Promise<IAirGapTransaction[]>;
70
+ getTransactionDetailsFromSigned(transaction: SignedEthereumTransaction): Promise<IAirGapTransaction[]>;
71
+ getBalanceOfPublicKey(publicKey: string): Promise<string>;
72
+ getBalanceOfAddresses(addresses: string[]): Promise<string>;
73
+ getBalanceOfPublicKeyForSubProtocols(publicKey: string, subProtocols: ICoinSubProtocol[]): Promise<string[]>;
74
+ getBalanceOfExtendedPublicKey(extendedPublicKey: string, offset?: number): Promise<string>;
75
+ getAvailableBalanceOfAddresses(addresses: string[]): Promise<string>;
76
+ estimateMaxTransactionValueFromExtendedPublicKey(extendedPublicKey: string, recipients: string[], fee?: string): Promise<string>;
77
+ estimateFeeDefaultsFromExtendedPublicKey(extendedPublicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
78
+ prepareTransactionFromExtendedPublicKey(extendedPublicKey: string, _offset: number, recipients: string[], values: string[], fee: string, data?: any): Promise<RawEthereumTransaction>;
79
+ estimateMaxTransactionValueFromPublicKey(publicKey: string, recipients: string[], fee?: string): Promise<string>;
80
+ estimateFeeDefaultsFromPublicKey(publicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
81
+ prepareTransactionFromPublicKey(publicKey: string, recipients: string[], values: string[], fee: string, data?: any): Promise<RawEthereumTransaction>;
82
+ broadcastTransaction(rawTransaction: string): Promise<string>;
83
+ getTransactionsFromExtendedPublicKey(extendedPublicKey: string, limit: number, cursor: EthereumTransactionCursor): Promise<EthereumTransactionResult>;
84
+ getTransactionsFromPublicKey(publicKey: string, limit?: number, cursor?: EthereumTransactionCursor): Promise<EthereumTransactionResult>;
85
+ getTransactionsFromAddresses(addresses: string[], limit: number, cursor?: EthereumTransactionCursor): Promise<EthereumTransactionResult>;
86
+ signMessage(message: string, keypair: {
87
+ privateKey: string;
88
+ }): Promise<string>;
89
+ verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
90
+ encryptAsymmetric(message: string, publicKey: string): Promise<string>;
91
+ decryptAsymmetric(message: string, keypair: {
92
+ publicKey: string;
93
+ privateKey: string;
94
+ }): Promise<string>;
95
+ encryptAES(message: string, privateKey: string): Promise<string>;
96
+ decryptAES(message: string, privateKey: string): Promise<string>;
97
+ getTransactionStatuses(transactionHashes: string[]): Promise<AirGapTransactionStatus[]>;
98
+ }