Ruby
Turnkey offers native tooling for interacting with the API using Ruby. See https://github.com/tkhq/ruby-sdk for more details.
This repository contains a Ruby gem, turnkey_client
to interact with the Turnkey API.
Using Turnkey in your Ruby projects
To install turnkey_client
, install it with bundler:
Then require
it in Ruby files to use it:
See the examples folder if you’re looking for a complete sample project
Examples
- Whoami: example showcasing API request signing in its simplest form
- Signing: example showcasing wallet creation and ETH message signing
Using Turnkey in your Rails projects
To use in Rails we recommend creating a new config/initializers/turnkey.rb
file:
You can then use this in your controller or models with:
Re-generating turnkey_client
We use a swagger spec and Swagger Codegen to generate turnkey_client
. To update this gem:
- Update the swagger spec in
turnkey_client_inputs
- Bump
gemVersion
inconfig.json
- Run
make
Updating codegen templates
We use custom templates to insert custom functionality, namely:
- added
openssl
as a dependency to load API keys - added functionality to insert
X-Stamp
headers to requests for authentication - modified
configure
function to require a valid P256 public/private key pair at initialization time
If you want to tweak something related to codegen itself, head (here), make the desired change, and re-generate turnkey_client
If you want to update templates with upstream this is a bit harder but possible: these templates were downloaded from this folder (this is a permalink to the right git SHA). You can see all the changes made to these by looking at the history of changes in the templates folder: https://github.com/tkhq/ruby-sdk/commits/main/turnkey_client_inputs/templates.
Ruby
On Mac, Ruby will come installed automatically. However, the default version might not be compatible with certain gems, nor will it allow you to modify the default gems directory. To set up Ruby, there are many options: rbenv, rvm, asdf, chruby, etc. For example, rbenv can be set up by following the instructions here.
Rubocop
We use Rubocop for linting. To install:
And run:
Releasing on Rubygems.org
To build and release: