Skip to content
Merged
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
10 changes: 7 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,17 @@ const config = createConfig([
},
},

// Wasm example
// Examples
{
files: ['packages/examples/packages/wasm/src/index.ts'],
files: [
'packages/examples/packages/rollup-plugin/rollup.config.mjs',
'packages/examples/packages/wasm/src/index.ts',
],

rules: {
// This rule changes depending on whether the build files exist or not.
// These rules change depending on whether the build files exist or not.
'import-x/extensions': 'off',
'import-x/no-unresolved': 'off',
},
},
]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@metamask/eslint-config-jest": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@swc/core": "1.3.78",
"@ts-bridge/cli": "^0.6.1",
"@types/jest": "^27.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@metamask/key-tree": "^10.1.1",
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@noble/ed25519": "^1.6.0",
"@noble/secp256k1": "^1.7.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@metamask/key-tree": "^10.1.1",
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@noble/bls12-381": "^1.2.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/file-upload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-entropy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@noble/bls12-381": "^1.2.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/interactive-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@metamask/key-tree": "^10.1.1",
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@noble/hashes": "^1.7.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@metamask/key-tree": "^10.1.1",
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@noble/curves": "^1.1.0",
"async-mutex": "^0.5.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@metamask/auto-changelog": "^5.0.1",
"@metamask/snaps-cli": "workspace:^",
"@metamask/snaps-jest": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@swc/core": "1.3.78",
"@swc/jest": "^0.2.26",
"@types/node": "18.14.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/manage-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/network-access/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/preinstalled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@metamask/snaps-cli": "workspace:^",
"@metamask/snaps-controllers": "workspace:^",
"@metamask/snaps-jest": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@swc/core": "1.3.78",
"@swc/jest": "^0.2.26",
"@types/node": "18.14.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line
import snaps from '@metamask/snaps-rollup-plugin';
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/send-flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@metamask/rpc-errors": "^7.0.2",
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@metamask/snaps-sdk": "workspace:^",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@metamask/snaps-utils": "workspace:^",
"@metamask/snaps-webpack-plugin": "workspace:^",
"@metamask/superstruct": "^3.2.1",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@swc/core": "1.3.78",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"@metamask/snaps-rpc-methods": "workspace:^",
"@metamask/snaps-sdk": "workspace:^",
"@metamask/snaps-utils": "workspace:^",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@xstate/fsm": "^2.0.0",
"async-mutex": "^0.5.0",
"browserify-zlib": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-execution-environments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@metamask/snaps-sdk": "workspace:^",
"@metamask/snaps-utils": "workspace:^",
"@metamask/superstruct": "^3.2.1",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"nanoid": "^3.3.10",
"readable-stream": "^3.6.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Json, JsonRpcRequest, JsonRpcResponse } from '@metamask/utils';
import type { JsonRpcRequest, JsonRpcResponse } from '@metamask/utils';
import type { DuplexOptions, Readable } from 'readable-stream';
import { Duplex } from 'readable-stream';

