serpent 0.0.1 → 0.1.0

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: ad07711497242c6c90013febde570d8a87958329
4
- data.tar.gz: 91f99850b31ccc9ab4a20744793d6836b1574c85
3
+ metadata.gz: 9e064fffc2cbbd7c57f6a9f8c8b0a4cf326ec73b
4
+ data.tar.gz: d7403a3c974afdac5933e4c6d960fdc642c9c25e
5
5
  SHA512:
6
- metadata.gz: b745daa653e6eabe1f5657053a55ffbcb1845c14c8d4dec678647d8a9aca49248e1ef58befa1bedcede9e8a48659983cb4764799d46b2f73a3306093b2c025f5
7
- data.tar.gz: c60cc1e0e94fc1a793effffec1f4934cacb6399684d8f8a68d48492477eae8a40c95750c332ec17eb0edf5a8b594cdf3b2aa465bca3445b5a88c750f70f6d578
6
+ metadata.gz: 676765556e178545eac61b86590d55e9b6885897cbbb959df28b8e6a4c1c376665e164491c256e0ac856049df8c3d1e9fbdb605d8e18875bdd7a68bf296673fa
7
+ data.tar.gz: e5c93ddca6f6dcd41979f7aa4e0a4e6731292df4665d2b477548d3cdfe63df26517fd38caa8cbb201a5cf17aa1d88be649371ae909e6bac5b916fa113d8d2ffa
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- serpent (0.0.1)
4
+ serpent (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Install
4
4
 
5
+ Make sure you already have [libserpent](https://github.com/ethereum/serpent/tree/develop) at location.
6
+
5
7
  ```
6
8
  gem i serpent
7
9
  ```
@@ -7,8 +7,28 @@ std::string serpent_compile(Object self, std::string code) {
7
7
  return compile(code);
8
8
  }
9
9
 
10
+ std::string serpent_mk_raw_signature(Object self, std::string input) {
11
+ return mkSignature(input);
12
+ }
13
+
14
+ std::string serpent_mk_raw_full_signature(Object self, std::string input) {
15
+ return mkFullSignature(input);
16
+ }
17
+
18
+ std::string serpent_mk_raw_contract_info(Object self, std::string input) {
19
+ return mkContractInfoDecl(input);
20
+ }
21
+
22
+ unsigned int serpent_get_prefix(Object self, std::string signature) {
23
+ return getPrefix(signature);
24
+ }
25
+
10
26
  extern "C"
11
27
  void Init_serpent() {
12
28
  Module rb_mSerpent = define_module("Serpent")
13
- .define_module_function("compile", &serpent_compile);
29
+ .define_module_function("compile", &serpent_compile)
30
+ .define_module_function("mk_raw_signature", &serpent_mk_raw_signature)
31
+ .define_module_function("mk_raw_full_signature", &serpent_mk_raw_full_signature)
32
+ .define_module_function("mk_raw_contract_info", &serpent_mk_raw_contract_info)
33
+ .define_module_function("get_prefix", &serpent_get_prefix);
14
34
  }
@@ -1,2 +1,20 @@
1
+ require 'json'
2
+
1
3
  require 'serpent/version'
2
4
  require 'serpent/serpent'
5
+
6
+ module Serpent
7
+ class <<self
8
+ def mk_signature(s)
9
+ JSON.parse mk_raw_signature(s)
10
+ end
11
+
12
+ def mk_full_signature(s)
13
+ JSON.parse mk_raw_full_signature(s)
14
+ end
15
+
16
+ def mk_contract_info(s)
17
+ JSON.parse mk_raw_contract_info(s)
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Serpent
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -5,13 +5,19 @@ require 'serpent'
5
5
 
6
6
  class SerpentTest < Minitest::Test
7
7
 
8
- def test_compile
9
- code = <<-SERPENT
8
+ CODE = <<EOF
10
9
  def main(a,b):
11
10
  return(a ^ b)
12
- SERPENT
11
+ EOF
12
+
13
+ def test_compile
14
+ assert_equal decode_hex('604a80600b6000396055567c0100000000000000000000000000000000000000000000000000000000600035046397d857aa8114156048576004356040526024356060526060516040510a60805260206080f35b505b6000f3'), Serpent.compile(CODE)
15
+ end
13
16
 
14
- assert_equal decode_hex('604a80600b6000396055567c0100000000000000000000000000000000000000000000000000000000600035046397d857aa8114156048576004356040526024356060526060516040510a60805260206080f35b505b6000f3'), Serpent.compile(code)
17
+ def test_mk_full_signature
18
+ sig = Serpent.mk_full_signature(CODE).first
19
+ assert_equal 'main(int256,int256)', sig['name']
20
+ assert_equal [{'name' => 'a', 'type' => 'int256'}, {'name' => 'b', 'type' => 'int256'}], sig['inputs']
15
21
  end
16
22
 
17
23
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serpent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Xie