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
c2d9c1a6
Commit
c2d9c1a6
authored
Jan 21, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toDecimal/fromDecimal is using bignumber.js now
parent
81a58132
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
29 deletions
+63
-29
ethereum.js
dist/ethereum.js
+30
-13
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
web3.js
lib/web3.js
+30
-13
No files found.
dist/ethereum.js
View file @
c2d9c1a6
...
@@ -804,6 +804,32 @@ module.exports = ProviderManager;
...
@@ -804,6 +804,32 @@ module.exports = ProviderManager;
* @date 2014
* @date 2014
*/
*/
if
(
"build"
!==
'build'
)
{
/*
var BigNumber = require('bignumber.js');
*/
}
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
[
...
@@ -941,16 +967,6 @@ var setupProperties = function (obj, properties) {
...
@@ -941,16 +967,6 @@ var setupProperties = function (obj, properties) {
});
});
};
};
// TODO: import from a dependency, don't duplicate.
// TODO: use bignumber for that!
var
hexToDec
=
function
(
hex
)
{
return
parseInt
(
hex
,
16
).
toString
();
};
var
decToHex
=
function
(
dec
)
{
return
parseInt
(
dec
).
toString
(
16
);
};
/// setups web3 object, and it's in-browser executed methods
/// setups web3 object, and it's in-browser executed methods
var
web3
=
{
var
web3
=
{
_callbacks
:
{},
_callbacks
:
{},
...
@@ -997,19 +1013,20 @@ var web3 = {
...
@@ -997,19 +1013,20 @@ var web3 = {
/// @returns decimal representaton of hex value prefixed by 0x
/// @returns decimal representaton of hex value prefixed by 0x
toDecimal
:
function
(
val
)
{
toDecimal
:
function
(
val
)
{
return
hexToDec
(
val
.
substring
(
2
));
return
(
new
BigNumber
(
val
.
substring
(
2
),
16
).
toString
(
10
));
},
},
/// @returns hex representation (prefixed by 0x) of decimal value
/// @returns hex representation (prefixed by 0x) of decimal value
fromDecimal
:
function
(
val
)
{
fromDecimal
:
function
(
val
)
{
return
"0x"
+
decToHex
(
val
);
return
"0x"
+
(
new
BigNumber
(
val
).
toString
(
16
)
);
},
},
/// used to transform value/string to eth string
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
toEth
:
function
(
str
)
{
toEth
:
function
(
str
)
{
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
unit
=
0
;
var
unit
=
0
;
var
units
=
[
'wei'
,
'Kwei'
,
'Mwei'
,
'Gwei'
,
'szabo'
,
'finney'
,
'ether'
,
'grand'
,
'Mether'
,
'Gether'
,
'Tether'
,
'Pether'
,
'Eether'
,
'Zether'
,
'Yether'
,
'Nether'
,
'Dether'
,
'Vether'
,
'Uether'
]
;
var
units
=
ETH_UNITS
;
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
{
{
val
/=
1000
;
val
/=
1000
;
...
...
dist/ethereum.js.map
View file @
c2d9c1a6
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
c2d9c1a6
This diff is collapsed.
Click to expand it.
lib/web3.js
View file @
c2d9c1a6
...
@@ -23,6 +23,32 @@
...
@@ -23,6 +23,32 @@
* @date 2014
* @date 2014
*/
*/
if
(
process
.
env
.
NODE_ENV
!==
'build'
)
{
var
BigNumber
=
require
(
'bignumber.js'
);
}
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
[
...
@@ -160,16 +186,6 @@ var setupProperties = function (obj, properties) {
...
@@ -160,16 +186,6 @@ var setupProperties = function (obj, properties) {
});
});
};
};
// TODO: import from a dependency, don't duplicate.
// TODO: use bignumber for that!
var
hexToDec
=
function
(
hex
)
{
return
parseInt
(
hex
,
16
).
toString
();
};
var
decToHex
=
function
(
dec
)
{
return
parseInt
(
dec
).
toString
(
16
);
};
/// setups web3 object, and it's in-browser executed methods
/// setups web3 object, and it's in-browser executed methods
var
web3
=
{
var
web3
=
{
_callbacks
:
{},
_callbacks
:
{},
...
@@ -216,19 +232,20 @@ var web3 = {
...
@@ -216,19 +232,20 @@ var web3 = {
/// @returns decimal representaton of hex value prefixed by 0x
/// @returns decimal representaton of hex value prefixed by 0x
toDecimal
:
function
(
val
)
{
toDecimal
:
function
(
val
)
{
return
hexToDec
(
val
.
substring
(
2
));
return
(
new
BigNumber
(
val
.
substring
(
2
),
16
).
toString
(
10
));
},
},
/// @returns hex representation (prefixed by 0x) of decimal value
/// @returns hex representation (prefixed by 0x) of decimal value
fromDecimal
:
function
(
val
)
{
fromDecimal
:
function
(
val
)
{
return
"0x"
+
decToHex
(
val
);
return
"0x"
+
(
new
BigNumber
(
val
).
toString
(
16
)
);
},
},
/// used to transform value/string to eth string
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
toEth
:
function
(
str
)
{
toEth
:
function
(
str
)
{
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
val
=
typeof
str
===
"string"
?
str
.
indexOf
(
'0x'
)
===
0
?
parseInt
(
str
.
substr
(
2
),
16
)
:
parseInt
(
str
)
:
str
;
var
unit
=
0
;
var
unit
=
0
;
var
units
=
[
'wei'
,
'Kwei'
,
'Mwei'
,
'Gwei'
,
'szabo'
,
'finney'
,
'ether'
,
'grand'
,
'Mether'
,
'Gether'
,
'Tether'
,
'Pether'
,
'Eether'
,
'Zether'
,
'Yether'
,
'Nether'
,
'Dether'
,
'Vether'
,
'Uether'
]
;
var
units
=
ETH_UNITS
;
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
while
(
val
>
3000
&&
unit
<
units
.
length
-
1
)
{
{
val
/=
1000
;
val
/=
1000
;
...
...
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