Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-86ducxtcz - Error to make a transaction in NeoX using AbstractWall… #127

Merged
merged 1 commit into from
Aug 14, 2024
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
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
Loading