@walletconnect/utils
Advanced tools
Comparing version 1.0.0-beta.25 to 1.0.0-beta.26
/// <reference types="node" /> | ||
import { ITxData, IClientMeta, IParseURIResult, IJsonRpcResponseSuccess, IJsonRpcResponseError, IJsonRpcErrorMessage } from '@walletconnect/types'; | ||
import { ITxData, IClientMeta, IParseURIResult, IJsonRpcSubscription, IJsonRpcRequest, IJsonRpcResponseSuccess, IJsonRpcResponseError, IJsonRpcErrorMessage, IInternalEvent, IWalletConnectSession } from '@walletconnect/types'; | ||
export declare function convertArrayBufferToBuffer(arrayBuffer: ArrayBuffer): Buffer; | ||
@@ -44,2 +44,11 @@ export declare function convertArrayBufferToUtf8(arrayBuffer: ArrayBuffer): string; | ||
}; | ||
export declare function isJsonRpcSubscription(object: any): object is IJsonRpcSubscription; | ||
export declare function isJsonRpcRequest(object: any): object is IJsonRpcRequest; | ||
export declare function isJsonRpcResponseSuccess(object: any): object is IJsonRpcResponseSuccess; | ||
export declare function isJsonRpcResponseError(object: any): object is IJsonRpcResponseError; | ||
export declare function isInternalEvent(object: any): object is IInternalEvent; | ||
export declare function isWalletConnectSession(object: any): object is IWalletConnectSession; | ||
export declare function isReservedEvent(event: string): boolean; | ||
export declare const signingMethods: string[]; | ||
export declare function isSilentPayload(request: IJsonRpcRequest): boolean; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@walletconnect/utils", | ||
"version": "1.0.0-beta.25", | ||
"version": "1.0.0-beta.26", | ||
"description": "Utility Library for WalletConnect", | ||
@@ -61,3 +61,3 @@ "scripts": { | ||
"@ethersproject/strings": "^5.0.0-beta.125", | ||
"@walletconnect/types": "^1.0.0-beta.25", | ||
"@walletconnect/types": "^1.0.0-beta.26", | ||
"bignumber.js": "^8.1.1" | ||
@@ -64,0 +64,0 @@ }, |
@@ -57,2 +57,10 @@ # WalletConnect Utils | ||
function formatRpcError (error: Partial<IJsonRpcErrorMessage>): { code: number; message: string } | ||
function isJsonRpcSubscription (object: any): boolean | ||
function isJsonRpcRequest (object: any): boolean | ||
function isJsonRpcResponseSuccess (object: any): boolean | ||
function isJsonRpcResponseError (object: any): boolean | ||
function isInternalEvent (object: any): boolean | ||
function isWalletConnectSession (object: any): boolean | ||
function isReservedEvent (event: string): boolean | ||
``` |
@@ -16,5 +16,9 @@ import BigNumber from 'bignumber.js' | ||
IQueryParamsResult, | ||
IJsonRpcSubscription, | ||
IJsonRpcRequest, | ||
IJsonRpcResponseSuccess, | ||
IJsonRpcResponseError, | ||
IJsonRpcErrorMessage | ||
IJsonRpcErrorMessage, | ||
IInternalEvent, | ||
IWalletConnectSession | ||
} from '@walletconnect/types' | ||
@@ -561,1 +565,66 @@ | ||
} | ||
// -- typeGuards ----------------------------------------------------------- // | ||
export function isJsonRpcSubscription ( | ||
object: any | ||
): object is IJsonRpcSubscription { | ||
return typeof object.params === 'object' | ||
} | ||
export function isJsonRpcRequest (object: any): object is IJsonRpcRequest { | ||
return typeof object.method !== 'undefined' | ||
} | ||
export function isJsonRpcResponseSuccess ( | ||
object: any | ||
): object is IJsonRpcResponseSuccess { | ||
return typeof object.result !== 'undefined' | ||
} | ||
export function isJsonRpcResponseError ( | ||
object: any | ||
): object is IJsonRpcResponseError { | ||
return typeof object.error !== 'undefined' | ||
} | ||
export function isInternalEvent (object: any): object is IInternalEvent { | ||
return typeof object.event !== 'undefined' | ||
} | ||
export function isWalletConnectSession ( | ||
object: any | ||
): object is IWalletConnectSession { | ||
return typeof object.bridge !== 'undefined' | ||
} | ||
export function isReservedEvent (event: string) { | ||
const reservedEvents = [ | ||
'session_request', | ||
'session_update', | ||
'exchange_key', | ||
'connect', | ||
'disconnect' | ||
] | ||
return reservedEvents.includes(event) || event.startsWith('wc_') | ||
} | ||
export const signingMethods = [ | ||
'eth_sendTransaction', | ||
'eth_signTransction', | ||
'eth_sign', | ||
'eth_signTypedData', | ||
'eth_signTypedData_v1', | ||
'eth_signTypedData_v3', | ||
'personal_sign' | ||
] | ||
export function isSilentPayload (request: IJsonRpcRequest): boolean { | ||
if (request.method.startsWith('wc_')) { | ||
return true | ||
} | ||
if (signingMethods.includes(request.method)) { | ||
return false | ||
} | ||
return true | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
1114
66
717299