Skip to content

Commit

Permalink
fix: issues OK-23730 OK-23672 (#3679)
Browse files Browse the repository at this point in the history
* fix: sign message error on sol

* fix: needless dapp connect modal

* fix: sol insufficient funds for rent alert message

* fix: typo
  • Loading branch information
weatherstar authored Oct 20, 2023
1 parent 683e306 commit 7dd32e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/engine/src/vaults/impl/sol/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
17 changes: 8 additions & 9 deletions packages/kit-bg/src/providers/ProviderApiSolana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import bs58 from 'bs58';
import isArray from 'lodash/isArray';
import isString from 'lodash/isString';

import { ETHMessageTypes } from '@onekeyhq/engine/src/types/message';
import { CommonMessageTypes } from '@onekeyhq/engine/src/types/message';
import { getActiveWalletAccount } from '@onekeyhq/kit/src/hooks';
import {
backgroundClass,
Expand Down Expand Up @@ -35,7 +35,7 @@ type SolanaSendOptions = {
class ProviderApiSolana extends ProviderApiBase {
public providerName = IInjectedProviderNames.solana;

private getConnectedAcccountPublicKey(
private getConnectedAccountPublicKey(
request: IJsBridgeMessagePayload,
): Promise<string> {
const [account] = this.backgroundApi.serviceDapp.getActiveConnectedAccounts(
Expand All @@ -55,7 +55,7 @@ class ProviderApiSolana extends ProviderApiBase {
params: {
accounts: [
{
publicKey: await this.getConnectedAcccountPublicKey({ origin }),
publicKey: await this.getConnectedAccountPublicKey({ origin }),
},
].filter((item) => !!item.publicKey),
},
Expand Down Expand Up @@ -168,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,
{
Expand Down Expand Up @@ -198,12 +198,11 @@ 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: ETHMessageTypes.ETH_SIGN,
type: CommonMessageTypes.SIGN_MESSAGE,
// TODO: different display needed?
message: bs58.decode(message).toString(),
},
Expand All @@ -221,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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit-bg/src/services/ServiceDapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class ServiceDapp extends ServiceBase {
reject(error);
}
} else {
this._openModalByRouteParams({
this._openModalByRouteParamsDebounced({
routeNames,
routeParams,
modalParams,
Expand Down

0 comments on commit 7dd32e8

Please sign in to comment.