Skip to content

Commit ec60f5a

Browse files
authored
Merge pull request #176 from coinbase/v0.1.0
V0.1.0 SDK Release
2 parents 9be2165 + 451c638 commit ec60f5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2424
-1279
lines changed

CAPABILITIES.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,20 @@ those capabilities for the NodeJS SDK:
66
## Developer Wallets
77

88
| Concept | Base-Sepolia | Base-Mainnet | Ethereum-Holesky | Ethereum-Mainnet |
9-
| ------------- | :----------: | :----------: | :--------------: | :--------------: |
10-
| Addresses |||||
11-
| Send |||||
12-
| Trade |||||
13-
| Faucet |||||
14-
| Server-Signer |||||
15-
| Stake [^1] |||||
16-
17-
[^1]: Currently only available for Shared ETH Staking.
9+
|---------------|:------------:|:------------:|:----------------:|:----------------:|
10+
| Addresses |||||
11+
| Send |||||
12+
| Trade |||||
13+
| Faucet |||||
14+
| Server-Signer |||||
15+
| Stake |||||
1816

1917
## End-User Wallets
2018

2119
| Concept | Base-Sepolia | Base-Mainnet | Ethereum-Holesky | Ethereum-Mainnet |
22-
| ------------------ | :----------: | :----------: | :--------------: | :--------------: |
23-
| External Addresses |||||
24-
| Stake [^2] |||||
25-
26-
[^2]: Dedicated ETH Staking is currently only available on Testnet (Ethereum-Holesky).
20+
|--------------------|:------------:|:------------:|:----------------:|:----------------:|
21+
| External Addresses |||||
22+
| Stake |||||
2723

2824
## Testnet vs. Mainnet
2925

@@ -32,4 +28,4 @@ The Coinbase SDK supports both testnets and mainnets.
3228
- Testnets are for building and testing applications. Funds are not real, and you can get test currencies from a faucet.
3329
- Mainnet is where the funds, contracts and applications are real.
3430

35-
Wallets, assets, etc, cannot be moved from testnet to mainnet (or vice versa).
31+
Wallets, assets, etc. cannot be moved from testnet to mainnet (or vice versa).

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Coinbase Node.js SDK Changelog
22

3+
## Unreleased
4+
5+
## [0.1.0] - 2024-08-22
6+
7+
### Added
8+
9+
- Add `listHistoricalBalances` wallet method, that lists the historical balances for the wallet's default address.
10+
- Add toAddressId() method to Transaction class
11+
12+
### Removed
13+
14+
- Remove user concept from the SDK
15+
- Remove "pending" status from StakingOperationStatusEnum
16+
- Add staking operation class helper methods like `isTerminalState`, `isFailedState` and `isCompleteState`.
17+
- Add validator status enum
18+
19+
### Changed
20+
21+
- The `createTransfer` and `createTrade` functions no longer wait for the transactions to confirm or
22+
fail on-chain.
23+
- Now they return a `Transfer` and `Trade` object respectively, which support the `wait`
24+
function, e.g. `await transfer.wait()`.
25+
- This ensures that the developer has a reference to the object in case there is a timeout while
26+
waiting to land on-chain.
27+
- Update `reload()` method to work with both External and Wallet address.
28+
- Update `createStakingOperation` logic to make sure we only pull in newer unsigned txs from the server.
29+
This is especially important for External Address use-case where tx signing and broadcast status is maintained on client side, and we risk overwriting the existing txs.
30+
- Increase default timeout for `createStakingOperation` to 10 min.
31+
332
## [0.0.16] - 2024-08-14
433

534
### Added
@@ -8,7 +37,7 @@
837
- Support for retrieving historical staking balances information
938
- USD value conversion details to the StakingReward object
1039
- Gasless USDC Sends
11-
- Support for Etherum-Mainnet and Polygon-Mainnet
40+
- Support for Ethereum-Mainnet and Polygon-Mainnet
1241

1342
## [0.0.15] - 2024-08-12
1443

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ nvm use node
4242

4343
Optional: Initialize the npm
4444

45-
This command initializes a new npm project with default settings and configures it to use ES modules by setting the type field to "module" in the package.json file.
45+
This command initializes a new npm project with default settings and configures it to use ES modules by setting the type field to "module" in the package.json file.
4646

