Skip to content

Commit

Permalink
Merge pull request #4615 from WalletConnect/chore/remove-metadata-val…
Browse files Browse the repository at this point in the history
…idation

chore: remove metadata validation
  • Loading branch information
lukaisailovic authored Jun 14, 2024
2 parents 6653afa + d092b56 commit fd1da7d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 62 deletions.
13 changes: 0 additions & 13 deletions packages/sign-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ export class SignClient extends ISignClient {
return this.core.pairing.pairings;
}

private validateMetadata(metadata: SignClientTypes.Metadata) {
if (!metadata.name) {
throw new Error("name is required value in metadata");
}
if (!metadata.description) {
throw new Error("description is required value in metadata");
}
if (!metadata.url) {
throw new Error("url is required value in metadata");
}
}

// ---------- Events ----------------------------------------------- //

public on: ISignClientEvents["on"] = (name, listener) => {
Expand Down Expand Up @@ -257,7 +245,6 @@ export class SignClient extends ISignClient {
private async initialize() {
this.logger.trace(`Initialized`);
try {
await this.validateMetadata(this.metadata);
await this.core.start();
await this.session.init();
await this.proposal.init();
Expand Down
59 changes: 17 additions & 42 deletions packages/sign-client/test/sdk/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,52 +50,27 @@ describe("Sign Client Integration", () => {
await deleteClients({ A: client, B: undefined });
});

it("should not initialize without metadata object", async () => {
it("should initialize without metadata object", async () => {
const options = TEST_SIGN_CLIENT_OPTIONS;
delete options.metadata;

await expect(
SignClient.init({
...options,
name: "init",
signConfig: { disableRequestQueue: true },
}),
).rejects.toThrowError("name is required value in metadata");
});

it("should not initialize with empty metadata", async () => {
await expect(
SignClient.init({
...TEST_SIGN_CLIENT_OPTIONS,
metadata: TEST_EMPTY_METADATA,
name: "init",
signConfig: { disableRequestQueue: true },
}),
).rejects.toThrowError("name is required value in metadata");
const client = await SignClient.init({
...options,
name: "init",
signConfig: { disableRequestQueue: true },
});
expect(client).to.be.exist;
await deleteClients({ A: client, B: undefined });
});

it("should not initialize with invalid metadata", async () => {
await expect(
SignClient.init({
...TEST_SIGN_CLIENT_OPTIONS,
metadata: TEST_INVALID_METADATA,
name: "init",
signConfig: { disableRequestQueue: true },
}),
).rejects.toThrowError("description is required value in metadata");
});
it("should not initialize with invalid metadata url", async () => {
await expect(
SignClient.init({
...TEST_SIGN_CLIENT_OPTIONS,
metadata: {
...TEST_INVALID_METADATA,
description: "description",
},
name: "init",
signConfig: { disableRequestQueue: true },
}),
).rejects.toThrowError("url is required value in metadata");
it("should initialize with empty metadata", async () => {
const client = await SignClient.init({
...TEST_SIGN_CLIENT_OPTIONS,
metadata: TEST_EMPTY_METADATA,
name: "init",
signConfig: { disableRequestQueue: true },
});
expect(client).to.be.exist;
await deleteClients({ A: client, B: undefined });
});

describe("connect", () => {
Expand Down
7 changes: 1 addition & 6 deletions providers/ethereum-provider/src/EthereumProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,12 @@ export class EthereumProvider implements IEthereumProvider {
protected async initialize(opts: EthereumProviderOptions) {
this.rpc = this.getRpcConfig(opts);

const metadata = this.rpc.metadata;
if (metadata === undefined) {
throw new Error("Metadata field is required");
}

this.chainId = this.rpc.chains.length
? getEthereumChainId(this.rpc.chains)
: getEthereumChainId(this.rpc.optionalChains);
this.signer = await UniversalProvider.init({
projectId: this.rpc.projectId,
metadata,
metadata: this.rpc.metadata,
disableProviderPing: opts.disableProviderPing,
relayUrl: opts.relayUrl,
storageOptions: opts.storageOptions,
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/types/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IProvider } from "./providers";

export interface UniversalProviderOpts {
projectId?: string;
metadata: Metadata;
metadata?: Metadata;
logger?: string | Logger;
client?: SignClient;
relayUrl?: string;
Expand Down

0 comments on commit fd1da7d

Please sign in to comment.