Skip to content

Commit

Permalink
fix[nova]: deployed safe check
Browse files Browse the repository at this point in the history
  • Loading branch information
thelazyindian committed Jun 14, 2024
1 parent 7ddcd4a commit f86d19d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions packages/agents/nova/src/core/resources/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
normalizeMetaTransaction,
relayTransaction,
signSafeTransaction,
isSCWDeployed,
} from '@qw/utils';
import {JsonRpcProvider, parseUnits} from 'ethers';
import { ConfigService } from 'src/config/config.service';
Expand Down Expand Up @@ -77,16 +78,14 @@ export class UserService {
// Initialize the user's smart contract wallet (SCW)
const userSafe = await initSCW({ rpc: rpcUrl, address: signerAddress });

// // Check if the SCW is already deployed
// const hasSCW = await isSCWDeployed({
// rpc: rpcUrl,
// address: walletAddress,
// safe: userSafe,
// });
// Check if the SCW is already deployed
const hasSCW = await isSCWDeployed({
safe: userSafe,
});

// If SCW is already deployed
const users = await this.userModel.find({ id: signerAddress });
if (users.length > 0 && users[0].deployed) {
if (users.length > 0 && hasSCW) {
// Update the user's providers if they already exist
await this.userModel.updateOne(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/sdk/safe/safeScw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const getSCW = async (args: CreateSafeSdkArgs): Promise<string> => {
};

export const isSCWDeployed = async (
args: CreateSafeSdkArgs
args: { safe: Safe }
): Promise<boolean> => {
return await args.safe.isSafeDeployed();
};

0 comments on commit f86d19d

Please sign in to comment.