@0xsequence/provider 1.1.7 → 1.1.9
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 +18 -7
- package/dist/0xsequence-provider.cjs.prod.js +18 -7
- package/dist/0xsequence-provider.esm.js +18 -7
- package/dist/declarations/src/client.d.ts +8 -2
- package/dist/declarations/src/init.d.ts +1 -0
- package/package.json +10 -10
- package/src/client.ts +26 -4
- package/src/init.ts +12 -2
|
@@ -3585,16 +3585,16 @@ class DefaultChainIdTracker {
|
|
|
3585
3585
|
return parseInt(read);
|
|
3586
3586
|
}
|
|
3587
3587
|
}
|
|
3588
|
-
|
|
3588
|
+
DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
3589
3589
|
/**
|
|
3590
3590
|
* This is a wallet client for sequence wallet-webapp. It connects using *some* transport
|
|
3591
3591
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3592
|
-
*
|
|
3592
|
+
*s
|
|
3593
3593
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3594
3594
|
*/
|
|
3595
|
-
DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
3596
3595
|
class SequenceClient {
|
|
3597
|
-
constructor(transport, store,
|
|
3596
|
+
constructor(transport, store, options) {
|
|
3597
|
+
var _options$defaultEIP;
|
|
3598
3598
|
this.callbacks = {};
|
|
3599
3599
|
if (isMuxTransportTemplate(transport)) {
|
|
3600
3600
|
this.transport = MuxMessageProvider.new(transport);
|
|
@@ -3603,6 +3603,8 @@ class SequenceClient {
|
|
|
3603
3603
|
} else {
|
|
3604
3604
|
throw new Error('Invalid transport');
|
|
3605
3605
|
}
|
|
3606
|
+
const defaultChainId = typeof options === 'number' ? options : options == null ? void 0 : options.defaultChainId;
|
|
3607
|
+
this.defaultEIP6492 = typeof options === 'number' ? false : (_options$defaultEIP = options == null ? void 0 : options.defaultEIP6492) != null ? _options$defaultEIP : false;
|
|
3606
3608
|
this.session = new SequenceClientSession(store);
|
|
3607
3609
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId);
|
|
3608
3610
|
this.transport.on('accountsChanged', accounts => {
|
|
@@ -3812,8 +3814,14 @@ class SequenceClient {
|
|
|
3812
3814
|
}
|
|
3813
3815
|
return connectedSession.networks;
|
|
3814
3816
|
}
|
|
3817
|
+
usesEIP6492(options) {
|
|
3818
|
+
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3819
|
+
return this.defaultEIP6492;
|
|
3820
|
+
}
|
|
3821
|
+
return options.eip6492;
|
|
3822
|
+
}
|
|
3815
3823
|
async signMessage(message, options) {
|
|
3816
|
-
const method = options
|
|
3824
|
+
const method = this.usesEIP6492(options) ? 'sequence_sign' : 'personal_sign';
|
|
3817
3825
|
|
|
3818
3826
|
// Address is ignored by the wallet webapp
|
|
3819
3827
|
return this.send({
|
|
@@ -3822,7 +3830,7 @@ class SequenceClient {
|
|
|
3822
3830
|
}, options == null ? void 0 : options.chainId);
|
|
3823
3831
|
}
|
|
3824
3832
|
async signTypedData(typedData, options) {
|
|
3825
|
-
const method = options
|
|
3833
|
+
const method = this.usesEIP6492(options) ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4';
|
|
3826
3834
|
|
|
3827
3835
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
3828
3836
|
// and it makes the client depend on ethers.
|
|
@@ -3932,7 +3940,10 @@ const initWallet = partialConfig => {
|
|
|
3932
3940
|
const itemStore = config.localStorage || useBestStore();
|
|
3933
3941
|
|
|
3934
3942
|
// Create client, provider and return signer
|
|
3935
|
-
const client = new SequenceClient(config.transports, itemStore,
|
|
3943
|
+
const client = new SequenceClient(config.transports, itemStore, {
|
|
3944
|
+
defaultChainId: defaultNetwork,
|
|
3945
|
+
defaultEIP6492: config.defaultEIP6492
|
|
3946
|
+
});
|
|
3936
3947
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
3937
3948
|
return sequenceWalletProvider;
|
|
3938
3949
|
};
|
|
@@ -3585,16 +3585,16 @@ class DefaultChainIdTracker {
|
|
|
3585
3585
|
return parseInt(read);
|
|
3586
3586
|
}
|
|
3587
3587
|
}
|
|
3588
|
-
|
|
3588
|
+
DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
3589
3589
|
/**
|
|
3590
3590
|
* This is a wallet client for sequence wallet-webapp. It connects using *some* transport
|
|
3591
3591
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3592
|
-
*
|
|
3592
|
+
*s
|
|
3593
3593
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3594
3594
|
*/
|
|
3595
|
-
DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
3596
3595
|
class SequenceClient {
|
|
3597
|
-
constructor(transport, store,
|
|
3596
|
+
constructor(transport, store, options) {
|
|
3597
|
+
var _options$defaultEIP;
|
|
3598
3598
|
this.callbacks = {};
|
|
3599
3599
|
if (isMuxTransportTemplate(transport)) {
|
|
3600
3600
|
this.transport = MuxMessageProvider.new(transport);
|
|
@@ -3603,6 +3603,8 @@ class SequenceClient {
|
|
|
3603
3603
|
} else {
|
|
3604
3604
|
throw new Error('Invalid transport');
|
|
3605
3605
|
}
|
|
3606
|
+
const defaultChainId = typeof options === 'number' ? options : options == null ? void 0 : options.defaultChainId;
|
|
3607
|
+
this.defaultEIP6492 = typeof options === 'number' ? false : (_options$defaultEIP = options == null ? void 0 : options.defaultEIP6492) != null ? _options$defaultEIP : false;
|
|
3606
3608
|
this.session = new SequenceClientSession(store);
|
|
3607
3609
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId);
|
|
3608
3610
|
this.transport.on('accountsChanged', accounts => {
|
|
@@ -3812,8 +3814,14 @@ class SequenceClient {
|
|
|
3812
3814
|
}
|
|
3813
3815
|
return connectedSession.networks;
|
|
3814
3816
|
}
|
|
3817
|
+
usesEIP6492(options) {
|
|
3818
|
+
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3819
|
+
return this.defaultEIP6492;
|
|
3820
|
+
}
|
|
3821
|
+
return options.eip6492;
|
|
3822
|
+
}
|
|
3815
3823
|
async signMessage(message, options) {
|
|
3816
|
-
const method = options
|
|
3824
|
+
const method = this.usesEIP6492(options) ? 'sequence_sign' : 'personal_sign';
|
|
3817
3825
|
|
|
3818
3826
|
// Address is ignored by the wallet webapp
|
|
3819
3827
|
return this.send({
|
|
@@ -3822,7 +3830,7 @@ class SequenceClient {
|
|
|
3822
3830
|
}, options == null ? void 0 : options.chainId);
|
|
3823
3831
|
}
|
|
3824
3832
|
async signTypedData(typedData, options) {
|
|
3825
|
-
const method = options
|
|
3833
|
+
const method = this.usesEIP6492(options) ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4';
|
|
3826
3834
|
|
|
3827
3835
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
3828
3836
|
// and it makes the client depend on ethers.
|
|
@@ -3932,7 +3940,10 @@ const initWallet = partialConfig => {
|
|
|
3932
3940
|
const itemStore = config.localStorage || useBestStore();
|
|
3933
3941
|
|
|
3934
3942
|
// Create client, provider and return signer
|
|
3935
|
-
const client = new SequenceClient(config.transports, itemStore,
|
|
3943
|
+
const client = new SequenceClient(config.transports, itemStore, {
|
|
3944
|
+
defaultChainId: defaultNetwork,
|
|
3945
|
+
defaultEIP6492: config.defaultEIP6492
|
|
3946
|
+
});
|
|
3936
3947
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
3937
3948
|
return sequenceWalletProvider;
|
|
3938
3949
|
};
|
|
@@ -3581,16 +3581,16 @@ class DefaultChainIdTracker {
|
|
|
3581
3581
|
return parseInt(read);
|
|
3582
3582
|
}
|
|
3583
3583
|
}
|
|
3584
|
-
|
|
3584
|
+
DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
3585
3585
|
/**
|
|
3586
3586
|
* This is a wallet client for sequence wallet-webapp. It connects using *some* transport
|
|
3587
3587
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3588
|
-
*
|
|
3588
|
+
*s
|
|
3589
3589
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3590
3590
|
*/
|
|
3591
|
-
DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
3592
3591
|
class SequenceClient {
|
|
3593
|
-
constructor(transport, store,
|
|
3592
|
+
constructor(transport, store, options) {
|
|
3593
|
+
var _options$defaultEIP;
|
|
3594
3594
|
this.callbacks = {};
|
|
3595
3595
|
if (isMuxTransportTemplate(transport)) {
|
|
3596
3596
|
this.transport = MuxMessageProvider.new(transport);
|
|
@@ -3599,6 +3599,8 @@ class SequenceClient {
|
|
|
3599
3599
|
} else {
|
|
3600
3600
|
throw new Error('Invalid transport');
|
|
3601
3601
|
}
|
|
3602
|
+
const defaultChainId = typeof options === 'number' ? options : options == null ? void 0 : options.defaultChainId;
|
|
3603
|
+
this.defaultEIP6492 = typeof options === 'number' ? false : (_options$defaultEIP = options == null ? void 0 : options.defaultEIP6492) != null ? _options$defaultEIP : false;
|
|
3602
3604
|
this.session = new SequenceClientSession(store);
|
|
3603
3605
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId);
|
|
3604
3606
|
this.transport.on('accountsChanged', accounts => {
|
|
@@ -3808,8 +3810,14 @@ class SequenceClient {
|
|
|
3808
3810
|
}
|
|
3809
3811
|
return connectedSession.networks;
|
|
3810
3812
|
}
|
|
3813
|
+
usesEIP6492(options) {
|
|
3814
|
+
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3815
|
+
return this.defaultEIP6492;
|
|
3816
|
+
}
|
|
3817
|
+
return options.eip6492;
|
|
3818
|
+
}
|
|
3811
3819
|
async signMessage(message, options) {
|
|
3812
|
-
const method = options
|
|
3820
|
+
const method = this.usesEIP6492(options) ? 'sequence_sign' : 'personal_sign';
|
|
3813
3821
|
|
|
3814
3822
|
// Address is ignored by the wallet webapp
|
|
3815
3823
|
return this.send({
|
|
@@ -3818,7 +3826,7 @@ class SequenceClient {
|
|
|
3818
3826
|
}, options == null ? void 0 : options.chainId);
|
|
3819
3827
|
}
|
|
3820
3828
|
async signTypedData(typedData, options) {
|
|
3821
|
-
const method = options
|
|
3829
|
+
const method = this.usesEIP6492(options) ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4';
|
|
3822
3830
|
|
|
3823
3831
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
3824
3832
|
// and it makes the client depend on ethers.
|
|
@@ -3928,7 +3936,10 @@ const initWallet = partialConfig => {
|
|
|
3928
3936
|
const itemStore = config.localStorage || useBestStore();
|
|
3929
3937
|
|
|
3930
3938
|
// Create client, provider and return signer
|
|
3931
|
-
const client = new SequenceClient(config.transports, itemStore,
|
|
3939
|
+
const client = new SequenceClient(config.transports, itemStore, {
|
|
3940
|
+
defaultChainId: defaultNetwork,
|
|
3941
|
+
defaultEIP6492: config.defaultEIP6492
|
|
3942
|
+
});
|
|
3932
3943
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
3933
3944
|
return sequenceWalletProvider;
|
|
3934
3945
|
};
|
|
@@ -33,10 +33,14 @@ export declare class DefaultChainIdTracker {
|
|
|
33
33
|
setDefaultChainId(chainId: number): void;
|
|
34
34
|
getDefaultChainId(): number;
|
|
35
35
|
}
|
|
36
|
+
export type SequenceClientOptions = {
|
|
37
|
+
defaultChainId?: number;
|
|
38
|
+
defaultEIP6492?: boolean;
|
|
39
|
+
};
|
|
36
40
|
/**
|
|
37
41
|
* This is a wallet client for sequence wallet-webapp. It connects using *some* transport
|
|
38
42
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
39
|
-
*
|
|
43
|
+
*s
|
|
40
44
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
41
45
|
*/
|
|
42
46
|
export declare class SequenceClient {
|
|
@@ -44,7 +48,8 @@ export declare class SequenceClient {
|
|
|
44
48
|
private readonly defaultChainId;
|
|
45
49
|
private readonly callbacks;
|
|
46
50
|
readonly transport: ProviderTransport;
|
|
47
|
-
|
|
51
|
+
readonly defaultEIP6492: boolean;
|
|
52
|
+
constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions | number);
|
|
48
53
|
registerCallback<K extends keyof WalletEventTypes>(eventName: K, callback: WalletEventTypes[K]): () => void;
|
|
49
54
|
onOpen(callback: WalletEventTypes['open']): () => void;
|
|
50
55
|
onClose(callback: WalletEventTypes['close']): () => void;
|
|
@@ -66,6 +71,7 @@ export declare class SequenceClient {
|
|
|
66
71
|
disconnect(): Promise<void>;
|
|
67
72
|
send(request: JsonRpcRequest, chainId?: number): Promise<any>;
|
|
68
73
|
getNetworks(pull?: boolean): Promise<NetworkConfig[]>;
|
|
74
|
+
private usesEIP6492;
|
|
69
75
|
signMessage(message: ethers.BytesLike, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
|
|
70
76
|
signTypedData(typedData: TypedData, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
|
|
71
77
|
sendTransaction(tx: ethers.providers.TransactionRequest[] | ethers.providers.TransactionRequest, options?: OptionalChainId): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
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/auth": "1.1.
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "1.1.
|
|
20
|
-
"@0xsequence/
|
|
21
|
-
"@0xsequence/
|
|
22
|
-
"@0xsequence/
|
|
14
|
+
"@0xsequence/abi": "1.1.9",
|
|
15
|
+
"@0xsequence/auth": "1.1.9",
|
|
16
|
+
"@0xsequence/core": "1.1.9",
|
|
17
|
+
"@0xsequence/migration": "1.1.9",
|
|
18
|
+
"@0xsequence/account": "1.1.9",
|
|
19
|
+
"@0xsequence/network": "1.1.9",
|
|
20
|
+
"@0xsequence/relayer": "1.1.9",
|
|
21
|
+
"@0xsequence/wallet": "1.1.9",
|
|
22
|
+
"@0xsequence/utils": "1.1.9"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
package/src/client.ts
CHANGED
|
@@ -112,10 +112,15 @@ export class DefaultChainIdTracker {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
export type SequenceClientOptions = {
|
|
116
|
+
defaultChainId?: number
|
|
117
|
+
defaultEIP6492?: boolean
|
|
118
|
+
}
|
|
119
|
+
|
|
115
120
|
/**
|
|
116
121
|
* This is a wallet client for sequence wallet-webapp. It connects using *some* transport
|
|
117
122
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
118
|
-
*
|
|
123
|
+
*s
|
|
119
124
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
120
125
|
*/
|
|
121
126
|
export class SequenceClient {
|
|
@@ -125,7 +130,13 @@ export class SequenceClient {
|
|
|
125
130
|
|
|
126
131
|
public readonly transport: ProviderTransport
|
|
127
132
|
|
|
128
|
-
|
|
133
|
+
public readonly defaultEIP6492: boolean
|
|
134
|
+
|
|
135
|
+
constructor(
|
|
136
|
+
transport: ProviderTransport | MuxTransportTemplate,
|
|
137
|
+
store: ItemStore,
|
|
138
|
+
options?: SequenceClientOptions | number
|
|
139
|
+
) {
|
|
129
140
|
if (isMuxTransportTemplate(transport)) {
|
|
130
141
|
this.transport = MuxMessageProvider.new(transport)
|
|
131
142
|
} else if (isProviderTransport(transport)) {
|
|
@@ -134,6 +145,9 @@ export class SequenceClient {
|
|
|
134
145
|
throw new Error('Invalid transport')
|
|
135
146
|
}
|
|
136
147
|
|
|
148
|
+
const defaultChainId = typeof options === 'number' ? options : options?.defaultChainId
|
|
149
|
+
this.defaultEIP6492 = typeof options === 'number' ? false : options?.defaultEIP6492 ?? false
|
|
150
|
+
|
|
137
151
|
this.session = new SequenceClientSession(store)
|
|
138
152
|
this.defaultChainId = new DefaultChainIdTracker(store, defaultChainId)
|
|
139
153
|
|
|
@@ -366,15 +380,23 @@ export class SequenceClient {
|
|
|
366
380
|
return connectedSession.networks
|
|
367
381
|
}
|
|
368
382
|
|
|
383
|
+
private usesEIP6492(options?: OptionalEIP6492): boolean {
|
|
384
|
+
if (options?.eip6492 === undefined) {
|
|
385
|
+
return this.defaultEIP6492
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return options.eip6492
|
|
389
|
+
}
|
|
390
|
+
|
|
369
391
|
async signMessage(message: ethers.BytesLike, options?: OptionalEIP6492 & OptionalChainId): Promise<string> {
|
|
370
|
-
const method = options
|
|
392
|
+
const method = this.usesEIP6492(options) ? 'sequence_sign' : 'personal_sign'
|
|
371
393
|
|
|
372
394
|
// Address is ignored by the wallet webapp
|
|
373
395
|
return this.send({ method, params: [message, this.getAddress()] }, options?.chainId)
|
|
374
396
|
}
|
|
375
397
|
|
|
376
398
|
async signTypedData(typedData: TypedData, options?: OptionalEIP6492 & OptionalChainId): Promise<string> {
|
|
377
|
-
const method = options
|
|
399
|
+
const method = this.usesEIP6492(options) ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4'
|
|
378
400
|
|
|
379
401
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
380
402
|
// and it makes the client depend on ethers.
|
package/src/init.ts
CHANGED
|
@@ -26,6 +26,9 @@ export interface ProviderConfig {
|
|
|
26
26
|
// need to match
|
|
27
27
|
defaultNetwork?: ChainIdLike
|
|
28
28
|
|
|
29
|
+
// defaultEIP6492 defines if EIP-6492 is enabled by default when signing messages.
|
|
30
|
+
defaultEIP6492?: boolean
|
|
31
|
+
|
|
29
32
|
// networks is a configuration list of networks used by the wallet. This list
|
|
30
33
|
// is combined with the network list specified by sequence.js.
|
|
31
34
|
// notice that this can only replace the rpc urls on the dapp side,
|
|
@@ -115,9 +118,16 @@ export const initWallet = (partialConfig?: Partial<ProviderConfig>) => {
|
|
|
115
118
|
const itemStore = config.localStorage || useBestStore()
|
|
116
119
|
|
|
117
120
|
// Create client, provider and return signer
|
|
118
|
-
const client = new SequenceClient(
|
|
119
|
-
|
|
121
|
+
const client = new SequenceClient(
|
|
122
|
+
config.transports,
|
|
123
|
+
itemStore,
|
|
124
|
+
{
|
|
125
|
+
defaultChainId: defaultNetwork,
|
|
126
|
+
defaultEIP6492: config.defaultEIP6492
|
|
127
|
+
}
|
|
128
|
+
)
|
|
120
129
|
|
|
130
|
+
sequenceWalletProvider = new SequenceProvider(client, providerForChainId)
|
|
121
131
|
return sequenceWalletProvider
|
|
122
132
|
}
|
|
123
133
|
|