mirror of
https://github.com/hanzoai/account-sdk.git
synced 2026-09-24 16:55:42 +00:00
[BA-2214] Package Renaming (#6)
This commit is contained in:
+1
-1
@@ -1,3 +1,3 @@
|
||||
secure:
|
||||
required_reviews: 1
|
||||
upstream_repository: coinbase/coinbase-wallet-sdk
|
||||
upstream_repository: base/account-sdk
|
||||
|
||||
@@ -38,7 +38,7 @@ body:
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: Which version of Coinbase Wallet SDK
|
||||
description: Which version of Base Account SDK
|
||||
|
||||
- type: textarea
|
||||
id: additional
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Coinbase Wallet Developer Docs
|
||||
url: https://docs.cloud.coinbase.com/wallet-sdk/docs
|
||||
about: Coinbase Wallet's developer documentation
|
||||
- name: Base Account Developer Docs
|
||||
url: https://www.base.org/builders/smart-wallet
|
||||
about: Base Account's developer documentation
|
||||
|
||||
@@ -81,7 +81,7 @@ jobs:
|
||||
|
||||
- name: Runs compile asset script
|
||||
run: |
|
||||
cd ./packages/wallet-sdk
|
||||
cd ./packages/account-sdk
|
||||
yarn build
|
||||
node ./compile-assets.cjs
|
||||
cd ../../
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Deploy Coinbase Wallet SDK Playground to Pages
|
||||
name: Deploy Base Account SDK Playground to Pages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -29,14 +29,14 @@ jobs:
|
||||
uses: ./.github/actions/setup
|
||||
|
||||
- name: Set version
|
||||
run: yarn workspace @coinbase/wallet-sdk version ${{ env.PACKAGE_VERSION }}-canary.$(date +'%Y%m%d%H%M%S')
|
||||
run: yarn workspace @base/account-sdk version ${{ env.PACKAGE_VERSION }}-canary.$(date +'%Y%m%d%H%M%S')
|
||||
|
||||
# Build the package
|
||||
- name: Prebuild Packages
|
||||
run: yarn workspace @coinbase/wallet-sdk prebuild
|
||||
run: yarn workspace @base/account-sdk prebuild
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn workspace @coinbase/wallet-sdk build
|
||||
run: yarn workspace @base/account-sdk build
|
||||
|
||||
# Publish to npm
|
||||
- name: Set deployment token
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
|
||||
- name: Publish to npm
|
||||
run: |
|
||||
cd packages/wallet-sdk
|
||||
cd packages/account-sdk
|
||||
npm publish --tag canary
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
@@ -29,14 +29,14 @@ jobs:
|
||||
uses: ./.github/actions/setup
|
||||
|
||||
- name: Set version
|
||||
run: yarn workspace @coinbase/wallet-sdk version ${{ env.PACKAGE_VERSION }}
|
||||
run: yarn workspace @base/account-sdk version ${{ env.PACKAGE_VERSION }}
|
||||
|
||||
# Build the package
|
||||
- name: Prebuild Packages
|
||||
run: yarn workspace @coinbase/wallet-sdk prebuild
|
||||
run: yarn workspace @base/account-sdk prebuild
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn workspace @coinbase/wallet-sdk build
|
||||
run: yarn workspace @base/account-sdk build
|
||||
|
||||
# Publish to npm
|
||||
- name: Set deployment token
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
|
||||
- name: Publish to npm
|
||||
run: |
|
||||
cd packages/wallet-sdk
|
||||
cd packages/account-sdk
|
||||
npm publish --tag latest
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
* @coinbase/coinbase-wallet-sdk
|
||||
* @base/account-sdk
|
||||
|
||||
+8
-8
@@ -15,21 +15,21 @@
|
||||
|
||||
## How to Contribute
|
||||
|
||||
🎉 First off, thank you for considering contributing to the Coinbase Wallet SDK! 🎉
|
||||
🎉 First off, thank you for considering contributing to the Base Account SDK! 🎉
|
||||
|
||||
The following is a set of guidelines for contributing to the Coinbase Wallet SDK. These are just guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
|
||||
The following is a set of guidelines for contributing to the Base Account SDK. These are just guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
|
||||
|
||||
### Reporting Bugs
|
||||
|
||||
1. **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/coinbase/coinbase-wallet-sdk/issues).
|
||||
1. **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/base/account-sdk/issues).
|
||||
|
||||
2. If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/coinbase/coinbase-wallet-sdk/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||
2. If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/base/account-sdk/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||
|
||||
### Suggesting Enhancements
|
||||
|
||||
1. **Check the [Issues](https://github.com/coinbase/coinbase-wallet-sdk/issues)** to see if there's someone who has already suggested the same enhancement.
|
||||
1. **Check the [Issues](https://github.com/base/account-sdk/issues)** to see if there's someone who has already suggested the same enhancement.
|
||||
|
||||
2. If it doesn't exist, [create a new issue](https://github.com/coinbase/coinbase-wallet-sdk/issues/new). Provide a clear and detailed explanation of the feature you want and why it's important to add.
|
||||
2. If it doesn't exist, [create a new issue](https://github.com/base/account-sdk/issues/new). Provide a clear and detailed explanation of the feature you want and why it's important to add.
|
||||
|
||||
### Pull Requests
|
||||
|
||||
@@ -52,7 +52,7 @@ The following is a set of guidelines for contributing to the Coinbase Wallet SDK
|
||||
First, ensure that the following are installed globally on your machine:
|
||||
|
||||
- [Node.js 20.11+](https://nodejs.org/en/download/releases)
|
||||
- [Yarn v3](https://yarnpkg.com/getting-started/install)
|
||||
- [Yarn v4](https://yarnpkg.com/getting-started/install)
|
||||
|
||||
Then, from the root folder run:
|
||||
|
||||
@@ -65,7 +65,7 @@ Then, from the root folder run:
|
||||
|
||||
The SDK is built using yarn workspaces.
|
||||
|
||||
- `packages/wallet-sdk` - The main package that exports the SDK
|
||||
- `packages/account-sdk` - The main package that exports the SDK
|
||||
- `examples/test-app` - An example React app that is used to test the SDK in a real browser environment
|
||||
|
||||
Use `yarn dev` to start the example app and build the package with hot reloading.
|
||||
|
||||
@@ -1,87 +1,80 @@
|
||||
# Coinbase Wallet SDK
|
||||
# Base Account SDK
|
||||
|
||||
[](https://www.npmjs.com/package/@coinbase/wallet-sdk)
|
||||
[](https://www.npmjs.com/package/@base/account-sdk)
|
||||
|
||||
## Coinbase Wallet SDK allows dapps to connect to Coinbase Wallet
|
||||
## Base Account SDK allows dapps to connect to Base Account
|
||||
|
||||
1. [Coinbase Smart Wallet](https://keys.coinbase.com/onboarding)
|
||||
- [Docs](https://www.smartwallet.dev/)
|
||||
1. Coinbase Wallet mobile for [Android](https://play.google.com/store/apps/details?id=org.toshi&referrer=utm_source%3DWallet_LP) and [iOS](https://apps.apple.com/app/apple-store/id1278383455?pt=118788940&ct=Wallet_LP&mt=8)
|
||||
- Desktop: Users can connect to your dapp by scanning a QR code
|
||||
- Mobile: Users can connect to your mobile dapp through a deeplink to the dapp browser
|
||||
1. Coinbase Wallet extension for [Chrome](https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad?hl=en) and [Brave](https://chromewebstore.google.com/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad?hl=en)
|
||||
- Desktop: Users can connect by clicking the connect with an extension option.
|
||||
1. [Base Account](https://account.base.org/)
|
||||
- [Docs](https://www.base.org/builders/smart-wallet)
|
||||
|
||||
### Installing Wallet SDK
|
||||
### Installing Base Account SDK
|
||||
|
||||
1. Check available versions:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn info @coinbase/wallet-sdk versions
|
||||
yarn info @base/account-sdk versions
|
||||
|
||||
# npm
|
||||
npm view @coinbase/wallet-sdk versions
|
||||
npm view @base/account-sdk versions
|
||||
```
|
||||
|
||||
2. Install latest version:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn add @coinbase/wallet-sdk
|
||||
yarn add @base/account-sdk
|
||||
|
||||
# npm
|
||||
npm install @coinbase/wallet-sdk
|
||||
npm install @base/account-sdk
|
||||
```
|
||||
|
||||
3. Check installed version:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn list @coinbase/wallet-sdk
|
||||
yarn list @base/account-sdk
|
||||
|
||||
# npm
|
||||
npm list @coinbase/wallet-sdk
|
||||
npm list @base/account-sdk
|
||||
```
|
||||
|
||||
### Upgrading Wallet SDK
|
||||
|
||||
> Migrating from v3 to v4? Please see our [v4 migration guide](https://www.smartwallet.dev/sdk/v3-to-v4-changes) for a full list of breaking changes.
|
||||
### Upgrading Base Account SDK
|
||||
|
||||
1. Compare the installed version with the latest:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn outdated @coinbase/wallet-sdk
|
||||
yarn outdated @base/account-sdk
|
||||
|
||||
# npm
|
||||
npm outdated @coinbase/wallet-sdk
|
||||
npm outdated @base/account-sdk
|
||||
```
|
||||
|
||||
2. Update to latest:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn upgrade @coinbase/wallet-sdk --latest
|
||||
yarn upgrade @base/account-sdk --latest
|
||||
|
||||
# npm
|
||||
npm update @coinbase/wallet-sdk
|
||||
npm update @base/account-sdk
|
||||
```
|
||||
|
||||
### Basic Usage
|
||||
|
||||
1. Initialize SDK
|
||||
1. Initialize Base Account SDK
|
||||
|
||||
```js
|
||||
const sdk = new CoinbaseWalletSDK({
|
||||
const sdk = createBaseAccountSDK({
|
||||
appName: 'SDK Playground',
|
||||
});
|
||||
```
|
||||
|
||||
2. Make web3 Provider
|
||||
2. Make Base Account Provider
|
||||
|
||||
```js
|
||||
const provider = sdk.makeWeb3Provider();
|
||||
const provider = sdk.getProvider();
|
||||
```
|
||||
|
||||
3. Request accounts to initialize a connection to wallet
|
||||
@@ -127,7 +120,7 @@
|
||||
|
||||
### Developing locally and running the test dapp
|
||||
|
||||
- The Coinbase Wallet SDK test dapp can be viewed here https://coinbase.github.io/coinbase-wallet-sdk/.
|
||||
- The Base Account SDK test dapp can be viewed here https://base.github.io/account-sdk/.
|
||||
- To run it locally follow these steps:
|
||||
|
||||
1. Fork this repo and clone it
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# Coinbase Wallet SDK v3.x.x
|
||||
|
||||
- [Playground](https://coinbase.github.io/coinbase-wallet-sdk/)
|
||||
- [Developer docs](https://docs.cloud.coinbase.com/wallet-sdk/docs)
|
||||
|
||||
Coinbase Wallet SDK (formerly WalletLink) lets developers connect their dapps to Coinbase Wallet
|
||||
on both mobile web (for iOS and Android) and desktop:
|
||||
|
||||
- **Mobile**: Users can connect to your mobile web dapp through a deeplink to the dapp browser in [Coinbase Wallet Mobile App](https://coinbase-wallet.onelink.me/q5Sx/fdb9b250).
|
||||
|
||||
- **Desktop**: Users can connect to your desktop app with a QR code in the [Coinbase Wallet Mobile App](https://coinbase-wallet.onelink.me/q5Sx/fdb9b250) or with the [Coinbase Wallet Chrome Extension](https://coinbase-wallet.onelink.me/q5Sx/fdb9b250).
|
||||
|
||||
Wallet SDK is open-source and uses minimal dependencies for maximum security and no code bloat. Simply drop a few lines of code into your dapp and Wallet SDK takes care of the rest.
|
||||
|
||||
## Getting started
|
||||
|
||||
This repo uses a yarn workspace. To get started, run:
|
||||
|
||||
```shell
|
||||
yarn install
|
||||
|
||||
# To start the development server run the following command. This starts a nextjs app on port 3001. Any changes in the SDK become available through the app.
|
||||
yarn dev
|
||||
|
||||
# To interact with the SDK directly:
|
||||
yarn workspace @coinbase/wallet-sdk "<command>"
|
||||
|
||||
# To lint all files
|
||||
yarn lint
|
||||
|
||||
# To typecheck all files
|
||||
yarn typecheck
|
||||
```
|
||||
|
||||
## Installing and Upgrading
|
||||
|
||||
> The installation package for **Coinbase Wallet SDK** (formerly WalletLink) is now named `@coinbase/wallet-sdk`.
|
||||
|
||||
- This [readme](/packages/wallet-sdk/README.md) contains brief instructions to get up and running.
|
||||
- Visit our [public developer docs](https://docs.cloud.coinbase.com/wallet-sdk/docs) for more detail, including samples for integrating Coinbase Wallet using libraries like [web3-react](https://github.com/Uniswap/web3-react), [web3modal](https://github.com/Web3Modal/web3modal), [Web3-Onboard](https://docs.blocknative.com/onboard), and [wagmi](https://wagmi.sh/).
|
||||
|
||||
## Libraries using Coinbase Wallet SDK
|
||||
|
||||
- [blocknative/onboard](https://github.com/blocknative/onboard)
|
||||
- [wagmi](https://github.com/tmm/wagmi)
|
||||
- [web3-react](https://github.com/NoahZinsmeister/web3-react)
|
||||
- [web3modal](https://github.com/Web3Modal/web3modal)
|
||||
@@ -1 +0,0 @@
|
||||
The migration guide has moved to https://www.smartwallet.dev/sdk/v3-to-v4-changes.
|
||||
@@ -1 +0,0 @@
|
||||
The Smart Wallet wagmi guide has moved to https://www.smartwallet.dev/guides/create-app/using-wagmi.
|
||||
@@ -1,9 +1,9 @@
|
||||
export default {
|
||||
output: 'export',
|
||||
basePath: process.env.NODE_ENV === 'production' ? '/coinbase-wallet-sdk' : undefined,
|
||||
basePath: process.env.NODE_ENV === 'production' ? '/account-sdk' : undefined,
|
||||
pageExtensions: ['page.tsx', 'page.ts', 'page.js', 'page.jsx'],
|
||||
eslint: {
|
||||
// Ignore eslint for `next lint`.
|
||||
// Ignore eslint for `next lint`.
|
||||
// GitHub discussion for supporting biome: https://github.com/vercel/next.js/discussions/59347
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"dependencies": {
|
||||
"@chakra-ui/icons": "^2.1.1",
|
||||
"@chakra-ui/react": "^2.8.0",
|
||||
"@coinbase/wallet-sdk": "workspace:*",
|
||||
"@coinbase/wallet-sdk": "npm:@coinbase/wallet-sdk@canary",
|
||||
"@coinbase/wallet-sdk-latest": "npm:@coinbase/wallet-sdk@latest",
|
||||
"@emotion/react": "^11.11.1",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
|
||||
@@ -75,22 +75,30 @@ export default function SubAccounts() {
|
||||
</Stack>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
{/* @ts-expect-error - sdk is not typed correctly */}
|
||||
<Connect sdk={sdk} />
|
||||
<AddSubAccount
|
||||
// @ts-expect-error - sdk is not typed correctly
|
||||
sdk={sdk}
|
||||
onAddSubAccount={setSubAccountAddress}
|
||||
signerFn={getSubAccountSigner}
|
||||
/>
|
||||
<AddSubAccountWithoutKeys
|
||||
// @ts-expect-error - sdk is not typed correctly
|
||||
sdk={sdk}
|
||||
onAddSubAccount={setSubAccountAddress}
|
||||
signerFn={getSubAccountSigner}
|
||||
/>
|
||||
{/* @ts-expect-error - sdk is not typed correctly */}
|
||||
<PersonalSign sdk={sdk} subAccountAddress={subAccountAddress} />
|
||||
{/* @ts-expect-error - sdk is not typed correctly */}
|
||||
<SendCalls sdk={sdk} subAccountAddress={subAccountAddress} />
|
||||
{/* @ts-expect-error - sdk is not typed correctly */}
|
||||
<GrantSpendPermission sdk={sdk} subAccountAddress={subAccountAddress} />
|
||||
{/* @ts-expect-error - sdk is not typed correctly */}
|
||||
<SpendPermissions sdk={sdk} subAccountAddress={subAccountAddress} />
|
||||
<GenerateNewSigner />
|
||||
{/* @ts-expect-error - sdk is not typed correctly */}
|
||||
<AddOwner sdk={sdk} />
|
||||
</VStack>
|
||||
</Container>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const cleanupSDKLocalStorage = () => {
|
||||
// remove all keys that contains 'cbw' or 'CBW'
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (key.startsWith('cbwsdk.') || key.startsWith('-CBWSDK:')) {
|
||||
if (key.startsWith('cbwsdk.') || key.startsWith('-CBWSDK:') || key.startsWith('base-acc-sdk')) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
});
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "coinbase-wallet-sdk",
|
||||
"name": "account-sdk",
|
||||
"version": "0.0.1",
|
||||
"repository": "https://github.com/coinbase/coinbase-wallet-sdk",
|
||||
"author": "Coinbase, Inc.",
|
||||
"repository": "https://github.com/base/account-sdk",
|
||||
"author": "Base",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
@@ -11,7 +11,7 @@
|
||||
"examples/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build:packages": "yarn workspace @coinbase/wallet-sdk build",
|
||||
"build:packages": "yarn workspace @base/account-sdk build",
|
||||
"clean": "yarn workspaces foreach -A -ipv run clean && rm -rf node_modules && yarn",
|
||||
"deploy": "yarn build:packages && yarn workspace sdk-playground export",
|
||||
"dev": "yarn workspaces foreach -A -ipv run dev",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2018-2023 Coinbase, Inc.
|
||||
Copyright (c) 2018-2025 Coinbase, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -0,0 +1,126 @@
|
||||
# Base Account SDK
|
||||
|
||||
## Base Account SDK allows dapps to connect to Base Account
|
||||
|
||||
1. [Base Account](https://account.base.org/)
|
||||
- [Docs](https://www.base.org/builders/smart-wallet)
|
||||
|
||||
### Installing Base Account SDK
|
||||
|
||||
1. Check available versions:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn info @base/account-sdk versions
|
||||
|
||||
# npm
|
||||
npm view @base/account-sdk versions
|
||||
```
|
||||
|
||||
2. Install latest version:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn add @base/account-sdk
|
||||
|
||||
# npm
|
||||
npm install @base/account-sdk
|
||||
```
|
||||
|
||||
3. Check installed version:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn list @base/account-sdk
|
||||
|
||||
# npm
|
||||
npm list @base/account-sdk
|
||||
```
|
||||
|
||||
### Upgrading Base Account SDK
|
||||
|
||||
1. Compare the installed version with the latest:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn outdated @base/account-sdk
|
||||
|
||||
# npm
|
||||
npm outdated @base/account-sdk
|
||||
```
|
||||
|
||||
2. Update to latest:
|
||||
|
||||
```shell
|
||||
# yarn
|
||||
yarn upgrade @base/account-sdk --latest
|
||||
|
||||
# npm
|
||||
npm update @base/account-sdk
|
||||
```
|
||||
|
||||
### Basic Usage
|
||||
|
||||
1. Initialize Base Account SDK
|
||||
|
||||
```js
|
||||
const sdk = createBaseAccountSDK({
|
||||
appName: 'SDK Playground',
|
||||
});
|
||||
```
|
||||
|
||||
2. Make Base Account Provider
|
||||
|
||||
```js
|
||||
const provider = sdk.getProvider();
|
||||
```
|
||||
|
||||
3. Request accounts to initialize a connection to wallet
|
||||
|
||||
```js
|
||||
const addresses = provider.request({
|
||||
method: 'eth_requestAccounts',
|
||||
});
|
||||
```
|
||||
|
||||
4. Make more requests
|
||||
|
||||
```js
|
||||
provider.request('personal_sign', [
|
||||
`0x${Buffer.from('test message', 'utf8').toString('hex')}`,
|
||||
addresses[0],
|
||||
]);
|
||||
```
|
||||
|
||||
5. Handle provider events
|
||||
|
||||
```js
|
||||
provider.on('connect', (info) => {
|
||||
setConnect(info);
|
||||
});
|
||||
|
||||
provider.on('disconnect', (error) => {
|
||||
setDisconnect({ code: error.code, message: error.message });
|
||||
});
|
||||
|
||||
provider.on('accountsChanged', (accounts) => {
|
||||
setAccountsChanged(accounts);
|
||||
});
|
||||
|
||||
provider.on('chainChanged', (chainId) => {
|
||||
setChainChanged(chainId);
|
||||
});
|
||||
|
||||
provider.on('message', (message) => {
|
||||
setMessage(message);
|
||||
});
|
||||
```
|
||||
|
||||
### Developing locally and running the test dapp
|
||||
|
||||
- The Base Account SDK test dapp can be viewed here https://base.github.io/account-sdk/.
|
||||
- To run it locally follow these steps:
|
||||
|
||||
1. Fork this repo and clone it
|
||||
1. From the root dir run `yarn install`
|
||||
1. From the root dir run `yarn dev`
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2018-2023 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
// Copyright (c) 2018-2025 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
@@ -1,21 +1,19 @@
|
||||
{
|
||||
"name": "@coinbase/wallet-sdk",
|
||||
"version": "4.3.2",
|
||||
"description": "Coinbase Wallet JavaScript SDK",
|
||||
"name": "@base/account-sdk",
|
||||
"version": "1.0.0",
|
||||
"description": "Base Account SDK",
|
||||
"keywords": [
|
||||
"coinbase",
|
||||
"coinbasewallet",
|
||||
"eth",
|
||||
"ethereum",
|
||||
"wallet",
|
||||
"base",
|
||||
"account",
|
||||
"sdk",
|
||||
"web3"
|
||||
],
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"repository": "https://github.com/coinbase/coinbase-wallet-sdk.git",
|
||||
"author": "Coinbase, Inc.",
|
||||
"repository": "https://github.com/base/account-sdk.git",
|
||||
"author": "Base",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"clean": "rm -rf dist && rm -rf node_modules",
|
||||
+1
-1
@@ -18,7 +18,7 @@ export type CommunicatorOptions = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Communicates with a popup window for Coinbase keys.coinbase.com (or another url)
|
||||
* Communicates with a popup window for specific Base Account environment
|
||||
* to send and receive messages.
|
||||
*
|
||||
* This class is responsible for opening a popup window, posting messages to it,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
// Copyright (c) 2018-2025 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
|
||||
// TODO: clean up, or possibly deprecate Storage class
|
||||
export class ScopedLocalStorage {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { LocalAccount, OneOf } from 'viem';
|
||||
import { WebAuthnAccount } from 'viem/account-abstraction';
|
||||
|
||||
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
// Copyright (c) 2018-2025 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
interface Tag<T extends string, RealType> {
|
||||
__tag__: T;
|
||||
__realType__: RealType;
|
||||
-24
@@ -10,7 +10,6 @@ import {
|
||||
ensureIntNumber,
|
||||
ensureParsedJSONObject,
|
||||
ensureRegExpString,
|
||||
getFavicon,
|
||||
has0xPrefix,
|
||||
hexStringFromBuffer,
|
||||
hexStringFromNumber,
|
||||
@@ -179,27 +178,4 @@ describe('util', () => {
|
||||
test('range', () => {
|
||||
expect(range(1, 5)).toMatchObject([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
describe('getFavicon', () => {
|
||||
test('return https', () => {
|
||||
document.head.innerHTML = `
|
||||
<link rel="shortcut icon" sizes="16x16 24x24" href="https://coinbase.com/favicon.ico">
|
||||
`;
|
||||
expect(getFavicon()).toEqual('https://coinbase.com/favicon.ico');
|
||||
});
|
||||
|
||||
test('return http', () => {
|
||||
document.head.innerHTML = `
|
||||
<link rel="shortcut icon" sizes="16x16 24x24" href="//coinbase.com/favicon.ico">
|
||||
`;
|
||||
expect(getFavicon()).toEqual('http://coinbase.com/favicon.ico');
|
||||
});
|
||||
|
||||
test('return localhost', () => {
|
||||
document.head.innerHTML = `
|
||||
<link rel="shortcut icon" sizes="16x16 24x24" href="/favicon.ico">
|
||||
`;
|
||||
expect(getFavicon()).toEqual('http://localhost:3000/favicon.ico');
|
||||
});
|
||||
});
|
||||
});
|
||||
-21
@@ -177,27 +177,6 @@ export function range(start: number, stop: number): number[] {
|
||||
return Array.from({ length: stop - start }, (_, i) => start + i);
|
||||
}
|
||||
|
||||
export function getFavicon(): string | null {
|
||||
const el =
|
||||
document.querySelector('link[sizes="192x192"]') ||
|
||||
document.querySelector('link[sizes="180x180"]') ||
|
||||
document.querySelector('link[rel="icon"]') ||
|
||||
document.querySelector('link[rel="shortcut icon"]');
|
||||
|
||||
const { protocol, host } = document.location;
|
||||
const href = el ? el.getAttribute('href') : null;
|
||||
if (!href || href.startsWith('javascript:') || href.startsWith('vbscript:')) {
|
||||
return `${protocol}//${host}/favicon.ico`; // fallback
|
||||
}
|
||||
if (href.startsWith('http://') || href.startsWith('https://') || href.startsWith('data:')) {
|
||||
return href;
|
||||
}
|
||||
if (href.startsWith('//')) {
|
||||
return protocol + href;
|
||||
}
|
||||
return `${protocol}//${host}${href}`;
|
||||
}
|
||||
|
||||
export function areAddressArraysEqual(arr1: Address[], arr2: Address[]): boolean {
|
||||
return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
// Copyright (c) 2018-2025 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
export type { AppMetadata, Preference, ProviderInterface } from ':core/provider/interface.js';
|
||||
|
||||
export { createCoinbaseWalletSDK } from './createCoinbaseWalletSDK.js';
|
||||
export { createBaseAccountSDK } from './interface/builder/core/createBaseAccountSDK.js';
|
||||
export { getCryptoKeyAccount, removeCryptoKey } from './kms/crypto-key/index.js';
|
||||
+4
-4
@@ -4,12 +4,12 @@ import { standardErrors } from ':core/error/errors.js';
|
||||
import { RequestArguments } from ':core/provider/interface.js';
|
||||
import { store } from ':store/store.js';
|
||||
import * as providerUtil from ':util/provider.js';
|
||||
import { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
|
||||
import { BaseAccountProvider } from './BaseAccountProvider.js';
|
||||
|
||||
function createProvider() {
|
||||
return new CoinbaseWalletProvider({
|
||||
return new BaseAccountProvider({
|
||||
metadata: { appName: 'Test App', appLogoUrl: null, appChainIds: [1] },
|
||||
preference: { options: 'all' },
|
||||
preference: { telemetry: false },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const mockRequest = vi.fn();
|
||||
const mockCleanup = vi.fn();
|
||||
const mockFetchRPCRequest = vi.fn();
|
||||
|
||||
let provider: CoinbaseWalletProvider;
|
||||
let provider: BaseAccountProvider;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
+1
-1
@@ -21,7 +21,7 @@ import { correlationIds } from ':store/correlation-ids/store.js';
|
||||
import { store } from ':store/store.js';
|
||||
import { checkErrorForInvalidRequestArgs, fetchRPCRequest } from ':util/provider.js';
|
||||
|
||||
export class CoinbaseWalletProvider extends ProviderEventEmitter implements ProviderInterface {
|
||||
export class BaseAccountProvider extends ProviderEventEmitter implements ProviderInterface {
|
||||
private readonly communicator: Communicator;
|
||||
private readonly signer: Signer;
|
||||
|
||||
+13
-13
@@ -3,7 +3,7 @@ import { store } from ':store/store.js';
|
||||
import * as checkCrossOriginModule from ':util/checkCrossOriginOpenerPolicy.js';
|
||||
import * as validatePreferencesModule from ':util/validatePreferences.js';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
|
||||
import { BaseAccountProvider } from './BaseAccountProvider.js';
|
||||
import { CreateProviderOptions, createBaseAccountSDK } from './createBaseAccountSDK.js';
|
||||
|
||||
// Mock all dependencies
|
||||
@@ -34,8 +34,8 @@ vi.mock(':util/validatePreferences.js', () => ({
|
||||
validateSubAccount: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('./CoinbaseWalletProvider.js', () => ({
|
||||
CoinbaseWalletProvider: vi.fn(),
|
||||
vi.mock('./BaseAccountProvider.js', () => ({
|
||||
BaseAccountProvider: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockStore = store as any;
|
||||
@@ -43,12 +43,12 @@ const mockLoadTelemetryScript = telemetryModule.loadTelemetryScript as any;
|
||||
const mockCheckCrossOriginOpenerPolicy = checkCrossOriginModule.checkCrossOriginOpenerPolicy as any;
|
||||
const mockValidatePreferences = validatePreferencesModule.validatePreferences as any;
|
||||
const mockValidateSubAccount = validatePreferencesModule.validateSubAccount as any;
|
||||
const mockCoinbaseWalletProvider = CoinbaseWalletProvider as any;
|
||||
const mockBaseAccountProvider = BaseAccountProvider as any;
|
||||
|
||||
describe('createProvider', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockCoinbaseWalletProvider.mockReturnValue({
|
||||
mockBaseAccountProvider.mockReturnValue({
|
||||
mockProvider: true,
|
||||
});
|
||||
});
|
||||
@@ -57,7 +57,7 @@ describe('createProvider', () => {
|
||||
it('should create a provider with minimal parameters', () => {
|
||||
const result = createBaseAccountSDK({}).getProvider();
|
||||
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith({
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith({
|
||||
metadata: {
|
||||
appName: 'App',
|
||||
appLogoUrl: '',
|
||||
@@ -79,7 +79,7 @@ describe('createProvider', () => {
|
||||
|
||||
createBaseAccountSDK(params).getProvider();
|
||||
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith({
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith({
|
||||
metadata: {
|
||||
appName: 'Test App',
|
||||
appLogoUrl: 'https://example.com/logo.png',
|
||||
@@ -99,7 +99,7 @@ describe('createProvider', () => {
|
||||
|
||||
createBaseAccountSDK(params).getProvider();
|
||||
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith({
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith({
|
||||
metadata: {
|
||||
appName: 'App',
|
||||
appLogoUrl: '',
|
||||
@@ -122,7 +122,7 @@ describe('createProvider', () => {
|
||||
|
||||
createBaseAccountSDK(params).getProvider();
|
||||
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith(
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
paymasterUrls: {
|
||||
1: 'https://paymaster.example.com',
|
||||
@@ -351,7 +351,7 @@ describe('createProvider', () => {
|
||||
expect(mockLoadTelemetryScript).toHaveBeenCalled();
|
||||
|
||||
// Check provider creation
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith({
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith({
|
||||
metadata: {
|
||||
appName: 'Integration Test',
|
||||
appLogoUrl: 'https://example.com/logo.png',
|
||||
@@ -373,7 +373,7 @@ describe('createProvider', () => {
|
||||
it('should handle null app logo URL', () => {
|
||||
createBaseAccountSDK({ appLogoUrl: null }).getProvider();
|
||||
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith(
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
metadata: expect.objectContaining({
|
||||
appLogoUrl: '',
|
||||
@@ -385,7 +385,7 @@ describe('createProvider', () => {
|
||||
it('should handle empty app chain IDs array', () => {
|
||||
createBaseAccountSDK({ appChainIds: [] }).getProvider();
|
||||
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith(
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
metadata: expect.objectContaining({
|
||||
appChainIds: [],
|
||||
@@ -404,7 +404,7 @@ describe('createProvider', () => {
|
||||
createBaseAccountSDK({ preference: complexPreference }).getProvider();
|
||||
|
||||
expect(mockValidatePreferences).toHaveBeenCalledWith(complexPreference);
|
||||
expect(mockCoinbaseWalletProvider).toHaveBeenCalledWith(
|
||||
expect(mockBaseAccountProvider).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
preference: complexPreference,
|
||||
})
|
||||
+2
-2
@@ -9,7 +9,7 @@ import { loadTelemetryScript } from ':core/telemetry/initCCA.js';
|
||||
import { store } from ':store/store.js';
|
||||
import { checkCrossOriginOpenerPolicy } from ':util/checkCrossOriginOpenerPolicy.js';
|
||||
import { validatePreferences, validateSubAccount } from ':util/validatePreferences.js';
|
||||
import { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
|
||||
import { BaseAccountProvider } from './BaseAccountProvider.js';
|
||||
|
||||
export type CreateProviderOptions = Partial<AppMetadata> & {
|
||||
preference?: Preference;
|
||||
@@ -76,7 +76,7 @@ export function createBaseAccountSDK(params: CreateProviderOptions) {
|
||||
return {
|
||||
getProvider: () => {
|
||||
if (!provider) {
|
||||
provider = new CoinbaseWalletProvider(options);
|
||||
provider = new BaseAccountProvider(options);
|
||||
}
|
||||
|
||||
return provider;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { Hex, PublicKey, Signature, WebAuthnP256, WebCryptoP256 } from 'ox';
|
||||
import { hashMessage, hashTypedData, LocalAccount, OneOf } from 'viem';
|
||||
import { LocalAccount, OneOf, hashMessage, hashTypedData } from 'viem';
|
||||
import { type WebAuthnAccount } from 'viem/account-abstraction';
|
||||
|
||||
import { createStorage } from './storage.js';
|
||||
@@ -12,7 +12,7 @@ export type P256KeyPair = {
|
||||
// *****************************************************************
|
||||
// Constants
|
||||
// *****************************************************************
|
||||
export const STORAGE_SCOPE = 'cbwsdk';
|
||||
export const STORAGE_SCOPE = 'base-acc-sdk';
|
||||
export const STORAGE_NAME = 'keys';
|
||||
|
||||
export const ACTIVE_ID_KEY = 'activeId';
|
||||
@@ -144,7 +144,7 @@ export const sdkstore = createStore(
|
||||
...createSubAccountConfigSlice(...args),
|
||||
}),
|
||||
{
|
||||
name: 'cbwsdk.store',
|
||||
name: 'base-acc-sdk.store',
|
||||
storage: createJSONStorage(() => localStorage),
|
||||
partialize: (state) => {
|
||||
// Explicitly select only the data properties we want to persist
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2018-2023 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
// Copyright (c) 2018-2025 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
|
||||
.-cbwsdk-css-reset {
|
||||
.-gear-container {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2018-2023 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
// Copyright (c) 2018-2025 Coinbase, Inc. <https://www.coinbase.com/>
|
||||
|
||||
import { clsx } from 'clsx';
|
||||
import { FunctionComponent, render } from 'preact';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user