Skip to content

Instantly share code, notes, and snippets.

@inertia186
Last active April 26, 2017 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inertia186/814532e66cc4cd537f418ac7f1f420d5 to your computer and use it in GitHub Desktop.
Save inertia186/814532e66cc4cd537f418ac7f1f420d5 to your computer and use it in GitHub Desktop.
Golos Genesis Fix ('genesis_fix.rb') for GOLOS. Please have a look at the README.md file.
  • Title: genesis_fix.rb - Golos Genesis Fix
  • Tags: en radiator ruby golos
  • Notes:

Overview

Golos Genesis Fix (genesis_fix.rb) is a script that will fix your account's json_metadata field, if it looks like this:

{created_at: 'GENESIS'}

Install

To use this Radiator script:

Linux
$ sudo apt-get install ruby-full git openssl libssl1.0.0 libssl-dev
$ gem install bundler
macOS
$ gem install bundler

I've tested it on various versions of ruby. The oldest one I got it to work was:

ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-darwin14.4.0]

First, clone this gist and install the dependencies:

$ git clone https://gist.github.com/814532e66cc4cd537f418ac7f1f420d5.git genesis_fix
$ cd genesis_fix
$ bundle install

Edit genesis_fix.yml, then run it:

$ ruby genesis_fix.rb

Check here to see an updated version of this script:

https://gist.github.com/inertia186/814532e66cc4cd537f418ac7f1f420d5


Upgrade

Typically, you can upgrade to the latest version by this command, from the original directory you cloned into:

$ git pull

Usually, this works fine as long as you haven't modified anything. If you get an error, try this:

$ git stash --all
$ git pull --rebase
$ git stash pop

If you're still having problems, I suggest starting a new clone.


Troubleshooting

Problem: What does this error mean?
genesis_fix.yml:1: syntax error, unexpected ':', expecting end-of-input
Solution: You ran ruby genesis_fix.yml but you should run ruby genesis_fix.rb.

Problem: Everything looks ok, but every time genesis_fix tries to post, I get this error:
`from_base58': Invalid version (RuntimeError)
Solution: You're trying to vote with an invalid key.

Make sure the .yml file account item has the correct account name and WIF active key.


See my previous Ruby How To posts in: #radiator #ruby

Get in touch!

If you're using genesis_fix, I'd love to hear from you. Drop me a line and tell me what you think! I'm @inertia on STEEM and SteemSpeak.

License

I don't believe in intellectual "property". If you do, consider genesis_fix as licensed under a Creative Commons CC0 License.

source 'https://rubygems.org'
gem 'radiator', git: 'https://github.com/inertia186/radiator.git'
gem 'pry'
GIT
remote: https://github.com/inertia186/radiator.git
revision: 8260788471efb27ceec58f2c3c86f98f2a199991
specs:
radiator (0.1.3)
bitcoin-ruby (= 0.0.10)
ffi (= 1.9.17)
hashie (>= 1.1)
json (~> 1.8.6)
logging (~> 2.2.0)
net-http-persistent (~> 2.9.4)
GEM
remote: https://rubygems.org/
specs:
bitcoin-ruby (0.0.10)
coderay (1.1.1)
ffi (1.9.17)
hashie (3.5.5)
json (1.8.6)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
method_source (0.8.2)
multi_json (1.12.1)
net-http-persistent (2.9.4)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
slop (3.6.0)
PLATFORMS
ruby
DEPENDENCIES
pry
radiator!
BUNDLED WITH
1.14.3
require 'rubygems'
require 'bundler/setup'
require 'yaml'
require 'pry'
Bundler.require
genesis_fix_path = __FILE__.sub(/\.rb$/, '.yml')
unless File.exist? genesis_fix_path
puts "Unable to find: #{genesis_fix_path}"
exit
end
genesis_fix = YAML.load_file(genesis_fix_path)
chain_options = genesis_fix[:chain_options]
account = genesis_fix[:account]
account_name = account[:name]
account_active_wif = account[:active_wif]
api = Radiator::Api.new(chain_options.dup)
response = api.get_accounts([account_name])
account = response.result.first
if account.nil?
raise "Unable to find account: #{account_name}"
end
unless account.json_metadata == '{created_at: \'GENESIS\'}'
raise "Unexpected json: #{account.json_metadata}"
end
account_update = {
type: :account_update,
memo_key: account.memo_key,
json_metadata: '{"created_at": "GENESIS"}'
}
tx = Radiator::Transaction.new(chain_options.dup.merge(wif: account_active_wif))
tx.operations = [Radiator::Operation.new(account_update)]
response = tx.process(true)
puts response
:account:
:name: <Your Account>
:active_wif: <Your Active Wif>
:chain_options:
:chain: golos
:url: https://ws.golos.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment