Skip to content

Commit

Permalink
Merge branch 'v2.0' into refactor/replace-stablelibs-with-noble
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/utils/package.json
  • Loading branch information
ganchoradkov committed Jan 23, 2025
2 parents c174548 + fc73374 commit 3b77b0e
Show file tree
Hide file tree
Showing 18 changed files with 231 additions and 100 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"packages/*",
"providers/*"
],
"version": "2.17.4"
"version": "2.17.5"
}
80 changes: 40 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@walletconnect/core",
"description": "Core for WalletConnect Protocol",
"version": "2.17.4",
"version": "2.17.5",
"author": "WalletConnect, Inc. <walletconnect.com>",
"homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
"license": "Apache-2.0",
Expand Down Expand Up @@ -42,8 +42,8 @@
"@walletconnect/relay-auth": "1.0.4-canary-bnl-1",
"@walletconnect/safe-json": "1.0.2",
"@walletconnect/time": "1.0.2",
"@walletconnect/types": "2.17.4",
"@walletconnect/utils": "2.17.4",
"@walletconnect/types": "2.17.5",
"@walletconnect/utils": "2.17.5",
"@walletconnect/window-getters": "1.0.1",
"events": "3.3.0",
"lodash.isequal": "4.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/constants/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RELAYER_STORAGE_OPTIONS = {

// Updated automatically via `new-version` npm script.

export const RELAYER_SDK_VERSION = "2.17.4";
export const RELAYER_SDK_VERSION = "2.17.5";

// delay to wait before closing the transport connection after init if not active
export const RELAYER_TRANSPORT_CUTOFF = 10_000;
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/controllers/pairing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
isJsonRpcResult,
isJsonRpcError,
} from "@walletconnect/jsonrpc-utils";
import { FIVE_MINUTES, THIRTY_DAYS, toMiliseconds } from "@walletconnect/time";
import { FIVE_MINUTES, toMiliseconds } from "@walletconnect/time";
import EventEmitter from "events";
import {
PAIRING_CONTEXT,
Expand Down Expand Up @@ -187,14 +187,18 @@ export class Pairing implements IPairing {

public activate: IPairing["activate"] = async ({ topic }) => {
this.isInitialized();
const expiry = calcExpiry(THIRTY_DAYS);
const expiry = calcExpiry(FIVE_MINUTES);
this.core.expirer.set(topic, expiry);
await this.pairings.update(topic, { active: true, expiry });
};

/**
* @deprecated Ping will be removed in the next major release.
*/
public ping: IPairing["ping"] = async (params) => {
this.isInitialized();
await this.isValidPing(params);
this.logger.warn("ping() is deprecated and will be removed in the next major release.");
const { topic } = params;
if (this.pairings.keys.includes(topic)) {
const id = await this.sendRequest(topic, "wc_pairingPing", {});
Expand Down
11 changes: 8 additions & 3 deletions packages/core/test/pairing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { expect, describe, it, beforeEach, afterEach } from "vitest";
import { ICore } from "@walletconnect/types";
import { Core, CORE_PROTOCOL, CORE_VERSION, PAIRING_EVENTS, SUBSCRIBER_EVENTS } from "../src";
import { TEST_CORE_OPTIONS, disconnectSocket, waitForEvent } from "./shared";
import { generateRandomBytes32, parseUri, toBase64 } from "@walletconnect/utils";
import { calcExpiry, generateRandomBytes32, parseUri, toBase64 } from "@walletconnect/utils";
import { FIVE_MINUTES } from "@walletconnect/time";

const createCoreClients: () => Promise<{ coreA: ICore; coreB: ICore }> = async () => {
const coreA = new Core(TEST_CORE_OPTIONS);
Expand Down Expand Up @@ -121,8 +122,12 @@ describe("Pairing", () => {
const inactivePairing = coreA.pairing.pairings.get(topic);
expect(inactivePairing.active).toBe(false);
await coreA.pairing.activate({ topic });
expect(coreA.pairing.pairings.get(topic).active).toBe(true);
expect(coreA.pairing.pairings.get(topic).expiry > inactivePairing.expiry).toBe(true);
const activePairing = coreA.pairing.pairings.get(topic);
expect(activePairing.active).toBe(true);
// inactive pairing should have an expiry of 5 minutes
expect(inactivePairing.expiry).to.be.approximately(calcExpiry(FIVE_MINUTES), 5);
// active pairing should still have an expiry of 5 minutes
expect(activePairing.expiry).to.be.approximately(calcExpiry(FIVE_MINUTES), 5);
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@walletconnect/react-native-compat",
"description": "Shims for WalletConnect Protocol in React Native Projects",
"version": "2.17.4",
"version": "2.17.5",
"author": "WalletConnect, Inc. <walletconnect.com>",
"homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
"license": "Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/sign-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@walletconnect/sign-client",
"description": "Sign Client for WalletConnect Protocol",
"version": "2.17.4",
"version": "2.17.5",
"author": "WalletConnect, Inc. <walletconnect.com>",
"homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
"license": "Apache-2.0",
Expand Down Expand Up @@ -38,14 +38,14 @@
"prettier": "prettier --check '{src,test}/**/*.{js,ts,jsx,tsx}'"
},
"dependencies": {
"@walletconnect/core": "2.17.4",
"@walletconnect/core": "2.17.5",
"@walletconnect/events": "1.0.1",
"@walletconnect/heartbeat": "1.2.2",
"@walletconnect/jsonrpc-utils": "1.0.8",
"@walletconnect/logger": "2.1.2",
"@walletconnect/time": "1.0.2",
"@walletconnect/types": "2.17.4",
"@walletconnect/utils": "2.17.4",
"@walletconnect/types": "2.17.5",
"@walletconnect/utils": "2.17.5",
"events": "3.3.0"
},
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion packages/sign-client/src/controllers/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ export class Engine extends IEngine {
let topic = pairingTopic;
let uri: string | undefined;
let active = false;

try {
if (topic) {
const pairing = this.client.core.pairing.pairings.get(topic);
this.client.logger.warn(
"connect() with existing pairing topic is deprecated and will be removed in the next major release.",
);
active = pairing.active;
}
} catch (error) {
Expand Down Expand Up @@ -681,6 +683,9 @@ export class Engine extends IEngine {
done(),
]);
} else if (this.client.core.pairing.pairings.keys.includes(topic)) {
this.client.logger.warn(
"ping() on pairing topic is deprecated and will be removed in the next major release.",
);
await this.client.core.pairing.ping({ topic });
}
};
Expand Down
7 changes: 4 additions & 3 deletions packages/sign-client/test/sdk/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("Authenticated Sessions", () => {
name: "wallet",
metadata: TEST_APP_METADATA_B,
});
await Promise.all([
const result = await Promise.all([
Promise.race<void>([
new Promise((resolve) => {
wallet.on("session_authenticate", async (payload) => {
Expand Down Expand Up @@ -110,8 +110,9 @@ describe("Authenticated Sessions", () => {
wallet.pair({ uri });
resolve();
}),
]);
const session = (await response()).session;
response(),
]).then((res) => res[2]);
const session = result.session;
const walletSession = wallet.session.get(session.topic);
// approved namespaces on both sides must be equal
expect(JSON.stringify(session.namespaces)).to.eq(JSON.stringify(walletSession.namespaces));
Expand Down
Loading

0 comments on commit 3b77b0e

Please sign in to comment.