@0xsequence/provider 0.0.0-20240829183049 → 0.0.0-20240903195246

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.
@@ -3995,7 +3995,10 @@ class SequenceClient {
3995
3995
  // to avoid the default EIP6492 behavior overriding an explicit
3996
3996
  // "legacy sign" request, so we map the method here.
3997
3997
  request.method = this.mapSignMethod(request.method);
3998
- return this.transport.request(request);
3998
+ const result = await this.transport.request(request);
3999
+
4000
+ // We may need to unwrap the response if it's a JSON-RPC response. ie. older universal wallet versions
4001
+ return unwrapJsonRpcResponse(result);
3999
4002
  }
4000
4003
  async getNetworks(pull) {
4001
4004
  const connectedSession = this.session.connectedSession();
@@ -4127,6 +4130,14 @@ class SequenceClient {
4127
4130
  // exclusively used for Sequence specific methods
4128
4131
  }
4129
4132
 
4133
+ // Unwrap a JsonRpcResponse result
4134
+ const unwrapJsonRpcResponse = response => {
4135
+ if (response && typeof response === 'object' && 'jsonrpc' in response && 'result' in response) {
4136
+ return response.result;
4137
+ }
4138
+ return response;
4139
+ };
4140
+
4130
4141
  const DefaultProviderConfig = {
4131
4142
  transports: {
4132
4143
  walletAppURL: 'https://sequence.app',
@@ -3995,7 +3995,10 @@ class SequenceClient {
3995
3995
  // to avoid the default EIP6492 behavior overriding an explicit
3996
3996
  // "legacy sign" request, so we map the method here.
3997
3997
  request.method = this.mapSignMethod(request.method);
3998
- return this.transport.request(request);
3998
+ const result = await this.transport.request(request);
3999
+
4000
+ // We may need to unwrap the response if it's a JSON-RPC response. ie. older universal wallet versions
4001
+ return unwrapJsonRpcResponse(result);
3999
4002
  }
4000
4003
  async getNetworks(pull) {
4001
4004
  const connectedSession = this.session.connectedSession();
@@ -4127,6 +4130,14 @@ class SequenceClient {
4127
4130
  // exclusively used for Sequence specific methods
4128
4131
  }
4129
4132
 
4133
+ // Unwrap a JsonRpcResponse result
4134
+ const unwrapJsonRpcResponse = response => {
4135
+ if (response && typeof response === 'object' && 'jsonrpc' in response && 'result' in response) {
4136
+ return response.result;
4137
+ }
4138
+ return response;
4139
+ };
4140
+
4130
4141
  const DefaultProviderConfig = {
4131
4142
  transports: {
4132
4143
  walletAppURL: 'https://sequence.app',
@@ -3991,7 +3991,10 @@ class SequenceClient {
3991
3991
  // to avoid the default EIP6492 behavior overriding an explicit
3992
3992
  // "legacy sign" request, so we map the method here.
3993
3993
  request.method = this.mapSignMethod(request.method);
3994
- return this.transport.request(request);
3994
+ const result = await this.transport.request(request);
3995
+
3996
+ // We may need to unwrap the response if it's a JSON-RPC response. ie. older universal wallet versions
3997
+ return unwrapJsonRpcResponse(result);
3995
3998
  }
3996
3999
  async getNetworks(pull) {
3997
4000
  const connectedSession = this.session.connectedSession();
@@ -4123,6 +4126,14 @@ class SequenceClient {
4123
4126
  // exclusively used for Sequence specific methods
4124
4127
  }
4125
4128
 
4129
+ // Unwrap a JsonRpcResponse result
4130
+ const unwrapJsonRpcResponse = response => {
4131
+ if (response && typeof response === 'object' && 'jsonrpc' in response && 'result' in response) {
4132
+ return response.result;
4133
+ }
4134
+ return response;
4135
+ };
4136
+
4126
4137
  const DefaultProviderConfig = {
4127
4138
  transports: {
4128
4139
  walletAppURL: 'https://sequence.app',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "0.0.0-20240829183049",
3
+ "version": "0.0.0-20240903195246",
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",
@@ -12,15 +12,15 @@
12
12
  "@databeat/tracker": "^0.9.1",
13
13
  "eventemitter2": "^6.4.5",
14
14
  "webextension-polyfill": "^0.10.0",
15
- "@0xsequence/abi": "0.0.0-20240829183049",
16
- "@0xsequence/account": "0.0.0-20240829183049",
17
- "@0xsequence/auth": "0.0.0-20240829183049",
18
- "@0xsequence/core": "0.0.0-20240829183049",
19
- "@0xsequence/migration": "0.0.0-20240829183049",
20
- "@0xsequence/network": "0.0.0-20240829183049",
21
- "@0xsequence/relayer": "0.0.0-20240829183049",
22
- "@0xsequence/utils": "0.0.0-20240829183049",
23
- "@0xsequence/wallet": "0.0.0-20240829183049"
15
+ "@0xsequence/abi": "0.0.0-20240903195246",
16
+ "@0xsequence/account": "0.0.0-20240903195246",
17
+ "@0xsequence/auth": "0.0.0-20240903195246",
18
+ "@0xsequence/core": "0.0.0-20240903195246",
19
+ "@0xsequence/migration": "0.0.0-20240903195246",
20
+ "@0xsequence/network": "0.0.0-20240903195246",
21
+ "@0xsequence/relayer": "0.0.0-20240903195246",
22
+ "@0xsequence/utils": "0.0.0-20240903195246",
23
+ "@0xsequence/wallet": "0.0.0-20240903195246"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "ethers": ">=6"
package/src/client.ts CHANGED
@@ -385,7 +385,10 @@ export class SequenceClient {
385
385
  // "legacy sign" request, so we map the method here.
386
386
  request.method = this.mapSignMethod(request.method)
387
387
 
388
- return this.transport.request(request)
388
+ const result = await this.transport.request(request)
389
+
390
+ // We may need to unwrap the response if it's a JSON-RPC response. ie. older universal wallet versions
391
+ return unwrapJsonRpcResponse(result)
389
392
  }
390
393
 
391
394
  async getNetworks(pull?: boolean): Promise<NetworkConfig[]> {
@@ -511,3 +514,12 @@ export class SequenceClient {
511
514
  // wallet-webapp does implement them, but this client is meant to be
512
515
  // exclusively used for Sequence specific methods
513
516
  }
517
+
518
+ // Unwrap a JsonRpcResponse result
519
+ const unwrapJsonRpcResponse = (response: any): any => {
520
+ if (response && typeof response === 'object' && 'jsonrpc' in response && 'result' in response) {
521
+ return response.result
522
+ }
523
+
524
+ return response
525
+ }