@solana-mobile/mobile-wallet-adapter-protocol-web3js 2.1.4 → 2.1.7
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 +70 -129
- package/lib/cjs/index.js +70 -129
- package/lib/cjs/index.native.js +70 -129
- package/lib/esm/index.browser.js +71 -130
- package/lib/esm/index.js +71 -130
- package/lib/types/index.browser.d.ts +8 -4
- package/lib/types/index.d.ts +8 -4
- package/lib/types/index.native.d.ts +8 -4
- package/package.json +57 -53
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VersionedMessage, Transaction, VersionedTransaction, SIGNATURE_LENGTH_IN_BYTES } from '@solana/web3.js';
|
|
2
|
-
import { transact as transact$1,
|
|
2
|
+
import { transact as transact$1, startRemoteScenario as startRemoteScenario$1 } from '@solana-mobile/mobile-wallet-adapter-protocol';
|
|
3
3
|
import bs58 from 'bs58';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -73,142 +73,83 @@ function getTransactionFromWireMessage(byteArray) {
|
|
|
73
73
|
function transact(callback, config) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
const augmentedCallback = (wallet) => {
|
|
76
|
-
|
|
77
|
-
get(target, p) {
|
|
78
|
-
if (target[p] == null) {
|
|
79
|
-
switch (p) {
|
|
80
|
-
case 'signAndSendTransactions':
|
|
81
|
-
target[p] = function (_a) {
|
|
82
|
-
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
85
|
-
const options = {
|
|
86
|
-
min_context_slot: minContextSlot,
|
|
87
|
-
commitment: commitment,
|
|
88
|
-
skip_preflight: skipPreflight,
|
|
89
|
-
max_retries: maxRetries,
|
|
90
|
-
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
91
|
-
};
|
|
92
|
-
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
93
|
-
? { options: options }
|
|
94
|
-
: null)), { payloads }));
|
|
95
|
-
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
96
|
-
return signatures;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
break;
|
|
100
|
-
case 'signMessages':
|
|
101
|
-
target[p] = function (_a) {
|
|
102
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
105
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
106
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
107
|
-
return signedMessages;
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
break;
|
|
111
|
-
case 'signTransactions':
|
|
112
|
-
target[p] = function (_a) {
|
|
113
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
116
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
117
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
118
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
119
|
-
return signedTransactions;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
break;
|
|
123
|
-
default: {
|
|
124
|
-
target[p] = wallet[p];
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return target[p];
|
|
130
|
-
},
|
|
131
|
-
defineProperty() {
|
|
132
|
-
return false;
|
|
133
|
-
},
|
|
134
|
-
deleteProperty() {
|
|
135
|
-
return false;
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
return callback(augmentedAPI);
|
|
76
|
+
return callback(augmentWalletAPI(wallet));
|
|
139
77
|
};
|
|
140
78
|
return yield transact$1(augmentedCallback, config);
|
|
141
79
|
});
|
|
142
80
|
}
|
|
143
|
-
function
|
|
81
|
+
function startRemoteScenario(config) {
|
|
144
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
169
|
-
break;
|
|
170
|
-
case 'signMessages':
|
|
171
|
-
target[p] = function (_a) {
|
|
172
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
173
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
175
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
176
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
177
|
-
return signedMessages;
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
break;
|
|
181
|
-
case 'signTransactions':
|
|
182
|
-
target[p] = function (_a) {
|
|
183
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
186
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
187
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
188
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
189
|
-
return signedTransactions;
|
|
190
|
-
});
|
|
83
|
+
const { wallet, close, associationUrl } = yield startRemoteScenario$1(config);
|
|
84
|
+
const augmentedPromise = wallet.then((wallet) => {
|
|
85
|
+
return augmentWalletAPI(wallet);
|
|
86
|
+
});
|
|
87
|
+
return { wallet: augmentedPromise, close, associationUrl };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function augmentWalletAPI(wallet) {
|
|
91
|
+
return new Proxy({}, {
|
|
92
|
+
get(target, p) {
|
|
93
|
+
if (target[p] == null) {
|
|
94
|
+
switch (p) {
|
|
95
|
+
case 'signAndSendTransactions':
|
|
96
|
+
target[p] = function (_a) {
|
|
97
|
+
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
100
|
+
const options = {
|
|
101
|
+
min_context_slot: minContextSlot,
|
|
102
|
+
commitment: commitment,
|
|
103
|
+
skip_preflight: skipPreflight,
|
|
104
|
+
max_retries: maxRetries,
|
|
105
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
191
106
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
107
|
+
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
108
|
+
? { options: options }
|
|
109
|
+
: null)), { payloads }));
|
|
110
|
+
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
111
|
+
return signatures;
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
break;
|
|
115
|
+
case 'signMessages':
|
|
116
|
+
target[p] = function (_a) {
|
|
117
|
+
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
120
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
121
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
122
|
+
return signedMessages;
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
break;
|
|
126
|
+
case 'signTransactions':
|
|
127
|
+
target[p] = function (_a) {
|
|
128
|
+
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
131
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
132
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
133
|
+
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
134
|
+
return signedTransactions;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
break;
|
|
138
|
+
default: {
|
|
139
|
+
target[p] = wallet[p];
|
|
140
|
+
break;
|
|
198
141
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
return yield transactRemote$1(augmentedCallback, config);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return target[p];
|
|
145
|
+
},
|
|
146
|
+
defineProperty() {
|
|
147
|
+
return false;
|
|
148
|
+
},
|
|
149
|
+
deleteProperty() {
|
|
150
|
+
return false;
|
|
151
|
+
},
|
|
211
152
|
});
|
|
212
153
|
}
|
|
213
154
|
|
|
214
|
-
export {
|
|
155
|
+
export { startRemoteScenario, transact };
|
|
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
|
|
|
26
26
|
}
|
|
27
27
|
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type Web3Scenario = Readonly<{
|
|
30
|
+
wallet: Promise<Web3MobileWallet>;
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
31
34
|
associationUrl: URL;
|
|
32
|
-
result: Promise<TReturn>;
|
|
33
35
|
}>;
|
|
34
|
-
|
|
36
|
+
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
|
+
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3Scenario, Web3RemoteScenario, transact, startRemoteScenario };
|
|
35
39
|
//# sourceMappingURL=index.browser.d.ts.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
|
|
|
26
26
|
}
|
|
27
27
|
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type Web3Scenario = Readonly<{
|
|
30
|
+
wallet: Promise<Web3MobileWallet>;
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
31
34
|
associationUrl: URL;
|
|
32
|
-
result: Promise<TReturn>;
|
|
33
35
|
}>;
|
|
34
|
-
|
|
36
|
+
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
|
+
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3Scenario, Web3RemoteScenario, transact, startRemoteScenario };
|
|
35
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
|
|
|
26
26
|
}
|
|
27
27
|
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type Web3Scenario = Readonly<{
|
|
30
|
+
wallet: Promise<Web3MobileWallet>;
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
31
34
|
associationUrl: URL;
|
|
32
|
-
result: Promise<TReturn>;
|
|
33
35
|
}>;
|
|
34
|
-
|
|
36
|
+
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
|
+
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3Scenario, Web3RemoteScenario, transact, startRemoteScenario };
|
|
35
39
|
//# sourceMappingURL=index.native.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,53 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@solana-mobile/mobile-wallet-adapter-protocol-web3js",
|
|
3
|
-
"description": "A convenience wrapper that enables you to call Solana Mobile Stack protocol methods using objects from @solana/web3.js",
|
|
4
|
-
"version": "2.1.
|
|
5
|
-
"author": "Steven Luscher <steven.luscher@solanamobile.com>",
|
|
6
|
-
"repository":
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"./
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@solana-mobile/mobile-wallet-adapter-protocol-web3js",
|
|
3
|
+
"description": "A convenience wrapper that enables you to call Solana Mobile Stack protocol methods using objects from @solana/web3.js",
|
|
4
|
+
"version": "2.1.7",
|
|
5
|
+
"author": "Steven Luscher <steven.luscher@solanamobile.com>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/solana-mobile/mobile-wallet-adapter.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"main": "lib/cjs/index.js",
|
|
14
|
+
"react-native": "lib/cjs/index.native.js",
|
|
15
|
+
"module": "lib/esm/index.js",
|
|
16
|
+
"types": "lib/types/index.d.ts",
|
|
17
|
+
"browser": {
|
|
18
|
+
"./lib/cjs/index.js": "./lib/cjs/index.browser.js",
|
|
19
|
+
"./lib/esm/index.js": "./lib/esm/index.browser.js"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./lib/esm/index.js",
|
|
25
|
+
"require": "./lib/cjs/index.js",
|
|
26
|
+
"types": "./lib/types/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"clean": "shx rm -rf lib/*",
|
|
38
|
+
"build": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts",
|
|
39
|
+
"build:watch": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts --watch",
|
|
40
|
+
"postbuild": "cross-env echo {\\\"type\\\":\\\"commonjs\\\"} | npx json > lib/cjs/package.json && echo {\\\"type\\\":\\\"module\\\"} | npx json > lib/esm/package.json",
|
|
41
|
+
"prepublishOnly": "agadoo"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@solana/web3.js": "^1.58.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.1.7",
|
|
48
|
+
"bs58": "^5.0.0",
|
|
49
|
+
"js-base64": "^3.7.5"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@solana/web3.js": "^1.91.7",
|
|
53
|
+
"agadoo": "^3.0.0",
|
|
54
|
+
"cross-env": "^7.0.3",
|
|
55
|
+
"shx": "^0.3.4"
|
|
56
|
+
}
|
|
57
|
+
}
|