@solana-mobile/wallet-standard-mobile 0.3.0 → 0.4.1
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/lib/cjs/index.browser.js +67 -45
- package/lib/cjs/index.js +67 -45
- package/lib/cjs/index.native.js +65 -43
- package/lib/esm/index.browser.js +67 -45
- package/lib/esm/index.js +67 -45
- package/lib/types/index.browser.d.ts +4 -2
- package/lib/types/index.d.ts +4 -2
- package/lib/types/index.native.d.ts +4 -2
- package/package.json +2 -2
package/lib/cjs/index.browser.js
CHANGED
|
@@ -549,6 +549,7 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
549
549
|
if (silent) {
|
|
550
550
|
const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
551
551
|
if (cachedAuthorization) {
|
|
552
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
|
|
552
553
|
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
|
|
553
554
|
}
|
|
554
555
|
else {
|
|
@@ -586,7 +587,7 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
586
587
|
})
|
|
587
588
|
]);
|
|
588
589
|
const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
589
|
-
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain });
|
|
590
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
|
|
590
591
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
591
592
|
Promise.all([
|
|
592
593
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
|
|
@@ -638,14 +639,18 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
638
639
|
}
|
|
639
640
|
}));
|
|
640
641
|
_LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
|
|
642
|
+
var _b, _c;
|
|
641
643
|
try {
|
|
642
|
-
const mwaAuthorizationResult = yield
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
644
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
645
|
+
(_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
|
|
646
|
+
wallet.authorize({
|
|
647
|
+
auth_token: authToken,
|
|
648
|
+
identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
649
|
+
chain: chain
|
|
650
|
+
})
|
|
651
|
+
]);
|
|
647
652
|
const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
648
|
-
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain });
|
|
653
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
|
|
649
654
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
650
655
|
Promise.all([
|
|
651
656
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
@@ -658,16 +663,16 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
658
663
|
}
|
|
659
664
|
}));
|
|
660
665
|
_LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
661
|
-
var
|
|
666
|
+
var _d;
|
|
662
667
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
663
668
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false, "f");
|
|
664
|
-
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (
|
|
669
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d), "f");
|
|
665
670
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined, "f");
|
|
666
671
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
667
672
|
}));
|
|
668
673
|
_LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
|
|
669
|
-
var
|
|
670
|
-
const walletUriBase = (
|
|
674
|
+
var _e;
|
|
675
|
+
const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
|
|
671
676
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
672
677
|
const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
|
|
673
678
|
try {
|
|
@@ -790,19 +795,19 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
790
795
|
return outputs;
|
|
791
796
|
}));
|
|
792
797
|
_LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
|
|
793
|
-
var
|
|
798
|
+
var _f, _g, _h;
|
|
794
799
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true, "f");
|
|
795
800
|
try {
|
|
796
|
-
const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (
|
|
801
|
+
const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_f = input === null || input === void 0 ? void 0 : input.domain) !== null && _f !== void 0 ? _f : window.location.host }));
|
|
797
802
|
if (!authorizationResult.sign_in_result) {
|
|
798
803
|
throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
799
804
|
}
|
|
800
805
|
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
801
|
-
const signedInAccount =
|
|
802
|
-
address: signedInAddress
|
|
803
|
-
}), { publicKey: toUint8Array(signedInAddress) });
|
|
806
|
+
const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
|
|
804
807
|
return {
|
|
805
|
-
account: signedInAccount
|
|
808
|
+
account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
|
|
809
|
+
address: base58__default["default"].encode(toUint8Array(signedInAddress))
|
|
810
|
+
}), { publicKey: toUint8Array(signedInAddress), chains: (_g = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _g !== void 0 ? _g : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"), features: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _h !== void 0 ? _h : authorizationResult.capabilities.features }),
|
|
806
811
|
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
807
812
|
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
808
813
|
};
|
|
@@ -820,15 +825,21 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
820
825
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector, "f");
|
|
821
826
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound, "f");
|
|
822
827
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
|
|
823
|
-
//
|
|
824
|
-
//
|
|
825
|
-
// MWA
|
|
826
|
-
//
|
|
828
|
+
// In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
|
|
829
|
+
// signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
|
|
830
|
+
// 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
|
|
831
|
+
// assume both are supported here. The features will be updated based on the actual connected
|
|
832
|
+
// wallets capabilities during connection regardless, so this is safe.
|
|
827
833
|
[walletStandardFeatures.SolanaSignAndSendTransaction]: {
|
|
828
834
|
version: '1.0.0',
|
|
829
835
|
supportedTransactionVersions: ['legacy', 0],
|
|
830
836
|
signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
831
837
|
},
|
|
838
|
+
[walletStandardFeatures.SolanaSignTransaction]: {
|
|
839
|
+
version: '1.0.0',
|
|
840
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
841
|
+
signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
842
|
+
},
|
|
832
843
|
}, "f");
|
|
833
844
|
}
|
|
834
845
|
get version() {
|
|
@@ -955,7 +966,7 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
955
966
|
})
|
|
956
967
|
]);
|
|
957
968
|
const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
958
|
-
const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain });
|
|
969
|
+
const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
|
|
959
970
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
960
971
|
Promise.all([
|
|
961
972
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
|
|
@@ -1008,13 +1019,18 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1008
1019
|
}
|
|
1009
1020
|
}));
|
|
1010
1021
|
_RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
|
|
1022
|
+
var _b, _c;
|
|
1011
1023
|
try {
|
|
1012
|
-
const mwaAuthorizationResult = yield
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1024
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
1025
|
+
(_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
|
|
1026
|
+
wallet.authorize({
|
|
1027
|
+
auth_token: authToken,
|
|
1028
|
+
identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
1029
|
+
chain: chain
|
|
1030
|
+
})
|
|
1031
|
+
]);
|
|
1016
1032
|
const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
1017
|
-
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain });
|
|
1033
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
|
|
1018
1034
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
1019
1035
|
Promise.all([
|
|
1020
1036
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
@@ -1027,19 +1043,19 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1027
1043
|
}
|
|
1028
1044
|
}));
|
|
1029
1045
|
_RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
1030
|
-
var
|
|
1031
|
-
var
|
|
1032
|
-
(
|
|
1046
|
+
var _d;
|
|
1047
|
+
var _e;
|
|
1048
|
+
(_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
|
|
1033
1049
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
1034
1050
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false, "f");
|
|
1035
|
-
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (
|
|
1051
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e), "f");
|
|
1036
1052
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined, "f");
|
|
1037
1053
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
|
|
1038
1054
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
1039
1055
|
}));
|
|
1040
1056
|
_RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
|
|
1041
|
-
var
|
|
1042
|
-
const walletUriBase = (
|
|
1057
|
+
var _f;
|
|
1058
|
+
const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
|
|
1043
1059
|
const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
1044
1060
|
const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
|
|
1045
1061
|
const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
|
|
@@ -1176,19 +1192,19 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1176
1192
|
return outputs;
|
|
1177
1193
|
}));
|
|
1178
1194
|
_RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
|
|
1179
|
-
var
|
|
1195
|
+
var _g, _h, _j;
|
|
1180
1196
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true, "f");
|
|
1181
1197
|
try {
|
|
1182
|
-
const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (
|
|
1198
|
+
const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_g = input === null || input === void 0 ? void 0 : input.domain) !== null && _g !== void 0 ? _g : window.location.host }));
|
|
1183
1199
|
if (!authorizationResult.sign_in_result) {
|
|
1184
1200
|
throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
1185
1201
|
}
|
|
1186
1202
|
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
1187
|
-
const signedInAccount =
|
|
1188
|
-
address: signedInAddress
|
|
1189
|
-
}), { publicKey: toUint8Array(signedInAddress) });
|
|
1203
|
+
const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
|
|
1190
1204
|
return {
|
|
1191
|
-
account: signedInAccount
|
|
1205
|
+
account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
|
|
1206
|
+
address: base58__default["default"].encode(toUint8Array(signedInAddress))
|
|
1207
|
+
}), { publicKey: toUint8Array(signedInAddress), chains: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _h !== void 0 ? _h : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"), features: (_j = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _j !== void 0 ? _j : authorizationResult.capabilities.features }),
|
|
1192
1208
|
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
1193
1209
|
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
1194
1210
|
};
|
|
@@ -1207,15 +1223,21 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1207
1223
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority, "f");
|
|
1208
1224
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound, "f");
|
|
1209
1225
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
|
|
1210
|
-
//
|
|
1211
|
-
//
|
|
1212
|
-
// MWA
|
|
1213
|
-
//
|
|
1226
|
+
// In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
|
|
1227
|
+
// signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
|
|
1228
|
+
// 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
|
|
1229
|
+
// assume both are supported here. The features will be updated based on the actual connected
|
|
1230
|
+
// wallets capabilities during connection regardless, so this is safe.
|
|
1214
1231
|
[walletStandardFeatures.SolanaSignAndSendTransaction]: {
|
|
1215
1232
|
version: '1.0.0',
|
|
1216
1233
|
supportedTransactionVersions: ['legacy', 0],
|
|
1217
1234
|
signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
1218
1235
|
},
|
|
1236
|
+
[walletStandardFeatures.SolanaSignTransaction]: {
|
|
1237
|
+
version: '1.0.0',
|
|
1238
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
1239
|
+
signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
1240
|
+
},
|
|
1219
1241
|
}, "f");
|
|
1220
1242
|
}
|
|
1221
1243
|
get version() {
|
|
@@ -1571,13 +1593,13 @@ function createDefaultAuthorizationCache() {
|
|
|
1571
1593
|
catch (_a) { }
|
|
1572
1594
|
});
|
|
1573
1595
|
},
|
|
1574
|
-
set(
|
|
1596
|
+
set(authorization) {
|
|
1575
1597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1576
1598
|
if (!storage) {
|
|
1577
1599
|
return;
|
|
1578
1600
|
}
|
|
1579
1601
|
try {
|
|
1580
|
-
storage.setItem(CACHE_KEY, JSON.stringify(
|
|
1602
|
+
storage.setItem(CACHE_KEY, JSON.stringify(authorization));
|
|
1581
1603
|
// eslint-disable-next-line no-empty
|
|
1582
1604
|
}
|
|
1583
1605
|
catch (_a) { }
|
package/lib/cjs/index.js
CHANGED
|
@@ -549,6 +549,7 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
549
549
|
if (silent) {
|
|
550
550
|
const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
551
551
|
if (cachedAuthorization) {
|
|
552
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
|
|
552
553
|
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
|
|
553
554
|
}
|
|
554
555
|
else {
|
|
@@ -586,7 +587,7 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
586
587
|
})
|
|
587
588
|
]);
|
|
588
589
|
const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
589
|
-
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain });
|
|
590
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
|
|
590
591
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
591
592
|
Promise.all([
|
|
592
593
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
|
|
@@ -638,14 +639,18 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
638
639
|
}
|
|
639
640
|
}));
|
|
640
641
|
_LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
|
|
642
|
+
var _b, _c;
|
|
641
643
|
try {
|
|
642
|
-
const mwaAuthorizationResult = yield
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
644
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
645
|
+
(_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
|
|
646
|
+
wallet.authorize({
|
|
647
|
+
auth_token: authToken,
|
|
648
|
+
identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
649
|
+
chain: chain
|
|
650
|
+
})
|
|
651
|
+
]);
|
|
647
652
|
const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
648
|
-
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain });
|
|
653
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
|
|
649
654
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
650
655
|
Promise.all([
|
|
651
656
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
@@ -658,16 +663,16 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
658
663
|
}
|
|
659
664
|
}));
|
|
660
665
|
_LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
661
|
-
var
|
|
666
|
+
var _d;
|
|
662
667
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
663
668
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false, "f");
|
|
664
|
-
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (
|
|
669
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d), "f");
|
|
665
670
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined, "f");
|
|
666
671
|
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
667
672
|
}));
|
|
668
673
|
_LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
|
|
669
|
-
var
|
|
670
|
-
const walletUriBase = (
|
|
674
|
+
var _e;
|
|
675
|
+
const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
|
|
671
676
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
672
677
|
const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
|
|
673
678
|
try {
|
|
@@ -790,19 +795,19 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
790
795
|
return outputs;
|
|
791
796
|
}));
|
|
792
797
|
_LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
|
|
793
|
-
var
|
|
798
|
+
var _f, _g, _h;
|
|
794
799
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true, "f");
|
|
795
800
|
try {
|
|
796
|
-
const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (
|
|
801
|
+
const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_f = input === null || input === void 0 ? void 0 : input.domain) !== null && _f !== void 0 ? _f : window.location.host }));
|
|
797
802
|
if (!authorizationResult.sign_in_result) {
|
|
798
803
|
throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
799
804
|
}
|
|
800
805
|
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
801
|
-
const signedInAccount =
|
|
802
|
-
address: signedInAddress
|
|
803
|
-
}), { publicKey: toUint8Array(signedInAddress) });
|
|
806
|
+
const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
|
|
804
807
|
return {
|
|
805
|
-
account: signedInAccount
|
|
808
|
+
account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
|
|
809
|
+
address: base58__default["default"].encode(toUint8Array(signedInAddress))
|
|
810
|
+
}), { publicKey: toUint8Array(signedInAddress), chains: (_g = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _g !== void 0 ? _g : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"), features: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _h !== void 0 ? _h : authorizationResult.capabilities.features }),
|
|
806
811
|
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
807
812
|
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
808
813
|
};
|
|
@@ -820,15 +825,21 @@ class LocalSolanaMobileWalletAdapterWallet {
|
|
|
820
825
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector, "f");
|
|
821
826
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound, "f");
|
|
822
827
|
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
|
|
823
|
-
//
|
|
824
|
-
//
|
|
825
|
-
// MWA
|
|
826
|
-
//
|
|
828
|
+
// In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
|
|
829
|
+
// signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
|
|
830
|
+
// 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
|
|
831
|
+
// assume both are supported here. The features will be updated based on the actual connected
|
|
832
|
+
// wallets capabilities during connection regardless, so this is safe.
|
|
827
833
|
[walletStandardFeatures.SolanaSignAndSendTransaction]: {
|
|
828
834
|
version: '1.0.0',
|
|
829
835
|
supportedTransactionVersions: ['legacy', 0],
|
|
830
836
|
signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
831
837
|
},
|
|
838
|
+
[walletStandardFeatures.SolanaSignTransaction]: {
|
|
839
|
+
version: '1.0.0',
|
|
840
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
841
|
+
signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
842
|
+
},
|
|
832
843
|
}, "f");
|
|
833
844
|
}
|
|
834
845
|
get version() {
|
|
@@ -955,7 +966,7 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
955
966
|
})
|
|
956
967
|
]);
|
|
957
968
|
const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
958
|
-
const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain });
|
|
969
|
+
const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
|
|
959
970
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
960
971
|
Promise.all([
|
|
961
972
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
|
|
@@ -1008,13 +1019,18 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1008
1019
|
}
|
|
1009
1020
|
}));
|
|
1010
1021
|
_RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
|
|
1022
|
+
var _b, _c;
|
|
1011
1023
|
try {
|
|
1012
|
-
const mwaAuthorizationResult = yield
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1024
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
1025
|
+
(_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
|
|
1026
|
+
wallet.authorize({
|
|
1027
|
+
auth_token: authToken,
|
|
1028
|
+
identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
1029
|
+
chain: chain
|
|
1030
|
+
})
|
|
1031
|
+
]);
|
|
1016
1032
|
const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
1017
|
-
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain });
|
|
1033
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
|
|
1018
1034
|
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
1019
1035
|
Promise.all([
|
|
1020
1036
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
@@ -1027,19 +1043,19 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1027
1043
|
}
|
|
1028
1044
|
}));
|
|
1029
1045
|
_RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
1030
|
-
var
|
|
1031
|
-
var
|
|
1032
|
-
(
|
|
1046
|
+
var _d;
|
|
1047
|
+
var _e;
|
|
1048
|
+
(_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
|
|
1033
1049
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
1034
1050
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false, "f");
|
|
1035
|
-
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (
|
|
1051
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e), "f");
|
|
1036
1052
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined, "f");
|
|
1037
1053
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
|
|
1038
1054
|
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
1039
1055
|
}));
|
|
1040
1056
|
_RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
|
|
1041
|
-
var
|
|
1042
|
-
const walletUriBase = (
|
|
1057
|
+
var _f;
|
|
1058
|
+
const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
|
|
1043
1059
|
const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
1044
1060
|
const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
|
|
1045
1061
|
const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
|
|
@@ -1176,19 +1192,19 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1176
1192
|
return outputs;
|
|
1177
1193
|
}));
|
|
1178
1194
|
_RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
|
|
1179
|
-
var
|
|
1195
|
+
var _g, _h, _j;
|
|
1180
1196
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true, "f");
|
|
1181
1197
|
try {
|
|
1182
|
-
const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (
|
|
1198
|
+
const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_g = input === null || input === void 0 ? void 0 : input.domain) !== null && _g !== void 0 ? _g : window.location.host }));
|
|
1183
1199
|
if (!authorizationResult.sign_in_result) {
|
|
1184
1200
|
throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
1185
1201
|
}
|
|
1186
1202
|
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
1187
|
-
const signedInAccount =
|
|
1188
|
-
address: signedInAddress
|
|
1189
|
-
}), { publicKey: toUint8Array(signedInAddress) });
|
|
1203
|
+
const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
|
|
1190
1204
|
return {
|
|
1191
|
-
account: signedInAccount
|
|
1205
|
+
account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
|
|
1206
|
+
address: base58__default["default"].encode(toUint8Array(signedInAddress))
|
|
1207
|
+
}), { publicKey: toUint8Array(signedInAddress), chains: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _h !== void 0 ? _h : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"), features: (_j = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _j !== void 0 ? _j : authorizationResult.capabilities.features }),
|
|
1192
1208
|
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
1193
1209
|
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
1194
1210
|
};
|
|
@@ -1207,15 +1223,21 @@ class RemoteSolanaMobileWalletAdapterWallet {
|
|
|
1207
1223
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority, "f");
|
|
1208
1224
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound, "f");
|
|
1209
1225
|
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
|
|
1210
|
-
//
|
|
1211
|
-
//
|
|
1212
|
-
// MWA
|
|
1213
|
-
//
|
|
1226
|
+
// In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
|
|
1227
|
+
// signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
|
|
1228
|
+
// 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
|
|
1229
|
+
// assume both are supported here. The features will be updated based on the actual connected
|
|
1230
|
+
// wallets capabilities during connection regardless, so this is safe.
|
|
1214
1231
|
[walletStandardFeatures.SolanaSignAndSendTransaction]: {
|
|
1215
1232
|
version: '1.0.0',
|
|
1216
1233
|
supportedTransactionVersions: ['legacy', 0],
|
|
1217
1234
|
signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
1218
1235
|
},
|
|
1236
|
+
[walletStandardFeatures.SolanaSignTransaction]: {
|
|
1237
|
+
version: '1.0.0',
|
|
1238
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
1239
|
+
signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
1240
|
+
},
|
|
1219
1241
|
}, "f");
|
|
1220
1242
|
}
|
|
1221
1243
|
get version() {
|
|
@@ -1571,13 +1593,13 @@ function createDefaultAuthorizationCache() {
|
|
|
1571
1593
|
catch (_a) { }
|
|
1572
1594
|
});
|
|
1573
1595
|
},
|
|
1574
|
-
set(
|
|
1596
|
+
set(authorization) {
|
|
1575
1597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1576
1598
|
if (!storage) {
|
|
1577
1599
|
return;
|
|
1578
1600
|
}
|
|
1579
1601
|
try {
|
|
1580
|
-
storage.setItem(CACHE_KEY, JSON.stringify(
|
|
1602
|
+
storage.setItem(CACHE_KEY, JSON.stringify(authorization));
|
|
1581
1603
|
// eslint-disable-next-line no-empty
|
|
1582
1604
|
}
|
|
1583
1605
|
catch (_a) { }
|