@bit-buccaneers/wallet-abstraction 0.0.22 → 0.0.24
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/dev.js +21 -1
- package/dist/dev.jsx +21 -1
- package/dist/index.js +21 -1
- package/dist/index.jsx +21 -1
- package/dist/lib/connectors/shared/wc-connector-factory.d.ts +2 -0
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -616,6 +616,7 @@ var createWcEvmConnector = (config2) => {
|
|
|
616
616
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
617
617
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
618
618
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
619
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
619
620
|
return {
|
|
620
621
|
...walletConfig2,
|
|
621
622
|
type: "evm",
|
|
@@ -647,6 +648,9 @@ var createWcEvmConnector = (config2) => {
|
|
|
647
648
|
throw new Error("No EVM account in session");
|
|
648
649
|
}
|
|
649
650
|
const address = account.split(":")[2];
|
|
651
|
+
if (isMobile() && signDeeplink) {
|
|
652
|
+
openDeeplink(signDeeplink);
|
|
653
|
+
}
|
|
650
654
|
const result = await requestWalletConnect(
|
|
651
655
|
"personal_sign",
|
|
652
656
|
[message, address],
|
|
@@ -661,6 +665,7 @@ var createWcSolanaConnector = (config2) => {
|
|
|
661
665
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
662
666
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
663
667
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
668
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
664
669
|
return {
|
|
665
670
|
...walletConfig2,
|
|
666
671
|
type: "solana",
|
|
@@ -687,6 +692,9 @@ var createWcSolanaConnector = (config2) => {
|
|
|
687
692
|
}
|
|
688
693
|
const pubkey = account.split(":")[2];
|
|
689
694
|
const messageBytes = new TextEncoder().encode(message);
|
|
695
|
+
if (isMobile() && signDeeplink) {
|
|
696
|
+
openDeeplink(signDeeplink);
|
|
697
|
+
}
|
|
690
698
|
const result = await requestWalletConnect(
|
|
691
699
|
"solana_signMessage",
|
|
692
700
|
{ message: bs582.encode(messageBytes), pubkey },
|
|
@@ -1298,6 +1306,9 @@ var checkEvmWalletInstalled = (connectorId) => {
|
|
|
1298
1306
|
return true;
|
|
1299
1307
|
}
|
|
1300
1308
|
};
|
|
1309
|
+
var cleanupWalletLocalStorage = () => {
|
|
1310
|
+
Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
|
|
1311
|
+
};
|
|
1301
1312
|
var getEvmConnectors = () => {
|
|
1302
1313
|
const wagmiConnectors = getConnectors(getEvmConfig());
|
|
1303
1314
|
const connectors = wagmiConnectors.map((c) => ({
|
|
@@ -1316,6 +1327,7 @@ var getEvmConnectors = () => {
|
|
|
1316
1327
|
} catch (err) {
|
|
1317
1328
|
if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
|
|
1318
1329
|
await disconnect(getEvmConfig(), { connector: c });
|
|
1330
|
+
cleanupWalletLocalStorage();
|
|
1319
1331
|
await sleep(100);
|
|
1320
1332
|
const result = await connect(getEvmConfig(), { connector: c });
|
|
1321
1333
|
if (!result.accounts[0]) throw new Error("No accounts returned");
|
|
@@ -1325,13 +1337,21 @@ var getEvmConnectors = () => {
|
|
|
1325
1337
|
}
|
|
1326
1338
|
},
|
|
1327
1339
|
disconnect: async () => {
|
|
1328
|
-
await disconnect(getEvmConfig()
|
|
1340
|
+
await disconnect(getEvmConfig());
|
|
1341
|
+
cleanupWalletLocalStorage();
|
|
1329
1342
|
},
|
|
1330
1343
|
signMessage: async (message) => {
|
|
1331
1344
|
return signMessage(getEvmConfig(), { message });
|
|
1332
1345
|
}
|
|
1333
1346
|
}
|
|
1334
1347
|
}));
|
|
1348
|
+
if (!isMobile()) {
|
|
1349
|
+
const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
|
|
1350
|
+
const metamaskConnector = connectors[metamaskIndex];
|
|
1351
|
+
if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
|
|
1352
|
+
connectors[metamaskIndex] = createMetaMaskEvmConnector();
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1335
1355
|
addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
|
|
1336
1356
|
return connectors;
|
|
1337
1357
|
};
|
package/dist/dev.jsx
CHANGED
|
@@ -623,6 +623,7 @@ var createWcEvmConnector = (config2) => {
|
|
|
623
623
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
624
624
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
625
625
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
626
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
626
627
|
return {
|
|
627
628
|
...walletConfig2,
|
|
628
629
|
type: "evm",
|
|
@@ -654,6 +655,9 @@ var createWcEvmConnector = (config2) => {
|
|
|
654
655
|
throw new Error("No EVM account in session");
|
|
655
656
|
}
|
|
656
657
|
const address = account.split(":")[2];
|
|
658
|
+
if (isMobile() && signDeeplink) {
|
|
659
|
+
openDeeplink(signDeeplink);
|
|
660
|
+
}
|
|
657
661
|
const result = await requestWalletConnect(
|
|
658
662
|
"personal_sign",
|
|
659
663
|
[message, address],
|
|
@@ -668,6 +672,7 @@ var createWcSolanaConnector = (config2) => {
|
|
|
668
672
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
669
673
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
670
674
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
675
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
671
676
|
return {
|
|
672
677
|
...walletConfig2,
|
|
673
678
|
type: "solana",
|
|
@@ -694,6 +699,9 @@ var createWcSolanaConnector = (config2) => {
|
|
|
694
699
|
}
|
|
695
700
|
const pubkey = account.split(":")[2];
|
|
696
701
|
const messageBytes = new TextEncoder().encode(message);
|
|
702
|
+
if (isMobile() && signDeeplink) {
|
|
703
|
+
openDeeplink(signDeeplink);
|
|
704
|
+
}
|
|
697
705
|
const result = await requestWalletConnect(
|
|
698
706
|
"solana_signMessage",
|
|
699
707
|
{ message: bs583.encode(messageBytes), pubkey },
|
|
@@ -1322,6 +1330,9 @@ var checkEvmWalletInstalled = (connectorId) => {
|
|
|
1322
1330
|
return true;
|
|
1323
1331
|
}
|
|
1324
1332
|
};
|
|
1333
|
+
var cleanupWalletLocalStorage = () => {
|
|
1334
|
+
Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
|
|
1335
|
+
};
|
|
1325
1336
|
var getEvmConnectors = () => {
|
|
1326
1337
|
const wagmiConnectors = getConnectors(getEvmConfig());
|
|
1327
1338
|
const connectors = wagmiConnectors.map((c) => ({
|
|
@@ -1340,6 +1351,7 @@ var getEvmConnectors = () => {
|
|
|
1340
1351
|
} catch (err) {
|
|
1341
1352
|
if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
|
|
1342
1353
|
await disconnect(getEvmConfig(), { connector: c });
|
|
1354
|
+
cleanupWalletLocalStorage();
|
|
1343
1355
|
await sleep(100);
|
|
1344
1356
|
const result = await connect(getEvmConfig(), { connector: c });
|
|
1345
1357
|
if (!result.accounts[0]) throw new Error("No accounts returned");
|
|
@@ -1349,13 +1361,21 @@ var getEvmConnectors = () => {
|
|
|
1349
1361
|
}
|
|
1350
1362
|
},
|
|
1351
1363
|
disconnect: async () => {
|
|
1352
|
-
await disconnect(getEvmConfig()
|
|
1364
|
+
await disconnect(getEvmConfig());
|
|
1365
|
+
cleanupWalletLocalStorage();
|
|
1353
1366
|
},
|
|
1354
1367
|
signMessage: async (message) => {
|
|
1355
1368
|
return wagmiSignMessage(getEvmConfig(), { message });
|
|
1356
1369
|
}
|
|
1357
1370
|
}
|
|
1358
1371
|
}));
|
|
1372
|
+
if (!isMobile()) {
|
|
1373
|
+
const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
|
|
1374
|
+
const metamaskConnector = connectors[metamaskIndex];
|
|
1375
|
+
if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
|
|
1376
|
+
connectors[metamaskIndex] = createMetaMaskEvmConnector();
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1359
1379
|
addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
|
|
1360
1380
|
return connectors;
|
|
1361
1381
|
};
|
package/dist/index.js
CHANGED
|
@@ -616,6 +616,7 @@ var createWcEvmConnector = (config2) => {
|
|
|
616
616
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
617
617
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
618
618
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
619
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
619
620
|
return {
|
|
620
621
|
...walletConfig2,
|
|
621
622
|
type: "evm",
|
|
@@ -647,6 +648,9 @@ var createWcEvmConnector = (config2) => {
|
|
|
647
648
|
throw new Error("No EVM account in session");
|
|
648
649
|
}
|
|
649
650
|
const address = account.split(":")[2];
|
|
651
|
+
if (isMobile() && signDeeplink) {
|
|
652
|
+
openDeeplink(signDeeplink);
|
|
653
|
+
}
|
|
650
654
|
const result = await requestWalletConnect(
|
|
651
655
|
"personal_sign",
|
|
652
656
|
[message, address],
|
|
@@ -661,6 +665,7 @@ var createWcSolanaConnector = (config2) => {
|
|
|
661
665
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
662
666
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
663
667
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
668
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
664
669
|
return {
|
|
665
670
|
...walletConfig2,
|
|
666
671
|
type: "solana",
|
|
@@ -687,6 +692,9 @@ var createWcSolanaConnector = (config2) => {
|
|
|
687
692
|
}
|
|
688
693
|
const pubkey = account.split(":")[2];
|
|
689
694
|
const messageBytes = new TextEncoder().encode(message);
|
|
695
|
+
if (isMobile() && signDeeplink) {
|
|
696
|
+
openDeeplink(signDeeplink);
|
|
697
|
+
}
|
|
690
698
|
const result = await requestWalletConnect(
|
|
691
699
|
"solana_signMessage",
|
|
692
700
|
{ message: bs582.encode(messageBytes), pubkey },
|
|
@@ -1298,6 +1306,9 @@ var checkEvmWalletInstalled = (connectorId) => {
|
|
|
1298
1306
|
return true;
|
|
1299
1307
|
}
|
|
1300
1308
|
};
|
|
1309
|
+
var cleanupWalletLocalStorage = () => {
|
|
1310
|
+
Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
|
|
1311
|
+
};
|
|
1301
1312
|
var getEvmConnectors = () => {
|
|
1302
1313
|
const wagmiConnectors = getConnectors(getEvmConfig());
|
|
1303
1314
|
const connectors = wagmiConnectors.map((c) => ({
|
|
@@ -1316,6 +1327,7 @@ var getEvmConnectors = () => {
|
|
|
1316
1327
|
} catch (err) {
|
|
1317
1328
|
if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
|
|
1318
1329
|
await disconnect(getEvmConfig(), { connector: c });
|
|
1330
|
+
cleanupWalletLocalStorage();
|
|
1319
1331
|
await sleep(100);
|
|
1320
1332
|
const result = await connect(getEvmConfig(), { connector: c });
|
|
1321
1333
|
if (!result.accounts[0]) throw new Error("No accounts returned");
|
|
@@ -1325,13 +1337,21 @@ var getEvmConnectors = () => {
|
|
|
1325
1337
|
}
|
|
1326
1338
|
},
|
|
1327
1339
|
disconnect: async () => {
|
|
1328
|
-
await disconnect(getEvmConfig()
|
|
1340
|
+
await disconnect(getEvmConfig());
|
|
1341
|
+
cleanupWalletLocalStorage();
|
|
1329
1342
|
},
|
|
1330
1343
|
signMessage: async (message) => {
|
|
1331
1344
|
return signMessage(getEvmConfig(), { message });
|
|
1332
1345
|
}
|
|
1333
1346
|
}
|
|
1334
1347
|
}));
|
|
1348
|
+
if (!isMobile()) {
|
|
1349
|
+
const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
|
|
1350
|
+
const metamaskConnector = connectors[metamaskIndex];
|
|
1351
|
+
if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
|
|
1352
|
+
connectors[metamaskIndex] = createMetaMaskEvmConnector();
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1335
1355
|
addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
|
|
1336
1356
|
return connectors;
|
|
1337
1357
|
};
|
package/dist/index.jsx
CHANGED
|
@@ -623,6 +623,7 @@ var createWcEvmConnector = (config2) => {
|
|
|
623
623
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
624
624
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
625
625
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
626
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
626
627
|
return {
|
|
627
628
|
...walletConfig2,
|
|
628
629
|
type: "evm",
|
|
@@ -654,6 +655,9 @@ var createWcEvmConnector = (config2) => {
|
|
|
654
655
|
throw new Error("No EVM account in session");
|
|
655
656
|
}
|
|
656
657
|
const address = account.split(":")[2];
|
|
658
|
+
if (isMobile() && signDeeplink) {
|
|
659
|
+
openDeeplink(signDeeplink);
|
|
660
|
+
}
|
|
657
661
|
const result = await requestWalletConnect(
|
|
658
662
|
"personal_sign",
|
|
659
663
|
[message, address],
|
|
@@ -668,6 +672,7 @@ var createWcSolanaConnector = (config2) => {
|
|
|
668
672
|
const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
|
|
669
673
|
const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
|
|
670
674
|
const isInWallet = () => isInWalletBrowser(config2.injectedKey);
|
|
675
|
+
const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
|
|
671
676
|
return {
|
|
672
677
|
...walletConfig2,
|
|
673
678
|
type: "solana",
|
|
@@ -694,6 +699,9 @@ var createWcSolanaConnector = (config2) => {
|
|
|
694
699
|
}
|
|
695
700
|
const pubkey = account.split(":")[2];
|
|
696
701
|
const messageBytes = new TextEncoder().encode(message);
|
|
702
|
+
if (isMobile() && signDeeplink) {
|
|
703
|
+
openDeeplink(signDeeplink);
|
|
704
|
+
}
|
|
697
705
|
const result = await requestWalletConnect(
|
|
698
706
|
"solana_signMessage",
|
|
699
707
|
{ message: bs583.encode(messageBytes), pubkey },
|
|
@@ -1322,6 +1330,9 @@ var checkEvmWalletInstalled = (connectorId) => {
|
|
|
1322
1330
|
return true;
|
|
1323
1331
|
}
|
|
1324
1332
|
};
|
|
1333
|
+
var cleanupWalletLocalStorage = () => {
|
|
1334
|
+
Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
|
|
1335
|
+
};
|
|
1325
1336
|
var getEvmConnectors = () => {
|
|
1326
1337
|
const wagmiConnectors = getConnectors(getEvmConfig());
|
|
1327
1338
|
const connectors = wagmiConnectors.map((c) => ({
|
|
@@ -1340,6 +1351,7 @@ var getEvmConnectors = () => {
|
|
|
1340
1351
|
} catch (err) {
|
|
1341
1352
|
if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
|
|
1342
1353
|
await disconnect(getEvmConfig(), { connector: c });
|
|
1354
|
+
cleanupWalletLocalStorage();
|
|
1343
1355
|
await sleep(100);
|
|
1344
1356
|
const result = await connect(getEvmConfig(), { connector: c });
|
|
1345
1357
|
if (!result.accounts[0]) throw new Error("No accounts returned");
|
|
@@ -1349,13 +1361,21 @@ var getEvmConnectors = () => {
|
|
|
1349
1361
|
}
|
|
1350
1362
|
},
|
|
1351
1363
|
disconnect: async () => {
|
|
1352
|
-
await disconnect(getEvmConfig()
|
|
1364
|
+
await disconnect(getEvmConfig());
|
|
1365
|
+
cleanupWalletLocalStorage();
|
|
1353
1366
|
},
|
|
1354
1367
|
signMessage: async (message) => {
|
|
1355
1368
|
return wagmiSignMessage(getEvmConfig(), { message });
|
|
1356
1369
|
}
|
|
1357
1370
|
}
|
|
1358
1371
|
}));
|
|
1372
|
+
if (!isMobile()) {
|
|
1373
|
+
const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
|
|
1374
|
+
const metamaskConnector = connectors[metamaskIndex];
|
|
1375
|
+
if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
|
|
1376
|
+
connectors[metamaskIndex] = createMetaMaskEvmConnector();
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1359
1379
|
addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
|
|
1360
1380
|
return connectors;
|
|
1361
1381
|
};
|
|
@@ -7,6 +7,8 @@ export interface WcWalletConfig {
|
|
|
7
7
|
injectedKey: string;
|
|
8
8
|
/** Custom deeplink builder for wallets that need special formatting */
|
|
9
9
|
getDeeplink?: (uri: string) => string;
|
|
10
|
+
/** Deeplink to open wallet app for signing (without WC URI) */
|
|
11
|
+
signDeeplink?: string;
|
|
10
12
|
}
|
|
11
13
|
export declare const createWcEvmConnector: (config: WcWalletConfig) => EvmWalletConnector;
|
|
12
14
|
export declare const createWcSolanaConnector: (config: WcWalletConfig) => SolanaWalletConnector;
|