@particle-network/wallet-plugin 1.0.7 → 2.1.0
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
34
34
|
__reExport(src_exports, require("@particle-network/wallet"), module.exports);
|
|
35
35
|
|
|
36
36
|
// src/version.ts
|
|
37
|
-
var version = "1.0
|
|
37
|
+
var version = "2.1.0";
|
|
38
38
|
|
|
39
39
|
// src/wallet.ts
|
|
40
40
|
var import_connector_core2 = require("@particle-network/connector-core");
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts", "../../src/version.ts", "../../src/wallet.ts", "../../src/createSolanaWallet.ts"],
|
|
4
|
-
"sourcesContent": ["export * from '@particle-network/wallet';\nexport * from './version';\nexport * from './wallet';\n", "export const version = '1.0
|
|
4
|
+
"sourcesContent": ["export * from '@particle-network/wallet';\nexport * from './version';\nexport * from './wallet';\n", "export const version = '2.1.0';\n", "import { isEVMChain, isSolanaChain, type Evaluate, type SolanaProvider } from '@particle-network/connector-core';\nimport { createPlugin, type Plugin } from '@particle-network/plugin-core';\nimport {\n walletEntryPlugin,\n type CustomMessageType,\n type EthereumProvider,\n type SolanaWallet,\n type WalletCore,\n type WalletEntryPlugin,\n type WalletOption,\n} from '@particle-network/wallet';\nimport { createSolanaWallet } from './createSolanaWallet';\n\nexport type WalletPlugin = Plugin<WalletEntryPlugin, void, WalletPluginProperties>;\n\nexport type OpenWalletParamers = Evaluate<Parameters<WalletEntryPlugin['openWallet']>[0]>;\nexport type GetWalletIFrameParamers = Evaluate<Parameters<WalletEntryPlugin['getWalletIFrame']>[0]>;\nexport type InitParamers = Evaluate<Omit<WalletOption, 'widgetIntegration' | 'entryPosition' | 'visible' | 'preload'>>;\n\nexport type WalletPluginProperties = {\n getWalletIFrame: (parameters?: GetWalletIFrameParamers) => ReturnType<WalletEntryPlugin['getWalletIFrame']>;\n openWallet: (parameters?: OpenWalletParamers) => void;\n destory: () => void;\n init: (parameters?: InitParamers) => void;\n overrideWalletOption: (parameters: Evaluate<Parameters<WalletEntryPlugin['overrideWalletOption']>[0]>) => void;\n};\n\nexport type WalletPluginParamers = Evaluate<\n Pick<WalletOption, 'widgetIntegration' | 'entryPosition' | 'visible' | 'preload' | 'themeType' | 'walletUrl'> & {\n customStyle?: Omit<WalletOption['customStyle'], 'supportChains'>;\n }\n>;\n\nenum MessageType {\n OpenAccountAndSecurity = 'open-account-and-security',\n GetUserInfo = 'get-user-info',\n GetPasskeyOption = 'get-passkey-option',\n}\n\nexport const wallet = (parameters: WalletPluginParamers = {}) => {\n const { widgetIntegration, entryPosition, visible, preload, themeType, customStyle, walletUrl } = parameters;\n\n return createPlugin<WalletEntryPlugin, void, WalletPluginProperties>((config) => ({\n get id() {\n return 'wallet';\n },\n get name() {\n return 'Particle Wallet';\n },\n getPlugin() {\n return walletEntryPlugin;\n },\n async onConnect(connection) {\n const connector = connection[0].connector;\n const provider: any = await connector.getProvider();\n const walletCore: WalletCore = {};\n if (connector.type === 'particleAuth') {\n if (connector.chainType === 'evm') {\n walletCore.ethereum = provider as EthereumProvider;\n } else {\n walletCore.solana = provider as SolanaWallet;\n }\n } else {\n if (connector.chainType === 'evm') {\n walletCore.ethereum = provider as unknown as EthereumProvider;\n } else {\n if ((this.getPlugin().walletCore?.solana as any)?.provider == provider) {\n walletCore.solana = this.getPlugin().walletCore?.solana;\n } else {\n const chainId = await connector.getChainId();\n walletCore.solana = createSolanaWallet(provider as SolanaProvider, chainId);\n }\n }\n }\n if (\n this.getPlugin().walletCore?.ethereum != walletCore.ethereum ||\n this.getPlugin().walletCore?.solana != walletCore.solana\n ) {\n // set custom event handler\n if (connector.type === 'particleAuth') {\n const customEventHandler = async (messageType: CustomMessageType) => {\n if (messageType === MessageType.OpenAccountAndSecurity) {\n (window as any).particle?._internal?.openAccountAndSecurity();\n } else if (messageType === MessageType.GetUserInfo) {\n return await (window as any).particle?._internal.getUserInfo();\n }\n };\n customEventHandler.type = 'auth' as const;\n walletCore.customEventHandler = customEventHandler;\n } else if (provider.isPasskey && provider.getPasskeyOption) {\n // passkey + aa\n const customEventHandler = async (messageType: string) => {\n if (messageType === MessageType.GetPasskeyOption) {\n const option = await await provider.getPasskeyOption();\n return option;\n }\n };\n customEventHandler.type = 'passkey' as const;\n walletCore.customEventHandler = customEventHandler;\n }\n\n const validChains = config.chains.filter((chain) =>\n connector.chainType === 'evm' ? isEVMChain(chain) : isSolanaChain(chain)\n );\n this.getPlugin().overrideWalletOption({\n entryPosition,\n visible,\n preload,\n customStyle: {\n ...this.getPlugin().walletOptions?.customStyle,\n supportChains: validChains.map((chain) => ({\n id: chain.id,\n chainType: connector.chainType,\n })),\n },\n });\n\n console.log('wallet plugin setWalletCore', walletCore);\n this.getPlugin().setWalletCore(walletCore);\n this.getPlugin().walletEntryCreate();\n } else {\n if (!this.getPlugin().walletCreated) {\n const validChains = config.chains.filter((chain) =>\n connector.chainType === 'evm' ? isEVMChain(chain) : isSolanaChain(chain)\n );\n this.getPlugin().overrideWalletOption({\n customStyle: {\n ...this.getPlugin()?.walletOptions?.customStyle,\n supportChains: validChains.map((chain) => ({\n id: chain.id,\n chainType: connector.chainType,\n })),\n },\n });\n this.getPlugin().walletEntryCreate();\n }\n }\n },\n async onDisconnect() {\n this.getPlugin().walletEntryDestroy();\n },\n getWalletIFrame(parameters) {\n return this.getPlugin().getWalletIFrame(parameters);\n },\n openWallet(parameters) {\n return this.getPlugin().openWallet(parameters);\n },\n destory() {\n this.getPlugin().destroy();\n },\n init(parameters) {\n this.getPlugin().init(config.projectConfig, {\n // \u53EF\u4EE5\u88AB\u8986\u76D6\n entryPosition,\n visible,\n preload,\n\n ...parameters,\n widgetIntegration,\n walletUrl,\n themeType: themeType ?? parameters?.themeType,\n customStyle: {\n ...parameters?.customStyle,\n ...customStyle,\n },\n });\n },\n overrideWalletOption(parameters) {\n const mergeOptions = {\n // \u53EF\u4EE5\u88AB\u8986\u76D6\n entryPosition,\n visible,\n preload,\n\n ...parameters,\n widgetIntegration,\n themeType: themeType ?? parameters?.themeType,\n customStyle: {\n ...parameters?.customStyle,\n ...customStyle,\n supportChains:\n parameters?.customStyle?.supportChains || this.getPlugin().walletOptions.customStyle?.supportChains,\n },\n };\n console.log('wallet plugin overrideWalletOption', mergeOptions);\n this.getPlugin().overrideWalletOption(mergeOptions);\n },\n }));\n};\n", "import { getChain, sendSolanaTransaction, type SolanaProvider } from '@particle-network/connector-core';\nimport type { SolanaWallet } from '@particle-network/wallet';\nimport type { Transaction, VersionedTransaction } from '@solana/web3.js';\n\nexport const createSolanaWallet = (\n provider: SolanaProvider,\n chainId: number\n): SolanaWallet & { provider: SolanaProvider } => {\n return {\n provider,\n publicKey: provider.publicKey,\n chainId: chainId || 101,\n on(event, listener) {\n provider.on(event, listener);\n return this;\n },\n removeListener(event, listener) {\n provider.removeListener(event, listener);\n return this;\n },\n async connect() {\n await provider.connect();\n },\n async signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T> {\n return await provider.signTransaction(transaction);\n },\n async signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]> {\n return await provider.signAllTransactions(transactions);\n },\n async signAndSendTransaction<T extends Transaction | VersionedTransaction>(\n transaction: T\n ): Promise<{\n signature: string;\n }> {\n const chain = getChain(chainId);\n const module = await import('@solana/web3.js');\n const { Connection } = module.default || module;\n const connection = new Connection(chain.rpcUrls.default.http[0]!);\n return await sendSolanaTransaction(provider, transaction, connection);\n },\n async signMessage(message: Uint8Array): Promise<{\n signature: Uint8Array;\n }> {\n return await provider.signMessage(message);\n },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EAAE,kBAAkB;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAAA,IACA,MAAM,eAAe;AACnB,WAAK,UAAU,EAAE,mBAAmB;AAAA,IACtC;AAAA,IACA,gBAAgBC,aAAY;AAC1B,aAAO,KAAK,UAAU,EAAE,gBAAgBA,WAAU;AAAA,IACpD;AAAA,IACA,WAAWA,aAAY;AACrB,aAAO,KAAK,UAAU,EAAE,WAAWA,WAAU;AAAA,IAC/C;AAAA,IACA,UAAU;AACR,WAAK,UAAU,EAAE,QAAQ;AAAA,IAC3B;AAAA,IACA,KAAKA,aAAY;AACf,WAAK,UAAU,EAAE,KAAK,OAAO,eAAe;AAAA,QAE1C;AAAA,QACA;AAAA,QACA;AAAA,QAEA,GAAGA;AAAA,QACH;AAAA,QACA;AAAA,QACA,WAAW,gCAAaA,eAAA,gBAAAA,YAAY;AAAA,QACpC,aAAa;AAAA,UACX,GAAGA,eAAA,gBAAAA,YAAY;AAAA,UACf,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,qBAAqBA,aAAY;AAvKrC;AAwKM,YAAM,eAAe;AAAA,QAEnB;AAAA,QACA;AAAA,QACA;AAAA,QAEA,GAAGA;AAAA,QACH;AAAA,QACA,WAAW,gCAAaA,eAAA,gBAAAA,YAAY;AAAA,QACpC,aAAa;AAAA,UACX,GAAGA,eAAA,gBAAAA,YAAY;AAAA,UACf,GAAG;AAAA,UACH,iBACE,KAAAA,eAAA,gBAAAA,YAAY,gBAAZ,mBAAyB,oBAAiB,UAAK,UAAU,EAAE,cAAc,gBAA/B,mBAA4C;AAAA,QAC1F;AAAA,MACF;AAEA,WAAK,UAAU,EAAE,qBAAqB,YAAY;AAAA,IACpD;AAAA,EACF,EAAE;AACJ;",
|
|
6
6
|
"names": ["import_connector_core", "module", "chainId", "_a", "_b", "_c", "parameters"]
|
|
7
7
|
}
|
package/dist/esm/index.mjs
CHANGED
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts", "../../src/version.ts", "../../src/wallet.ts", "../../src/createSolanaWallet.ts"],
|
|
4
|
-
"sourcesContent": ["export * from '@particle-network/wallet';\nexport * from './version';\nexport * from './wallet';\n", "export const version = '1.0
|
|
4
|
+
"sourcesContent": ["export * from '@particle-network/wallet';\nexport * from './version';\nexport * from './wallet';\n", "export const version = '2.1.0';\n", "import { isEVMChain, isSolanaChain, type Evaluate, type SolanaProvider } from '@particle-network/connector-core';\nimport { createPlugin, type Plugin } from '@particle-network/plugin-core';\nimport {\n walletEntryPlugin,\n type CustomMessageType,\n type EthereumProvider,\n type SolanaWallet,\n type WalletCore,\n type WalletEntryPlugin,\n type WalletOption,\n} from '@particle-network/wallet';\nimport { createSolanaWallet } from './createSolanaWallet';\n\nexport type WalletPlugin = Plugin<WalletEntryPlugin, void, WalletPluginProperties>;\n\nexport type OpenWalletParamers = Evaluate<Parameters<WalletEntryPlugin['openWallet']>[0]>;\nexport type GetWalletIFrameParamers = Evaluate<Parameters<WalletEntryPlugin['getWalletIFrame']>[0]>;\nexport type InitParamers = Evaluate<Omit<WalletOption, 'widgetIntegration' | 'entryPosition' | 'visible' | 'preload'>>;\n\nexport type WalletPluginProperties = {\n getWalletIFrame: (parameters?: GetWalletIFrameParamers) => ReturnType<WalletEntryPlugin['getWalletIFrame']>;\n openWallet: (parameters?: OpenWalletParamers) => void;\n destory: () => void;\n init: (parameters?: InitParamers) => void;\n overrideWalletOption: (parameters: Evaluate<Parameters<WalletEntryPlugin['overrideWalletOption']>[0]>) => void;\n};\n\nexport type WalletPluginParamers = Evaluate<\n Pick<WalletOption, 'widgetIntegration' | 'entryPosition' | 'visible' | 'preload' | 'themeType' | 'walletUrl'> & {\n customStyle?: Omit<WalletOption['customStyle'], 'supportChains'>;\n }\n>;\n\nenum MessageType {\n OpenAccountAndSecurity = 'open-account-and-security',\n GetUserInfo = 'get-user-info',\n GetPasskeyOption = 'get-passkey-option',\n}\n\nexport const wallet = (parameters: WalletPluginParamers = {}) => {\n const { widgetIntegration, entryPosition, visible, preload, themeType, customStyle, walletUrl } = parameters;\n\n return createPlugin<WalletEntryPlugin, void, WalletPluginProperties>((config) => ({\n get id() {\n return 'wallet';\n },\n get name() {\n return 'Particle Wallet';\n },\n getPlugin() {\n return walletEntryPlugin;\n },\n async onConnect(connection) {\n const connector = connection[0].connector;\n const provider: any = await connector.getProvider();\n const walletCore: WalletCore = {};\n if (connector.type === 'particleAuth') {\n if (connector.chainType === 'evm') {\n walletCore.ethereum = provider as EthereumProvider;\n } else {\n walletCore.solana = provider as SolanaWallet;\n }\n } else {\n if (connector.chainType === 'evm') {\n walletCore.ethereum = provider as unknown as EthereumProvider;\n } else {\n if ((this.getPlugin().walletCore?.solana as any)?.provider == provider) {\n walletCore.solana = this.getPlugin().walletCore?.solana;\n } else {\n const chainId = await connector.getChainId();\n walletCore.solana = createSolanaWallet(provider as SolanaProvider, chainId);\n }\n }\n }\n if (\n this.getPlugin().walletCore?.ethereum != walletCore.ethereum ||\n this.getPlugin().walletCore?.solana != walletCore.solana\n ) {\n // set custom event handler\n if (connector.type === 'particleAuth') {\n const customEventHandler = async (messageType: CustomMessageType) => {\n if (messageType === MessageType.OpenAccountAndSecurity) {\n (window as any).particle?._internal?.openAccountAndSecurity();\n } else if (messageType === MessageType.GetUserInfo) {\n return await (window as any).particle?._internal.getUserInfo();\n }\n };\n customEventHandler.type = 'auth' as const;\n walletCore.customEventHandler = customEventHandler;\n } else if (provider.isPasskey && provider.getPasskeyOption) {\n // passkey + aa\n const customEventHandler = async (messageType: string) => {\n if (messageType === MessageType.GetPasskeyOption) {\n const option = await await provider.getPasskeyOption();\n return option;\n }\n };\n customEventHandler.type = 'passkey' as const;\n walletCore.customEventHandler = customEventHandler;\n }\n\n const validChains = config.chains.filter((chain) =>\n connector.chainType === 'evm' ? isEVMChain(chain) : isSolanaChain(chain)\n );\n this.getPlugin().overrideWalletOption({\n entryPosition,\n visible,\n preload,\n customStyle: {\n ...this.getPlugin().walletOptions?.customStyle,\n supportChains: validChains.map((chain) => ({\n id: chain.id,\n chainType: connector.chainType,\n })),\n },\n });\n\n console.log('wallet plugin setWalletCore', walletCore);\n this.getPlugin().setWalletCore(walletCore);\n this.getPlugin().walletEntryCreate();\n } else {\n if (!this.getPlugin().walletCreated) {\n const validChains = config.chains.filter((chain) =>\n connector.chainType === 'evm' ? isEVMChain(chain) : isSolanaChain(chain)\n );\n this.getPlugin().overrideWalletOption({\n customStyle: {\n ...this.getPlugin()?.walletOptions?.customStyle,\n supportChains: validChains.map((chain) => ({\n id: chain.id,\n chainType: connector.chainType,\n })),\n },\n });\n this.getPlugin().walletEntryCreate();\n }\n }\n },\n async onDisconnect() {\n this.getPlugin().walletEntryDestroy();\n },\n getWalletIFrame(parameters) {\n return this.getPlugin().getWalletIFrame(parameters);\n },\n openWallet(parameters) {\n return this.getPlugin().openWallet(parameters);\n },\n destory() {\n this.getPlugin().destroy();\n },\n init(parameters) {\n this.getPlugin().init(config.projectConfig, {\n // \u53EF\u4EE5\u88AB\u8986\u76D6\n entryPosition,\n visible,\n preload,\n\n ...parameters,\n widgetIntegration,\n walletUrl,\n themeType: themeType ?? parameters?.themeType,\n customStyle: {\n ...parameters?.customStyle,\n ...customStyle,\n },\n });\n },\n overrideWalletOption(parameters) {\n const mergeOptions = {\n // \u53EF\u4EE5\u88AB\u8986\u76D6\n entryPosition,\n visible,\n preload,\n\n ...parameters,\n widgetIntegration,\n themeType: themeType ?? parameters?.themeType,\n customStyle: {\n ...parameters?.customStyle,\n ...customStyle,\n supportChains:\n parameters?.customStyle?.supportChains || this.getPlugin().walletOptions.customStyle?.supportChains,\n },\n };\n console.log('wallet plugin overrideWalletOption', mergeOptions);\n this.getPlugin().overrideWalletOption(mergeOptions);\n },\n }));\n};\n", "import { getChain, sendSolanaTransaction, type SolanaProvider } from '@particle-network/connector-core';\nimport type { SolanaWallet } from '@particle-network/wallet';\nimport type { Transaction, VersionedTransaction } from '@solana/web3.js';\n\nexport const createSolanaWallet = (\n provider: SolanaProvider,\n chainId: number\n): SolanaWallet & { provider: SolanaProvider } => {\n return {\n provider,\n publicKey: provider.publicKey,\n chainId: chainId || 101,\n on(event, listener) {\n provider.on(event, listener);\n return this;\n },\n removeListener(event, listener) {\n provider.removeListener(event, listener);\n return this;\n },\n async connect() {\n await provider.connect();\n },\n async signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T> {\n return await provider.signTransaction(transaction);\n },\n async signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]> {\n return await provider.signAllTransactions(transactions);\n },\n async signAndSendTransaction<T extends Transaction | VersionedTransaction>(\n transaction: T\n ): Promise<{\n signature: string;\n }> {\n const chain = getChain(chainId);\n const module = await import('@solana/web3.js');\n const { Connection } = module.default || module;\n const connection = new Connection(chain.rpcUrls.default.http[0]!);\n return await sendSolanaTransaction(provider, transaction, connection);\n },\n async signMessage(message: Uint8Array): Promise<{\n signature: Uint8Array;\n }> {\n return await provider.signMessage(message);\n },\n async switchChain(chainId: number) {\n throw new Error('Wallet not support switch chain.');\n },\n };\n};\n"],
|
|
5
5
|
"mappings": ";AAAA,cAAc;;;ACAP,IAAM,UAAU;;;ACAvB,SAAS,YAAY,qBAAyD;AAC9E,SAAS,oBAAiC;AAC1C;AAAA,EACE;AAAA,OAOK;;;ACVP,SAAS,UAAU,6BAAkD;AAI9D,IAAM,qBAAqB,CAChC,UACA,YACgD;AAChD,SAAO;AAAA,IACL;AAAA,IACA,WAAW,SAAS;AAAA,IACpB,SAAS,WAAW;AAAA,IACpB,GAAG,OAAO,UAAU;AAClB,eAAS,GAAG,OAAO,QAAQ;AAC3B,aAAO;AAAA,IACT;AAAA,IACA,eAAe,OAAO,UAAU;AAC9B,eAAS,eAAe,OAAO,QAAQ;AACvC,aAAO;AAAA,IACT;AAAA,IACA,MAAM,UAAU;AACd,YAAM,SAAS,QAAQ;AAAA,IACzB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,QACL;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,qBAAqBA,aAAY;AAvKrC;AAwKM,YAAM,eAAe;AAAA,QAEnB;AAAA,QACA;AAAA,QACA;AAAA,QAEA,GAAGA;AAAA,QACH;AAAA,QACA,WAAW,gCAAaA,eAAA,gBAAAA,YAAY;AAAA,QACpC,aAAa;AAAA,UACX,GAAGA,eAAA,gBAAAA,YAAY;AAAA,UACf,GAAG;AAAA,UACH,iBACE,KAAAA,eAAA,gBAAAA,YAAY,gBAAZ,mBAAyB,oBAAiB,UAAK,UAAU,EAAE,cAAc,gBAA/B,mBAA4C;AAAA,QAC1F;AAAA,MACF;AAEA,WAAK,UAAU,EAAE,qBAAqB,YAAY;AAAA,IACpD;AAAA,EACF,EAAE;AACJ;",
|
|
6
6
|
"names": ["chainId", "_a", "_b", "_c", "parameters"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/wallet-plugin",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"typegen:watch": "tsc --emitDeclarationOnly --watch"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@particle-network/plugin-core": "^1.0
|
|
44
|
-
"@particle-network/wallet": "^2.0
|
|
43
|
+
"@particle-network/plugin-core": "^2.1.0",
|
|
44
|
+
"@particle-network/wallet": "^2.1.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "a8e8d55f7596adda56c6348b3e6a825bc6b9dcf0"
|
|
47
47
|
}
|