This repository has been archived by the owner on May 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/opt/local/bin/ruby | ||
############################################################# {{{1 ########## | ||
# Copyright © 2019 Martin Krischik «krischik@users.sourceforge.net» | ||
############################################################################# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see «http://www.gnu.org/licenses/». | ||
############################################################# }}}1 ########## | ||
|
||
# use the "steem.rb" file from the radiator gem. This is | ||
# only needed if you have both steem-api and radiator | ||
# installed. | ||
|
||
gem "radiator", :require => "steem" | ||
|
||
require 'pp' | ||
require 'colorize' | ||
require 'contracts' | ||
require 'radiator' | ||
|
||
require_relative 'Steem_Engine' | ||
|
||
## | ||
# | ||
module SCC | ||
class Contract < SCC::Steem_Engine | ||
include Contracts::Core | ||
include Contracts::Builtin | ||
|
||
attr_reader :name, :owner, :code, :codeHash, :tables | ||
|
||
public | ||
|
||
Contract String => nil | ||
def initialize(_name) | ||
super(:contract, Steem_Engine.contracts_api.contract(_name)) | ||
|
||
@name = @value.name | ||
@owner = @value.owner | ||
@code = @value.code | ||
@codeHash = @value.codeHash | ||
@tables = @value.tables | ||
|
||
return | ||
end | ||
end # Token | ||
end # SCC | ||
|
||
############################################################ {{{1 ########### | ||
# vim: set nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab : | ||
# vim: set textwidth=0 filetype=ruby foldmethod=marker nospell : | ||
# vim: set spell spelllang=en_gb fileencoding=utf-8 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
############################################################# {{{1 ########## | ||
# Copyright © 2019 Martin Krischik «krischik@users.sourceforge.net» | ||
############################################################################# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see «http://www.gnu.org/licenses/». | ||
############################################################# }}}1 ########## | ||
|
||
# use the "steem.rb" file from the radiator gem. This is | ||
# only needed if you have both steem-api and radiator | ||
# installed. | ||
|
||
gem "radiator", :require => "steem" | ||
|
||
require 'pp' | ||
require 'colorize' | ||
require 'contracts' | ||
require 'radiator' | ||
|
||
## | ||
# | ||
module SCC | ||
class Steem_Engine < Radiator::Type::Serializer | ||
include Contracts::Core | ||
include Contracts::Builtin | ||
|
||
protected | ||
|
||
## | ||
# Access to contracts interface | ||
# | ||
# @return ~ | ||
# | ||
Contract None => Radiator::SSC::Contracts | ||
def self.contracts_api | ||
# create instance to the steem condenser API which | ||
# will give us access to the median history price | ||
|
||
if @@api == nil then | ||
@@api = Radiator::SSC::Contracts.new | ||
end | ||
|
||
return @@api | ||
rescue => error | ||
# I am using Kernel::abort so the code snipped | ||
# including error handler can be copy pasted into other | ||
# scripts | ||
|
||
Kernel::abort("Error creating contracts API :\n".red + error.to_s) | ||
end #contracts | ||
|
||
private | ||
|
||
@@api = nil | ||
|
||
end # Token | ||
end # SCC | ||
|
||
############################################################ {{{1 ########### | ||
# vim: set nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab : | ||
# vim: set textwidth=0 filetype=ruby foldmethod=marker nospell : | ||
# vim: set spell spelllang=en_gb fileencoding=utf-8 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/opt/local/bin/ruby | ||
############################################################# {{{1 ########## | ||
# Copyright © 2019 Martin Krischik «krischik@users.sourceforge.net» | ||
############################################################################# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see «http://www.gnu.org/licenses/». | ||
############################################################# }}}1 ########## | ||
|
||
# use the "steem.rb" file from the radiator gem. This is | ||
# only needed if you have both steem-api and radiator | ||
# installed. | ||
|
||
gem "radiator", :require => "steem" | ||
|
||
require 'pp' | ||
require 'colorize' | ||
require 'contracts' | ||
require 'radiator' | ||
|
||
## | ||
# | ||
module SCC | ||
class Token | ||
include Contracts::Core | ||
include Contracts::Builtin | ||
|
||
public | ||
|
||
def find (String _name) | ||
_contract = Contracts.contract _name | ||
end | ||
|
||
private | ||
def self.contracts | ||
# create instance to the steem condenser API which | ||
# will give us access to the median history price | ||
|
||
@contracts ||= Radiator::SSC::Contracts.new | ||
|
||
return @contracts | ||
rescue => error | ||
# I am using Kernel::abort so the code snipped | ||
# including error handler can be copy pasted into other | ||
# scripts | ||
|
||
Kernel::abort("Error reading global properties:\n".red + error.to_s) | ||
end #contracts | ||
end # Token | ||
end # SCC | ||
|
||
############################################################ {{{1 ########### | ||
# vim: set nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab : | ||
# vim: set textwidth=0 filetype=ruby foldmethod=marker nospell : | ||
# vim: set spell spelllang=en_gb fileencoding=utf-8 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/opt/local/bin/ruby | ||
############################################################# {{{1 ########## | ||
# Copyright © 2019 Martin Krischik «krischik@users.sourceforge.net» | ||
############################################################################# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see «http://www.gnu.org/licenses/». | ||
############################################################# }}}1 ########## | ||
|
||
require_relative '../Scripts/SCC/Contract' | ||
|
||
_tokens = SCC::Contract.new "tokens" | ||
|
||
pp _tokens | ||
|
||
############################################################ {{{1 ########### | ||
# vim: set nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab : | ||
# vim: set textwidth=0 filetype=ruby foldmethod=marker nospell : | ||
# vim: set spell spelllang=en_gb fileencoding=utf-8 : |