Skip to content

Commit

Permalink
chore: remove metadata validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaisailovic committed Jun 13, 2024
1 parent 6653afa commit 6acdcb2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 68 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
48 changes: 0 additions & 48 deletions packages/sign-client/test/sdk/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,54 +50,6 @@ describe("Sign Client Integration", () => {
await deleteClients({ A: client, B: undefined });
});

it("should not 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");
});

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");
});

describe("connect", () => {
it("connect (with new pairing)", async () => {
const { clients, sessionA, pairingA } = await initTwoPairedClients(
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 6acdcb2

Please sign in to comment.