Skip to content

Commit

Permalink
fix: invalid global controller type definition (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI authored Dec 16, 2024
1 parent ffe48e9 commit 4738bd9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/keychain/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Controller } from "utils/controller";
import Controller from "utils/controller";

declare global {
interface Window {
controller: Controller?;
controller?: Controller;
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/keychain/src/utils/connection/estimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {

export function estimateInvokeFee() {
return async (
transactions: Call | Call[],
transactions: Call[],
details?: EstimateFeeDetails,
): Promise<EstimateFee> => {
): Promise<EstimateFee | undefined> => {
return await window.controller?.estimateInvokeFee(transactions, details);
};
}
Expand All @@ -18,7 +18,7 @@ export function estimateDeclareFee() {
return async (
payload: DeclareContractPayload,
details?: EstimateFeeDetails,
): Promise<EstimateFee> => {
): Promise<EstimateFee | undefined> => {
return await window.controller?.estimateDeclareFee(payload, details);
};
}
15 changes: 12 additions & 3 deletions packages/keychain/src/utils/connection/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export function execute({

return await new Promise<InvokeFunctionResponse | ConnectError>(
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)) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4738bd9

Please sign in to comment.