@coinbase/wallet-sdk
Advanced tools
Comparing version 4.2.4 to 4.3.0
@@ -14,2 +14,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { Communicator } from './core/communicator/Communicator.js'; | ||
import { CB_WALLET_RPC_URL } from './core/constants.js'; | ||
import { standardErrorCodes } from './core/error/constants.js'; | ||
@@ -21,3 +22,3 @@ import { standardErrors } from './core/error/errors.js'; | ||
import { hexStringFromNumber } from './core/type/util.js'; | ||
import { checkErrorForInvalidRequestArgs } from './util/provider.js'; | ||
import { checkErrorForInvalidRequestArgs, fetchRPCRequest } from './util/provider.js'; | ||
export class CoinbaseWalletProvider extends ProviderEventEmitter { | ||
@@ -54,2 +55,11 @@ constructor(_a) { | ||
} | ||
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': | ||
@@ -64,3 +74,3 @@ return 1; // default value | ||
} | ||
return this.signer.request(args); | ||
return await this.signer.request(args); | ||
} | ||
@@ -67,0 +77,0 @@ catch (error) { |
export declare const CB_KEYS_URL = "https://keys.coinbase.com/connect"; | ||
export declare const CB_WALLET_RPC_URL = "http://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 |
export const CB_KEYS_URL = 'https://keys.coinbase.com/connect'; | ||
export const CB_WALLET_RPC_URL = 'http://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 |
@@ -1,3 +0,3 @@ | ||
export declare const VERSION = "4.2.4"; | ||
export declare const VERSION = "4.3.0"; | ||
export declare const NAME = "@coinbase/wallet-sdk"; | ||
//# sourceMappingURL=sdk-info.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export const VERSION = '4.2.4'; | ||
export const VERSION = '4.3.0'; | ||
export const NAME = '@coinbase/wallet-sdk'; | ||
//# sourceMappingURL=sdk-info.js.map |
@@ -29,7 +29,10 @@ import { SCWKeyManager } from './SCWKeyManager.js'; | ||
async handshake(args) { | ||
var _a, _b; | ||
var _a, _b, _c, _d; | ||
// Open the popup before constructing the request message. | ||
// This is to ensure that the popup is not blocked by some browsers (i.e. Safari) | ||
await ((_b = (_a = this.communicator).waitForPopupLoaded) === null || _b === void 0 ? void 0 : _b.call(_a)); | ||
const handshakeMessage = await this.createRequestMessage({ | ||
handshake: { | ||
method: args.method, | ||
params: Object.assign({}, this.metadata, (_a = args.params) !== null && _a !== void 0 ? _a : {}), | ||
params: Object.assign({}, this.metadata, (_c = args.params) !== null && _c !== void 0 ? _c : {}), | ||
}, | ||
@@ -47,6 +50,11 @@ }); | ||
throw result.error; | ||
const accounts = result.value; | ||
this.accounts = accounts; | ||
this.storage.storeObject(ACCOUNTS_KEY, accounts); | ||
(_b = this.callback) === null || _b === void 0 ? void 0 : _b.call(this, 'accountsChanged', accounts); | ||
switch (args.method) { | ||
case 'eth_requestAccounts': { | ||
const accounts = result.value; | ||
this.accounts = accounts; | ||
this.storage.storeObject(ACCOUNTS_KEY, accounts); | ||
(_d = this.callback) === null || _d === void 0 ? void 0 : _d.call(this, 'accountsChanged', accounts); | ||
break; | ||
} | ||
} | ||
} | ||
@@ -56,3 +64,8 @@ async request(request) { | ||
if (this.accounts.length === 0) { | ||
throw standardErrors.provider.unauthorized(); | ||
switch (request.method) { | ||
case 'wallet_sendCalls': | ||
return this.sendRequestToPopup(request); | ||
default: | ||
throw standardErrors.provider.unauthorized(); | ||
} | ||
} | ||
@@ -77,2 +90,3 @@ switch (request.method) { | ||
case 'personal_sign': | ||
case 'wallet_sign': | ||
case 'personal_ecRecover': | ||
@@ -79,0 +93,0 @@ case 'eth_signTransaction': |
@@ -11,3 +11,4 @@ import { NAME, VERSION } from '../sdk-info.js'; | ||
appendAppInfoQueryParams(url); | ||
const popup = window.open(url, 'Smart Wallet', `width=${POPUP_WIDTH}, height=${POPUP_HEIGHT}, left=${left}, top=${top}`); | ||
const popupId = `wallet_${crypto.randomUUID()}`; | ||
const popup = window.open(url, popupId, `width=${POPUP_WIDTH}, height=${POPUP_HEIGHT}, left=${left}, top=${top}`); | ||
popup === null || popup === void 0 ? void 0 : popup.focus(); | ||
@@ -14,0 +15,0 @@ if (!popup) { |
{ | ||
"name": "@coinbase/wallet-sdk", | ||
"version": "4.2.4", | ||
"version": "4.3.0", | ||
"description": "Coinbase Wallet JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
384410
5352