From f0ae32db5c0448f9643ec5586caf22bd21679cb2 Mon Sep 17 00:00:00 2001 From: weatherstar Date: Thu, 19 Oct 2023 16:20:43 +0800 Subject: [PATCH 1/4] fix: sign message error on sol --- packages/kit-bg/src/providers/ProviderApiSolana.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/kit-bg/src/providers/ProviderApiSolana.ts b/packages/kit-bg/src/providers/ProviderApiSolana.ts index 6557252b3fd..041e0a6a182 100644 --- a/packages/kit-bg/src/providers/ProviderApiSolana.ts +++ b/packages/kit-bg/src/providers/ProviderApiSolana.ts @@ -5,7 +5,10 @@ import bs58 from 'bs58'; import isArray from 'lodash/isArray'; import isString from 'lodash/isString'; -import { ETHMessageTypes } from '@onekeyhq/engine/src/types/message'; +import { + CommonMessageTypes, + ETHMessageTypes, +} from '@onekeyhq/engine/src/types/message'; import { getActiveWalletAccount } from '@onekeyhq/kit/src/hooks'; import { backgroundClass, @@ -203,7 +206,7 @@ class ProviderApiSolana extends ProviderApiBase { await this.backgroundApi.serviceDapp?.openSignAndSendModal(request, { unsignedMessage: { // Use ETH_SIGN to sign plain message - type: ETHMessageTypes.ETH_SIGN, + type: CommonMessageTypes.SIGN_MESSAGE, // TODO: different display needed? message: bs58.decode(message).toString(), }, From d45baa7316de1637a53bb401910f5e197275f3f1 Mon Sep 17 00:00:00 2001 From: weatherstar Date: Thu, 19 Oct 2023 16:24:22 +0800 Subject: [PATCH 2/4] fix: needless dapp connect modal --- packages/kit-bg/src/services/ServiceDapp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit-bg/src/services/ServiceDapp.ts b/packages/kit-bg/src/services/ServiceDapp.ts index 6eea95ff39e..9bb32207f0b 100644 --- a/packages/kit-bg/src/services/ServiceDapp.ts +++ b/packages/kit-bg/src/services/ServiceDapp.ts @@ -497,7 +497,7 @@ class ServiceDapp extends ServiceBase { reject(error); } } else { - this._openModalByRouteParams({ + this._openModalByRouteParamsDebounced({ routeNames, routeParams, modalParams, From ab6876b0cbe32d099c33472ae0a7c918a694e6a6 Mon Sep 17 00:00:00 2001 From: weatherstar Date: Thu, 19 Oct 2023 20:45:45 +0800 Subject: [PATCH 3/4] fix: sol insufficient funds for rent alert message --- packages/engine/src/vaults/impl/sol/Vault.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/engine/src/vaults/impl/sol/Vault.ts b/packages/engine/src/vaults/impl/sol/Vault.ts index b8b35e57203..241da475503 100644 --- a/packages/engine/src/vaults/impl/sol/Vault.ts +++ b/packages/engine/src/vaults/impl/sol/Vault.ts @@ -774,7 +774,7 @@ export default class Vault extends VaultBase { // https://docs.solana.com/developing/intro/rent if ( rpcErrorData.code === -32002 && - rpcErrorData.message.endsWith('without insufficient funds for rent') + rpcErrorData.message.endsWith('insufficient funds for rent') ) { isNodeBehind = false; throw new MinimumTransferBalanceRequiredError( From 6764b95d33bf1dcd2c5491d0183862891887501c Mon Sep 17 00:00:00 2001 From: weatherstar Date: Fri, 20 Oct 2023 10:37:43 +0800 Subject: [PATCH 4/4] fix: typo --- .../kit-bg/src/providers/ProviderApiSolana.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/kit-bg/src/providers/ProviderApiSolana.ts b/packages/kit-bg/src/providers/ProviderApiSolana.ts index 041e0a6a182..029cb2d6696 100644 --- a/packages/kit-bg/src/providers/ProviderApiSolana.ts +++ b/packages/kit-bg/src/providers/ProviderApiSolana.ts @@ -5,10 +5,7 @@ import bs58 from 'bs58'; import isArray from 'lodash/isArray'; import isString from 'lodash/isString'; -import { - CommonMessageTypes, - ETHMessageTypes, -} from '@onekeyhq/engine/src/types/message'; +import { CommonMessageTypes } from '@onekeyhq/engine/src/types/message'; import { getActiveWalletAccount } from '@onekeyhq/kit/src/hooks'; import { backgroundClass, @@ -38,7 +35,7 @@ type SolanaSendOptions = { class ProviderApiSolana extends ProviderApiBase { public providerName = IInjectedProviderNames.solana; - private getConnectedAcccountPublicKey( + private getConnectedAccountPublicKey( request: IJsBridgeMessagePayload, ): Promise { const [account] = this.backgroundApi.serviceDapp.getActiveConnectedAccounts( @@ -58,7 +55,7 @@ class ProviderApiSolana extends ProviderApiBase { params: { accounts: [ { - publicKey: await this.getConnectedAcccountPublicKey({ origin }), + publicKey: await this.getConnectedAccountPublicKey({ origin }), }, ].filter((item) => !!item.publicKey), }, @@ -171,7 +168,7 @@ class ProviderApiSolana extends ProviderApiBase { throw web3Errors.rpc.invalidInput(); } - const publicKey = await this.getConnectedAcccountPublicKey(request); + const publicKey = await this.getConnectedAccountPublicKey(request); const txid = (await this.backgroundApi.serviceDapp?.openSignAndSendModal( request, { @@ -201,11 +198,10 @@ class ProviderApiSolana extends ProviderApiBase { } debugLogger.providerApi.info('solana signMessage', request, params); - const publicKey = await this.getConnectedAcccountPublicKey(request); + const publicKey = await this.getConnectedAccountPublicKey(request); const signature = await this.backgroundApi.serviceDapp?.openSignAndSendModal(request, { unsignedMessage: { - // Use ETH_SIGN to sign plain message type: CommonMessageTypes.SIGN_MESSAGE, // TODO: different display needed? message: bs58.decode(message).toString(), @@ -224,10 +220,10 @@ class ProviderApiSolana extends ProviderApiBase { // onlyIfTrusted: false show connection Modal const { onlyIfTrusted = false } = params || {}; - let publicKey = await this.getConnectedAcccountPublicKey(request); + let publicKey = await this.getConnectedAccountPublicKey(request); if (!publicKey && !onlyIfTrusted) { await this.backgroundApi.serviceDapp.openConnectionModal(request); - publicKey = await this.getConnectedAcccountPublicKey(request); + publicKey = await this.getConnectedAccountPublicKey(request); } if (!publicKey) {