@0xsequence/provider 1.1.9 → 1.1.11
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.
|
@@ -3788,6 +3788,10 @@ class SequenceClient {
|
|
|
3788
3788
|
// Working with sendAsync is less idiomatic
|
|
3789
3789
|
// but transport uses it instead of send, so we wrap it
|
|
3790
3790
|
send(request, chainId) {
|
|
3791
|
+
// Internally when sending requests we use `legacy_sign`
|
|
3792
|
+
// to avoid the default EIP6492 behavior overriding an explicit
|
|
3793
|
+
// "legacy sign" request, so we map the method here.
|
|
3794
|
+
request.method = this.mapSignMethod(request.method);
|
|
3791
3795
|
return new Promise((resolve, reject) => {
|
|
3792
3796
|
this.transport.sendAsync(request, (error, response) => {
|
|
3793
3797
|
if (error) {
|
|
@@ -3814,14 +3818,48 @@ class SequenceClient {
|
|
|
3814
3818
|
}
|
|
3815
3819
|
return connectedSession.networks;
|
|
3816
3820
|
}
|
|
3817
|
-
|
|
3821
|
+
|
|
3822
|
+
// NOTICE: `legacy_sign` will get overriden by `send`
|
|
3823
|
+
// it is done this way to ensure that:
|
|
3824
|
+
// - `send` handles `personal_sign` as a request for the default sign method
|
|
3825
|
+
// - explicit `personal_sign` is not replaced by `sequence_sign` (if default is EI6492)
|
|
3826
|
+
signMethod(options) {
|
|
3827
|
+
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3828
|
+
return 'personal_sign';
|
|
3829
|
+
}
|
|
3830
|
+
return options.eip6492 ? 'sequence_sign' : 'legacy_sign';
|
|
3831
|
+
}
|
|
3832
|
+
signTypedDataMethod(options) {
|
|
3818
3833
|
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3819
|
-
return
|
|
3834
|
+
return 'eth_signTypedData_v4';
|
|
3835
|
+
}
|
|
3836
|
+
return options.eip6492 ? 'sequence_signTypedData_v4' : 'legacy_signTypedData_v4';
|
|
3837
|
+
}
|
|
3838
|
+
mapSignMethod(method) {
|
|
3839
|
+
if (method === 'personal_sign') {
|
|
3840
|
+
if (this.defaultEIP6492) {
|
|
3841
|
+
return 'sequence_sign';
|
|
3842
|
+
} else {
|
|
3843
|
+
return 'personal_sign';
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
if (method === 'eth_signTypedData_v4') {
|
|
3847
|
+
if (this.defaultEIP6492) {
|
|
3848
|
+
return 'sequence_signTypedData_v4';
|
|
3849
|
+
} else {
|
|
3850
|
+
return 'eth_signTypedData_v4';
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
if (method === 'legacy_sign') {
|
|
3854
|
+
return 'personal_sign';
|
|
3855
|
+
}
|
|
3856
|
+
if (method === 'legacy_signTypedData_v4') {
|
|
3857
|
+
return 'eth_signTypedData_v4';
|
|
3820
3858
|
}
|
|
3821
|
-
return
|
|
3859
|
+
return method;
|
|
3822
3860
|
}
|
|
3823
3861
|
async signMessage(message, options) {
|
|
3824
|
-
const method = this.
|
|
3862
|
+
const method = this.signMethod(options);
|
|
3825
3863
|
|
|
3826
3864
|
// Address is ignored by the wallet webapp
|
|
3827
3865
|
return this.send({
|
|
@@ -3830,7 +3868,7 @@ class SequenceClient {
|
|
|
3830
3868
|
}, options == null ? void 0 : options.chainId);
|
|
3831
3869
|
}
|
|
3832
3870
|
async signTypedData(typedData, options) {
|
|
3833
|
-
const method = this.
|
|
3871
|
+
const method = this.signTypedDataMethod(options);
|
|
3834
3872
|
|
|
3835
3873
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
3836
3874
|
// and it makes the client depend on ethers.
|
|
@@ -3788,6 +3788,10 @@ class SequenceClient {
|
|
|
3788
3788
|
// Working with sendAsync is less idiomatic
|
|
3789
3789
|
// but transport uses it instead of send, so we wrap it
|
|
3790
3790
|
send(request, chainId) {
|
|
3791
|
+
// Internally when sending requests we use `legacy_sign`
|
|
3792
|
+
// to avoid the default EIP6492 behavior overriding an explicit
|
|
3793
|
+
// "legacy sign" request, so we map the method here.
|
|
3794
|
+
request.method = this.mapSignMethod(request.method);
|
|
3791
3795
|
return new Promise((resolve, reject) => {
|
|
3792
3796
|
this.transport.sendAsync(request, (error, response) => {
|
|
3793
3797
|
if (error) {
|
|
@@ -3814,14 +3818,48 @@ class SequenceClient {
|
|
|
3814
3818
|
}
|
|
3815
3819
|
return connectedSession.networks;
|
|
3816
3820
|
}
|
|
3817
|
-
|
|
3821
|
+
|
|
3822
|
+
// NOTICE: `legacy_sign` will get overriden by `send`
|
|
3823
|
+
// it is done this way to ensure that:
|
|
3824
|
+
// - `send` handles `personal_sign` as a request for the default sign method
|
|
3825
|
+
// - explicit `personal_sign` is not replaced by `sequence_sign` (if default is EI6492)
|
|
3826
|
+
signMethod(options) {
|
|
3827
|
+
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3828
|
+
return 'personal_sign';
|
|
3829
|
+
}
|
|
3830
|
+
return options.eip6492 ? 'sequence_sign' : 'legacy_sign';
|
|
3831
|
+
}
|
|
3832
|
+
signTypedDataMethod(options) {
|
|
3818
3833
|
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3819
|
-
return
|
|
3834
|
+
return 'eth_signTypedData_v4';
|
|
3835
|
+
}
|
|
3836
|
+
return options.eip6492 ? 'sequence_signTypedData_v4' : 'legacy_signTypedData_v4';
|
|
3837
|
+
}
|
|
3838
|
+
mapSignMethod(method) {
|
|
3839
|
+
if (method === 'personal_sign') {
|
|
3840
|
+
if (this.defaultEIP6492) {
|
|
3841
|
+
return 'sequence_sign';
|
|
3842
|
+
} else {
|
|
3843
|
+
return 'personal_sign';
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
if (method === 'eth_signTypedData_v4') {
|
|
3847
|
+
if (this.defaultEIP6492) {
|
|
3848
|
+
return 'sequence_signTypedData_v4';
|
|
3849
|
+
} else {
|
|
3850
|
+
return 'eth_signTypedData_v4';
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
if (method === 'legacy_sign') {
|
|
3854
|
+
return 'personal_sign';
|
|
3855
|
+
}
|
|
3856
|
+
if (method === 'legacy_signTypedData_v4') {
|
|
3857
|
+
return 'eth_signTypedData_v4';
|
|
3820
3858
|
}
|
|
3821
|
-
return
|
|
3859
|
+
return method;
|
|
3822
3860
|
}
|
|
3823
3861
|
async signMessage(message, options) {
|
|
3824
|
-
const method = this.
|
|
3862
|
+
const method = this.signMethod(options);
|
|
3825
3863
|
|
|
3826
3864
|
// Address is ignored by the wallet webapp
|
|
3827
3865
|
return this.send({
|
|
@@ -3830,7 +3868,7 @@ class SequenceClient {
|
|
|
3830
3868
|
}, options == null ? void 0 : options.chainId);
|
|
3831
3869
|
}
|
|
3832
3870
|
async signTypedData(typedData, options) {
|
|
3833
|
-
const method = this.
|
|
3871
|
+
const method = this.signTypedDataMethod(options);
|
|
3834
3872
|
|
|
3835
3873
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
3836
3874
|
// and it makes the client depend on ethers.
|
|
@@ -3784,6 +3784,10 @@ class SequenceClient {
|
|
|
3784
3784
|
// Working with sendAsync is less idiomatic
|
|
3785
3785
|
// but transport uses it instead of send, so we wrap it
|
|
3786
3786
|
send(request, chainId) {
|
|
3787
|
+
// Internally when sending requests we use `legacy_sign`
|
|
3788
|
+
// to avoid the default EIP6492 behavior overriding an explicit
|
|
3789
|
+
// "legacy sign" request, so we map the method here.
|
|
3790
|
+
request.method = this.mapSignMethod(request.method);
|
|
3787
3791
|
return new Promise((resolve, reject) => {
|
|
3788
3792
|
this.transport.sendAsync(request, (error, response) => {
|
|
3789
3793
|
if (error) {
|
|
@@ -3810,14 +3814,48 @@ class SequenceClient {
|
|
|
3810
3814
|
}
|
|
3811
3815
|
return connectedSession.networks;
|
|
3812
3816
|
}
|
|
3813
|
-
|
|
3817
|
+
|
|
3818
|
+
// NOTICE: `legacy_sign` will get overriden by `send`
|
|
3819
|
+
// it is done this way to ensure that:
|
|
3820
|
+
// - `send` handles `personal_sign` as a request for the default sign method
|
|
3821
|
+
// - explicit `personal_sign` is not replaced by `sequence_sign` (if default is EI6492)
|
|
3822
|
+
signMethod(options) {
|
|
3823
|
+
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3824
|
+
return 'personal_sign';
|
|
3825
|
+
}
|
|
3826
|
+
return options.eip6492 ? 'sequence_sign' : 'legacy_sign';
|
|
3827
|
+
}
|
|
3828
|
+
signTypedDataMethod(options) {
|
|
3814
3829
|
if ((options == null ? void 0 : options.eip6492) === undefined) {
|
|
3815
|
-
return
|
|
3830
|
+
return 'eth_signTypedData_v4';
|
|
3831
|
+
}
|
|
3832
|
+
return options.eip6492 ? 'sequence_signTypedData_v4' : 'legacy_signTypedData_v4';
|
|
3833
|
+
}
|
|
3834
|
+
mapSignMethod(method) {
|
|
3835
|
+
if (method === 'personal_sign') {
|
|
3836
|
+
if (this.defaultEIP6492) {
|
|
3837
|
+
return 'sequence_sign';
|
|
3838
|
+
} else {
|
|
3839
|
+
return 'personal_sign';
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
if (method === 'eth_signTypedData_v4') {
|
|
3843
|
+
if (this.defaultEIP6492) {
|
|
3844
|
+
return 'sequence_signTypedData_v4';
|
|
3845
|
+
} else {
|
|
3846
|
+
return 'eth_signTypedData_v4';
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
if (method === 'legacy_sign') {
|
|
3850
|
+
return 'personal_sign';
|
|
3851
|
+
}
|
|
3852
|
+
if (method === 'legacy_signTypedData_v4') {
|
|
3853
|
+
return 'eth_signTypedData_v4';
|
|
3816
3854
|
}
|
|
3817
|
-
return
|
|
3855
|
+
return method;
|
|
3818
3856
|
}
|
|
3819
3857
|
async signMessage(message, options) {
|
|
3820
|
-
const method = this.
|
|
3858
|
+
const method = this.signMethod(options);
|
|
3821
3859
|
|
|
3822
3860
|
// Address is ignored by the wallet webapp
|
|
3823
3861
|
return this.send({
|
|
@@ -3826,7 +3864,7 @@ class SequenceClient {
|
|
|
3826
3864
|
}, options == null ? void 0 : options.chainId);
|
|
3827
3865
|
}
|
|
3828
3866
|
async signTypedData(typedData, options) {
|
|
3829
|
-
const method = this.
|
|
3867
|
+
const method = this.signTypedDataMethod(options);
|
|
3830
3868
|
|
|
3831
3869
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
3832
3870
|
// and it makes the client depend on ethers.
|
|
@@ -71,7 +71,9 @@ export declare class SequenceClient {
|
|
|
71
71
|
disconnect(): Promise<void>;
|
|
72
72
|
send(request: JsonRpcRequest, chainId?: number): Promise<any>;
|
|
73
73
|
getNetworks(pull?: boolean): Promise<NetworkConfig[]>;
|
|
74
|
-
private
|
|
74
|
+
private signMethod;
|
|
75
|
+
private signTypedDataMethod;
|
|
76
|
+
private mapSignMethod;
|
|
75
77
|
signMessage(message: ethers.BytesLike, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
|
|
76
78
|
signTypedData(typedData: TypedData, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
|
|
77
79
|
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.11",
|
|
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/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "1.1.
|
|
20
|
-
"@0xsequence/
|
|
21
|
-
"@0xsequence/wallet": "1.1.
|
|
22
|
-
"@0xsequence/
|
|
14
|
+
"@0xsequence/abi": "1.1.11",
|
|
15
|
+
"@0xsequence/account": "1.1.11",
|
|
16
|
+
"@0xsequence/auth": "1.1.11",
|
|
17
|
+
"@0xsequence/core": "1.1.11",
|
|
18
|
+
"@0xsequence/migration": "1.1.11",
|
|
19
|
+
"@0xsequence/network": "1.1.11",
|
|
20
|
+
"@0xsequence/utils": "1.1.11",
|
|
21
|
+
"@0xsequence/wallet": "1.1.11",
|
|
22
|
+
"@0xsequence/relayer": "1.1.11"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
package/src/client.ts
CHANGED
|
@@ -132,11 +132,7 @@ export class SequenceClient {
|
|
|
132
132
|
|
|
133
133
|
public readonly defaultEIP6492: boolean
|
|
134
134
|
|
|
135
|
-
constructor(
|
|
136
|
-
transport: ProviderTransport | MuxTransportTemplate,
|
|
137
|
-
store: ItemStore,
|
|
138
|
-
options?: SequenceClientOptions | number
|
|
139
|
-
) {
|
|
135
|
+
constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions | number) {
|
|
140
136
|
if (isMuxTransportTemplate(transport)) {
|
|
141
137
|
this.transport = MuxMessageProvider.new(transport)
|
|
142
138
|
} else if (isProviderTransport(transport)) {
|
|
@@ -348,6 +344,12 @@ export class SequenceClient {
|
|
|
348
344
|
// Working with sendAsync is less idiomatic
|
|
349
345
|
// but transport uses it instead of send, so we wrap it
|
|
350
346
|
send(request: JsonRpcRequest, chainId?: number): Promise<any> {
|
|
347
|
+
|
|
348
|
+
// Internally when sending requests we use `legacy_sign`
|
|
349
|
+
// to avoid the default EIP6492 behavior overriding an explicit
|
|
350
|
+
// "legacy sign" request, so we map the method here.
|
|
351
|
+
request.method = this.mapSignMethod(request.method)
|
|
352
|
+
|
|
351
353
|
return new Promise((resolve, reject) => {
|
|
352
354
|
this.transport.sendAsync(
|
|
353
355
|
request,
|
|
@@ -380,23 +382,63 @@ export class SequenceClient {
|
|
|
380
382
|
return connectedSession.networks
|
|
381
383
|
}
|
|
382
384
|
|
|
383
|
-
|
|
385
|
+
// NOTICE: `legacy_sign` will get overriden by `send`
|
|
386
|
+
// it is done this way to ensure that:
|
|
387
|
+
// - `send` handles `personal_sign` as a request for the default sign method
|
|
388
|
+
// - explicit `personal_sign` is not replaced by `sequence_sign` (if default is EI6492)
|
|
389
|
+
private signMethod(options?: OptionalEIP6492) {
|
|
390
|
+
if (options?.eip6492 === undefined) {
|
|
391
|
+
return 'personal_sign'
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return options.eip6492 ? 'sequence_sign' : 'legacy_sign'
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
private signTypedDataMethod(options?: OptionalEIP6492) {
|
|
384
398
|
if (options?.eip6492 === undefined) {
|
|
385
|
-
return
|
|
399
|
+
return 'eth_signTypedData_v4'
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return options.eip6492 ? 'sequence_signTypedData_v4' : 'legacy_signTypedData_v4'
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
private mapSignMethod(method: string): string {
|
|
406
|
+
if (method === 'personal_sign') {
|
|
407
|
+
if (this.defaultEIP6492) {
|
|
408
|
+
return 'sequence_sign'
|
|
409
|
+
} else {
|
|
410
|
+
return 'personal_sign'
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (method === 'eth_signTypedData_v4') {
|
|
415
|
+
if (this.defaultEIP6492) {
|
|
416
|
+
return 'sequence_signTypedData_v4'
|
|
417
|
+
} else {
|
|
418
|
+
return 'eth_signTypedData_v4'
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (method === 'legacy_sign') {
|
|
423
|
+
return 'personal_sign'
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (method === 'legacy_signTypedData_v4') {
|
|
427
|
+
return 'eth_signTypedData_v4'
|
|
386
428
|
}
|
|
387
429
|
|
|
388
|
-
return
|
|
430
|
+
return method
|
|
389
431
|
}
|
|
390
432
|
|
|
391
433
|
async signMessage(message: ethers.BytesLike, options?: OptionalEIP6492 & OptionalChainId): Promise<string> {
|
|
392
|
-
const method = this.
|
|
434
|
+
const method = this.signMethod(options)
|
|
393
435
|
|
|
394
436
|
// Address is ignored by the wallet webapp
|
|
395
437
|
return this.send({ method, params: [message, this.getAddress()] }, options?.chainId)
|
|
396
438
|
}
|
|
397
439
|
|
|
398
440
|
async signTypedData(typedData: TypedData, options?: OptionalEIP6492 & OptionalChainId): Promise<string> {
|
|
399
|
-
const method = this.
|
|
441
|
+
const method = this.signTypedDataMethod(options)
|
|
400
442
|
|
|
401
443
|
// TODO: Stop using ethers for this, this is the only place where we use it
|
|
402
444
|
// and it makes the client depend on ethers.
|
package/src/init.ts
CHANGED
|
@@ -118,14 +118,10 @@ export const initWallet = (partialConfig?: Partial<ProviderConfig>) => {
|
|
|
118
118
|
const itemStore = config.localStorage || useBestStore()
|
|
119
119
|
|
|
120
120
|
// Create client, provider and return signer
|
|
121
|
-
const client = new SequenceClient(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
defaultChainId: defaultNetwork,
|
|
126
|
-
defaultEIP6492: config.defaultEIP6492
|
|
127
|
-
}
|
|
128
|
-
)
|
|
121
|
+
const client = new SequenceClient(config.transports, itemStore, {
|
|
122
|
+
defaultChainId: defaultNetwork,
|
|
123
|
+
defaultEIP6492: config.defaultEIP6492
|
|
124
|
+
})
|
|
129
125
|
|
|
130
126
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId)
|
|
131
127
|
return sequenceWalletProvider
|