@solana-mobile/mobile-wallet-adapter-protocol-web3js 2.2.5 → 2.2.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/README.md +1 -1
- package/lib/cjs/index.browser.js +110 -150
- package/lib/cjs/index.browser.js.map +1 -0
- package/lib/cjs/index.js +110 -150
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/index.native.js +107 -145
- package/lib/cjs/index.native.js.map +1 -0
- package/lib/cjs/package.json +1 -3
- package/lib/esm/index.browser.js +86 -142
- package/lib/esm/index.browser.js.map +1 -0
- package/lib/esm/index.js +86 -142
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +1 -3
- package/lib/types/index.d.ts +26 -26
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +62 -62
- package/lib/types/index.browser.d.ts +0 -39
- package/lib/types/index.browser.d.ts.map +0 -1
- package/lib/types/index.native.d.ts +0 -39
- package/lib/types/index.native.d.ts.map +0 -1
package/lib/esm/index.js
CHANGED
|
@@ -1,155 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import bs58 from
|
|
4
|
-
|
|
5
|
-
/******************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
function __rest(s, e) {
|
|
21
|
-
var t = {};
|
|
22
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23
|
-
t[p] = s[p];
|
|
24
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
27
|
-
t[p[i]] = s[p[i]];
|
|
28
|
-
}
|
|
29
|
-
return t;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
33
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
1
|
+
import { SIGNATURE_LENGTH_IN_BYTES, Transaction, VersionedMessage, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { startRemoteScenario as startRemoteScenario$1, transact as transact$1 } from "@solana-mobile/mobile-wallet-adapter-protocol";
|
|
3
|
+
import bs58 from "bs58";
|
|
4
|
+
//#region src/base64Utils.ts
|
|
42
5
|
function fromUint8Array(byteArray) {
|
|
43
|
-
|
|
6
|
+
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
44
7
|
}
|
|
45
8
|
function toUint8Array(base64EncodedByteArray) {
|
|
46
|
-
|
|
47
|
-
.atob(base64EncodedByteArray)
|
|
48
|
-
.split('')
|
|
49
|
-
.map((c) => c.charCodeAt(0)));
|
|
9
|
+
return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
|
|
50
10
|
}
|
|
51
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/transact.ts
|
|
52
13
|
function getPayloadFromTransaction(transaction) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
verifySignatures: false,
|
|
58
|
-
});
|
|
59
|
-
const payload = fromUint8Array(serializedTransaction);
|
|
60
|
-
return payload;
|
|
14
|
+
return fromUint8Array("version" in transaction ? transaction.serialize() : transaction.serialize({
|
|
15
|
+
requireAllSignatures: false,
|
|
16
|
+
verifySignatures: false
|
|
17
|
+
}));
|
|
61
18
|
}
|
|
62
19
|
function getTransactionFromWireMessage(byteArray) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (version === 'legacy') {
|
|
67
|
-
return Transaction.from(byteArray);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
return VersionedTransaction.deserialize(byteArray);
|
|
71
|
-
}
|
|
20
|
+
const messageOffset = byteArray[0] * SIGNATURE_LENGTH_IN_BYTES + 1;
|
|
21
|
+
if (VersionedMessage.deserializeMessageVersion(byteArray.slice(messageOffset, byteArray.length)) === "legacy") return Transaction.from(byteArray);
|
|
22
|
+
else return VersionedTransaction.deserialize(byteArray);
|
|
72
23
|
}
|
|
73
|
-
function transact(callback, config) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return yield transact$1(augmentedCallback, config);
|
|
79
|
-
});
|
|
24
|
+
async function transact(callback, config) {
|
|
25
|
+
const augmentedCallback = (wallet) => {
|
|
26
|
+
return callback(augmentWalletAPI(wallet));
|
|
27
|
+
};
|
|
28
|
+
return await transact$1(augmentedCallback, config);
|
|
80
29
|
}
|
|
81
|
-
function startRemoteScenario(config) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
30
|
+
async function startRemoteScenario(config) {
|
|
31
|
+
const { wallet, close, associationUrl } = await startRemoteScenario$1(config);
|
|
32
|
+
return {
|
|
33
|
+
wallet: wallet.then((wallet) => {
|
|
34
|
+
return augmentWalletAPI(wallet);
|
|
35
|
+
}),
|
|
36
|
+
close,
|
|
37
|
+
associationUrl
|
|
38
|
+
};
|
|
89
39
|
}
|
|
90
40
|
function augmentWalletAPI(wallet) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
},
|
|
146
|
-
defineProperty() {
|
|
147
|
-
return false;
|
|
148
|
-
},
|
|
149
|
-
deleteProperty() {
|
|
150
|
-
return false;
|
|
151
|
-
},
|
|
152
|
-
});
|
|
41
|
+
return new Proxy({}, {
|
|
42
|
+
get(target, p) {
|
|
43
|
+
if (target[p] == null) switch (p) {
|
|
44
|
+
case "signAndSendTransactions":
|
|
45
|
+
target[p] = async function({ minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions, ...rest }) {
|
|
46
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
47
|
+
const options = {
|
|
48
|
+
min_context_slot: minContextSlot,
|
|
49
|
+
commitment,
|
|
50
|
+
skip_preflight: skipPreflight,
|
|
51
|
+
max_retries: maxRetries,
|
|
52
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
53
|
+
};
|
|
54
|
+
const { signatures: base64EncodedSignatures } = await wallet.signAndSendTransactions({
|
|
55
|
+
...rest,
|
|
56
|
+
...Object.values(options).some((element) => element != null) ? { options } : null,
|
|
57
|
+
payloads
|
|
58
|
+
});
|
|
59
|
+
return base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
60
|
+
};
|
|
61
|
+
break;
|
|
62
|
+
case "signMessages":
|
|
63
|
+
target[p] = async function({ payloads, ...rest }) {
|
|
64
|
+
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
65
|
+
const { signed_payloads: base64EncodedSignedMessages } = await wallet.signMessages({
|
|
66
|
+
...rest,
|
|
67
|
+
payloads: base64EncodedPayloads
|
|
68
|
+
});
|
|
69
|
+
return base64EncodedSignedMessages.map(toUint8Array);
|
|
70
|
+
};
|
|
71
|
+
break;
|
|
72
|
+
case "signTransactions":
|
|
73
|
+
target[p] = async function({ transactions, ...rest }) {
|
|
74
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
75
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = await wallet.signTransactions({
|
|
76
|
+
...rest,
|
|
77
|
+
payloads
|
|
78
|
+
});
|
|
79
|
+
return base64EncodedCompiledTransactions.map(toUint8Array).map(getTransactionFromWireMessage);
|
|
80
|
+
};
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
target[p] = wallet[p];
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
return target[p];
|
|
87
|
+
},
|
|
88
|
+
defineProperty() {
|
|
89
|
+
return false;
|
|
90
|
+
},
|
|
91
|
+
deleteProperty() {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
153
95
|
}
|
|
154
|
-
|
|
96
|
+
//#endregion
|
|
155
97
|
export { startRemoteScenario, transact };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["baseTransact","baseStartRemoteScenario"],"sources":["../../src/base64Utils.ts","../../src/transact.ts"],"sourcesContent":["export function fromUint8Array(byteArray: Uint8Array): string {\n return window.btoa(String.fromCharCode.call(null, ...byteArray));\n}\n\nexport function toUint8Array(base64EncodedByteArray: string): Uint8Array {\n return new Uint8Array(\n window\n .atob(base64EncodedByteArray)\n .split('')\n .map((c) => c.charCodeAt(0)),\n );\n}\n","import {\n SIGNATURE_LENGTH_IN_BYTES,\n Transaction as LegacyTransaction,\n Transaction,\n TransactionSignature,\n VersionedMessage,\n VersionedTransaction,\n} from '@solana/web3.js';\nimport {\n AuthorizeAPI,\n Base64EncodedAddress,\n Base64EncodedTransaction,\n CloneAuthorizationAPI,\n DeauthorizeAPI,\n GetCapabilitiesAPI,\n MobileWallet,\n ReauthorizeAPI,\n TerminateSessionAPI,\n transact as baseTransact,\n startRemoteScenario as baseStartRemoteScenario,\n WalletAssociationConfig,\n RemoteWalletAssociationConfig,\n} from '@solana-mobile/mobile-wallet-adapter-protocol';\nimport bs58 from 'bs58';\n\nimport { fromUint8Array, toUint8Array } from './base64Utils.js';\n\ninterface Web3SignAndSendTransactionsAPI {\n signAndSendTransactions<T extends LegacyTransaction | VersionedTransaction>(params: {\n minContextSlot?: number;\n commitment?: string;\n skipPreflight?: boolean;\n maxRetries?: number;\n waitForCommitmentToSendNextTransaction?: boolean;\n transactions: T[];\n }): Promise<TransactionSignature[]>;\n}\n\ninterface Web3SignTransactionsAPI {\n signTransactions<T extends LegacyTransaction | VersionedTransaction>(params: { transactions: T[] }): Promise<T[]>;\n}\n\ninterface Web3SignMessagesAPI {\n signMessages(params: { addresses: Base64EncodedAddress[]; payloads: Uint8Array[] }): Promise<Uint8Array[]>;\n}\n\nexport interface Web3MobileWallet\n extends\n AuthorizeAPI,\n CloneAuthorizationAPI,\n DeauthorizeAPI,\n GetCapabilitiesAPI,\n ReauthorizeAPI,\n Web3SignAndSendTransactionsAPI,\n Web3SignTransactionsAPI,\n Web3SignMessagesAPI {}\n\nexport interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {}\n\nexport type Web3Scenario = Readonly<{\n wallet: Promise<Web3MobileWallet>;\n close: () => void;\n}>;\n\nexport type Web3RemoteScenario = Web3Scenario &\n Readonly<{\n associationUrl: URL;\n }>;\n\nfunction getPayloadFromTransaction(transaction: LegacyTransaction | VersionedTransaction): Base64EncodedTransaction {\n const serializedTransaction =\n 'version' in transaction\n ? transaction.serialize()\n : transaction.serialize({\n requireAllSignatures: false,\n verifySignatures: false,\n });\n const payload = fromUint8Array(serializedTransaction);\n return payload;\n}\n\nfunction getTransactionFromWireMessage(byteArray: Uint8Array): Transaction | VersionedTransaction {\n const numSignatures = byteArray[0];\n const messageOffset = numSignatures * SIGNATURE_LENGTH_IN_BYTES + 1;\n const version = VersionedMessage.deserializeMessageVersion(byteArray.slice(messageOffset, byteArray.length));\n if (version === 'legacy') {\n return Transaction.from(byteArray);\n } else {\n return VersionedTransaction.deserialize(byteArray);\n }\n}\n\nexport async function transact<TReturn>(\n callback: (wallet: Web3MobileWallet) => TReturn,\n config?: WalletAssociationConfig,\n): Promise<TReturn> {\n const augmentedCallback: (wallet: MobileWallet) => TReturn = (wallet) => {\n return callback(augmentWalletAPI(wallet));\n };\n return await baseTransact(augmentedCallback, config);\n}\n\nexport async function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario> {\n const { wallet, close, associationUrl } = await baseStartRemoteScenario(config);\n const augmentedPromise = wallet.then((wallet) => {\n return augmentWalletAPI(wallet);\n });\n return { wallet: augmentedPromise, close, associationUrl };\n}\n\nfunction augmentWalletAPI(wallet: MobileWallet): Web3MobileWallet {\n return new Proxy<Web3MobileWallet>({} as Web3MobileWallet, {\n get<TMethodName extends keyof Web3MobileWallet>(target: Web3MobileWallet, p: TMethodName) {\n if (target[p] == null) {\n switch (p) {\n case 'signAndSendTransactions':\n target[p] = async function ({\n minContextSlot,\n commitment,\n skipPreflight,\n maxRetries,\n waitForCommitmentToSendNextTransaction,\n transactions,\n ...rest\n }: Parameters<Web3MobileWallet['signAndSendTransactions']>[0]) {\n const payloads = transactions.map(getPayloadFromTransaction);\n const options = {\n min_context_slot: minContextSlot,\n commitment: commitment,\n skip_preflight: skipPreflight,\n max_retries: maxRetries,\n wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction,\n };\n const { signatures: base64EncodedSignatures } = await wallet.signAndSendTransactions({\n ...rest,\n ...(Object.values(options).some((element) => element != null)\n ? { options: options }\n : null),\n payloads,\n });\n const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);\n return signatures as TransactionSignature[];\n } as Web3MobileWallet[TMethodName];\n break;\n case 'signMessages':\n target[p] = async function ({\n payloads,\n ...rest\n }: Parameters<Web3MobileWallet['signMessages']>[0]) {\n const base64EncodedPayloads = payloads.map(fromUint8Array);\n const { signed_payloads: base64EncodedSignedMessages } = await wallet.signMessages({\n ...rest,\n payloads: base64EncodedPayloads,\n });\n const signedMessages = base64EncodedSignedMessages.map(toUint8Array);\n return signedMessages;\n } as Web3MobileWallet[TMethodName];\n break;\n case 'signTransactions':\n target[p] = async function ({\n transactions,\n ...rest\n }: Parameters<Web3MobileWallet['signTransactions']>[0]) {\n const payloads = transactions.map(getPayloadFromTransaction);\n const { signed_payloads: base64EncodedCompiledTransactions } =\n await wallet.signTransactions({\n ...rest,\n payloads,\n });\n const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);\n const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);\n return signedTransactions;\n } as Web3MobileWallet[TMethodName];\n break;\n default: {\n target[p] = wallet[p] as unknown as Web3MobileWallet[TMethodName];\n break;\n }\n }\n }\n return target[p];\n },\n defineProperty() {\n return false;\n },\n deleteProperty() {\n return false;\n },\n });\n}\n"],"mappings":";;;;AAAA,SAAgB,eAAe,WAA+B;AAC1D,QAAO,OAAO,KAAK,OAAO,aAAa,KAAK,MAAM,GAAG,UAAU,CAAC;;AAGpE,SAAgB,aAAa,wBAA4C;AACrE,QAAO,IAAI,WACP,OACK,KAAK,uBAAuB,CAC5B,MAAM,GAAG,CACT,KAAK,MAAM,EAAE,WAAW,EAAE,CAAC,CACnC;;;;AC2DL,SAAS,0BAA0B,aAAiF;AAShH,QADgB,eANZ,aAAa,cACP,YAAY,WAAW,GACvB,YAAY,UAAU;EAClB,sBAAsB;EACtB,kBAAkB;EACrB,CAAC,CACyC;;AAIzD,SAAS,8BAA8B,WAA2D;CAE9F,MAAM,gBADgB,UAAU,KACM,4BAA4B;AAElE,KADgB,iBAAiB,0BAA0B,UAAU,MAAM,eAAe,UAAU,OAAO,CAAC,KAC5F,SACZ,QAAO,YAAY,KAAK,UAAU;KAElC,QAAO,qBAAqB,YAAY,UAAU;;AAI1D,eAAsB,SAClB,UACA,QACgB;CAChB,MAAM,qBAAwD,WAAW;AACrE,SAAO,SAAS,iBAAiB,OAAO,CAAC;;AAE7C,QAAO,MAAMA,WAAa,mBAAmB,OAAO;;AAGxD,eAAsB,oBAAoB,QAAoE;CAC1G,MAAM,EAAE,QAAQ,OAAO,mBAAmB,MAAMC,sBAAwB,OAAO;AAI/E,QAAO;EAAE,QAHgB,OAAO,MAAM,WAAW;AAC7C,UAAO,iBAAiB,OAAO;IACjC;EACiC;EAAO;EAAgB;;AAG9D,SAAS,iBAAiB,QAAwC;AAC9D,QAAO,IAAI,MAAwB,EAAE,EAAsB;EACvD,IAAgD,QAA0B,GAAgB;AACtF,OAAI,OAAO,MAAM,KACb,SAAQ,GAAR;IACI,KAAK;AACD,YAAO,KAAK,eAAgB,EACxB,gBACA,YACA,eACA,YACA,wCACA,cACA,GAAG,QACwD;MAC3D,MAAM,WAAW,aAAa,IAAI,0BAA0B;MAC5D,MAAM,UAAU;OACZ,kBAAkB;OACN;OACZ,gBAAgB;OAChB,aAAa;OACb,8CAA8C;OACjD;MACD,MAAM,EAAE,YAAY,4BAA4B,MAAM,OAAO,wBAAwB;OACjF,GAAG;OACH,GAAI,OAAO,OAAO,QAAQ,CAAC,MAAM,YAAY,WAAW,KAAK,GACvD,EAAW,SAAS,GACpB;OACN;OACH,CAAC;AAEF,aADmB,wBAAwB,IAAI,aAAa,CAAC,IAAI,KAAK,OAAO;;AAGjF;IACJ,KAAK;AACD,YAAO,KAAK,eAAgB,EACxB,UACA,GAAG,QAC6C;MAChD,MAAM,wBAAwB,SAAS,IAAI,eAAe;MAC1D,MAAM,EAAE,iBAAiB,gCAAgC,MAAM,OAAO,aAAa;OAC/E,GAAG;OACH,UAAU;OACb,CAAC;AAEF,aADuB,4BAA4B,IAAI,aAAa;;AAGxE;IACJ,KAAK;AACD,YAAO,KAAK,eAAgB,EACxB,cACA,GAAG,QACiD;MACpD,MAAM,WAAW,aAAa,IAAI,0BAA0B;MAC5D,MAAM,EAAE,iBAAiB,sCACrB,MAAM,OAAO,iBAAiB;OAC1B,GAAG;OACH;OACH,CAAC;AAGN,aAF6B,kCAAkC,IAAI,aAAa,CAChC,IAAI,8BAA8B;;AAGtF;IACJ;AACI,YAAO,KAAK,OAAO;AACnB;;AAIZ,UAAO,OAAO;;EAElB,iBAAiB;AACb,UAAO;;EAEX,iBAAiB;AACb,UAAO;;EAEd,CAAC"}
|
package/lib/esm/package.json
CHANGED
package/lib/types/index.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Transaction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, RemoteWalletAssociationConfig, TerminateSessionAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
|
|
3
|
+
|
|
4
|
+
//#region src/transact.d.ts
|
|
4
5
|
interface Web3SignAndSendTransactionsAPI {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
signAndSendTransactions<T extends Transaction | VersionedTransaction>(params: {
|
|
7
|
+
minContextSlot?: number;
|
|
8
|
+
commitment?: string;
|
|
9
|
+
skipPreflight?: boolean;
|
|
10
|
+
maxRetries?: number;
|
|
11
|
+
waitForCommitmentToSendNextTransaction?: boolean;
|
|
12
|
+
transactions: T[];
|
|
13
|
+
}): Promise<TransactionSignature[]>;
|
|
13
14
|
}
|
|
14
15
|
interface Web3SignTransactionsAPI {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
signTransactions<T extends Transaction | VersionedTransaction>(params: {
|
|
17
|
+
transactions: T[];
|
|
18
|
+
}): Promise<T[]>;
|
|
18
19
|
}
|
|
19
20
|
interface Web3SignMessagesAPI {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
|
|
26
|
-
}
|
|
27
|
-
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
21
|
+
signMessages(params: {
|
|
22
|
+
addresses: Base64EncodedAddress[];
|
|
23
|
+
payloads: Uint8Array[];
|
|
24
|
+
}): Promise<Uint8Array[]>;
|
|
28
25
|
}
|
|
26
|
+
interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {}
|
|
27
|
+
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {}
|
|
29
28
|
type Web3Scenario = Readonly<{
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
wallet: Promise<Web3MobileWallet>;
|
|
30
|
+
close: () => void;
|
|
32
31
|
}>;
|
|
33
32
|
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
34
|
-
|
|
33
|
+
associationUrl: URL;
|
|
35
34
|
}>;
|
|
36
35
|
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
36
|
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
-
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3RemoteScenario, Web3Scenario, startRemoteScenario, transact };
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/transact.ts"],"mappings":";;;;UA2BU,8BAAA;EACN,uBAAA,WAAkC,WAAA,GAAoB,oBAAA,EAAsB,MAAA;IACxE,cAAA;IACA,UAAA;IACA,aAAA;IACA,UAAA;IACA,sCAAA;IACA,YAAA,EAAc,CAAA;EAAA,IACd,OAAA,CAAQ,oBAAA;AAAA;AAAA,UAGN,uBAAA;EACN,gBAAA,WAA2B,WAAA,GAAoB,oBAAA,EAAsB,MAAA;IAAU,YAAA,EAAc,CAAA;EAAA,IAAQ,OAAA,CAAQ,CAAA;AAAA;AAAA,UAGvG,mBAAA;EACN,YAAA,CAAa,MAAA;IAAU,SAAA,EAAW,oBAAA;IAAwB,QAAA,EAAU,UAAA;EAAA,IAAiB,OAAA,CAAQ,UAAA;AAAA;AAAA,UAGhF,gBAAA,SAET,YAAA,EACA,qBAAA,EACA,cAAA,EACA,kBAAA,EACA,cAAA,EACA,8BAAA,EACA,uBAAA,EACA,mBAAA;AAAA,UAES,sBAAA,SAA+B,gBAAA,EAAkB,mBAAA;AAAA,KAEtD,YAAA,GAAe,QAAA;EACvB,MAAA,EAAQ,OAAA,CAAQ,gBAAA;EAChB,KAAA;AAAA;AAAA,KAGQ,kBAAA,GAAqB,YAAA,GAC7B,QAAA;EACI,cAAA,EAAgB,GAAA;AAAA;AAAA,iBA0BF,QAAA,SAAA,CAClB,QAAA,GAAW,MAAA,EAAQ,gBAAA,KAAqB,OAAA,EACxC,MAAA,GAAS,uBAAA,GACV,OAAA,CAAQ,OAAA;AAAA,iBAOW,mBAAA,CAAoB,MAAA,EAAQ,6BAAA,GAAgC,OAAA,CAAQ,kBAAA"}
|
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.2.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
|
+
"exports": {
|
|
12
|
+
"edge-light": {
|
|
13
|
+
"import": "./lib/esm/index.js",
|
|
14
|
+
"require": "./lib/cjs/index.js"
|
|
9
15
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"import": "./lib/esm/index.js",
|
|
14
|
-
"require": "./lib/cjs/index.js"
|
|
15
|
-
},
|
|
16
|
-
"workerd": {
|
|
17
|
-
"import": "./lib/esm/index.js",
|
|
18
|
-
"require": "./lib/cjs/index.js"
|
|
19
|
-
},
|
|
20
|
-
"browser": {
|
|
21
|
-
"import": "./lib/esm/index.browser.js",
|
|
22
|
-
"require": "./lib/cjs/index.browser.js"
|
|
23
|
-
},
|
|
24
|
-
"node": {
|
|
25
|
-
"import": "./lib/esm/index.js",
|
|
26
|
-
"require": "./lib/cjs/index.js"
|
|
27
|
-
},
|
|
28
|
-
"react-native": "./lib/cjs/index.native.js",
|
|
29
|
-
"types": "./lib/types/index.d.ts"
|
|
16
|
+
"workerd": {
|
|
17
|
+
"import": "./lib/esm/index.js",
|
|
18
|
+
"require": "./lib/cjs/index.js"
|
|
30
19
|
},
|
|
31
20
|
"browser": {
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
"import": "./lib/esm/index.browser.js",
|
|
22
|
+
"require": "./lib/cjs/index.browser.js"
|
|
34
23
|
},
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"types": "lib/types/index.d.ts",
|
|
39
|
-
"type": "module",
|
|
40
|
-
"files": [
|
|
41
|
-
"lib",
|
|
42
|
-
"LICENSE"
|
|
43
|
-
],
|
|
44
|
-
"sideEffects": false,
|
|
45
|
-
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
24
|
+
"node": {
|
|
25
|
+
"import": "./lib/esm/index.js",
|
|
26
|
+
"require": "./lib/cjs/index.js"
|
|
47
27
|
},
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
28
|
+
"react-native": "./lib/cjs/index.native.js",
|
|
29
|
+
"types": "./lib/types/index.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"browser": {
|
|
32
|
+
"./lib/cjs/index.js": "./lib/cjs/index.browser.js",
|
|
33
|
+
"./lib/esm/index.js": "./lib/esm/index.browser.js"
|
|
34
|
+
},
|
|
35
|
+
"main": "lib/cjs/index.js",
|
|
36
|
+
"module": "lib/esm/index.js",
|
|
37
|
+
"react-native": "lib/cjs/index.native.js",
|
|
38
|
+
"types": "lib/types/index.d.ts",
|
|
39
|
+
"type": "module",
|
|
40
|
+
"files": [
|
|
41
|
+
"lib",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@solana/web3.js": "^1.98.4"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"bs58": "^6.0.0",
|
|
53
|
+
"js-base64": "^3.7.5",
|
|
54
|
+
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.7"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@solana/web3.js": "^1.98.4",
|
|
58
|
+
"agadoo": "^3.0.0",
|
|
59
|
+
"cross-env": "^10.1.0",
|
|
60
|
+
"shx": "^0.4.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"clean": "shx rm -rf lib/*",
|
|
64
|
+
"build": "pnpm clean && tsdown --config ../../tsdown.config.ts",
|
|
65
|
+
"build:watch": "pnpm clean && tsdown --config ../../tsdown.config.ts --watch",
|
|
66
|
+
"check-types": "tsc -p tsconfig.json --noEmit",
|
|
67
|
+
"postbuild": "printf '%s' '{\"type\":\"commonjs\"}' > lib/cjs/package.json && printf '%s' '{\"type\":\"module\"}' > lib/esm/package.json"
|
|
68
|
+
}
|
|
69
69
|
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
-
import { Transaction as LegacyTransaction } from "@solana/web3.js";
|
|
3
|
-
import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, TerminateSessionAPI, WalletAssociationConfig, RemoteWalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
|
|
4
|
-
interface Web3SignAndSendTransactionsAPI {
|
|
5
|
-
signAndSendTransactions<T extends LegacyTransaction | VersionedTransaction>(params: {
|
|
6
|
-
minContextSlot?: number;
|
|
7
|
-
commitment?: string;
|
|
8
|
-
skipPreflight?: boolean;
|
|
9
|
-
maxRetries?: number;
|
|
10
|
-
waitForCommitmentToSendNextTransaction?: boolean;
|
|
11
|
-
transactions: T[];
|
|
12
|
-
}): Promise<TransactionSignature[]>;
|
|
13
|
-
}
|
|
14
|
-
interface Web3SignTransactionsAPI {
|
|
15
|
-
signTransactions<T extends LegacyTransaction | VersionedTransaction>(params: {
|
|
16
|
-
transactions: T[];
|
|
17
|
-
}): Promise<T[]>;
|
|
18
|
-
}
|
|
19
|
-
interface Web3SignMessagesAPI {
|
|
20
|
-
signMessages(params: {
|
|
21
|
-
addresses: Base64EncodedAddress[];
|
|
22
|
-
payloads: Uint8Array[];
|
|
23
|
-
}): Promise<Uint8Array[]>;
|
|
24
|
-
}
|
|
25
|
-
interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
|
|
26
|
-
}
|
|
27
|
-
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
|
-
}
|
|
29
|
-
type Web3Scenario = Readonly<{
|
|
30
|
-
wallet: Promise<Web3MobileWallet>;
|
|
31
|
-
close: () => void;
|
|
32
|
-
}>;
|
|
33
|
-
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
34
|
-
associationUrl: URL;
|
|
35
|
-
}>;
|
|
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 };
|
|
39
|
-
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/transact.ts"],"names":[],"mappings":""}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
-
import { Transaction as LegacyTransaction } from "@solana/web3.js";
|
|
3
|
-
import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, TerminateSessionAPI, WalletAssociationConfig, RemoteWalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
|
|
4
|
-
interface Web3SignAndSendTransactionsAPI {
|
|
5
|
-
signAndSendTransactions<T extends LegacyTransaction | VersionedTransaction>(params: {
|
|
6
|
-
minContextSlot?: number;
|
|
7
|
-
commitment?: string;
|
|
8
|
-
skipPreflight?: boolean;
|
|
9
|
-
maxRetries?: number;
|
|
10
|
-
waitForCommitmentToSendNextTransaction?: boolean;
|
|
11
|
-
transactions: T[];
|
|
12
|
-
}): Promise<TransactionSignature[]>;
|
|
13
|
-
}
|
|
14
|
-
interface Web3SignTransactionsAPI {
|
|
15
|
-
signTransactions<T extends LegacyTransaction | VersionedTransaction>(params: {
|
|
16
|
-
transactions: T[];
|
|
17
|
-
}): Promise<T[]>;
|
|
18
|
-
}
|
|
19
|
-
interface Web3SignMessagesAPI {
|
|
20
|
-
signMessages(params: {
|
|
21
|
-
addresses: Base64EncodedAddress[];
|
|
22
|
-
payloads: Uint8Array[];
|
|
23
|
-
}): Promise<Uint8Array[]>;
|
|
24
|
-
}
|
|
25
|
-
interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, GetCapabilitiesAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
|
|
26
|
-
}
|
|
27
|
-
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
|
-
}
|
|
29
|
-
type Web3Scenario = Readonly<{
|
|
30
|
-
wallet: Promise<Web3MobileWallet>;
|
|
31
|
-
close: () => void;
|
|
32
|
-
}>;
|
|
33
|
-
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
34
|
-
associationUrl: URL;
|
|
35
|
-
}>;
|
|
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 };
|
|
39
|
-
//# sourceMappingURL=index.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/transact.ts"],"names":[],"mappings":""}
|