@cowprotocol/iframe-transport 2.0.8 → 2.0.9

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +25 -3
  3. package/src/IframeTransport.d.ts +11 -0
  4. package/src/IframeTransport.js +42 -0
  5. package/src/IframeTransport.js.map +1 -0
  6. package/src/iframeRpcProvider/IframeRpcProviderBridge.d.ts +45 -0
  7. package/src/iframeRpcProvider/IframeRpcProviderBridge.js +143 -0
  8. package/src/iframeRpcProvider/IframeRpcProviderBridge.js.map +1 -0
  9. package/src/iframeRpcProvider/WidgetEthereumProvider.d.ts +134 -0
  10. package/src/iframeRpcProvider/WidgetEthereumProvider.js +300 -0
  11. package/src/iframeRpcProvider/WidgetEthereumProvider.js.map +1 -0
  12. package/src/iframeRpcProvider/iframeRpcProviderEvents.d.ts +31 -0
  13. package/src/iframeRpcProvider/iframeRpcProviderEvents.js +11 -0
  14. package/src/iframeRpcProvider/iframeRpcProviderEvents.js.map +1 -0
  15. package/src/iframeRpcProvider/utils.d.ts +4 -0
  16. package/src/iframeRpcProvider/utils.js +11 -0
  17. package/src/iframeRpcProvider/utils.js.map +1 -0
  18. package/src/index.d.ts +5 -0
  19. package/src/index.js +6 -0
  20. package/src/index.js.map +1 -0
  21. package/src/types.d.ts +59 -0
  22. package/src/types.js +2 -0
  23. package/src/types.js.map +1 -0
  24. package/.babelrc +0 -20
  25. package/jest.config.ts +0 -11
  26. package/project.json +0 -42
  27. package/src/IframeTransport.ts +0 -73
  28. package/src/iframeRpcProvider/IframeRpcProviderBridge.ts +0 -192
  29. package/src/iframeRpcProvider/WidgetEthereumProvider.ts +0 -489
  30. package/src/iframeRpcProvider/iframeRpcProviderEvents.ts +0 -40
  31. package/src/iframeRpcProvider/utils.ts +0 -18
  32. package/src/index.ts +0 -5
  33. package/src/types.ts +0 -75
  34. package/tsconfig.json +0 -21
  35. package/tsconfig.lib.json +0 -10
  36. package/tsconfig.spec.json +0 -20
@@ -1,40 +0,0 @@
1
- import { IframeTransport } from '../IframeTransport'
2
-
3
- import type { EIP6963ProviderInfo, JsonRpcRequestMessage, JsonRpcResponse, ProviderWcMetadata } from '../types'
4
-
5
- export interface ProviderRpcRequestPayload {
6
- rpcRequest: JsonRpcRequestMessage
7
- }
8
- export type ProviderRpcResponsePayload = {
9
- rpcResponse: JsonRpcResponse
10
- }
11
-
12
- export interface ProviderOnEventPayload {
13
- event: string
14
- params: unknown
15
- }
16
-
17
- export interface ProviderMetaInfoPayload {
18
- providerEip6963Info?: EIP6963ProviderInfo
19
- providerWcMetadata?: ProviderWcMetadata
20
- }
21
-
22
- export enum IframeRpcProviderEvents {
23
- PROVIDER_RPC_REQUEST = 'PROVIDER_RPC_REQUEST',
24
- PROVIDER_RPC_RESPONSE = 'PROVIDER_RPC_RESPONSE',
25
- PROVIDER_ON_EVENT = 'PROVIDER_ON_EVENT',
26
- SEND_PROVIDER_META_INFO = 'SEND_PROVIDER_META_INFO',
27
- REQUEST_PROVIDER_META_INFO = 'REQUEST_PROVIDER_META_INFO',
28
- }
29
-
30
- export interface IframeEventsPayloadMap {
31
- [IframeRpcProviderEvents.PROVIDER_RPC_REQUEST]: ProviderRpcRequestPayload
32
- [IframeRpcProviderEvents.PROVIDER_RPC_RESPONSE]: ProviderRpcResponsePayload
33
- [IframeRpcProviderEvents.PROVIDER_ON_EVENT]: ProviderOnEventPayload
34
- [IframeRpcProviderEvents.SEND_PROVIDER_META_INFO]: ProviderMetaInfoPayload
35
- [IframeRpcProviderEvents.REQUEST_PROVIDER_META_INFO]: null
36
- }
37
-
38
- export const iframeRpcProviderTransport = new IframeTransport<IframeEventsPayloadMap>(
39
- 'cowSwapIframeRpcProviderTransport',
40
- )
@@ -1,18 +0,0 @@
1
- import type { EIP6963ProviderDetail } from '@cowprotocol/types'
2
-
3
- import { EIP6963ProviderInfo, ProviderWcMetadata } from '../types'
4
-
5
- // TODO: Replace any with proper type definitions
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- export function getProviderWcMetadata(provider: any): ProviderWcMetadata | undefined {
8
- if (!provider.isWalletConnect) return
9
-
10
- return provider?.session?.peer?.metadata
11
- }
12
-
13
- export function getEip6963ProviderInfo(
14
- provider: unknown,
15
- eip6963Providers: EIP6963ProviderDetail[],
16
- ): EIP6963ProviderInfo | undefined {
17
- return eip6963Providers.find((p) => p.provider === provider)?.info
18
- }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export { IframeRpcProviderBridge } from './iframeRpcProvider/IframeRpcProviderBridge'
2
- export { WidgetEthereumProvider } from './iframeRpcProvider/WidgetEthereumProvider'
3
- export { IframeTransport } from './IframeTransport'
4
- export * from './iframeRpcProvider/iframeRpcProviderEvents'
5
- export * from './types'
package/src/types.ts DELETED
@@ -1,75 +0,0 @@
1
- export interface JsonRpcRequest {
2
- id?: number
3
- method: string
4
- // TODO: Replace any with proper type definitions
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- params?: any[]
7
- }
8
-
9
- export interface JsonRpcRequestMessage {
10
- jsonrpc: '2.0'
11
- // Optional in the request.
12
- id?: number
13
- method: string
14
- params: unknown[] | undefined
15
- }
16
-
17
- export interface BaseJsonRpcResponseMessage {
18
- // Required but null if not identified in request
19
- id: number
20
- jsonrpc: '2.0'
21
- }
22
-
23
- export interface JsonRpcSucessfulResponseMessage<TResult = unknown> extends BaseJsonRpcResponseMessage {
24
- result: TResult
25
- }
26
-
27
- export interface JsonRpcError<TData = unknown> {
28
- code: number
29
- message: string
30
- data?: TData
31
- }
32
-
33
- export interface JsonRpcErrorResponseMessage<TErrorData = unknown> extends BaseJsonRpcResponseMessage {
34
- error: JsonRpcError<TErrorData>
35
- }
36
-
37
- export type JsonRpcResponse = JsonRpcRequestMessage | JsonRpcErrorResponseMessage | JsonRpcSucessfulResponseMessage
38
-
39
- // https://eips.ethereum.org/EIPS/eip-1193
40
- export interface EthereumProvider {
41
- /**
42
- * Subscribes to Ethereum-related events.
43
- * @param event - The event to subscribe to.
44
- * @param args - Arguments for the event.
45
- */
46
- on(event: string, args: unknown): void
47
-
48
- /**
49
- * Sends a JSON-RPC request to the Ethereum provider and returns the response.
50
- * @param params - JSON-RPC request parameters.
51
- * @returns A promise that resolves with the response.
52
- */
53
- request<T>(params: JsonRpcRequest): Promise<T>
54
- }
55
-
56
- export type WindowListener = (event: MessageEvent<unknown>) => void
57
-
58
- export interface ProviderWcMetadata {
59
- name: string
60
- description: string
61
- url: string
62
- icons: string[]
63
- verifyUrl?: string
64
- redirect?: {
65
- native?: string
66
- universal?: string
67
- }
68
- }
69
-
70
- export interface EIP6963ProviderInfo {
71
- uuid: string
72
- name: string
73
- icon: string
74
- rdns: string
75
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "allowJs": false,
5
- "esModuleInterop": false,
6
- "allowSyntheticDefaultImports": true,
7
- "strict": true,
8
- "types": ["vite/client"]
9
- },
10
- "files": [],
11
- "include": [],
12
- "references": [
13
- {
14
- "path": "./tsconfig.lib.json"
15
- },
16
- {
17
- "path": "./tsconfig.spec.json"
18
- }
19
- ],
20
- "extends": "../../tsconfig.base.json"
21
- }
package/tsconfig.lib.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "declaration": true,
6
- "types": ["node"]
7
- },
8
- "include": ["src/**/*.ts"],
9
- "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
10
- }
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["jest", "node"]
7
- },
8
- "include": [
9
- "jest.config.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.ts",
12
- "src/**/*.test.tsx",
13
- "src/**/*.spec.tsx",
14
- "src/**/*.test.js",
15
- "src/**/*.spec.js",
16
- "src/**/*.test.jsx",
17
- "src/**/*.spec.jsx",
18
- "src/**/*.d.ts"
19
- ]
20
- }