@0xsequence/provider 0.0.0-20230726184000 → 0.0.0-20230726193528

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.
@@ -3502,7 +3502,7 @@ class DefaultChainIdTracker {
3502
3502
  this.callbacks = [];
3503
3503
  this.store = store;
3504
3504
  this.startingChainId = startingChainId;
3505
- store.onItemChange(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, value => {
3505
+ store.onItemChange(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, value => {
3506
3506
  if (value) {
3507
3507
  const chainId = parseInt(value);
3508
3508
  this.callbacks.forEach(cb => cb(chainId));
@@ -3517,11 +3517,11 @@ class DefaultChainIdTracker {
3517
3517
  }
3518
3518
  setDefaultChainId(chainId) {
3519
3519
  if (chainId !== this.getDefaultChainId()) {
3520
- this.store.setItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, chainId.toString());
3520
+ this.store.setItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, chainId.toString());
3521
3521
  }
3522
3522
  }
3523
3523
  getDefaultChainId() {
3524
- const read = this.store.getItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY);
3524
+ const read = this.store.getItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY);
3525
3525
  if (!read || read.length === 0) {
3526
3526
  return this.startingChainId;
3527
3527
  }
@@ -3535,7 +3535,7 @@ class DefaultChainIdTracker {
3535
3535
  *
3536
3536
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3537
3537
  */
3538
- DefaultChainIdTracker.SESSION_LOCALSTORE_KEY = '@sequence.session.defaultChainId';
3538
+ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3539
3539
  class SequenceClient {
3540
3540
  constructor(transport, store, defaultChainId) {
3541
3541
  this.callbacks = {};
@@ -3712,8 +3712,12 @@ class SequenceClient {
3712
3712
  reject(error);
3713
3713
  } else if (response === undefined) {
3714
3714
  reject(new Error(`Got undefined response for request: ${request}`));
3715
+ } else if (typeof response === 'object' && response.error) {
3716
+ reject(response.error);
3717
+ } else if (typeof response === 'object' && response.result) {
3718
+ resolve(response.result);
3715
3719
  } else {
3716
- resolve(response);
3720
+ reject(new Error(`Got invalid response for request: ${request}`));
3717
3721
  }
3718
3722
  }, chainId || this.getChainId());
3719
3723
  });
@@ -3721,10 +3725,9 @@ class SequenceClient {
3721
3725
  async getNetworks(pull) {
3722
3726
  const connectedSession = this.session.connectedSession();
3723
3727
  if (pull) {
3724
- const nextNetworks = await this.send({
3728
+ connectedSession.networks = await this.send({
3725
3729
  method: 'sequence_getNetworks'
3726
3730
  });
3727
- connectedSession.networks = nextNetworks.result;
3728
3731
  this.session.setSession(connectedSession);
3729
3732
  }
3730
3733
  return connectedSession.networks;
@@ -3733,11 +3736,10 @@ class SequenceClient {
3733
3736
  const method = options != null && options.eip6492 ? 'sequence_sign' : 'personal_sign';
3734
3737
 
3735
3738
  // Address is ignored by the wallet webapp
3736
- const res = await this.send({
3739
+ return this.send({
3737
3740
  method,
3738
3741
  params: [message, this.getAddress()]
3739
3742
  }, options == null ? void 0 : options.chainId);
3740
- return res.result;
3741
3743
  }
3742
3744
  async signTypedData(typedData, options) {
3743
3745
  const method = options != null && options.eip6492 ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4';
@@ -3751,26 +3753,23 @@ class SequenceClient {
3751
3753
  // - The one provided in the typedData.domain.chainId
3752
3754
  // - The default chainId
3753
3755
 
3754
- const res = await this.send({
3756
+ return this.send({
3755
3757
  method,
3756
3758
  params: [this.getAddress(), encoded]
3757
3759
  }, (options == null ? void 0 : options.chainId) || typedData.domain.chainId && ethers.ethers.BigNumber.from(typedData.domain.chainId).toNumber() || this.getChainId());
3758
- return res.result;
3759
3760
  }
3760
3761
  async sendTransaction(tx, options) {
3761
3762
  const sequenceTxs = Array.isArray(tx) ? tx : [tx];
3762
3763
  const extendedTxs = toExtended(sequenceTxs);
3763
- const res = await this.send({
3764
+ return this.send({
3764
3765
  method: 'eth_sendTransaction',
3765
3766
  params: [extendedTxs]
3766
3767
  }, options == null ? void 0 : options.chainId);
3767
- return res.result;
3768
3768
  }
3769
3769
  async getWalletContext() {
3770
- const res = await this.send({
3770
+ return this.send({
3771
3771
  method: 'sequence_getWalletContext'
3772
3772
  });
3773
- return res.result;
3774
3773
  }
3775
3774
  async getOnchainWalletConfig(options) {
3776
3775
  // NOTICE: sequence_getWalletConfig sends the chainId as a param
@@ -3778,7 +3777,7 @@ class SequenceClient {
3778
3777
  method: 'sequence_getWalletConfig',
3779
3778
  params: [(options == null ? void 0 : options.chainId) || this.getChainId()]
3780
3779
  }, options == null ? void 0 : options.chainId);
3781
- return Array.isArray(res.result) ? res.result[0] : res.result;
3780
+ return Array.isArray(res) ? res[0] : res;
3782
3781
  }
3783
3782
 
3784
3783
  // NOTICE: We are leaving out all the "regular" methods os a tipical
@@ -3502,7 +3502,7 @@ class DefaultChainIdTracker {
3502
3502
  this.callbacks = [];
3503
3503
  this.store = store;
3504
3504
  this.startingChainId = startingChainId;
3505
- store.onItemChange(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, value => {
3505
+ store.onItemChange(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, value => {
3506
3506
  if (value) {
3507
3507
  const chainId = parseInt(value);
3508
3508
  this.callbacks.forEach(cb => cb(chainId));
@@ -3517,11 +3517,11 @@ class DefaultChainIdTracker {
3517
3517
  }
3518
3518
  setDefaultChainId(chainId) {
3519
3519
  if (chainId !== this.getDefaultChainId()) {
3520
- this.store.setItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, chainId.toString());
3520
+ this.store.setItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, chainId.toString());
3521
3521
  }
3522
3522
  }
3523
3523
  getDefaultChainId() {
3524
- const read = this.store.getItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY);
3524
+ const read = this.store.getItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY);
3525
3525
  if (!read || read.length === 0) {
3526
3526
  return this.startingChainId;
3527
3527
  }
@@ -3535,7 +3535,7 @@ class DefaultChainIdTracker {
3535
3535
  *
3536
3536
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3537
3537
  */
3538
- DefaultChainIdTracker.SESSION_LOCALSTORE_KEY = '@sequence.session.defaultChainId';
3538
+ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3539
3539
  class SequenceClient {
3540
3540
  constructor(transport, store, defaultChainId) {
3541
3541
  this.callbacks = {};
@@ -3712,8 +3712,12 @@ class SequenceClient {
3712
3712
  reject(error);
3713
3713
  } else if (response === undefined) {
3714
3714
  reject(new Error(`Got undefined response for request: ${request}`));
3715
+ } else if (typeof response === 'object' && response.error) {
3716
+ reject(response.error);
3717
+ } else if (typeof response === 'object' && response.result) {
3718
+ resolve(response.result);
3715
3719
  } else {
3716
- resolve(response);
3720
+ reject(new Error(`Got invalid response for request: ${request}`));
3717
3721
  }
3718
3722
  }, chainId || this.getChainId());
3719
3723
  });
@@ -3721,10 +3725,9 @@ class SequenceClient {
3721
3725
  async getNetworks(pull) {
3722
3726
  const connectedSession = this.session.connectedSession();
3723
3727
  if (pull) {
3724
- const nextNetworks = await this.send({
3728
+ connectedSession.networks = await this.send({
3725
3729
  method: 'sequence_getNetworks'
3726
3730
  });
3727
- connectedSession.networks = nextNetworks.result;
3728
3731
  this.session.setSession(connectedSession);
3729
3732
  }
3730
3733
  return connectedSession.networks;
@@ -3733,11 +3736,10 @@ class SequenceClient {
3733
3736
  const method = options != null && options.eip6492 ? 'sequence_sign' : 'personal_sign';
3734
3737
 
3735
3738
  // Address is ignored by the wallet webapp
3736
- const res = await this.send({
3739
+ return this.send({
3737
3740
  method,
3738
3741
  params: [message, this.getAddress()]
3739
3742
  }, options == null ? void 0 : options.chainId);
3740
- return res.result;
3741
3743
  }
3742
3744
  async signTypedData(typedData, options) {
3743
3745
  const method = options != null && options.eip6492 ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4';
@@ -3751,26 +3753,23 @@ class SequenceClient {
3751
3753
  // - The one provided in the typedData.domain.chainId
3752
3754
  // - The default chainId
3753
3755
 
3754
- const res = await this.send({
3756
+ return this.send({
3755
3757
  method,
3756
3758
  params: [this.getAddress(), encoded]
3757
3759
  }, (options == null ? void 0 : options.chainId) || typedData.domain.chainId && ethers.ethers.BigNumber.from(typedData.domain.chainId).toNumber() || this.getChainId());
3758
- return res.result;
3759
3760
  }
3760
3761
  async sendTransaction(tx, options) {
3761
3762
  const sequenceTxs = Array.isArray(tx) ? tx : [tx];
3762
3763
  const extendedTxs = toExtended(sequenceTxs);
3763
- const res = await this.send({
3764
+ return this.send({
3764
3765
  method: 'eth_sendTransaction',
3765
3766
  params: [extendedTxs]
3766
3767
  }, options == null ? void 0 : options.chainId);
3767
- return res.result;
3768
3768
  }
3769
3769
  async getWalletContext() {
3770
- const res = await this.send({
3770
+ return this.send({
3771
3771
  method: 'sequence_getWalletContext'
3772
3772
  });
3773
- return res.result;
3774
3773
  }
3775
3774
  async getOnchainWalletConfig(options) {
3776
3775
  // NOTICE: sequence_getWalletConfig sends the chainId as a param
@@ -3778,7 +3777,7 @@ class SequenceClient {
3778
3777
  method: 'sequence_getWalletConfig',
3779
3778
  params: [(options == null ? void 0 : options.chainId) || this.getChainId()]
3780
3779
  }, options == null ? void 0 : options.chainId);
3781
- return Array.isArray(res.result) ? res.result[0] : res.result;
3780
+ return Array.isArray(res) ? res[0] : res;
3782
3781
  }
3783
3782
 
3784
3783
  // NOTICE: We are leaving out all the "regular" methods os a tipical
@@ -3498,7 +3498,7 @@ class DefaultChainIdTracker {
3498
3498
  this.callbacks = [];
3499
3499
  this.store = store;
3500
3500
  this.startingChainId = startingChainId;
3501
- store.onItemChange(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, value => {
3501
+ store.onItemChange(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, value => {
3502
3502
  if (value) {
3503
3503
  const chainId = parseInt(value);
3504
3504
  this.callbacks.forEach(cb => cb(chainId));
@@ -3513,11 +3513,11 @@ class DefaultChainIdTracker {
3513
3513
  }
3514
3514
  setDefaultChainId(chainId) {
3515
3515
  if (chainId !== this.getDefaultChainId()) {
3516
- this.store.setItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, chainId.toString());
3516
+ this.store.setItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, chainId.toString());
3517
3517
  }
3518
3518
  }
3519
3519
  getDefaultChainId() {
3520
- const read = this.store.getItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY);
3520
+ const read = this.store.getItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY);
3521
3521
  if (!read || read.length === 0) {
3522
3522
  return this.startingChainId;
3523
3523
  }
@@ -3531,7 +3531,7 @@ class DefaultChainIdTracker {
3531
3531
  *
3532
3532
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3533
3533
  */
3534
- DefaultChainIdTracker.SESSION_LOCALSTORE_KEY = '@sequence.session.defaultChainId';
3534
+ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3535
3535
  class SequenceClient {
3536
3536
  constructor(transport, store, defaultChainId) {
3537
3537
  this.callbacks = {};
@@ -3708,8 +3708,12 @@ class SequenceClient {
3708
3708
  reject(error);
3709
3709
  } else if (response === undefined) {
3710
3710
  reject(new Error(`Got undefined response for request: ${request}`));
3711
+ } else if (typeof response === 'object' && response.error) {
3712
+ reject(response.error);
3713
+ } else if (typeof response === 'object' && response.result) {
3714
+ resolve(response.result);
3711
3715
  } else {
3712
- resolve(response);
3716
+ reject(new Error(`Got invalid response for request: ${request}`));
3713
3717
  }
3714
3718
  }, chainId || this.getChainId());
3715
3719
  });
@@ -3717,10 +3721,9 @@ class SequenceClient {
3717
3721
  async getNetworks(pull) {
3718
3722
  const connectedSession = this.session.connectedSession();
3719
3723
  if (pull) {
3720
- const nextNetworks = await this.send({
3724
+ connectedSession.networks = await this.send({
3721
3725
  method: 'sequence_getNetworks'
3722
3726
  });
3723
- connectedSession.networks = nextNetworks.result;
3724
3727
  this.session.setSession(connectedSession);
3725
3728
  }
3726
3729
  return connectedSession.networks;
@@ -3729,11 +3732,10 @@ class SequenceClient {
3729
3732
  const method = options != null && options.eip6492 ? 'sequence_sign' : 'personal_sign';
3730
3733
 
3731
3734
  // Address is ignored by the wallet webapp
3732
- const res = await this.send({
3735
+ return this.send({
3733
3736
  method,
3734
3737
  params: [message, this.getAddress()]
3735
3738
  }, options == null ? void 0 : options.chainId);
3736
- return res.result;
3737
3739
  }
3738
3740
  async signTypedData(typedData, options) {
3739
3741
  const method = options != null && options.eip6492 ? 'sequence_signTypedData_v4' : 'eth_signTypedData_v4';
@@ -3747,26 +3749,23 @@ class SequenceClient {
3747
3749
  // - The one provided in the typedData.domain.chainId
3748
3750
  // - The default chainId
3749
3751
 
3750
- const res = await this.send({
3752
+ return this.send({
3751
3753
  method,
3752
3754
  params: [this.getAddress(), encoded]
3753
3755
  }, (options == null ? void 0 : options.chainId) || typedData.domain.chainId && ethers.BigNumber.from(typedData.domain.chainId).toNumber() || this.getChainId());
3754
- return res.result;
3755
3756
  }
3756
3757
  async sendTransaction(tx, options) {
3757
3758
  const sequenceTxs = Array.isArray(tx) ? tx : [tx];
3758
3759
  const extendedTxs = toExtended(sequenceTxs);
3759
- const res = await this.send({
3760
+ return this.send({
3760
3761
  method: 'eth_sendTransaction',
3761
3762
  params: [extendedTxs]
3762
3763
  }, options == null ? void 0 : options.chainId);
3763
- return res.result;
3764
3764
  }
3765
3765
  async getWalletContext() {
3766
- const res = await this.send({
3766
+ return this.send({
3767
3767
  method: 'sequence_getWalletContext'
3768
3768
  });
3769
- return res.result;
3770
3769
  }
3771
3770
  async getOnchainWalletConfig(options) {
3772
3771
  // NOTICE: sequence_getWalletConfig sends the chainId as a param
@@ -3774,7 +3773,7 @@ class SequenceClient {
3774
3773
  method: 'sequence_getWalletConfig',
3775
3774
  params: [(options == null ? void 0 : options.chainId) || this.getChainId()]
3776
3775
  }, options == null ? void 0 : options.chainId);
3777
- return Array.isArray(res.result) ? res.result[0] : res.result;
3776
+ return Array.isArray(res) ? res[0] : res;
3778
3777
  }
3779
3778
 
3780
3779
  // NOTICE: We are leaving out all the "regular" methods os a tipical
@@ -1,4 +1,4 @@
1
- import { JsonRpcRequest, JsonRpcResponse, NetworkConfig } from "@0xsequence/network";
1
+ import { JsonRpcRequest, NetworkConfig } from "@0xsequence/network";
2
2
  import { ConnectDetails, ConnectOptions, ItemStore, MuxTransportTemplate, OpenWalletIntent, OptionalChainId, OptionalEIP6492, ProviderTransport, WalletSession } from "./index.js";
3
3
  import { commons } from "@0xsequence/core";
4
4
  import { TypedData } from "@0xsequence/utils";
@@ -34,7 +34,7 @@ export declare class SequenceClientSession {
34
34
  export declare class DefaultChainIdTracker {
35
35
  private store;
36
36
  private startingChainId;
37
- static readonly SESSION_LOCALSTORE_KEY = "@sequence.session.defaultChainId";
37
+ static readonly SESSION_CHAIN_ID_KEY = "@sequence.session.defaultChainId";
38
38
  callbacks: ((chainId: number) => void)[];
39
39
  constructor(store: ItemStore, startingChainId?: number);
40
40
  onDefaultChainIdChanged(callback: (chainId: number) => void): () => void;
@@ -70,7 +70,7 @@ export declare class SequenceClient {
70
70
  getAddress(): string;
71
71
  connect(options: ConnectOptions): Promise<ConnectDetails>;
72
72
  disconnect(): Promise<void>;
73
- send(request: JsonRpcRequest, chainId?: number): Promise<JsonRpcResponse>;
73
+ send(request: JsonRpcRequest, chainId?: number): Promise<any>;
74
74
  getNetworks(pull?: boolean): Promise<NetworkConfig[]>;
75
75
  signMessage(message: ethers.BytesLike, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
76
76
  signTypedData(typedData: TypedData, options?: OptionalEIP6492 & OptionalChainId): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "0.0.0-20230726184000",
3
+ "version": "0.0.0-20230726193528",
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/account": "0.0.0-20230726184000",
15
- "@0xsequence/core": "0.0.0-20230726184000",
16
- "@0xsequence/auth": "0.0.0-20230726184000",
17
- "@0xsequence/abi": "0.0.0-20230726184000",
18
- "@0xsequence/network": "0.0.0-20230726184000",
19
- "@0xsequence/migration": "0.0.0-20230726184000",
20
- "@0xsequence/relayer": "0.0.0-20230726184000",
21
- "@0xsequence/utils": "0.0.0-20230726184000",
22
- "@0xsequence/wallet": "0.0.0-20230726184000"
14
+ "@0xsequence/abi": "0.0.0-20230726193528",
15
+ "@0xsequence/account": "0.0.0-20230726193528",
16
+ "@0xsequence/migration": "0.0.0-20230726193528",
17
+ "@0xsequence/auth": "0.0.0-20230726193528",
18
+ "@0xsequence/core": "0.0.0-20230726193528",
19
+ "@0xsequence/network": "0.0.0-20230726193528",
20
+ "@0xsequence/relayer": "0.0.0-20230726193528",
21
+ "@0xsequence/utils": "0.0.0-20230726193528",
22
+ "@0xsequence/wallet": "0.0.0-20230726193528"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "ethers": ">=5.5 < 6"
package/src/client.ts CHANGED
@@ -74,7 +74,7 @@ export class SequenceClientSession {
74
74
  * track it locally using storage, that way the data stays always in sync.
75
75
  */
76
76
  export class DefaultChainIdTracker {
77
- static readonly SESSION_LOCALSTORE_KEY = '@sequence.session.defaultChainId'
77
+ static readonly SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId'
78
78
 
79
79
  callbacks: ((chainId: number) => void)[] = []
80
80
 
@@ -82,7 +82,7 @@ export class DefaultChainIdTracker {
82
82
  private store: ItemStore,
83
83
  private startingChainId: number = 1
84
84
  ) {
85
- store.onItemChange(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, (value: string | null) => {
85
+ store.onItemChange(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, (value: string | null) => {
86
86
  if (value) {
87
87
  const chainId = parseInt(value)
88
88
  this.callbacks.forEach(cb => cb(chainId))
@@ -99,12 +99,12 @@ export class DefaultChainIdTracker {
99
99
 
100
100
  setDefaultChainId(chainId: number) {
101
101
  if (chainId !== this.getDefaultChainId()) {
102
- this.store.setItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY, chainId.toString())
102
+ this.store.setItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY, chainId.toString())
103
103
  }
104
104
  }
105
105
 
106
106
  getDefaultChainId(): number {
107
- const read = this.store.getItem(DefaultChainIdTracker.SESSION_LOCALSTORE_KEY)
107
+ const read = this.store.getItem(DefaultChainIdTracker.SESSION_CHAIN_ID_KEY)
108
108
 
109
109
  if (!read || read.length === 0) {
110
110
  return this.startingChainId
@@ -312,15 +312,19 @@ export class SequenceClient {
312
312
 
313
313
  // Working with sendAsync is less idiomatic
314
314
  // but transport uses it instead of send, so we wrap it
315
- send(request: JsonRpcRequest, chainId?: number): Promise<JsonRpcResponse> {
315
+ send(request: JsonRpcRequest, chainId?: number): Promise<any> {
316
316
  return new Promise((resolve, reject) => {
317
317
  this.transport.sendAsync(request, (error, response) => {
318
318
  if (error) {
319
319
  reject(error)
320
320
  } else if (response === undefined) {
321
321
  reject(new Error(`Got undefined response for request: ${request}`))
322
+ } else if (typeof response === 'object' && response.error) {
323
+ reject(response.error)
324
+ } else if (typeof response === 'object' && response.result) {
325
+ resolve(response.result)
322
326
  } else {
323
- resolve(response)
327
+ reject(new Error(`Got invalid response for request: ${request}`))
324
328
  }
325
329
  }, chainId || this.getChainId())
326
330
  })
@@ -330,8 +334,7 @@ export class SequenceClient {
330
334
  const connectedSession = this.session.connectedSession()
331
335
 
332
336
  if (pull) {
333
- const nextNetworks = await this.send({ method: 'sequence_getNetworks' })
334
- connectedSession.networks = nextNetworks.result
337
+ connectedSession.networks = await this.send({ method: 'sequence_getNetworks' })
335
338
  this.session.setSession(connectedSession)
336
339
  }
337
340
 
@@ -345,8 +348,7 @@ export class SequenceClient {
345
348
  const method = options?.eip6492 ? 'sequence_sign' : 'personal_sign'
346
349
 
347
350
  // Address is ignored by the wallet webapp
348
- const res = await this.send({ method, params: [message, this.getAddress()] }, options?.chainId)
349
- return res.result
351
+ return this.send({ method, params: [message, this.getAddress()] }, options?.chainId)
350
352
  }
351
353
 
352
354
  async signTypedData(
@@ -364,7 +366,7 @@ export class SequenceClient {
364
366
  // - The one provided in the typedData.domain.chainId
365
367
  // - The default chainId
366
368
 
367
- const res = await this.send({ method, params: [this.getAddress(), encoded] }, (
369
+ return this.send({ method, params: [this.getAddress(), encoded] }, (
368
370
  options?.chainId ||
369
371
  (
370
372
  typedData.domain.chainId &&
@@ -372,7 +374,6 @@ export class SequenceClient {
372
374
  ) ||
373
375
  this.getChainId()
374
376
  ))
375
- return res.result
376
377
  }
377
378
 
378
379
  async sendTransaction(
@@ -385,19 +386,17 @@ export class SequenceClient {
385
386
  const sequenceTxs = Array.isArray(tx) ? tx : [tx]
386
387
  const extendedTxs = toExtended(sequenceTxs)
387
388
 
388
- const res = await this.send({ method: 'eth_sendTransaction', params: [extendedTxs] }, options?.chainId )
389
- return res.result
389
+ return this.send({ method: 'eth_sendTransaction', params: [extendedTxs] }, options?.chainId )
390
390
  }
391
391
 
392
392
  async getWalletContext(): Promise<commons.context.VersionedContext> {
393
- const res = await this.send({ method: 'sequence_getWalletContext' })
394
- return res.result
393
+ return this.send({ method: 'sequence_getWalletContext' })
395
394
  }
396
395
 
397
396
  async getOnchainWalletConfig(options?: OptionalChainId): Promise<commons.config.Config> {
398
397
  // NOTICE: sequence_getWalletConfig sends the chainId as a param
399
398
  const res = await this.send({ method: 'sequence_getWalletConfig', params: [options?.chainId || this.getChainId()] }, options?.chainId)
400
- return Array.isArray(res.result) ? res.result[0] : res.result
399
+ return Array.isArray(res) ? res[0] : res
401
400
  }
402
401
 
403
402
  // NOTICE: We are leaving out all the "regular" methods os a tipical