Socket
Socket
Sign inDemoInstall

@0xsequence/provider

Package Overview
Dependencies
Maintainers
6
Versions
482
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-20240703210534 to 0.0.0-20240704152116

10

dist/declarations/src/client.d.ts

@@ -1,2 +0,2 @@

import { NetworkConfig } from '@0xsequence/network';
import { JsonRpcRequest, NetworkConfig } from '@0xsequence/network';
import { ConnectDetails, ConnectOptions, ItemStore, MuxTransportTemplate, OpenWalletIntent, OptionalChainId, OptionalEIP6492, ProviderTransport, WalletEventTypes, WalletSession } from "./index.js";

@@ -78,7 +78,3 @@ import { commons } from '@0xsequence/core';

disconnect(): Promise<void>;
request(request: {
method: string;
params?: any[];
chainId?: number;
}): Promise<any>;
send(request: JsonRpcRequest, chainId?: number): Promise<any>;
getNetworks(pull?: boolean): Promise<NetworkConfig[]>;

@@ -90,5 +86,5 @@ private signMethod;

signTypedData(typedData: TypedData, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
sendTransaction(tx: ethers.TransactionRequest[] | ethers.TransactionRequest, options?: OptionalChainId): Promise<string>;
sendTransaction(tx: ethers.providers.TransactionRequest[] | ethers.providers.TransactionRequest, options?: OptionalChainId): Promise<string>;
getWalletContext(): Promise<commons.context.VersionedContext>;
getOnchainWalletConfig(options?: OptionalChainId): Promise<commons.config.Config>;
}
import { ethers } from 'ethers';
import { SequenceClient } from "./client.js";
import { EIP1193Provider, ChainIdLike, NetworkConfig } from '@0xsequence/network';
import { ConnectDetails, ConnectOptions, OpenWalletIntent, OptionalChainIdLike, WalletSession } from "./types.js";
import { ChainIdLike, NetworkConfig } from '@0xsequence/network';
import { ConnectDetails, ConnectOptions, EIP1193Provider, OpenWalletIntent, OptionalChainIdLike, WalletSession } from "./types.js";
import { commons } from '@0xsequence/core';

@@ -32,9 +32,6 @@ import { WalletUtils } from "./utils/index.js";

}
declare const EIP1193EventTypes: readonly ["connect", "disconnect", "chainChanged", "accountsChanged"];
type EIP1193EventType = (typeof EIP1193EventTypes)[number];
export declare class SequenceProvider extends ethers.AbstractProvider implements ISequenceProvider, EIP1193Provider {
export declare class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider, EIP1193Provider {
readonly client: SequenceClient;
private readonly providerFor;
readonly networks: NetworkConfig[];
options?: ethers.AbstractProviderOptions | undefined;
private readonly singleNetworkProviders;

@@ -44,6 +41,3 @@ readonly _isSequenceProvider = true;

readonly signer: SequenceSigner;
readonly eip1193EventListeners: Map<"connect" | "disconnect" | "accountsChanged" | "chainChanged", Set<ethers.Listener>>;
constructor(client: SequenceClient, providerFor: (networkId: number) => ethers.JsonRpcProvider, networks?: NetworkConfig[], options?: ethers.AbstractProviderOptions | undefined);
on(event: ethers.ProviderEvent | EIP1193EventType, listener: ethers.Listener): Promise<this>;
off(event: ethers.ProviderEvent | EIP1193EventType, listener?: ethers.Listener | undefined): Promise<this>;
constructor(client: SequenceClient, providerFor: (networkId: number) => ethers.providers.JsonRpcProvider, networks?: NetworkConfig[]);
getSigner(): SequenceSigner;

@@ -87,4 +81,3 @@ getSigner(chainId: ChainIdLike): SingleNetworkSequenceSigner;

*/
_getSubprovider(chainId?: ChainIdLike): Promise<ethers.JsonRpcProvider>;
_perform(req: ethers.PerformActionRequest): Promise<any>;
_getSubprovider(chainId?: ChainIdLike): Promise<ethers.providers.JsonRpcProvider>;
perform(method: string, params: any): Promise<any>;

@@ -96,20 +89,19 @@ send(method: string, params: any): Promise<any>;

}): Promise<any>;
_detectNetwork(): Promise<ethers.Network>;
detectNetwork(): Promise<ethers.Network>;
waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number, optionals?: OptionalChainIdLike): Promise<ethers.TransactionReceipt | null>;
detectNetwork(): Promise<ethers.providers.Network>;
waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number, optionals?: OptionalChainIdLike): Promise<ethers.providers.TransactionReceipt>;
getBlockNumber(optionals?: OptionalChainIdLike): Promise<number>;
getFeeData(optionals?: OptionalChainIdLike): Promise<ethers.FeeData>;
getBalance(addressOrName: string | Promise<string>, blockTag?: ethers.BlockTag, optionals?: OptionalChainIdLike): Promise<bigint>;
getTransactionCount(addressOrName: string | Promise<string>, blockTag?: ethers.BlockTag, optionals?: OptionalChainIdLike): Promise<number>;
getCode(addressOrName: string | Promise<string>, blockTag?: ethers.BlockTag, optionals?: OptionalChainIdLike): Promise<string>;
getStorage(addressOrName: string | Promise<string>, position: ethers.BigNumberish, blockTag?: ethers.BlockTag, optionals?: OptionalChainIdLike): Promise<string>;
call(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike): Promise<string>;
estimateGas(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike): Promise<bigint>;
getBlock(blockHashOrBlockTag: ethers.BlockTag | string, prefetchTxs?: boolean, optionals?: OptionalChainIdLike): Promise<ethers.Block | null>;
getTransaction(transactionHash: string, optionals?: OptionalChainIdLike): Promise<ethers.TransactionResponse | null>;
getLogs(filter: ethers.Filter, optionals?: OptionalChainIdLike): Promise<ethers.Log[]>;
getGasPrice(optionals?: OptionalChainIdLike): Promise<ethers.BigNumber>;
getBalance(addressOrName: string | Promise<string>, blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>, optionals?: OptionalChainIdLike): Promise<ethers.BigNumber>;
getTransactionCount(addressOrName: string | Promise<string>, blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>, optionals?: OptionalChainIdLike): Promise<number>;
getCode(addressOrName: string | Promise<string>, blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>, optionals?: OptionalChainIdLike): Promise<string>;
getStorageAt(addressOrName: string | Promise<string>, position: ethers.BigNumberish | Promise<ethers.BigNumberish>, blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>, optionals?: OptionalChainIdLike): Promise<string>;
call(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>, blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>, optionals?: OptionalChainIdLike): Promise<string>;
estimateGas(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>, optionals?: OptionalChainIdLike): Promise<ethers.BigNumber>;
getBlock(blockHashOrBlockTag: ethers.providers.BlockTag | string | Promise<ethers.providers.BlockTag | string>, optionals?: OptionalChainIdLike): Promise<ethers.providers.Block>;
getTransaction(transactionHash: string | Promise<string>, optionals?: OptionalChainIdLike): Promise<ethers.providers.TransactionResponse>;
getLogs(filter: ethers.providers.Filter | Promise<ethers.providers.Filter>, optionals?: OptionalChainIdLike): Promise<ethers.providers.Log[]>;
supportsENS(): Promise<boolean>;
getResolver(name: string): Promise<ethers.EnsResolver | null>;
resolveName(name: string): Promise<string | null>;
lookupAddress(address: string): Promise<string | null>;
getResolver(name: string): Promise<ethers.providers.Resolver | null>;
resolveName(name: string | Promise<string>): Promise<string | null>;
lookupAddress(address: string | Promise<string>): Promise<string | null>;
getAvatar(nameOrAddress: string): Promise<string | null>;

@@ -130,7 +122,7 @@ static is: (provider: any) => provider is SequenceProvider;

