Skip to content

Commit

Permalink
Merge branch 'Thunnini/prepare-starknet' into delivan/keplr-486
Browse files Browse the repository at this point in the history
  • Loading branch information
delivan authored Oct 8, 2024
2 parents e527c8f + bab6c77 commit c19376a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { InExtensionMessageRequester } from "@keplr-wallet/router-extension";
import { BACKGROUND_PORT } from "@keplr-wallet/router";
import { FeeControl } from "../input/fee-control";
import { ExtensionKVStore } from "@keplr-wallet/common";
import { ExtensionKVStore, sleep } from "@keplr-wallet/common";
import { CoinPretty, Dec } from "@keplr-wallet/unit";
import { num } from "starknet";
import { useNotification } from "../../../../hooks/notification";
Expand Down Expand Up @@ -346,23 +346,39 @@ export const AccountActivationModal: FunctionComponent<{
}),
""
);
starknetAccount.setIsDeployingAccount(false);
close();
starknetQueries.queryAccountNonce
.getNonce(account.starknetHexAddress)
.fetch();
if (feeConfig.fee != null) {
starknetQueries.queryStarknetERC20Balance
.getBalance(
chainId,
chainStore,
account.starknetHexAddress,
feeConfig.fee.currency.coinMinimalDenom
)
?.fetch();
}
const starknetQueries =
starknetQueriesStore.get(chainId);

close();
(async () => {
// tx commit 이후의 state sync 시점이 이싱해서 일단 성공할때까지 2초 쉬면서 refresh 해본다.
const maxRetry = 15;
let retry = 0;
while (retry < maxRetry) {
const res = await starknetQueries.queryAccountNonce
.getNonce(account.starknetHexAddress)
.waitFreshResponse();
if (res?.data) {
starknetAccount.setIsDeployingAccount(false);

Check failure on line 362 in apps/extension/src/pages/starknet/components/account-activation-modal/index.tsx

View workflow job for this annotation

GitHub Actions / Lint code base

Delete `·····························`

Check failure on line 362 in apps/extension/src/pages/starknet/components/account-activation-modal/index.tsx

View workflow job for this annotation

GitHub Actions / Lint code base

Delete `·····························`
if (feeConfig.fee != null) {
starknetQueries.queryStarknetERC20Balance
.getBalance(
chainId,
chainStore,
account.starknetHexAddress,
feeConfig.fee.currency.coinMinimalDenom
)
?.fetch();
}
close();
break;
}

retry++;

await sleep(2000);
}
})();
})
.catch((e) => {
starknetAccount.setIsDeployingAccount(false);
Expand Down
26 changes: 18 additions & 8 deletions packages/provider/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,18 @@ export class Keplr implements IKeplr, KeplrCoreTypes {

public readonly starknet = new StarknetProvider(this, this.requester);
}

// IMPORTANT: 사이드 패널을 열어야하는 JSON-RPC 메소드들이 생길 때마다 여기에 추가해야한다.
const sidePanelOpenNeededJSONRPCMethods = [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData_v3",
"eth_signTypedData_v4",
"wallet_addEthereumChain",
"wallet_switchEthereumChain",
"wallet_watchAsset",
];

class EthereumProvider extends EventEmitter implements IEthereumProvider {
chainId: string | null = null;
selectedAddress: string | null = null;
Expand Down Expand Up @@ -1554,14 +1566,12 @@ class EthereumProvider extends EventEmitter implements IEthereumProvider {
}

// IMPORTANT: 사이드 패널을 열어야하는 JSON-RPC 메소드들이 생길 때마다 여기에 추가해야한다.
const sidePanelOpenNeededJSONRPCMethods = [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData_v3",
"eth_signTypedData_v4",
"wallet_addEthereumChain",
"wallet_switchEthereumChain",
const sidePanelOpenNeededStarknetJSONRPCMethods = [
"wallet_watchAsset",
"wallet_switchStarknetChain",
"wallet_addInvokeTransaction",
"wallet_addDeclareTransaction",
"wallet_signTypedData",
];

class StarknetProvider implements IStarknetProvider {
Expand Down Expand Up @@ -1644,7 +1654,7 @@ class StarknetProvider implements IStarknetProvider {
.finally(() => (f = true));

setTimeout(() => {
if (!f && sidePanelOpenNeededJSONRPCMethods.includes(type)) {
if (!f && sidePanelOpenNeededStarknetJSONRPCMethods.includes(type)) {
this.keplr.protectedTryOpenSidePanelIfEnabled();
}
}, 100);
Expand Down

0 comments on commit c19376a

Please sign in to comment.