@airgap/ethereum 0.13.11-beta.1 → 0.13.11-beta.3
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/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +1 -5
- package/v0/index.d.ts +12 -0
- package/v0/index.js +39 -0
- package/v0/index.js.map +1 -0
- package/v0/protocol/BaseEthereumProtocol.d.ts +98 -0
- package/v0/protocol/BaseEthereumProtocol.js +939 -0
- package/v0/protocol/BaseEthereumProtocol.js.map +1 -0
- package/v0/protocol/EthereumAddress.d.ts +8 -0
- package/v0/protocol/EthereumAddress.js +43 -0
- package/v0/protocol/EthereumAddress.js.map +1 -0
- package/v0/protocol/EthereumChainIDs.d.ts +1 -0
- package/v0/protocol/EthereumChainIDs.js +340 -0
- package/v0/protocol/EthereumChainIDs.js.map +1 -0
- package/v0/protocol/EthereumClassicProtocol.d.ts +6 -0
- package/v0/protocol/EthereumClassicProtocol.js +30 -0
- package/v0/protocol/EthereumClassicProtocol.js.map +1 -0
- package/v0/protocol/EthereumCryptoClient.d.ts +12 -0
- package/v0/protocol/EthereumCryptoClient.js +148 -0
- package/v0/protocol/EthereumCryptoClient.js.map +1 -0
- package/v0/protocol/EthereumProtocol.d.ts +10 -0
- package/v0/protocol/EthereumProtocol.js +34 -0
- package/v0/protocol/EthereumProtocol.js.map +1 -0
- package/v0/protocol/EthereumProtocolOptions.d.ts +46 -0
- package/v0/protocol/EthereumProtocolOptions.js +150 -0
- package/v0/protocol/EthereumProtocolOptions.js.map +1 -0
- package/v0/protocol/EthereumRopstenProtocol.d.ts +6 -0
- package/v0/protocol/EthereumRopstenProtocol.js +30 -0
- package/v0/protocol/EthereumRopstenProtocol.js.map +1 -0
- package/v0/protocol/EthereumTypes.d.ts +14 -0
- package/v0/protocol/EthereumTypes.js +3 -0
- package/v0/protocol/EthereumTypes.js.map +1 -0
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.d.ts +8 -0
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +195 -0
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -0
- package/v0/protocol/clients/info-clients/InfoClient.d.ts +8 -0
- package/v0/protocol/clients/info-clients/InfoClient.js +11 -0
- package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -0
- package/v0/protocol/clients/node-clients/AirGapNodeClient.d.ts +41 -0
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js +353 -0
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -0
- package/v0/protocol/clients/node-clients/NodeClient.d.ts +17 -0
- package/v0/protocol/clients/node-clients/NodeClient.js +11 -0
- package/v0/protocol/clients/node-clients/NodeClient.js.map +1 -0
- package/v0/protocol/erc20/ERC20.d.ts +3 -0
- package/v0/protocol/erc20/ERC20.js +9 -0
- package/v0/protocol/erc20/ERC20.js.map +1 -0
- package/v0/protocol/erc20/GenericERC20.d.ts +32 -0
- package/v0/protocol/erc20/GenericERC20.js +335 -0
- package/v0/protocol/erc20/GenericERC20.js.map +1 -0
- package/v0/protocol/utils/utils.d.ts +13 -0
- package/v0/protocol/utils/utils.js +140 -0
- package/v0/protocol/utils/utils.js.map +1 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-ethereum.json +50 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-ethereum.json +19 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-ethereum-typed.json +38 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-ethereum.json +50 -0
- package/v0/serializer/schemas/v3/transaction-sign-response-ethereum.json +19 -0
- package/v0/serializer/validators/transaction-validator.d.ts +15 -0
- package/v0/serializer/validators/transaction-validator.js +96 -0
- package/v0/serializer/validators/transaction-validator.js.map +1 -0
- package/v0/serializer/validators/validators.d.ts +1 -0
- package/v0/serializer/validators/validators.js +78 -0
- package/v0/serializer/validators/validators.js.map +1 -0
- package/v0/types/signed-transaction-ethereum.d.ts +5 -0
- package/v0/types/signed-transaction-ethereum.js +3 -0
- package/v0/types/signed-transaction-ethereum.js.map +1 -0
- package/v0/types/transaction-ethereum.d.ts +14 -0
- package/v0/types/transaction-ethereum.js +3 -0
- package/v0/types/transaction-ethereum.js.map +1 -0
- package/v0/types/unsigned-transaction-ethereum-typed.d.ts +11 -0
- package/v0/types/unsigned-transaction-ethereum-typed.js +3 -0
- package/v0/types/unsigned-transaction-ethereum-typed.js.map +1 -0
- package/v0/types/unsigned-transaction-ethereum.d.ts +15 -0
- package/v0/types/unsigned-transaction-ethereum.js +3 -0
- package/v0/types/unsigned-transaction-ethereum.js.map +1 -0
- package/v1/block-explorer/EtherscanBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/EtherscanBlockExplorer.js +74 -0
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -0
- package/v1/clients/crypto/EthereumCryptoClient.d.ts +7 -0
- package/v1/clients/crypto/EthereumCryptoClient.js +147 -0
- package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -0
- package/v1/clients/info/EthereumInfoClient.d.ts +15 -0
- package/v1/clients/info/EthereumInfoClient.js +11 -0
- package/v1/clients/info/EthereumInfoClient.js.map +1 -0
- package/v1/clients/info/EtherscanInfoClient.d.ts +7 -0
- package/v1/clients/info/EtherscanInfoClient.js +165 -0
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -0
- package/v1/clients/node/AirGapNodeClient.d.ts +41 -0
- package/v1/clients/node/AirGapNodeClient.js +351 -0
- package/v1/clients/node/AirGapNodeClient.js.map +1 -0
- package/v1/clients/node/EthereumNodeClient.d.ts +17 -0
- package/v1/clients/node/EthereumNodeClient.js +11 -0
- package/v1/clients/node/EthereumNodeClient.js.map +1 -0
- package/v1/data/EthereumAddress.d.ts +7 -0
- package/v1/data/EthereumAddress.js +46 -0
- package/v1/data/EthereumAddress.js.map +1 -0
- package/v1/index.d.ts +11 -0
- package/v1/index.js +13 -0
- package/v1/index.js.map +1 -0
- package/v1/module/ERC20Tokens.d.ts +3 -0
- package/v1/module/ERC20Tokens.js +815 -0
- package/v1/module/ERC20Tokens.js.map +1 -0
- package/v1/module/EthereumModule.d.ts +13 -0
- package/v1/module/EthereumModule.js +125 -0
- package/v1/module/EthereumModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/EthereumBaseProtocol.d.ts +84 -0
- package/v1/protocol/EthereumBaseProtocol.js +827 -0
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -0
- package/v1/protocol/EthereumChainIds.d.ts +1 -0
- package/v1/protocol/EthereumChainIds.js +340 -0
- package/v1/protocol/EthereumChainIds.js.map +1 -0
- package/v1/protocol/EthereumProtocol.d.ts +8 -0
- package/v1/protocol/EthereumProtocol.js +64 -0
- package/v1/protocol/EthereumProtocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +8 -0
- package/v1/protocol/erc20/ERC20Token.js +421 -0
- package/v1/protocol/erc20/ERC20Token.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +12 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +80 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +10 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +14 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +41 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +58 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +13 -0
- package/v1/serializer/v3/serializer-companion.js +190 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +7 -0
- package/v1/serializer/v3/validators/transaction-validator.js +71 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/protocol.d.ts +32 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +24 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/EthereumUtils.d.ts +13 -0
- package/v1/utils/EthereumUtils.js +140 -0
- package/v1/utils/EthereumUtils.js.map +1 -0
- package/v1/utils/key.d.ts +5 -0
- package/v1/utils/key.js +101 -0
- package/v1/utils/key.js.map +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BigNumber } from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
+
import { AirGapTransactionStatus } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
|
|
3
|
+
export declare abstract class EthereumNodeClient {
|
|
4
|
+
baseURL: string;
|
|
5
|
+
constructor(baseURL: string);
|
|
6
|
+
abstract fetchBalance(address: string): Promise<BigNumber>;
|
|
7
|
+
abstract fetchTransactionCount(address: string): Promise<number>;
|
|
8
|
+
abstract sendSignedTransaction(transaction: string): Promise<string>;
|
|
9
|
+
abstract callBalanceOf(contractAddress: string, address: string): Promise<BigNumber>;
|
|
10
|
+
abstract getTransactionStatus(transactionHash: string): Promise<AirGapTransactionStatus>;
|
|
11
|
+
abstract estimateTransferGas(contractAddress: string, fromAddress: string, toAddress: string, hexAmount: string): Promise<BigNumber>;
|
|
12
|
+
abstract estimateTransactionGas(fromAddress: string, toAddress: string, amount?: string, data?: string, gas?: string): Promise<BigNumber>;
|
|
13
|
+
abstract getGasPrice(): Promise<BigNumber>;
|
|
14
|
+
abstract callBalanceOfOnContracts(contractAddresses: string[], address: string): Promise<{
|
|
15
|
+
[contractAddress: string]: BigNumber;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EthereumNodeClient = void 0;
|
|
4
|
+
var EthereumNodeClient = /** @class */ (function () {
|
|
5
|
+
function EthereumNodeClient(baseURL) {
|
|
6
|
+
this.baseURL = baseURL;
|
|
7
|
+
}
|
|
8
|
+
return EthereumNodeClient;
|
|
9
|
+
}());
|
|
10
|
+
exports.EthereumNodeClient = EthereumNodeClient;
|
|
11
|
+
//# sourceMappingURL=NodeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeClient.js","sourceRoot":"","sources":["../../../../../src/v0/protocol/clients/node-clients/NodeClient.ts"],"names":[],"mappings":";;;AAGA;IAGE,4BAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAwBH,yBAAC;AAAD,CAAC,AA7BD,IA6BC;AA7BqB,gDAAkB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERC20Token = void 0;
|
|
4
|
+
var ProtocolSymbols_1 = require("@airgap/coinlib-core/utils/ProtocolSymbols");
|
|
5
|
+
var EthereumProtocolOptions_1 = require("../EthereumProtocolOptions");
|
|
6
|
+
var GenericERC20_1 = require("./GenericERC20");
|
|
7
|
+
var ERC20Token = new GenericERC20_1.GenericERC20(new EthereumProtocolOptions_1.EthereumERC20ProtocolOptions(new EthereumProtocolOptions_1.EthereumProtocolNetwork(undefined, undefined, undefined, undefined, new EthereumProtocolOptions_1.EthereumProtocolNetworkExtras(3)), new EthereumProtocolOptions_1.EthereumERC20ProtocolConfig('ETH-ERC20', 'Unknown Ethereum ERC20-Token', 'erc20', ProtocolSymbols_1.SubProtocolSymbols.ETH_ERC20, '0x2dd847af80418D280B7078888B6A6133083001C9', 18)));
|
|
8
|
+
exports.ERC20Token = ERC20Token;
|
|
9
|
+
//# sourceMappingURL=ERC20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20.js","sourceRoot":"","sources":["../../../../src/v0/protocol/erc20/ERC20.ts"],"names":[],"mappings":";;;AAAA,8EAA+E;AAC/E,sEAKmC;AAEnC,+CAA6C;AAE7C,IAAM,UAAU,GAAG,IAAI,2BAAY,CACjC,IAAI,sDAA4B,CAC9B,IAAI,iDAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,uDAA6B,CAAC,CAAC,CAAC,CAAC,EAC7G,IAAI,qDAA2B,CAC7B,WAAW,EACX,8BAA8B,EAC9B,OAAO,EACP,oCAAkB,CAAC,SAAS,EAC5B,4CAA4C,EAC5C,EAAE,CACH,CACF,CACF,CAAA;AAEQ,gCAAU"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UnsignedTransaction } from '@airgap/coinlib-core';
|
|
2
|
+
import { IAirGapSignedTransaction } from '@airgap/coinlib-core/interfaces/IAirGapSignedTransaction';
|
|
3
|
+
import { IAirGapTransaction } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
|
|
4
|
+
import { FeeDefaults } from '@airgap/coinlib-core/protocols/ICoinProtocol';
|
|
5
|
+
import { ICoinSubProtocol, SubProtocolType } from '@airgap/coinlib-core/protocols/ICoinSubProtocol';
|
|
6
|
+
import { SignedEthereumTransaction } from '../../types/signed-transaction-ethereum';
|
|
7
|
+
import { RawEthereumTransaction } from '../../types/transaction-ethereum';
|
|
8
|
+
import { BaseEthereumProtocol } from '../BaseEthereumProtocol';
|
|
9
|
+
import { EtherscanInfoClient } from '../clients/info-clients/EtherscanInfoClient';
|
|
10
|
+
import { AirGapNodeClient } from '../clients/node-clients/AirGapNodeClient';
|
|
11
|
+
import { EthereumERC20ProtocolOptions } from '../EthereumProtocolOptions';
|
|
12
|
+
import { EthereumTransactionCursor, EthereumTransactionResult } from '../EthereumTypes';
|
|
13
|
+
export declare class GenericERC20 extends BaseEthereumProtocol<AirGapNodeClient, EtherscanInfoClient> implements ICoinSubProtocol {
|
|
14
|
+
readonly options: EthereumERC20ProtocolOptions;
|
|
15
|
+
isSubProtocol: boolean;
|
|
16
|
+
subProtocolType: SubProtocolType;
|
|
17
|
+
readonly contractAddress: string;
|
|
18
|
+
constructor(options: EthereumERC20ProtocolOptions);
|
|
19
|
+
getIsSubProtocol(): Promise<boolean>;
|
|
20
|
+
getSubProtocolType(): Promise<SubProtocolType>;
|
|
21
|
+
getContractAddress(): Promise<string>;
|
|
22
|
+
getBalanceOfPublicKey(publicKey: string): Promise<string>;
|
|
23
|
+
getBalanceOfAddresses(addresses: string[]): Promise<string>;
|
|
24
|
+
signWithPrivateKey(privateKey: string, transaction: RawEthereumTransaction): Promise<IAirGapSignedTransaction>;
|
|
25
|
+
private estimateGas;
|
|
26
|
+
estimateMaxTransactionValueFromPublicKey(publicKey: string, recipients: string[], fee?: string): Promise<string>;
|
|
27
|
+
estimateFeeDefaultsFromPublicKey(publicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
|
|
28
|
+
prepareTransactionFromPublicKey(publicKey: string, recipients: string[], values: string[], fee: string): Promise<RawEthereumTransaction>;
|
|
29
|
+
getTransactionsFromAddresses(addresses: string[], limit: number, cursor?: EthereumTransactionCursor): Promise<EthereumTransactionResult>;
|
|
30
|
+
getTransactionDetailsFromSigned(signedTx: SignedEthereumTransaction): Promise<IAirGapTransaction[]>;
|
|
31
|
+
getTransactionDetails(unsignedTx: UnsignedTransaction): Promise<IAirGapTransaction[]>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
+
function step(op) {
|
|
54
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
+
while (_) try {
|
|
56
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
+
switch (op[0]) {
|
|
59
|
+
case 0: case 1: t = op; break;
|
|
60
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
+
default:
|
|
64
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
+
if (t[2]) _.ops.pop();
|
|
69
|
+
_.trys.pop(); continue;
|
|
70
|
+
}
|
|
71
|
+
op = body.call(thisArg, _);
|
|
72
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
77
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
+
exports.GenericERC20 = void 0;
|
|
81
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
var ethUtil = __importStar(require("@airgap/coinlib-core/dependencies/src/ethereumjs-util-5.2.0"));
|
|
84
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
85
|
+
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
86
|
+
var ICoinSubProtocol_1 = require("@airgap/coinlib-core/protocols/ICoinSubProtocol");
|
|
87
|
+
var BaseEthereumProtocol_1 = require("../BaseEthereumProtocol");
|
|
88
|
+
var AirGapNodeClient_1 = require("../clients/node-clients/AirGapNodeClient");
|
|
89
|
+
var utils_1 = require("../utils/utils");
|
|
90
|
+
var EthereumTransaction = require('@airgap/coinlib-core/dependencies/src/ethereumjs-tx-1.3.7/index');
|
|
91
|
+
var GenericERC20 = /** @class */ (function (_super) {
|
|
92
|
+
__extends(GenericERC20, _super);
|
|
93
|
+
function GenericERC20(options) {
|
|
94
|
+
var _this = _super.call(this, options) || this;
|
|
95
|
+
_this.options = options;
|
|
96
|
+
_this.isSubProtocol = true;
|
|
97
|
+
_this.subProtocolType = ICoinSubProtocol_1.SubProtocolType.TOKEN;
|
|
98
|
+
_this.contractAddress = options.config.contractAddress;
|
|
99
|
+
_this.symbol = options.config.symbol;
|
|
100
|
+
_this.name = options.config.name;
|
|
101
|
+
_this.marketSymbol = options.config.marketSymbol;
|
|
102
|
+
_this.identifier = options.config.identifier;
|
|
103
|
+
_this.decimals = options.config.decimals;
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
GenericERC20.prototype.getIsSubProtocol = function () {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
return [2 /*return*/, this.isSubProtocol];
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
GenericERC20.prototype.getSubProtocolType = function () {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
return [2 /*return*/, this.subProtocolType];
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
GenericERC20.prototype.getContractAddress = function () {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
return [2 /*return*/, this.contractAddress];
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
GenericERC20.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var address;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
133
|
+
case 1:
|
|
134
|
+
address = _a.sent();
|
|
135
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
GenericERC20.prototype.getBalanceOfAddresses = function (addresses) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
var balances;
|
|
143
|
+
var _this = this;
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0: return [4 /*yield*/, Promise.all(addresses.map(function (address) {
|
|
147
|
+
return _this.options.nodeClient.callBalanceOf(_this.contractAddress, address);
|
|
148
|
+
}))];
|
|
149
|
+
case 1:
|
|
150
|
+
balances = _a.sent();
|
|
151
|
+
return [2 /*return*/, balances.reduce(function (a, b) { return a.plus(b); }).toString(10)];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
GenericERC20.prototype.signWithPrivateKey = function (privateKey, transaction) {
|
|
157
|
+
if (!transaction.data || transaction.data === '0x') {
|
|
158
|
+
transaction.data = new AirGapNodeClient_1.EthereumRPCDataTransfer(transaction.to, transaction.value).abiEncoded(); // backwards-compatible fix
|
|
159
|
+
}
|
|
160
|
+
return _super.prototype.signWithPrivateKey.call(this, privateKey, transaction);
|
|
161
|
+
};
|
|
162
|
+
GenericERC20.prototype.estimateGas = function (source, recipient, hexValue) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
var result;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, this.options.nodeClient.estimateTransferGas(this.contractAddress, source, recipient, hexValue)];
|
|
168
|
+
case 1:
|
|
169
|
+
result = _a.sent();
|
|
170
|
+
return [2 /*return*/, result];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
GenericERC20.prototype.estimateMaxTransactionValueFromPublicKey = function (publicKey, recipients, fee) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
return [2 /*return*/, this.getBalanceOfPublicKey(publicKey)];
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
GenericERC20.prototype.estimateFeeDefaultsFromPublicKey = function (publicKey, recipients, values, data) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
var address, estimatedGas, gasPrise, feeStepFactor, estimatedFee, lowFee, mediumFee, highFee;
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
switch (_a.label) {
|
|
187
|
+
case 0:
|
|
188
|
+
if (recipients.length !== values.length) {
|
|
189
|
+
return [2 /*return*/, Promise.reject('recipients length does not match with values')];
|
|
190
|
+
}
|
|
191
|
+
if (recipients.length !== 1) {
|
|
192
|
+
return [2 /*return*/, Promise.reject('you cannot have 0 recipients')];
|
|
193
|
+
}
|
|
194
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
195
|
+
case 1:
|
|
196
|
+
address = (_a.sent()).address;
|
|
197
|
+
return [4 /*yield*/, this.estimateGas(address, recipients[0], utils_1.EthereumUtils.toHex(values[0]))];
|
|
198
|
+
case 2:
|
|
199
|
+
estimatedGas = _a.sent();
|
|
200
|
+
return [4 /*yield*/, this.options.nodeClient.getGasPrice()];
|
|
201
|
+
case 3:
|
|
202
|
+
gasPrise = _a.sent();
|
|
203
|
+
feeStepFactor = new bignumber_1.default(0.5);
|
|
204
|
+
estimatedFee = estimatedGas.times(gasPrise);
|
|
205
|
+
lowFee = estimatedFee.minus(estimatedFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
206
|
+
mediumFee = estimatedFee;
|
|
207
|
+
highFee = mediumFee.plus(mediumFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
208
|
+
return [2 /*return*/, {
|
|
209
|
+
low: lowFee.shiftedBy(-this.feeDecimals).toFixed(),
|
|
210
|
+
medium: mediumFee.shiftedBy(-this.feeDecimals).toFixed(),
|
|
211
|
+
high: highFee.shiftedBy(-this.feeDecimals).toFixed()
|
|
212
|
+
}];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
GenericERC20.prototype.prepareTransactionFromPublicKey = function (publicKey, recipients, values, fee) {
|
|
218
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
+
var wrappedValues, wrappedFee, balance, _a, address, ethBalance, _b, estimatedGas, txCount, gasPrice, transaction;
|
|
220
|
+
return __generator(this, function (_c) {
|
|
221
|
+
switch (_c.label) {
|
|
222
|
+
case 0:
|
|
223
|
+
wrappedValues = values.map(function (value) { return new bignumber_1.default(value); });
|
|
224
|
+
wrappedFee = new bignumber_1.default(fee);
|
|
225
|
+
if (recipients.length !== wrappedValues.length) {
|
|
226
|
+
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.ERC20, 'recipients length does not match with values');
|
|
227
|
+
}
|
|
228
|
+
if (recipients.length !== 1) {
|
|
229
|
+
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.ERC20, 'you cannot have 0 recipients');
|
|
230
|
+
}
|
|
231
|
+
_a = bignumber_1.default.bind;
|
|
232
|
+
return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
233
|
+
case 1:
|
|
234
|
+
balance = new (_a.apply(bignumber_1.default, [void 0, _c.sent()]))();
|
|
235
|
+
if (!balance.isGreaterThanOrEqualTo(wrappedValues[0])) return [3 /*break*/, 8];
|
|
236
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
237
|
+
case 2:
|
|
238
|
+
address = _c.sent();
|
|
239
|
+
_b = bignumber_1.default.bind;
|
|
240
|
+
return [4 /*yield*/, _super.prototype.getBalanceOfAddresses.call(this, [address])];
|
|
241
|
+
case 3:
|
|
242
|
+
ethBalance = new (_b.apply(bignumber_1.default, [void 0, _c.sent()]))();
|
|
243
|
+
return [4 /*yield*/, this.estimateGas(address, recipients[0], utils_1.EthereumUtils.toHex(wrappedValues[0].toFixed()))];
|
|
244
|
+
case 4:
|
|
245
|
+
estimatedGas = _c.sent();
|
|
246
|
+
if (!ethBalance.isGreaterThanOrEqualTo(wrappedFee)) return [3 /*break*/, 6];
|
|
247
|
+
return [4 /*yield*/, this.options.nodeClient.fetchTransactionCount(address)];
|
|
248
|
+
case 5:
|
|
249
|
+
txCount = _c.sent();
|
|
250
|
+
gasPrice = wrappedFee.isEqualTo(0)
|
|
251
|
+
? new bignumber_1.default(0)
|
|
252
|
+
: wrappedFee.div(estimatedGas).integerValue(bignumber_1.default.ROUND_CEIL);
|
|
253
|
+
transaction = {
|
|
254
|
+
nonce: utils_1.EthereumUtils.toHex(txCount),
|
|
255
|
+
gasLimit: utils_1.EthereumUtils.toHex(estimatedGas.toFixed()),
|
|
256
|
+
gasPrice: utils_1.EthereumUtils.toHex(gasPrice.toFixed()),
|
|
257
|
+
to: this.contractAddress,
|
|
258
|
+
value: utils_1.EthereumUtils.toHex(new bignumber_1.default(0).toFixed()),
|
|
259
|
+
chainId: this.options.network.extras.chainID,
|
|
260
|
+
data: new AirGapNodeClient_1.EthereumRPCDataTransfer(recipients[0], utils_1.EthereumUtils.toHex(wrappedValues[0].toFixed())).abiEncoded()
|
|
261
|
+
};
|
|
262
|
+
return [2 /*return*/, transaction];
|
|
263
|
+
case 6: throw new errors_1.BalanceError(coinlib_error_1.Domain.ERC20, 'not enough ETH balance');
|
|
264
|
+
case 7: return [3 /*break*/, 9];
|
|
265
|
+
case 8: throw new errors_1.BalanceError(coinlib_error_1.Domain.ERC20, 'not enough token balance');
|
|
266
|
+
case 9: return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
GenericERC20.prototype.getTransactionsFromAddresses = function (addresses, limit, cursor) {
|
|
272
|
+
var _this = this;
|
|
273
|
+
return new Promise(function (overallResolve, overallReject) {
|
|
274
|
+
var promises = [];
|
|
275
|
+
for (var _i = 0, addresses_1 = addresses; _i < addresses_1.length; _i++) {
|
|
276
|
+
var address = addresses_1[_i];
|
|
277
|
+
promises.push(_this.options.infoClient.fetchContractTransactions(_this, _this.contractAddress, address, limit, cursor));
|
|
278
|
+
}
|
|
279
|
+
Promise.all(promises)
|
|
280
|
+
.then(function (values) {
|
|
281
|
+
var page = Math.max.apply(Math, values.map(function (txResult) { return txResult.cursor.page; }));
|
|
282
|
+
overallResolve(values.reduce(function (a, b) {
|
|
283
|
+
return { transactions: a.transactions.concat(b.transactions), cursor: { page: page } };
|
|
284
|
+
}));
|
|
285
|
+
})
|
|
286
|
+
.catch(overallReject);
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
GenericERC20.prototype.getTransactionDetailsFromSigned = function (signedTx) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
291
|
+
var ethTxs, ethTx, extractedTx, tokenTransferDetails;
|
|
292
|
+
return __generator(this, function (_a) {
|
|
293
|
+
switch (_a.label) {
|
|
294
|
+
case 0: return [4 /*yield*/, _super.prototype.getTransactionDetailsFromSigned.call(this, signedTx)];
|
|
295
|
+
case 1:
|
|
296
|
+
ethTxs = _a.sent();
|
|
297
|
+
if (ethTxs.length !== 1) {
|
|
298
|
+
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.ERC20, 'More than one ETH transaction detected.');
|
|
299
|
+
}
|
|
300
|
+
ethTx = ethTxs[0];
|
|
301
|
+
extractedTx = new EthereumTransaction(signedTx.transaction);
|
|
302
|
+
tokenTransferDetails = new AirGapNodeClient_1.EthereumRPCDataTransfer("0x".concat(extractedTx.data.toString('hex')));
|
|
303
|
+
ethTx.to = [ethUtil.toChecksumAddress(tokenTransferDetails.recipient)];
|
|
304
|
+
ethTx.amount = new bignumber_1.default(tokenTransferDetails.amount).toString(10);
|
|
305
|
+
return [2 /*return*/, [ethTx]];
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
GenericERC20.prototype.getTransactionDetails = function (unsignedTx) {
|
|
311
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
312
|
+
var unsignedEthereumTx, ethTxs, ethTx, tokenTransferDetails;
|
|
313
|
+
return __generator(this, function (_a) {
|
|
314
|
+
switch (_a.label) {
|
|
315
|
+
case 0:
|
|
316
|
+
unsignedEthereumTx = unsignedTx;
|
|
317
|
+
return [4 /*yield*/, _super.prototype.getTransactionDetails.call(this, unsignedEthereumTx)];
|
|
318
|
+
case 1:
|
|
319
|
+
ethTxs = _a.sent();
|
|
320
|
+
if (ethTxs.length !== 1) {
|
|
321
|
+
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.ERC20, 'More than one ETH transaction detected.');
|
|
322
|
+
}
|
|
323
|
+
ethTx = ethTxs[0];
|
|
324
|
+
tokenTransferDetails = new AirGapNodeClient_1.EthereumRPCDataTransfer(unsignedEthereumTx.transaction.data);
|
|
325
|
+
ethTx.to = [ethUtil.toChecksumAddress(tokenTransferDetails.recipient)];
|
|
326
|
+
ethTx.amount = new bignumber_1.default(tokenTransferDetails.amount).toString(10);
|
|
327
|
+
return [2 /*return*/, [ethTx]];
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
return GenericERC20;
|
|
333
|
+
}(BaseEthereumProtocol_1.BaseEthereumProtocol));
|
|
334
|
+
exports.GenericERC20 = GenericERC20;
|
|
335
|
+
//# sourceMappingURL=GenericERC20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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uB,MAAM,CAAC,CAAC,CAAC,CAAA;wBAErC,oBAAoB,GAAG,IAAI,0CAAuB,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;wBAE7F,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAA;wBACtE,KAAK,CAAC,MAAM,GAAG,IAAI,mBAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;wBAEtE,sBAAO,CAAC,KAAK,CAAC,EAAA;;;;KACf;IACH,mBAAC;AAAD,CAAC,AAtMD,CAAkC,2CAAoB,GAsMrD;AAtMY,oCAAY"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class EthereumUtils {
|
|
2
|
+
static toHex(value: any): string;
|
|
3
|
+
private static readonly SHA3_NULL_S;
|
|
4
|
+
static sha3(value: any): string | null;
|
|
5
|
+
private static numberToHex;
|
|
6
|
+
private static hexToBytes;
|
|
7
|
+
private static isHexStrict;
|
|
8
|
+
private static checkAddressChecksum;
|
|
9
|
+
private static isAddress;
|
|
10
|
+
private static isBigNumber;
|
|
11
|
+
private static utf8ToHex;
|
|
12
|
+
private static isObject;
|
|
13
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EthereumUtils = void 0;
|
|
4
|
+
var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
|
|
5
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
7
|
+
// var _ = require('underscore')
|
|
8
|
+
// var BN = require('@airgap/coinlib-core/dependencies/src/bn.js-4.11.8/bn')
|
|
9
|
+
// var numberToBN = require('number-to-bn')
|
|
10
|
+
var utf8 = require('@airgap/coinlib-core/dependencies/src/utf8-3.0.0/utf8');
|
|
11
|
+
var createKeccakHash = require('@airgap/coinlib-core/dependencies/src/keccak-1.0.2/js');
|
|
12
|
+
// this code was adapted from web3.js (https://github.com/ethereum/web3.js/blob/2.x/packages/web3-utils/src/Utils.js)
|
|
13
|
+
var EthereumUtils = /** @class */ (function () {
|
|
14
|
+
function EthereumUtils() {
|
|
15
|
+
}
|
|
16
|
+
EthereumUtils.toHex = function (value) {
|
|
17
|
+
if (EthereumUtils.isAddress(value)) {
|
|
18
|
+
return "0x".concat(value.toLowerCase().replace(/^0x/i, ''));
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'boolean') {
|
|
21
|
+
return value ? '0x01' : '0x00';
|
|
22
|
+
}
|
|
23
|
+
if (EthereumUtils.isObject(value) && !EthereumUtils.isBigNumber(value) /* && !EthereumUtils.isBN(value)*/) {
|
|
24
|
+
return EthereumUtils.utf8ToHex(JSON.stringify(value));
|
|
25
|
+
}
|
|
26
|
+
// if its a negative number, pass it through numberToHex
|
|
27
|
+
if (typeof value === 'string') {
|
|
28
|
+
if (value.indexOf('-0x') === 0 || value.indexOf('-0X') === 0) {
|
|
29
|
+
return EthereumUtils.numberToHex(value);
|
|
30
|
+
}
|
|
31
|
+
else if (value.indexOf('0x') === 0 || value.indexOf('0X') === 0) {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
else if (!isFinite(Number(value))) {
|
|
35
|
+
return EthereumUtils.utf8ToHex(value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return EthereumUtils.numberToHex(value);
|
|
39
|
+
};
|
|
40
|
+
EthereumUtils.sha3 = function (value) {
|
|
41
|
+
var valueInBytes = value;
|
|
42
|
+
if (EthereumUtils.isHexStrict(value) && /^0x/i.test(value.toString())) {
|
|
43
|
+
valueInBytes = EthereumUtils.hexToBytes(value);
|
|
44
|
+
}
|
|
45
|
+
var hash = createKeccakHash('keccak256').update(valueInBytes).digest('hex');
|
|
46
|
+
var returnValue = "0x".concat(hash);
|
|
47
|
+
if (returnValue === EthereumUtils.SHA3_NULL_S) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return returnValue;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
EthereumUtils.numberToHex = function (value) {
|
|
55
|
+
if (value === null || value === undefined) {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
if (!isFinite(Number(value)) && !EthereumUtils.isHexStrict(value)) {
|
|
59
|
+
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given input \"".concat(JSON.stringify(value), "\" is not a number."));
|
|
60
|
+
}
|
|
61
|
+
// var number = EthereumUtils.toBN(value)
|
|
62
|
+
var myNumber = new bignumber_1.BigNumber(value);
|
|
63
|
+
var result = myNumber.toString(16);
|
|
64
|
+
return myNumber.lt(new bignumber_1.BigNumber(0)) ? "-0x".concat(result.substr(1)) : "0x".concat(result);
|
|
65
|
+
};
|
|
66
|
+
EthereumUtils.hexToBytes = function (value) {
|
|
67
|
+
var hex = typeof value === 'number' ? value.toString(16) : value;
|
|
68
|
+
if (!EthereumUtils.isHexStrict(hex)) {
|
|
69
|
+
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given value \"".concat(JSON.stringify(hex), "\" is not a valid hex string."));
|
|
70
|
+
}
|
|
71
|
+
hex = hex.replace(/^0x/i, '');
|
|
72
|
+
var bytes = [];
|
|
73
|
+
for (var c = 0; c < hex.length; c += 2) {
|
|
74
|
+
bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
75
|
+
}
|
|
76
|
+
return bytes;
|
|
77
|
+
};
|
|
78
|
+
EthereumUtils.isHexStrict = function (hex) {
|
|
79
|
+
return (typeof hex === 'string' || typeof hex === 'number') && /^(-)?0x[0-9a-f]*$/i.test(hex.toString());
|
|
80
|
+
};
|
|
81
|
+
EthereumUtils.checkAddressChecksum = function (value) {
|
|
82
|
+
var address = value.replace(/^0x/i, '');
|
|
83
|
+
var addressHash = EthereumUtils.sha3(address.toLowerCase());
|
|
84
|
+
if (addressHash === null) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
addressHash = addressHash.replace(/^0x/i, '');
|
|
88
|
+
for (var i = 0; i < 40; i++) {
|
|
89
|
+
if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) ||
|
|
90
|
+
(parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
};
|
|
96
|
+
EthereumUtils.isAddress = function (value) {
|
|
97
|
+
if (!/^(0x)?[0-9a-f]{40}$/i.test(value)) {
|
|
98
|
+
return false;
|
|
99
|
+
// If it's ALL lowercase or ALL upppercase
|
|
100
|
+
}
|
|
101
|
+
else if (/^(0x|0X)?[0-9a-f]{40}$/.test(value) || /^(0x|0X)?[0-9A-F]{40}$/.test(value)) {
|
|
102
|
+
return true;
|
|
103
|
+
// Otherwise check each case
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return EthereumUtils.checkAddressChecksum(value);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
EthereumUtils.isBigNumber = function (value) {
|
|
110
|
+
if (!value) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return bignumber_1.BigNumber.isBigNumber(value);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
EthereumUtils.utf8ToHex = function (value) {
|
|
118
|
+
var str = utf8.encode(value);
|
|
119
|
+
var hex = '';
|
|
120
|
+
// remove \u0000 padding from either side
|
|
121
|
+
str = str.replace(/^(?:\u0000)*/, '');
|
|
122
|
+
str = str.split('').reverse().join('');
|
|
123
|
+
str = str.replace(/^(?:\u0000)*/, '');
|
|
124
|
+
str = str.split('').reverse().join('');
|
|
125
|
+
for (var i = 0; i < str.length; i++) {
|
|
126
|
+
var code = str.charCodeAt(i);
|
|
127
|
+
var n = code.toString(16);
|
|
128
|
+
hex += n.length < 2 ? "0".concat(n) : n;
|
|
129
|
+
}
|
|
130
|
+
return "0x".concat(hex);
|
|
131
|
+
};
|
|
132
|
+
EthereumUtils.isObject = function (value) {
|
|
133
|
+
var type = typeof value;
|
|
134
|
+
return type === 'function' || (type === 'object' && !!value);
|
|
135
|
+
};
|
|
136
|
+
EthereumUtils.SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';
|
|
137
|
+
return EthereumUtils;
|
|
138
|
+
}());
|
|
139
|
+
exports.EthereumUtils = EthereumUtils;
|
|
140
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/v0/protocol/utils/utils.ts"],"names":[],"mappings":";;;AAAA,gGAA8F;AAC9F,sDAA+D;AAC/D,2EAAkE;AAClE,gCAAgC;AAChC,4EAA4E;AAC5E,2CAA2C;AAC3C,IAAM,IAAI,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAA;AAC7E,IAAM,gBAAgB,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAA;AAEzF,qHAAqH;AACrH;IAAA;IAqJA,CAAC;IApJe,mBAAK,GAAnB,UAAoB,KAAU;QAC5B,IAAI,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAClC,OAAO,YAAK,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAE,CAAA;SACtD;QAED,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;SAC/B;QAED,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAA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