Skip to content

Commit 57deb7b

Browse files
committed
adds typing to evm switch chain
1 parent d97eb19 commit 57deb7b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Extension } from '@magic-sdk/provider';
2-
import { EVMNetworkConfig, EVMPayloadMethod } from './types';
2+
import { EVMNetworkConfig, EVMPayloadMethod, SwitchEVMChainResult } from './types';
33

44
export class EVMExtension extends Extension.Internal<'evm', any> {
55
name = 'evm' as const;
@@ -14,13 +14,8 @@ export class EVMExtension extends Extension.Internal<'evm', any> {
1414
}
1515

1616
public switchEVMChain = (chainId: number) => {
17-
return this.request({
18-
id: 42,
19-
jsonrpc: '2.0',
20-
method: EVMPayloadMethod.SwitchEVMChain,
21-
params: {
22-
chainId,
23-
},
24-
});
17+
return this.request<string | SwitchEVMChainResult>(
18+
this.utils.createJsonRpcRequestPayload(EVMPayloadMethod.SwitchEVMChain, [chainId]),
19+
);
2520
};
2621
}

packages/@magic-ext/evm/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ export enum EVMPayloadMethod {
77
export interface EVMNetworkConfig extends CustomNodeConfiguration {
88
default?: boolean;
99
}
10+
11+
export interface SwitchEVMChainResult {
12+
rpcUrl: string;
13+
chainId?: number;
14+
chainType?: string;
15+
}

0 commit comments

Comments
 (0)