New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@coinbase/coinbase-sdk

Package Overview
Dependencies
Maintainers
9
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coinbase/coinbase-sdk - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

30

dist/coinbase/asset.js

@@ -41,16 +41,18 @@ "use strict";

// TODO: Push this logic down to the backend.
if (assetId &&
model.asset_id &&
coinbase_1.Coinbase.toAssetId(model.asset_id) !== coinbase_1.Coinbase.toAssetId(assetId)) {
switch (assetId) {
case "gwei":
decimals = constants_1.GWEI_DECIMALS;
break;
case "wei":
decimals = 0;
break;
case "eth":
break;
default:
throw new errors_1.ArgumentError(`Invalid asset ID: ${assetId}`);
if (assetId && model.asset_id) {
const normalizedModelAssetId = model.asset_id.toLowerCase();
const normalizedAssetId = assetId.toLowerCase();
if (coinbase_1.Coinbase.toAssetId(normalizedModelAssetId) !== coinbase_1.Coinbase.toAssetId(normalizedAssetId)) {
switch (normalizedAssetId) {
case "gwei":
decimals = constants_1.GWEI_DECIMALS;
break;
case "wei":
decimals = 0;
break;
case "eth":
break;
default:
throw new errors_1.ArgumentError(`Invalid asset ID: ${assetId}`);
}
}

@@ -57,0 +59,0 @@ }

@@ -54,2 +54,28 @@ "use strict";

});
describe("when the asset_id is not checksummed", () => {
it("should return the model with non-checksummed assetId", () => {
const nonChecksummedAssetId = "0x8309fbdf021edf768dc13195741940ba544dea98";
const model = {
asset_id: "0x8309fbdF021eDF768DC13195741940ba544dEa98",
network_id: coinbase_1.Coinbase.networks.BaseMainnet,
contract_address: "0x8309fbdF021eDF768DC13195741940ba544dEa98",
decimals: 18,
};
const asset = asset_1.Asset.fromModel(model, nonChecksummedAssetId);
expect(asset.getAssetId()).toEqual("0x8309fbdf021edf768dc13195741940ba544dea98");
});
});
describe("when the asset_id is checksummed", () => {
it("should return the model with checksummed assetId", () => {
const checksummedAssetId = "0x8309fbdF021eDF768DC13195741940ba544dEa98";
const model = {
asset_id: "0x8309fbdF021eDF768DC13195741940ba544dEa98",
network_id: coinbase_1.Coinbase.networks.BaseMainnet,
contract_address: "0x8309fbdF021eDF768DC13195741940ba544dEa98",
decimals: 18,
};
const asset = asset_1.Asset.fromModel(model, checksummedAssetId);
expect(asset.getAssetId()).toEqual(checksummedAssetId);
});
});
});

@@ -56,0 +82,0 @@ describe("#toString", () => {

@@ -122,2 +122,36 @@ "use strict";

}, 60000);
it.skip("should be able to make gasless transfers", async () => {
// Import wallet with balance
const seedFile = JSON.parse(process.env.WALLET_DATA || "");
const walletId = Object.keys(seedFile)[0];
const seed = seedFile[walletId].seed;
const sourceWallet = await index_1.Wallet.import({
seed,
walletId,
networkId: index_1.Coinbase.networks.BaseSepolia,
});
// Create destination wallet
const destinationWallet = await index_1.Wallet.create();
// Initialize transfer amount
const transferAmount = 0.000001;
console.log(`Making gasless transfer of ${transferAmount} USDC...`);
const transfer = await sourceWallet.createTransfer({
amount: transferAmount,
assetId: index_1.Coinbase.assets.Usdc,
destination: destinationWallet,
gasless: true,
});
await transfer.wait();
await new Promise(resolve => setTimeout(resolve, 60000));
expect(transfer.toString()).toBeDefined();
expect(await transfer.getStatus()).toBe(types_1.TransferStatus.COMPLETE);
console.log(`Completed gasless transfer from ${sourceWallet} to ${destinationWallet}`);
// Verify balances
const sourceBalance = await sourceWallet.listBalances();
const destBalance = await destinationWallet.listBalances();
expect(sourceBalance.get(index_1.Coinbase.assets.Usdc)).not.toEqual("0");
expect(destBalance.get(index_1.Coinbase.assets.Usdc)?.toString()).toEqual(`${transferAmount}`);
console.log(`Source balance: ${sourceBalance}`);
console.log(`Destination balance: ${destBalance}`);
}, 200000);
});

@@ -124,0 +158,0 @@ describe("Coinbase SDK Stake E2E Test", () => {

@@ -7,3 +7,3 @@ {

"repository": "https://github.com/coinbase/coinbase-sdk-nodejs",
"version": "0.15.0",
"version": "0.16.0",
"main": "dist/index.js",

@@ -10,0 +10,0 @@ "types": "dist/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc