ethereum-base 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ethereum-base.gemspec +1 -1
- data/lib/ethereum/base.rb +11 -0
- data/lib/ethereum/base/sedes.rb +40 -0
- data/lib/ethereum/base/utils.rb +8 -0
- data/lib/ethereum/base/version.rb +7 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7481184b422690d8b263481421edc49fb6026847
|
4
|
+
data.tar.gz: b27b06065393187ced784c9660349646f7865d47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dca2a78113d00d877355720edf829c2a2985f0b16797f64bfef5492db3e4f927741c468b947b797ae5850ea336c2336a1adb64e64ee0d253023a41c0c4be588
|
7
|
+
data.tar.gz: f6d5319d73aa2822d6595f6e153bc4cb7d2c05af67384a6fe31616b00fda2ad72691512299712788bb3353ef4d5a57ff664e19f95adef273d37856e295168ff9
|
data/ethereum-base.gemspec
CHANGED
data/lib/ethereum/base.rb
CHANGED
@@ -6,7 +6,18 @@ module Ethereum
|
|
6
6
|
|
7
7
|
VERSION = "0.1.2"
|
8
8
|
|
9
|
+
BYTE_ZERO = "\x00".freeze
|
10
|
+
GTXCOST = 21000 # TX BASE GAS COST
|
11
|
+
GTXDATANONZERO = 68 # TX DATA NON ZERO BYTE GAS COST
|
12
|
+
GTXDATAZERO = 4 # TX DATA ZERO BYTE GAS COST
|
13
|
+
SECP256K1_N = 115792089237316195423570985008687907852837564279074904382605163141518161494337
|
14
|
+
UINT_MAX = 2**256 - 1
|
15
|
+
|
16
|
+
autoload :Sedes, 'ethereum/base/sedes'
|
9
17
|
autoload :Utils, 'ethereum/base/utils'
|
10
18
|
|
19
|
+
class ValidationError < StandardError; end
|
20
|
+
class InvalidTransaction < ValidationError; end
|
21
|
+
|
11
22
|
end
|
12
23
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Ethereum::Base
|
2
|
+
module Sedes
|
3
|
+
include RLP::Sedes
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def address
|
8
|
+
Binary.fixed_length(20, allow_empty: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
def int20
|
12
|
+
BigEndianInt.new(20)
|
13
|
+
end
|
14
|
+
|
15
|
+
def int32
|
16
|
+
BigEndianInt.new(32)
|
17
|
+
end
|
18
|
+
|
19
|
+
def int256
|
20
|
+
BigEndianInt.new(256)
|
21
|
+
end
|
22
|
+
|
23
|
+
def hash32
|
24
|
+
Binary.fixed_length(32)
|
25
|
+
end
|
26
|
+
|
27
|
+
def trie_root
|
28
|
+
Binary.fixed_length(32, allow_empty: true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def big_endian_int
|
32
|
+
RLP::Sedes.big_endian_int
|
33
|
+
end
|
34
|
+
|
35
|
+
def binary
|
36
|
+
RLP::Sedes.binary
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/ethereum/base/utils.rb
CHANGED
@@ -25,6 +25,14 @@ module Ethereum::Base
|
|
25
25
|
RLP::Utils.decode_hex s
|
26
26
|
end
|
27
27
|
|
28
|
+
def encode_rlp(b)
|
29
|
+
RLP.encode b
|
30
|
+
end
|
31
|
+
|
32
|
+
def decode_rlp(s)
|
33
|
+
RLP.decode s
|
34
|
+
end
|
35
|
+
|
28
36
|
def big_endian_to_int(s)
|
29
37
|
RLP::Sedes.big_endian_int.deserialize s.sub(/\A(\x00)+/, '')
|
30
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethereum-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Xie
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: digest-sha3
|
@@ -100,7 +100,9 @@ files:
|
|
100
100
|
- bin/setup
|
101
101
|
- ethereum-base.gemspec
|
102
102
|
- lib/ethereum/base.rb
|
103
|
+
- lib/ethereum/base/sedes.rb
|
103
104
|
- lib/ethereum/base/utils.rb
|
105
|
+
- lib/ethereum/base/version.rb
|
104
106
|
homepage: https://github.com/janx/ruby-ethereum-base
|
105
107
|
licenses:
|
106
108
|
- MIT
|