Skip to content

Commit

Permalink
Merge pull request #127 from CityOfZion/CU-86ducxtcz
Browse files Browse the repository at this point in the history
CU-86ducxtcz - Error to make a transaction in NeoX using AbstractWall…
  • Loading branch information
lopescode authored Aug 14, 2024
2 parents 8280282 + 2cb2ecb commit cb50071
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/wallet-connect-sdk-wallet-core",
"comment": "fix error to make a transaction in NeoX using AbstractWalletConnectEIP155Adapter",
"type": "patch"
}
],
"packageName": "@cityofzion/wallet-connect-sdk-wallet-core"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export abstract class AbstractWalletConnectEIP155Adapter {
}
}

protected resolveParams(param: any) {
protected async resolveParams(param: any, args: TAdapterMethodParam) {
const { provider, wallet } = await this.getServices(args)
const gasPrice = await provider.getGasPrice()

if (typeof param !== 'object') {
throw new Error('Invalid Params')
}
Expand All @@ -35,7 +38,13 @@ export abstract class AbstractWalletConnectEIP155Adapter {
delete param.gas
}

return param
param.gasPrice = gasPrice

return {
param,
provider,
wallet,
}
}

protected convertHexToUtf8(value: string) {
Expand All @@ -61,8 +70,7 @@ export abstract class AbstractWalletConnectEIP155Adapter {
}

async eth_signTransaction(args: TAdapterMethodParam): Promise<string> {
const param = this.resolveParams(args.request.params.request.params[0])
const { wallet } = await this.getServices(args)
const { param, wallet } = await this.resolveParams(args.request.params.request.params[0], args)
const signature = await wallet.signTransaction(param)
return signature
}
Expand All @@ -89,19 +97,17 @@ export abstract class AbstractWalletConnectEIP155Adapter {
}

async eth_sendTransaction(args: TAdapterMethodParam): Promise<string> {
const param = this.resolveParams(args.request.params.request.params[0])
const { param, provider, wallet } = await this.resolveParams(args.request.params.request.params[0], args)

const { wallet, provider } = await this.getServices(args)
const connectedWallet = wallet.connect(provider)

const { hash } = await connectedWallet.sendTransaction(param)
return hash
}

async eth_call(args: TAdapterMethodParam): Promise<string> {
const param = this.resolveParams(args.request.params.request.params[0])
const { param, provider, wallet } = await this.resolveParams(args.request.params.request.params[0], args)

const { wallet, provider } = await this.getServices(args)
const connectedWallet = wallet.connect(provider)

return await connectedWallet.call(param)
Expand Down Expand Up @@ -139,8 +145,7 @@ export abstract class AbstractWalletConnectEIP155Adapter {
}

async calculateFee(args: TAdapterMethodParam): Promise<string> {
const param = this.resolveParams(args.request.params.request.params[0])
const { wallet, provider } = await this.getServices(args)
const { param, wallet, provider } = await this.resolveParams(args.request.params.request.params[0], args)
const connectedWallet = wallet.connect(provider)

const gasPrice = await provider.getGasPrice()
Expand Down

0 comments on commit cb50071

Please sign in to comment.