@0xsequence/provider
Advanced tools
Comparing version 0.0.0-20240903183150 to 0.0.0-20240903195246
{ | ||
"name": "@0xsequence/provider", | ||
"version": "0.0.0-20240903183150", | ||
"version": "0.0.0-20240903195246", | ||
"description": "provider sub-package for Sequence", | ||
@@ -15,11 +15,11 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider", | ||
"webextension-polyfill": "^0.10.0", | ||
"@0xsequence/abi": "0.0.0-20240903183150", | ||
"@0xsequence/account": "0.0.0-20240903183150", | ||
"@0xsequence/auth": "0.0.0-20240903183150", | ||
"@0xsequence/core": "0.0.0-20240903183150", | ||
"@0xsequence/network": "0.0.0-20240903183150", | ||
"@0xsequence/migration": "0.0.0-20240903183150", | ||
"@0xsequence/relayer": "0.0.0-20240903183150", | ||
"@0xsequence/utils": "0.0.0-20240903183150", | ||
"@0xsequence/wallet": "0.0.0-20240903183150" | ||
"@0xsequence/abi": "0.0.0-20240903195246", | ||
"@0xsequence/account": "0.0.0-20240903195246", | ||
"@0xsequence/auth": "0.0.0-20240903195246", | ||
"@0xsequence/core": "0.0.0-20240903195246", | ||
"@0xsequence/migration": "0.0.0-20240903195246", | ||
"@0xsequence/network": "0.0.0-20240903195246", | ||
"@0xsequence/relayer": "0.0.0-20240903195246", | ||
"@0xsequence/utils": "0.0.0-20240903195246", | ||
"@0xsequence/wallet": "0.0.0-20240903195246" | ||
}, | ||
@@ -26,0 +26,0 @@ "peerDependencies": { |
@@ -388,3 +388,6 @@ import { NetworkConfig } from '@0xsequence/network' | ||
return this.transport.request(request) | ||
const result = await this.transport.request(request) | ||
// We may need to unwrap the response if it's a JSON-RPC response. ie. older universal wallet versions | ||
return unwrapJsonRpcResponse(result) | ||
} | ||
@@ -515,1 +518,10 @@ | ||
} | ||
// Unwrap a JsonRpcResponse result | ||
const unwrapJsonRpcResponse = (response: any): any => { | ||
if (response && typeof response === 'object' && 'jsonrpc' in response && 'result' in response) { | ||
return response.result | ||
} | ||
return response | ||
} |
@@ -13,3 +13,3 @@ import { | ||
import { BaseWalletTransport } from '../base-wallet-transport' | ||
import { logger, base64DecodeObject } from '@0xsequence/utils' | ||
import { logger, base64DecodeObject, bigintReplacer } from '@0xsequence/utils' | ||
import { overrideLogs } from './overridelogs' | ||
@@ -108,3 +108,3 @@ | ||
// prepare payload | ||
const payload = JSON.stringify(message) | ||
const payload = JSON.stringify(message, bigintReplacer) | ||
@@ -111,0 +111,0 @@ // post-message to app. |
import { OpenWalletIntent, ProviderMessage, InitState, WindowSessionParams } from '../../types' | ||
import { BaseProviderTransport } from '../base-provider-transport' | ||
import { base64EncodeObject } from '@0xsequence/utils' | ||
import { base64EncodeObject, bigintReplacer } from '@0xsequence/utils' | ||
import { overrideLogs } from './overridelogs' | ||
@@ -117,3 +117,3 @@ | ||
sendMessage(message: ProviderMessage<unknown>) { | ||
const postedMessage = typeof message !== 'string' ? JSON.stringify(message) : message | ||
const postedMessage = typeof message !== 'string' ? JSON.stringify(message, bigintReplacer) : message | ||
console.log('Sending message to wallet:', postedMessage) | ||
@@ -120,0 +120,0 @@ window.ue?.sequencewallettransport?.sendmessagetowallet(postedMessage) |
@@ -13,3 +13,3 @@ import { | ||
import { BaseWalletTransport } from '../base-wallet-transport' | ||
import { logger, base64DecodeObject } from '@0xsequence/utils' | ||
import { logger, base64DecodeObject, bigintReviver, bigintReplacer } from '@0xsequence/utils' | ||
import { ethers } from 'ethers' | ||
@@ -97,10 +97,3 @@ | ||
try { | ||
request = JSON.parse(event.data, (key, value) => { | ||
// BigNumber compatibility with older versions of sequence.js | ||
if (isBigNumberSerialized(value)) { | ||
return BigInt(value.hex) | ||
} | ||
return value | ||
}) | ||
request = JSON.parse(event.data, bigintReviver) | ||
} catch (err) { | ||
@@ -130,3 +123,3 @@ // event is not a ProviderMessage JSON object, skip | ||
// prepare payload | ||
const payload = JSON.stringify(message) | ||
const payload = JSON.stringify(message, bigintReplacer) | ||
@@ -175,5 +168,1 @@ // post-message to app. | ||
} | ||
const isBigNumberSerialized = (value: any): boolean => { | ||
return typeof value === 'object' && value.type === 'BigNumber' && ethers.isHexString(value.hex) | ||
} |
import { OpenWalletIntent, ProviderMessage, InitState, WindowSessionParams } from '../../types' | ||
import { BaseProviderTransport } from '../base-provider-transport' | ||
import { logger, base64EncodeObject } from '@0xsequence/utils' | ||
import { logger, base64EncodeObject, bigintReplacer, bigintReviver } from '@0xsequence/utils' | ||
import { isBrowserExtension, isUnityPlugin } from '../../utils' | ||
@@ -175,3 +175,3 @@ | ||
try { | ||
message = JSON.parse(event.data) | ||
message = JSON.parse(event.data, bigintReviver) | ||
} catch (err) { | ||
@@ -195,5 +195,5 @@ // event is not a ProviderMessage JSON object, skip | ||
} | ||
const postedMessage = typeof message !== 'string' ? JSON.stringify(message) : message | ||
const postedMessage = typeof message !== 'string' ? JSON.stringify(message, bigintReplacer) : message | ||
this.walletWindow.postMessage(postedMessage, this.walletURL.origin) | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
700485
+ Added@0xsequence/abi@0.0.0-20240903195246(transitive)
+ Added@0xsequence/account@0.0.0-20240903195246(transitive)
+ Added@0xsequence/api@0.0.0-20240903195246(transitive)
+ Added@0xsequence/auth@0.0.0-20240903195246(transitive)
+ Added@0xsequence/core@0.0.0-20240903195246(transitive)
+ Added@0xsequence/indexer@0.0.0-20240903195246(transitive)
+ Added@0xsequence/metadata@0.0.0-20240903195246(transitive)
+ Added@0xsequence/migration@0.0.0-20240903195246(transitive)
+ Added@0xsequence/network@0.0.0-20240903195246(transitive)
+ Added@0xsequence/relayer@0.0.0-20240903195246(transitive)
+ Added@0xsequence/replacer@0.0.0-20240903195246(transitive)
+ Added@0xsequence/sessions@0.0.0-20240903195246(transitive)
+ Added@0xsequence/signhub@0.0.0-20240903195246(transitive)
+ Added@0xsequence/utils@0.0.0-20240903195246(transitive)
+ Added@0xsequence/wallet@0.0.0-20240903195246(transitive)
- Removed@0xsequence/abi@0.0.0-20240903183150(transitive)
- Removed@0xsequence/account@0.0.0-20240903183150(transitive)
- Removed@0xsequence/api@0.0.0-20240903183150(transitive)
- Removed@0xsequence/auth@0.0.0-20240903183150(transitive)
- Removed@0xsequence/core@0.0.0-20240903183150(transitive)
- Removed@0xsequence/indexer@0.0.0-20240903183150(transitive)
- Removed@0xsequence/metadata@0.0.0-20240903183150(transitive)
- Removed@0xsequence/migration@0.0.0-20240903183150(transitive)
- Removed@0xsequence/network@0.0.0-20240903183150(transitive)
- Removed@0xsequence/relayer@0.0.0-20240903183150(transitive)
- Removed@0xsequence/replacer@0.0.0-20240903183150(transitive)
- Removed@0xsequence/sessions@0.0.0-20240903183150(transitive)
- Removed@0xsequence/signhub@0.0.0-20240903183150(transitive)
- Removed@0xsequence/utils@0.0.0-20240903183150(transitive)
- Removed@0xsequence/wallet@0.0.0-20240903183150(transitive)