Created
June 21, 2018 04:52
-
-
Save tranvictor/37944aa9012deb94f9f3c924886a90cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def callUpdateToKyberAPI(email, addresses, timestamps) | |
| key = Rails.application.secrets.kyber_key | |
| nonce = (Time.now.to_f * 1000).to_i | |
| msg = URI.encode_www_form( | |
| [[:addresses, addresses], [:nonce, nonce], [:timestamps, timestamps], [:user, email]]) | |
| uri = URI.parse("https://mainnet-data.kyber.network/update-user-addresses") | |
| https = Net::HTTP.new(uri.host,uri.port) | |
| https.use_ssl = true | |
| req = Net::HTTP::Post.new( | |
| uri.path, initheader = { | |
| 'Content-Type' => 'application/x-www-form-urlencoded', | |
| 'signed' => OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), key, msg) | |
| }) | |
| req.body = msg | |
| res = https.request(req) | |
| JSON.parse(res.body) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment