@0xsequence/provider 0.36.6 → 0.36.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.
- package/dist/0xsequence-provider.cjs.dev.js +5 -3
- package/dist/0xsequence-provider.cjs.prod.js +5 -3
- package/dist/0xsequence-provider.esm.js +5 -3
- package/dist/declarations/src/types.d.ts +61 -10
- package/package.json +8 -8
- package/src/transports/extension-transport/base-injected-transport.ts +2 -1
- package/src/transports/extension-transport/extension-message-handler.ts +2 -1
- package/src/transports/wallet-request-handler.ts +1 -0
- package/src/transports/window-transport/window-message-provider.ts +4 -7
- package/src/types.ts +87 -44
|
@@ -814,6 +814,8 @@ class WalletRequestHandler {
|
|
|
814
814
|
}
|
|
815
815
|
|
|
816
816
|
response.result = null; // success
|
|
817
|
+
|
|
818
|
+
break;
|
|
817
819
|
}
|
|
818
820
|
// smart wallet method
|
|
819
821
|
|
|
@@ -2690,7 +2692,7 @@ class WindowMessageProvider extends BaseProviderTransport {
|
|
|
2690
2692
|
if (!isBrowserExtension()) {
|
|
2691
2693
|
intent.options.origin = window.location.origin;
|
|
2692
2694
|
}
|
|
2693
|
-
} // encode intent as
|
|
2695
|
+
} // encode intent as base64 url-encoded param
|
|
2694
2696
|
|
|
2695
2697
|
|
|
2696
2698
|
windowSessionParams.set('intent', utils.base64EncodeObject(intent));
|
|
@@ -2961,7 +2963,7 @@ class ExtensionMessageHandler extends BaseWalletTransport {
|
|
|
2961
2963
|
}
|
|
2962
2964
|
|
|
2963
2965
|
sendMessage(message) {
|
|
2964
|
-
|
|
2966
|
+
utils.logger.info('[ExtensionMessageHandler send]', message);
|
|
2965
2967
|
this.port.postMessage(message);
|
|
2966
2968
|
}
|
|
2967
2969
|
|
|
@@ -3017,7 +3019,7 @@ class BaseInjectedTransport extends eventemitter2.EventEmitter2 {
|
|
|
3017
3019
|
return;
|
|
3018
3020
|
}
|
|
3019
3021
|
|
|
3020
|
-
|
|
3022
|
+
utils.logger.info('[received message]', message);
|
|
3021
3023
|
const requestIdx = message.idx;
|
|
3022
3024
|
const responseCallback = this.responseCallbacks.get(requestIdx);
|
|
3023
3025
|
|
|
@@ -814,6 +814,8 @@ class WalletRequestHandler {
|
|
|
814
814
|
}
|
|
815
815
|
|
|
816
816
|
response.result = null; // success
|
|
817
|
+
|
|
818
|
+
break;
|
|
817
819
|
}
|
|
818
820
|
// smart wallet method
|
|
819
821
|
|
|
@@ -2690,7 +2692,7 @@ class WindowMessageProvider extends BaseProviderTransport {
|
|
|
2690
2692
|
if (!isBrowserExtension()) {
|
|
2691
2693
|
intent.options.origin = window.location.origin;
|
|
2692
2694
|
}
|
|
2693
|
-
} // encode intent as
|
|
2695
|
+
} // encode intent as base64 url-encoded param
|
|
2694
2696
|
|
|
2695
2697
|
|
|
2696
2698
|
windowSessionParams.set('intent', utils.base64EncodeObject(intent));
|
|
@@ -2961,7 +2963,7 @@ class ExtensionMessageHandler extends BaseWalletTransport {
|
|
|
2961
2963
|
}
|
|
2962
2964
|
|
|
2963
2965
|
sendMessage(message) {
|
|
2964
|
-
|
|
2966
|
+
utils.logger.info('[ExtensionMessageHandler send]', message);
|
|
2965
2967
|
this.port.postMessage(message);
|
|
2966
2968
|
}
|
|
2967
2969
|
|
|
@@ -3017,7 +3019,7 @@ class BaseInjectedTransport extends eventemitter2.EventEmitter2 {
|
|
|
3017
3019
|
return;
|
|
3018
3020
|
}
|
|
3019
3021
|
|
|
3020
|
-
|
|
3022
|
+
utils.logger.info('[received message]', message);
|
|
3021
3023
|
const requestIdx = message.idx;
|
|
3022
3024
|
const responseCallback = this.responseCallbacks.get(requestIdx);
|
|
3023
3025
|
|
|
@@ -810,6 +810,8 @@ class WalletRequestHandler {
|
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
response.result = null; // success
|
|
813
|
+
|
|
814
|
+
break;
|
|
813
815
|
}
|
|
814
816
|
// smart wallet method
|
|
815
817
|
|
|
@@ -2686,7 +2688,7 @@ class WindowMessageProvider extends BaseProviderTransport {
|
|
|
2686
2688
|
if (!isBrowserExtension()) {
|
|
2687
2689
|
intent.options.origin = window.location.origin;
|
|
2688
2690
|
}
|
|
2689
|
-
} // encode intent as
|
|
2691
|
+
} // encode intent as base64 url-encoded param
|
|
2690
2692
|
|
|
2691
2693
|
|
|
2692
2694
|
windowSessionParams.set('intent', base64EncodeObject(intent));
|
|
@@ -2957,7 +2959,7 @@ class ExtensionMessageHandler extends BaseWalletTransport {
|
|
|
2957
2959
|
}
|
|
2958
2960
|
|
|
2959
2961
|
sendMessage(message) {
|
|
2960
|
-
|
|
2962
|
+
logger.info('[ExtensionMessageHandler send]', message);
|
|
2961
2963
|
this.port.postMessage(message);
|
|
2962
2964
|
}
|
|
2963
2965
|
|
|
@@ -3013,7 +3015,7 @@ class BaseInjectedTransport extends EventEmitter2 {
|
|
|
3013
3015
|
return;
|
|
3014
3016
|
}
|
|
3015
3017
|
|
|
3016
|
-
|
|
3018
|
+
logger.info('[received message]', message);
|
|
3017
3019
|
const requestIdx = message.idx;
|
|
3018
3020
|
const responseCallback = this.responseCallbacks.get(requestIdx);
|
|
3019
3021
|
|
|
@@ -78,22 +78,22 @@ export declare enum EventType {
|
|
|
78
78
|
DEBUG = "_debug"
|
|
79
79
|
}
|
|
80
80
|
export interface WalletEventTypes {
|
|
81
|
-
|
|
81
|
+
open: (openInfo: {
|
|
82
82
|
chainId?: string;
|
|
83
83
|
sessionId?: string;
|
|
84
84
|
session?: WalletSession;
|
|
85
85
|
error?: string;
|
|
86
86
|
}) => void;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
close: (error?: ProviderRpcError) => void;
|
|
88
|
+
connect: (connectDetails: ConnectDetails) => void;
|
|
89
|
+
disconnect: (error?: ProviderRpcError) => void;
|
|
90
|
+
accountsChanged: (accounts: string[]) => void;
|
|
91
|
+
chainChanged: (chainIdHex: string) => void;
|
|
92
|
+
networks: (networks: NetworkConfig[]) => void;
|
|
93
|
+
walletContext: (walletContext: WalletContext) => void;
|
|
94
94
|
}
|
|
95
95
|
export interface ProviderEventTypes extends WalletEventTypes {
|
|
96
|
-
|
|
96
|
+
message: (message: ProviderMessageResponse) => void;
|
|
97
97
|
}
|
|
98
98
|
export declare enum OpenState {
|
|
99
99
|
CLOSED = 0,
|
|
@@ -106,15 +106,63 @@ export declare enum InitState {
|
|
|
106
106
|
OK = 2
|
|
107
107
|
}
|
|
108
108
|
export interface ConnectOptions {
|
|
109
|
+
/** Specifies the default network a dapp would like to connect to. This field
|
|
110
|
+
* is optional as it can be provided a number of different ways. */
|
|
109
111
|
networkId?: string | number;
|
|
112
|
+
/** app name of the dapp which will be announced to user on connect screen */
|
|
110
113
|
app?: string;
|
|
114
|
+
/** origin hint of the dapp's host opening the wallet. This value will automatically
|
|
115
|
+
* be determined and verified for integrity, and can be omitted. */
|
|
111
116
|
origin?: string;
|
|
117
|
+
/** expiry number (in seconds) to expire connect session. default is 1 week of seconds. */
|
|
112
118
|
expiry?: number;
|
|
119
|
+
/** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
|
|
113
120
|
authorize?: boolean;
|
|
121
|
+
/** *Currently not used* askForEmail will prompt to give permission to the dapp to access email address */
|
|
114
122
|
askForEmail?: boolean;
|
|
123
|
+
/** refresh flag will force a full re-connect (ie. disconnect then connect again) */
|
|
115
124
|
refresh?: boolean;
|
|
125
|
+
/** keepWalletOpened will keep the wallet window opened after connecting. The default
|
|
126
|
+
* is to automatically close the wallet after connecting. */
|
|
116
127
|
keepWalletOpened?: boolean;
|
|
117
|
-
|
|
128
|
+
/** Options to further customize the wallet experience. */
|
|
129
|
+
settings?: Settings;
|
|
130
|
+
}
|
|
131
|
+
/** Options to further customize the wallet experience. */
|
|
132
|
+
export interface Settings {
|
|
133
|
+
/** Specify a wallet theme. `light` and `dark` are the main themes, to use other available
|
|
134
|
+
* themes, you can use the camel case version of the theme names in the wallet settings.
|
|
135
|
+
* For example: "Blue Dark" on wallet UI can be passed as "blueDark".
|
|
136
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
137
|
+
* to set when you open the wallet for user. */
|
|
138
|
+
theme?: ThemeOption;
|
|
139
|
+
/** Specify payment providers to use. If not specified,
|
|
140
|
+
* all available payment providers will be enabled.
|
|
141
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
142
|
+
* to set when you open the wallet for user. */
|
|
143
|
+
includedPaymentProviders?: PaymentProviderOption[];
|
|
144
|
+
/** Specify a default currency to use with payment providers.
|
|
145
|
+
* If not specified, the default is USDC.
|
|
146
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
147
|
+
* to set when you open the wallet for user. */
|
|
148
|
+
defaultFundingCurrency?: CurrencyOption;
|
|
149
|
+
/** If true, lockFundingCurrencyToDefault disables picking any currency provided by payment
|
|
150
|
+
* providers other than the defaultFundingCurrency.
|
|
151
|
+
* If false, it allows picking any currency provided by payment providers.
|
|
152
|
+
* The default is true.
|
|
153
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
154
|
+
* to set when you open the wallet for user. */
|
|
155
|
+
lockFundingCurrencyToDefault?: boolean;
|
|
156
|
+
/** Specify auxiliary data
|
|
157
|
+
*/
|
|
158
|
+
aux?: any;
|
|
159
|
+
}
|
|
160
|
+
/** light and dark are the main themes, to use other themes in wallet settings,
|
|
161
|
+
* you can use the camel case version of the name in the wallet settings.
|
|
162
|
+
* For example: "Blue Dark" on wallet UI can be passed as "blueDark" */
|
|
163
|
+
export declare type ThemeOption = 'light' | 'dark' | string;
|
|
164
|
+
export declare type PaymentProviderOption = 'moonpay' | 'wyre' | 'ramp';
|
|
165
|
+
export declare type CurrencyOption = 'usdc' | 'eth' | 'matic';
|
|
118
166
|
export interface ConnectDetails {
|
|
119
167
|
chainId?: string;
|
|
120
168
|
error?: string;
|
|
@@ -127,6 +175,9 @@ export declare type PromptConnectDetails = Pick<ConnectDetails, 'chainId' | 'err
|
|
|
127
175
|
export declare type OpenWalletIntent = {
|
|
128
176
|
type: 'connect';
|
|
129
177
|
options?: ConnectOptions;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'openWithOptions';
|
|
180
|
+
options?: ConnectOptions;
|
|
130
181
|
} | {
|
|
131
182
|
type: 'jsonRpcRequest';
|
|
132
183
|
method: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.9",
|
|
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",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@0xsequence/abi": "^0.36.
|
|
17
|
-
"@0xsequence/auth": "^0.36.
|
|
18
|
-
"@0xsequence/config": "^0.36.
|
|
19
|
-
"@0xsequence/network": "^0.36.
|
|
20
|
-
"@0xsequence/transactions": "^0.36.
|
|
21
|
-
"@0xsequence/utils": "^0.36.
|
|
22
|
-
"@0xsequence/wallet": "^0.36.
|
|
16
|
+
"@0xsequence/abi": "^0.36.9",
|
|
17
|
+
"@0xsequence/auth": "^0.36.9",
|
|
18
|
+
"@0xsequence/config": "^0.36.9",
|
|
19
|
+
"@0xsequence/network": "^0.36.9",
|
|
20
|
+
"@0xsequence/transactions": "^0.36.9",
|
|
21
|
+
"@0xsequence/utils": "^0.36.9",
|
|
22
|
+
"@0xsequence/wallet": "^0.36.9",
|
|
23
23
|
"@ethersproject/abstract-signer": "^5.5.0",
|
|
24
24
|
"@ethersproject/hash": "^5.5.0",
|
|
25
25
|
"@ethersproject/providers": "^5.5.1",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JsonRpcRequest, JsonRpcResponse } from '@0xsequence/network'
|
|
2
|
+
import { logger } from '@0xsequence/utils'
|
|
2
3
|
import { EventEmitter2 as EventEmitter } from 'eventemitter2'
|
|
3
4
|
import {
|
|
4
5
|
ProviderMessageResponseCallback,
|
|
@@ -32,7 +33,7 @@ export abstract class BaseInjectedTransport extends EventEmitter {
|
|
|
32
33
|
return
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
logger.info('[received message]', message)
|
|
36
37
|
|
|
37
38
|
const requestIdx = message.idx
|
|
38
39
|
const responseCallback = this.responseCallbacks.get(requestIdx)
|
|
@@ -2,6 +2,7 @@ import { WalletRequestHandler } from '../wallet-request-handler'
|
|
|
2
2
|
import { BaseWalletTransport } from '../base-wallet-transport'
|
|
3
3
|
import { InitState, ProviderMessage } from '../../types'
|
|
4
4
|
import { Runtime } from 'webextension-polyfill-ts'
|
|
5
|
+
import { logger } from '@0xsequence/utils'
|
|
5
6
|
|
|
6
7
|
export const CHANNEL_ID = 'sequence-extension-message-handler'
|
|
7
8
|
|
|
@@ -19,7 +20,7 @@ export class ExtensionMessageHandler extends BaseWalletTransport {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
sendMessage(message: ProviderMessage<any>) {
|
|
22
|
-
|
|
23
|
+
logger.info('[ExtensionMessageHandler send]', message)
|
|
23
24
|
this.port.postMessage(message)
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -82,7 +82,7 @@ export class WindowMessageProvider extends BaseProviderTransport {
|
|
|
82
82
|
this._init = InitState.NIL
|
|
83
83
|
this._sessionId = `${performance.now()}`
|
|
84
84
|
windowSessionParams.set('sid', this._sessionId)
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
if (intent) {
|
|
87
87
|
// for the window-transport, we eagerly/optimistically set the origin host
|
|
88
88
|
// when connecting to the wallet, however, this will be verified and enforced
|
|
@@ -96,7 +96,7 @@ export class WindowMessageProvider extends BaseProviderTransport {
|
|
|
96
96
|
intent.options.origin = window.location.origin
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
// encode intent as
|
|
99
|
+
// encode intent as base64 url-encoded param
|
|
100
100
|
windowSessionParams.set('intent', base64EncodeObject(intent))
|
|
101
101
|
}
|
|
102
102
|
if (networkId) {
|
|
@@ -109,16 +109,13 @@ export class WindowMessageProvider extends BaseProviderTransport {
|
|
|
109
109
|
|
|
110
110
|
if (isBrowserExtension()) {
|
|
111
111
|
windowSize = [450, 750]
|
|
112
|
-
windowPos = [
|
|
113
|
-
Math.abs(window.screen.width / 2 - windowSize[0] / 2),
|
|
114
|
-
Math.abs(window.screen.height / 2 - windowSize[1] / 2)
|
|
115
|
-
]
|
|
112
|
+
windowPos = [Math.abs(window.screen.width / 2 - windowSize[0] / 2), Math.abs(window.screen.height / 2 - windowSize[1] / 2)]
|
|
116
113
|
} else {
|
|
117
114
|
windowSize = [450, 750]
|
|
118
115
|
windowPos = [
|
|
119
116
|
Math.abs(window.screenX + window.innerWidth / 2 - windowSize[0] / 2),
|
|
120
117
|
Math.abs(window.screenY + window.innerHeight / 2 - windowSize[1] / 2)
|
|
121
|
-
]
|
|
118
|
+
]
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
const windowFeatures =
|
package/src/types.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface WalletTransport extends JsonRpcHandler, ProviderMessageTranspor
|
|
|
23
23
|
register(): void
|
|
24
24
|
unregister(): void
|
|
25
25
|
|
|
26
|
-
notifyOpen(openInfo: { chainId?: string
|
|
26
|
+
notifyOpen(openInfo: { chainId?: string; sessionId?: string; session?: WalletSession; error?: string }): void
|
|
27
27
|
notifyClose(error?: ProviderRpcError): void
|
|
28
28
|
|
|
29
29
|
notifyConnect(connectDetails: ConnectDetails): void
|
|
@@ -33,10 +33,10 @@ export interface WalletTransport extends JsonRpcHandler, ProviderMessageTranspor
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface ProviderMessage<T> {
|
|
36
|
-
idx: number
|
|
37
|
-
type: string
|
|
38
|
-
data: T
|
|
39
|
-
chainId?: number
|
|
36
|
+
idx: number // message id number
|
|
37
|
+
type: string // message type
|
|
38
|
+
data: T // the ethereum json-rpc payload
|
|
39
|
+
chainId?: number // chain id which the message is intended
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export type ProviderMessageRequest = ProviderMessage<JsonRpcRequest>
|
|
@@ -83,8 +83,8 @@ export class WindowSessionParams extends URLSearchParams {
|
|
|
83
83
|
|
|
84
84
|
export interface TransportSession {
|
|
85
85
|
sessionId?: string | null
|
|
86
|
-
networkId?: string | number | null
|
|
87
|
-
intent?: OpenWalletIntent
|
|
86
|
+
networkId?: string | number | null
|
|
87
|
+
intent?: OpenWalletIntent
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export enum EventType {
|
|
@@ -105,21 +105,21 @@ export enum EventType {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export interface WalletEventTypes {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
open: (openInfo: { chainId?: string; sessionId?: string; session?: WalletSession; error?: string }) => void
|
|
109
|
+
close: (error?: ProviderRpcError) => void
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
connect: (connectDetails: ConnectDetails) => void
|
|
112
|
+
disconnect: (error?: ProviderRpcError) => void
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
accountsChanged: (accounts: string[]) => void
|
|
115
|
+
chainChanged: (chainIdHex: string) => void
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
networks: (networks: NetworkConfig[]) => void
|
|
118
|
+
walletContext: (walletContext: WalletContext) => void
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export interface ProviderEventTypes extends WalletEventTypes {
|
|
122
|
-
|
|
122
|
+
message: (message: ProviderMessageResponse) => void
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export enum OpenState {
|
|
@@ -135,35 +135,79 @@ export enum InitState {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
export interface ConnectOptions {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
/** Specifies the default network a dapp would like to connect to. This field
|
|
139
|
+
* is optional as it can be provided a number of different ways. */
|
|
140
140
|
networkId?: string | number
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
/** app name of the dapp which will be announced to user on connect screen */
|
|
143
143
|
app?: string
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
/** origin hint of the dapp's host opening the wallet. This value will automatically
|
|
146
|
+
* be determined and verified for integrity, and can be omitted. */
|
|
147
147
|
origin?: string
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
/** expiry number (in seconds) to expire connect session. default is 1 week of seconds. */
|
|
150
150
|
expiry?: number
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
/** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
|
|
153
153
|
authorize?: boolean
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
/** *Currently not used* askForEmail will prompt to give permission to the dapp to access email address */
|
|
156
156
|
// TODO: this feature is currently not used as the wallet does not report emails yet
|
|
157
157
|
askForEmail?: boolean
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
/** refresh flag will force a full re-connect (ie. disconnect then connect again) */
|
|
160
160
|
refresh?: boolean
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
/** keepWalletOpened will keep the wallet window opened after connecting. The default
|
|
163
|
+
* is to automatically close the wallet after connecting. */
|
|
164
164
|
keepWalletOpened?: boolean
|
|
165
|
+
|
|
166
|
+
/** Options to further customize the wallet experience. */
|
|
167
|
+
settings?: Settings
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Options to further customize the wallet experience. */
|
|
171
|
+
export interface Settings {
|
|
172
|
+
/** Specify a wallet theme. `light` and `dark` are the main themes, to use other available
|
|
173
|
+
* themes, you can use the camel case version of the theme names in the wallet settings.
|
|
174
|
+
* For example: "Blue Dark" on wallet UI can be passed as "blueDark".
|
|
175
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
176
|
+
* to set when you open the wallet for user. */
|
|
177
|
+
theme?: ThemeOption
|
|
178
|
+
|
|
179
|
+
/** Specify payment providers to use. If not specified,
|
|
180
|
+
* all available payment providers will be enabled.
|
|
181
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
182
|
+
* to set when you open the wallet for user. */
|
|
183
|
+
includedPaymentProviders?: PaymentProviderOption[]
|
|
184
|
+
|
|
185
|
+
/** Specify a default currency to use with payment providers.
|
|
186
|
+
* If not specified, the default is USDC.
|
|
187
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
188
|
+
* to set when you open the wallet for user. */
|
|
189
|
+
defaultFundingCurrency?: CurrencyOption
|
|
190
|
+
|
|
191
|
+
/** If true, lockFundingCurrencyToDefault disables picking any currency provided by payment
|
|
192
|
+
* providers other than the defaultFundingCurrency.
|
|
193
|
+
* If false, it allows picking any currency provided by payment providers.
|
|
194
|
+
* The default is true.
|
|
195
|
+
* Note that this setting will not be persisted, use wallet.open with 'openWithOptions' intent
|
|
196
|
+
* to set when you open the wallet for user. */
|
|
197
|
+
lockFundingCurrencyToDefault?: boolean
|
|
198
|
+
|
|
199
|
+
/** Specify auxiliary data
|
|
200
|
+
*/
|
|
201
|
+
aux?: any
|
|
165
202
|
}
|
|
166
203
|
|
|
204
|
+
/** light and dark are the main themes, to use other themes in wallet settings,
|
|
205
|
+
* you can use the camel case version of the name in the wallet settings.
|
|
206
|
+
* For example: "Blue Dark" on wallet UI can be passed as "blueDark" */
|
|
207
|
+
export type ThemeOption = 'light' | 'dark' | string
|
|
208
|
+
export type PaymentProviderOption = 'moonpay' | 'wyre' | 'ramp'
|
|
209
|
+
export type CurrencyOption = 'usdc' | 'eth' | 'matic'
|
|
210
|
+
|
|
167
211
|
export interface ConnectDetails {
|
|
168
212
|
// chainId (in hex) and error are defined by EIP-1193 expected fields
|
|
169
213
|
chainId?: string
|
|
@@ -187,8 +231,9 @@ export interface ConnectDetails {
|
|
|
187
231
|
export type PromptConnectDetails = Pick<ConnectDetails, 'chainId' | 'error' | 'connected' | 'proof' | 'email'>
|
|
188
232
|
|
|
189
233
|
export type OpenWalletIntent =
|
|
190
|
-
{ type: 'connect'; options?: ConnectOptions }
|
|
191
|
-
{ type: '
|
|
234
|
+
| { type: 'connect'; options?: ConnectOptions }
|
|
235
|
+
| { type: 'openWithOptions'; options?: ConnectOptions }
|
|
236
|
+
| { type: 'jsonRpcRequest'; method: string }
|
|
192
237
|
|
|
193
238
|
export interface MessageToSign {
|
|
194
239
|
message?: string
|
|
@@ -230,23 +275,21 @@ export const ErrSignedInRequired = new ProviderError('Wallet is not signed in. C
|
|
|
230
275
|
|
|
231
276
|
// TODO: lets build some nice error handling tools, prob in /utils ...
|
|
232
277
|
|
|
233
|
-
export interface TypedEventEmitter<Events>{
|
|
234
|
-
addListener<E extends keyof Events>
|
|
235
|
-
on<E extends keyof Events>
|
|
236
|
-
once<E extends keyof Events>
|
|
237
|
-
prependListener<E extends keyof Events>
|
|
238
|
-
prependOnceListener<E extends keyof Events>
|
|
278
|
+
export interface TypedEventEmitter<Events> {
|
|
279
|
+
addListener<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
280
|
+
on<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
281
|
+
once<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
282
|
+
prependListener<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
283
|
+
prependOnceListener<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
239
284
|
|
|
240
285
|
off<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
241
|
-
removeAllListeners<E extends keyof Events>
|
|
242
|
-
removeListener<E extends keyof Events>
|
|
286
|
+
removeAllListeners<E extends keyof Events>(event?: E): this
|
|
287
|
+
removeListener<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
243
288
|
|
|
244
|
-
emit<E extends keyof Events>
|
|
245
|
-
eventNames
|
|
246
|
-
listeners<E extends keyof Events>
|
|
247
|
-
listenerCount<E extends keyof Events>
|
|
289
|
+
emit<E extends keyof Events>(event: E, ...args: Arguments<Events[E]>): boolean
|
|
290
|
+
eventNames(): (keyof Events | string | symbol)[]
|
|
291
|
+
listeners<E extends keyof Events>(event: E): Function[]
|
|
292
|
+
listenerCount<E extends keyof Events>(event: E): number
|
|
248
293
|
}
|
|
249
294
|
|
|
250
|
-
type Arguments<T> = [T] extends [(...args: infer U) => any]
|
|
251
|
-
? U
|
|
252
|
-
: [T] extends [void] ? [] : [T]
|
|
295
|
+
type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T]
|