Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9d9c23e3
Commit
9d9c23e3
authored
Feb 02, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common cleanup
parent
011fdd91
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
110 deletions
+114
-110
ethereum.js
dist/ethereum.js
+55
-53
ethereum.js.map
dist/ethereum.js.map
+4
-4
ethereum.min.js
dist/ethereum.min.js
+1
-1
const.js
lib/const.js
+23
-0
utils.js
lib/utils.js
+30
-1
web3.js
lib/web3.js
+1
-51
No files found.
dist/ethereum.js
View file @
9d9c23e3
...
@@ -238,9 +238,32 @@ if ("build" !== 'build') {/*
...
@@ -238,9 +238,32 @@ if ("build" !== 'build') {/*
var BigNumber = require('bignumber.js'); // jshint ignore:line
var BigNumber = require('bignumber.js'); // jshint ignore:line
*/
}
*/
}
var
ETH_UNITS
=
[
'wei'
,
'Kwei'
,
'Mwei'
,
'Gwei'
,
'szabo'
,
'finney'
,
'ether'
,
'grand'
,
'Mether'
,
'Gether'
,
'Tether'
,
'Pether'
,
'Eether'
,
'Zether'
,
'Yether'
,
'Nether'
,
'Dether'
,
'Vether'
,
'Uether'
];
module
.
exports
=
{
module
.
exports
=
{
ETH_PADDING
:
32
,
ETH_PADDING
:
32
,
ETH_SIGNATURE_LENGTH
:
4
,
ETH_SIGNATURE_LENGTH
:
4
,
ETH_UNITS
:
ETH_UNITS
,
ETH_BIGNUMBER_ROUNDING_MODE
:
{
ROUNDING_MODE
:
BigNumber
.
ROUND_DOWN
}
ETH_BIGNUMBER_ROUNDING_MODE
:
{
ROUNDING_MODE
:
BigNumber
.
ROUND_DOWN
}
};
};
...
@@ -1101,6 +1124,8 @@ module.exports = {
...
@@ -1101,6 +1124,8 @@ module.exports = {
* @date 2015
* @date 2015
*/
*/
var
c
=
require
(
'./const'
);
/// Finds first index of array element matching pattern
/// Finds first index of array element matching pattern
/// @param array
/// @param array
/// @param callback pattern
/// @param callback pattern
...
@@ -1182,6 +1207,32 @@ var filterEvents = function (json) {
...
@@ -1182,6 +1207,32 @@ var filterEvents = function (json) {
});
});
};
};
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
/// TODO: add tests for it!
var
toEth
=
function
(
str
)
{
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
unit
=
0
;
var
units
=
c
.
ETH_UNITS
;
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
{
val
/=
1000
;
unit
++
;
}
var
s
=
val
.
toString
().
length
<
val
.
toFixed
(
2
).
length
?
val
.
toString
()
:
val
.
toFixed
(
2
);
var
replaceFunction
=
function
(
$0
,
$1
,
$2
)
{
return
$1
+
','
+
$2
;
};
while
(
true
)
{
var
o
=
s
;
s
=
s
.
replace
(
/
(\d)(\d\d\d[\.\,])
/
,
replaceFunction
);
if
(
o
===
s
)
break
;
}
return
s
+
' '
+
units
[
unit
];
};
module
.
exports
=
{
module
.
exports
=
{
findIndex
:
findIndex
,
findIndex
:
findIndex
,
toAscii
:
toAscii
,
toAscii
:
toAscii
,
...
@@ -1189,11 +1240,12 @@ module.exports = {
...
@@ -1189,11 +1240,12 @@ module.exports = {
extractDisplayName
:
extractDisplayName
,
extractDisplayName
:
extractDisplayName
,
extractTypeName
:
extractTypeName
,
extractTypeName
:
extractTypeName
,
filterFunctions
:
filterFunctions
,
filterFunctions
:
filterFunctions
,
filterEvents
:
filterEvents
filterEvents
:
filterEvents
,
toEth
:
toEth
};
};
},{}],
12
:[
function
(
require
,
module
,
exports
){
},{
"./const"
:
2
}],
12
:[
function
(
require
,
module
,
exports
){
/*
/*
This file is part of ethereum.js.
This file is part of ethereum.js.
...
@@ -1225,28 +1277,6 @@ if ("build" !== 'build') {/*
...
@@ -1225,28 +1277,6 @@ if ("build" !== 'build') {/*
var
utils
=
require
(
'./utils'
);
var
utils
=
require
(
'./utils'
);
var
ETH_UNITS
=
[
'wei'
,
'Kwei'
,
'Mwei'
,
'Gwei'
,
'szabo'
,
'finney'
,
'ether'
,
'grand'
,
'Mether'
,
'Gether'
,
'Tether'
,
'Pether'
,
'Eether'
,
'Zether'
,
'Yether'
,
'Nether'
,
'Dether'
,
'Vether'
,
'Uether'
];
/// @returns an array of objects describing web3 api methods
/// @returns an array of objects describing web3 api methods
var
web3Methods
=
function
()
{
var
web3Methods
=
function
()
{
return
[
return
[
...
@@ -1409,29 +1439,7 @@ var web3 = {
...
@@ -1409,29 +1439,7 @@ var web3 = {
},
},
/// used to transform value/string to eth string
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
toEth
:
utils
.
toEth
,
toEth
:
function
(
str
)
{
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
unit
=
0
;
var
units
=
ETH_UNITS
;
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
{
val
/=
1000
;
unit
++
;
}
var
s
=
val
.
toString
().
length
<
val
.
toFixed
(
2
).
length
?
val
.
toString
()
:
val
.
toFixed
(
2
);
var
replaceFunction
=
function
(
$0
,
$1
,
$2
)
{
return
$1
+
','
+
$2
;
};
while
(
true
)
{
var
o
=
s
;
s
=
s
.
replace
(
/
(\d)(\d\d\d[\.\,])
/
,
replaceFunction
);
if
(
o
===
s
)
break
;
}
return
s
+
' '
+
units
[
unit
];
},
/// eth object prototype
/// eth object prototype
eth
:
{
eth
:
{
...
@@ -1467,11 +1475,6 @@ var web3 = {
...
@@ -1467,11 +1475,6 @@ var web3 = {
return
new
web3
.
filter
(
filter
,
shhWatch
);
return
new
web3
.
filter
(
filter
,
shhWatch
);
}
}
},
},
/// @returns true if provider is installed
haveProvider
:
function
()
{
return
!!
web3
.
provider
.
provider
;
}
};
};
/// setups all api methods
/// setups all api methods
...
@@ -1494,7 +1497,6 @@ var shhWatch = {
...
@@ -1494,7 +1497,6 @@ var shhWatch = {
setupMethods
(
shhWatch
,
shhWatchMethods
());
setupMethods
(
shhWatch
,
shhWatchMethods
());
web3
.
setProvider
=
function
(
provider
)
{
web3
.
setProvider
=
function
(
provider
)
{
//provider.onmessage = messageHandler; // there will be no async calls, to remove
web3
.
provider
.
set
(
provider
);
web3
.
provider
.
set
(
provider
);
};
};
...
...
dist/ethereum.js.map
View file @
9d9c23e3
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
9d9c23e3
This diff is collapsed.
Click to expand it.
lib/const.js
View file @
9d9c23e3
...
@@ -25,9 +25,32 @@ if (process.env.NODE_ENV !== 'build') {
...
@@ -25,9 +25,32 @@ if (process.env.NODE_ENV !== 'build') {
var
BigNumber
=
require
(
'bignumber.js'
);
// jshint ignore:line
var
BigNumber
=
require
(
'bignumber.js'
);
// jshint ignore:line
}
}
var
ETH_UNITS
=
[
'wei'
,
'Kwei'
,
'Mwei'
,
'Gwei'
,
'szabo'
,
'finney'
,
'ether'
,
'grand'
,
'Mether'
,
'Gether'
,
'Tether'
,
'Pether'
,
'Eether'
,
'Zether'
,
'Yether'
,
'Nether'
,
'Dether'
,
'Vether'
,
'Uether'
];
module
.
exports
=
{
module
.
exports
=
{
ETH_PADDING
:
32
,
ETH_PADDING
:
32
,
ETH_SIGNATURE_LENGTH
:
4
,
ETH_SIGNATURE_LENGTH
:
4
,
ETH_UNITS
:
ETH_UNITS
,
ETH_BIGNUMBER_ROUNDING_MODE
:
{
ROUNDING_MODE
:
BigNumber
.
ROUND_DOWN
}
ETH_BIGNUMBER_ROUNDING_MODE
:
{
ROUNDING_MODE
:
BigNumber
.
ROUND_DOWN
}
};
};
lib/utils.js
View file @
9d9c23e3
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
* @date 2015
* @date 2015
*/
*/
var
c
=
require
(
'./const'
);
/// Finds first index of array element matching pattern
/// Finds first index of array element matching pattern
/// @param array
/// @param array
/// @param callback pattern
/// @param callback pattern
...
@@ -101,6 +103,32 @@ var filterEvents = function (json) {
...
@@ -101,6 +103,32 @@ var filterEvents = function (json) {
});
});
};
};
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
/// TODO: add tests for it!
var
toEth
=
function
(
str
)
{
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
unit
=
0
;
var
units
=
c
.
ETH_UNITS
;
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
{
val
/=
1000
;
unit
++
;
}
var
s
=
val
.
toString
().
length
<
val
.
toFixed
(
2
).
length
?
val
.
toString
()
:
val
.
toFixed
(
2
);
var
replaceFunction
=
function
(
$0
,
$1
,
$2
)
{
return
$1
+
','
+
$2
;
};
while
(
true
)
{
var
o
=
s
;
s
=
s
.
replace
(
/
(\d)(\d\d\d[\.\,])
/
,
replaceFunction
);
if
(
o
===
s
)
break
;
}
return
s
+
' '
+
units
[
unit
];
};
module
.
exports
=
{
module
.
exports
=
{
findIndex
:
findIndex
,
findIndex
:
findIndex
,
toAscii
:
toAscii
,
toAscii
:
toAscii
,
...
@@ -108,6 +136,7 @@ module.exports = {
...
@@ -108,6 +136,7 @@ module.exports = {
extractDisplayName
:
extractDisplayName
,
extractDisplayName
:
extractDisplayName
,
extractTypeName
:
extractTypeName
,
extractTypeName
:
extractTypeName
,
filterFunctions
:
filterFunctions
,
filterFunctions
:
filterFunctions
,
filterEvents
:
filterEvents
filterEvents
:
filterEvents
,
toEth
:
toEth
};
};
lib/web3.js
View file @
9d9c23e3
...
@@ -29,28 +29,6 @@ if (process.env.NODE_ENV !== 'build') {
...
@@ -29,28 +29,6 @@ if (process.env.NODE_ENV !== 'build') {
var
utils
=
require
(
'./utils'
);
var
utils
=
require
(
'./utils'
);
var
ETH_UNITS
=
[
'wei'
,
'Kwei'
,
'Mwei'
,
'Gwei'
,
'szabo'
,
'finney'
,
'ether'
,
'grand'
,
'Mether'
,
'Gether'
,
'Tether'
,
'Pether'
,
'Eether'
,
'Zether'
,
'Yether'
,
'Nether'
,
'Dether'
,
'Vether'
,
'Uether'
];
/// @returns an array of objects describing web3 api methods
/// @returns an array of objects describing web3 api methods
var
web3Methods
=
function
()
{
var
web3Methods
=
function
()
{
return
[
return
[
...
@@ -213,29 +191,7 @@ var web3 = {
...
@@ -213,29 +191,7 @@ var web3 = {
},
},
/// used to transform value/string to eth string
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
toEth
:
utils
.
toEth
,
toEth
:
function
(
str
)
{
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
unit
=
0
;
var
units
=
ETH_UNITS
;
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
{
val
/=
1000
;
unit
++
;
}
var
s
=
val
.
toString
().
length
<
val
.
toFixed
(
2
).
length
?
val
.
toString
()
:
val
.
toFixed
(
2
);
var
replaceFunction
=
function
(
$0
,
$1
,
$2
)
{
return
$1
+
','
+
$2
;
};
while
(
true
)
{
var
o
=
s
;
s
=
s
.
replace
(
/
(\d)(\d\d\d[\.\,])
/
,
replaceFunction
);
if
(
o
===
s
)
break
;
}
return
s
+
' '
+
units
[
unit
];
},
/// eth object prototype
/// eth object prototype
eth
:
{
eth
:
{
...
@@ -271,11 +227,6 @@ var web3 = {
...
@@ -271,11 +227,6 @@ var web3 = {
return
new
web3
.
filter
(
filter
,
shhWatch
);
return
new
web3
.
filter
(
filter
,
shhWatch
);
}
}
},
},
/// @returns true if provider is installed
haveProvider
:
function
()
{
return
!!
web3
.
provider
.
provider
;
}
};
};
/// setups all api methods
/// setups all api methods
...
@@ -298,7 +249,6 @@ var shhWatch = {
...
@@ -298,7 +249,6 @@ var shhWatch = {
setupMethods
(
shhWatch
,
shhWatchMethods
());
setupMethods
(
shhWatch
,
shhWatchMethods
());
web3
.
setProvider
=
function
(
provider
)
{
web3
.
setProvider
=
function
(
provider
)
{
//provider.onmessage = messageHandler; // there will be no async calls, to remove
web3
.
provider
.
set
(
provider
);
web3
.
provider
.
set
(
provider
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment