rubysol 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/rubysol.rb ADDED
@@ -0,0 +1,117 @@
1
+ ##
2
+ # note: for now rubidity/typed gem pulls in
3
+ # require 'forwardable' ## def_delegate
4
+
5
+ ##
6
+ ## move require json to rubidity/typed ??
7
+ require 'json' ## use in public_abi_to_json
8
+
9
+
10
+
11
+ require 'digest-lite' ### pulls in keccak256
12
+ require 'hexutils' ### pulls in hex/to_hex (decode/encode_hex)
13
+ require 'solidity/typed'
14
+
15
+
16
+
17
+
18
+ ## define global Array() and Mapping(,) helpers
19
+ ## to generate types
20
+ ## or add upstream TypedArray() and TypedMapping(,)
21
+ ## and add alias here for Array(), Mapping(,) - why? why not?
22
+
23
+ def array( sub_type, size=0 )
24
+ typedclass = Types::Array.new( sub_type, size )
25
+ typedclass
26
+ end
27
+
28
+ def mapping( key_type, value_type )
29
+ typedclass = Types::Mapping.new( key_type, value_type )
30
+ typedclass
31
+ end
32
+
33
+
34
+
35
+
36
+ ## add "namespaced" convenience / shortcut names for Typed<Type> classes
37
+ ## note use ::String for "standard" string and such!!!
38
+ class Contract
39
+
40
+ include Types
41
+ =begin
42
+ String = TypedString
43
+ Address = TypedAddress
44
+ InscriptionId = TypedInscriptionId
45
+ Bytes32 = TypedBytes32
46
+ Bytes = TypedBytes
47
+ Bool = TypedBool
48
+ UInt = TypedUInt
49
+ Int = TypedInt
50
+ Timestamp = TypedTimestamp
51
+ =end
52
+ ## todo/check - what to do about TypedArray and Typed Mapping
53
+ ## requires/uses mapping() and array for now
54
+ ##
55
+ ## Array = TypedArray
56
+ ## Mapping = TypedMapping ??
57
+ ## and (Typed)Array.of( UInt ) or (Typed)Array.of( String )
58
+ ## and (Typed)Mapping.of( Address, UInt) or ...
59
+ ## Array = TypedArray
60
+ ## Mapping = TypedMapping
61
+ ##
62
+ ## puts "check alias are same?"
63
+ ## pp String == TypedString #=> true!!
64
+ ## pp String === TypedString #=> false!!!!!!!
65
+ ## pp Address == TypedAddress #=> true
66
+ ## pp Address === TypedAddress #=> false!!!!!
67
+ ## note: use org class name; alias via === compare WILL FAIL!!!
68
+ ## note: case/when/ will NOT work; use if/elsfi/else!!!
69
+ end # class Contract
70
+
71
+
72
+
73
+ ## our own code
74
+ require_relative 'rubysol/version'
75
+ require_relative 'rubysol/generator'
76
+
77
+ require_relative 'rubysol/contract/crypto'
78
+ require_relative 'rubysol/contract/runtime'
79
+ require_relative 'rubysol/contract'
80
+ require_relative 'rubysol/abi_proxy'
81
+
82
+ require_relative 'rubysol/library' ## add support for libaries
83
+
84
+
85
+ require_relative 'rubysol/runtime'
86
+
87
+
88
+ ##
89
+ # add extra setup helpers
90
+
91
+ class Contract
92
+
93
+ def self.construct( *args, **kwargs )
94
+ ## todo/fix: check either args or kwargs MUST be empty
95
+ ## can only use one format
96
+ puts "[debug] Contract.construct - class -> #{self.name}"
97
+ puts " args: #{args.inspect}" unless args.empty?
98
+ puts " kwargs: #{kwargs.inspect}" unless kwargs.empty?
99
+
100
+ contract = new
101
+
102
+ ## (auto-)register before or after calling constructor - why? why not?
103
+ contract.__autoregister__
104
+
105
+ contract.constructor( *args, **kwargs )
106
+ contract
107
+ end
108
+ ## note: create is only an alias for construct !!!!
109
+ ## to create an empty contract to load with state use new!!!
110
+ class << self
111
+ alias_method :create, :construct
112
+ end
113
+ end # class Contract
114
+
115
+
116
+
117
+ puts Rubysol::Module::Lang.banner ## say hello
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubysol
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: solidity-typed
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: digest-lite
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hexutils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '7'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '4.0'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '7'
75
+ - !ruby/object:Gem::Dependency
76
+ name: hoe
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '4.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '4.0'
89
+ description: rubysol - ruby for (blockchain) layer 1 (l1) contracts / protocols with
90
+ "off-chain" indexer; 100% compatible with solidity datatypes and abis
91
+ email: gerald.bauer@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files:
95
+ - CHANGELOG.md
96
+ - Manifest.txt
97
+ - README.md
98
+ files:
99
+ - CHANGELOG.md
100
+ - Manifest.txt
101
+ - README.md
102
+ - Rakefile
103
+ - lib/rubysol.rb
104
+ - lib/rubysol/abi_proxy.rb
105
+ - lib/rubysol/contract.rb
106
+ - lib/rubysol/contract/crypto.rb
107
+ - lib/rubysol/contract/runtime.rb
108
+ - lib/rubysol/generator.rb
109
+ - lib/rubysol/library.rb
110
+ - lib/rubysol/runtime.rb
111
+ - lib/rubysol/version.rb
112
+ homepage: https://github.com/s6ruby/rubidity
113
+ licenses:
114
+ - Public Domain
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options:
118
+ - "--main"
119
+ - README.md
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '2.3'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubygems_version: 3.4.10
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: rubysol - ruby for (blockchain) layer 1 (l1) contracts / protocols with "off-chain"
137
+ indexer; 100% compatible with solidity datatypes and abis
138
+ test_files: []