Moved TypeScript generation to match library layout for easier importing sub-components.
This commit is contained in:
parent
45f8827c6e
commit
28cd3cace2
30
dist/ethers.d.ts
vendored
30
dist/ethers.d.ts
vendored
@ -756,16 +756,6 @@ declare module "index" {
|
||||
const version = "4.0.0";
|
||||
export { Wallet, HDNode, SigningKey, Contract, Interface, getNetwork, providers, errors, utils, version };
|
||||
}
|
||||
declare module "wordlists/lang-it" {
|
||||
import { Wordlist } from "wordlists/wordlist";
|
||||
class LangIt extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
const langIt: LangIt;
|
||||
export { langIt };
|
||||
}
|
||||
declare module "wordlists/lang-ja" {
|
||||
import { Wordlist } from "wordlists/wordlist";
|
||||
class LangJa extends Wordlist {
|
||||
@ -788,6 +778,16 @@ declare module "wordlists/lang-ko" {
|
||||
const langKo: LangKo;
|
||||
export { langKo };
|
||||
}
|
||||
declare module "wordlists/lang-it" {
|
||||
import { Wordlist } from "wordlists/wordlist";
|
||||
class LangIt extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
const langIt: LangIt;
|
||||
export { langIt };
|
||||
}
|
||||
declare module "wordlists/lang-zh" {
|
||||
import { Wordlist } from "wordlists/wordlist";
|
||||
class LangZh extends Wordlist {
|
||||
@ -801,4 +801,14 @@ declare module "wordlists/lang-zh" {
|
||||
const langZhTw: LangZh;
|
||||
export { langZhCn, langZhTw };
|
||||
}
|
||||
declare module "wordlists/index" {
|
||||
import { Wordlist } from "wordlists/wordlist";
|
||||
import { langJa as ja } from "wordlists/lang-ja";
|
||||
import { langKo as ko } from "wordlists/lang-ko";
|
||||
import { langIt as it } from "wordlists/lang-it";
|
||||
import { langEn as en } from "wordlists/lang-en";
|
||||
import { langZhCn as zh_cn, langZhTw as zh_tw } from "wordlists/lang-zh";
|
||||
const zh: Wordlist;
|
||||
export { en, it, ja, ko, zh, zh_cn, zh_tw };
|
||||
}
|
||||
//# sourceMappingURL=ethers.d.ts.map
|
2
dist/ethers.d.ts.map
vendored
2
dist/ethers.d.ts.map
vendored
File diff suppressed because one or more lines are too long
60
gulpfile.js
60
gulpfile.js
@ -15,6 +15,7 @@ var sourcemaps = require('gulp-sourcemaps');
|
||||
var uglify = require('gulp-uglify');
|
||||
var buffer = require('vinyl-buffer');
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Transforms
|
||||
|
||||
@ -77,6 +78,17 @@ function padding(length) {
|
||||
while (pad.length < length) { pad += ' '; }
|
||||
return pad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Browser Library
|
||||
*
|
||||
* Source: src.ts/index.ts src.ts/{contracts,providers,utils,wallet}/*.ts
|
||||
* Target: dist/ethers{.min,}.js
|
||||
*
|
||||
* See the above transform tables which maps regular expressions to
|
||||
* replacement source for largely libraries we only require parts of.
|
||||
*
|
||||
*/
|
||||
function transform(path, options) {
|
||||
var data = '';
|
||||
|
||||
@ -102,30 +114,32 @@ function transform(path, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function createDefer(map) {
|
||||
var output = "const map = " + JSON.stringify(map) + ';\n';
|
||||
output += 'const defer = new Object();\n';
|
||||
for (var key in map) {
|
||||
output += 'Object.defineProperty(defer, "' + key + '", { get: function() { return ' + map[key] + '; } });\n';
|
||||
}
|
||||
output += 'module.exports = defer;\n';
|
||||
return output
|
||||
}
|
||||
|
||||
/**
|
||||
* Browser Wordlist files
|
||||
*
|
||||
* Source: src.ts/wordlists/lang-*.ts.
|
||||
* Target: dist/wordlist-*.js
|
||||
*
|
||||
* Since all of the functions these wordlists use is already
|
||||
* available from the global ethers library, we use this to
|
||||
* target the global ethers functions directly, rather than
|
||||
* re-include them.
|
||||
*
|
||||
*/
|
||||
function transformBip39(path, options) {
|
||||
var data = '';
|
||||
|
||||
return through(function(chunk) {
|
||||
data += chunk;
|
||||
}, function () {
|
||||
var transformed = transformFile(path);
|
||||
var shortPath = path;
|
||||
if (shortPath.substring(0, __dirname.length) == __dirname) {
|
||||
shortPath = shortPath.substring(__dirname.length);
|
||||
}
|
||||
var size = fs.readFileSync(path).length;
|
||||
|
||||
// Word list files...
|
||||
if (shortPath.match(/^\/src\.ts\/wordlists\//)) {
|
||||
// If it is the wordlist class, register should export the wordlist
|
||||
if (shortPath === '/src.ts/wordlists/wordlist.ts') {
|
||||
data += '\n\nexportWordlist = true;'
|
||||
}
|
||||
@ -151,13 +165,14 @@ function transformBip39(path, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function task(name, options) {
|
||||
|
||||
function taskBundle(name, options) {
|
||||
|
||||
gulp.task(name, function () {
|
||||
|
||||
var result = browserify({
|
||||
basedir: '.',
|
||||
debug: options.debug,
|
||||
debug: false,
|
||||
entries: [ 'src.ts/' ],
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
@ -182,18 +197,14 @@ function task(name, options) {
|
||||
}
|
||||
|
||||
// Creates dist/ethers.js
|
||||
task("default", { filename: "ethers.js", debug: false, minify: false });
|
||||
|
||||
// Creates dist/ethers-debug.js
|
||||
//task("debug", { filename: "ethers-debug.js", debug: true, minify: false });
|
||||
taskBundle("default", { filename: "ethers.js", minify: false });
|
||||
|
||||
// Creates dist/ethers.min.js
|
||||
task("minified", { filename: "ethers.min.js", debug: false, minify: true });
|
||||
taskBundle("minified", { filename: "ethers.min.js", minify: true });
|
||||
|
||||
// Crearte a single definition file and its map as dist/ethers.d.ts[.map]
|
||||
gulp.task("types", function() {
|
||||
return ts.createProject("tsconfig.json")
|
||||
.src()
|
||||
return gulp.src(['./src.ts/index.ts', './src.ts/**/*.ts'])
|
||||
.pipe(ts({
|
||||
declaration: true,
|
||||
esModuleInterop: true,
|
||||
@ -208,6 +219,13 @@ gulp.task("types", function() {
|
||||
.pipe(gulp.dest("dist"))
|
||||
});
|
||||
|
||||
/**
|
||||
* Browser Friendly BIP39 Wordlists
|
||||
*
|
||||
* source: src.ts/wordlist/lang-*.ts
|
||||
* target: dist/wordlist-*.js
|
||||
*
|
||||
*/
|
||||
function taskLang(locale) {
|
||||
gulp.task("bip39-" + locale, function() {
|
||||
return browserify({
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "ethers",
|
||||
"version": "4.0.0",
|
||||
"description": "Ethereum wallet library.",
|
||||
"main": "./src/index.js",
|
||||
"main": "./index.js",
|
||||
"types": "./dist/ethers.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc -p ./tsconfig.json",
|
||||
|
14
src.ts/wordlists/index.ts
Normal file
14
src.ts/wordlists/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
import { Wordlist } from './wordlist';
|
||||
|
||||
import { langJa as ja } from './lang-ja';
|
||||
import { langKo as ko } from './lang-ko';
|
||||
import { langIt as it } from './lang-it';
|
||||
import { langEn as en } from './lang-en';
|
||||
import { langZhCn as zh_cn, langZhTw as zh_tw } from './lang-zh';
|
||||
|
||||
const zh: Wordlist = zh_cn;
|
||||
|
||||
export {
|
||||
en, it, ja, ko, zh, zh_cn, zh_tw
|
||||
}
|
27
src/contracts/contract.d.ts
vendored
27
src/contracts/contract.d.ts
vendored
@ -1,27 +0,0 @@
|
||||
import { Interface } from './interface';
|
||||
import { Provider, TransactionResponse } from '../providers/provider';
|
||||
import { Signer } from '../wallet/wallet';
|
||||
import { ParamType } from '../utils/abi-coder';
|
||||
import { BigNumber } from '../utils/bignumber';
|
||||
export declare type ContractEstimate = (...params: Array<any>) => Promise<BigNumber>;
|
||||
export declare type ContractFunction = (...params: Array<any>) => Promise<any>;
|
||||
export declare type ContractEvent = (...params: Array<any>) => void;
|
||||
interface Bucket<T> {
|
||||
[name: string]: T;
|
||||
}
|
||||
export declare type Contractish = Array<string | ParamType> | Interface | string;
|
||||
export declare class Contract {
|
||||
readonly address: string;
|
||||
readonly interface: Interface;
|
||||
readonly signer: Signer;
|
||||
readonly provider: Provider;
|
||||
readonly estimate: Bucket<ContractEstimate>;
|
||||
readonly functions: Bucket<ContractFunction>;
|
||||
readonly events: Bucket<ContractEvent>;
|
||||
readonly addressPromise: Promise<string>;
|
||||
readonly deployTransaction: TransactionResponse;
|
||||
constructor(addressOrName: string, contractInterface: Contractish, signerOrProvider: Signer | Provider);
|
||||
connect(signerOrProvider: Signer | Provider): Contract;
|
||||
deploy(bytecode: string, ...args: Array<any>): Promise<Contract>;
|
||||
}
|
||||
export {};
|
3
src/contracts/index.d.ts
vendored
3
src/contracts/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { Contract } from './contract';
|
||||
import { Interface } from './interface';
|
||||
export { Contract, Interface };
|
62
src/contracts/interface.d.ts
vendored
62
src/contracts/interface.d.ts
vendored
@ -1,62 +0,0 @@
|
||||
import { ParamType } from '../utils/abi-coder';
|
||||
import { BigNumber, BigNumberish } from '../utils/bignumber';
|
||||
export declare class Description {
|
||||
readonly type: string;
|
||||
constructor(info: any);
|
||||
}
|
||||
export declare class Indexed extends Description {
|
||||
readonly hash: string;
|
||||
}
|
||||
export declare class DeployDescription extends Description {
|
||||
readonly inputs: Array<ParamType>;
|
||||
readonly payable: boolean;
|
||||
encode(bytecode: string, params: Array<any>): string;
|
||||
}
|
||||
export declare class FunctionDescription extends Description {
|
||||
readonly name: string;
|
||||
readonly signature: string;
|
||||
readonly sighash: string;
|
||||
readonly inputs: Array<ParamType>;
|
||||
readonly outputs: Array<ParamType>;
|
||||
readonly payable: boolean;
|
||||
encode(params: Array<any>): string;
|
||||
decode(data: string): any;
|
||||
}
|
||||
export declare class EventDescription extends Description {
|
||||
readonly name: string;
|
||||
readonly signature: string;
|
||||
readonly inputs: Array<ParamType>;
|
||||
readonly anonymous: boolean;
|
||||
readonly topic: string;
|
||||
decode(data: string, topics?: Array<string>): any;
|
||||
}
|
||||
declare class TransactionDescription extends Description {
|
||||
readonly name: string;
|
||||
readonly args: Array<any>;
|
||||
readonly signature: string;
|
||||
readonly sighash: string;
|
||||
readonly decode: (data: string) => any;
|
||||
readonly value: BigNumber;
|
||||
}
|
||||
declare class LogDescription extends Description {
|
||||
readonly name: string;
|
||||
readonly signature: string;
|
||||
readonly topic: string;
|
||||
readonly values: Array<any>;
|
||||
}
|
||||
export declare class Interface {
|
||||
readonly abi: Array<any>;
|
||||
readonly functions: Array<FunctionDescription>;
|
||||
readonly events: Array<EventDescription>;
|
||||
readonly deployFunction: DeployDescription;
|
||||
constructor(abi: Array<string | ParamType> | string);
|
||||
parseTransaction(tx: {
|
||||
data: string;
|
||||
value?: BigNumberish;
|
||||
}): TransactionDescription;
|
||||
parseLog(log: {
|
||||
topics: Array<string>;
|
||||
data: string;
|
||||
}): LogDescription;
|
||||
}
|
||||
export {};
|
8
src/index.d.ts
vendored
8
src/index.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Contract, Interface } from './contracts';
|
||||
import * as providers from './providers';
|
||||
import * as errors from './utils/errors';
|
||||
import { getNetwork } from './providers/networks';
|
||||
import * as utils from './utils';
|
||||
import { HDNode, SigningKey, Wallet } from './wallet';
|
||||
declare const version = "4.0.0";
|
||||
export { Wallet, HDNode, SigningKey, Contract, Interface, getNetwork, providers, errors, utils, version };
|
63
src/lang-ja.d.ts
vendored
63
src/lang-ja.d.ts
vendored
@ -1,63 +0,0 @@
|
||||
declare const ethers: any;
|
||||
declare const data: string[];
|
||||
declare const mapping: {
|
||||
A: number;
|
||||
B: number;
|
||||
C: number;
|
||||
D: number;
|
||||
E: number;
|
||||
F: number;
|
||||
G: number;
|
||||
H: number;
|
||||
I: number;
|
||||
J: number;
|
||||
K: number;
|
||||
L: number;
|
||||
M: number;
|
||||
N: number;
|
||||
O: number;
|
||||
P: number;
|
||||
Q: number;
|
||||
R: number;
|
||||
S: number;
|
||||
T: number;
|
||||
U: number;
|
||||
V: number;
|
||||
W: number;
|
||||
X: number;
|
||||
Y: number;
|
||||
Z: number;
|
||||
a: number;
|
||||
b: number;
|
||||
c: number;
|
||||
d: number;
|
||||
e: number;
|
||||
f: number;
|
||||
g: number;
|
||||
h: number;
|
||||
i: number;
|
||||
j: number;
|
||||
k: number;
|
||||
l: number;
|
||||
m: number;
|
||||
n: number;
|
||||
o: number;
|
||||
p: number;
|
||||
q: number;
|
||||
r: number;
|
||||
s: number;
|
||||
t: number;
|
||||
u: number;
|
||||
v: number;
|
||||
w: number;
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
};
|
||||
declare var transform: {};
|
||||
declare function normalize(word: any): string;
|
||||
declare function sortJapanese(a: any, b: any): 0 | 1 | -1;
|
||||
declare let words: any[];
|
||||
declare let kyoku: any;
|
||||
declare function getWord(index: any): any;
|
||||
declare function getWordIndex(word: any): number;
|
136
src/lang-ja.js
136
src/lang-ja.js
@ -1,136 +0,0 @@
|
||||
var ethers = require('../src');
|
||||
// Words are broken up into 3-kana, 4-kana, ... 9-kana words
|
||||
var data = [
|
||||
'AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXBCDBCHBGFBEQBpBBpQBIkBHNBeOBgFBVCBhBBhNBmOBmRBiHBiFBUFBZDBvFBsXBkFBlcBjYBwDBMBBTBBTRBWBBWXXaQXaRXQWXSRXCFXYBXpHXOQXHRXhRXuRXmXXbRXlXXwDXTRXrCXWQXWGaBWaKcaYgasFadQalmaMBacAKaRKKBKKXKKjKQRKDRKCYKCRKIDKeVKHcKlXKjHKrYNAHNBWNaRNKcNIBNIONmXNsXNdXNnBNMBNRBNrXNWDNWMNFOQABQAHQBrQXBQXFQaRQKXQKDQKOQKFQNBQNDQQgQCXQCDQGBQGDQGdQYXQpBQpQQpHQLXQHuQgBQhBQhCQuFQmXQiDQUFQZDQsFQdRQkHQbRQlOQlmQPDQjDQwXQMBQMDQcFQTBQTHQrDDXQDNFDGBDGQDGRDpFDhFDmXDZXDbRDMYDRdDTRDrXSAhSBCSBrSGQSEQSHBSVRShYShkSyQSuFSiBSdcSoESocSlmSMBSFBSFKSFNSFdSFcCByCaRCKcCSBCSRCCrCGbCEHCYXCpBCpQCIBCIHCeNCgBCgFCVECVcCmkCmwCZXCZFCdRCl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IFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD',
|
||||
'QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD',
|
||||
'IJBEJqXZJ'
|
||||
];
|
||||
// Maps each character in the above data to a kana code
|
||||
var mapping = {
|
||||
A: 2,
|
||||
B: 4,
|
||||
C: 19,
|
||||
D: 15,
|
||||
E: 23,
|
||||
F: 83,
|
||||
G: 21,
|
||||
H: 36,
|
||||
I: 31,
|
||||
J: 89,
|
||||
K: 10,
|
||||
L: 29,
|
||||
M: 73,
|
||||
N: 11,
|
||||
O: 33,
|
||||
P: 67,
|
||||
Q: 13,
|
||||
R: 75,
|
||||
S: 17,
|
||||
T: 76,
|
||||
U: 50,
|
||||
V: 40,
|
||||
W: 79,
|
||||
X: 6,
|
||||
Y: 25,
|
||||
Z: 53,
|
||||
a: 8,
|
||||
b: 65,
|
||||
c: 74,
|
||||
d: 62,
|
||||
e: 35,
|
||||
f: 69,
|
||||
g: 38,
|
||||
h: 42,
|
||||
i: 47,
|
||||
j: 68,
|
||||
k: 63,
|
||||
l: 66,
|
||||
m: 46,
|
||||
n: 70,
|
||||
o: 64,
|
||||
p: 27,
|
||||
q: 71,
|
||||
r: 77,
|
||||
s: 59,
|
||||
t: 90,
|
||||
u: 45,
|
||||
v: 56,
|
||||
w: 72,
|
||||
x: 43,
|
||||
y: 44,
|
||||
z: 3
|
||||
};
|
||||
// Transforms for normalizing
|
||||
var transform = {};
|
||||
// Delete the diacritic marks
|
||||
transform[ethers.utils.toUtf8String([227, 130, 154])] = false;
|
||||
transform[ethers.utils.toUtf8String([227, 130, 153])] = false;
|
||||
// Some simple transforms that sort out most of the order
|
||||
transform[ethers.utils.toUtf8String([227, 130, 133])] = ethers.utils.toUtf8String([227, 130, 134]);
|
||||
transform[ethers.utils.toUtf8String([227, 129, 163])] = ethers.utils.toUtf8String([227, 129, 164]);
|
||||
transform[ethers.utils.toUtf8String([227, 130, 131])] = ethers.utils.toUtf8String([227, 130, 132]);
|
||||
transform[ethers.utils.toUtf8String([227, 130, 135])] = ethers.utils.toUtf8String([227, 130, 136]);
|
||||
// Normalize words using the transform
|
||||
function normalize(word) {
|
||||
var result = '';
|
||||
for (var i = 0; i < word.length; i++) {
|
||||
var kana = word[i];
|
||||
var target = transform[kana];
|
||||
if (target === false) {
|
||||
continue;
|
||||
}
|
||||
if (target) {
|
||||
kana = target;
|
||||
}
|
||||
result += kana;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Sort how the Japanese list is sorted
|
||||
function sortJapanese(a, b) {
|
||||
a = normalize(a);
|
||||
b = normalize(b);
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// Load all the words
|
||||
var words = [];
|
||||
for (var length_1 = 3; length_1 <= 9; length_1++) {
|
||||
var d = data[length_1 - 3];
|
||||
for (var offset = 0; offset < d.length; offset += length_1) {
|
||||
var word = [];
|
||||
for (var i = 0; i < length_1; i++) {
|
||||
var k = mapping[d[offset + i]];
|
||||
word.push(227);
|
||||
word.push((k & 0x40) ? 130 : 129);
|
||||
word.push((k & 0x3f) + 128);
|
||||
}
|
||||
words.push(ethers.utils.toUtf8String(word));
|
||||
}
|
||||
}
|
||||
words.sort(sortJapanese);
|
||||
// For some reason kyoku and kiyoku are flipped; we'll just manually fix it
|
||||
var kyoku = words[442];
|
||||
words[442] = words[443];
|
||||
words[443] = kyoku;
|
||||
/*
|
||||
var fs = require('fs');
|
||||
fs.readFileSync('lang-ja.txt').toString().split('\x0a').forEach(function(d, i) {
|
||||
if (d !== words[i]) { console.log(d, words[i], i, ethers.utils.toUtf8Bytes(d)); }
|
||||
});
|
||||
*/
|
||||
function getWord(index) {
|
||||
return words[index];
|
||||
}
|
||||
function getWordIndex(word) {
|
||||
return words.indexOf(word);
|
||||
}
|
0
src/providers/browser-xmlhttprequest.d.ts
vendored
0
src/providers/browser-xmlhttprequest.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
'use strict';
|
||||
try {
|
||||
module.exports.XMLHttpRequest = XMLHttpRequest;
|
||||
}
|
||||
catch (error) {
|
||||
console.log('Warning: XMLHttpRequest is not defined');
|
||||
module.exports.XMLHttpRequest = null;
|
||||
}
|
9
src/providers/etherscan-provider.d.ts
vendored
9
src/providers/etherscan-provider.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
import { BlockTag, Provider, TransactionResponse } from './provider';
|
||||
import { Networkish } from './networks';
|
||||
export declare class EtherscanProvider extends Provider {
|
||||
readonly baseUrl: string;
|
||||
readonly apiKey: string;
|
||||
constructor(network?: Networkish, apiKey?: string);
|
||||
perform(method: string, params: any): Promise<any>;
|
||||
getHistory(addressOrName: string | Promise<string>, startBlock?: BlockTag, endBlock?: BlockTag): Promise<Array<TransactionResponse>>;
|
||||
}
|
7
src/providers/fallback-provider.d.ts
vendored
7
src/providers/fallback-provider.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import { Provider } from './provider';
|
||||
export declare class FallbackProvider extends Provider {
|
||||
private _providers;
|
||||
constructor(providers: Array<Provider>);
|
||||
readonly providers: Array<Provider>;
|
||||
perform(method: string, params: any): any;
|
||||
}
|
10
src/providers/index.d.ts
vendored
10
src/providers/index.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import { Provider, ProviderSigner } from './provider';
|
||||
import { Network } from './networks';
|
||||
import { EtherscanProvider } from './etherscan-provider';
|
||||
import { FallbackProvider } from './fallback-provider';
|
||||
import { IpcProvider } from './ipc-provider';
|
||||
import { InfuraProvider } from './infura-provider';
|
||||
import { JsonRpcProvider } from './json-rpc-provider';
|
||||
import { Web3Provider } from './web3-provider';
|
||||
declare function getDefaultProvider(network?: Network | string): FallbackProvider;
|
||||
export { Provider, getDefaultProvider, ProviderSigner, FallbackProvider, EtherscanProvider, InfuraProvider, JsonRpcProvider, Web3Provider, IpcProvider };
|
9
src/providers/infura-provider.d.ts
vendored
9
src/providers/infura-provider.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
import { JsonRpcProvider, JsonRpcSigner } from './json-rpc-provider';
|
||||
import { Networkish } from './networks';
|
||||
export declare class InfuraProvider extends JsonRpcProvider {
|
||||
readonly apiAccessToken: string;
|
||||
constructor(network?: Networkish, apiAccessToken?: string);
|
||||
_startPending(): void;
|
||||
getSigner(address?: string): JsonRpcSigner;
|
||||
listAccounts(): Promise<Array<string>>;
|
||||
}
|
7
src/providers/ipc-provider.d.ts
vendored
7
src/providers/ipc-provider.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import { JsonRpcProvider } from './json-rpc-provider';
|
||||
import { Networkish } from './networks';
|
||||
export declare class IpcProvider extends JsonRpcProvider {
|
||||
readonly path: string;
|
||||
constructor(path: string, network?: Networkish);
|
||||
send(method: string, params: any): Promise<any>;
|
||||
}
|
30
src/providers/json-rpc-provider.d.ts
vendored
30
src/providers/json-rpc-provider.d.ts
vendored
@ -1,30 +0,0 @@
|
||||
import { Networkish } from './networks';
|
||||
import { BlockTag, Provider, TransactionRequest, TransactionResponse } from './provider';
|
||||
import { Signer } from '../wallet/wallet';
|
||||
import { BigNumber } from '../utils/bignumber';
|
||||
import { Arrayish } from '../utils/bytes';
|
||||
import { ConnectionInfo } from '../utils/web';
|
||||
export declare function hexlifyTransaction(transaction: TransactionRequest): any;
|
||||
export declare class JsonRpcSigner extends Signer {
|
||||
readonly provider: JsonRpcProvider;
|
||||
private _address;
|
||||
constructor(provider: JsonRpcProvider, address?: string);
|
||||
readonly address: string;
|
||||
getAddress(): Promise<string>;
|
||||
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
||||
getTransactionCount(blockTag: any): Promise<number>;
|
||||
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse>;
|
||||
signMessage(message: Arrayish | string): Promise<string>;
|
||||
unlock(password: any): Promise<boolean>;
|
||||
}
|
||||
export declare class JsonRpcProvider extends Provider {
|
||||
readonly connection: ConnectionInfo;
|
||||
private _pendingFilter;
|
||||
constructor(url?: ConnectionInfo | string, network?: Networkish);
|
||||
getSigner(address: string): JsonRpcSigner;
|
||||
listAccounts(): Promise<Array<string>>;
|
||||
send(method: string, params: any): Promise<any>;
|
||||
perform(method: string, params: any): Promise<any>;
|
||||
_startPending(): void;
|
||||
_stopPending(): void;
|
||||
}
|
13
src/providers/networks.d.ts
vendored
13
src/providers/networks.d.ts
vendored
@ -1,13 +0,0 @@
|
||||
export declare type Network = {
|
||||
name: string;
|
||||
chainId: number;
|
||||
ensAddress?: string;
|
||||
};
|
||||
export declare type Networkish = Network | string | number;
|
||||
/**
|
||||
* getNetwork
|
||||
*
|
||||
* Converts a named common networks or chain ID (network ID) to a Network
|
||||
* and verifies a network is a valid Network..
|
||||
*/
|
||||
export declare function getNetwork(network: Networkish): Network;
|
133
src/providers/provider.d.ts
vendored
133
src/providers/provider.d.ts
vendored
@ -1,133 +0,0 @@
|
||||
import { Signer } from '../wallet/wallet';
|
||||
import { BigNumber, BigNumberish } from '../utils/bignumber';
|
||||
import { Arrayish } from '../utils/bytes';
|
||||
import { Network, Networkish } from './networks';
|
||||
import { SignDigestFunc, Transaction } from '../utils/transaction';
|
||||
export declare type BlockTag = string | number;
|
||||
export interface Block {
|
||||
hash: string;
|
||||
parentHash: string;
|
||||
number: number;
|
||||
timestamp: number;
|
||||
nonce: string;
|
||||
difficulty: number;
|
||||
gasLimit: BigNumber;
|
||||
gasUsed: BigNumber;
|
||||
miner: string;
|
||||
extraData: string;
|
||||
transactions: Array<string>;
|
||||
}
|
||||
export declare type TransactionRequest = {
|
||||
to?: string | Promise<string>;
|
||||
from?: string | Promise<string>;
|
||||
nonce?: number | string | Promise<number | string>;
|
||||
gasLimit?: BigNumberish | Promise<BigNumberish>;
|
||||
gasPrice?: BigNumberish | Promise<BigNumberish>;
|
||||
data?: Arrayish | Promise<Arrayish>;
|
||||
value?: BigNumberish | Promise<BigNumberish>;
|
||||
chainId?: number | Promise<number>;
|
||||
};
|
||||
export interface TransactionResponse extends Transaction {
|
||||
blockNumber?: number;
|
||||
blockHash?: string;
|
||||
timestamp?: number;
|
||||
from: string;
|
||||
wait: (timeout?: number) => Promise<TransactionResponse>;
|
||||
}
|
||||
export interface TransactionReceipt {
|
||||
contractAddress?: string;
|
||||
transactionIndex?: number;
|
||||
root?: string;
|
||||
gasUsed?: BigNumber;
|
||||
logsBloom?: string;
|
||||
blockHash?: string;
|
||||
transactionHash?: string;
|
||||
logs?: Array<Log>;
|
||||
blockNumber?: number;
|
||||
cumulativeGasUsed?: BigNumber;
|
||||
status?: number;
|
||||
}
|
||||
export declare type Filter = {
|
||||
fromBlock?: BlockTag;
|
||||
toBlock?: BlockTag;
|
||||
address?: string;
|
||||
topics?: Array<any>;
|
||||
};
|
||||
export interface Log {
|
||||
blockNumber?: number;
|
||||
blockHash?: string;
|
||||
transactionIndex?: number;
|
||||
removed?: boolean;
|
||||
address: string;
|
||||
data?: string;
|
||||
topics?: Array<string>;
|
||||
transactionHash?: string;
|
||||
logIndex?: number;
|
||||
}
|
||||
export declare function checkTransactionResponse(transaction: any): TransactionResponse;
|
||||
export declare class ProviderSigner extends Signer {
|
||||
readonly provider: Provider;
|
||||
readonly signDigest: SignDigestFunc;
|
||||
private _addressPromise;
|
||||
constructor(address: string | Promise<string>, signDigest: SignDigestFunc, provider: Provider);
|
||||
getAddress(): Promise<string>;
|
||||
signMessage(message: Arrayish | string): Promise<string>;
|
||||
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse>;
|
||||
}
|
||||
export declare class Provider {
|
||||
private _network;
|
||||
private _events;
|
||||
protected _emitted: any;
|
||||
private _pollingInterval;
|
||||
private _poller;
|
||||
private _lastBlockNumber;
|
||||
private _balances;
|
||||
/**
|
||||
* ready
|
||||
*
|
||||
* A Promise<Network> that resolves only once the provider is ready.
|
||||
*
|
||||
* Sub-classes that call the super with a network without a chainId
|
||||
* MUST set this. Standard named networks have a known chainId.
|
||||
*
|
||||
*/
|
||||
protected ready: Promise<Network>;
|
||||
constructor(network: Networkish | Promise<Network>);
|
||||
private _doPoll;
|
||||
resetEventsBlock(blockNumber: number): void;
|
||||
readonly network: Network;
|
||||
getNetwork(): Promise<Network>;
|
||||
readonly blockNumber: number;
|
||||
polling: boolean;
|
||||
pollingInterval: number;
|
||||
waitForTransaction(transactionHash: string, timeout?: number): Promise<TransactionResponse>;
|
||||
getBlockNumber(): Promise<number>;
|
||||
getGasPrice(): Promise<BigNumber>;
|
||||
getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
|
||||
getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
|
||||
getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
|
||||
getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
|
||||
sendTransaction(signedTransaction: string | Promise<string>): Promise<TransactionResponse>;
|
||||
call(transaction: TransactionRequest): Promise<string>;
|
||||
estimateGas(transaction: TransactionRequest): Promise<BigNumber>;
|
||||
getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
|
||||
getTransaction(transactionHash: string): Promise<TransactionResponse>;
|
||||
getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
|
||||
getLogs(filter: Filter): Promise<Array<Log>>;
|
||||
getEtherPrice(): Promise<number>;
|
||||
_resolveNames(object: any, keys: Array<string>): Promise<any>;
|
||||
_getResolver(name: string): Promise<string>;
|
||||
resolveName(name: string | Promise<string>): Promise<string>;
|
||||
lookupAddress(address: string | Promise<string>): Promise<string>;
|
||||
doPoll(): void;
|
||||
perform(method: string, params: any): Promise<any>;
|
||||
_startPending(): void;
|
||||
_stopPending(): void;
|
||||
on(eventName: any, listener: any): Provider;
|
||||
once(eventName: any, listener: any): Provider;
|
||||
emit(eventName: any, ...args: any[]): boolean;
|
||||
listenerCount(eventName?: any): number;
|
||||
listeners(eventName: any): Array<any>;
|
||||
removeAllListeners(eventName: any): Provider;
|
||||
removeListener(eventName: any, listener: any): Provider;
|
||||
}
|
14
src/providers/web3-provider.d.ts
vendored
14
src/providers/web3-provider.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
import { Networkish } from './networks';
|
||||
import { JsonRpcProvider } from './json-rpc-provider';
|
||||
export declare type Callback = (error: any, response: any) => void;
|
||||
export declare type AsyncProvider = {
|
||||
isMetaMask: boolean;
|
||||
host?: string;
|
||||
path?: string;
|
||||
sendAsync: (request: any, callback: Callback) => void;
|
||||
};
|
||||
export declare class Web3Provider extends JsonRpcProvider {
|
||||
readonly _web3Provider: AsyncProvider;
|
||||
constructor(web3Provider: AsyncProvider, network?: Networkish);
|
||||
send(method: string, params: any): Promise<any>;
|
||||
}
|
33
src/utils/abi-coder.d.ts
vendored
33
src/utils/abi-coder.d.ts
vendored
@ -1,33 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare type CoerceFunc = (type: string, value: any) => any;
|
||||
export declare type ParamType = {
|
||||
name?: string;
|
||||
type: string;
|
||||
indexed?: boolean;
|
||||
components?: Array<any>;
|
||||
};
|
||||
export declare const defaultCoerceFunc: CoerceFunc;
|
||||
export declare type EventFragment = {
|
||||
type: string;
|
||||
name: string;
|
||||
anonymous: boolean;
|
||||
inputs: Array<ParamType>;
|
||||
};
|
||||
export declare type FunctionFragment = {
|
||||
type: string;
|
||||
name: string;
|
||||
constant: boolean;
|
||||
inputs: Array<ParamType>;
|
||||
outputs: Array<ParamType>;
|
||||
payable: boolean;
|
||||
stateMutability: string;
|
||||
};
|
||||
export declare function parseParamType(type: string): ParamType;
|
||||
export declare function parseSignature(fragment: string): EventFragment | FunctionFragment;
|
||||
export declare class AbiCoder {
|
||||
readonly coerceFunc: CoerceFunc;
|
||||
constructor(coerceFunc?: CoerceFunc);
|
||||
encode(types: Array<string | ParamType>, values: Array<any>): string;
|
||||
decode(types: Array<string | ParamType>, data: Arrayish): any;
|
||||
}
|
||||
export declare const defaultAbiCoder: AbiCoder;
|
8
src/utils/address.d.ts
vendored
8
src/utils/address.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { BigNumber } from './bignumber';
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function getAddress(address: string): string;
|
||||
export declare function getIcapAddress(address: string): string;
|
||||
export declare function getContractAddress(transaction: {
|
||||
from: string;
|
||||
nonce: Arrayish | BigNumber | number;
|
||||
}): string;
|
3
src/utils/base64.d.ts
vendored
3
src/utils/base64.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function decode(textData: string): Uint8Array;
|
||||
export declare function encode(data: Arrayish): string;
|
31
src/utils/bignumber.d.ts
vendored
31
src/utils/bignumber.d.ts
vendored
@ -1,31 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare type BigNumberish = BigNumber | string | number | Arrayish;
|
||||
export declare class BigNumber {
|
||||
private readonly _bn;
|
||||
constructor(value: BigNumberish);
|
||||
fromTwos(value: BigNumberish): BigNumber;
|
||||
toTwos(value: BigNumberish): BigNumber;
|
||||
add(other: BigNumberish): BigNumber;
|
||||
sub(other: BigNumberish): BigNumber;
|
||||
div(other: BigNumberish): BigNumber;
|
||||
mul(other: BigNumberish): BigNumber;
|
||||
mod(other: BigNumberish): BigNumber;
|
||||
pow(other: BigNumberish): BigNumber;
|
||||
maskn(value: BigNumberish): BigNumber;
|
||||
eq(other: BigNumberish): boolean;
|
||||
lt(other: BigNumberish): boolean;
|
||||
lte(other: BigNumberish): boolean;
|
||||
gt(other: BigNumberish): boolean;
|
||||
gte(other: BigNumberish): boolean;
|
||||
isZero(): boolean;
|
||||
toNumber(): number;
|
||||
toString(): string;
|
||||
toHexString(): string;
|
||||
}
|
||||
export declare function isBigNumber(value: any): boolean;
|
||||
export declare function bigNumberify(value: BigNumberish): BigNumber;
|
||||
export declare const ConstantNegativeOne: BigNumber;
|
||||
export declare const ConstantZero: BigNumber;
|
||||
export declare const ConstantOne: BigNumber;
|
||||
export declare const ConstantTwo: BigNumber;
|
||||
export declare const ConstantWeiPerEther: BigNumber;
|
1
src/utils/browser-base64.d.ts
vendored
1
src/utils/browser-base64.d.ts
vendored
@ -1 +0,0 @@
|
||||
export {};
|
@ -1,21 +0,0 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var convert = require("./convert");
|
||||
module.exports = {
|
||||
decode: function (textData) {
|
||||
textData = atob(textData);
|
||||
var data = [];
|
||||
for (var i = 0; i < textData.length; i++) {
|
||||
data.push(textData.charCodeAt(i));
|
||||
}
|
||||
return convert.arrayify(data);
|
||||
},
|
||||
encode: function (data) {
|
||||
data = convert.arrayify(data);
|
||||
var textData = '';
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
textData += String.fromCharCode(data[i]);
|
||||
}
|
||||
return btoa(textData);
|
||||
}
|
||||
};
|
1
src/utils/browser-random-bytes.d.ts
vendored
1
src/utils/browser-random-bytes.d.ts
vendored
@ -1 +0,0 @@
|
||||
export {};
|
@ -1,38 +0,0 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var convert = require("./convert");
|
||||
var properties = require("./properties");
|
||||
var defineProperty = properties.defineProperty;
|
||||
var crypto = global.crypto || global.msCrypto;
|
||||
if (!crypto || !crypto.getRandomValues) {
|
||||
console.log('WARNING: Missing strong random number source; using weak randomBytes');
|
||||
crypto = {
|
||||
getRandomValues: function (buffer) {
|
||||
for (var round = 0; round < 20; round++) {
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
if (round) {
|
||||
buffer[i] ^= parseInt(256 * Math.random());
|
||||
}
|
||||
else {
|
||||
buffer[i] = parseInt(256 * Math.random());
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
},
|
||||
_weakCrypto: true
|
||||
};
|
||||
}
|
||||
function randomBytes(length) {
|
||||
if (length <= 0 || length > 1024 || parseInt(length) != length) {
|
||||
throw new Error('invalid length');
|
||||
}
|
||||
var result = new Uint8Array(length);
|
||||
crypto.getRandomValues(result);
|
||||
return convert.arrayify(result);
|
||||
}
|
||||
;
|
||||
if (crypto._weakCrypto === true) {
|
||||
defineProperty(randomBytes, '_weakCrypto', true);
|
||||
}
|
||||
module.exports = randomBytes;
|
20
src/utils/bytes.d.ts
vendored
20
src/utils/bytes.d.ts
vendored
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* Conversion Utilities
|
||||
*
|
||||
*/
|
||||
import { BigNumber } from './bignumber';
|
||||
import { Signature } from './secp256k1';
|
||||
export declare type Arrayish = string | ArrayLike<number>;
|
||||
export declare function isArrayish(value: any): boolean;
|
||||
export declare function arrayify(value: Arrayish | BigNumber): Uint8Array;
|
||||
export declare function concat(objects: Array<Arrayish>): Uint8Array;
|
||||
export declare function stripZeros(value: Arrayish): Uint8Array;
|
||||
export declare function padZeros(value: Arrayish, length: number): Uint8Array;
|
||||
export declare function isHexString(value: any, length?: number): boolean;
|
||||
export declare function hexlify(value: Arrayish | BigNumber | number): string;
|
||||
export declare function hexDataLength(data: string): number;
|
||||
export declare function hexDataSlice(data: string, offset: number, length?: number): string;
|
||||
export declare function hexStripZeros(value: string): string;
|
||||
export declare function hexZeroPad(value: string, length: number): string;
|
||||
export declare function splitSignature(signature: Arrayish): Signature;
|
||||
export declare function joinSignature(signature: Signature): string;
|
6
src/utils/contract-address.d.ts
vendored
6
src/utils/contract-address.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
import { BigNumber } from './bignumber';
|
||||
import { Arrayish } from './convert';
|
||||
export declare function getContractAddress(transaction: {
|
||||
from: string;
|
||||
nonce: Arrayish | BigNumber | number;
|
||||
}): string;
|
@ -1,18 +0,0 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var address_1 = require("./address");
|
||||
var convert_1 = require("./convert");
|
||||
var keccak256_1 = require("./keccak256");
|
||||
var rlp_1 = require("./rlp");
|
||||
// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
|
||||
function getContractAddress(transaction) {
|
||||
if (!transaction.from) {
|
||||
throw new Error('missing from address');
|
||||
}
|
||||
var nonce = transaction.nonce;
|
||||
return address_1.getAddress('0x' + keccak256_1.keccak256(rlp_1.encode([
|
||||
address_1.getAddress(transaction.from),
|
||||
convert_1.stripZeros(convert_1.hexlify(nonce))
|
||||
])).substring(26));
|
||||
}
|
||||
exports.getContractAddress = getContractAddress;
|
19
src/utils/convert.d.ts
vendored
19
src/utils/convert.d.ts
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Conversion Utilities
|
||||
*
|
||||
*/
|
||||
import { BigNumber } from './bignumber';
|
||||
import { Signature } from './secp256k1';
|
||||
export declare type Arrayish = string | ArrayLike<number>;
|
||||
export declare function isArrayish(value: any): boolean;
|
||||
export declare function arrayify(value: Arrayish | BigNumber): Uint8Array;
|
||||
export declare function concat(objects: Array<Arrayish>): Uint8Array;
|
||||
export declare function stripZeros(value: Arrayish): Uint8Array;
|
||||
export declare function padZeros(value: Arrayish, length: number): Uint8Array;
|
||||
export declare function isHexString(value: any, length?: number): boolean;
|
||||
export declare function hexlify(value: Arrayish | BigNumber | number): string;
|
||||
export declare function hexDataLength(data: string): number;
|
||||
export declare function hexDataSlice(data: string, offset: number, length?: number): string;
|
||||
export declare function hexStripZeros(value: string): string;
|
||||
export declare function hexZeroPad(value: string, length: number): string;
|
||||
export declare function splitSignature(signature: Arrayish): Signature;
|
@ -1,226 +0,0 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Conversion Utilities
|
||||
*
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var errors = require("./errors");
|
||||
function isBigNumber(value) {
|
||||
return !!value._bn;
|
||||
}
|
||||
function addSlice(array) {
|
||||
if (array.slice) {
|
||||
return array;
|
||||
}
|
||||
array.slice = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
return new Uint8Array(Array.prototype.slice.apply(array, args));
|
||||
};
|
||||
return array;
|
||||
}
|
||||
function isArrayish(value) {
|
||||
if (!value || parseInt(value.length) != value.length || typeof (value) === 'string') {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var v = value[i];
|
||||
if (v < 0 || v >= 256 || parseInt(v) != v) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.isArrayish = isArrayish;
|
||||
function arrayify(value) {
|
||||
if (value == null) {
|
||||
errors.throwError('cannot convert null value to array', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
if (isBigNumber(value)) {
|
||||
value = value.toHexString();
|
||||
}
|
||||
if (typeof (value) === 'string') {
|
||||
var match = value.match(/^(0x)?[0-9a-fA-F]*$/);
|
||||
if (!match) {
|
||||
errors.throwError('invalid hexidecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
if (match[1] !== '0x') {
|
||||
errors.throwError('hex string must have 0x prefix', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
value = value.substring(2);
|
||||
if (value.length % 2) {
|
||||
value = '0' + value;
|
||||
}
|
||||
var result = [];
|
||||
for (var i = 0; i < value.length; i += 2) {
|
||||
result.push(parseInt(value.substr(i, 2), 16));
|
||||
}
|
||||
return addSlice(new Uint8Array(result));
|
||||
}
|
||||
else if (typeof (value) === 'string') {
|
||||
}
|
||||
if (isArrayish(value)) {
|
||||
return addSlice(new Uint8Array(value));
|
||||
}
|
||||
errors.throwError('invalid arrayify value', null, { arg: 'value', value: value, type: typeof (value) });
|
||||
return null;
|
||||
}
|
||||
exports.arrayify = arrayify;
|
||||
function concat(objects) {
|
||||
var arrays = [];
|
||||
var length = 0;
|
||||
for (var i = 0; i < objects.length; i++) {
|
||||
var object = arrayify(objects[i]);
|
||||
arrays.push(object);
|
||||
length += object.length;
|
||||
}
|
||||
var result = new Uint8Array(length);
|
||||
var offset = 0;
|
||||
for (var i = 0; i < arrays.length; i++) {
|
||||
result.set(arrays[i], offset);
|
||||
offset += arrays[i].length;
|
||||
}
|
||||
return addSlice(result);
|
||||
}
|
||||
exports.concat = concat;
|
||||
function stripZeros(value) {
|
||||
var result = arrayify(value);
|
||||
if (result.length === 0) {
|
||||
return result;
|
||||
}
|
||||
// Find the first non-zero entry
|
||||
var start = 0;
|
||||
while (result[start] === 0) {
|
||||
start++;
|
||||
}
|
||||
// If we started with zeros, strip them
|
||||
if (start) {
|
||||
result = result.slice(start);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.stripZeros = stripZeros;
|
||||
function padZeros(value, length) {
|
||||
value = arrayify(value);
|
||||
if (length < value.length) {
|
||||
throw new Error('cannot pad');
|
||||
}
|
||||
var result = new Uint8Array(length);
|
||||
result.set(value, length - value.length);
|
||||
return addSlice(result);
|
||||
}
|
||||
exports.padZeros = padZeros;
|
||||
function isHexString(value, length) {
|
||||
if (typeof (value) !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
||||
return false;
|
||||
}
|
||||
if (length && value.length !== 2 + 2 * length) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.isHexString = isHexString;
|
||||
var HexCharacters = '0123456789abcdef';
|
||||
function hexlify(value) {
|
||||
if (isBigNumber(value)) {
|
||||
return value.toHexString();
|
||||
}
|
||||
if (typeof (value) === 'number') {
|
||||
if (value < 0) {
|
||||
errors.throwError('cannot hexlify negative value', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
var hex = '';
|
||||
while (value) {
|
||||
hex = HexCharacters[value & 0x0f] + hex;
|
||||
value = Math.trunc(value / 16);
|
||||
}
|
||||
if (hex.length) {
|
||||
if (hex.length % 2) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
return '0x' + hex;
|
||||
}
|
||||
return '0x00';
|
||||
}
|
||||
if (typeof (value) === 'string') {
|
||||
var match = value.match(/^(0x)?[0-9a-fA-F]*$/);
|
||||
if (!match) {
|
||||
errors.throwError('invalid hexidecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
if (match[1] !== '0x') {
|
||||
errors.throwError('hex string must have 0x prefix', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
if (value.length % 2) {
|
||||
value = '0x0' + value.substring(2);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (isArrayish(value)) {
|
||||
var result = [];
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var v = value[i];
|
||||
result.push(HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]);
|
||||
}
|
||||
return '0x' + result.join('');
|
||||
}
|
||||
errors.throwError('invalid hexlify value', null, { arg: 'value', value: value });
|
||||
return 'never';
|
||||
}
|
||||
exports.hexlify = hexlify;
|
||||
function hexDataLength(data) {
|
||||
if (!isHexString(data) || (data.length % 2) !== 0) {
|
||||
return null;
|
||||
}
|
||||
return (data.length - 2) / 2;
|
||||
}
|
||||
exports.hexDataLength = hexDataLength;
|
||||
function hexDataSlice(data, offset, length) {
|
||||
if (!isHexString(data)) {
|
||||
errors.throwError('invalid hex data', errors.INVALID_ARGUMENT, { arg: 'value', value: data });
|
||||
}
|
||||
if ((data.length % 2) !== 0) {
|
||||
errors.throwError('hex data length must be even', errors.INVALID_ARGUMENT, { arg: 'value', value: data });
|
||||
}
|
||||
offset = 2 + 2 * offset;
|
||||
if (length != null) {
|
||||
return '0x' + data.substring(offset, offset + 2 * length);
|
||||
}
|
||||
return '0x' + data.substring(offset);
|
||||
}
|
||||
exports.hexDataSlice = hexDataSlice;
|
||||
function hexStripZeros(value) {
|
||||
if (!isHexString(value)) {
|
||||
errors.throwError('invalid hex string', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
while (value.length > 3 && value.substring(0, 3) === '0x0') {
|
||||
value = '0x' + value.substring(3);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
exports.hexStripZeros = hexStripZeros;
|
||||
function hexZeroPad(value, length) {
|
||||
if (!isHexString(value)) {
|
||||
errors.throwError('invalid hex string', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
|
||||
}
|
||||
while (value.length < 2 * length + 2) {
|
||||
value = '0x0' + value.substring(2);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
exports.hexZeroPad = hexZeroPad;
|
||||
function splitSignature(signature) {
|
||||
var bytes = arrayify(signature);
|
||||
if (bytes.length !== 65) {
|
||||
throw new Error('invalid signature');
|
||||
}
|
||||
var v = bytes[64];
|
||||
if (v !== 27 && v !== 28) {
|
||||
v = 27 + (v % 2);
|
||||
}
|
||||
return {
|
||||
r: hexlify(bytes.slice(0, 32)),
|
||||
s: hexlify(bytes.slice(32, 64)),
|
||||
recoveryParam: (v - 27),
|
||||
v: v
|
||||
};
|
||||
}
|
||||
exports.splitSignature = splitSignature;
|
0
src/utils/empty.d.ts
vendored
0
src/utils/empty.d.ts
vendored
@ -1 +0,0 @@
|
||||
module.exports = undefined;
|
11
src/utils/errors.d.ts
vendored
11
src/utils/errors.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export declare const UNKNOWN_ERROR = "UNKNOWN_ERROR";
|
||||
export declare const NOT_IMPLEMENTED = "NOT_IMPLEMENTED";
|
||||
export declare const MISSING_NEW = "MISSING_NEW";
|
||||
export declare const CALL_EXCEPTION = "CALL_EXCEPTION";
|
||||
export declare const INVALID_ARGUMENT = "INVALID_ARGUMENT";
|
||||
export declare const MISSING_ARGUMENT = "MISSING_ARGUMENT";
|
||||
export declare const UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT";
|
||||
export declare const NUMERIC_FAULT = "NUMERIC_FAULT";
|
||||
export declare const UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION";
|
||||
export declare function throwError(message: string, code: string, params: any): never;
|
||||
export declare function checkNew(self: any, kind: any): void;
|
4
src/utils/hash.d.ts
vendored
4
src/utils/hash.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function namehash(name: string): string;
|
||||
export declare function id(text: string): string;
|
||||
export declare function hashMessage(message: Arrayish | string): string;
|
2
src/utils/hmac.d.ts
vendored
2
src/utils/hmac.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function computeHmac(algorithm: string, key: Arrayish, data: Arrayish): Uint8Array;
|
1
src/utils/id.d.ts
vendored
1
src/utils/id.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare function id(text: string): string;
|
@ -1,8 +0,0 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var keccak256_1 = require("./keccak256");
|
||||
var utf8_1 = require("./utf8");
|
||||
function id(text) {
|
||||
return keccak256_1.keccak256(utf8_1.toUtf8Bytes(text));
|
||||
}
|
||||
exports.id = id;
|
19
src/utils/index.d.ts
vendored
19
src/utils/index.d.ts
vendored
@ -1,19 +0,0 @@
|
||||
import { getAddress, getContractAddress, getIcapAddress } from './address';
|
||||
import { AbiCoder, defaultAbiCoder, parseSignature, parseParamType } from './abi-coder';
|
||||
import * as base64 from './base64';
|
||||
import { BigNumber, bigNumberify } from './bignumber';
|
||||
import { arrayify, concat, hexlify, joinSignature, padZeros, splitSignature, stripZeros } from './bytes';
|
||||
import { hashMessage, id, namehash } from './hash';
|
||||
import { keccak256 } from './keccak256';
|
||||
import { sha256 } from './sha2';
|
||||
import { keccak256 as solidityKeccak256, pack as solidityPack, sha256 as soliditySha256 } from './solidity';
|
||||
import { randomBytes } from './random-bytes';
|
||||
import { defineFrozen, defineReadOnly, resolveProperties, shallowCopy } from './properties';
|
||||
import * as RLP from './rlp';
|
||||
import { toUtf8Bytes, toUtf8String } from './utf8';
|
||||
import { formatEther, parseEther, formatUnits, parseUnits } from './units';
|
||||
import { fetchJson } from './web';
|
||||
import { parse as parseTransaction } from './transaction';
|
||||
import * as errors from './errors';
|
||||
declare const etherSymbol = "\u039E";
|
||||
export { AbiCoder, defaultAbiCoder, parseSignature, parseParamType, RLP, fetchJson, defineReadOnly, defineFrozen, resolveProperties, shallowCopy, etherSymbol, arrayify, concat, padZeros, stripZeros, base64, bigNumberify, BigNumber, hexlify, toUtf8Bytes, toUtf8String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, errors };
|
2
src/utils/keccak256.d.ts
vendored
2
src/utils/keccak256.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function keccak256(data: Arrayish): string;
|
0
src/utils/messages.d.ts
vendored
0
src/utils/messages.d.ts
vendored
@ -1,31 +0,0 @@
|
||||
/*
|
||||
import { Arrayish, concat } from './bytes';
|
||||
export function hashMessage(message: Arrayish | string): string {
|
||||
var payload = concat([
|
||||
toUtf8Bytes('\x19Ethereum Signed Message:\n'),
|
||||
toUtf8Bytes(String(message.length)),
|
||||
((typeof(message) === 'string') ? toUtf8Bytes(message): message)
|
||||
]);
|
||||
return keccak256(payload);
|
||||
}
|
||||
|
||||
export verifyMessage(message: Arrayish | string, signature: string): string {
|
||||
signature = hexlify(signature);
|
||||
if (signature.length != 132) { throw new Error('invalid signature'); }
|
||||
var digest = Wallet.hashMessage(message);
|
||||
|
||||
var recoveryParam = parseInt(signature.substring(130), 16);
|
||||
if (recoveryParam >= 27) { recoveryParam -= 27; }
|
||||
if (recoveryParam < 0) { throw new Error('invalid signature'); }
|
||||
|
||||
return recoverAddress(
|
||||
digest,
|
||||
{
|
||||
r: signature.substring(0, 66),
|
||||
s: '0x' + signature.substring(66, 130),
|
||||
recoveryParam: recoveryParam
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
1
src/utils/namehash.d.ts
vendored
1
src/utils/namehash.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare function namehash(name: string): string;
|
@ -1,27 +0,0 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var bytes_1 = require("./bytes");
|
||||
var utf8_1 = require("./utf8");
|
||||
var keccak256_1 = require("./keccak256");
|
||||
var Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
var Partition = new RegExp("^((.*)\\.)?([^.]+)$");
|
||||
var UseSTD3ASCIIRules = new RegExp("^[a-z0-9.-]*$");
|
||||
function namehash(name) {
|
||||
name = name.toLowerCase();
|
||||
// Supporting the full UTF-8 space requires additional (and large)
|
||||
// libraries, so for now we simply do not support them.
|
||||
// It should be fairly easy in the future to support systems with
|
||||
// String.normalize, but that is future work.
|
||||
if (!name.match(UseSTD3ASCIIRules)) {
|
||||
throw new Error('contains invalid UseSTD3ASCIIRules characters');
|
||||
}
|
||||
var result = Zeros;
|
||||
while (name.length) {
|
||||
var partition = name.match(Partition);
|
||||
var label = utf8_1.toUtf8Bytes(partition[3]);
|
||||
result = keccak256_1.keccak256(bytes_1.concat([result, keccak256_1.keccak256(label)]));
|
||||
name = partition[2] || '';
|
||||
}
|
||||
return bytes_1.hexlify(result);
|
||||
}
|
||||
exports.namehash = namehash;
|
2
src/utils/pbkdf2.d.ts
vendored
2
src/utils/pbkdf2.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function pbkdf2(password: Arrayish, salt: Arrayish, iterations: number, keylen: number, hashAlgorithm: string): Uint8Array;
|
5
src/utils/properties.d.ts
vendored
5
src/utils/properties.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
export declare function defineReadOnly(object: any, name: string, value: any): void;
|
||||
export declare function defineFrozen(object: any, name: string, value: any): void;
|
||||
export declare function resolveProperties(object: any): Promise<any>;
|
||||
export declare function shallowCopy(object: any): any;
|
||||
export declare function jsonCopy(object: any): any;
|
1
src/utils/random-bytes.d.ts
vendored
1
src/utils/random-bytes.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare function randomBytes(length: number): Uint8Array;
|
3
src/utils/rlp.d.ts
vendored
3
src/utils/rlp.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function encode(object: any): string;
|
||||
export declare function decode(data: Arrayish): any;
|
20
src/utils/secp256k1.d.ts
vendored
20
src/utils/secp256k1.d.ts
vendored
@ -1,20 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare const N: string;
|
||||
export interface Signature {
|
||||
r: string;
|
||||
s: string;
|
||||
recoveryParam: number;
|
||||
v?: number;
|
||||
}
|
||||
export declare class KeyPair {
|
||||
readonly privateKey: string;
|
||||
readonly publicKey: string;
|
||||
readonly compressedPublicKey: string;
|
||||
readonly publicKeyBytes: Uint8Array;
|
||||
constructor(privateKey: Arrayish);
|
||||
sign(digest: Arrayish): Signature;
|
||||
}
|
||||
export declare function recoverPublicKey(digest: Arrayish, signature: Signature): string;
|
||||
export declare function computePublicKey(key: Arrayish, compressed?: boolean): string;
|
||||
export declare function recoverAddress(digest: Arrayish, signature: Signature): string;
|
||||
export declare function computeAddress(key: string): string;
|
3
src/utils/sha2.d.ts
vendored
3
src/utils/sha2.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare function sha256(data: Arrayish): string;
|
||||
export declare function sha512(data: Arrayish): string;
|
3
src/utils/solidity.d.ts
vendored
3
src/utils/solidity.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export declare function pack(types: Array<string>, values: Array<any>): string;
|
||||
export declare function keccak256(types: Array<string>, values: Array<any>): string;
|
||||
export declare function sha256(types: Array<string>, values: Array<any>): string;
|
1
src/utils/throw-error.d.ts
vendored
1
src/utils/throw-error.d.ts
vendored
@ -1 +0,0 @@
|
||||
declare function throwError(message: any, params: any): void;
|
@ -1,9 +0,0 @@
|
||||
'use strict';
|
||||
function throwError(message, params) {
|
||||
var error = new Error(message);
|
||||
for (var key in params) {
|
||||
error[key] = params[key];
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
module.exports = throwError;
|
29
src/utils/transaction.d.ts
vendored
29
src/utils/transaction.d.ts
vendored
@ -1,29 +0,0 @@
|
||||
import { BigNumber, BigNumberish } from './bignumber';
|
||||
import { Arrayish } from './bytes';
|
||||
import { Signature } from './secp256k1';
|
||||
export declare type UnsignedTransaction = {
|
||||
to?: string;
|
||||
nonce?: number;
|
||||
gasLimit?: BigNumberish;
|
||||
gasPrice?: BigNumberish;
|
||||
data?: Arrayish;
|
||||
value?: BigNumberish;
|
||||
chainId?: number;
|
||||
};
|
||||
export interface Transaction {
|
||||
hash?: string;
|
||||
to?: string;
|
||||
from?: string;
|
||||
nonce: number;
|
||||
gasLimit: BigNumber;
|
||||
gasPrice: BigNumber;
|
||||
data: string;
|
||||
value: BigNumber;
|
||||
chainId: number;
|
||||
r?: string;
|
||||
s?: string;
|
||||
v?: number;
|
||||
}
|
||||
export declare type SignDigestFunc = (digest: Arrayish) => Signature;
|
||||
export declare function sign(transaction: UnsignedTransaction, signDigest: SignDigestFunc): string;
|
||||
export declare function parse(rawTransaction: Arrayish): Transaction;
|
5
src/utils/units.d.ts
vendored
5
src/utils/units.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
import { BigNumber, BigNumberish } from './bignumber';
|
||||
export declare function formatUnits(value: BigNumberish, unitType?: string | number, options?: any): string;
|
||||
export declare function parseUnits(value: string, unitType?: string | number): BigNumber;
|
||||
export declare function formatEther(wei: BigNumberish, options: any): string;
|
||||
export declare function parseEther(ether: string): BigNumber;
|
10
src/utils/utf8.d.ts
vendored
10
src/utils/utf8.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import { Arrayish } from './bytes';
|
||||
export declare enum UnicodeNormalizationForm {
|
||||
current = "",
|
||||
NFC = "NFC",
|
||||
NFD = "NFD",
|
||||
NFKC = "NFKC",
|
||||
NFKD = "NFKD"
|
||||
}
|
||||
export declare function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8Array;
|
||||
export declare function toUtf8String(bytes: Arrayish): string;
|
8
src/utils/web.d.ts
vendored
8
src/utils/web.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
export declare type ConnectionInfo = {
|
||||
url: string;
|
||||
user?: string;
|
||||
password?: string;
|
||||
allowInsecure?: boolean;
|
||||
};
|
||||
export declare type ProcessFunc = (value: any) => any;
|
||||
export declare function fetchJson(url: string | ConnectionInfo, json: string, processFunc: ProcessFunc): Promise<any>;
|
29
src/wallet/hdnode.d.ts
vendored
29
src/wallet/hdnode.d.ts
vendored
@ -1,29 +0,0 @@
|
||||
import { Wordlist } from '../wordlists/wordlist';
|
||||
import { Arrayish } from '../utils/bytes';
|
||||
export declare const defaultPath = "m/44'/60'/0'/0/0";
|
||||
export declare class HDNode {
|
||||
private readonly keyPair;
|
||||
readonly privateKey: string;
|
||||
readonly publicKey: string;
|
||||
readonly mnemonic: string;
|
||||
readonly path: string;
|
||||
readonly chainCode: string;
|
||||
readonly index: number;
|
||||
readonly depth: number;
|
||||
/**
|
||||
* This constructor should not be called directly.
|
||||
*
|
||||
* Please use:
|
||||
* - fromMnemonic
|
||||
* - fromSeed
|
||||
*/
|
||||
constructor(privateKey: Arrayish, chainCode: Uint8Array, index: number, depth: number, mnemonic: string, path: string);
|
||||
private _derive;
|
||||
derivePath(path: string): HDNode;
|
||||
}
|
||||
export declare function fromMnemonic(mnemonic: string, wordlist?: Wordlist): HDNode;
|
||||
export declare function fromSeed(seed: Arrayish): HDNode;
|
||||
export declare function mnemonicToSeed(mnemonic: string, password?: string): string;
|
||||
export declare function mnemonicToEntropy(mnemonic: string, wordlist?: Wordlist): string;
|
||||
export declare function entropyToMnemonic(entropy: Arrayish, wordlist?: Wordlist): string;
|
||||
export declare function isValidMnemonic(mnemonic: string, wordlist?: Wordlist): boolean;
|
4
src/wallet/index.d.ts
vendored
4
src/wallet/index.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import { Wallet } from './wallet';
|
||||
import * as HDNode from './hdnode';
|
||||
import { SigningKey } from './signing-key';
|
||||
export { HDNode, SigningKey, Wallet };
|
8
src/wallet/lang-en.d.ts
vendored
8
src/wallet/lang-en.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Wordlist } from './hdnode';
|
||||
declare class LangEn extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
declare const langEn: LangEn;
|
||||
export { langEn };
|
File diff suppressed because one or more lines are too long
17
src/wallet/secp256k1.d.ts
vendored
17
src/wallet/secp256k1.d.ts
vendored
@ -1,17 +0,0 @@
|
||||
import { Arrayish } from '../utils/convert';
|
||||
export declare type Signature = {
|
||||
r: string;
|
||||
s: string;
|
||||
recoveryParam: number;
|
||||
};
|
||||
export declare class KeyPair {
|
||||
readonly privateKey: string;
|
||||
readonly publicKey: string;
|
||||
readonly compressedPublicKey: string;
|
||||
readonly publicKeyBytes: Uint8Array;
|
||||
constructor(privateKey: Arrayish);
|
||||
sign(digest: Arrayish): Signature;
|
||||
}
|
||||
export declare function recoverPublicKey(digest: Arrayish, signature: Signature): string;
|
||||
export declare function computePublicKey(key: Arrayish, compressed?: boolean): string;
|
||||
export declare const N: string;
|
@ -1,68 +0,0 @@
|
||||
'use strict';
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var convert_1 = require("../utils/convert");
|
||||
var properties_1 = require("../utils/properties");
|
||||
var errors = __importStar(require("../utils/errors"));
|
||||
var elliptic = __importStar(require("elliptic"));
|
||||
var curve = new elliptic.ec('secp256k1');
|
||||
var KeyPair = /** @class */ (function () {
|
||||
function KeyPair(privateKey) {
|
||||
var keyPair = curve.keyFromPrivate(convert_1.arrayify(privateKey));
|
||||
properties_1.defineReadOnly(this, 'privateKey', convert_1.hexlify(keyPair.priv.toArray('be', 32)));
|
||||
properties_1.defineReadOnly(this, 'publicKey', '0x' + keyPair.getPublic(false, 'hex'));
|
||||
properties_1.defineReadOnly(this, 'compressedPublicKey', '0x' + keyPair.getPublic(true, 'hex'));
|
||||
properties_1.defineReadOnly(this, 'publicKeyBytes', keyPair.getPublic().encode(null, true));
|
||||
}
|
||||
KeyPair.prototype.sign = function (digest) {
|
||||
var keyPair = curve.keyFromPrivate(convert_1.arrayify(this.privateKey));
|
||||
var signature = keyPair.sign(convert_1.arrayify(digest), { canonical: true });
|
||||
return {
|
||||
recoveryParam: signature.recoveryParam,
|
||||
r: '0x' + signature.r.toString(16),
|
||||
s: '0x' + signature.s.toString(16)
|
||||
};
|
||||
};
|
||||
return KeyPair;
|
||||
}());
|
||||
exports.KeyPair = KeyPair;
|
||||
function recoverPublicKey(digest, signature) {
|
||||
var sig = {
|
||||
r: convert_1.arrayify(signature.r),
|
||||
s: convert_1.arrayify(signature.s)
|
||||
};
|
||||
return '0x' + curve.recoverPubKey(convert_1.arrayify(digest), sig, signature.recoveryParam).encode('hex', false);
|
||||
}
|
||||
exports.recoverPublicKey = recoverPublicKey;
|
||||
function computePublicKey(key, compressed) {
|
||||
var bytes = convert_1.arrayify(key);
|
||||
if (bytes.length === 32) {
|
||||
var keyPair = new KeyPair(bytes);
|
||||
if (compressed) {
|
||||
return keyPair.compressedPublicKey;
|
||||
}
|
||||
return keyPair.publicKey;
|
||||
}
|
||||
else if (bytes.length === 33) {
|
||||
if (compressed) {
|
||||
return convert_1.hexlify(bytes);
|
||||
}
|
||||
return '0x' + curve.keyFromPublic(bytes).getPublic(false, 'hex');
|
||||
}
|
||||
else if (bytes.length === 65) {
|
||||
if (!compressed) {
|
||||
return convert_1.hexlify(bytes);
|
||||
}
|
||||
return '0x' + curve.keyFromPublic(bytes).getPublic(true, 'hex');
|
||||
}
|
||||
errors.throwError('invalid public or private key', errors.INVALID_ARGUMENT, { arg: 'key', value: '[REDACTED]' });
|
||||
return null;
|
||||
}
|
||||
exports.computePublicKey = computePublicKey;
|
||||
exports.N = '0x' + curve.n.toString(16);
|
10
src/wallet/secret-storage.d.ts
vendored
10
src/wallet/secret-storage.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import { Arrayish } from '../utils/bytes';
|
||||
import { SigningKey } from './signing-key';
|
||||
export interface ProgressCallback {
|
||||
(percent: number): void;
|
||||
}
|
||||
export declare function isCrowdsaleWallet(json: string): boolean;
|
||||
export declare function isValidWallet(json: string): boolean;
|
||||
export declare function decryptCrowdsale(json: string, password: Arrayish | string): SigningKey;
|
||||
export declare function decrypt(json: string, password: any, progressCallback?: ProgressCallback): Promise<SigningKey>;
|
||||
export declare function encrypt(privateKey: Arrayish | SigningKey, password: Arrayish | string, options?: any, progressCallback?: ProgressCallback): Promise<string>;
|
15
src/wallet/signing-key.d.ts
vendored
15
src/wallet/signing-key.d.ts
vendored
@ -1,15 +0,0 @@
|
||||
import { Arrayish } from '../utils/bytes';
|
||||
import { HDNode } from './hdnode';
|
||||
import { Signature } from '../utils/secp256k1';
|
||||
export declare class SigningKey {
|
||||
readonly privateKey: string;
|
||||
readonly publicKey: string;
|
||||
readonly address: string;
|
||||
readonly mnemonic: string;
|
||||
readonly path: string;
|
||||
private readonly keyPair;
|
||||
constructor(privateKey: Arrayish | HDNode);
|
||||
signDigest(digest: Arrayish): Signature;
|
||||
}
|
||||
export declare function recoverAddress(digest: Arrayish, signature: Signature): string;
|
||||
export declare function computeAddress(key: string): string;
|
49
src/wallet/wallet.d.ts
vendored
49
src/wallet/wallet.d.ts
vendored
@ -1,49 +0,0 @@
|
||||
import { HDNode } from './hdnode';
|
||||
import { ProgressCallback } from './secret-storage';
|
||||
import { SigningKey } from './signing-key';
|
||||
import { BlockTag, Provider, TransactionRequest, TransactionResponse } from '../providers/provider';
|
||||
import { Wordlist } from '../wordlists/wordlist';
|
||||
import { BigNumber, BigNumberish } from '../utils/bignumber';
|
||||
import { Arrayish } from '../utils/bytes';
|
||||
export declare abstract class Signer {
|
||||
provider?: Provider;
|
||||
abstract getAddress(): Promise<string>;
|
||||
abstract signMessage(transaction: Arrayish | string): Promise<string>;
|
||||
abstract sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse>;
|
||||
}
|
||||
export declare class Wallet extends Signer {
|
||||
readonly provider: Provider;
|
||||
private readonly signingKey;
|
||||
constructor(privateKey: SigningKey | HDNode | Arrayish, provider?: Provider);
|
||||
readonly address: string;
|
||||
readonly mnemonic: string;
|
||||
readonly path: string;
|
||||
readonly privateKey: string;
|
||||
/**
|
||||
* Create a new instance of this Wallet connected to provider.
|
||||
*/
|
||||
connect(provider: Provider): Wallet;
|
||||
getAddress(): Promise<string>;
|
||||
sign(transaction: TransactionRequest): Promise<string>;
|
||||
signMessage(message: Arrayish | string): Promise<string>;
|
||||
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
||||
getTransactionCount(blockTag?: BlockTag): Promise<number>;
|
||||
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse>;
|
||||
send(addressOrName: string, amountWei: BigNumberish, options: any): Promise<TransactionResponse>;
|
||||
encrypt(password: Arrayish | string, options: any, progressCallback: ProgressCallback): Promise<string>;
|
||||
/**
|
||||
* Static methods to create Wallet instances.
|
||||
*/
|
||||
static createRandom(options: any): Wallet;
|
||||
static fromEncryptedWallet(json: string, password: Arrayish, progressCallback: ProgressCallback): Promise<Wallet>;
|
||||
static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet;
|
||||
static fromBrainWallet(username: Arrayish | string, password: Arrayish | string, progressCallback: ProgressCallback): Promise<Wallet>;
|
||||
/**
|
||||
* Determine if this is an encryped JSON wallet.
|
||||
*/
|
||||
static isEncryptedWallet(json: string): boolean;
|
||||
/**
|
||||
* Verify a signed message, returning the address of the signer.
|
||||
*/
|
||||
static verifyMessage(message: Arrayish | string, signature: string): string;
|
||||
}
|
2
src/wallet/words.d.ts
vendored
2
src/wallet/words.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export declare function getWord(index: number): string;
|
||||
export declare function getWordIndex(word: string): number;
|
File diff suppressed because one or more lines are too long
8
src/wordlists/lang-en.d.ts
vendored
8
src/wordlists/lang-en.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Wordlist } from './wordlist';
|
||||
declare class LangEn extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
declare const langEn: LangEn;
|
||||
export { langEn };
|
8
src/wordlists/lang-it.d.ts
vendored
8
src/wordlists/lang-it.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Wordlist } from './wordlist';
|
||||
declare class LangIt extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
declare const langIt: LangIt;
|
||||
export { langIt };
|
10
src/wordlists/lang-ja.d.ts
vendored
10
src/wordlists/lang-ja.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import { Wordlist } from './wordlist';
|
||||
declare class LangJa extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: any): string;
|
||||
getWordIndex(word: any): number;
|
||||
split(mnemonic: string): Array<string>;
|
||||
join(words: Array<string>): string;
|
||||
}
|
||||
declare const langJa: LangJa;
|
||||
export { langJa };
|
8
src/wordlists/lang-ko.d.ts
vendored
8
src/wordlists/lang-ko.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Wordlist } from './wordlist';
|
||||
declare class LangKo extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
declare const langKo: LangKo;
|
||||
export { langKo };
|
8
src/wordlists/lang-kr.d.ts
vendored
8
src/wordlists/lang-kr.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Wordlist } from './wordlist';
|
||||
declare class LangKr extends Wordlist {
|
||||
constructor();
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
}
|
||||
declare const langKr: LangKr;
|
||||
export { langKr };
|
File diff suppressed because one or more lines are too long
11
src/wordlists/lang-zh.d.ts
vendored
11
src/wordlists/lang-zh.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
import { Wordlist } from './wordlist';
|
||||
declare class LangZh extends Wordlist {
|
||||
private _country;
|
||||
constructor(country: any);
|
||||
getWord(index: number): string;
|
||||
getWordIndex(word: string): number;
|
||||
split(mnemonic: string): Array<string>;
|
||||
}
|
||||
declare const langZhCn: LangZh;
|
||||
declare const langZhTw: LangZh;
|
||||
export { langZhCn, langZhTw };
|
9
src/wordlists/wordlist.d.ts
vendored
9
src/wordlists/wordlist.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
export declare abstract class Wordlist {
|
||||
locale: string;
|
||||
constructor(locale: string);
|
||||
abstract getWord(index: number): string;
|
||||
abstract getWordIndex(word: string): number;
|
||||
split(mnemonic: string): Array<string>;
|
||||
join(words: Array<string>): string;
|
||||
}
|
||||
export declare function register(lang: any): void;
|
@ -6,7 +6,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
var utils = require('./utils');
|
||||
|
@ -6,7 +6,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
var utils = require('./utils');
|
||||
|
@ -6,7 +6,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
var provider = new ethers.providers.InfuraProvider('rinkeby');
|
||||
|
@ -6,7 +6,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
var utils = require('./utils');
|
||||
@ -68,8 +68,8 @@ function testEasySeed(lang, locale) {
|
||||
});
|
||||
}
|
||||
|
||||
testEasySeed(require('../src/wordlists/lang-ja').langJa, 'ja');
|
||||
testEasySeed(require('../src/wordlists/lang-zh').langZhCn, 'zh_cn');
|
||||
testEasySeed(require('../src/wordlists/lang-zh').langZhTw, 'zh_tw');
|
||||
testEasySeed(require('../src/wordlists/lang-it').langIt, 'it');
|
||||
testEasySeed(require('../src/wordlists/lang-ko').langKo, 'ko');
|
||||
testEasySeed(require('../wordlists/lang-ja').langJa, 'ja');
|
||||
testEasySeed(require('../wordlists/lang-zh').langZhCn, 'zh_cn');
|
||||
testEasySeed(require('../wordlists/lang-zh').langZhTw, 'zh_tw');
|
||||
testEasySeed(require('../wordlists/lang-it').langIt, 'it');
|
||||
testEasySeed(require('../wordlists/lang-ko').langKo, 'ko');
|
||||
|
@ -7,7 +7,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
var providers = ethers.providers;
|
||||
|
@ -6,7 +6,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
var utils = require('./utils');
|
||||
|
@ -7,7 +7,7 @@ if (global.ethers) {
|
||||
console.log('Using global ethers; ' + __filename);
|
||||
var ethers = global.ethers;
|
||||
} else {
|
||||
var ethers = require('../src');
|
||||
var ethers = require('..');
|
||||
}
|
||||
|
||||
describe('Test Brain Wallets', function() {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user