readonly _isSingleNetworkSequenceProvider = true;
constructor(client: SequenceClient, providerFor: (networkId: number) => ethers.JsonRpcProvider, chainId: ChainIdLike, options?: ethers.AbstractProviderOptions);
constructor(client: SequenceClient, providerFor: (networkId: number) => ethers.providers.JsonRpcProvider, chainId: ChainIdLike);
private _useChainId;
protected useChainId(chainId?: ChainIdLike): Promise<number>;
getChainId(): number;
getNetwork(): Promise<ethers.Network>;
getNetwork(): Promise<NetworkConfig>;
/**

@@ -146,2 +138,1 @@ * Override getProvider and getSigner so they always use `useChainId`

}
export {};

@@ -8,3 +8,3 @@ import { ethers } from 'ethers';

import { OptionalChainIdLike, OptionalEIP6492 } from "./types.js";
export interface ISequenceSigner extends Omit<ethers.Signer, 'connect'> {
export interface ISequenceSigner extends ethers.Signer {
getProvider(): SequenceProvider;

@@ -18,6 +18,5 @@ getProvider(chainId: ChainIdLike): SingleNetworkSequenceProvider;

getNetworks(): Promise<NetworkConfig[]>;
connect: (provider: SequenceProvider) => SequenceSigner;
signMessage(message: ethers.BytesLike, options?: OptionalChainIdLike & OptionalEIP6492): Promise<string>;
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, Array<ethers.TypedDataField>>, message: Record<string, any>, options?: OptionalChainIdLike & OptionalEIP6492): Promise<string>;
sendTransaction(transaction: ethers.TransactionRequest[] | ethers.TransactionRequest, options?: OptionalChainIdLike): Promise<commons.transaction.TransactionResponse>;
sendTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>[] | ethers.utils.Deferrable<ethers.providers.TransactionRequest>, options?: OptionalChainIdLike): Promise<commons.transaction.TransactionResponse>;
utils: WalletUtils;

@@ -29,2 +28,3 @@ }

private readonly singleNetworkSigners;
readonly _isSigner: boolean;
readonly _isSequenceSigner: boolean;

@@ -34,3 +34,3 @@ get utils(): WalletUtils;

getAddress(): Promise<string>;
connect(provider: ethers.Provider): SequenceSigner;
connect(provider: ethers.providers.Provider): SequenceSigner;
getSigner(): SequenceSigner;

@@ -50,18 +50,17 @@ getSigner(chainId: ChainIdLike): SingleNetworkSequenceSigner;

getProvider(chainId?: ChainIdLike): SingleNetworkSequenceProvider | SequenceProvider;
sendTransaction(transaction: ethers.TransactionRequest[] | ethers.TransactionRequest, options?: OptionalChainIdLike): Promise<ethers.TransactionResponse>;
sendTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>[] | ethers.utils.Deferrable<ethers.providers.TransactionRequest>, options?: OptionalChainIdLike): Promise<ethers.providers.TransactionResponse>;
getWalletConfig(chainId?: ChainIdLike | undefined): Promise<commons.config.Config>;
getNetworks(): Promise<NetworkConfig[]>;
getBalance(blockTag?: ethers.BlockTag | undefined, optionals?: OptionalChainIdLike): Promise<bigint>;
estimateGas(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike): Promise<bigint>;
call(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike): Promise<string>;
getBalance(blockTag?: ethers.providers.BlockTag | undefined, optionals?: OptionalChainIdLike): Promise<ethers.BigNumber>;
estimateGas(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>, optionals?: OptionalChainIdLike): Promise<ethers.BigNumber>;
call(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>, blockTag?: ethers.providers.BlockTag | undefined, optionals?: OptionalChainIdLike): Promise<string>;
getChainId(): Promise<number>;
getFeeData(optionals?: OptionalChainIdLike): Promise<ethers.FeeData>;
getGasPrice(optionals?: OptionalChainIdLike): Promise<ethers.BigNumber>;
getFeeData(optionals?: OptionalChainIdLike): Promise<ethers.providers.FeeData>;
resolveName(name: string): Promise<string>;
_checkProvider(_operation?: string | undefined): void;
getNonce(_blockTag?: ethers.BlockTag): Promise<number>;
populateCall(_transaction: ethers.TransactionRequest): Promise<ethers.TransactionLike<string>>;
populateTransaction(_transaction: ethers.TransactionRequest): Promise<ethers.TransactionLike<string>>;
checkTransaction(_transaction: ethers.TransactionRequest): ethers.TransactionRequest;
getTransactionCount(_blockTag?: ethers.BlockTag | undefined): Promise<number>;
signTransaction(_transaction: commons.transaction.Transactionish): Promise<string>;
populateTransaction(_transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<ethers.providers.TransactionRequest>;
checkTransaction(_transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
getTransactionCount(_blockTag?: ethers.providers.BlockTag | undefined): Promise<number>;
signTransaction(_transaction: ethers.utils.Deferrable<commons.transaction.Transactionish>): Promise<string>;
static is(cand: any): cand is SequenceSigner;

@@ -68,0 +67,0 @@ }

import { ProviderTransport, ProviderMessage, ProviderMessageRequest, ProviderEventTypes, ProviderMessageResponse, ProviderMessageResponseCallback, OpenState, OpenWalletIntent, ConnectDetails, WalletSession, ProviderRpcError, InitState, TypedEventEmitter } from "../types.js";
import { NetworkConfig } from '@0xsequence/network';
import { NetworkConfig, JsonRpcRequest, JsonRpcResponseCallback } from '@0xsequence/network';
import { commons } from '@0xsequence/core';

@@ -34,7 +34,3 @@ export declare const PROVIDER_OPEN_TIMEOUT = 30000;

isConnected(): boolean;
request(request: {
method: string;
params?: any[];
chainId?: number;
}): Promise<any>;
sendAsync: (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => Promise<void>;
handleMessage(message: ProviderMessage<any>): void;

@@ -41,0 +37,0 @@ sendMessageRequest: (message: ProviderMessageRequest) => Promise<ProviderMessageResponse>;

import { WalletTransport, ProviderMessage, ProviderMessageRequest, ProviderMessageResponse, ProviderRpcError, InitState, ConnectDetails, WalletSession, TransportSession } from "../types.js";
import { WalletRequestHandler } from "./wallet-request-handler.js";
import { NetworkConfig } from '@0xsequence/network';
import { NetworkConfig, JsonRpcRequest, JsonRpcResponseCallback } from '@0xsequence/network';
import { commons } from '@0xsequence/core';

@@ -17,7 +17,3 @@ export declare abstract class BaseWalletTransport implements WalletTransport {

unregister(): void;
request(request: {
method: string;
params?: any[];
chainId?: number;
}): Promise<any>;
sendAsync: (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => Promise<never>;
handleMessage: (message: ProviderMessage<any>) => Promise<void>;

@@ -24,0 +20,0 @@ sendMessageRequest: (message: ProviderMessageRequest) => Promise<ProviderMessageResponse>;

import { ProviderMessage, ProviderTransport, ProviderEventTypes, ProviderMessageRequest, ProviderMessageResponse, WalletSession, OpenWalletIntent, ConnectDetails } from "../../types.js";
import { JsonRpcRequest, JsonRpcResponseCallback } from '@0xsequence/network';
import { ProxyMessageChannelPort } from "../proxy-transport/index.js";

@@ -37,7 +38,3 @@ import { Runtime } from 'webextension-polyfill';

emit<K extends keyof ProviderEventTypes>(event: K, ...args: Parameters<ProviderEventTypes[K]>): boolean;
request(request: {
method: string;
params?: any[];
chainId?: number;
}): Promise<any>;
sendAsync: (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => Promise<void>;
sendMessage(message: ProviderMessage<any>): void;

@@ -44,0 +41,0 @@ sendMessageRequest: (message: ProviderMessageRequest) => Promise<ProviderMessageResponse>;

import { Account } from '@0xsequence/account';
import { commons } from '@0xsequence/core';
import { ChainIdLike, NetworkConfig, EIP1193Provider } from '@0xsequence/network';
import { ChainIdLike, JsonRpcHandler, JsonRpcRequest, JsonRpcResponseCallback, NetworkConfig } from '@0xsequence/network';
import { providers } from 'ethers';
import { ConnectDetails, ConnectOptions, MessageToSign, NetworkedConnectOptions, OpenWalletIntent, PromptConnectDetails, ProviderEventTypes, ProviderMessageRequest, ProviderMessageRequestHandler, ProviderMessageResponse, ProviderRpcError, WalletSession } from "../types.js";
type ExternalProvider = providers.ExternalProvider;
export interface WalletSignInOptions {

@@ -9,3 +11,3 @@ connect?: boolean;

}
export declare class WalletRequestHandler implements EIP1193Provider, ProviderMessageRequestHandler {
export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, ProviderMessageRequestHandler {
private account;

@@ -28,7 +30,3 @@ private signerReadyCallbacks;

sendMessageRequest(message: ProviderMessageRequest): Promise<ProviderMessageResponse>;
request(request: {
method: string;
params?: any[];
chainId?: number;
}): Promise<any>;
sendAsync: (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => Promise<void>;
on<K extends keyof ProviderEventTypes>(event: K, fn: ProviderEventTypes[K]): void;

@@ -65,1 +63,2 @@ once<K extends keyof ProviderEventTypes>(event: K, fn: ProviderEventTypes[K]): void;

}
export {};
import { ETHAuthProof as AuthETHAuthProof } from '@0xsequence/auth';
import { commons } from '@0xsequence/core';
import { ChainIdLike, EIP1193Provider, JsonRpcRequest, JsonRpcResponse, NetworkConfig, JsonRpcErrorPayload as _JsonRpcErrorPayload } from '@0xsequence/network';
import { ChainIdLike, JsonRpcHandler, JsonRpcRequest, JsonRpcResponse, NetworkConfig, ProviderRpcError as NetworkProviderRpcError } from '@0xsequence/network';
import { TypedData } from '@0xsequence/utils';
export interface ProviderTransport extends EIP1193Provider, ProviderMessageTransport, ProviderMessageRequestHandler {
export interface ProviderTransport extends JsonRpcHandler, ProviderMessageTransport, ProviderMessageRequestHandler {
register(): void;

@@ -19,3 +19,3 @@ unregister(): void;

export declare function isProviderTransport(transport: any): transport is ProviderTransport;
export interface WalletTransport extends EIP1193Provider, ProviderMessageTransport, ProviderMessageRequestHandler {
export interface WalletTransport extends JsonRpcHandler, ProviderMessageTransport, ProviderMessageRequestHandler {
register(): void;

@@ -41,8 +41,7 @@ unregister(): void;

origin?: string;
clientVersion: string;
}
export type ProviderMessageRequest = ProviderMessage<JsonRpcRequest>;
export type ProviderMessageResponse = ProviderMessage<JsonRpcResponse | any>;
export type ProviderMessageResponse = ProviderMessage<JsonRpcResponse>;
export type ProviderMessageResponseCallback = (error?: ProviderRpcError, response?: ProviderMessageResponse) => void;
export type ProviderRpcError = _JsonRpcErrorPayload;
export type ProviderRpcError = NetworkProviderRpcError;
export interface ProviderMessageRequestHandler {

@@ -263,2 +262,8 @@ sendMessageRequest(message: ProviderMessageRequest): Promise<ProviderMessageResponse>;

} | undefined;
export interface EIP1193Provider {
request: (request: {
method: string;
params?: Array<any>;
}) => Promise<any>;
}
export {};

@@ -1,10 +0,10 @@

import { ethers } from 'ethers';
import { ethers, BytesLike } from 'ethers';
import { AccountStatus } from '@0xsequence/account';
import { TypedData } from '@0xsequence/utils';
export declare const messageToBytes: (message: ethers.BytesLike) => Uint8Array;
export declare const prefixEIP191Message: (message: ethers.BytesLike) => Uint8Array;
export declare const messageToBytes: (message: BytesLike) => Uint8Array;
export declare const prefixEIP191Message: (message: BytesLike) => Uint8Array;
export declare const trimEIP191Prefix: (prefixedMessage: Uint8Array) => Uint8Array;
export declare const isValidSignature: (address: string, digest: Uint8Array, sig: string, provider: ethers.Provider) => Promise<boolean>;
export declare const isValidMessageSignature: (address: string, message: string | Uint8Array, signature: string, provider: ethers.Provider) => Promise<boolean>;
export declare const isValidTypedDataSignature: (address: string, typedData: TypedData, signature: string, provider: ethers.Provider) => Promise<boolean>;
export declare const isValidSignature: (address: string, digest: Uint8Array, sig: string, provider: ethers.providers.Provider) => Promise<boolean>;
export declare const isValidMessageSignature: (address: string, message: string | Uint8Array, signature: string, provider: ethers.providers.Provider) => Promise<boolean>;
export declare const isValidTypedDataSignature: (address: string, typedData: TypedData, signature: string, provider: ethers.providers.Provider) => Promise<boolean>;
export declare const isBrowserExtension: () => boolean;

@@ -37,2 +37,2 @@ export declare const isUnityPlugin: () => boolean;

export declare function useBestStore(): ItemStore;
export declare function resolveArrayProperties<T>(object: Readonly<T> | Readonly<T>[]): Promise<T>;
export declare function resolveArrayProperties<T>(object: Readonly<ethers.utils.Deferrable<T>> | Readonly<ethers.utils.Deferrable<T>>[]): Promise<T>;

@@ -1,2 +0,2 @@

import { ethers } from 'ethers';
import { BytesLike, TypedDataDomain, TypedDataField } from 'ethers';
import { ChainIdLike } from '@0xsequence/network';

@@ -13,4 +13,4 @@ import { TypedData } from '@0xsequence/utils';

constructor(signer: SequenceSigner);
signMessage(message: ethers.BytesLike, chainId?: ChainIdLike, eip6492?: boolean): Promise<string>;
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, Array<ethers.TypedDataField>>, message: Record<string, any>, chainId?: ChainIdLike, eip6492?: boolean): Promise<string>;
signMessage(message: BytesLike, chainId?: ChainIdLike, eip6492?: boolean): Promise<string>;
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, message: Record<string, any>, chainId?: ChainIdLike, eip6492?: boolean): Promise<string>;
isValidSignature(address: string, digest: Uint8Array, signature: string, chainId: number): Promise<boolean>;

@@ -17,0 +17,0 @@ isValidMessageSignature(address: string, message: string | Uint8Array, signature: string, chainId: number): Promise<boolean>;

{
"name": "@0xsequence/provider",
"version": "0.0.0-20240703210534",
"version": "0.0.0-20240704152116",
"description": "provider sub-package for Sequence",

@@ -15,18 +15,18 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",

"webextension-polyfill": "^0.10.0",
"@0xsequence/abi": "0.0.0-20240703210534",
"@0xsequence/account": "0.0.0-20240703210534",
"@0xsequence/auth": "0.0.0-20240703210534",
"@0xsequence/core": "0.0.0-20240703210534",
"@0xsequence/migration": "0.0.0-20240703210534",
"@0xsequence/network": "0.0.0-20240703210534",
"@0xsequence/relayer": "0.0.0-20240703210534",
"@0xsequence/utils": "0.0.0-20240703210534",
"@0xsequence/wallet": "0.0.0-20240703210534"
"@0xsequence/abi": "0.0.0-20240704152116",
"@0xsequence/account": "0.0.0-20240704152116",
"@0xsequence/auth": "0.0.0-20240704152116",
"@0xsequence/core": "0.0.0-20240704152116",
"@0xsequence/migration": "0.0.0-20240704152116",
"@0xsequence/relayer": "0.0.0-20240704152116",
"@0xsequence/network": "0.0.0-20240704152116",
"@0xsequence/utils": "0.0.0-20240704152116",
"@0xsequence/wallet": "0.0.0-20240704152116"
},
"peerDependencies": {
"ethers": ">=6"
"ethers": ">=5.5 < 6"
},
"devDependencies": {
"@types/webextension-polyfill": "^0.10.0",
"ethers": "^6.13.0",
"ethers": "^5.7.2",
"hardhat": "^2.20.1"

@@ -33,0 +33,0 @@ },

@@ -1,2 +0,2 @@

import { NetworkConfig } from '@0xsequence/network'
import { JsonRpcRequest, JsonRpcResponse, NetworkConfig } from '@0xsequence/network'
import {

@@ -18,3 +18,3 @@ ConnectDetails,

} from '.'
import { commons, VERSION } from '@0xsequence/core'
import { commons } from '@0xsequence/core'
import { TypedData } from '@0xsequence/utils'

@@ -25,2 +25,4 @@ import { toExtended } from './extended'

import packageJson from '../package.json'
/**

@@ -169,3 +171,3 @@ * This session class is meant to persist the state of the wallet connection

this.transport.on('connect', (response: ConnectDetails) => {
const chainIdHex = ethers.toQuantity(this.getChainId())
const chainIdHex = ethers.utils.hexValue(this.getChainId())
this.callbacks.connect?.forEach(cb =>

@@ -208,3 +210,3 @@ cb({

this.defaultChainId.onDefaultChainIdChanged((chainId: number) => {
const chainIdHex = ethers.toQuantity(chainId)
const chainIdHex = ethers.utils.hexValue(chainId)
this.callbacks.chainChanged?.forEach(cb => cb(chainIdHex))

@@ -342,3 +344,3 @@ })

type: 'connect',
options: { ...options, networkId: this.getChainId(), clientVersion: VERSION }
options: { ...options, networkId: this.getChainId(), clientVersion: packageJson.version }
})

@@ -357,3 +359,3 @@

if (connectDetails.chainId) {
connectDetails.chainId = BigInt(connectDetails.chainId).toString()
connectDetails.chainId = ethers.BigNumber.from(connectDetails.chainId).toString()
}

@@ -388,3 +390,5 @@

async request(request: { method: string; params?: any[]; chainId?: number }): Promise<any> {
// Working with sendAsync is less idiomatic
// but transport uses it instead of send, so we wrap it
send(request: JsonRpcRequest, chainId?: number): Promise<any> {
// Internally when sending requests we use `legacy_sign`

@@ -395,3 +399,21 @@ // to avoid the default EIP6492 behavior overriding an explicit

return this.transport.request(request)
return new Promise((resolve, reject) => {
this.transport.sendAsync(
request,
(error, response) => {
if (error) {
reject(error)
} else if (response === undefined) {
reject(new Error(`Got undefined response for request: ${request}`))
} else if (typeof response === 'object' && response.error) {
reject(response.error)
} else if (typeof response === 'object' && response.result) {
resolve(response.result)
} else {
reject(new Error(`Got invalid response for request: ${request}`))
}
},
chainId || this.getChainId()
)
})
}

@@ -403,3 +425,3 @@

if (pull) {
connectedSession.networks = await this.request({ method: 'sequence_getNetworks' })
connectedSession.networks = await this.send({ method: 'sequence_getNetworks' })
this.session.setSession(connectedSession)

@@ -464,12 +486,7 @@ }

// If the message is a string, even if it looks like a BytesLike string we need to represent it as utf8 bytes.
// ie. '0x1234' is a string, '0x1234' is a bytesLike string which is 2 bytes but we must sign the full '0x1234' as 6 utf8 bytes
message = ethers.hexlify(typeof message === 'string' ? ethers.toUtf8Bytes(message) : message)
// Serialize a BytesLike or string message into a hex string before sending
message = ethers.utils.hexlify(messageToBytes(message))
// Address is ignored by the wallet webapp
return this.request({
method,
params: [message, this.getAddress()],
chainId: options?.chainId
})
return this.send({ method, params: [message, this.getAddress()] }, options?.chainId)
}

@@ -482,3 +499,3 @@

// and it makes the client depend on ethers.
const encoded = ethers.TypedDataEncoder.getPayload(typedData.domain, typedData.types, typedData.message)
const encoded = ethers.utils._TypedDataEncoder.getPayload(typedData.domain, typedData.types, typedData.message)

@@ -492,10 +509,14 @@ // The sign typed data will use one of the following chainIds, in order:

return this.request({
method,
params: [this.getAddress(), encoded],
chainId: options?.chainId || (typedData.domain.chainId && Number(BigInt(typedData.domain.chainId))) || this.getChainId()
})
return this.send(
{ method, params: [this.getAddress(), encoded] },
options?.chainId ||
(typedData.domain.chainId && ethers.BigNumber.from(typedData.domain.chainId).toNumber()) ||
this.getChainId()
)
}
async sendTransaction(tx: ethers.TransactionRequest[] | ethers.TransactionRequest, options?: OptionalChainId): Promise<string> {
async sendTransaction(
tx: ethers.providers.TransactionRequest[] | ethers.providers.TransactionRequest,
options?: OptionalChainId
): Promise<string> {
const sequenceTxs = Array.isArray(tx) ? tx : [tx]

@@ -506,7 +527,7 @@ const extendedTxs = toExtended(sequenceTxs)

return this.request({ method: 'eth_sendTransaction', params: [extendedTxs], chainId: options?.chainId })
return this.send({ method: 'eth_sendTransaction', params: [extendedTxs] }, options?.chainId)
}
async getWalletContext(): Promise<commons.context.VersionedContext> {
return this.request({ method: 'sequence_getWalletContext' })
return this.send({ method: 'sequence_getWalletContext' })
}

@@ -516,7 +537,6 @@

// NOTICE: sequence_getWalletConfig sends the chainId as a param
const res = await this.request({
method: 'sequence_getWalletConfig',
params: [options?.chainId || this.getChainId()],
chainId: options?.chainId
})
const res = await this.send(
{ method: 'sequence_getWalletConfig', params: [options?.chainId || this.getChainId()] },
options?.chainId
)
return Array.isArray(res) ? res[0] : res

@@ -523,0 +543,0 @@ }

@@ -26,3 +26,3 @@ import { ethers } from 'ethers'

try {
const stringified = ethers.toUtf8String(bytes)
const stringified = ethers.utils.toUtf8String(bytes)
return DCL_REGEX.test(stringified)

@@ -37,3 +37,3 @@ } catch {

export function isZeroExV3Order(bytes: Uint8Array): boolean {
const abi = new ethers.Interface(ZeroXV3EIP1271OrderWithHashAbi)
const abi = new ethers.utils.Interface(ZeroXV3EIP1271OrderWithHashAbi)
try {

@@ -40,0 +40,0 @@ abi.decodeFunctionData('OrderWithHash', bytes)

import { ethers } from 'ethers'
export type ExtendedTransactionRequest = ethers.TransactionRequest & {
auxiliary?: ethers.TransactionRequest[]
export type ExtendedTransactionRequest = ethers.providers.TransactionRequest & {
auxiliary?: ethers.providers.TransactionRequest[]
}
export function toExtended(transactions: ethers.TransactionRequest[]): ExtendedTransactionRequest {
export function toExtended(transactions: ethers.providers.TransactionRequest[]): ExtendedTransactionRequest {
if (transactions.length === 0) {

@@ -20,8 +20,8 @@ throw new Error('No transaction provided')

export function fromExtended(transaction: ExtendedTransactionRequest): ethers.TransactionRequest[] {
export function fromExtended(transaction: ExtendedTransactionRequest): ethers.providers.TransactionRequest[] {
return [transaction, ...(transaction.auxiliary || [])]
}
export function isExtended(transaction: ethers.TransactionRequest): transaction is ExtendedTransactionRequest {
export function isExtended(transaction: ethers.providers.TransactionRequest): transaction is ExtendedTransactionRequest {
return (transaction as any).auxiliary !== undefined
}
import {
CachedProvider,
ChainIdLike,
JsonRpcRouter,
JsonRpcSender,
NetworkConfig,

@@ -8,4 +10,3 @@ allNetworks,

findNetworkConfig,
loggingProviderMiddleware,
JsonRpcProvider
loggingProviderMiddleware
} from '@0xsequence/network'

@@ -88,3 +89,3 @@ import { MuxTransportTemplate } from './transports'

const rpcProviders: Record<number, ethers.JsonRpcProvider> = {}
const rpcProviders: Record<number, ethers.providers.JsonRpcProvider> = {}

@@ -124,9 +125,9 @@ // Find any new networks that aren't already defined in sequence.js

rpcProviders[chainId] = new JsonRpcProvider(
rpcUrl,
{
middlewares: [loggingProviderMiddleware, exceptionProviderMiddleware, new CachedProvider()]
},
{ cacheTimeout: -1 }
const baseProvider = new ethers.providers.JsonRpcProvider(rpcUrl)
const router = new JsonRpcRouter(
[loggingProviderMiddleware, exceptionProviderMiddleware, new CachedProvider()],
new JsonRpcSender(baseProvider)
)
rpcProviders[chainId] = new ethers.providers.Web3Provider(router, chainId)
}

@@ -133,0 +134,0 @@

import { ethers } from 'ethers'
import { SequenceClient } from './client'
import { EIP1193Provider, ChainIdLike, NetworkConfig, allNetworks, findNetworkConfig } from '@0xsequence/network'
import { ConnectDetails, ConnectOptions, OpenWalletIntent, OptionalChainIdLike, WalletSession } from './types'
import { ChainIdLike, NetworkConfig, allNetworks, findNetworkConfig } from '@0xsequence/network'
import { ConnectDetails, ConnectOptions, EIP1193Provider, OpenWalletIntent, OptionalChainIdLike, WalletSession } from './types'
import { commons } from '@0xsequence/core'

@@ -49,6 +49,3 @@ import { WalletUtils } from './utils/index'

const EIP1193EventTypes = ['connect', 'disconnect', 'chainChanged', 'accountsChanged'] as const
type EIP1193EventType = (typeof EIP1193EventTypes)[number]
export class SequenceProvider extends ethers.AbstractProvider implements ISequenceProvider, EIP1193Provider {
export class SequenceProvider extends ethers.providers.BaseProvider implements ISequenceProvider, EIP1193Provider {
private readonly singleNetworkProviders: { [chainId: number]: SingleNetworkSequenceProvider } = {}

@@ -61,33 +58,26 @@

readonly eip1193EventListeners = new Map<EIP1193EventType, Set<ethers.Listener>>()
constructor(
public readonly client: SequenceClient,
private readonly providerFor: (networkId: number) => ethers.JsonRpcProvider,
public readonly networks: NetworkConfig[] = allNetworks,
public options?: ethers.AbstractProviderOptions
private readonly providerFor: (networkId: number) => ethers.providers.JsonRpcProvider,
public readonly networks: NetworkConfig[] = allNetworks
) {
// We support a lot of networks
// but we start with the default one
super(client.getChainId(), options)
super(client.getChainId())
// Emit events as defined by EIP-1193
client.onConnect(details => {
//this.emit('connect', details)
this.eip1193EventListeners.get('connect')?.forEach(listener => listener(details))
this.emit('connect', details)
})
client.onDisconnect(error => {
//this.emit('disconnect', error)
this.eip1193EventListeners.get('disconnect')?.forEach(listener => listener(error))
this.emit('disconnect', error)
})
client.onDefaultChainIdChanged(chainId => {
//this.emit('chainChanged', chainId)
this.eip1193EventListeners.get('chainChanged')?.forEach(listener => listener(chainId))
this.emit('chainChanged', chainId)
})
client.onAccountsChanged(accounts => {
//this.emit('accountsChanged', accounts)
this.eip1193EventListeners.get('accountsChanged')?.forEach(listener => listener(accounts))
this.emit('accountsChanged', accounts)
})

@@ -110,32 +100,2 @@

async on(event: ethers.ProviderEvent | EIP1193EventType, listener: ethers.Listener): Promise<this> {
if (EIP1193EventTypes.includes(event as EIP1193EventType)) {
const listeners = this.eip1193EventListeners.get(event as EIP1193EventType) || new Set()
listeners.add(listener)
this.eip1193EventListeners.set(event as EIP1193EventType, listeners)
return this
}
return super.on(event, listener) as Promise<this>
}
async off(event: ethers.ProviderEvent | EIP1193EventType, listener?: ethers.Listener | undefined): Promise<this> {
if (EIP1193EventTypes.includes(event as EIP1193EventType)) {
const listeners = this.eip1193EventListeners.get(event as EIP1193EventType)
if (listeners) {
if (listener) {
listeners.delete(listener)
} else {
listeners.clear()
}
}
return this
}
return super.off(event, listener) as Promise<this>
}
getSigner(): SequenceSigner

@@ -252,3 +212,3 @@ getSigner(chainId: ChainIdLike): SingleNetworkSequenceSigner

if (!chainId) {
return this as SequenceProvider
return this
}

@@ -259,8 +219,3 @@

if (!this.singleNetworkProviders[useChainId]) {
this.singleNetworkProviders[useChainId] = new SingleNetworkSequenceProvider(
this.client,
this.providerFor,
useChainId,
this.options
)
this.singleNetworkProviders[useChainId] = new SingleNetworkSequenceProvider(this.client, this.providerFor, useChainId)
}

@@ -275,3 +230,3 @@

*/
async _getSubprovider(chainId?: ChainIdLike): Promise<ethers.JsonRpcProvider> {
async _getSubprovider(chainId?: ChainIdLike): Promise<ethers.providers.JsonRpcProvider> {
const useChainId = await this.useChainId(chainId)

@@ -290,19 +245,6 @@

async _perform(req: ethers.PerformActionRequest): Promise<any> {
const { method, ...args } = req
const provider = await this._getSubprovider()
const prepared = provider.getRpcRequest(req) ?? { method, args: Object.values(args) }
if (!prepared) {
throw new Error(`Unsupported method ${req.method}`)
}
return provider.send(prepared.method, prepared.args)
}
async perform(method: string, params: any): Promise<any> {
// First we check if the method should be handled by the client
if (method === 'eth_chainId') {
return ethers.toQuantity(await this.useChainId())
return ethers.utils.hexValue(await this.useChainId())
}

@@ -336,6 +278,10 @@

// the client will use its own default chainId
return this.client.request({ method, params, chainId: this.getChainId() })
return this.client.send({ method, params }, this.getChainId())
}
return this._perform({ method, ...params })
// Forward call to the corresponding provider
// we use the provided chainId, or the default one provided by the client
const provider = await this._getSubprovider()
const prepared = provider.prepareRequest(method, params) ?? [method, params]
return provider.send(prepared[0], prepared[1])
}

@@ -351,19 +297,13 @@

async _detectNetwork(): Promise<ethers.Network> {
async detectNetwork(): Promise<ethers.providers.Network> {
const chainId = this.client.getChainId()
const found = findNetworkConfig(this.networks, chainId)
const network = findNetworkConfig(this.networks, chainId)
if (!found) {
if (!network) {
throw new Error(`Unknown network ${chainId}`)
}
const network = new ethers.Network(found.name, found.chainId)
return network
}
async detectNetwork(): Promise<ethers.Network> {
return this._detectNetwork()
}
// Override most of the methods, so we add support for an optional chainId

@@ -386,8 +326,12 @@ // argument, which is used to select the provider to use.

async getFeeData(optionals?: OptionalChainIdLike) {
async getGasPrice(optionals?: OptionalChainIdLike) {
const provider = await this._getSubprovider(optionals?.chainId)
return await provider.getFeeData()
return provider.getGasPrice()
}
async getBalance(addressOrName: string | Promise<string>, blockTag?: ethers.BlockTag, optionals?: OptionalChainIdLike) {
async getBalance(
addressOrName: string | Promise<string>,
blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>,
optionals?: OptionalChainIdLike
) {
const provider = await this._getSubprovider(optionals?.chainId)

@@ -399,3 +343,3 @@ return provider.getBalance(addressOrName, blockTag)

addressOrName: string | Promise<string>,
blockTag?: ethers.BlockTag,
blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>,
optionals?: OptionalChainIdLike

@@ -407,3 +351,7 @@ ) {

async getCode(addressOrName: string | Promise<string>, blockTag?: ethers.BlockTag, optionals?: OptionalChainIdLike) {
async getCode(
addressOrName: string | Promise<string>,
blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>,
optionals?: OptionalChainIdLike
) {
const provider = await this._getSubprovider(optionals?.chainId)

@@ -413,18 +361,22 @@ return provider.getCode(addressOrName, blockTag)

async getStorage(
async getStorageAt(
addressOrName: string | Promise<string>,
position: ethers.BigNumberish,
blockTag?: ethers.BlockTag,
position: ethers.BigNumberish | Promise<ethers.BigNumberish>,
blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>,
optionals?: OptionalChainIdLike
) {
const provider = await this._getSubprovider(optionals?.chainId)
return provider.getStorage(addressOrName, position, blockTag)
return provider.getStorageAt(addressOrName, position, blockTag)
}
async call(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike) {
async call(
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>,
blockTag?: ethers.providers.BlockTag | Promise<ethers.providers.BlockTag>,
optionals?: OptionalChainIdLike
) {
const provider = await this._getSubprovider(optionals?.chainId)
return provider.call(transaction)
return provider.call(transaction, blockTag)
}
async estimateGas(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike) {
async estimateGas(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>, optionals?: OptionalChainIdLike) {
const provider = await this._getSubprovider(optionals?.chainId)

@@ -434,8 +386,11 @@ return provider.estimateGas(transaction)

async getBlock(blockHashOrBlockTag: ethers.BlockTag | string, prefetchTxs?: boolean, optionals?: OptionalChainIdLike) {
async getBlock(
blockHashOrBlockTag: ethers.providers.BlockTag | string | Promise<ethers.providers.BlockTag | string>,
optionals?: OptionalChainIdLike
) {
const provider = await this._getSubprovider(optionals?.chainId)
return provider.getBlock(blockHashOrBlockTag, prefetchTxs)
return provider.getBlock(blockHashOrBlockTag)
}
async getTransaction(transactionHash: string, optionals?: OptionalChainIdLike) {
async getTransaction(transactionHash: string | Promise<string>, optionals?: OptionalChainIdLike) {
const provider = await this._getSubprovider(optionals?.chainId)

@@ -445,3 +400,3 @@ return provider.getTransaction(transactionHash)

async getLogs(filter: ethers.Filter, optionals?: OptionalChainIdLike) {
async getLogs(filter: ethers.providers.Filter | Promise<ethers.providers.Filter>, optionals?: OptionalChainIdLike) {
const provider = await this._getSubprovider(optionals?.chainId)

@@ -468,4 +423,4 @@ return provider.getLogs(filter)

async resolveName(name: string) {
if (ethers.isAddress(await name)) {
async resolveName(name: string | Promise<string>) {
if (ethers.utils.isAddress(await name)) {
return name

@@ -483,3 +438,3 @@ }

async lookupAddress(address: string) {
async lookupAddress(address: string | Promise<string>) {
if (!(await this.supportsENS())) {

@@ -508,5 +463,5 @@ return null

function normalizeChainId(chainId: ethers.BigNumberish | { chainId: string }): number {
function normalizeChainId(chainId: string | number | bigint | { chainId: string }): number {
if (typeof chainId === 'object') return normalizeChainId(chainId.chainId)
return Number(BigInt(chainId))
return ethers.BigNumber.from(chainId).toNumber()
}

@@ -528,7 +483,6 @@

client: SequenceClient,
providerFor: (networkId: number) => ethers.JsonRpcProvider,
public readonly chainId: ChainIdLike,
options?: ethers.AbstractProviderOptions
providerFor: (networkId: number) => ethers.providers.JsonRpcProvider,
public readonly chainId: ChainIdLike
) {
super(client, providerFor, undefined, options)
super(client, providerFor)
}

@@ -554,13 +508,11 @@

async getNetwork(): Promise<ethers.Network> {
async getNetwork(): Promise<NetworkConfig> {
const networks = await this.client.getNetworks()
const found = findNetworkConfig(networks, this.chainId)
const res = findNetworkConfig(networks, this.chainId)
if (!found) {
if (!res) {
throw new Error(`Unsupported network ${this.chainId}`)
}
const network = new ethers.Network(found.name, found.chainId)
return network
return res
}

@@ -567,0 +519,0 @@

@@ -11,3 +11,3 @@ import { ethers } from 'ethers'

export interface ISequenceSigner extends Omit<ethers.Signer, 'connect'> {
export interface ISequenceSigner extends ethers.Signer {
getProvider(): SequenceProvider

@@ -24,4 +24,2 @@ getProvider(chainId: ChainIdLike): SingleNetworkSequenceProvider

connect: (provider: SequenceProvider) => SequenceSigner
signMessage(message: ethers.BytesLike, options?: OptionalChainIdLike & OptionalEIP6492): Promise<string>

@@ -40,3 +38,5 @@

sendTransaction(
transaction: ethers.TransactionRequest[] | ethers.TransactionRequest,
transaction:
| ethers.utils.Deferrable<ethers.providers.TransactionRequest>[]
| ethers.utils.Deferrable<ethers.providers.TransactionRequest>,
options?: OptionalChainIdLike

@@ -51,2 +51,3 @@ ): Promise<commons.transaction.TransactionResponse>

readonly _isSigner: boolean = true
readonly _isSequenceSigner: boolean = true

@@ -69,3 +70,3 @@

// it exists to maintain compatibility with ethers.Signer
connect(provider: ethers.Provider): SequenceSigner {
connect(provider: ethers.providers.Provider): SequenceSigner {
if (!SequenceProvider.is(provider)) {

@@ -131,3 +132,8 @@ throw new Error('SequenceSigner can only be connected to a SequenceProvider')

async sendTransaction(transaction: ethers.TransactionRequest[] | ethers.TransactionRequest, options?: OptionalChainIdLike) {
async sendTransaction(
transaction:
| ethers.utils.Deferrable<ethers.providers.TransactionRequest>[]
| ethers.utils.Deferrable<ethers.providers.TransactionRequest>,
options?: OptionalChainIdLike
) {
const chainId = this.useChainId(options?.chainId)

@@ -139,21 +145,9 @@ const resolved = await resolveArrayProperties(transaction)

try {
const result = await new Promise<ethers.TransactionResponse>(resolve => {
let attempts = 0
const check = async () => {
attempts++
return (await ethers.utils.poll(
async () => {
const tx = await provider.getTransaction(txHash)
if (tx !== null) {
return resolve(tx)
}
await provider.once('block', check)
}
check()
})
return result
return tx ? provider._wrapTransaction(tx, txHash) : undefined
},
{ onceBlock: provider }
)) as ethers.providers.TransactionResponse
} catch (err) {

@@ -174,3 +168,3 @@ err.transactionHash = txHash

async getBalance(blockTag?: ethers.BlockTag | undefined, optionals?: OptionalChainIdLike): Promise<bigint> {
async getBalance(blockTag?: ethers.providers.BlockTag | undefined, optionals?: OptionalChainIdLike): Promise<ethers.BigNumber> {
const provider = this.getProvider(optionals?.chainId)

@@ -180,8 +174,15 @@ return provider.getBalance(this.getAddress(), blockTag)

async estimateGas(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike): Promise<bigint> {
async estimateGas(
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>,
optionals?: OptionalChainIdLike
): Promise<ethers.BigNumber> {
return this.getProvider(optionals?.chainId).estimateGas(transaction)
}
async call(transaction: ethers.TransactionRequest, optionals?: OptionalChainIdLike): Promise<string> {
return this.getProvider(optionals?.chainId).call(transaction)
async call(
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>,
blockTag?: ethers.providers.BlockTag | undefined,
optionals?: OptionalChainIdLike
): Promise<string> {
return this.getProvider(optionals?.chainId).call(transaction, blockTag)
}

@@ -193,3 +194,7 @@

async getFeeData(optionals?: OptionalChainIdLike): Promise<ethers.FeeData> {
async getGasPrice(optionals?: OptionalChainIdLike): Promise<ethers.BigNumber> {
return this.getProvider(optionals?.chainId).getGasPrice()
}
async getFeeData(optionals?: OptionalChainIdLike): Promise<ethers.providers.FeeData> {
return this.getProvider(optionals?.chainId).getFeeData()

@@ -202,3 +207,3 @@ }

// For some reason ethers.Signer expects this to return `string`
// but ethers.Provider expects this to return `string | null`.
// but ethers.providers.Provider expects this to return `string | null`.
// The signer doesn't have any other source of information, so we'll

@@ -217,23 +222,15 @@ // fail if the provider doesn't return a result.

// populateCall(transaction: ethers.PopulatedTransaction): Promise<ethers.PopulatedTransaction> {
// return this.provider.populateCall(transaction)
// }
getNonce(_blockTag?: ethers.BlockTag): Promise<number> {
throw new Error('SequenceSigner does not support getNonce')
}
populateCall(_transaction: ethers.TransactionRequest): Promise<ethers.TransactionLike<string>> {
throw new Error('SequenceSigner does not support populateCall')
}
populateTransaction(_transaction: ethers.TransactionRequest): Promise<ethers.TransactionLike<string>> {
populateTransaction(
_transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>
): Promise<ethers.providers.TransactionRequest> {
throw new Error('SequenceSigner does not support populateTransaction')
}
checkTransaction(_transaction: ethers.TransactionRequest): ethers.TransactionRequest {
checkTransaction(
_transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>
): ethers.utils.Deferrable<ethers.providers.TransactionRequest> {
throw new Error('SequenceSigner does not support checkTransaction')
}
getTransactionCount(_blockTag?: ethers.BlockTag | undefined): Promise<number> {
getTransactionCount(_blockTag?: ethers.providers.BlockTag | undefined): Promise<number> {
// We could try returning the sequence nonce here

@@ -244,3 +241,3 @@ // but we aren't sure how ethers will use this nonce

signTransaction(_transaction: commons.transaction.Transactionish): Promise<string> {
signTransaction(_transaction: ethers.utils.Deferrable<commons.transaction.Transactionish>): Promise<string> {
// We could implement signTransaction/sendTransaction here

@@ -247,0 +244,0 @@ // but first we need a way of serializing these signed transactions

@@ -15,3 +15,3 @@ import { walletContracts } from '@0xsequence/abi'

'updateImplementation(address)'
].map(signature => [ethers.keccak256(ethers.toUtf8Bytes(signature)).slice(0, 10), signature])
].map(signature => [ethers.utils.keccak256(ethers.utils.toUtf8Bytes(signature)).slice(0, 10), signature])
)

@@ -28,3 +28,3 @@

if (transaction.data) {
const data = ethers.getBytes(transaction.data)
const data = ethers.utils.arrayify(transaction.data)
if (data.length >= 4 && !isCreateContractCall(data)) {

@@ -41,3 +41,3 @@ throw new Error('self calls are forbidden')

if (transaction.data) {
const data = ethers.hexlify(transaction.data)
const data = ethers.utils.hexlify(transaction.data)
const selector = data.slice(0, 10)

@@ -53,3 +53,3 @@ const signature = PROHIBITED_FUNCTIONS.get(selector)

function isCreateContractCall(data: ethers.BytesLike): boolean {
const walletInterface = new ethers.Interface(walletContracts.mainModule.abi)
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi)
try {

@@ -56,0 +56,0 @@ walletInterface.decodeFunctionData('createContract', data)

@@ -20,6 +20,6 @@ import { EventEmitter2 as EventEmitter } from 'eventemitter2'

import { NetworkConfig } from '@0xsequence/network'
import { NetworkConfig, JsonRpcRequest, JsonRpcResponseCallback } from '@0xsequence/network'
import { logger } from '@0xsequence/utils'
import { ethers } from 'ethers'
import { VERSION, commons } from '@0xsequence/core'
import { commons } from '@0xsequence/core'

@@ -93,3 +93,5 @@ export const PROVIDER_OPEN_TIMEOUT = 30000 // in ms

async request(request: { method: string; params?: any[]; chainId?: number }): Promise<any> {
sendAsync = async (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => {
// here, we receive the message from the dapp provider call
if (this.state === OpenState.CLOSED) {

@@ -107,17 +109,20 @@ // flag the wallet to auto-close once user submits input. ie.

// TODO: how does this behave with a session has expired?
this.openWallet(undefined, { type: 'jsonRpcRequest', method: request.method }, request.chainId)
this.openWallet(undefined, { type: 'jsonRpcRequest', method: request.method }, chainId)
if (!this.isOpened()) {
await this.waitUntilOpened() // will throw on timeout
// send message request, await, and then execute callback after receiving the response
try {
if (!this.isOpened()) {
await this.waitUntilOpened() // will throw on timeout
}
const response = await this.sendMessageRequest({
idx: nextMessageIdx(),
type: EventType.MESSAGE,
data: request,
chainId: chainId
})
callback(undefined, response.data)
} catch (err) {
callback(err)
}
const response = await this.sendMessageRequest({
idx: nextMessageIdx(),
type: EventType.MESSAGE,
data: request,
chainId: request.chainId,
clientVersion: VERSION
})
return response.data
}

@@ -143,4 +148,3 @@

nonce: nonce
},
clientVersion: VERSION
}
})

@@ -231,3 +235,3 @@ }

this.accountsChangedPayload = {
accounts: [ethers.getAddress(message.data[0])],
accounts: [ethers.utils.getAddress(message.data[0])],
origin: message.origin

@@ -234,0 +238,0 @@ }

@@ -17,3 +17,3 @@ import { ethers } from 'ethers'

import { NetworkConfig, findSupportedNetwork } from '@0xsequence/network'
import { NetworkConfig, JsonRpcRequest, JsonRpcResponseCallback, findSupportedNetwork } from '@0xsequence/network'
import { logger, sanitizeAlphanumeric, sanitizeHost, sanitizeNumberString } from '@0xsequence/utils'

@@ -24,3 +24,3 @@ import { AuthorizationOptions } from '@0xsequence/auth'

import { isBrowserExtension, useBestStore } from '../utils'
import { VERSION, commons } from '@0xsequence/core'
import { commons } from '@0xsequence/core'

@@ -70,3 +70,3 @@ const TRANSPORT_SESSION_LS_KEY = '@sequence.transportSession'

} else {
this.notifyChainChanged(ethers.toQuantity(networks.find(network => network.isDefaultChain)!.chainId))
this.notifyChainChanged(ethers.utils.hexValue(networks.find(network => network.isDefaultChain)!.chainId))
}

@@ -102,3 +102,3 @@ })

request(request: { method: string; params?: any[]; chainId?: number }): Promise<any> {
sendAsync = async (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => {
throw new Error('abstract method')

@@ -188,4 +188,3 @@ }

error
},
clientVersion: VERSION
}
})

@@ -198,4 +197,3 @@ }

type: EventType.CLOSE,
data: error ? { error } : null,
clientVersion: VERSION
data: error ? { error } : null
})

@@ -208,4 +206,3 @@ }

type: EventType.CONNECT,
data: connectDetails,
clientVersion: VERSION
data: connectDetails
})

@@ -219,4 +216,3 @@ }

data: error ? { error } : null,
origin,
clientVersion: VERSION
origin
})

@@ -230,4 +226,3 @@ }

data: accounts,
origin,
clientVersion: VERSION
origin
})

@@ -241,4 +236,3 @@ }

data: chainIdHex,
origin,
clientVersion: VERSION
origin
})

@@ -251,4 +245,3 @@ }

type: EventType.NETWORKS,
data: networks,
clientVersion: VERSION
data: networks
})

@@ -261,4 +254,3 @@ }

type: EventType.WALLET_CONTEXT,
data: walletContext,
clientVersion: VERSION
data: walletContext
})

@@ -332,4 +324,3 @@ }

type: EventType.INIT,
data: { nonce: this._initNonce },
clientVersion: VERSION
data: { nonce: this._initNonce }
})

@@ -336,0 +327,0 @@ this._init = InitState.SENT_NONCE

@@ -12,2 +12,3 @@ import {

import { JsonRpcRequest, JsonRpcResponseCallback } from '@0xsequence/network'
import { ProxyMessageChannelPort, ProxyMessageProvider } from '../proxy-transport'

@@ -18,3 +19,2 @@ import { Runtime } from 'webextension-polyfill'

import { WindowMessageProvider } from '../window-transport'
import { JsonRpcResponse } from '@0xsequence/network'

@@ -203,7 +203,8 @@ export type MuxTransportTemplate = {

request(request: { method: string; params?: any[]; chainId?: number }): Promise<any> {
if (!this.provider) {
throw new Error('impossible state, wallet must be opened first')
sendAsync = async (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => {
if (this.provider) {
this.provider.sendAsync(request, callback, chainId)
return
}
return this.provider.request(request)
throw new Error('impossible state, wallet must be opened first')
}

@@ -210,0 +211,0 @@

@@ -6,3 +6,2 @@ import { BaseProviderTransport } from '../base-provider-transport'

import { ProxyMessageChannelPort, ProxyEventTypes } from './proxy-message-channel'
import { VERSION } from '@0xsequence/core'

@@ -67,4 +66,3 @@ export class ProxyMessageProvider extends BaseProviderTransport {

sessionId
},
clientVersion: VERSION
}
})

@@ -78,4 +76,3 @@ }

type: EventType.CLOSE,
data: null,
clientVersion: VERSION
data: null
})

@@ -82,0 +79,0 @@ this.close()

@@ -9,8 +9,10 @@ import { Account, AccountStatus } from '@0xsequence/account'

findSupportedNetwork,
NetworkConfig,
EIP1193Provider,
JsonRpcResponse
JsonRpcHandler,
JsonRpcRequest,
JsonRpcResponse,
JsonRpcResponseCallback,
NetworkConfig
} from '@0xsequence/network'
import { logger, toHexString, TypedData } from '@0xsequence/utils'
import { ethers } from 'ethers'
import { logger, TypedData } from '@0xsequence/utils'
import { BigNumber, ethers, providers } from 'ethers'
import { EventEmitter2 as EventEmitter } from 'eventemitter2'

@@ -38,2 +40,4 @@

type ExternalProvider = providers.ExternalProvider
const SIGNER_READY_TIMEOUT = 10000

@@ -46,3 +50,3 @@

export class WalletRequestHandler implements EIP1193Provider, ProviderMessageRequestHandler {
export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, ProviderMessageRequestHandler {
// signer interface of the wallet. A null value means there is no signer (ie. user not signed in). An undefined

@@ -156,3 +160,3 @@ // value means the signer state is unknown, usually meaning the wallet app is booting up and initializing. Of course

connected: true,
chainId: ethers.toQuantity(chainId)
chainId: ethers.utils.hexValue(chainId)
}

@@ -218,33 +222,31 @@

// ProviderMessageResponse to be sent over the transport
async sendMessageRequest(message: ProviderMessageRequest): Promise<ProviderMessageResponse> {
// Older versions of the client require the response to be jsonrpc wrapped
const majorVersion = Number(message.clientVersion?.split('.')[0] || '0')
const isJsonRpcResponse = majorVersion < 2
const jsonRpcResponse: JsonRpcResponse = {
id: message.data.id!,
jsonrpc: '2.0',
result: null,
error: undefined
}
sendMessageRequest(message: ProviderMessageRequest): Promise<ProviderMessageResponse> {
return new Promise(resolve => {
this.sendAsync(
message.data,
(error: any, response?: JsonRpcResponse) => {
// TODO: if response includes data.error, why do we need a separate error argument here?
try {
const result = await this.request({
method: message.data.method,
params: message.data.params,
chainId: message.chainId
})
const responseMessage: ProviderMessageResponse = {
...message,
data: response!
}
return {
...message,
data: isJsonRpcResponse ? { ...jsonRpcResponse, result } : result
}
} catch (error) {
return {
...message,
data: isJsonRpcResponse ? { ...jsonRpcResponse, error } : error
}
}
// NOTE: we always resolve here, are the sendAsync call will wrap any exceptions
// in the error field of the response to ensure we send back to the user
resolve(responseMessage)
},
message.chainId
)
})
}
async request(request: { method: string; params?: any[]; chainId?: number }): Promise<any> {
// sendAsync implements the JsonRpcHandler interface for sending JsonRpcRequests to the wallet
sendAsync = async (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => {
const response: JsonRpcResponse = {
jsonrpc: '2.0',
id: request.id!,
result: null
}
await this.getAccount()

@@ -261,12 +263,8 @@

const account = this.account
if (!account) {
throw new Error('WalletRequestHandler: wallet account is not configured')
}
if (!account) throw new Error('WalletRequestHandler: wallet account is not configured')
// fetch the provider for the specific chain, or undefined will select defaultChain
const provider = this.account?.providerFor(request.chainId ?? this.defaultChainId())
if (!provider) {
throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${request.chainId}`)
}
const jsonRpcProvider = provider instanceof ethers.JsonRpcProvider ? provider : undefined
const provider = this.account?.providerFor(chainId ?? this.defaultChainId())
if (!provider) throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${chainId}`)
const jsonRpcProvider = provider instanceof ethers.providers.JsonRpcProvider ? provider : undefined

@@ -279,3 +277,5 @@ switch (request.method) {

return await jsonRpcProvider.send('net_version', [])
const result = await jsonRpcProvider.send('net_version', [])
response.result = result
break
}

@@ -288,7 +288,11 @@

return await jsonRpcProvider.send('eth_chainId', [])
const result = await jsonRpcProvider.send('eth_chainId', [])
response.result = result
break
}
case 'eth_accounts': {
return [account.address]
const walletAddress = account.address
response.result = [walletAddress]
break
}

@@ -299,3 +303,4 @@

const walletBalance = await provider.getBalance(accountAddress, blockTag)
return toHexString(walletBalance)
response.result = walletBalance.toHexString()
break
}

@@ -335,3 +340,2 @@

const sequenceVerified = request.method === 'sequence_sign'
if (this.prompter === null) {

@@ -341,3 +345,3 @@ // prompter is null, so we'll sign from here

prefixedMessage,
request.chainId ?? this.defaultChainId(),
chainId ?? this.defaultChainId(),
sequenceVerified ? 'eip6492' : 'ignore'

@@ -348,4 +352,4 @@ )

{
chainId: request.chainId,
message: ethers.getBytes(prefixedMessage),
chainId: chainId,
message: prefixedMessage,
eip6492: sequenceVerified

@@ -358,3 +362,3 @@ },

if (sig && sig.length > 0) {
return sig
response.result = sig
} else {

@@ -364,2 +368,3 @@ // The user has declined the request when value is null

}
break
}

@@ -398,3 +403,3 @@

typedData.message,
request.chainId ?? this.defaultChainId(),
chainId ?? this.defaultChainId(),
sequenceVerified ? 'eip6492' : 'ignore'

@@ -405,3 +410,3 @@ )

{
chainId: request.chainId,
chainId: chainId,
typedData: typedData,

@@ -415,3 +420,3 @@ eip6492: sequenceVerified

if (sig && sig.length > 0) {
return sig
response.result = sig
} else {

@@ -421,2 +426,3 @@ // The user has declined the request when value is null

}
break
}

@@ -442,11 +448,11 @@

// prompter is null, so we'll send from here
const txnResponse = await account.sendTransaction(transactionParams, request.chainId ?? this.defaultChainId())
const txnResponse = await account.sendTransaction(transactionParams, chainId ?? this.defaultChainId())
txnHash = txnResponse?.hash ?? ''
} else {
// prompt user to provide the response
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId, this.connectOptions)
txnHash = await this.prompter.promptSendTransaction(transactionParams, chainId, this.connectOptions)
}
if (txnHash) {
return txnHash
response.result = txnHash
} else {

@@ -456,2 +462,3 @@ // The user has declined the request when value is null

}
break
}

@@ -462,3 +469,3 @@

const [transaction] = request.params!
const sender = ethers.getAddress(transaction.from)
const sender = ethers.utils.getAddress(transaction.from)

@@ -477,6 +484,8 @@ if (sender !== account.address) {

// we will want to resolveProperties the big number values to hex strings
return await account.signTransactions(transaction, request.chainId ?? this.defaultChainId())
response.result = await account.signTransactions(transaction, chainId ?? this.defaultChainId())
} else {
return await this.prompter.promptSignTransaction(transaction, request.chainId, this.connectOptions)
response.result = await this.prompter.promptSignTransaction(transaction, chainId, this.connectOptions)
}
break
}

@@ -490,13 +499,14 @@

if (commons.transaction.isSignedTransactionBundle(request.params![0])) {
const txChainId = Number(BigInt(request.params![0].chainId))
const txChainId = BigNumber.from(request.params![0].chainId).toNumber()
const tx = await account.relayer(txChainId)!.relay(request.params![0])
return tx.hash
response.result = tx.hash
} else {
const tx = await provider.broadcastTransaction(request.params![0])
return tx.hash
const tx = await provider.sendTransaction(request.params![0])
response.result = tx.hash
}
break
}
case 'eth_getTransactionCount': {
const address = ethers.getAddress(request.params![0] as string)
const address = ethers.utils.getAddress(request.params![0] as string)
const tag = request.params![1]

@@ -508,19 +518,25 @@

const count = await provider.getTransactionCount(address, tag)
return toHexString(BigInt(count))
response.result = ethers.BigNumber.from(count).toHexString()
break
}
case 'eth_blockNumber': {
return await provider.getBlockNumber()
response.result = await provider.getBlockNumber()
break
}
case 'eth_getBlockByNumber': {
return await provider.getBlock(request.params![0] /* , jsonRpcRequest.params[1] */)
response.result = await provider.getBlock(request.params![0] /* , jsonRpcRequest.params[1] */)
break
}
case 'eth_getBlockByHash': {
return await provider.getBlock(request.params![0] /* , jsonRpcRequest.params[1] */)
response.result = await provider.getBlock(request.params![0] /* , jsonRpcRequest.params[1] */)
break
}
case 'eth_getTransactionByHash': {
return await provider.getTransaction(request.params![0])
response.result = await provider.getTransaction(request.params![0])
break
}

@@ -530,3 +546,4 @@

const [transactionObject, blockTag] = request.params!
return await provider.call({ ...transactionObject, blockTag })
response.result = await provider.call(transactionObject, blockTag)
break
}

@@ -536,3 +553,4 @@

const [contractAddress, blockTag] = request.params!
return await provider.getCode(contractAddress, blockTag)
response.result = await provider.getCode(contractAddress, blockTag)
break
}

@@ -542,8 +560,10 @@

const [transactionObject] = request.params!
return await provider.estimateGas(transactionObject)
response.result = await provider.estimateGas(transactionObject)
break
}
case 'eth_gasPrice': {
const feeData = await provider.getFeeData()
return feeData.gasPrice && toHexString(feeData.gasPrice)
const gasPrice = await provider.getGasPrice()
response.result = gasPrice.toHexString()
break
}

@@ -557,7 +577,8 @@

const chainId = BigInt(switchParams.chainId)
const chainId = ethers.BigNumber.from(switchParams.chainId)
this.setDefaultChainId(Number(chainId))
this.setDefaultChainId(chainId.toNumber())
return null // success
response.result = null // success
break
}

@@ -567,3 +588,4 @@

case 'sequence_getWalletContext': {
return account.contexts
response.result = account.contexts
break
}

@@ -575,5 +597,5 @@

if (chainId) {
return [(await account.status(chainId)).onChain.config]
response.result = [(await account.status(chainId)).onChain.config]
} else {
return await Promise.all(
response.result = await Promise.all(
account.networks.map(async network => {

@@ -585,2 +607,3 @@ const status = await account.status(network.chainId)

}
break
}

@@ -593,5 +616,5 @@

if (chainId) {
return [getLegacyWalletState(chainId, await account.status(chainId))]
response.result = [getLegacyWalletState(chainId, await account.status(chainId))]
} else {
return await Promise.all(
response.result = await Promise.all(
account.networks.map(async network => {

@@ -603,2 +626,3 @@ const status = await account.status(network.chainId)

}
break
}

@@ -611,7 +635,9 @@

// This is handled by this.getNetworks() but noted here for future readers.
return await this.getNetworks(true)
response.result = await this.getNetworks(true)
break
}
case 'sequence_isSequence': {
return true
response.result = true
break
}

@@ -627,3 +653,4 @@

// const [newConfig] = request.params
// return await signer.updateConfig(newConfig)
// response.result = await signer.updateConfig(newConfig)
break
}

@@ -634,2 +661,3 @@

throw new Error('sequence_publishConfig method is not allowed from a dapp')
break
}

@@ -664,3 +692,4 @@

this.setDefaultChainId(defaultChainId)
return await this.getNetworks(true)
response.result = await this.getNetworks(true)
break
}

@@ -674,8 +703,18 @@

// NOTE: provider here will be chain-bound if chainId is provided
return await jsonRpcProvider.send(request.method, request.params!)
const providerResponse = await jsonRpcProvider.send(request.method, request.params!)
response.result = providerResponse
}
}
} catch (err) {
throw { message: err?.message, code: 4001 } as ProviderRpcError
logger.error(err)
// See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#rpc-errors
response.result = null
response.error = {
...new Error(err),
code: 4001
}
}
callback(undefined, response)
}

@@ -709,2 +748,3 @@

this._connectOptions = options
this.onConnectOptionsChange?.(options)

@@ -778,3 +818,3 @@ }

notifyChainChanged(chainId: number, origin?: string) {
this.events.emit('chainChanged', ethers.toQuantity(chainId), origin)
this.events.emit('chainChanged', ethers.utils.hexValue(chainId), origin)
}

@@ -788,3 +828,3 @@

if (defaultNetwork) {
this.events.emit('chainChanged', ethers.toQuantity(defaultNetwork.chainId))
this.events.emit('chainChanged', ethers.utils.hexValue(defaultNetwork.chainId))
}

@@ -791,0 +831,0 @@ } else {

@@ -13,4 +13,3 @@ import {

import { BaseWalletTransport } from '../base-wallet-transport'
import { logger, base64DecodeObject } from '@0xsequence/utils'
import { ethers } from 'ethers'
import { logger, sanitizeNumberString, base64DecodeObject } from '@0xsequence/utils'

@@ -35,3 +34,3 @@ export class WindowMessageHandler extends BaseWalletTransport {

// record open details (sessionId + default network) from the window url
const { search: rawParams } = new URL(windowHref || window.location.href)
const { pathname, search: rawParams } = new URL(windowHref || window.location.href)

@@ -98,10 +97,3 @@ let session: TransportSession | null = this.getWindowTransportSession(rawParams)

try {
request = JSON.parse(event.data, (key, value) => {
// BigNumber compatibility with older versions of sequence.js
if (isBigNumberSerialized(value)) {
return BigInt(value.hex)
}
return value
})
request = JSON.parse(event.data)
} catch (err) {

@@ -175,7 +167,1 @@ // event is not a ProviderMessage JSON object, skip

}
const isBigNumberSerialized = (value: any): boolean => {
return (
typeof value === 'object' && 'type' in value && value.type === 'BigNumber' && 'hex' in value && ethers.isHexString(value.hex)
)
}

@@ -1,2 +0,2 @@

import { OpenWalletIntent, ProviderMessage, InitState, WindowSessionParams } from '../../types'
import { OpenWalletIntent, ProviderMessage, InitState, EventType, WindowSessionParams } from '../../types'
import { BaseProviderTransport } from '../base-provider-transport'

@@ -3,0 +3,0 @@ import { logger, base64EncodeObject } from '@0xsequence/utils'

@@ -5,11 +5,11 @@ import { ETHAuthProof as AuthETHAuthProof } from '@0xsequence/auth'

ChainIdLike,
EIP1193Provider,
JsonRpcHandler,
JsonRpcRequest,
JsonRpcResponse,
NetworkConfig,
JsonRpcErrorPayload as _JsonRpcErrorPayload
ProviderRpcError as NetworkProviderRpcError
} from '@0xsequence/network'
import { TypedData } from '@0xsequence/utils'
export interface ProviderTransport extends EIP1193Provider, ProviderMessageTransport, ProviderMessageRequestHandler {
export interface ProviderTransport extends JsonRpcHandler, ProviderMessageTransport, ProviderMessageRequestHandler {
register(): void

@@ -46,3 +46,3 @@ unregister(): void

export interface WalletTransport extends EIP1193Provider, ProviderMessageTransport, ProviderMessageRequestHandler {
export interface WalletTransport extends JsonRpcHandler, ProviderMessageTransport, ProviderMessageRequestHandler {
register(): void

@@ -66,3 +66,2 @@ unregister(): void

origin?: string // origin of the message
clientVersion: string // client version of the message
}

@@ -72,4 +71,3 @@

// Older versions of sequence.js will require a JsonRpcResponse result type, but newer versions use raw EIP1193 results
export type ProviderMessageResponse = ProviderMessage<JsonRpcResponse | any>
export type ProviderMessageResponse = ProviderMessage<JsonRpcResponse>

@@ -81,3 +79,3 @@ // ProviderMessageCallback is used to respond to ProviderMessage requests. The error

export type ProviderRpcError = _JsonRpcErrorPayload
export type ProviderRpcError = NetworkProviderRpcError

@@ -383,1 +381,6 @@ export interface ProviderMessageRequestHandler {

| undefined
// This is required by viem, it expects a provider to have an EIP-1193 compliant `request` attribute.
export interface EIP1193Provider {
request: (request: { method: string; params?: Array<any> }) => Promise<any>
}

@@ -1,2 +0,2 @@

import { ethers } from 'ethers'
import { ethers, BytesLike } from 'ethers'
import { messageIsExemptFromEIP191Prefix } from './eip191exceptions'

@@ -7,13 +7,13 @@ import { AccountStatus } from '@0xsequence/account'

const eip191prefix = ethers.toUtf8Bytes('\x19Ethereum Signed Message:\n')
const eip191prefix = ethers.utils.toUtf8Bytes('\x19Ethereum Signed Message:\n')
export const messageToBytes = (message: ethers.BytesLike): Uint8Array => {
if (ethers.isBytesLike(message)) {
return ethers.getBytes(message)
export const messageToBytes = (message: BytesLike): Uint8Array => {
if (ethers.utils.isBytesLike(message)) {
return ethers.utils.arrayify(message)
}
return ethers.toUtf8Bytes(message)
return ethers.utils.toUtf8Bytes(message)
}
export const prefixEIP191Message = (message: ethers.BytesLike): Uint8Array => {
export const prefixEIP191Message = (message: BytesLike): Uint8Array => {
const messageBytes = messageToBytes(message)

@@ -23,3 +23,3 @@ if (messageIsExemptFromEIP191Prefix(messageBytes)) {

} else {
return ethers.getBytes(ethers.concat([eip191prefix, ethers.toUtf8Bytes(String(messageBytes.length)), messageBytes]))
return ethers.utils.concat([eip191prefix, ethers.utils.toUtf8Bytes(String(messageBytes.length)), messageBytes])
}

@@ -52,5 +52,5 @@ }

try {
prefixAsNumber = Number(ethers.toUtf8String(ethereumSignedMessagePartSlicedArray.slice(0, maxPrefixCharLength)))
prefixAsNumber = Number(ethers.utils.toUtf8String(ethereumSignedMessagePartSlicedArray.slice(0, maxPrefixCharLength)))
} catch {
prefixAsNumber = Number(ethers.hexlify(ethereumSignedMessagePartSlicedArray.slice(0, maxPrefixCharLength)))
prefixAsNumber = Number(ethers.utils.hexlify(ethereumSignedMessagePartSlicedArray.slice(0, maxPrefixCharLength)))
}

@@ -73,3 +73,3 @@

sig: string,
provider: ethers.Provider
provider: ethers.providers.Provider
): Promise<boolean> => {

@@ -85,3 +85,3 @@ const reader = new commons.reader.OnChainReader(provider)

signature: string,
provider: ethers.Provider
provider: ethers.providers.Provider
): Promise<boolean> => {

@@ -98,3 +98,3 @@ const prefixed = prefixEIP191Message(message)

signature: string,
provider: ethers.Provider
provider: ethers.providers.Provider
): Promise<boolean> => {

@@ -209,9 +209,11 @@ return isValidSignature(address, encodeTypedDataDigest(typedData), signature, provider)

export async function resolveArrayProperties<T>(object: Readonly<T> | Readonly<T>[]): Promise<T> {
export async function resolveArrayProperties<T>(
object: Readonly<ethers.utils.Deferrable<T>> | Readonly<ethers.utils.Deferrable<T>>[]
): Promise<T> {
if (Array.isArray(object)) {
// T must include array type
return Promise.all(object.map(o => ethers.resolveProperties(o))) as any
return Promise.all(object.map(o => ethers.utils.resolveProperties(o))) as any
}
return ethers.resolveProperties(object)
return ethers.utils.resolveProperties(object)
}

@@ -1,2 +0,2 @@

import { ethers } from 'ethers'
import { BytesLike, TypedDataDomain, TypedDataField } from 'ethers'
import { ChainIdLike } from '@0xsequence/network'

@@ -20,3 +20,3 @@ import { encodeMessageDigest, TypedData, encodeTypedDataDigest } from '@0xsequence/utils'

// Sign message on a specified chain, or DefaultChain by default
signMessage(message: ethers.BytesLike, chainId?: ChainIdLike, eip6492?: boolean): Promise<string> {
signMessage(message: BytesLike, chainId?: ChainIdLike, eip6492?: boolean): Promise<string> {
return this.signer.signMessage(message, { chainId, eip6492 })

@@ -27,4 +27,4 @@ }

signTypedData(
domain: ethers.TypedDataDomain,
types: Record<string, Array<ethers.TypedDataField>>,
domain: TypedDataDomain,
types: Record<string, Array<TypedDataField>>,
message: Record<string, any>,

@@ -31,0 +31,0 @@ chainId?: ChainIdLike,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc