File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
packages/@magic-ext/evm/src Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { Extension } from '@magic-sdk/provider' ;
2
- import { EVMNetworkConfig , EVMPayloadMethod } from './types' ;
2
+ import { EVMNetworkConfig , EVMPayloadMethod , SwitchEVMChainResult } from './types' ;
3
3
4
4
export class EVMExtension extends Extension . Internal < 'evm' , any > {
5
5
name = 'evm' as const ;
@@ -14,13 +14,8 @@ export class EVMExtension extends Extension.Internal<'evm', any> {
14
14
}
15
15
16
16
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
+ ) ;
25
20
} ;
26
21
}
Original file line number Diff line number Diff line change @@ -7,3 +7,9 @@ export enum EVMPayloadMethod {
7
7
export interface EVMNetworkConfig extends CustomNodeConfiguration {
8
8
default ?: boolean ;
9
9
}
10
+
11
+ export interface SwitchEVMChainResult {
12
+ rpcUrl : string ;
13
+ chainId ?: number ;
14
+ chainType ?: string ;
15
+ }
You can’t perform that action at this time.
0 commit comments