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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9a3e98ec02453d5b813ccbecbdd60524579dac9
4
- data.tar.gz: 70b91b172ce76019c1d7b9d31cd53e0f7ed81525
3
+ metadata.gz: 7481184b422690d8b263481421edc49fb6026847
4
+ data.tar.gz: b27b06065393187ced784c9660349646f7865d47
5
5
  SHA512:
6
- metadata.gz: 7bf43d84c682f2fe071f8b6799301b82caa37fe51162d36e39c77a4622bf85283bf801490c520b0c1249b2240d17b2c61918817c70f419eefe3ad7ad5725e965
7
- data.tar.gz: 4ab944bd460d8e9ad84829dea63218a99713fbc23237be0fb76a687c83e8593b38f149bd00f46d78d4d83146be4eec3c9acb954dcdeb3478d6a5889caebd176f
6
+ metadata.gz: 1dca2a78113d00d877355720edf829c2a2985f0b16797f64bfef5492db3e4f927741c468b947b797ae5850ea336c2336a1adb64e64ee0d253023a41c0c4be588
7
+ data.tar.gz: f6d5319d73aa2822d6595f6e153bc4cb7d2c05af67384a6fe31616b00fda2ad72691512299712788bb3353ef4d5a57ff664e19f95adef273d37856e295168ff9
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ethereum/base'
4
+ require 'ethereum/base/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ethereum-base"
@@ -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
@@ -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
@@ -0,0 +1,7 @@
1
+ module Ethereum
2
+ module Base
3
+
4
+ VERSION = "0.1.3"
5
+
6
+ end
7
+ 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.2
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-07 00:00:00.000000000 Z
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