@web3modal/wallet
Advanced tools
Comparing version 4.0.13 to 4.0.14-b3fbdad8.0
@@ -13,2 +13,4 @@ export const W3mFrameConstants = { | ||
PREFERRED_ACCOUNT_TYPE: 'PREFERRED_ACCOUNT_TYPE', | ||
SMART_ACCOUNT_ENABLED: 'SMART_ACCOUNT_ENABLED', | ||
SMART_ACCOUNT_ENABLED_NETWORKS: 'SMART_ACCOUNT_ENABLED_NETWORKS', | ||
APP_SWITCH_NETWORK: '@w3m-app/SWITCH_NETWORK', | ||
@@ -15,0 +17,0 @@ APP_CONNECT_EMAIL: '@w3m-app/CONNECT_EMAIL', |
@@ -61,4 +61,11 @@ import { W3mFrameStorage } from './W3mFrameStorage.js'; | ||
}, | ||
getPreferredAccountType(isEnabled) { | ||
if (!isEnabled) { | ||
return 'eoa'; | ||
} | ||
const storedType = W3mFrameStorage.get(W3mFrameConstants.PREFERRED_ACCOUNT_TYPE); | ||
return storedType || 'eoa'; | ||
}, | ||
isClient: typeof window !== 'undefined' | ||
}; | ||
//# sourceMappingURL=W3mFrameHelpers.js.map |
@@ -22,3 +22,2 @@ import { W3mFrame } from './W3mFrame.js'; | ||
this.smartAccountEnabledNetworksResolver = undefined; | ||
this.initSmartAccountResolver = undefined; | ||
this.setPreferredAccountResolver = undefined; | ||
@@ -91,6 +90,2 @@ this.w3mFrame = new W3mFrame(projectId, true); | ||
return this.onSmartAccountEnabledNetworksError(event); | ||
case W3mFrameConstants.FRAME_INIT_SMART_ACCOUNT_SUCCESS: | ||
return this.onInitSmartAccountSuccess(event); | ||
case W3mFrameConstants.FRAME_INIT_SMART_ACCOUNT_ERROR: | ||
return this.onInitSmartAccountError(event); | ||
case W3mFrameConstants.FRAME_SET_PREFERRED_ACCOUNT_SUCCESS: | ||
@@ -204,9 +199,2 @@ return this.onPreferSmartAccountSuccess(event); | ||
} | ||
async initSmartAccount() { | ||
await this.w3mFrame.frameLoadPromise; | ||
this.w3mFrame.events.postAppEvent({ type: W3mFrameConstants.APP_INIT_SMART_ACCOUNT }); | ||
return new Promise((resolve, reject) => { | ||
this.initSmartAccountResolver = { resolve, reject }; | ||
}); | ||
} | ||
async setPreferredAccount(type) { | ||
@@ -227,3 +215,3 @@ await this.w3mFrame.frameLoadPromise; | ||
type: W3mFrameConstants.APP_GET_USER, | ||
payload: { chainId } | ||
payload: { chainId, preferredAccountType: payload?.preferredAccountType } | ||
}); | ||
@@ -281,3 +269,3 @@ return new Promise((resolve, reject) => { | ||
if (event.type === W3mFrameConstants.FRAME_GET_USER_SUCCESS) { | ||
callback(); | ||
callback(event.payload); | ||
} | ||
@@ -297,12 +285,25 @@ }); | ||
} | ||
onInitSmartAccount(callback) { | ||
onSetPreferredAccount(callback) { | ||
this.w3mFrame.events.onFrameEvent(event => { | ||
if (event.type === W3mFrameConstants.FRAME_INIT_SMART_ACCOUNT_SUCCESS) { | ||
callback(event.payload.isDeployed); | ||
if (event.type === W3mFrameConstants.FRAME_SET_PREFERRED_ACCOUNT_SUCCESS) { | ||
callback(event.payload); | ||
} | ||
else if (event.type === W3mFrameConstants.FRAME_INIT_SMART_ACCOUNT_ERROR) { | ||
callback(false); | ||
else if (event.type === W3mFrameConstants.FRAME_SET_PREFERRED_ACCOUNT_ERROR) { | ||
callback({ type: 'eoa' }); | ||
} | ||
}); | ||
} | ||
onGetSmartAccountEnabledNetworks(callback) { | ||
this.w3mFrame.events.onFrameEvent(event => { | ||
if (event.type === W3mFrameConstants.FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS) { | ||
callback(event.payload.smartAccountEnabledNetworks); | ||
} | ||
else if (event.type === W3mFrameConstants.FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR) { | ||
callback([]); | ||
} | ||
}); | ||
} | ||
setSmartAccountEnabled(enabled) { | ||
W3mFrameStorage.set(W3mFrameConstants.SMART_ACCOUNT_ENABLED, String(enabled)); | ||
} | ||
onConnectEmailSuccess(event) { | ||
@@ -410,13 +411,9 @@ this.connectEmailResolver?.resolve(event.payload); | ||
onSmartAccountEnabledNetworksSuccess(event) { | ||
this.persistSmartAccountEnabledNetworks(event.payload.smartAccountEnabledNetworks); | ||
this.smartAccountEnabledNetworksResolver?.resolve(event.payload); | ||
} | ||
onSmartAccountEnabledNetworksError(event) { | ||
this.persistSmartAccountEnabledNetworks([]); | ||
this.smartAccountEnabledNetworksResolver?.reject(event.payload.message); | ||
} | ||
onInitSmartAccountSuccess(event) { | ||
this.initSmartAccountResolver?.resolve(event.payload); | ||
} | ||
onInitSmartAccountError(event) { | ||
this.initSmartAccountResolver?.reject(event.payload.message); | ||
} | ||
onPreferSmartAccountSuccess(event) { | ||
@@ -451,3 +448,6 @@ this.persistPreferredAccount(event.payload.type); | ||
} | ||
persistSmartAccountEnabledNetworks(networks) { | ||
W3mFrameStorage.set(W3mFrameConstants.SMART_ACCOUNT_ENABLED_NETWORKS, networks.join(',')); | ||
} | ||
} | ||
//# sourceMappingURL=W3mFrameProvider.js.map |
@@ -30,3 +30,6 @@ import { z } from 'zod'; | ||
export const AppConnectOtpRequest = z.object({ otp: z.string() }); | ||
export const AppGetUserRequest = z.object({ chainId: z.optional(z.number()) }); | ||
export const AppGetUserRequest = z.object({ | ||
chainId: z.optional(z.number()), | ||
preferredAccountType: z.optional(z.string()) | ||
}); | ||
export const AppUpdateEmailRequest = z.object({ email: z.string().email() }); | ||
@@ -58,3 +61,4 @@ export const AppUpdateEmailPrimaryOtpRequest = z.object({ otp: z.string() }); | ||
address: z.string(), | ||
chainId: z.number() | ||
chainId: z.number(), | ||
smartAccountDeployed: z.boolean() | ||
}); | ||
@@ -68,7 +72,3 @@ export const FrameIsConnectedResponse = z.object({ isConnected: z.boolean() }); | ||
}); | ||
export const FrameInitSmartAccountResponse = z.object({ | ||
address: z.string(), | ||
isDeployed: z.boolean() | ||
}); | ||
export const FrameSetPreferredAccountResponse = z.object({ type: z.string() }); | ||
export const FrameSetPreferredAccountResponse = z.object({ type: z.string(), address: z.string() }); | ||
export const RpcResponse = z.any(); | ||
@@ -325,6 +325,2 @@ export const RpcEthAccountsRequest = z.object({ | ||
})) | ||
.or(z.object({ | ||
type: zType('FRAME_INIT_SMART_ACCOUNT_SUCCESS'), | ||
payload: FrameInitSmartAccountResponse | ||
})) | ||
.or(z.object({ type: zType('FRAME_INIT_SMART_ACCOUNT_ERROR'), payload: zError })) | ||
@@ -331,0 +327,0 @@ .or(z.object({ |
import { z } from 'zod'; | ||
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcEthBlockNumber, RpcEthGetTransactionByHash, RpcEthGetBlockByNumber, RpcEthCall, RpcEthFeeHistory, RpcEthGetAccount, RpcEthGetBalance, RpcEthGetBlockyByHash, RpcUnistallFilter, RpcEthSyncing, RpcEthSendRawTransaction, RpcEthNewPendingTransactionFilter, RpcEthNewFilter, RpcEthNewBlockFilter, RpcEthMaxPriorityFeePerGas, RpcEthGetUncleCountByBlockNumber, RpcEthGetUncleCountByBlockHash, RpcEthGetTransactionReceipt, RpcEthGetTransactionCount, RpcEthGetTransactionByBlockNumberAndIndex, RpcEthGetTransactionByBlockHashAndIndex, RpcEthGetStorageAt, RpcEthGetProof, RpcEthGetLogs, RpcEthGetFilterLogs, RpcEthGetFilter, RpcEthGetCode, RcpEthGetBlockTransactionCountByNumber, RcpEthGetBlockTransactionCountByHash, RpcEthGetBlockReceipts, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameUpdateEmailSecondaryOtpResolver, AppUpdateEmailPrimaryOtpRequest, AppUpdateEmailSecondaryOtpRequest, AppSyncThemeRequest, RpcEthChainId, FrameSwitchNetworkResponse, AppSyncDappDataRequest, FrameGetSmartAccountEnabledNetworksResponse, FrameInitSmartAccountResponse } from './W3mFrameSchema.js'; | ||
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcEthBlockNumber, RpcEthGetTransactionByHash, RpcEthGetBlockByNumber, RpcEthCall, RpcEthFeeHistory, RpcEthGetAccount, RpcEthGetBalance, RpcEthGetBlockyByHash, RpcUnistallFilter, RpcEthSyncing, RpcEthSendRawTransaction, RpcEthNewPendingTransactionFilter, RpcEthNewFilter, RpcEthNewBlockFilter, RpcEthMaxPriorityFeePerGas, RpcEthGetUncleCountByBlockNumber, RpcEthGetUncleCountByBlockHash, RpcEthGetTransactionReceipt, RpcEthGetTransactionCount, RpcEthGetTransactionByBlockNumberAndIndex, RpcEthGetTransactionByBlockHashAndIndex, RpcEthGetStorageAt, RpcEthGetProof, RpcEthGetLogs, RpcEthGetFilterLogs, RpcEthGetFilter, RpcEthGetCode, RcpEthGetBlockTransactionCountByNumber, RcpEthGetBlockTransactionCountByHash, RpcEthGetBlockReceipts, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameUpdateEmailSecondaryOtpResolver, AppUpdateEmailPrimaryOtpRequest, AppUpdateEmailSecondaryOtpRequest, AppSyncThemeRequest, RpcEthChainId, FrameSwitchNetworkResponse, AppSyncDappDataRequest, FrameGetSmartAccountEnabledNetworksResponse } from './W3mFrameSchema.js'; | ||
//# sourceMappingURL=W3mFrameTypes.js.map |
@@ -13,2 +13,4 @@ export declare const W3mFrameConstants: { | ||
readonly PREFERRED_ACCOUNT_TYPE: "PREFERRED_ACCOUNT_TYPE"; | ||
readonly SMART_ACCOUNT_ENABLED: "SMART_ACCOUNT_ENABLED"; | ||
readonly SMART_ACCOUNT_ENABLED_NETWORKS: "SMART_ACCOUNT_ENABLED_NETWORKS"; | ||
readonly APP_SWITCH_NETWORK: "@w3m-app/SWITCH_NETWORK"; | ||
@@ -15,0 +17,0 @@ readonly APP_CONNECT_EMAIL: "@w3m-app/CONNECT_EMAIL"; |
@@ -8,3 +8,4 @@ export declare const W3mFrameHelpers: { | ||
checkIfRequestIsAllowed(request: unknown): boolean; | ||
getPreferredAccountType(isEnabled: boolean): 'eoa' | 'smartAccount'; | ||
isClient: boolean; | ||
}; |
@@ -19,3 +19,2 @@ import type { W3mFrameTypes } from './W3mFrameTypes.js'; | ||
private smartAccountEnabledNetworksResolver; | ||
private initSmartAccountResolver; | ||
private setPreferredAccountResolver; | ||
@@ -47,6 +46,2 @@ constructor(projectId: string); | ||
}>; | ||
initSmartAccount(): Promise<{ | ||
address: string; | ||
isDeployed: boolean; | ||
}>; | ||
setPreferredAccount(type: 'eoa' | 'smartAccount'): Promise<unknown>; | ||
@@ -57,2 +52,3 @@ connect(payload?: W3mFrameTypes.Requests['AppGetUserRequest']): Promise<{ | ||
address: string; | ||
smartAccountDeployed: boolean; | ||
}>; | ||
@@ -66,5 +62,10 @@ switchNetwork(chainId: number): Promise<{ | ||
onRpcResponse(callback: (request: unknown) => void): void; | ||
onIsConnected(callback: () => void): void; | ||
onIsConnected(callback: (request: W3mFrameTypes.Responses['FrameGetUserResponse']) => void): void; | ||
onNotConnected(callback: () => void): void; | ||
onInitSmartAccount(callback: (isDeployed: boolean) => void): void; | ||
onSetPreferredAccount(callback: ({ type, address }: { | ||
type: string; | ||
address?: string; | ||
}) => void): void; | ||
onGetSmartAccountEnabledNetworks(callback: (networks: number[]) => void): void; | ||
setSmartAccountEnabled(enabled: boolean): void; | ||
private onConnectEmailSuccess; | ||
@@ -101,4 +102,2 @@ private onConnectEmailError; | ||
private onSmartAccountEnabledNetworksError; | ||
private onInitSmartAccountSuccess; | ||
private onInitSmartAccountError; | ||
private onPreferSmartAccountSuccess; | ||
@@ -112,2 +111,3 @@ private onPreferSmartAccountError; | ||
private persistPreferredAccount; | ||
private persistSmartAccountEnabledNetworks; | ||
} |
import { z } from 'zod'; | ||
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcEthBlockNumber, RpcEthGetTransactionByHash, RpcEthGetBlockByNumber, RpcEthCall, RpcEthFeeHistory, RpcEthGetAccount, RpcEthGetBalance, RpcEthGetBlockyByHash, RpcUnistallFilter, RpcEthSyncing, RpcEthSendRawTransaction, RpcEthNewPendingTransactionFilter, RpcEthNewFilter, RpcEthNewBlockFilter, RpcEthMaxPriorityFeePerGas, RpcEthGetUncleCountByBlockNumber, RpcEthGetUncleCountByBlockHash, RpcEthGetTransactionReceipt, RpcEthGetTransactionCount, RpcEthGetTransactionByBlockNumberAndIndex, RpcEthGetTransactionByBlockHashAndIndex, RpcEthGetStorageAt, RpcEthGetProof, RpcEthGetLogs, RpcEthGetFilterLogs, RpcEthGetFilter, RpcEthGetCode, RcpEthGetBlockTransactionCountByNumber, RcpEthGetBlockTransactionCountByHash, RpcEthGetBlockReceipts, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameUpdateEmailSecondaryOtpResolver, AppUpdateEmailPrimaryOtpRequest, AppUpdateEmailSecondaryOtpRequest, AppSyncThemeRequest, RpcEthChainId, FrameSwitchNetworkResponse, AppSyncDappDataRequest, FrameGetSmartAccountEnabledNetworksResponse, FrameInitSmartAccountResponse } from './W3mFrameSchema.js'; | ||
import { W3mFrameSchema, AppConnectEmailRequest, AppConnectOtpRequest, AppSwitchNetworkRequest, FrameConnectEmailResponse, FrameGetChainIdResponse, FrameGetUserResponse, FrameIsConnectedResponse, RpcPersonalSignRequest, RpcResponse, RpcEthSendTransactionRequest, RpcEthSignTypedDataV4, RpcEthAccountsRequest, RpcEthEstimateGas, RpcEthGasPrice, RpcEthBlockNumber, RpcEthGetTransactionByHash, RpcEthGetBlockByNumber, RpcEthCall, RpcEthFeeHistory, RpcEthGetAccount, RpcEthGetBalance, RpcEthGetBlockyByHash, RpcUnistallFilter, RpcEthSyncing, RpcEthSendRawTransaction, RpcEthNewPendingTransactionFilter, RpcEthNewFilter, RpcEthNewBlockFilter, RpcEthMaxPriorityFeePerGas, RpcEthGetUncleCountByBlockNumber, RpcEthGetUncleCountByBlockHash, RpcEthGetTransactionReceipt, RpcEthGetTransactionCount, RpcEthGetTransactionByBlockNumberAndIndex, RpcEthGetTransactionByBlockHashAndIndex, RpcEthGetStorageAt, RpcEthGetProof, RpcEthGetLogs, RpcEthGetFilterLogs, RpcEthGetFilter, RpcEthGetCode, RcpEthGetBlockTransactionCountByNumber, RcpEthGetBlockTransactionCountByHash, RpcEthGetBlockReceipts, FrameSession, AppGetUserRequest, AppUpdateEmailRequest, FrameUpdateEmailSecondaryOtpResolver, AppUpdateEmailPrimaryOtpRequest, AppUpdateEmailSecondaryOtpRequest, AppSyncThemeRequest, RpcEthChainId, FrameSwitchNetworkResponse, AppSyncDappDataRequest, FrameGetSmartAccountEnabledNetworksResponse } from './W3mFrameSchema.js'; | ||
export declare namespace W3mFrameTypes { | ||
@@ -25,3 +25,2 @@ type AppEvent = z.infer<typeof W3mFrameSchema.appEvent>; | ||
FrameGetSmartAccountEnabledNetworksResponse: z.infer<typeof FrameGetSmartAccountEnabledNetworksResponse>; | ||
FrameInitSmartAccountResponse: z.infer<typeof FrameInitSmartAccountResponse>; | ||
} | ||
@@ -28,0 +27,0 @@ interface Network { |
{ | ||
"name": "@web3modal/wallet", | ||
"version": "4.0.13", | ||
"version": "4.0.14-b3fbdad8.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
173201
3355
1