Skip to content

Commit 10a646a

Browse files
authored
release v0.14.0 (#361)
* feat(PSDK-782): allow users to send sponsored transactions immediately (#357) * chore: bump version to v0.14.0 (#359)
1 parent 343e123 commit 10a646a

File tree

11 files changed

+527
-7
lines changed

11 files changed

+527
-7
lines changed

CHANGELOG.md

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

3+
## [0.14.0] - 2025-01-14
4+
5+
### Added
6+
- Add `skipBatching` option to `Wallet.createTransfer` to allow for lower latency gasless transfers.
7+
38
## [0.13.0] - 2024-12-19
49

510
### Added

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ let transfer = await wallet.createTransfer({ amount: 0.00001, assetId: Coinbase.
162162
transfer = await transfer.wait();
163163
```
164164

165+
By default, gasless transfers are batched with other transfers, and might take longer to submit. If you want to opt out of batching, you can set the `skipBatching` option to `true`, which will submit the transaction immediately.
166+
```typescript
167+
let transfer = await wallet.createTransfer({
168+
amount: 0.00001,
169+
assetId: Coinbase.assets.Usdc,
170+
destination: anotherWallet,
171+
gasless: true,
172+
skipBatching: true
173+
});
174+
transfer = await transfer.wait();
175+
```
165176

166177
### Trading Funds
167178

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "ISC",
55
"description": "Coinbase Platform SDK",
66
"repository": "https://github.com/coinbase/coinbase-sdk-nodejs",
7-
"version": "0.13.0",
7+
"version": "0.14.0",
88
"main": "dist/index.js",
99
"types": "dist/index.d.ts",
1010
"scripts": {

quickstart-template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"@solana/web3.js": "^2.0.0-rc.1",
2424
"bs58": "^6.0.0",
25-
"@coinbase/coinbase-sdk": "^0.13.0",
25+
"@coinbase/coinbase-sdk": "^0.14.0",
2626
"csv-parse": "^5.5.6",
2727
"csv-writer": "^1.6.0",
2828
"viem": "^2.21.6"

src/client/api.ts

Lines changed: 365 additions & 3 deletions
Large diffs are not rendered by default.

src/coinbase/address/wallet_address.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export class WalletAddress extends Address {
203203
* @param options.assetId - The ID of the Asset to send. For Ether, Coinbase.assets.Eth, Coinbase.assets.Gwei, and Coinbase.assets.Wei supported.
204204
* @param options.destination - The destination of the transfer. If a Wallet, sends to the Wallet's default address. If a String, interprets it as the address ID.
205205
* @param options.gasless - Whether the Transfer should be gasless. Defaults to false.
206+
* @param options.skipBatching - When true, the Transfer will be submitted immediately. Otherwise, the Transfer will be batched. Defaults to false. Note: requires gasless option to be set to true.
206207
* @returns The transfer object.
207208
* @throws {APIError} if the API request to create a Transfer fails.
208209
* @throws {APIError} if the API request to broadcast a Transfer fails.
@@ -212,6 +213,7 @@ export class WalletAddress extends Address {
212213
assetId,
213214
destination,
214215
gasless = false,
216+
skipBatching = false,
215217
}: CreateTransferOptions): Promise<Transfer> {
216218
if (!Coinbase.useServerSigner && !this.key) {
217219
throw new Error("Cannot transfer from address without private key loaded");
@@ -228,12 +230,17 @@ export class WalletAddress extends Address {
228230
);
229231
}
230232

233+
if (skipBatching && !gasless) {
234+
throw new ArgumentError("skipBatching requires gasless to be true");
235+
}
236+
231237
const createTransferRequest = {
232238
amount: asset.toAtomicAmount(normalizedAmount).toString(),
233239
network_id: destinationNetworkId,
234240
asset_id: asset.primaryDenomination(),
235241
destination: destinationAddress,
236242
gasless: gasless,
243+
skip_batching: skipBatching,
237244
};
238245

239246
const response = await Coinbase.apiClients.transfer!.createTransfer(

src/coinbase/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ export type CreateTransferOptions = {
10851085
assetId: string;
10861086
destination: Destination;
10871087
gasless?: boolean;
1088+
skipBatching?: boolean;
10881089
};
10891090

10901091
/**

src/coinbase/wallet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ export class Wallet {
840840
* @param options.assetId - The ID of the Asset to send.
841841
* @param options.destination - The destination of the transfer. If a Wallet, sends to the Wallet's default address. If a String, interprets it as the address ID.
842842
* @param options.gasless - Whether the Transfer should be gasless. Defaults to false.
843+
* @param options.skipBatching - When true, the Transfer will be submitted immediately. Otherwise, the Transfer will be batched. Defaults to false. Note: requires gasless option to be set to true.
843844
* @returns The created Transfer object.
844845
* @throws {APIError} if the API request to create a Transfer fails.
845846
* @throws {APIError} if the API request to broadcast a Transfer fails.

src/tests/wallet_address_test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,63 @@ describe("WalletAddress", () => {
707707
expect(transfer.getId()).toBe(VALID_TRANSFER_MODEL.transfer_id);
708708
});
709709

710+
it("should default skipBatching to false", async () => {
711+
Coinbase.apiClients.transfer!.createTransfer = mockReturnValue(VALID_TRANSFER_MODEL);
712+
Coinbase.apiClients.transfer!.broadcastTransfer = mockReturnValue({
713+
transaction_hash: "0x6c087c1676e8269dd81e0777244584d0cbfd39b6997b3477242a008fa9349e11",
714+
...VALID_TRANSFER_MODEL,
715+
});
716+
717+
await address.createTransfer({
718+
amount: weiAmount,
719+
assetId: Coinbase.assets.Wei,
720+
destination,
721+
});
722+
723+
expect(Coinbase.apiClients.transfer!.createTransfer).toHaveBeenCalledWith(
724+
address.getWalletId(),
725+
address.getId(),
726+
expect.objectContaining({
727+
skip_batching: false,
728+
}),
729+
);
730+
});
731+
732+
it("should allow skipBatching to be set to true", async () => {
733+
Coinbase.apiClients.transfer!.createTransfer = mockReturnValue(VALID_TRANSFER_MODEL);
734+
Coinbase.apiClients.transfer!.broadcastTransfer = mockReturnValue({
735+
transaction_hash: "0x6c087c1676e8269dd81e0777244584d0cbfd39b6997b3477242a008fa9349e11",
736+
...VALID_TRANSFER_MODEL,
737+
});
738+
739+
await address.createTransfer({
740+
amount: weiAmount,
741+
assetId: Coinbase.assets.Wei,
742+
destination,
743+
gasless: true,
744+
skipBatching: true,
745+
});
746+
747+
expect(Coinbase.apiClients.transfer!.createTransfer).toHaveBeenCalledWith(
748+
address.getWalletId(),
749+
address.getId(),
750+
expect.objectContaining({
751+
skip_batching: true,
752+
}),
753+
);
754+
});
755+
756+
it("should throw an ArgumentError if skipBatching is true but gasless is false", async () => {
757+
await expect(
758+
address.createTransfer({
759+
amount: weiAmount,
760+
assetId: Coinbase.assets.Wei,
761+
destination,
762+
skipBatching: true,
763+
}),
764+
).rejects.toThrow(ArgumentError);
765+
});
766+
710767
it("should successfully construct createTransfer request when using a large number that causes scientific notation", async () => {
711768
Coinbase.apiClients.transfer!.createTransfer = mockReturnValue(VALID_TRANSFER_MODEL);
712769
Coinbase.apiClients.transfer!.broadcastTransfer = mockReturnValue({
@@ -745,6 +802,7 @@ describe("WalletAddress", () => {
745802
destination: destination.getId(),
746803
gasless: false,
747804
network_id: Coinbase.networks.BaseSepolia,
805+
skip_batching: false,
748806
},
749807
);
750808

0 commit comments

Comments
 (0)