@0xsequence/provider 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0xsequence-provider.cjs.dev.js +10 -4
- package/dist/0xsequence-provider.cjs.prod.js +10 -4
- package/dist/0xsequence-provider.esm.js +11 -5
- package/dist/declarations/src/transports/wallet-request-handler.d.ts +3 -3
- package/package.json +10 -10
- package/src/transports/base-wallet-transport.ts +6 -0
- package/src/transports/wallet-request-handler.ts +18 -15
|
@@ -835,6 +835,11 @@ class BaseWalletTransport {
|
|
|
835
835
|
if (connectOptions.app) {
|
|
836
836
|
connectOptions.app = utils.sanitizeAlphanumeric(connectOptions.app);
|
|
837
837
|
}
|
|
838
|
+
if (connectOptions.networkId) {
|
|
839
|
+
networkId = connectOptions.networkId;
|
|
840
|
+
} else if (networkId) {
|
|
841
|
+
connectOptions.networkId = networkId;
|
|
842
|
+
}
|
|
838
843
|
|
|
839
844
|
// Set connect options on the walletRequestHandler as our primary
|
|
840
845
|
// wallet controller, and fall back to networkId if necessary
|
|
@@ -2645,7 +2650,7 @@ class WalletRequestHandler {
|
|
|
2645
2650
|
});
|
|
2646
2651
|
}
|
|
2647
2652
|
async connect(options) {
|
|
2648
|
-
var
|
|
2653
|
+
var _ref, _options$networkId;
|
|
2649
2654
|
if (!this.account) {
|
|
2650
2655
|
return {
|
|
2651
2656
|
connected: false,
|
|
@@ -2653,7 +2658,8 @@ class WalletRequestHandler {
|
|
|
2653
2658
|
error: 'unable to connect without signed in account'
|
|
2654
2659
|
};
|
|
2655
2660
|
}
|
|
2656
|
-
const
|
|
2661
|
+
const networkId = (_ref = (_options$networkId = options == null ? void 0 : options.networkId) != null ? _options$networkId : this.defaultChainId()) != null ? _ref : network.ChainId.MAINNET;
|
|
2662
|
+
const chainId = network.findSupportedNetwork(networkId).chainId;
|
|
2657
2663
|
const connectDetails = {
|
|
2658
2664
|
connected: true,
|
|
2659
2665
|
chainId: ethers.ethers.utils.hexValue(chainId)
|
|
@@ -2730,8 +2736,8 @@ class WalletRequestHandler {
|
|
|
2730
2736
|
(_this$onConnectOption = this.onConnectOptionsChange) == null ? void 0 : _this$onConnectOption.call(this, options);
|
|
2731
2737
|
}
|
|
2732
2738
|
async setDefaultChainId(chainId) {
|
|
2733
|
-
var _this$
|
|
2734
|
-
await ((_this$
|
|
2739
|
+
var _this$prompter4;
|
|
2740
|
+
await ((_this$prompter4 = this.prompter) == null ? void 0 : _this$prompter4.promptChangeNetwork(chainId));
|
|
2735
2741
|
return this.defaultChainId();
|
|
2736
2742
|
}
|
|
2737
2743
|
async getNetworks(jsonRpcResponse) {
|
|
@@ -835,6 +835,11 @@ class BaseWalletTransport {
|
|
|
835
835
|
if (connectOptions.app) {
|
|
836
836
|
connectOptions.app = utils.sanitizeAlphanumeric(connectOptions.app);
|
|
837
837
|
}
|
|
838
|
+
if (connectOptions.networkId) {
|
|
839
|
+
networkId = connectOptions.networkId;
|
|
840
|
+
} else if (networkId) {
|
|
841
|
+
connectOptions.networkId = networkId;
|
|
842
|
+
}
|
|
838
843
|
|
|
839
844
|
// Set connect options on the walletRequestHandler as our primary
|
|
840
845
|
// wallet controller, and fall back to networkId if necessary
|
|
@@ -2645,7 +2650,7 @@ class WalletRequestHandler {
|
|
|
2645
2650
|
});
|
|
2646
2651
|
}
|
|
2647
2652
|
async connect(options) {
|
|
2648
|
-
var
|
|
2653
|
+
var _ref, _options$networkId;
|
|
2649
2654
|
if (!this.account) {
|
|
2650
2655
|
return {
|
|
2651
2656
|
connected: false,
|
|
@@ -2653,7 +2658,8 @@ class WalletRequestHandler {
|
|
|
2653
2658
|
error: 'unable to connect without signed in account'
|
|
2654
2659
|
};
|
|
2655
2660
|
}
|
|
2656
|
-
const
|
|
2661
|
+
const networkId = (_ref = (_options$networkId = options == null ? void 0 : options.networkId) != null ? _options$networkId : this.defaultChainId()) != null ? _ref : network.ChainId.MAINNET;
|
|
2662
|
+
const chainId = network.findSupportedNetwork(networkId).chainId;
|
|
2657
2663
|
const connectDetails = {
|
|
2658
2664
|
connected: true,
|
|
2659
2665
|
chainId: ethers.ethers.utils.hexValue(chainId)
|
|
@@ -2730,8 +2736,8 @@ class WalletRequestHandler {
|
|
|
2730
2736
|
(_this$onConnectOption = this.onConnectOptionsChange) == null ? void 0 : _this$onConnectOption.call(this, options);
|
|
2731
2737
|
}
|
|
2732
2738
|
async setDefaultChainId(chainId) {
|
|
2733
|
-
var _this$
|
|
2734
|
-
await ((_this$
|
|
2739
|
+
var _this$prompter4;
|
|
2740
|
+
await ((_this$prompter4 = this.prompter) == null ? void 0 : _this$prompter4.promptChangeNetwork(chainId));
|
|
2735
2741
|
return this.defaultChainId();
|
|
2736
2742
|
}
|
|
2737
2743
|
async getNetworks(jsonRpcResponse) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter2 } from 'eventemitter2';
|
|
2
2
|
import { logger, encodeMessageDigest, encodeTypedDataDigest, sanitizeNumberString, sanitizeHost, sanitizeAlphanumeric, base64EncodeObject, base64DecodeObject } from '@0xsequence/utils';
|
|
3
3
|
import { ethers, BigNumber } from 'ethers';
|
|
4
|
-
import { findSupportedNetwork, allNetworks, findNetworkConfig, JsonRpcRouter, loggingProviderMiddleware, exceptionProviderMiddleware, CachedProvider, JsonRpcSender } from '@0xsequence/network';
|
|
4
|
+
import { findSupportedNetwork, ChainId, allNetworks, findNetworkConfig, JsonRpcRouter, loggingProviderMiddleware, exceptionProviderMiddleware, CachedProvider, JsonRpcSender } from '@0xsequence/network';
|
|
5
5
|
import { commons } from '@0xsequence/core';
|
|
6
6
|
import { signAuthorization } from '@0xsequence/auth';
|
|
7
7
|
|
|
@@ -831,6 +831,11 @@ class BaseWalletTransport {
|
|
|
831
831
|
if (connectOptions.app) {
|
|
832
832
|
connectOptions.app = sanitizeAlphanumeric(connectOptions.app);
|
|
833
833
|
}
|
|
834
|
+
if (connectOptions.networkId) {
|
|
835
|
+
networkId = connectOptions.networkId;
|
|
836
|
+
} else if (networkId) {
|
|
837
|
+
connectOptions.networkId = networkId;
|
|
838
|
+
}
|
|
834
839
|
|
|
835
840
|
// Set connect options on the walletRequestHandler as our primary
|
|
836
841
|
// wallet controller, and fall back to networkId if necessary
|
|
@@ -2641,7 +2646,7 @@ class WalletRequestHandler {
|
|
|
2641
2646
|
});
|
|
2642
2647
|
}
|
|
2643
2648
|
async connect(options) {
|
|
2644
|
-
var
|
|
2649
|
+
var _ref, _options$networkId;
|
|
2645
2650
|
if (!this.account) {
|
|
2646
2651
|
return {
|
|
2647
2652
|
connected: false,
|
|
@@ -2649,7 +2654,8 @@ class WalletRequestHandler {
|
|
|
2649
2654
|
error: 'unable to connect without signed in account'
|
|
2650
2655
|
};
|
|
2651
2656
|
}
|
|
2652
|
-
const
|
|
2657
|
+
const networkId = (_ref = (_options$networkId = options == null ? void 0 : options.networkId) != null ? _options$networkId : this.defaultChainId()) != null ? _ref : ChainId.MAINNET;
|
|
2658
|
+
const chainId = findSupportedNetwork(networkId).chainId;
|
|
2653
2659
|
const connectDetails = {
|
|
2654
2660
|
connected: true,
|
|
2655
2661
|
chainId: ethers.utils.hexValue(chainId)
|
|
@@ -2726,8 +2732,8 @@ class WalletRequestHandler {
|
|
|
2726
2732
|
(_this$onConnectOption = this.onConnectOptionsChange) == null ? void 0 : _this$onConnectOption.call(this, options);
|
|
2727
2733
|
}
|
|
2728
2734
|
async setDefaultChainId(chainId) {
|
|
2729
|
-
var _this$
|
|
2730
|
-
await ((_this$
|
|
2735
|
+
var _this$prompter4;
|
|
2736
|
+
await ((_this$prompter4 = this.prompter) == null ? void 0 : _this$prompter4.promptChangeNetwork(chainId));
|
|
2731
2737
|
return this.defaultChainId();
|
|
2732
2738
|
}
|
|
2733
2739
|
async getNetworks(jsonRpcResponse) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Account } from '@0xsequence/account';
|
|
2
2
|
import { commons } from '@0xsequence/core';
|
|
3
|
-
import {
|
|
3
|
+
import { JsonRpcHandler, JsonRpcRequest, JsonRpcResponseCallback, NetworkConfig } from '@0xsequence/network';
|
|
4
4
|
import { providers } from 'ethers';
|
|
5
|
-
import {
|
|
5
|
+
import { ConnectDetails, ConnectOptions, MessageToSign, NetworkedConnectOptions, OpenWalletIntent, PromptConnectDetails, ProviderEventTypes, ProviderMessageRequest, ProviderMessageRequestHandler, ProviderMessageResponse, ProviderRpcError, WalletSession } from "../types.js";
|
|
6
6
|
type ExternalProvider = providers.ExternalProvider;
|
|
7
7
|
export interface WalletSignInOptions {
|
|
8
8
|
connect?: boolean;
|
|
@@ -23,7 +23,7 @@ export declare class WalletRequestHandler implements ExternalProvider, JsonRpcHa
|
|
|
23
23
|
signOut(): void;
|
|
24
24
|
signerReset(): void;
|
|
25
25
|
signerReady(timeout?: number): Promise<void>;
|
|
26
|
-
connect(options?:
|
|
26
|
+
connect(options?: NetworkedConnectOptions): Promise<ConnectDetails>;
|
|
27
27
|
promptConnect: (options?: ConnectOptions) => Promise<ConnectDetails>;
|
|
28
28
|
sendMessageRequest(message: ProviderMessageRequest): Promise<ProviderMessageResponse>;
|
|
29
29
|
sendAsync: (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "provider sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eventemitter2": "^6.4.5",
|
|
13
13
|
"webextension-polyfill": "^0.10.0",
|
|
14
|
-
"@0xsequence/abi": "1.1.
|
|
15
|
-
"@0xsequence/account": "1.1.
|
|
16
|
-
"@0xsequence/auth": "1.1.
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "1.1.
|
|
20
|
-
"@0xsequence/relayer": "1.1.
|
|
21
|
-
"@0xsequence/utils": "1.1.
|
|
22
|
-
"@0xsequence/wallet": "1.1.
|
|
14
|
+
"@0xsequence/abi": "1.1.3",
|
|
15
|
+
"@0xsequence/account": "1.1.3",
|
|
16
|
+
"@0xsequence/auth": "1.1.3",
|
|
17
|
+
"@0xsequence/core": "1.1.3",
|
|
18
|
+
"@0xsequence/migration": "1.1.3",
|
|
19
|
+
"@0xsequence/network": "1.1.3",
|
|
20
|
+
"@0xsequence/relayer": "1.1.3",
|
|
21
|
+
"@0xsequence/utils": "1.1.3",
|
|
22
|
+
"@0xsequence/wallet": "1.1.3"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
|
@@ -372,6 +372,12 @@ export abstract class BaseWalletTransport implements WalletTransport {
|
|
|
372
372
|
connectOptions.app = sanitizeAlphanumeric(connectOptions.app)
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
if (connectOptions.networkId) {
|
|
376
|
+
networkId = connectOptions.networkId
|
|
377
|
+
} else if (networkId) {
|
|
378
|
+
connectOptions.networkId = networkId
|
|
379
|
+
}
|
|
380
|
+
|
|
375
381
|
// Set connect options on the walletRequestHandler as our primary
|
|
376
382
|
// wallet controller, and fall back to networkId if necessary
|
|
377
383
|
this.walletRequestHandler.setConnectOptions(connectOptions)
|
|
@@ -2,12 +2,13 @@ import { Account, AccountStatus } from '@0xsequence/account'
|
|
|
2
2
|
import { signAuthorization, AuthorizationOptions } from '@0xsequence/auth'
|
|
3
3
|
import { commons } from '@0xsequence/core'
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
ChainId,
|
|
6
|
+
findSupportedNetwork,
|
|
6
7
|
JsonRpcHandler,
|
|
7
8
|
JsonRpcRequest,
|
|
8
|
-
JsonRpcResponseCallback,
|
|
9
9
|
JsonRpcResponse,
|
|
10
|
-
|
|
10
|
+
JsonRpcResponseCallback,
|
|
11
|
+
NetworkConfig
|
|
11
12
|
} from '@0xsequence/network'
|
|
12
13
|
import { logger, TypedData } from '@0xsequence/utils'
|
|
13
14
|
import { BigNumber, ethers, providers } from 'ethers'
|
|
@@ -16,19 +17,20 @@ import { EventEmitter2 as EventEmitter } from 'eventemitter2'
|
|
|
16
17
|
import { fromExtended } from '../extended'
|
|
17
18
|
import { validateTransactionRequest } from '../transactions'
|
|
18
19
|
import {
|
|
19
|
-
ProviderMessageRequest,
|
|
20
|
-
ProviderMessageResponse,
|
|
21
|
-
ProviderMessageRequestHandler,
|
|
22
|
-
MessageToSign,
|
|
23
|
-
ProviderRpcError,
|
|
24
|
-
ConnectOptions,
|
|
25
20
|
ConnectDetails,
|
|
26
|
-
|
|
27
|
-
WalletSession,
|
|
28
|
-
OpenWalletIntent,
|
|
21
|
+
ConnectOptions,
|
|
29
22
|
ErrSignedInRequired,
|
|
23
|
+
MessageToSign,
|
|
24
|
+
NetworkedConnectOptions,
|
|
25
|
+
OpenWalletIntent,
|
|
26
|
+
PromptConnectDetails,
|
|
30
27
|
ProviderEventTypes,
|
|
31
|
-
|
|
28
|
+
ProviderMessageRequest,
|
|
29
|
+
ProviderMessageRequestHandler,
|
|
30
|
+
ProviderMessageResponse,
|
|
31
|
+
ProviderRpcError,
|
|
32
|
+
TypedEventEmitter,
|
|
33
|
+
WalletSession
|
|
32
34
|
} from '../types'
|
|
33
35
|
import { prefixEIP191Message } from '../utils'
|
|
34
36
|
|
|
@@ -132,7 +134,7 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
132
134
|
})
|
|
133
135
|
}
|
|
134
136
|
|
|
135
|
-
async connect(options?:
|
|
137
|
+
async connect(options?: NetworkedConnectOptions): Promise<ConnectDetails> {
|
|
136
138
|
if (!this.account) {
|
|
137
139
|
return {
|
|
138
140
|
connected: false,
|
|
@@ -141,7 +143,8 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
const
|
|
146
|
+
const networkId = options?.networkId ?? this.defaultChainId() ?? ChainId.MAINNET
|
|
147
|
+
const chainId = findSupportedNetwork(networkId)!.chainId
|
|
145
148
|
|
|
146
149
|
const connectDetails: ConnectDetails = {
|
|
147
150
|
connected: true,
|