4747
```bash
4848
npm init -y; npm pkg set type="module"
@@ -68,13 +68,13 @@ yarn add @coinbase/coinbase-sdk
6868
CommonJs:
6969

7070
```javascript
71-
const { Coinbase } = require("@coinbase/coinbase-sdk");
71+
const { Coinbase, Wallet } = require("@coinbase/coinbase-sdk");
7272
```
7373

7474
ES modules:
7575

7676
```typescript
77-
import { Coinbase } from "@coinbase/coinbase-sdk";
77+
import { Coinbase, Wallet } from "@coinbase/coinbase-sdk";
7878
```
7979

8080
To start, [create a CDP API Key](https://portal.cdp.coinbase.com/access/api). Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the `Coinbase` constructor:
@@ -98,34 +98,38 @@ Another way to initialize the SDK is by sourcing the API key from the json file
9898
const coinbase = Coinbase.configureFromJson({ filePath: "path/to/your/api-key.json" });
9999
```
100100

101-
This will allow you to authenticate with the Platform APIs and get access to the default `User`.
101+
This will allow you to authenticate with the Platform APIs.
102102

103103
CommonJs:
104104

105105
```javascript
106-
const { Coinbase } = require("@coinbase/coinbase-sdk");
106+
const { Coinbase, Wallet } = require("@coinbase/coinbase-sdk");
107107
const coinbase = Coinbase.configureFromJson("path/to/your/api-key.json");
108-
coinbase.getDefaultUser().then(user => {
109-
console.log(user);
108+
109+
// List all Wallets for the CDP Project.
110+
Wallet.listWallets().then(wallets => {
111+
console.log(wallets);
110112
});
111113
```
112114

113115
Or using ES modules and async/await:
114116

115117
```typescript
116-
import { Coinbase } from "@coinbase/coinbase-sdk";
118+
import { Coinbase, Wallet } from "@coinbase/coinbase-sdk";
117119
const coinbase = Coinbase.configureFromJson("path/to/your/api-key.json");
118-
const user = await coinbase.getDefaultUser();
119-
console.log(user);
120+
121+
// List all Wallets for the CDP Project.
122+
const wallets = await Wallet.listWallets();
123+
console.log(wallets);
120124
```
121125

122126
### Wallets, Addresses, and Transfers
123127

124-
Now, create a Wallet from the User. Wallets are created with a single default Address.
128+
Now, create a Wallet which will default to the Base Sepolia testnet network (if not specified).
125129

126130
```typescript
127131
// Create a Wallet with one Address by default.
128-
const wallet = await user.createWallet();
132+
const wallet = await Wallet.create();
129133
```
130134

131135
Next, view the default Address of your Wallet. You will need this default Address in order to fund the Wallet for your first Transfer.
@@ -149,7 +153,7 @@ console.log(`Faucet transaction: ${faucetTransaction}`);
149153
```typescript
150154
// Create a new Wallet to transfer funds to.
151155
// Then, we can transfer 0.00001 ETH out of the Wallet to another Wallet.
152-
const anotherWallet = await user.createWallet();
156+
const anotherWallet = await Wallet.create();
153157
const transfer = await wallet.createTransfer({ amount: 0.00001, assetId: Coinbase.assets.Eth, destination: anotherWallet });
154158
```
155159

@@ -166,7 +170,7 @@ const transfer = await wallet.createTransfer({ amount: 0.00001, assetId: Coinbas
166170

167171
```typescript
168172
// Create a Wallet on `base-mainnet` to trade assets with.
169-
let mainnetWallet = await user.createWallet({ networkId: Coinbase.networks.BaseMainnet });
173+
let mainnetWallet = await Wallet.create({ networkId: Coinbase.networks.BaseMainnet });
170174

171175
console.log(`Wallet successfully created: ${mainnetWallet}`);
172176

@@ -212,13 +216,13 @@ The below code demonstrates how to re-instantiate a Wallet from the data export.
212216

213217
```typescript
214218
// The Wallet can be re-instantiated using the exported data.
215-
const importedWallet = await user.importWallet(data);
219+
const importedWallet = await Wallet.import(data);
216220
```
217221

218222
To import Wallets that were persisted to your local file system using `saveSeed`, use the below code.
219223

220224
```typescript
221-
const userWallet = await user.getWallet(wallet.getId());
225+
const userWallet = await Wallet.fetch(wallet.getId());
222226
await userWallet.loadSeed(seedFilePath);
223227
```
224228

0 commit comments

Comments
 (0)