@multiplatform.one/web3 7.88.8 → 7.88.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/web3",
3
- "version": "7.88.8",
3
+ "version": "7.88.9",
4
4
  "description": "Web3 wallet integration for multiplatform.one ecosystem with ConnectKit and wagmi",
5
5
  "keywords": [
6
6
  "connectkit",
@@ -120,10 +120,10 @@
120
120
  "@aave/account": "^0.2.1",
121
121
  "@coinbase/wallet-sdk": "^4.4.0",
122
122
  "@metamask/connect-evm": "^2.1.1",
123
- "@multiplatform.one/connectkit": "^7.88.8",
124
- "@multiplatform.one/gpg": "^7.88.8",
125
- "@multiplatform.one/platform": "^7.88.8",
126
- "@multiplatform.one/theme": "^7.88.8",
123
+ "@multiplatform.one/connectkit": "^7.88.9",
124
+ "@multiplatform.one/gpg": "^7.88.9",
125
+ "@multiplatform.one/platform": "^7.88.9",
126
+ "@multiplatform.one/theme": "^7.88.9",
127
127
  "@noble/ciphers": "^1.3.0",
128
128
  "@noble/curves": "^1.9.7",
129
129
  "@phosphor-icons/react": "^2.1.10",
@@ -147,8 +147,8 @@
147
147
  "wagmi": "^3.7.1"
148
148
  },
149
149
  "devDependencies": {
150
- "@multiplatform.one/config": "7.88.8",
151
- "@multiplatform.one/test-utils": "7.88.8",
150
+ "@multiplatform.one/config": "7.88.9",
151
+ "@multiplatform.one/test-utils": "7.88.9",
152
152
  "@tamagui/build": "2.7.6",
153
153
  "@tanstack/react-query": "^5.104.3",
154
154
  "@testing-library/jest-dom": "^7.0.1",
@@ -225,6 +225,110 @@ describe("phantomDeeplink", () => {
225
225
  });
226
226
  });
227
227
 
228
+ describe("phantomDeeplink answers and edges", () => {
229
+ function connected() {
230
+ const phantom = fakePhantom();
231
+ const ctx = setup();
232
+ ctx.client.handleRedirect(phantom.approveConnect(ctx.client.connect()));
233
+ return { phantom, ...ctx };
234
+ }
235
+
236
+ it("signs every transaction in one trip and returns each signed copy", () => {
237
+ const { phantom, client } = connected();
238
+ const txs = [Uint8Array.from([1]), Uint8Array.from([2, 3])];
239
+ const request = phantom.open(client.signAllTransactions(txs));
240
+ expect(request.method).toBe("signAllTransactions");
241
+ expect(request.payload).toEqual({
242
+ transactions: txs.map((tx) => bs58.encode(tx)),
243
+ session: phantom.session,
244
+ });
245
+ const signed = [Uint8Array.from([8]), Uint8Array.from([9, 9])];
246
+ expect(
247
+ client.handleRedirect(
248
+ phantom.approve(request.redirect, { transactions: signed.map((tx) => bs58.encode(tx)) }),
249
+ ),
250
+ ).toEqual({ ok: true, method: "signAllTransactions", transactions: signed });
251
+ expect(client.pending).toBeUndefined();
252
+ });
253
+
254
+ it("sends a transaction without options and signs raw message bytes without a display", () => {
255
+ const { phantom, client } = connected();
256
+ expect(phantom.open(client.signAndSendTransaction(Uint8Array.from([4]))).payload).toEqual({
257
+ transaction: bs58.encode(Uint8Array.from([4])),
258
+ session: phantom.session,
259
+ });
260
+ const bytes = Uint8Array.from([0, 255]);
261
+ expect(phantom.open(client.signMessage(bytes)).payload).toEqual({
262
+ message: bs58.encode(bytes),
263
+ session: phantom.session,
264
+ });
265
+ });
266
+
267
+ it("refuses an answer this browser holds no request for", () => {
268
+ const phantom = fakePhantom();
269
+ const other = setup();
270
+ const back = phantom.approveConnect(other.client.connect());
271
+ const { client } = setup();
272
+ expect(client.handleRedirect(back)).toEqual({
273
+ ok: false,
274
+ method: undefined,
275
+ errorCode: "-32603",
276
+ errorMessage: "Phantom answered, but this browser holds no matching request",
277
+ });
278
+ });
279
+
280
+ it("refuses a connect answer that carries no encryption key", () => {
281
+ const phantom = fakePhantom();
282
+ const { client } = setup();
283
+ const back = new URL(
284
+ phantom.approveConnect(client.connect()).replace("?mobile=1?", "?mobile=1&"),
285
+ );
286
+ back.searchParams.delete("phantom_encryption_public_key");
287
+ expect(client.handleRedirect(back.toString())).toMatchObject({
288
+ ok: false,
289
+ method: "connect",
290
+ errorMessage: "Phantom's answer carries no encryption key",
291
+ });
292
+ });
293
+
294
+ it("refuses an answer to a request it did not make", () => {
295
+ const { phantom, client, storage, config } = connected();
296
+ const [key] = [...storage.data.keys()];
297
+ const record = JSON.parse(storage.data.get(key)!);
298
+ storage.data.set(key, JSON.stringify({ ...record, pending: { method: "teleport", at: 1 } }));
299
+ expect(
300
+ phantomDeeplink(config).handleRedirect(phantom.approve(config.redirectLink, { ok: 1 })),
301
+ ).toMatchObject({
302
+ ok: false,
303
+ method: "teleport",
304
+ errorMessage: "Phantom answered a request this browser did not make",
305
+ });
306
+ expect(client.connected).toBe(true);
307
+ });
308
+
309
+ it("treats an unreadable stored session as none, and forget drops it", () => {
310
+ const { client, storage } = connected();
311
+ const [key] = [...storage.data.keys()];
312
+ client.forget();
313
+ expect(storage.data.has(key)).toBe(false);
314
+ storage.data.set(key, "{not json");
315
+ expect(client.connected).toBe(false);
316
+ });
317
+
318
+ it("asks for storage and a location when the page has neither", () => {
319
+ vi.stubGlobal("localStorage", undefined);
320
+ vi.stubGlobal("location", undefined);
321
+ try {
322
+ const client = phantomDeeplink({ appUrl: "https://app.example", navigate: vi.fn() });
323
+ expect(() => client.connect()).toThrow(/pass `redirectLink`|pass `storage`/);
324
+ expect(() => client.handleRedirect()).toThrow(/no location here/);
325
+ expect(() => client.forget()).toThrow(/no localStorage here/);
326
+ } finally {
327
+ vi.unstubAllGlobals();
328
+ }
329
+ });
330
+ });
331
+
228
332
  describe("sendSolanaTransaction", () => {
229
333
  it("posts the signed bytes as base64 and returns the signature", async () => {
230
334
  const fetch = vi.fn(