Skip to content

Commit

Permalink
Coinbase-SDK V0.0.6 release (#68)
Browse files Browse the repository at this point in the history
### What changed? Why?

- Ability to create wallets backed by server signers and transfer with
them
- Changed save_wallet to save_seed
- Changed load_wallets to load_seed and moved at wallet level

#### Qualified Impact
<!-- Please evaluate what components could be affected and what the
impact would be if there was an
error. How would this error be resolved, e.g. rollback a deploy, push a
new fix, disable a feature
flag, etc... -->

---------

Co-authored-by: yuga-cb <82042350+yuga-cb@users.noreply.github.com>
Co-authored-by: Alexander Stone <alex.stone@coinbase.com>
Co-authored-by: Yuga Cohler <yuga.cohler@coinbase.com>
Co-authored-by: John-peterson-coinbase <98187317+John-peterson-coinbase@users.noreply.github.com>
  • Loading branch information
5 people committed Jun 3, 2024
1 parent 6030264 commit 9e356ed
Show file tree
Hide file tree
Showing 79 changed files with 47,885 additions and 3,113 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Gemfile.lock
lib/**/.DS_Store
.idea
.DS_Store
seeds.json
seeds.json
coverage
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Trade

## [0.0.6] - 2024-06-03

### Added

- Server-Signer feature: ability to create wallets backed by server signers and create transfers with them.

### Changed

- Changed save_wallet to save_seed
- Changed load_wallets to load_seed and moved at wallet level

## [0.0.5] - 2024-05-20

### Added

- `wallets` method on the User class
- Ability to hydrate wallets (i.e. set the seed on it)
- Ability to create wallets backed by server signers.
- Note: External developers cannot use this until we enable them to create and run them.

## [0.0.4] - 2024-05-13

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ lint:
test:
bundle exec rake test

.PHONY: test-coverage
test-coverage:
open coverage/index.html

.PHONY: repl
repl:
bundle exec bin/repl
Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ This will allow you to [authenticate](./authentication.md) with the Platform API
u = Coinbase.default_user
```

If you are using a CDP Server-Signer to manage your private keys, enable it with

```ruby
Coinbase.configuration.use_server_signer=true
```
Now, create a wallet from the User. Wallets are created with a single default address.

```ruby
Expand Down Expand Up @@ -227,14 +232,17 @@ store(data.to_hash)

For more information on wallet persistence, see [the documentation on wallets](./wallets.md#persisting-a-wallet).

Alternatively, you can use the `save_wallet_locally!` function to persist wallets on your local file system. This is a
Alternatively, you can use the `save_seed!` function to persist a wallet's seed to a local file. This is a
convenience function purely for testing purposes, and should not be considered a secure method of persisting wallets.

```ruby
# Set encrypt: true to encrypt the wallet export data with your CDP API key.
u.save_wallet_locally!(w1, encrypt: true)
# Pick a file to which to save your wallet seed.
file_path = 'my_seed.json'

puts "Wallet #{w1.id} successfully saved to local file storage."
# Set encrypt: true to encrypt the wallet seed with your CDP API key.
w1.save_seed!(file_path, encrypt: true)

puts "Seed for wallet #{w1.id} successfully saved to #{file_path}."
```

## Re-instantiating a Wallet
Expand All @@ -250,17 +258,16 @@ fetched_data = fetch(w1.id)
w3 = u.import_wallet(fetched_data)
```

If you used the `save_wallet_locally!` function to persist wallets on your local file system, then you can use the
`load_wallets_from_local` function re-instantiate the wallets.
If you used the `save_seed!` function to persist a wallet's seed to a local file, then you can first fetch
the unhydrated wallet from the server, and then use the `load_seed` method to re-instantiate the wallet.

```ruby
# wallets will contain a Hash from wallet ID to wallet.
wallets = u.load_wallets_from_local

puts "Wallets successfully loaded from local file storage."
# Get the unhydrated wallet from the server.
w4 = u.wallet(w1.id)

# w4 will be equivalent to w1 and w3.
w4 = wallets[w1.id]
# You can now load the seed into the wallet from the local file.
# w4 will be equivalent to w1.
w4.load_seed(file_path)
```

## Development
Expand Down
1 change: 1 addition & 0 deletions coinbase.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec'
# Pin to a specific version of RuboCop to ensure consistent linting.
spec.add_development_dependency 'rubocop', '1.63.1'
spec.add_development_dependency 'simplecov'
# Pin to a specific version of YARD to ensure consistent documentation generation.
spec.add_development_dependency 'yard', '0.9.36'
spec.add_development_dependency 'yard-markdown'
Expand Down
Loading

0 comments on commit 9e356ed

Please sign in to comment.