Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build errors #1

Draft
wants to merge 1 commit into
base: v2.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/core/src/controllers/pairing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class Pairing implements IPairing {
const payload = formatJsonRpcResult(id, result);
const message = await this.core.crypto.encode(topic, payload);
const record = await this.core.history.get(topic, id);
const opts = PAIRING_RPC_OPTS[record.request.method].res;
const opts = PAIRING_RPC_OPTS[record.request.method as keyof typeof PAIRING_RPC_OPTS].res;
await this.core.relayer.publish(topic, message, opts);
await this.core.history.resolve(payload);
};
Expand All @@ -213,8 +213,8 @@ export class Pairing implements IPairing {
const payload = formatJsonRpcError(id, error);
const message = await this.core.crypto.encode(topic, payload);
const record = await this.core.history.get(topic, id);
const opts = PAIRING_RPC_OPTS[record.request.method]
? PAIRING_RPC_OPTS[record.request.method].res
const opts = PAIRING_RPC_OPTS[record.request.method as keyof typeof PAIRING_RPC_OPTS]
? PAIRING_RPC_OPTS[record.request.method as keyof typeof PAIRING_RPC_OPTS].res
: PAIRING_RPC_OPTS.unregistered_method.res;

await this.core.relayer.publish(topic, message, opts);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/controllers/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export class Subscriber extends ISubscriber {
return await subscribe;
} catch (err) {
this.relayer.events.emit(RELAYER_EVENTS.connection_stalled);
throw err;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/sign-client/src/controllers/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ export class Engine extends IEngine {
this.client.logger.error(`sendResult() -> history.get(${topic}, ${id}) failed`);
throw error;
}
const opts = ENGINE_RPC_OPTS[record.request.method].res;
const opts = ENGINE_RPC_OPTS[record.request.method as keyof typeof ENGINE_RPC_OPTS].res;
if (throwOnFailedPublish) {
opts.internal = {
...opts.internal,
Expand Down Expand Up @@ -1266,7 +1266,7 @@ export class Engine extends IEngine {
this.client.logger.error(`sendError() -> history.get(${topic}, ${id}) failed`);
throw error;
}
const opts = rpcOpts || ENGINE_RPC_OPTS[record.request.method].res;
const opts = rpcOpts || ENGINE_RPC_OPTS[record.request.method as keyof typeof ENGINE_RPC_OPTS].res;
// await is intentionally omitted to speed up performance
this.client.core.relayer.publish(topic, message, opts);
await this.client.core.history.resolve(payload);
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"uint8arrays": "3.1.0"
},
"devDependencies": {
"@types/lodash.isequal": "4.5.6"
"@types/lodash.isequal": "4.5.6",
"vite": "^5.3.5"
}
}
6 changes: 3 additions & 3 deletions packages/utils/src/cacao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export function addResourceToRecap(recap: RecapType, resource: string, actions:
obj.att[key] = recap.att[key];
return obj;
},
{ att: {} },
{ att: {} as RecapType["att"] },
);
return sorted;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ export function mergeRecaps(recap1: RecapType, recap2: RecapType) {
const keys = Object.keys(recap1.att)
.concat(Object.keys(recap2.att))
.sort((a, b) => a.localeCompare(b));
const mergedRecap = { att: {} };
const mergedRecap: RecapType = { att: {} };
keys.forEach((key) => {
const actions = Object.keys(recap1.att?.[key] || {})
.concat(Object.keys(recap2.att?.[key] || {}))
Expand Down Expand Up @@ -344,7 +344,7 @@ export function formatStatementFromRecap(statement = "", recap: RecapType) {
});
//
actions.sort((a, b) => a.action.localeCompare(b.action));
const uniqueAbilities = {};
const uniqueAbilities: { [key: string]: any } = {};
actions.forEach((action: any) => {
if (!uniqueAbilities[action.ability]) {
uniqueAbilities[action.ability] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/memoryStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const memoryStore = {};
const memoryStore: { [key: string]: any } = {};

export abstract class MemoryStore {
static get<T = unknown>(key: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export function mapEntries<A = any, B = any>(
obj: Record<string, A>,
cb: (x: A) => B,
): Record<string, B> {
const res = {};
const res: { [key: string]: any } = {};
Object.keys(obj).forEach((key) => {
res[key] = cb(obj[key]);
});
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/src/namespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function getRequiredNamespacesFromNamespaces(
const validNamespacesError = isValidNamespaces(namespaces, caller);
if (validNamespacesError) throw new Error(validNamespacesError.message);

const required = {};
const required: { [key: string]: any } = {};
for (const [namespace, values] of Object.entries(namespaces)) {
required[namespace] = {
methods: values.methods,
Expand Down Expand Up @@ -91,7 +91,7 @@ export function buildApprovedNamespaces(
const normalizedOptional = normalizeNamespaces(optionalNamespaces);

// build approved namespaces
const namespaces = {};
const namespaces: { [key: string]: any } = {};
Object.keys(supportedNamespaces).forEach((namespace) => {
const supportedChains = supportedNamespaces[namespace].chains;
const supportedMethods = supportedNamespaces[namespace].methods;
Expand All @@ -116,7 +116,7 @@ export function buildApprovedNamespaces(
const err = isConformingNamespaces(requiredNamespaces, namespaces, "approve()");
if (err) throw new Error(err.message);

const approvedNamespaces = {};
const approvedNamespaces: { [key: string]: any } = {};

// if both required & optional namespaces are empty, return all supported namespaces by the wallet
if (!Object.keys(requiredNamespaces).length && !Object.keys(optionalNamespaces).length)
Expand Down Expand Up @@ -230,7 +230,7 @@ export function normalizeNamespaces(
}

export function getNamespacesFromAccounts(accounts: string[]) {
const namespaces = {};
const namespaces: { [key: string]: any } = {};
accounts?.forEach((account) => {
const [namespace, chainId] = account.split(":");
if (!namespaces[namespace]) {
Expand Down
7 changes: 4 additions & 3 deletions packages/utils/src/uri.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as qs from "query-string";
import { EngineTypes, RelayerTypes } from "@walletconnect/types";


// -- uri -------------------------------------------------- //

export function parseRelayParams(params: any, delimiter = "-"): RelayerTypes.ProtocolOptions {
Expand Down Expand Up @@ -50,11 +51,11 @@ export function parseTopic(topic: string): string {

export function formatRelayParams(relay: RelayerTypes.ProtocolOptions, delimiter = "-") {
const prefix = "relay";
const params: any = {};
const params: Record<string, unknown> = {};
Object.keys(relay).forEach((key) => {
const k = prefix + delimiter + key;
if (relay[key]) {
params[k] = relay[key];
if (relay[key as keyof RelayerTypes.ProtocolOptions]) {
params[k] = relay[key as keyof RelayerTypes.ProtocolOptions];
}
});
return params;
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ export function isConformingNamespaces(
}

function parseNamespaces(namespaces: ProposalTypes.RequiredNamespaces) {
const parsed = {};
const parsed: { [key: string]: any } = {};
Object.keys(namespaces).forEach((key) => {
// e.g. `eip155:1`
const isInlineChainDefinition = key.includes(":");
Expand Down Expand Up @@ -468,7 +468,7 @@ function filterDuplicateNamespaces(namespaces: string[]) {
}

function parseApprovedNamespaces(namespaces: SessionTypes.Namespaces) {
const parsed = {};
const parsed: { [key: string]: any } = {};
Object.keys(namespaces).forEach((key) => {
const isInlineChainDefinition = key.includes(":");
if (isInlineChainDefinition) {
Expand Down
4 changes: 2 additions & 2 deletions packages/web3wallet/src/controllers/engine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthClient, AuthEngineTypes, IAuthClient } from "@walletconnect/auth-client";
import { SignClient } from "@walletconnect/sign-client";
import { ISignClient } from "@walletconnect/types";
import { ISignClient, SessionTypes } from "@walletconnect/types";
import { IWeb3WalletEngine, Web3WalletTypes } from "../types";

export class Engine extends IWeb3WalletEngine {
Expand Down Expand Up @@ -74,7 +74,7 @@ export class Engine extends IWeb3WalletEngine {
return sessions.reduce((sessions, session) => {
sessions[session.topic] = session;
return sessions;
}, {});
}, {} as Record<string, SessionTypes.Struct>);
};

public getPendingSessionProposals: IWeb3WalletEngine["getPendingSessionProposals"] = () => {
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/cardano.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CardanoProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const rpcURL = this.getCardanoRPCUrl(chain);
const parsedChain = getChainId(chain);
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CosmosProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const parsedChainId = getChainId(chain);
http[parsedChainId] = this.createHttpProvider(parsedChainId, this.namespace.rpcMap?.[chain]);
Expand Down
15 changes: 11 additions & 4 deletions providers/universal-provider/src/providers/eip155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Eip155Provider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const parsedChain = parseInt(getChainId(chain));
http[parsedChain] = this.createHttpProvider(parsedChain, this.namespace.rpcMap?.[chain]);
Expand Down Expand Up @@ -138,7 +138,12 @@ class Eip155Provider implements IProvider {
}

private async handleSwitchChain(args: RequestParams): Promise<any> {
let hexChainId = args.request.params ? args.request.params[0]?.chainId : "0x0";
let hexChainId = "0x0";
const params = args.request.params;
if (params && Array.isArray(params) && params.length > 0) {
hexChainId = params[0]?.chainId;
}

hexChainId = hexChainId.startsWith("0x") ? hexChainId : `0x${hexChainId}`;
const parsedChainId = parseInt(hexChainId, 16);
// if chainId is already approved, switch locally
Expand Down Expand Up @@ -173,10 +178,12 @@ class Eip155Provider implements IProvider {

private async getCapabilities(args: RequestParams) {
// if capabilities are stored in the session, return them, else send the request to the wallet
const address = args.request?.params?.[0];
const params = args.request?.params;
const address = Array.isArray(params) ? params[0] as string : undefined;
if (!address) throw new Error("Missing address parameter in `wallet_getCapabilities` request");
const session = this.client.session.get(args.topic);
const sessionCapabilities = session?.sessionProperties?.capabilities || {};
const sessionCapabilities: Record<string, any> = (session?.sessionProperties?.capabilities || {}) as Record<string, any>;

if (sessionCapabilities?.[address]) {
return sessionCapabilities?.[address];
}
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/elrond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ElrondProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const parsedChainId = getChainId(chain);
http[parsedChainId] = this.createHttpProvider(parsedChainId, this.namespace.rpcMap?.[chain]);
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/multiversx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MultiversXProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const parsedChainId = getChainId(chain);
http[parsedChainId] = this.createHttpProvider(parsedChainId, this.namespace.rpcMap?.[chain]);
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/near.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class NearProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
http[chain] = this.createHttpProvider(chain, this.namespace.rpcMap?.[chain]);
});
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/polkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PolkadotProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const parsedChainId = getChainId(chain);
http[parsedChainId] = this.createHttpProvider(parsedChainId, this.namespace.rpcMap?.[chain]);
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/providers/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SolanaProvider implements IProvider {
}

private createHttpProviders(): RpcProvidersMap {
const http = {};
const http: { [key: string]: any } = {};
this.namespace.chains.forEach((chain) => {
const parsedChainId = getChainId(chain);
http[parsedChainId] = this.createHttpProvider(parsedChainId, this.namespace.rpcMap?.[chain]);
Expand Down
2 changes: 1 addition & 1 deletion providers/universal-provider/src/utils/globals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const globals = {};
const globals: { [key: string]: any } = {};
export const getGlobal = (key: string) => {
return globals[key];
};
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"suppressImplicitAnyIndexErrors": true
"ignoreDeprecations": "5.0"
},
"include": ["**/package.json", "packages", "providers"]
}