FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

88
node_modules/@coinbase/wallet-sdk/.eslintrc.cjs generated vendored Normal file
View File

@@ -0,0 +1,88 @@
module.exports = {
root: true,
extends: [
'preact',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
settings: {
react: {
pragma: 'h',
},
},
env: {
browser: true,
es2021: true,
node: true,
commonjs: true,
},
plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [['^\\u0000'], ['^@?\\w'], ['^src(/.*|$)']],
},
],
'simple-import-sort/exports': 'error',
'no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'no-console': [
'error',
{
allow: ['warn', 'error', 'info'],
},
],
'prettier/prettier': [
'error',
{
arrowParens: 'always',
bracketSpacing: true,
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'css',
printWidth: 100,
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
},
],
// TODO: change this back to error
'@typescript-eslint/no-explicit-any': 'warn',
'no-useless-constructor': 'off',
'jest/no-deprecated-functions': 'off',
'no-restricted-globals': [
'error',
{
name: 'parseInt',
message: 'Use Number.parseInt instead of parseInt.',
},
],
},
overrides: [
{
files: ['**/*.test.*'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
],
};

13
node_modules/@coinbase/wallet-sdk/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,13 @@
Copyright (c) 2018-2023 Coinbase, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

136
node_modules/@coinbase/wallet-sdk/README.md generated vendored Normal file
View File

@@ -0,0 +1,136 @@
# Coinbase Wallet SDK
## Coinbase Wallet SDK lets developers connect their dapps to Coinbase Wallet in the following ways:
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 extension option.
### Installing Wallet SDK
1. Check available versions:
```shell
# yarn
yarn info @coinbase/wallet-sdk versions
# npm
npm view @coinbase/wallet-sdk versions
```
2. Install latest version:
```shell
# yarn
yarn add @coinbase/wallet-sdk
# npm
npm install @coinbase/wallet-sdk
```
3. Check installed version:
```shell
# yarn
yarn list @coinbase/wallet-sdk
# npm
npm list @coinbase/wallet-sdk
```
### Upgrading Wallet SDK
Upgrade Coinbase Wallet SDK using yarn or npm.
#### yarn/npm
1. Compare installed version with latest:
```shell
# yarn
yarn outdated @coinbase/wallet-sdk
# npm
npm outdated @coinbase/wallet-sdk
```
2. Update to latest:
```shell
# yarn
yarn upgrade @coinbase/wallet-sdk --latest
# npm
npm update @coinbase/wallet-sdk
```
### Basic Usage
1. Initialize SDK
```js
const sdk = new CoinbaseWalletSDK({
appName: 'SDK Playground',
});
```
2. Make web3 Provider
```js
const provider = sdk.makeWeb3Provider();
```
3. Request accounts to initialize 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 Coinbase Wallet SDK test dapp can be viewed here https://coinbase.github.io/coinbase-wallet-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`

View File

@@ -0,0 +1,16 @@
import { ConstructorOptions, ProviderEventEmitter, ProviderInterface, RequestArguments } from './core/provider/interface.js';
export declare class CoinbaseWalletProvider extends ProviderEventEmitter implements ProviderInterface {
private readonly metadata;
private readonly preference;
private readonly communicator;
private signer;
constructor({ metadata, preference: { keysUrl, ...preference } }: Readonly<ConstructorOptions>);
request<T>(args: RequestArguments): Promise<T>;
/** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */
enable(): Promise<unknown>;
disconnect(): Promise<void>;
readonly isCoinbaseWallet = true;
private requestSignerSelection;
private initSigner;
}
//# sourceMappingURL=CoinbaseWalletProvider.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoinbaseWalletProvider.d.ts","sourceRoot":"","sources":["../src/CoinbaseWalletProvider.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,kBAAkB,EAElB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAKrC,qBAAa,sBAAuB,SAAQ,oBAAqB,YAAW,iBAAiB;IAC3F,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,OAAO,CAAC,MAAM,CAAuB;gBAEzB,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IAgBjF,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC;IAyC3D,6EAA6E;IAChE,MAAM;IASb,UAAU;IAOhB,QAAQ,CAAC,gBAAgB,QAAQ;IAEjC,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,UAAU;CAQnB"}

View File

@@ -0,0 +1,112 @@
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { createSigner, fetchSignerType, loadSignerType, storeSignerType } from './sign/util.js';
import { Communicator } from './core/communicator/Communicator.js';
import { CB_WALLET_RPC_URL } from './core/constants.js';
import { standardErrorCodes } from './core/error/constants.js';
import { standardErrors } from './core/error/errors.js';
import { serializeError } from './core/error/serialize.js';
import { ProviderEventEmitter, } from './core/provider/interface.js';
import { ScopedLocalStorage } from './core/storage/ScopedLocalStorage.js';
import { hexStringFromNumber } from './core/type/util.js';
import { checkErrorForInvalidRequestArgs, fetchRPCRequest } from './util/provider.js';
export class CoinbaseWalletProvider extends ProviderEventEmitter {
constructor(_a) {
var { metadata } = _a, _b = _a.preference, { keysUrl } = _b, preference = __rest(_b, ["keysUrl"]);
super();
this.signer = null;
this.isCoinbaseWallet = true;
this.metadata = metadata;
this.preference = preference;
this.communicator = new Communicator({
url: keysUrl,
metadata,
preference,
});
const signerType = loadSignerType();
if (signerType) {
this.signer = this.initSigner(signerType);
}
}
async request(args) {
try {
checkErrorForInvalidRequestArgs(args);
if (!this.signer) {
switch (args.method) {
case 'eth_requestAccounts': {
const signerType = await this.requestSignerSelection(args);
const signer = this.initSigner(signerType);
await signer.handshake(args);
this.signer = signer;
storeSignerType(signerType);
break;
}
case 'wallet_sendCalls': {
const ephemeralSigner = this.initSigner('scw');
await ephemeralSigner.handshake({ method: 'handshake' }); // exchange session keys
const result = await ephemeralSigner.request(args); // send diffie-hellman encrypted request
await ephemeralSigner.cleanup(); // clean up (rotate) the ephemeral session keys
return result;
}
case 'wallet_getCallsStatus':
return fetchRPCRequest(args, CB_WALLET_RPC_URL);
case 'net_version':
return 1; // default value
case 'eth_chainId':
return hexStringFromNumber(1); // default value
default: {
throw standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");
}
}
}
return await this.signer.request(args);
}
catch (error) {
const { code } = error;
if (code === standardErrorCodes.provider.unauthorized)
this.disconnect();
return Promise.reject(serializeError(error));
}
}
/** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */
async enable() {
console.warn(`.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.`);
return await this.request({
method: 'eth_requestAccounts',
});
}
async disconnect() {
var _a;
await ((_a = this.signer) === null || _a === void 0 ? void 0 : _a.cleanup());
this.signer = null;
ScopedLocalStorage.clearAll();
this.emit('disconnect', standardErrors.provider.disconnected('User initiated disconnection'));
}
requestSignerSelection(handshakeRequest) {
return fetchSignerType({
communicator: this.communicator,
preference: this.preference,
metadata: this.metadata,
handshakeRequest,
callback: this.emit.bind(this),
});
}
initSigner(signerType) {
return createSigner({
signerType,
metadata: this.metadata,
communicator: this.communicator,
callback: this.emit.bind(this),
});
}
}
//# sourceMappingURL=CoinbaseWalletProvider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoinbaseWalletProvider.js","sourceRoot":"","sources":["../src/CoinbaseWalletProvider.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAIL,oBAAoB,GAGrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,+BAA+B,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,OAAO,sBAAuB,SAAQ,oBAAoB;IAO9D,YAAY,EAAkF;YAAlF,EAAE,QAAQ,OAAwE,EAAtE,kBAAsC,EAAtC,EAAc,OAAO,OAAiB,EAAZ,UAAU,cAAxB,WAA0B,CAAF;QAC1D,KAAK,EAAE,CAAC;QAHF,WAAM,GAAkB,IAAI,CAAC;QA4E5B,qBAAgB,GAAG,IAAI,CAAC;QAxE/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAA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YACrB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,gBAAgB;YAChB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAEO,UAAU,CAAC,UAAsB;QACvC,OAAO,YAAY,CAAC;YAClB,UAAU;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;CACF"}

View File

@@ -0,0 +1,24 @@
import { LogoType } from './assets/wallet-logo.js';
import { AppMetadata, Preference, ProviderInterface } from './core/provider/interface.js';
type CoinbaseWalletSDKOptions = Partial<AppMetadata>;
/**
* CoinbaseWalletSDK
*
* @deprecated CoinbaseWalletSDK is deprecated and will likely be removed in a future major version release.
* It's recommended to use `createCoinbaseWalletSDK` instead.
*/
export declare class CoinbaseWalletSDK {
private metadata;
constructor(metadata: Readonly<CoinbaseWalletSDKOptions>);
makeWeb3Provider(preference?: Preference): ProviderInterface;
/**
* Official Coinbase Wallet logo for developers to use on their frontend
* @param type Type of wallet logo: "standard" | "circle" | "text" | "textWithLogo" | "textLight" | "textWithLogoLight"
* @param width Width of the logo (Optional)
* @returns SVG Data URI
*/
getCoinbaseWalletLogo(type: LogoType, width?: number): string;
private storeLatestVersion;
}
export {};
//# sourceMappingURL=CoinbaseWalletSDK.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoinbaseWalletSDK.d.ts","sourceRoot":"","sources":["../src/CoinbaseWalletSDK.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAS1F,KAAK,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAc;gBAElB,QAAQ,EAAE,QAAQ,CAAC,wBAAwB,CAAC;IAUjD,gBAAgB,CAAC,UAAU,GAAE,UAA+B,GAAG,iBAAiB;IAMvF;;;;;OAKG;IACI,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,SAAM,GAAG,MAAM;IAIjE,OAAO,CAAC,kBAAkB;CAI3B"}

View File

@@ -0,0 +1,46 @@
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
import { walletLogo } from './assets/wallet-logo.js';
import { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
import { VERSION } from './sdk-info.js';
import { ScopedLocalStorage } from './core/storage/ScopedLocalStorage.js';
import { getFavicon } from './core/type/util.js';
import { checkCrossOriginOpenerPolicy } from './util/checkCrossOriginOpenerPolicy.js';
import { getCoinbaseInjectedProvider } from './util/provider.js';
import { validatePreferences } from './util/validatePreferences.js';
/**
* CoinbaseWalletSDK
*
* @deprecated CoinbaseWalletSDK is deprecated and will likely be removed in a future major version release.
* It's recommended to use `createCoinbaseWalletSDK` instead.
*/
export class CoinbaseWalletSDK {
constructor(metadata) {
this.metadata = {
appName: metadata.appName || 'Dapp',
appLogoUrl: metadata.appLogoUrl || getFavicon(),
appChainIds: metadata.appChainIds || [],
};
this.storeLatestVersion();
void checkCrossOriginOpenerPolicy();
}
makeWeb3Provider(preference = { options: 'all' }) {
var _a;
validatePreferences(preference);
const params = { metadata: this.metadata, preference };
return (_a = getCoinbaseInjectedProvider(params)) !== null && _a !== void 0 ? _a : new CoinbaseWalletProvider(params);
}
/**
* Official Coinbase Wallet logo for developers to use on their frontend
* @param type Type of wallet logo: "standard" | "circle" | "text" | "textWithLogo" | "textLight" | "textWithLogoLight"
* @param width Width of the logo (Optional)
* @returns SVG Data URI
*/
getCoinbaseWalletLogo(type, width = 240) {
return walletLogo(type, width);
}
storeLatestVersion() {
const versionStorage = new ScopedLocalStorage('CBWSDK');
versionStorage.setItem('VERSION', VERSION);
}
}
//# sourceMappingURL=CoinbaseWalletSDK.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoinbaseWalletSDK.js","sourceRoot":"","sources":["../src/CoinbaseWalletSDK.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,EAAY,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAKnE;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAG5B,YAAY,QAA4C;QACtD,IAAI,CAAC,QAAQ,GAAG;YACd,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,MAAM;YACnC,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,UAAU,EAAE;YAC/C,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,EAAE;SACxC,CAAC;QACF,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,KAAK,4BAA4B,EAAE,CAAC;IACtC,CAAC;IAEM,gBAAgB,CAAC,aAAyB,EAAE,OAAO,EAAE,KAAK,EAAE;;QACjE,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;QACvD,OAAO,MAAA,2BAA2B,CAAC,MAAM,CAAC,mCAAI,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACnF,CAAC;IAED;;;;;OAKG;IACI,qBAAqB,CAAC,IAAc,EAAE,KAAK,GAAG,GAAG;QACtD,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAEO,kBAAkB;QACxB,MAAM,cAAc,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACxD,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF"}

View File

@@ -0,0 +1,3 @@
export type LogoType = 'standard' | 'circle' | 'text' | 'textWithLogo' | 'textLight' | 'textWithLogoLight';
export declare const walletLogo: (type: LogoType, width: number) => string;
//# sourceMappingURL=wallet-logo.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"wallet-logo.d.ts","sourceRoot":"","sources":["../../src/assets/wallet-logo.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,QAAQ,GACR,MAAM,GACN,cAAc,GACd,WAAW,GACX,mBAAmB,CAAC;AAExB,eAAO,MAAM,UAAU,SAAU,QAAQ,SAAS,MAAM,WAyBvD,CAAC"}

View File

@@ -0,0 +1,27 @@
export const walletLogo = (type, width) => {
let height;
switch (type) {
case 'standard':
height = width;
return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
case 'circle':
height = width;
return `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;
case 'text':
height = (0.1 * width).toFixed(2);
return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
case 'textWithLogo':
height = (0.25 * width).toFixed(2);
return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
case 'textLight':
height = (0.1 * width).toFixed(2);
return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
case 'textWithLogoLight':
height = (0.25 * width).toFixed(2);
return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
default:
height = width;
return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
}
};
//# sourceMappingURL=wallet-logo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"wallet-logo.js","sourceRoot":"","sources":["../../src/assets/wallet-logo.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAc,EAAE,KAAa,EAAE,EAAE;IAC1D,IAAI,MAAM,CAAC;IACX,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU;YACb,MAAM,GAAG,KAAK,CAAC;YACf,OAAO,oCAAoC,KAAK,aAAa,MAAM,yfAAyf,CAAC;QAC/jB,KAAK,QAAQ;YACX,MAAM,GAAG,KAAK,CAAC;YACf,OAAO,uEAAuE,KAAK,aAAa,MAAM,srDAAsrD,CAAC;QAC/xD,KAAK,MAAM;YACT,MAAM,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAClC,OAAO,oCAAoC,KAAK,aAAa,MAAM,kiFAAkiF,CAAC;QACxmF,KAAK,cAAc;YACjB,MAAM,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACnC,OAAO,oCAAoC,KAAK,aAAa,MAAM,4tBAA4tB,CAAC;QAClyB,KAAK,WAAW;YACd,MAAM,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAClC,OAAO,oCAAoC,KAAK,aAAa,MAAM,kiFAAkiF,CAAC;QACxmF,KAAK,mBAAmB;YACtB,MAAM,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACnC,OAAO,oCAAoC,KAAK,aAAa,MAAM,4tBAA4tB,CAAC;QAClyB;YACE,MAAM,GAAG,KAAK,CAAC;YACf,OAAO,oCAAoC,KAAK,aAAa,MAAM,yfAAyf,CAAC;IACjkB,CAAC;AACH,CAAC,CAAC"}

View File

@@ -0,0 +1,47 @@
import { Message, MessageID } from '../message/Message.js';
import { AppMetadata, Preference } from '../provider/interface.js';
export type CommunicatorOptions = {
url?: string;
metadata: AppMetadata;
preference: Preference;
};
/**
* Communicates with a popup window for Coinbase keys.coinbase.com (or another url)
* to send and receive messages.
*
* This class is responsible for opening a popup window, posting messages to it,
* and listening for responses.
*
* It also handles cleanup of event listeners and the popup window itself when necessary.
*/
export declare class Communicator {
private readonly metadata;
private readonly preference;
private readonly url;
private popup;
private listeners;
constructor({ url, metadata, preference }: CommunicatorOptions);
/**
* Posts a message to the popup window
*/
postMessage: (message: Message) => Promise<void>;
/**
* Posts a request to the popup window and waits for a response
*/
postRequestAndWaitForResponse: <M extends Message>(request: Message & {
id: MessageID;
}) => Promise<M>;
/**
* Listens for messages from the popup window that match a given predicate.
*/
onMessage: <M extends Message>(predicate: (_: Partial<M>) => boolean) => Promise<M>;
/**
* Closes the popup, rejects all requests and clears the listeners
*/
private disconnect;
/**
* Waits for the popup window to fully load and then sends a version message.
*/
waitForPopupLoaded: () => Promise<Window>;
}
//# sourceMappingURL=Communicator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Communicator.d.ts","sourceRoot":"","sources":["../../../src/core/communicator/Communicator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGtE,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAC1B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,SAAS,CAAwE;gBAE7E,EAAE,GAAiB,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,mBAAmB;IAM5E;;OAEG;IACH,WAAW,YAAmB,OAAO,mBAGnC;IAEF;;OAEG;IACH,6BAA6B,GAAU,CAAC,SAAS,OAAO,WAC7C,OAAO,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,KACnC,OAAO,CAAC,CAAC,CAAC,CAIX;IAEF;;OAEG;IACH,SAAS,GAAU,CAAC,SAAS,OAAO,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,KAAG,OAAO,CAAC,CAAC,CAAC,CAgBtF;IAEF;;OAEG;IACH,OAAO,CAAC,UAAU,CAUhB;IAEF;;OAEG;IACH,kBAAkB,QAAa,OAAO,CAAC,MAAM,CAAC,CA6B5C;CACH"}

View File

@@ -0,0 +1,101 @@
import { VERSION } from '../../sdk-info.js';
import { CB_KEYS_URL } from '../constants.js';
import { standardErrors } from '../error/errors.js';
import { closePopup, openPopup } from '../../util/web.js';
/**
* Communicates with a popup window for Coinbase keys.coinbase.com (or another url)
* to send and receive messages.
*
* This class is responsible for opening a popup window, posting messages to it,
* and listening for responses.
*
* It also handles cleanup of event listeners and the popup window itself when necessary.
*/
export class Communicator {
constructor({ url = CB_KEYS_URL, metadata, preference }) {
this.popup = null;
this.listeners = new Map();
/**
* Posts a message to the popup window
*/
this.postMessage = async (message) => {
const popup = await this.waitForPopupLoaded();
popup.postMessage(message, this.url.origin);
};
/**
* Posts a request to the popup window and waits for a response
*/
this.postRequestAndWaitForResponse = async (request) => {
const responsePromise = this.onMessage(({ requestId }) => requestId === request.id);
this.postMessage(request);
return await responsePromise;
};
/**
* Listens for messages from the popup window that match a given predicate.
*/
this.onMessage = async (predicate) => {
return new Promise((resolve, reject) => {
const listener = (event) => {
if (event.origin !== this.url.origin)
return; // origin validation
const message = event.data;
if (predicate(message)) {
resolve(message);
window.removeEventListener('message', listener);
this.listeners.delete(listener);
}
};
window.addEventListener('message', listener);
this.listeners.set(listener, { reject });
});
};
/**
* Closes the popup, rejects all requests and clears the listeners
*/
this.disconnect = () => {
// Note: keys popup handles closing itself. this is a fallback.
closePopup(this.popup);
this.popup = null;
this.listeners.forEach(({ reject }, listener) => {
reject(standardErrors.provider.userRejectedRequest('Request rejected'));
window.removeEventListener('message', listener);
});
this.listeners.clear();
};
/**
* Waits for the popup window to fully load and then sends a version message.
*/
this.waitForPopupLoaded = async () => {
if (this.popup && !this.popup.closed) {
// In case the user un-focused the popup between requests, focus it again
this.popup.focus();
return this.popup;
}
this.popup = await openPopup(this.url);
this.onMessage(({ event }) => event === 'PopupUnload')
.then(this.disconnect)
.catch(() => { });
return this.onMessage(({ event }) => event === 'PopupLoaded')
.then((message) => {
this.postMessage({
requestId: message.id,
data: {
version: VERSION,
metadata: this.metadata,
preference: this.preference,
location: window.location.toString(),
},
});
})
.then(() => {
if (!this.popup)
throw standardErrors.rpc.internal();
return this.popup;
});
};
this.url = new URL(url);
this.metadata = metadata;
this.preference = preference;
}
}
//# sourceMappingURL=Communicator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Communicator.js","sourceRoot":"","sources":["../../../src/core/communicator/Communicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQrD;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IAOvB,YAAY,EAAE,GAAG,GAAG,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAuB;QAHpE,UAAK,GAAkB,IAAI,CAAC;QAC5B,cAAS,GAAG,IAAI,GAAG,EAA6D,CAAC;QAQzF;;WAEG;QACH,gBAAW,GAAG,KAAK,EAAE,OAAgB,EAAE,EAAE;YACvC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC9C,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEF;;WAEG;QACH,kCAA6B,GAAG,KAAK,EACnC,OAAoC,EACxB,EAAE;YACd,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAI,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;YACvF,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC1B,OAAO,MAAM,eAAe,CAA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G,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CA0FF"}

View File

@@ -0,0 +1,5 @@
export declare const CB_KEYS_URL = "https://keys.coinbase.com/connect";
export declare const CB_WALLET_RPC_URL = "https://rpc.wallet.coinbase.com";
export declare const WALLETLINK_URL = "https://www.walletlink.org";
export declare const CBW_MOBILE_DEEPLINK_URL = "https://go.cb-w.com/walletlink";
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,sCAAsC,CAAC;AAC/D,eAAO,MAAM,iBAAiB,oCAAoC,CAAC;AACnE,eAAO,MAAM,cAAc,+BAA+B,CAAC;AAC3D,eAAO,MAAM,uBAAuB,mCAAmC,CAAC"}

View File

@@ -0,0 +1,5 @@
export const CB_KEYS_URL = 'https://keys.coinbase.com/connect';
export const CB_WALLET_RPC_URL = 'https://rpc.wallet.coinbase.com';
export const WALLETLINK_URL = 'https://www.walletlink.org';
export const CBW_MOBILE_DEEPLINK_URL = 'https://go.cb-w.com/walletlink';
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,iCAAiC,CAAC;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAC3D,MAAM,CAAC,MAAM,uBAAuB,GAAG,gCAAgC,CAAC"}

View File

@@ -0,0 +1,96 @@
interface ErrorCodes {
readonly rpc: {
readonly invalidInput: -32000;
readonly resourceNotFound: -32001;
readonly resourceUnavailable: -32002;
readonly transactionRejected: -32003;
readonly methodNotSupported: -32004;
readonly limitExceeded: -32005;
readonly parse: -32700;
readonly invalidRequest: -32600;
readonly methodNotFound: -32601;
readonly invalidParams: -32602;
readonly internal: -32603;
};
readonly provider: {
readonly userRejectedRequest: 4001;
readonly unauthorized: 4100;
readonly unsupportedMethod: 4200;
readonly disconnected: 4900;
readonly chainDisconnected: 4901;
readonly unsupportedChain: 4902;
};
}
export declare const standardErrorCodes: ErrorCodes;
export declare const errorValues: {
'-32700': {
standard: string;
message: string;
};
'-32600': {
standard: string;
message: string;
};
'-32601': {
standard: string;
message: string;
};
'-32602': {
standard: string;
message: string;
};
'-32603': {
standard: string;
message: string;
};
'-32000': {
standard: string;
message: string;
};
'-32001': {
standard: string;
message: string;
};
'-32002': {
standard: string;
message: string;
};
'-32003': {
standard: string;
message: string;
};
'-32004': {
standard: string;
message: string;
};
'-32005': {
standard: string;
message: string;
};
'4001': {
standard: string;
message: string;
};
'4100': {
standard: string;
message: string;
};
'4200': {
standard: string;
message: string;
};
'4900': {
standard: string;
message: string;
};
'4901': {
standard: string;
message: string;
};
'4902': {
standard: string;
message: string;
};
};
export {};
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/core/error/constants.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,QAAQ,CAAC,GAAG,EAAE;QACZ,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;QAC9B,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC;QAClC,QAAQ,CAAC,mBAAmB,EAAE,CAAC,KAAK,CAAC;QACrC,QAAQ,CAAC,mBAAmB,EAAE,CAAC,KAAK,CAAC;QACrC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,CAAC;QACpC,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC;QAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC;QACvB,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC;QAChC,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC;QAChC,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC;QAC/B,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC;KAC3B,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC;QACnC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;QAC5B,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC;QACjC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;QAC5B,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC;QACjC,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC;KACjC,CAAC;CACH;AAED,eAAO,MAAM,kBAAkB,EAAE,UAsBhC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsEvB,CAAC"}

View File

@@ -0,0 +1,94 @@
export const standardErrorCodes = {
rpc: {
invalidInput: -32000,
resourceNotFound: -32001,
resourceUnavailable: -32002,
transactionRejected: -32003,
methodNotSupported: -32004,
limitExceeded: -32005,
parse: -32700,
invalidRequest: -32600,
methodNotFound: -32601,
invalidParams: -32602,
internal: -32603,
},
provider: {
userRejectedRequest: 4001,
unauthorized: 4100,
unsupportedMethod: 4200,
disconnected: 4900,
chainDisconnected: 4901,
unsupportedChain: 4902,
},
};
export const errorValues = {
'-32700': {
standard: 'JSON RPC 2.0',
message: 'Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.',
},
'-32600': {
standard: 'JSON RPC 2.0',
message: 'The JSON sent is not a valid Request object.',
},
'-32601': {
standard: 'JSON RPC 2.0',
message: 'The method does not exist / is not available.',
},
'-32602': {
standard: 'JSON RPC 2.0',
message: 'Invalid method parameter(s).',
},
'-32603': {
standard: 'JSON RPC 2.0',
message: 'Internal JSON-RPC error.',
},
'-32000': {
standard: 'EIP-1474',
message: 'Invalid input.',
},
'-32001': {
standard: 'EIP-1474',
message: 'Resource not found.',
},
'-32002': {
standard: 'EIP-1474',
message: 'Resource unavailable.',
},
'-32003': {
standard: 'EIP-1474',
message: 'Transaction rejected.',
},
'-32004': {
standard: 'EIP-1474',
message: 'Method not supported.',
},
'-32005': {
standard: 'EIP-1474',
message: 'Request limit exceeded.',
},
'4001': {
standard: 'EIP-1193',
message: 'User rejected the request.',
},
'4100': {
standard: 'EIP-1193',
message: 'The requested account and/or method has not been authorized by the user.',
},
'4200': {
standard: 'EIP-1193',
message: 'The requested method is not supported by this Ethereum provider.',
},
'4900': {
standard: 'EIP-1193',
message: 'The provider is disconnected from all chains.',
},
'4901': {
standard: 'EIP-1193',
message: 'The provider is disconnected from the specified chain.',
},
'4902': {
standard: 'EIP-3085',
message: 'Unrecognized chain ID.',
},
};
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/core/error/constants.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,MAAM,kBAAkB,GAAe;IAC5C,GAAG,EAAE;QACH,YAAY,EAAE,CAAC,KAAK;QACpB,gBAAgB,EAAE,CAAC,KAAK;QACxB,mBAAmB,EAAE,CAAC,KAAK;QAC3B,mBAAmB,EAAE,CAAC,KAAK;QAC3B,kBAAkB,EAAE,CAAC,KAAK;QAC1B,aAAa,EAAE,CAAC,KAAK;QACrB,KAAK,EAAE,CAAC,KAAK;QACb,cAAc,EAAE,CAAC,KAAK;QACtB,cAAc,EAAE,CAAC,KAAK;QACtB,aAAa,EAAE,CAAC,KAAK;QACrB,QAAQ,EAAE,CAAC,KAAK;KACjB;IACD,QAAQ,EAAE;QACR,mBAAmB,EAAE,IAAI;QACzB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;QACvB,YA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C;KACzD;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,wDAAwD;KAClE;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,wBAAwB;KAClC;CACF,CAAC"}

View File

@@ -0,0 +1,48 @@
export declare const standardErrors: {
rpc: {
parse: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
invalidRequest: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
invalidParams: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
methodNotFound: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
internal: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
server: <T>(opts: ServerErrorOptions<T>) => EthereumRpcError<T>;
invalidInput: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
resourceNotFound: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
resourceUnavailable: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
transactionRejected: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
methodNotSupported: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
limitExceeded: <T>(arg?: EthErrorsArg<T>) => EthereumRpcError<T>;
};
provider: {
userRejectedRequest: <T>(arg?: EthErrorsArg<T>) => EthereumProviderError<T>;
unauthorized: <T>(arg?: EthErrorsArg<T>) => EthereumProviderError<T>;
unsupportedMethod: <T>(arg?: EthErrorsArg<T>) => EthereumProviderError<T>;
disconnected: <T>(arg?: EthErrorsArg<T>) => EthereumProviderError<T>;
chainDisconnected: <T>(arg?: EthErrorsArg<T>) => EthereumProviderError<T>;
unsupportedChain: <T>(arg?: EthErrorsArg<T>) => EthereumProviderError<T>;
custom: <T>(opts: CustomErrorArg<T>) => EthereumProviderError<T>;
};
};
interface EthereumErrorOptions<T> {
message?: string;
data?: T;
}
interface ServerErrorOptions<T> extends EthereumErrorOptions<T> {
code: number;
}
type CustomErrorArg<T> = ServerErrorOptions<T>;
type EthErrorsArg<T> = EthereumErrorOptions<T> | string;
declare class EthereumRpcError<T> extends Error {
code: number;
data?: T;
constructor(code: number, message: string, data?: T);
}
declare class EthereumProviderError<T> extends EthereumRpcError<T> {
/**
* Create an Ethereum Provider JSON-RPC error.
* `code` must be an integer in the 1000 <= 4999 range.
*/
constructor(code: number, message: string, data?: T);
}
export {};
//# sourceMappingURL=errors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/error/errors.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;gBAEf,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;yBAEf,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;wBAGzB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;yBAGvB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;mBAG9B,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;iBAG1B,CAAC,QAAQ,kBAAkB,CAAC,CAAC,CAAC;uBAWxB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;2BAGpB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;8BAGrB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;8BAGxB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;6BAGzB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;wBAG7B,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;;;8BAKlB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;uBAI/B,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;4BAInB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;uBAI7B,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;4BAInB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;2BAIzB,CAAC,QAAQ,YAAY,CAAC,CAAC,CAAC;iBAIlC,CAAC,QAAQ,cAAc,CAAC,CAAC,CAAC;;CAatC,CAAC;AA8BF,UAAU,oBAAoB,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;CACV;AAED,UAAU,kBAAkB,CAAC,CAAC,CAAE,SAAQ,oBAAoB,CAAC,CAAC,CAAC;IAC7D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,cAAc,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE/C,KAAK,YAAY,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAExD,cAAM,gBAAgB,CAAC,CAAC,CAAE,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,CAAC,EAAE,CAAC,CAAC;gBAEG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;CAcpD;AAED,cAAM,qBAAqB,CAAC,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IACxD;;;OAGG;gBACS,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;CAOpD"}

View File

@@ -0,0 +1,112 @@
import { standardErrorCodes } from './constants.js';
import { getMessageFromCode } from './utils.js';
export const standardErrors = {
rpc: {
parse: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.parse, arg),
invalidRequest: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.invalidRequest, arg),
invalidParams: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.invalidParams, arg),
methodNotFound: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.methodNotFound, arg),
internal: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.internal, arg),
server: (opts) => {
if (!opts || typeof opts !== 'object' || Array.isArray(opts)) {
throw new Error('Ethereum RPC Server errors must provide single object argument.');
}
const { code } = opts;
if (!Number.isInteger(code) || code > -32005 || code < -32099) {
throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');
}
return getEthJsonRpcError(code, opts);
},
invalidInput: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.invalidInput, arg),
resourceNotFound: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.resourceNotFound, arg),
resourceUnavailable: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.resourceUnavailable, arg),
transactionRejected: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.transactionRejected, arg),
methodNotSupported: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.methodNotSupported, arg),
limitExceeded: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.limitExceeded, arg),
},
provider: {
userRejectedRequest: (arg) => {
return getEthProviderError(standardErrorCodes.provider.userRejectedRequest, arg);
},
unauthorized: (arg) => {
return getEthProviderError(standardErrorCodes.provider.unauthorized, arg);
},
unsupportedMethod: (arg) => {
return getEthProviderError(standardErrorCodes.provider.unsupportedMethod, arg);
},
disconnected: (arg) => {
return getEthProviderError(standardErrorCodes.provider.disconnected, arg);
},
chainDisconnected: (arg) => {
return getEthProviderError(standardErrorCodes.provider.chainDisconnected, arg);
},
unsupportedChain: (arg) => {
return getEthProviderError(standardErrorCodes.provider.unsupportedChain, arg);
},
custom: (opts) => {
if (!opts || typeof opts !== 'object' || Array.isArray(opts)) {
throw new Error('Ethereum Provider custom errors must provide single object argument.');
}
const { code, message, data } = opts;
if (!message || typeof message !== 'string') {
throw new Error('"message" must be a nonempty string');
}
return new EthereumProviderError(code, message, data);
},
},
};
// Internal
function getEthJsonRpcError(code, arg) {
const [message, data] = parseOpts(arg);
return new EthereumRpcError(code, message || getMessageFromCode(code), data);
}
function getEthProviderError(code, arg) {
const [message, data] = parseOpts(arg);
return new EthereumProviderError(code, message || getMessageFromCode(code), data);
}
function parseOpts(arg) {
if (arg) {
if (typeof arg === 'string') {
return [arg];
}
else if (typeof arg === 'object' && !Array.isArray(arg)) {
const { message, data } = arg;
if (message && typeof message !== 'string') {
throw new Error('Must specify string message.');
}
return [message || undefined, data];
}
}
return [];
}
class EthereumRpcError extends Error {
constructor(code, message, data) {
if (!Number.isInteger(code)) {
throw new Error('"code" must be an integer.');
}
if (!message || typeof message !== 'string') {
throw new Error('"message" must be a nonempty string.');
}
super(message);
this.code = code;
if (data !== undefined) {
this.data = data;
}
}
}
class EthereumProviderError extends EthereumRpcError {
/**
* Create an Ethereum Provider JSON-RPC error.
* `code` must be an integer in the 1000 <= 4999 range.
*/
constructor(code, message, data) {
if (!isValidEthProviderCode(code)) {
throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
}
super(code, message, data);
}
}
function isValidEthProviderCode(code) {
return Number.isInteger(code) && code >= 1000 && code <= 4999;
}
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/error/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,EAAE;QACH,KAAK,EAAE,CAAI,GAAqB,EAAE,EAAE,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC;QAE1F,cAAc,EAAE,CAAI,GAAqB,EAAE,EAAE,CAC3C,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC;QAEhE,aAAa,EAAE,CAAI,GAAqB,EAAE,EAAE,CAC1C,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC;QAE/D,cAAc,EAAE,CAAI,GAAqB,EAAE,EAAE,CAC3C,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC;QAEhE,QAAQ,EAAE,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,IAAI,SAAS,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAeD,MAAM,gBAAoB,SAAQ,KAAK;IAKrC,YAAY,IAAY,EAAE,OAAe,EAAE,IAAQ;QACjD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAED,MAAM,qBAAyB,SAAQ,gBAAmB;IACxD;;;OAGG;IACH,YAAY,IAAY,EAAE,OAAe,EAAE,IAAQ;QACjD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QAED,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;AAChE,CAAC"}

View File

@@ -0,0 +1,13 @@
/**
* Serializes an error to a format that is compatible with the Ethereum JSON RPC error format.
* See https://docs.cloud.coinbase.com/wallet-sdk/docs/errors
* for more information.
*/
export declare function serializeError(error: unknown): {
docUrl: string;
code: number;
message: string;
data?: unknown;
stack?: string;
};
//# sourceMappingURL=serialize.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/core/error/serialize.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO;;;;;;EAc5C"}

View File

@@ -0,0 +1,42 @@
// TODO: error should not depend on walletlink. revisit this.
import { VERSION } from '../../sdk-info.js';
import { isErrorResponse } from '../../sign/walletlink/relay/type/Web3Response.js';
import { standardErrorCodes } from './constants.js';
import { serialize } from './utils.js';
/**
* Serializes an error to a format that is compatible with the Ethereum JSON RPC error format.
* See https://docs.cloud.coinbase.com/wallet-sdk/docs/errors
* for more information.
*/
export function serializeError(error) {
const serialized = serialize(getErrorObject(error), {
shouldIncludeStack: true,
});
const docUrl = new URL('https://docs.cloud.coinbase.com/wallet-sdk/docs/errors');
docUrl.searchParams.set('version', VERSION);
docUrl.searchParams.set('code', serialized.code.toString());
docUrl.searchParams.set('message', serialized.message);
return Object.assign(Object.assign({}, serialized), { docUrl: docUrl.href });
}
/**
* Converts an error to a serializable object.
*/
function getErrorObject(error) {
var _a;
if (typeof error === 'string') {
return {
message: error,
code: standardErrorCodes.rpc.internal,
};
}
else if (isErrorResponse(error)) {
const message = error.errorMessage;
const code = (_a = error.errorCode) !== null && _a !== void 0 ? _a : (message.match(/(denied|rejected)/i)
? standardErrorCodes.provider.userRejectedRequest
: undefined);
return Object.assign(Object.assign({}, error), { message,
code, data: { method: error.method } });
}
return error;
}
//# sourceMappingURL=serialize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/core/error/serialize.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAgB,MAAM,kDAAkD,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC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CAAC;AACf,CAAC"}

View File

@@ -0,0 +1,31 @@
export declare const JSON_RPC_SERVER_ERROR_MESSAGE = "Unspecified server error.";
/**
* Gets the message for a given code, or a fallback message if the code has
* no corresponding message.
*/
export declare function getMessageFromCode(code: number | undefined, fallbackMessage?: string): string;
/**
* Returns whether the given code is valid.
* A code is only valid if it has a message.
*/
export declare function isValidCode(code: number): boolean;
/**
* Returns the error code from an error object.
*/
export declare function getErrorCode(error: unknown): number | undefined;
/**
* Serializes the given error to an Ethereum JSON RPC-compatible error object.
* Merely copies the given error's values if it is already compatible.
* If the given error is not fully compatible, it will be preserved on the
* returned object's data.originalError property.
*/
export interface SerializedEthereumRpcError {
code: number;
message: string;
data?: unknown;
stack?: string;
}
export declare function serialize(error: unknown, { shouldIncludeStack }?: {
shouldIncludeStack?: boolean | undefined;
}): SerializedEthereumRpcError;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/error/utils.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAIzE;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,eAAe,GAAE,MAAyB,GACzC,MAAM,CAYR;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAcjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQ/D;AAgBD;;;;;GAKG;AAEH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,EAAE,kBAA0B,EAAE;;CAAK,GAClC,0BAA0B,CAmC5B"}

View File

@@ -0,0 +1,102 @@
import { errorValues, standardErrorCodes } from './constants.js';
const FALLBACK_MESSAGE = 'Unspecified error message.';
export const JSON_RPC_SERVER_ERROR_MESSAGE = 'Unspecified server error.';
/**
* Gets the message for a given code, or a fallback message if the code has
* no corresponding message.
*/
export function getMessageFromCode(code, fallbackMessage = FALLBACK_MESSAGE) {
if (code && Number.isInteger(code)) {
const codeString = code.toString();
if (hasKey(errorValues, codeString)) {
return errorValues[codeString].message;
}
if (isJsonRpcServerError(code)) {
return JSON_RPC_SERVER_ERROR_MESSAGE;
}
}
return fallbackMessage;
}
/**
* Returns whether the given code is valid.
* A code is only valid if it has a message.
*/
export function isValidCode(code) {
if (!Number.isInteger(code)) {
return false;
}
const codeString = code.toString();
if (errorValues[codeString]) {
return true;
}
if (isJsonRpcServerError(code)) {
return true;
}
return false;
}
/**
* Returns the error code from an error object.
*/
export function getErrorCode(error) {
var _a;
if (typeof error === 'number') {
return error;
}
else if (isErrorWithCode(error)) {
return (_a = error.code) !== null && _a !== void 0 ? _a : error.errorCode;
}
return undefined;
}
function isErrorWithCode(error) {
return (typeof error === 'object' &&
error !== null &&
(typeof error.code === 'number' ||
typeof error.errorCode === 'number'));
}
export function serialize(error, { shouldIncludeStack = false } = {}) {
const serialized = {};
if (error &&
typeof error === 'object' &&
!Array.isArray(error) &&
hasKey(error, 'code') &&
isValidCode(error.code)) {
const _error = error;
serialized.code = _error.code;
if (_error.message && typeof _error.message === 'string') {
serialized.message = _error.message;
if (hasKey(_error, 'data')) {
serialized.data = _error.data;
}
}
else {
serialized.message = getMessageFromCode(serialized.code);
serialized.data = { originalError: assignOriginalError(error) };
}
}
else {
serialized.code = standardErrorCodes.rpc.internal;
serialized.message = hasStringProperty(error, 'message') ? error.message : FALLBACK_MESSAGE;
serialized.data = { originalError: assignOriginalError(error) };
}
if (shouldIncludeStack) {
serialized.stack = hasStringProperty(error, 'stack') ? error.stack : undefined;
}
return serialized;
}
// Internal
function isJsonRpcServerError(code) {
return code >= -32099 && code <= -32000;
}
function assignOriginalError(error) {
if (error && typeof error === 'object' && !Array.isArray(error)) {
return Object.assign({}, error);
}
return error;
}
function hasKey(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function hasStringProperty(obj, prop) {
return (typeof obj === 'object' && obj !== null && prop in obj && typeof obj[prop] === 'string');
}
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/error/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAEtD,MAAM,CAAC,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAIzE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAwB,EACxB,kBAA0B,gBAAgB;IAE1C,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEnC,IAAI,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,CAAC;YACpC,OAAO,WAAW,CAAC,UAA2B,CAAC,CAAC,OAAO,CAAC;QAC1D,CAAC;QACD,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,6BAA6B,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IACnC,IAAI,WAAW,CAAC,UAA2B,CAAC,EAAE,CAAC;QAC7C,OA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AAC;AAED,SAAS,MAAM,CAAC,GAA4B,EAAE,GAAW;IACvD,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,iBAAiB,CAAI,GAAY,EAAE,IAAa;IACvD,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI,OAAQ,GAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,CAC/F,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,7 @@
import { Message } from './Message.js';
export interface ConfigMessage extends Message {
event: ConfigEvent;
}
export type ConfigEvent = 'PopupLoaded' | 'PopupUnload' | 'selectSignerType' | 'WalletLinkSessionRequest' | 'WalletLinkUpdate';
export type SignerType = 'scw' | 'walletlink';
//# sourceMappingURL=ConfigMessage.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConfigMessage.d.ts","sourceRoot":"","sources":["../../../src/core/message/ConfigMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,aAAa,GACb,kBAAkB,GAClB,0BAA0B,GAC1B,kBAAkB,CAAC;AAEvB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,YAAY,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ConfigMessage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConfigMessage.js","sourceRoot":"","sources":["../../../src/core/message/ConfigMessage.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
import { UUID } from 'crypto';
export type MessageID = UUID;
export interface Message {
id?: MessageID;
requestId?: MessageID;
data?: unknown;
}
//# sourceMappingURL=Message.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/core/message/Message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC;AAE7B,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=Message.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/core/message/Message.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,30 @@
import { SerializedEthereumRpcError } from '../error/utils.js';
import { Message, MessageID } from './Message.js';
import { RequestArguments } from '../provider/interface.js';
interface RPCMessage extends Message {
id: MessageID;
sender: string;
content: unknown;
timestamp: Date;
}
export type EncryptedData = {
iv: ArrayBuffer;
cipherText: ArrayBuffer;
};
export interface RPCRequestMessage extends RPCMessage {
content: {
handshake: RequestArguments;
} | {
encrypted: EncryptedData;
};
}
export interface RPCResponseMessage extends RPCMessage {
requestId: MessageID;
content: {
encrypted: EncryptedData;
} | {
failure: SerializedEthereumRpcError;
};
}
export {};
//# sourceMappingURL=RPCMessage.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RPCMessage.d.ts","sourceRoot":"","sources":["../../../src/core/message/RPCMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,UAAU,UAAW,SAAQ,OAAO;IAClC,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,WAAW,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,OAAO,EACH;QACE,SAAS,EAAE,gBAAgB,CAAC;KAC7B,GACD;QACE,SAAS,EAAE,aAAa,CAAC;KAC1B,CAAC;CACP;AAED,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EACH;QACE,SAAS,EAAE,aAAa,CAAC;KAC1B,GACD;QACE,OAAO,EAAE,0BAA0B,CAAC;KACrC,CAAC;CACP"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=RPCMessage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RPCMessage.js","sourceRoot":"","sources":["../../../src/core/message/RPCMessage.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
import { RequestArguments } from '../provider/interface.js';
export type RPCRequest = {
action: RequestArguments;
chainId: number;
};
//# sourceMappingURL=RPCRequest.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RPCRequest.d.ts","sourceRoot":"","sources":["../../../src/core/message/RPCRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=RPCRequest.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RPCRequest.js","sourceRoot":"","sources":["../../../src/core/message/RPCRequest.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,15 @@
import { SerializedEthereumRpcError } from '../error/utils.js';
export type RPCResponse = {
result: {
value: unknown;
} | {
error: SerializedEthereumRpcError;
};
data?: {
chains?: {
[key: number]: string;
};
capabilities?: Record<`0x${string}`, Record<string, unknown>>;
};
};
//# sourceMappingURL=RPCResponse.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RPCResponse.d.ts","sourceRoot":"","sources":["../../../src/core/message/RPCResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EACF;QACE,KAAK,EAAE,OAAO,CAAC;KAChB,GACD;QACE,KAAK,EAAE,0BAA0B,CAAC;KACnC,CAAC;IACN,IAAI,CAAC,EAAE;QAEL,MAAM,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAC;QACnC,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KAC/D,CAAC;CACH,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=RPCResponse.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RPCResponse.js","sourceRoot":"","sources":["../../../src/core/message/RPCResponse.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,70 @@
import { EventEmitter } from 'eventemitter3';
export interface RequestArguments {
readonly method: string;
readonly params?: readonly unknown[] | object;
}
export interface ProviderRpcError extends Error {
message: string;
code: number;
data?: unknown;
}
interface ProviderConnectInfo {
readonly chainId: string;
}
type ProviderEventMap = {
connect: ProviderConnectInfo;
disconnect: ProviderRpcError;
chainChanged: string;
accountsChanged: string[];
};
export declare class ProviderEventEmitter extends EventEmitter<keyof ProviderEventMap> {
}
export interface ProviderInterface extends ProviderEventEmitter {
request(args: RequestArguments): Promise<unknown>;
disconnect(): Promise<void>;
emit<K extends keyof ProviderEventMap>(event: K, ...args: [ProviderEventMap[K]]): boolean;
on<K extends keyof ProviderEventMap>(event: K, listener: (_: ProviderEventMap[K]) => void): this;
}
export type ProviderEventCallback = ProviderInterface['emit'];
export interface AppMetadata {
/** Application name */
appName: string;
/** Application logo image URL; favicon is used if unspecified */
appLogoUrl: string | null;
/** Array of chainIds your dapp supports */
appChainIds: number[];
}
export type Attribution = {
auto: boolean;
dataSuffix?: never;
} | {
auto?: never;
dataSuffix: `0x${string}`;
};
export type Preference = {
/**
* The URL for the keys popup.
* By default, `https://keys.coinbase.com/connect` is used for production. Use `https://keys-dev.coinbase.com/connect` for development environments.
* @type {string}
*/
keysUrl?: string;
/**
* @param options
*/
options: 'all' | 'smartWalletOnly' | 'eoaOnly';
/**
* @param attribution
* @type {Attribution}
* @note Smart Wallet only
* @description This option only applies to Coinbase Smart Wallet. When a valid data suffix is supplied, it is appended to the initCode and executeBatch calldata.
* Coinbase Smart Wallet expects a 16 byte hex string. If the data suffix is not a 16 byte hex string, the Smart Wallet will ignore the property. If auto is true,
* the Smart Wallet will generate a 16 byte hex string from the apps origin.
*/
attribution?: Attribution;
} & Record<string, unknown>;
export interface ConstructorOptions {
metadata: AppMetadata;
preference: Preference;
}
export {};
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/core/provider/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,OAAO,EAA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AIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,KAAK,GAAG,iBAAiB,GAAG,SAAS,CAAC;IAC/C;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB"}

View File

@@ -0,0 +1,4 @@
import { EventEmitter } from 'eventemitter3';
export class ProviderEventEmitter extends EventEmitter {
}
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/core/provider/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAwB7C,MAAM,OAAO,oBAAqB,SAAQ,YAAoC;CAAG"}

View File

@@ -0,0 +1,14 @@
export declare class ScopedLocalStorage {
private scope;
private module?;
constructor(scope: 'CBWSDK' | 'walletlink', module?: string | undefined);
storeObject<T>(key: string, item: T): void;
loadObject<T>(key: string): T | undefined;
setItem(key: string, value: string): void;
getItem(key: string): string | null;
removeItem(key: string): void;
clear(): void;
scopedKey(key: string): string;
static clearAll(): void;
}
//# sourceMappingURL=ScopedLocalStorage.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ScopedLocalStorage.d.ts","sourceRoot":"","sources":["../../../src/core/storage/ScopedLocalStorage.ts"],"names":[],"mappings":"AAGA,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM,CAAC;gBADP,KAAK,EAAE,QAAQ,GAAG,YAAY,EAC9B,MAAM,CAAC,EAAE,MAAM,YAAA;IAGzB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAInC,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAKlC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAInC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,KAAK,IAAI,IAAI;IAYpB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI9B,MAAM,CAAC,QAAQ;CAIhB"}

View File

@@ -0,0 +1,43 @@
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
// TODO: clean up, or possibly deprecate Storage class
export class ScopedLocalStorage {
constructor(scope, module) {
this.scope = scope;
this.module = module;
}
storeObject(key, item) {
this.setItem(key, JSON.stringify(item));
}
loadObject(key) {
const item = this.getItem(key);
return item ? JSON.parse(item) : undefined;
}
setItem(key, value) {
localStorage.setItem(this.scopedKey(key), value);
}
getItem(key) {
return localStorage.getItem(this.scopedKey(key));
}
removeItem(key) {
localStorage.removeItem(this.scopedKey(key));
}
clear() {
const prefix = this.scopedKey('');
const keysToRemove = [];
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (typeof key === 'string' && key.startsWith(prefix)) {
keysToRemove.push(key);
}
}
keysToRemove.forEach((key) => localStorage.removeItem(key));
}
scopedKey(key) {
return `-${this.scope}${this.module ? `:${this.module}` : ''}:${key}`;
}
static clearAll() {
new ScopedLocalStorage('CBWSDK').clear();
new ScopedLocalStorage('walletlink').clear();
}
}
//# sourceMappingURL=ScopedLocalStorage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ScopedLocalStorage.js","sourceRoot":"","sources":["../../../src/core/storage/ScopedLocalStorage.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,sDAAsD;AACtD,MAAM,OAAO,kBAAkB;IAC7B,YACU,KAA8B,EAC9B,MAAe;QADf,UAAK,GAAL,KAAK,CAAyB;QA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CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,OAAO,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,QAAQ;QACb,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,kBAAkB,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;CACF"}

View File

@@ -0,0 +1,19 @@
interface Tag<T extends string, RealType> {
__tag__: T;
__realType__: RealType;
}
export type OpaqueType<T extends string, U> = U & Tag<T, U>;
export declare function OpaqueType<T extends Tag<string, unknown>>(): (value: T extends Tag<string, infer U> ? U : never) => T;
export type HexString = OpaqueType<'HexString', string>;
export declare const HexString: (value: string) => HexString;
export type AddressString = OpaqueType<'AddressString', string>;
export declare const AddressString: (value: string) => AddressString;
export type BigIntString = OpaqueType<'BigIntString', string>;
export declare const BigIntString: (value: string) => BigIntString;
export type IntNumber = OpaqueType<'IntNumber', number>;
export declare function IntNumber(num: number): IntNumber;
export type RegExpString = OpaqueType<'RegExpString', string>;
export declare const RegExpString: (value: string) => RegExpString;
export type Callback<T> = (err: Error | null, result: T | null) => void;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/type/index.ts"],"names":[],"mappings":"AACA,UAAU,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,YAAY,EAAE,QAAQ,CAAC;CACxB;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5D,wBAAgB,UAAU,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,aACxC,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,KAAG,CAAC,CAC9D;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACxD,eAAO,MAAM,SAAS,8BAA0B,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAChE,eAAO,MAAM,aAAa,kCAA8B,CAAC;AAEzD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC9D,eAAO,MAAM,YAAY,iCAA6B,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACxD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAEhD;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC9D,eAAO,MAAM,YAAY,iCAA6B,CAAC;AAEvD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC"}

View File

@@ -0,0 +1,11 @@
export function OpaqueType() {
return (value) => value;
}
export const HexString = OpaqueType();
export const AddressString = OpaqueType();
export const BigIntString = OpaqueType();
export function IntNumber(num) {
return Math.floor(num);
}
export const RegExpString = OpaqueType();
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/type/index.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,KAAiD,EAAK,EAAE,CAAC,KAAU,CAAC;AAC9E,CAAC;AAGD,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,EAAa,CAAC;AAGjD,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,EAAiB,CAAC;AAGzD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,EAAgB,CAAC;AAGvD,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAc,CAAC;AACtC,CAAC;AAGD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,EAAgB,CAAC"}

View File

@@ -0,0 +1,29 @@
import { AddressString, BigIntString, HexString, IntNumber, RegExpString } from './index.js';
/**
* @param length number of bytes
*/
export declare function randomBytesHex(length: number): string;
export declare function uint8ArrayToHex(value: Uint8Array): string;
export declare function hexStringToUint8Array(hexString: string): Uint8Array;
export declare function hexStringFromBuffer(buf: Buffer, includePrefix?: boolean): HexString;
export declare function encodeToHexString(str: unknown): HexString;
export declare function bigIntStringFromBigInt(bi: bigint): BigIntString;
export declare function intNumberFromHexString(hex: HexString): IntNumber;
export declare function hexStringFromNumber(num: number): HexString;
export declare function has0xPrefix(str: string): boolean;
export declare function strip0x(hex: string): string;
export declare function prepend0x(hex: string): string;
export declare function isHexString(hex: unknown): hex is HexString;
export declare function ensureHexString(hex: unknown, includePrefix?: boolean): HexString;
export declare function ensureEvenLengthHexString(hex: unknown, includePrefix?: boolean): HexString;
export declare function ensureAddressString(str: unknown): AddressString;
export declare function ensureBuffer(str: unknown): Buffer;
export declare function ensureIntNumber(num: unknown): IntNumber;
export declare function ensureRegExpString(regExp: unknown): RegExpString;
export declare function ensureBigInt(val: unknown): bigint;
export declare function ensureParsedJSONObject<T extends object>(val: unknown): T;
export declare function isBigNumber(val: unknown): boolean;
export declare function range(start: number, stop: number): number[];
export declare function getFavicon(): string | null;
export declare function areAddressArraysEqual(arr1: AddressString[], arr2: AddressString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G,aAAa,CAQ/D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAYjD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAavD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAKhE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAgBjD;AAED,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,CAAC,CAUxE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAMjD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE3D;AAED,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAmB1C;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,CAE3F"}

View File

@@ -0,0 +1,172 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// Copyright (c) 2018-2023 Coinbase, Inc. <https://www.coinbase.com/>
import { standardErrors } from '../error/errors.js';
import { AddressString, BigIntString, HexString, IntNumber, RegExpString } from './index.js';
const INT_STRING_REGEX = /^[0-9]*$/;
const HEXADECIMAL_STRING_REGEX = /^[a-f0-9]*$/;
/**
* @param length number of bytes
*/
export function randomBytesHex(length) {
return uint8ArrayToHex(crypto.getRandomValues(new Uint8Array(length)));
}
export function uint8ArrayToHex(value) {
return [...value].map((b) => b.toString(16).padStart(2, '0')).join('');
}
export function hexStringToUint8Array(hexString) {
return new Uint8Array(hexString.match(/.{1,2}/g).map((byte) => Number.parseInt(byte, 16)));
}
export function hexStringFromBuffer(buf, includePrefix = false) {
const hex = buf.toString('hex');
return HexString(includePrefix ? `0x${hex}` : hex);
}
export function encodeToHexString(str) {
return hexStringFromBuffer(ensureBuffer(str), true);
}
export function bigIntStringFromBigInt(bi) {
return BigIntString(bi.toString(10));
}
export function intNumberFromHexString(hex) {
return IntNumber(Number(BigInt(ensureEvenLengthHexString(hex, true))));
}
export function hexStringFromNumber(num) {
return HexString(`0x${BigInt(num).toString(16)}`);
}
export function has0xPrefix(str) {
return str.startsWith('0x') || str.startsWith('0X');
}
export function strip0x(hex) {
if (has0xPrefix(hex)) {
return hex.slice(2);
}
return hex;
}
export function prepend0x(hex) {
if (has0xPrefix(hex)) {
return `0x${hex.slice(2)}`;
}
return `0x${hex}`;
}
export function isHexString(hex) {
if (typeof hex !== 'string') {
return false;
}
const s = strip0x(hex).toLowerCase();
return HEXADECIMAL_STRING_REGEX.test(s);
}
export function ensureHexString(hex, includePrefix = false) {
if (typeof hex === 'string') {
const s = strip0x(hex).toLowerCase();
if (HEXADECIMAL_STRING_REGEX.test(s)) {
return HexString(includePrefix ? `0x${s}` : s);
}
}
throw standardErrors.rpc.invalidParams(`"${String(hex)}" is not a hexadecimal string`);
}
export function ensureEvenLengthHexString(hex, includePrefix = false) {
let h = ensureHexString(hex, false);
if (h.length % 2 === 1) {
h = HexString(`0${h}`);
}
return includePrefix ? HexString(`0x${h}`) : h;
}
export function ensureAddressString(str) {
if (typeof str === 'string') {
const s = strip0x(str).toLowerCase();
if (isHexString(s) && s.length === 40) {
return AddressString(prepend0x(s));
}
}
throw standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(str)}`);
}
export function ensureBuffer(str) {
if (Buffer.isBuffer(str)) {
return str;
}
if (typeof str === 'string') {
if (isHexString(str)) {
const s = ensureEvenLengthHexString(str, false);
return Buffer.from(s, 'hex');
}
return Buffer.from(str, 'utf8');
}
throw standardErrors.rpc.invalidParams(`Not binary data: ${String(str)}`);
}
export function ensureIntNumber(num) {
if (typeof num === 'number' && Number.isInteger(num)) {
return IntNumber(num);
}
if (typeof num === 'string') {
if (INT_STRING_REGEX.test(num)) {
return IntNumber(Number(num));
}
if (isHexString(num)) {
return IntNumber(Number(BigInt(ensureEvenLengthHexString(num, true))));
}
}
throw standardErrors.rpc.invalidParams(`Not an integer: ${String(num)}`);
}
export function ensureRegExpString(regExp) {
if (regExp instanceof RegExp) {
return RegExpString(regExp.toString());
}
throw standardErrors.rpc.invalidParams(`Not a RegExp: ${String(regExp)}`);
}
export function ensureBigInt(val) {
if (val !== null && (typeof val === 'bigint' || isBigNumber(val))) {
return BigInt(val.toString(10));
}
if (typeof val === 'number') {
return BigInt(ensureIntNumber(val));
}
if (typeof val === 'string') {
if (INT_STRING_REGEX.test(val)) {
return BigInt(val);
}
if (isHexString(val)) {
return BigInt(ensureEvenLengthHexString(val, true));
}
}
throw standardErrors.rpc.invalidParams(`Not an integer: ${String(val)}`);
}
export function ensureParsedJSONObject(val) {
if (typeof val === 'string') {
return JSON.parse(val);
}
if (typeof val === 'object') {
return val;
}
throw standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(val)}`);
}
export function isBigNumber(val) {
if (val == null || typeof val.constructor !== 'function') {
return false;
}
const { constructor } = val;
return typeof constructor.config === 'function' && typeof constructor.EUCLID === 'number';
}
export function range(start, stop) {
return Array.from({ length: stop - start }, (_, i) => start + i);
}
export function getFavicon() {
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, arr2) {
return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
}
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
import { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
import { AppMetadata, Preference } from './core/provider/interface.js';
export type CreateProviderOptions = {
metadata: AppMetadata;
preference: Preference;
};
export declare function createCoinbaseWalletProvider(options: CreateProviderOptions): import("./core/provider/interface.js").ProviderInterface | CoinbaseWalletProvider;
//# sourceMappingURL=createCoinbaseWalletProvider.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createCoinbaseWalletProvider.d.ts","sourceRoot":"","sources":["../src/createCoinbaseWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAsB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG1F,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,qBAAqB,oFAM1E"}

View File

@@ -0,0 +1,11 @@
import { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
import { getCoinbaseInjectedProvider } from './util/provider.js';
export function createCoinbaseWalletProvider(options) {
var _a;
const params = {
metadata: options.metadata,
preference: options.preference,
};
return (_a = getCoinbaseInjectedProvider(params)) !== null && _a !== void 0 ? _a : new CoinbaseWalletProvider(params);
}
//# sourceMappingURL=createCoinbaseWalletProvider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createCoinbaseWalletProvider.js","sourceRoot":"","sources":["../src/createCoinbaseWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAOhE,MAAM,UAAU,4BAA4B,CAAC,OAA8B;;IACzE,MAAM,MAAM,GAAuB;QACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC;IACF,OAAO,MAAA,2BAA2B,CAAC,MAAM,CAAC,mCAAI,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;AACnF,CAAC"}

View File

@@ -0,0 +1,13 @@
import { AppMetadata, Preference, ProviderInterface } from './core/provider/interface.js';
export type CreateCoinbaseWalletSDKOptions = Partial<AppMetadata> & {
preference?: Preference;
};
/**
* Create a Coinbase Wallet SDK instance.
* @param params - Options to create a Coinbase Wallet SDK instance.
* @returns A Coinbase Wallet SDK object.
*/
export declare function createCoinbaseWalletSDK(params: CreateCoinbaseWalletSDKOptions): {
getProvider: () => ProviderInterface;
};
//# sourceMappingURL=createCoinbaseWalletSDK.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createCoinbaseWalletSDK.d.ts","sourceRoot":"","sources":["../src/createCoinbaseWalletSDK.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EAEX,UAAU,EACV,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAKrC,MAAM,MAAM,8BAA8B,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG;IAClE,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAMF;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,8BAA8B;;EA8B7E"}

View File

@@ -0,0 +1,41 @@
import { createCoinbaseWalletProvider } from './createCoinbaseWalletProvider.js';
import { VERSION } from './sdk-info.js';
import { ScopedLocalStorage } from './core/storage/ScopedLocalStorage.js';
import { checkCrossOriginOpenerPolicy } from './util/checkCrossOriginOpenerPolicy.js';
import { validatePreferences } from './util/validatePreferences.js';
const DEFAULT_PREFERENCE = {
options: 'all',
};
/**
* Create a Coinbase Wallet SDK instance.
* @param params - Options to create a Coinbase Wallet SDK instance.
* @returns A Coinbase Wallet SDK object.
*/
export function createCoinbaseWalletSDK(params) {
var _a;
const versionStorage = new ScopedLocalStorage('CBWSDK');
versionStorage.setItem('VERSION', VERSION);
void checkCrossOriginOpenerPolicy();
const options = {
metadata: {
appName: params.appName || 'Dapp',
appLogoUrl: params.appLogoUrl || '',
appChainIds: params.appChainIds || [],
},
preference: Object.assign(DEFAULT_PREFERENCE, (_a = params.preference) !== null && _a !== void 0 ? _a : {}),
};
/**
* Validate user supplied preferences. Throws if key/values are not valid.
*/
validatePreferences(options.preference);
let provider = null;
return {
getProvider: () => {
if (!provider) {
provider = createCoinbaseWalletProvider(options);
}
return provider;
},
};
}
//# sourceMappingURL=createCoinbaseWalletSDK.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createCoinbaseWalletSDK.js","sourceRoot":"","sources":["../src/createCoinbaseWalletSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAOxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAMnE,MAAM,kBAAkB,GAAe;IACrC,OAAO,EAAE,KAAK;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAsC;;IAC5E,MAAM,cAAc,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxD,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE3C,KAAK,4BAA4B,EAAE,CAAC;IAEpC,MAAM,OAAO,GAAuB;QAClC,QAAQ,EAAE;YACR,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM;YACjC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE;YACnC,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;SACtC;QACD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAA,MAAM,CAAC,UAAU,mCAAI,EAAE,CAAC;KACvE,CAAC;IAEF;;OAEG;IACH,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAExC,IAAI,QAAQ,GAA6B,IAAI,CAAC;IAE9C,OAAO;QACL,WAAW,EAAE,GAAG,EAAE;YAChB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,QAAQ,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}

7
node_modules/@coinbase/wallet-sdk/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { CoinbaseWalletSDK } from './CoinbaseWalletSDK.js';
export default CoinbaseWalletSDK;
export type { CoinbaseWalletProvider } from './CoinbaseWalletProvider.js';
export { CoinbaseWalletSDK } from './CoinbaseWalletSDK.js';
export { createCoinbaseWalletSDK } from './createCoinbaseWalletSDK.js';
export type { AppMetadata, Preference, ProviderInterface } from './core/provider/interface.js';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,eAAe,iBAAiB,CAAC;AAEjC,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC"}

6
node_modules/@coinbase/wallet-sdk/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
import { CoinbaseWalletSDK } from './CoinbaseWalletSDK.js';
export default CoinbaseWalletSDK;
export { CoinbaseWalletSDK } from './CoinbaseWalletSDK.js';
export { createCoinbaseWalletSDK } from './createCoinbaseWalletSDK.js';
//# sourceMappingURL=index.js.map

1
node_modules/@coinbase/wallet-sdk/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,eAAe,iBAAiB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}

3
node_modules/@coinbase/wallet-sdk/dist/sdk-info.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare const VERSION = "4.3.7";
export declare const NAME = "@coinbase/wallet-sdk";
//# sourceMappingURL=sdk-info.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sdk-info.d.ts","sourceRoot":"","sources":["../src/sdk-info.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,IAAI,yBAAyB,CAAC"}

3
node_modules/@coinbase/wallet-sdk/dist/sdk-info.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export const VERSION = '4.3.7';
export const NAME = '@coinbase/wallet-sdk';
//# sourceMappingURL=sdk-info.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sdk-info.js","sourceRoot":"","sources":["../src/sdk-info.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,sBAAsB,CAAC"}

View File

@@ -0,0 +1,7 @@
import { RequestArguments } from '../core/provider/interface.js';
export interface Signer {
handshake(_: RequestArguments): Promise<void>;
request<T>(_: RequestArguments): Promise<T>;
cleanup: () => Promise<void>;
}
//# sourceMappingURL=interface.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/sign/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,WAAW,MAAM;IACrB,SAAS,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/sign/interface.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,16 @@
export declare class SCWKeyManager {
private readonly storage;
private ownPrivateKey;
private ownPublicKey;
private peerPublicKey;
private sharedSecret;
getOwnPublicKey(): Promise<CryptoKey>;
getSharedSecret(): Promise<CryptoKey | null>;
setPeerPublicKey(key: CryptoKey): Promise<void>;
clear(): Promise<void>;
private generateKeyPair;
private loadKeysIfNeeded;
private loadKey;
private storeKey;
}
//# sourceMappingURL=SCWKeyManager.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SCWKeyManager.d.ts","sourceRoot":"","sources":["../../../src/sign/scw/SCWKeyManager.ts"],"names":[],"mappings":"AAyBA,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqD;IAC7E,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,YAAY,CAA0B;IAExC,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC;IAMrC,eAAe,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAK5C,gBAAgB,CAAC,GAAG,EAAE,SAAS;IAO/B,KAAK;YAWG,eAAe;YAQf,gBAAgB;YAyBhB,OAAO;YAOP,QAAQ;CAIvB"}

View File

@@ -0,0 +1,85 @@
import { ScopedLocalStorage } from '../../core/storage/ScopedLocalStorage.js';
import { deriveSharedSecret, exportKeyToHexString, generateKeyPair, importKeyFromHexString, } from '../../util/cipher.js';
const OWN_PRIVATE_KEY = {
storageKey: 'ownPrivateKey',
keyType: 'private',
};
const OWN_PUBLIC_KEY = {
storageKey: 'ownPublicKey',
keyType: 'public',
};
const PEER_PUBLIC_KEY = {
storageKey: 'peerPublicKey',
keyType: 'public',
};
export class SCWKeyManager {
constructor() {
this.storage = new ScopedLocalStorage('CBWSDK', 'SCWKeyManager');
this.ownPrivateKey = null;
this.ownPublicKey = null;
this.peerPublicKey = null;
this.sharedSecret = null;
}
async getOwnPublicKey() {
await this.loadKeysIfNeeded();
return this.ownPublicKey;
}
// returns null if the shared secret is not yet derived
async getSharedSecret() {
await this.loadKeysIfNeeded();
return this.sharedSecret;
}
async setPeerPublicKey(key) {
this.sharedSecret = null;
this.peerPublicKey = key;
await this.storeKey(PEER_PUBLIC_KEY, key);
await this.loadKeysIfNeeded();
}
async clear() {
this.ownPrivateKey = null;
this.ownPublicKey = null;
this.peerPublicKey = null;
this.sharedSecret = null;
this.storage.removeItem(OWN_PUBLIC_KEY.storageKey);
this.storage.removeItem(OWN_PRIVATE_KEY.storageKey);
this.storage.removeItem(PEER_PUBLIC_KEY.storageKey);
}
async generateKeyPair() {
const newKeyPair = await generateKeyPair();
this.ownPrivateKey = newKeyPair.privateKey;
this.ownPublicKey = newKeyPair.publicKey;
await this.storeKey(OWN_PRIVATE_KEY, newKeyPair.privateKey);
await this.storeKey(OWN_PUBLIC_KEY, newKeyPair.publicKey);
}
async loadKeysIfNeeded() {
if (this.ownPrivateKey === null) {
this.ownPrivateKey = await this.loadKey(OWN_PRIVATE_KEY);
}
if (this.ownPublicKey === null) {
this.ownPublicKey = await this.loadKey(OWN_PUBLIC_KEY);
}
if (this.ownPrivateKey === null || this.ownPublicKey === null) {
await this.generateKeyPair();
}
if (this.peerPublicKey === null) {
this.peerPublicKey = await this.loadKey(PEER_PUBLIC_KEY);
}
if (this.sharedSecret === null) {
if (this.ownPrivateKey === null || this.peerPublicKey === null)
return;
this.sharedSecret = await deriveSharedSecret(this.ownPrivateKey, this.peerPublicKey);
}
}
// storage methods
async loadKey(item) {
const key = this.storage.getItem(item.storageKey);
if (!key)
return null;
return importKeyFromHexString(item.keyType, key);
}
async storeKey(item, key) {
const hexString = await exportKeyToHexString(item.keyType, key);
this.storage.setItem(item.storageKey, hexString);
}
}
//# sourceMappingURL=SCWKeyManager.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SCWKeyManager.js","sourceRoot":"","sources":["../../../src/sign/scw/SCWKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAMzB,MAAM,eAAe,GAAG;IACtB,UAAU,EAAE,eAAe;IAC3B,OAAO,EAAE,SAAS;CACV,CAAC;AACX,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,QAAQ;CACT,CAAC;AACX,MAAM,eAAe,GAAG;IACtB,UAAU,EAAE,eAAe;IAC3B,OAAO,EAAE,QAAQ;CACT,CAAC;AAEX,MAAM,OAAO,aAAa;IAA1B;QACmB,YAAO,GAAG,IAAI,kBAAkB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACrE,kBAAa,GAAqB,IAAI,CAAC;QACvC,iBAAY,GAAqB,IAAI,CAAC;QACtC,kBAAa,GAAqB,IAAI,CAAC;QACvC,iBAAY,GAAqB,IAAI,CAAC;IA2EhD,CAAC;IAzEC,KAAK,CAAC,eAAe;QACnB,MAAM,IAA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MAAM,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;CACF"}

View File

@@ -0,0 +1,34 @@
import { Signer } from '../interface.js';
import { Communicator } from '../../core/communicator/Communicator.js';
import { AppMetadata, ProviderEventCallback, RequestArguments } from '../../core/provider/interface.js';
type ConstructorOptions = {
metadata: AppMetadata;
communicator: Communicator;
callback: ProviderEventCallback | null;
};
export declare class SCWSigner implements Signer {
private readonly metadata;
private readonly communicator;
private readonly keyManager;
private readonly storage;
private callback;
private accounts;
private chain;
constructor(params: ConstructorOptions);
handshake(args: RequestArguments): Promise<void>;
request(request: RequestArguments): Promise<any>;
private sendRequestToPopup;
cleanup(): Promise<void>;
/**
* @returns `null` if the request was successful.
* https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain
*/
private handleSwitchChainRequest;
private handleGetCapabilitiesRequest;
private sendEncryptedRequest;
private createRequestMessage;
private decryptResponseMessage;
private updateChain;
}
export {};
//# sourceMappingURL=SCWSigner.d.ts.map

Some files were not shown because too many files have changed in this diff Show More