@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/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, transactRemote as transactRemote$1 } from '@solana-mobile/mobile-wallet-adapter-protocol';
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
- const augmentedAPI = new Proxy({}, {
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 transactRemote(callback, config) {
81
+ function startRemoteScenario(config) {
144
82
  return __awaiter(this, void 0, void 0, function* () {
145
- const augmentedCallback = (wallet) => {
146
- const augmentedAPI = new Proxy({}, {
147
- get(target, p) {
148
- if (target[p] == null) {
149
- switch (p) {
150
- case 'signAndSendTransactions':
151
- target[p] = function (_a) {
152
- var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const payloads = transactions.map(getPayloadFromTransaction);
155
- const options = {
156
- min_context_slot: minContextSlot,
157
- commitment: commitment,
158
- skip_preflight: skipPreflight,
159
- max_retries: maxRetries,
160
- wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
161
- };
162
- const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
163
- ? { options: options }
164
- : null)), { payloads }));
165
- const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
166
- return signatures;
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
- break;
193
- default: {
194
- target[p] = wallet[p];
195
- break;
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
- return target[p];
200
- },
201
- defineProperty() {
202
- return false;
203
- },
204
- deleteProperty() {
205
- return false;
206
- },
207
- });
208
- return callback(augmentedAPI);
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 { transact, transactRemote };
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
- declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
30
- declare function transactRemote<TReturn>(callback: (wallet: Web3RemoteMobileWallet) => TReturn, config: RemoteWalletAssociationConfig): Promise<{
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
- export { Web3MobileWallet, Web3RemoteMobileWallet, transact, transactRemote };
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
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
26
26
  }
27
27
  interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
28
28
  }
29
- declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
30
- declare function transactRemote<TReturn>(callback: (wallet: Web3RemoteMobileWallet) => TReturn, config: RemoteWalletAssociationConfig): Promise<{
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
- export { Web3MobileWallet, Web3RemoteMobileWallet, transact, transactRemote };
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
- declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
30
- declare function transactRemote<TReturn>(callback: (wallet: Web3RemoteMobileWallet) => TReturn, config: RemoteWalletAssociationConfig): Promise<{
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
- export { Web3MobileWallet, Web3RemoteMobileWallet, transact, transactRemote };
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.4",
5
- "author": "Steven Luscher <steven.luscher@solanamobile.com>",
6
- "repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
7
- "license": "Apache-2.0",
8
- "type": "module",
9
- "sideEffects": false,
10
- "main": "lib/cjs/index.js",
11
- "react-native": "lib/cjs/index.native.js",
12
- "module": "lib/esm/index.js",
13
- "types": "lib/types/index.d.ts",
14
- "browser": {
15
- "./lib/cjs/index.js": "./lib/cjs/index.browser.js",
16
- "./lib/esm/index.js": "./lib/esm/index.browser.js"
17
- },
18
- "exports": {
19
- "./package.json": "./package.json",
20
- ".": {
21
- "import": "./lib/esm/index.js",
22
- "require": "./lib/cjs/index.js"
23
- }
24
- },
25
- "files": [
26
- "lib",
27
- "LICENSE"
28
- ],
29
- "publishConfig": {
30
- "access": "public"
31
- },
32
- "scripts": {
33
- "clean": "shx rm -rf lib/*",
34
- "build": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts",
35
- "build:watch": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts --watch",
36
- "postbuild": "cross-env echo {\\\"type\\\":\\\"commonjs\\\"} | npx json > lib/cjs/package.json && echo {\\\"type\\\":\\\"module\\\"} | npx json > lib/esm/package.json",
37
- "prepublishOnly": "agadoo"
38
- },
39
- "peerDependencies": {
40
- "@solana/web3.js": "^1.58.0"
41
- },
42
- "dependencies": {
43
- "@solana-mobile/mobile-wallet-adapter-protocol": "^2.1.4",
44
- "bs58": "^5.0.0",
45
- "js-base64": "^3.7.5"
46
- },
47
- "devDependencies": {
48
- "@solana/web3.js": "^1.91.7",
49
- "agadoo": "^3.0.0",
50
- "cross-env": "^7.0.3",
51
- "shx": "^0.3.4"
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
+ }