diff --git a/packages/keychain/global.d.ts b/packages/keychain/global.d.ts index 328973f84..d2248f526 100644 --- a/packages/keychain/global.d.ts +++ b/packages/keychain/global.d.ts @@ -1,8 +1,8 @@ -import { Controller } from "utils/controller"; +import Controller from "utils/controller"; declare global { interface Window { - controller: Controller?; + controller?: Controller; } } diff --git a/packages/keychain/src/utils/connection/estimate.ts b/packages/keychain/src/utils/connection/estimate.ts index 7b3b216e0..bea7aefe1 100644 --- a/packages/keychain/src/utils/connection/estimate.ts +++ b/packages/keychain/src/utils/connection/estimate.ts @@ -7,9 +7,9 @@ import { export function estimateInvokeFee() { return async ( - transactions: Call | Call[], + transactions: Call[], details?: EstimateFeeDetails, - ): Promise => { + ): Promise => { return await window.controller?.estimateInvokeFee(transactions, details); }; } @@ -18,7 +18,7 @@ export function estimateDeclareFee() { return async ( payload: DeclareContractPayload, details?: EstimateFeeDetails, - ): Promise => { + ): Promise => { return await window.controller?.estimateDeclareFee(payload, details); }; } diff --git a/packages/keychain/src/utils/connection/execute.ts b/packages/keychain/src/utils/connection/execute.ts index 687f9c5aa..f524d7700 100644 --- a/packages/keychain/src/utils/connection/execute.ts +++ b/packages/keychain/src/utils/connection/execute.ts @@ -66,6 +66,12 @@ export function execute({ return await new Promise( async (resolve, reject) => { + if (!account) { + return reject({ + message: "Controller context not available", + }); + } + // If a session call and there is no session available // fallback to manual apporval flow if (!account.hasSession(calls)) { @@ -123,9 +129,12 @@ export function execute({ num.addPercent(estimate.overall_fee, ESTIMATE_FEE_PERCENTAGE), ); - let { transaction_hash } = await account.execute(transactions, { - maxFee, - }); + let { transaction_hash } = await account.execute( + transactions as Call[], + { + maxFee, + }, + ); return resolve({ code: ResponseCodes.SUCCESS, transaction_hash,