Expand Down Expand Up @@ -157,7 +157,7 @@ export class TestSnapExecutor extends BaseSnapExecutor {

public async writeRpc(message: {
name: string;
data: JsonRpcResponse<Json>;
data: JsonRpcResponse;
}): Promise<void> {
return new Promise((resolve, reject) =>
this.#rpcLeft.write(message, (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from '@metamask/superstruct';
import type {
CaipChainId,
Json,
JsonRpcRequest,
JsonRpcSuccess,
} from '@metamask/utils';
Expand Down Expand Up @@ -372,7 +371,7 @@ type RequestParams<Params extends unknown[] | undefined> =

type RequestFunction<
Args extends RequestArguments,
ResponseType extends JsonRpcSuccess<Json>,
ResponseType extends JsonRpcSuccess,
> = (...args: RequestParams<Args>) => Promise<ResponseType['result']>;

export type Ping = RequestFunction<PingRequestArguments, OkResponse>;
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@metamask/snaps-sdk": "workspace:^",
"@metamask/snaps-simulation": "workspace:^",
"@metamask/superstruct": "^3.2.1",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"express": "^4.21.2",
"jest-environment-node": "^29.5.0",
"jest-matcher-utils": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-rpc-methods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@metamask/snaps-sdk": "workspace:^",
"@metamask/snaps-utils": "workspace:^",
"@metamask/superstruct": "^3.2.1",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@noble/hashes": "^1.7.1",
"luxon": "^3.5.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export type ProviderRequestParameters = InferMatching<
*/
async function providerRequestImplementation(
req: JsonRpcRequest<ProviderRequestParams>,
// `ProviderRequestResult` is an alias for `Json` (which is the default type
// argument for `PendingJsonRpcResponse`), but that may not be the case in the
// future. We use `ProviderRequestResult` here to make it clear that this is
// the expected type of the result.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
res: PendingJsonRpcResponse<ProviderRequestResult>,
_next: unknown,
end: JsonRpcEngineEndCallback,
Expand Down
5 changes: 5 additions & 0 deletions packages/snaps-rpc-methods/src/permitted/getState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export type GetStateParameters = InferMatching<
*/
async function getStateImplementation(
request: JsonRpcRequest<GetStateParameters>,
// `GetStateResult` is an alias for `Json` (which is the default type argument
// for `PendingJsonRpcResponse`), but that may not be the case in the future.
// We use `GetStateResult` here to make it clear that this is the expected
// type of the result.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
response: PendingJsonRpcResponse<GetStateResult>,
_next: unknown,
end: JsonRpcEngineEndCallback,
Expand Down
5 changes: 5 additions & 0 deletions packages/snaps-rpc-methods/src/permitted/invokeKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export type InvokeKeyringHooks = {
*/
async function invokeKeyringImplementation(
req: JsonRpcRequest<InvokeKeyringParams>,
// `InvokeKeyringResult` is an alias for `Json` (which is the default type
// argument for `PendingJsonRpcResponse`), but that may not be the case in the
// future. We use `InvokeKeyringResult` here to make it clear that this is the
// expected type of the result.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
res: PendingJsonRpcResponse<InvokeKeyringResult>,
_next: unknown,
end: JsonRpcEngineEndCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
JsonRpcEngineNextCallback,
} from '@metamask/json-rpc-engine';
import { rpcErrors } from '@metamask/rpc-errors';
import type { InvokeSnapParams, InvokeSnapResult } from '@metamask/snaps-sdk';
import type { InvokeSnapParams } from '@metamask/snaps-sdk';
import type { PendingJsonRpcResponse } from '@metamask/utils';
import { assertIsJsonRpcSuccess, jsonrpc2 } from '@metamask/utils';

Expand All @@ -17,11 +17,12 @@ describe('wallet_invokeSnap', () => {
method: 'wallet_invokeSnap',
params,
});

const getMockRpcResponse = () =>
({
id: 'some-id',
jsonrpc: jsonrpc2,
}) as PendingJsonRpcResponse<InvokeSnapResult>;
}) as PendingJsonRpcResponse;

it('invokes snap using hook', async () => {
const params = {
Expand Down
5 changes: 5 additions & 0 deletions packages/snaps-rpc-methods/src/permitted/invokeSnapSugar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export type InvokeSnapSugarHooks = {
*/
export async function invokeSnapSugar(
req: JsonRpcRequest<InvokeSnapParams>,
// `InvokeSnapResult` is an alias for `Json` (which is the default type
// argument for `PendingJsonRpcResponse`), but that may not be the case in the
// future. We use `InvokeSnapResult` here to make it clear that this is the
// expected type of the result.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
res: PendingJsonRpcResponse<InvokeSnapResult>,
_next: JsonRpcEngineNextCallback,
end: JsonRpcEngineEndCallback,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@metamask/providers": "^21.0.0",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/superstruct": "^3.2.1",
"@metamask/utils": "^11.2.0"
"@metamask/utils": "^11.4.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-simulation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@metamask/snaps-sdk": "workspace:^",
"@metamask/snaps-utils": "workspace:^",
"@metamask/superstruct": "^3.2.1",
"@metamask/utils": "^11.2.0",
"@metamask/utils": "^11.4.0",
"@reduxjs/toolkit": "^1.9.5",
"fast-deep-equal": "^3.1.3",
"mime": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import type {
JsonRpcEngineNextCallback,
} from '@metamask/json-rpc-engine';
import { BIP44Node } from '@metamask/key-tree';
import type {
Json,
JsonRpcRequest,
PendingJsonRpcResponse,
} from '@metamask/utils';
import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';

export type GetAccountsHandlerHooks = {
getMnemonic: () => Promise<Uint8Array>;
Expand All @@ -28,7 +24,7 @@ export type GetAccountsHandlerHooks = {
*/
export async function getAccountsHandler(
_request: JsonRpcRequest,
response: PendingJsonRpcResponse<Json>,
response: PendingJsonRpcResponse,
_next: JsonRpcEngineNextCallback,
end: JsonRpcEngineEndCallback,
hooks: GetAccountsHandlerHooks,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Json, PendingJsonRpcResponse } from '@metamask/utils';
import type { PendingJsonRpcResponse } from '@metamask/utils';

import { getChainIdHandler } from './chain-id';

describe('getChainIdHandler', () => {
it('returns the chain id', async () => {
const end = jest.fn();
const result: PendingJsonRpcResponse<Json> = {
const result: PendingJsonRpcResponse = {
jsonrpc: '2.0' as const,
id: 1,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import type {
JsonRpcEngineEndCallback,
JsonRpcEngineNextCallback,
} from '@metamask/json-rpc-engine';
import type {
Json,
JsonRpcRequest,
PendingJsonRpcResponse,
} from '@metamask/utils';
import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';

/**
* A mock handler for eth_chainId that always returns a specific
Expand All @@ -22,7 +18,7 @@ import type {
*/
export async function getChainIdHandler(
_request: JsonRpcRequest,
response: PendingJsonRpcResponse<Json>,
response: PendingJsonRpcResponse,
_next: JsonRpcEngineNextCallback,
end: JsonRpcEngineEndCallback,
) {
Expand Down
Loading
Loading