Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async handleStateMethods (payload: any) {
let result: any = null
switch (payload.method) {
case 'eth_accounts':
result = this.accounts
break
case 'eth_chainId':
result = convertNumberToHex(this.chainId)
break
case 'net_version':
result = this.networkId
break
default:
break
}
return {
id: payload.id,
jsonrpc: payload.jsonrpc,
result
}
}
public async handleStateMethods (payload: any) {
let result: any = null
switch (payload.method) {
case 'eth_accounts':
result = this.accounts
break
case 'eth_chainId':
result = convertNumberToHex(this.chainId)
break
case 'net_version':
result = this.networkId
break
default:
break
}
return {
id: payload.id,
jsonrpc: payload.jsonrpc,
result
}
}
public async handleStateMethods (payload: any) {
let result: any = null
switch (payload.method) {
case 'eth_accounts':
result = this.accounts
break
case 'eth_chainId':
result = convertNumberToHex(this.chainId)
break
case 'net_version':
result = this.networkId
break
default:
break
}
return {
id: payload.id,
jsonrpc: payload.jsonrpc,
result
}
}
public async sendCustomRequest (request: Partial) {
if (!this._connected) {
throw new Error(ERROR_SESSION_DISCONNECTED)
}
switch (request.method) {
case 'eth_accounts':
return this.accounts
case 'eth_chainId':
return convertNumberToHex(this.chainId)
case 'eth_sendTransaction':
case 'eth_signTransaction':
if (request.params) {
request.params[0] = parseTransactionData(request.params[0])
}
break
case 'personal_sign':
if (request.params) {
request.params = parsePersonalSign(request.params)
}
break
default:
break
}
const formattedRequest = this._formatRequest(request)