Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show upgrade dialog on get-starknet calls #247

Merged
merged 67 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9fe75f1
feat: change account contract to cairo 1 (#152)
stanleyyconsensys Oct 4, 2023
1db6955
feat: sf-542 block cairo0 (#153)
stanleyyconsensys Oct 5, 2023
42a1f90
chore(deps): bump word-wrap from 1.2.3 to 1.2.5 (#131)
dependabot[bot] Oct 5, 2023
1a32b29
chore(deps): bump @adobe/css-tools from 4.2.0 to 4.3.1 (#132)
dependabot[bot] Oct 5, 2023
be880ca
chore(deps): bump semver from 7.3.8 to 7.5.2 (#130)
dependabot[bot] Oct 5, 2023
101804d
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Oct 13, 2023
62f589e
feat: merge main
stanleyyconsensys Nov 17, 2023
2ee8e1b
feat: simplify snap logic
stanleyyconsensys Nov 17, 2023
ba81932
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Nov 21, 2023
b87e23d
fix: replace hardcode class hash
stanleyyconsensys Nov 21, 2023
ef4eb37
fix: get version function
stanleyyconsensys Nov 21, 2023
bd45f53
fix: recover account for getting upgraded cairo 1 address
stanleyyconsensys Nov 21, 2023
c166dde
feat: sf 549 update all method to support upgraded address (#188)
stanleyyconsensys Jan 5, 2024
eb5f4d7
feat: sf-540 add account contract upgrade api (#189)
stanleyyconsensys Feb 21, 2024
34a11a4
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Feb 28, 2024
c9270ac
feat: sf-539 UI upgrade account (#191)
stanleyyconsensys Feb 28, 2024
b0c4817
fix: test (#203)
stanleyyconsensys Feb 28, 2024
e84dd4e
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Mar 22, 2024
c8276d0
chore: rebase
stanleyyconsensys Mar 22, 2024
065cc40
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Apr 10, 2024
213b2e2
chore: update conflict
stanleyyconsensys Apr 10, 2024
63e405a
fix: lint issue
stanleyyconsensys Apr 11, 2024
e2b1039
feat: add webpack.config.dev.js for local serving of remoteEntry.js
khanti42 May 23, 2024
3c8ccf3
chore: lint and optional env variable for SNAP_ID
khanti42 May 24, 2024
e664d9e
fix: update get-starknet/webpack-dev-server dep to address security v…
khanti42 May 24, 2024
46414e7
fix: remoteEntry.js serving done on static file from dist/webpack folder
khanti42 May 24, 2024
14129eb
chore: added .env.sample example file
khanti42 May 24, 2024
cae8a9d
feat: optional PUBLIC_PATH env variable to produce local remoteEntry.js
khanti42 May 24, 2024
03eee4c
chore: updated README.md
khanti42 May 24, 2024
a776b04
Merge branch 'main' into feat/sf-614-rebase
stanleyyconsensys Jun 3, 2024
1a42322
fix: methods signature
khanti42 Jun 3, 2024
6f97ce1
test: make existing tests pass successfully
khanti42 Jun 3, 2024
ec49b03
fix: rollback check CairoVersion not needed
khanti42 Jun 3, 2024
de5a79f
fix: lint
khanti42 Jun 3, 2024
9bdc735
fix: contractCallData format in massagedTransaction
khanti42 Jun 3, 2024
63ca289
fix: upgrade function detection in getMassagedTransactions filtering …
khanti42 Jun 4, 2024
002fcb5
Merge branch 'feat/local-remoteentry-for-dev' into feat/sf-614-rebase
khanti42 Jun 4, 2024
d6f0111
refactor: ugrade detection mechanism similar to transfer based on met…
khanti42 Jun 5, 2024
0f68c85
test: adapt constants.test.ts
khanti42 Jun 5, 2024
e607658
feat: show upgrade dialog on get-starknet calls
khanti42 Jun 5, 2024
29f7a29
feat: sf 614 rebase (#246)
stanleyyconsensys Jun 6, 2024
556e9d7
Merge branch 'releases/2.3.0' into feat/sf-618
stanleyyconsensys Jun 6, 2024
47de7df
chore: upgrade modal link
khanti42 Jun 6, 2024
61d6a0f
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Jun 12, 2024
2fedd78
chore: lint style
stanleyyconsensys Jun 12, 2024
b5cd8c6
fix: lint issue
stanleyyconsensys Jun 12, 2024
17f5975
fix: yarn lock
stanleyyconsensys Jun 12, 2024
fe5631d
Merge branch 'main' into releases/2.3.0
stanleyyconsensys Jun 12, 2024
3209fe3
chore: add update text
stanleyyconsensys Jun 13, 2024
d695ead
chore: update snap file
stanleyyconsensys Jun 13, 2024
47ffbb5
chore: update yarn.lock
stanleyyconsensys Jun 13, 2024
450376c
Merge branch 'releases/2.3.0' into feat/sf-618
khanti42 Jun 17, 2024
cbd9ead
style: prettier
khanti42 Jun 17, 2024
81f5dfa
fix: await missing in some upgradeRequired check
khanti42 Jun 17, 2024
1f602a7
Merge branch 'main' into feat/sf-618
khanti42 Jun 17, 2024
cfbbed1
test: updated unit testing associated to get-starknet
khanti42 Jun 17, 2024
f783bf5
fix: adapted text of the upgradeRequestModal
khanti42 Jun 17, 2024
a0a03fa
style: lint
khanti42 Jun 17, 2024
0af0afb
chore: update snap sdk
stanleyyconsensys Jun 18, 2024
20f4fac
chore: update snap sdk
stanleyyconsensys Jun 18, 2024
3718151
Merge branch 'releases/2.3.0' into feat/sf-618
khanti42 Jun 18, 2024
076cf4a
fix: manifest
khanti42 Jun 18, 2024
4de9b46
test: fix on executTxn.test.ts
khanti42 Jun 18, 2024
d3e17ff
Merge branch 'main' into feat/sf-618
khanti42 Jun 20, 2024
4ee1864
Merge branch 'main' into feat/sf-618
khanti42 Jun 20, 2024
1605a16
fix: executeTxn with deployed cairov2 should not trigger deployment
khanti42 Jun 20, 2024
ac2f797
fix: resolve local build get-starknet config issue
stanleyyconsensys Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/get-starknet/webpack.config.local.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { merge } = require('webpack-merge');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const common = require('./webpack.common.js');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');

module.exports = {
module.exports = (env) => merge(common, {
mode: 'development',
output: {
publicPath: process.env.GET_STARKNET_PUBLIC_PATH ?? 'http://localhost:8082/', // Adjust the development publicPath as needed
Expand All @@ -11,4 +15,4 @@ module.exports = {
compress: true,
port: 8082,
}
};
});
2 changes: 1 addition & 1 deletion packages/starknet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/ConsenSys/starknet-snap.git"
},
"source": {
"shasum": "kl5iM2GRyXtFYwezb2vvrh2iTNC4Gw4K1I3PVOttXJ4=",
"shasum": "w/9IComQVArE5jU1RHIW8Y5CnN//nBoHKBQDFRhM8yI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
9 changes: 7 additions & 2 deletions packages/starknet-snap/src/declareContract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toJson } from './utils/serializer';
import { ApiParams, DeclareContractRequestParams } from './types/snapApi';
import { getNetworkFromChainId, getDeclareSnapTxt } from './utils/snapUtils';
import { getKeysFromAddress, declareContract as declareContractUtil } from './utils/starknetUtils';
import { getNetworkFromChainId, getDeclareSnapTxt, showUpgradeRequestModal } from './utils/snapUtils';
import { getKeysFromAddress, declareContract as declareContractUtil, isUpgradeRequired } from './utils/starknetUtils';
import { DialogType } from '@metamask/rpc-methods';
import { heading, panel } from '@metamask/snaps-sdk';
import { logger } from './utils/logger';
Expand All @@ -17,6 +17,11 @@ export async function declareContract(params: ApiParams) {
const network = getNetworkFromChainId(state, requestParamsObj.chainId);
const { privateKey } = await getKeysFromAddress(keyDeriver, network, state, senderAddress);

if (await isUpgradeRequired(network, senderAddress)) {
await showUpgradeRequestModal(wallet);
throw new Error('Upgrade required');
}

const snapComponents = getDeclareSnapTxt(
senderAddress,
network,
Expand Down
14 changes: 10 additions & 4 deletions packages/starknet-snap/src/executeTxn.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Invocations, TransactionType } from 'starknet';
import { getNetworkFromChainId, getTxnSnapTxt, addDialogTxt } from './utils/snapUtils';
import { getNetworkFromChainId, getTxnSnapTxt, addDialogTxt, showUpgradeRequestModal } from './utils/snapUtils';
import {
getKeysFromAddress,
executeTxn as executeTxnUtil,
isAccountDeployed,
estimateFeeBulk,
getAccContractAddressAndCallData,
addFeesFromAllTransactions,
isUpgradeRequired,
} from './utils/starknetUtils';
import { ApiParams, ExecuteTxnRequestParams } from './types/snapApi';
import { createAccount } from './createAccount';
import { DialogType } from '@metamask/rpc-methods';
import { heading, panel, divider } from '@metamask/snaps-sdk';
import { logger } from './utils/logger';
import { PROXY_CONTRACT_HASH } from './utils/constants';
import { ACCOUNT_CLASS_HASH } from './utils/constants';

export async function executeTxn(params: ApiParams) {
try {
Expand All @@ -27,18 +28,23 @@ export async function executeTxn(params: ApiParams) {
addressIndex,
} = await getKeysFromAddress(keyDeriver, network, state, senderAddress);

if (await isUpgradeRequired(network, senderAddress)) {
await showUpgradeRequestModal(wallet);
throw new Error('Upgrade required');
}

const txnInvocationArray = Array.isArray(requestParamsObj.txnInvocation)
? requestParamsObj.txnInvocation
: [requestParamsObj.txnInvocation];
const bulkTransactions: Invocations = txnInvocationArray.map((ele) => ({
type: TransactionType.INVOKE,
payload: ele,
}));
const accountDeployed = await isAccountDeployed(network, publicKey);
const accountDeployed = await isAccountDeployed(network, senderAddress);
if (!accountDeployed) {
const { callData } = getAccContractAddressAndCallData(publicKey);
const deployAccountpayload = {
classHash: PROXY_CONTRACT_HASH,
classHash: ACCOUNT_CLASS_HASH,
contractAddress: senderAddress,
constructorCalldata: callData,
addressSalt: publicKey,
Expand Down
13 changes: 11 additions & 2 deletions packages/starknet-snap/src/signDeclareTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { toJson } from './utils/serializer';
import { Signature } from 'starknet';
import { ApiParams, SignDeclareTransactionRequestParams } from './types/snapApi';
import { getKeysFromAddress, signDeclareTransaction as signDeclareTransactionUtil } from './utils/starknetUtils';
import { getNetworkFromChainId, getSignTxnTxt } from './utils/snapUtils';
import {
getKeysFromAddress,
signDeclareTransaction as signDeclareTransactionUtil,
isUpgradeRequired,
} from './utils/starknetUtils';
import { getNetworkFromChainId, getSignTxnTxt, showUpgradeRequestModal } from './utils/snapUtils';
import { DialogType } from '@metamask/rpc-methods';
import { heading, panel } from '@metamask/snaps-sdk';
import { logger } from './utils/logger';
Expand All @@ -15,6 +19,11 @@ export async function signDeclareTransaction(params: ApiParams): Promise<Signatu
const network = getNetworkFromChainId(state, requestParamsObj.chainId);
const { privateKey } = await getKeysFromAddress(keyDeriver, network, state, signerAddress);

if (await isUpgradeRequired(network, signerAddress)) {
await showUpgradeRequestModal(wallet);
throw new Error('Upgrade required');
}

logger.log(`signDeclareTransaction params: ${toJson(requestParamsObj.transaction, 2)}}`);

const snapComponents = getSignTxnTxt(signerAddress, network, requestParamsObj.transaction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { ApiParams, SignDeployAccountTransactionRequestParams } from './types/sn
import {
getKeysFromAddress,
signDeployAccountTransaction as signDeployAccountTransactionUtil,
isUpgradeRequired,
} from './utils/starknetUtils';
import { getNetworkFromChainId, getSignTxnTxt } from './utils/snapUtils';
import { getNetworkFromChainId, getSignTxnTxt, showUpgradeRequestModal } from './utils/snapUtils';
import { DialogType } from '@metamask/rpc-methods';
import { heading, panel } from '@metamask/snaps-sdk';
import { logger } from '../src/utils/logger';
Expand All @@ -18,6 +19,11 @@ export async function signDeployAccountTransaction(params: ApiParams): Promise<S
const network = getNetworkFromChainId(state, requestParamsObj.chainId);
const { privateKey } = await getKeysFromAddress(keyDeriver, network, state, signerAddress);

if (await isUpgradeRequired(network, signerAddress)) {
await showUpgradeRequestModal(wallet);
throw new Error('Upgrade required');
}

logger.log(`signDeployAccountTransaction params: ${toJson(requestParamsObj.transaction, 2)}}`);

const snapComponents = getSignTxnTxt(signerAddress, network, requestParamsObj.transaction);
Expand Down
15 changes: 12 additions & 3 deletions packages/starknet-snap/src/signMessage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { toJson } from './utils/serializer';
import { signMessage as signMessageUtil, getKeysFromAddress, isUpgradeRequired } from './utils/starknetUtils';
import { getNetworkFromChainId, addDialogTxt } from './utils/snapUtils';
import {
signMessage as signMessageUtil,
getKeysFromAddress,
isUpgradeRequired,
validateAndParseAddress,
} from './utils/starknetUtils';
import { getNetworkFromChainId, addDialogTxt, showUpgradeRequestModal } from './utils/snapUtils';
import { ApiParams, SignMessageRequestParams } from './types/snapApi';
import { validateAndParseAddress } from '../src/utils/starknetUtils';
import { DialogType } from '@metamask/rpc-methods';
import { heading, panel } from '@metamask/snaps-sdk';
import { logger } from './utils/logger';
Expand All @@ -15,6 +19,11 @@ export async function signMessage(params: ApiParams) {
const typedDataMessage = requestParamsObj.typedDataMessage;
const network = getNetworkFromChainId(state, requestParamsObj.chainId);

if (await isUpgradeRequired(network, signerAddress)) {
await showUpgradeRequestModal(wallet);
throw new Error('Upgrade required');
}

logger.log(`signMessage:\nsignerAddress: ${signerAddress}\ntypedDataMessage: ${toJson(typedDataMessage)}`);

if (!signerAddress) {
Expand Down
9 changes: 7 additions & 2 deletions packages/starknet-snap/src/signTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { toJson } from './utils/serializer';
import { Signature } from 'starknet';
import { ApiParams, SignTransactionRequestParams } from './types/snapApi';
import { getKeysFromAddress, signTransactions } from './utils/starknetUtils';
import { getNetworkFromChainId, getSignTxnTxt } from './utils/snapUtils';
import { getKeysFromAddress, signTransactions, isUpgradeRequired } from './utils/starknetUtils';
import { getNetworkFromChainId, getSignTxnTxt, showUpgradeRequestModal } from './utils/snapUtils';
import { DialogType } from '@metamask/rpc-methods';
import { heading, panel } from '@metamask/snaps-sdk';
import { logger } from '../src/utils/logger';
Expand All @@ -15,6 +15,11 @@ export async function signTransaction(params: ApiParams): Promise<Signature | bo
const network = getNetworkFromChainId(state, requestParamsObj.chainId);
const { privateKey } = await getKeysFromAddress(keyDeriver, network, state, signerAddress);

if (await isUpgradeRequired(network, signerAddress)) {
await showUpgradeRequestModal(wallet);
throw new Error('Upgrade required');
}

logger.log(`signTransaction params: ${toJson(requestParamsObj.transactions, 2)}}`);

const snapComponents = getSignTxnTxt(signerAddress, network, requestParamsObj.transactions);
Expand Down
18 changes: 17 additions & 1 deletion packages/starknet-snap/src/utils/snapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
constants,
} from 'starknet';
import { validateAndParseAddress } from './starknetUtils';
import { Component, text, copyable } from '@metamask/snaps-sdk';
import { Component, text, copyable, panel, heading } from '@metamask/snaps-sdk';
import {
Network,
Erc20Token,
Expand Down Expand Up @@ -42,6 +42,7 @@ import {
ChainIdFilter,
} from './transaction/filter';
import { logger } from './logger';
import { DialogType } from '@metamask/rpc-methods';

function hasOnlyAsciiChars(str: string) {
return /^[ -~]+$/.test(str);
Expand Down Expand Up @@ -757,3 +758,18 @@ export function dappUrl(envt: string) {
return DAPP.prod;
}
}

export async function showUpgradeRequestModal(wallet) {
await wallet.request({
method: 'snap_dialog',
params: {
type: DialogType.Alert,
content: panel([
heading('Account Upgrade Mandatory!'),
text(
`Visit the [companion dapp for Starknet](${dappUrl(process.env.SNAP_ENV)}) and click “Upgrade”.\nThank you!`,
),
]),
},
});
}
19 changes: 19 additions & 0 deletions packages/starknet-snap/test/src/declareContract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import { WalletMock } from '../wallet.mock.test';
import * as utils from '../../src/utils/starknetUtils';
import * as snapsUtil from '../../src/utils/snapUtils';
import { declareContract } from '../../src/declareContract';
import { SnapState } from '../../src/types/snapState';
import { STARKNET_MAINNET_NETWORK, STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants';
Expand Down Expand Up @@ -55,7 +56,23 @@ describe('Test function: declareContract', function () {
sandbox.restore();
});

it('should 1) throw an error and 2) show upgrade modal if account deployed required', async function () {
const isUpgradeRequiredStub = sandbox.stub(utils, 'isUpgradeRequired').resolves(true);
const showUpgradeRequestModalStub = sandbox.stub(snapsUtil, 'showUpgradeRequestModal').resolves();
let result;
try {
result = await declareContract(apiParams);
} catch (err) {
result = err;
} finally {
expect(isUpgradeRequiredStub).to.have.been.calledOnceWith(STARKNET_SEPOLIA_TESTNET_NETWORK, account1.address);
expect(showUpgradeRequestModalStub).to.have.been.calledOnce;
expect(result).to.be.an('Error');
}
});

it('should declareContract correctly', async function () {
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
const declareContractStub = sandbox.stub(utils, 'declareContract').resolves({
transaction_hash: 'transaction_hash',
class_hash: 'class_hash',
Expand Down Expand Up @@ -83,6 +100,7 @@ describe('Test function: declareContract', function () {
});

it('should throw error if declareContract fail', async function () {
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
const declareContractStub = sandbox.stub(utils, 'declareContract').rejects('error');
const { privateKey } = await utils.getKeysFromAddress(
apiParams.keyDeriver,
Expand All @@ -109,6 +127,7 @@ describe('Test function: declareContract', function () {
});

it('should return false if user rejected to sign the transaction', async function () {
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
walletStub.rpcStubs.snap_dialog.resolves(false);
const declareContractStub = sandbox.stub(utils, 'declareContract').resolves({
transaction_hash: 'transaction_hash',
Expand Down
22 changes: 22 additions & 0 deletions packages/starknet-snap/test/src/executeTxn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
estimateFeeResp,
} from '../constants.test';
import * as createAccountUtils from '../../src/createAccount';
import * as snapsUtil from '../../src/utils/snapUtils';
import { getAddressKeyDeriver } from '../../src/utils/keyPair';
import { Mutex } from 'async-mutex';
import { ApiParams, ExecuteTxnRequestParams } from '../../src/types/snapApi';
Expand Down Expand Up @@ -79,7 +80,23 @@ describe('Test function: executeTxn', function () {
apiParams.requestParams = requestObject;
});

it('should 1) throw an error and 2) show upgrade modal if account deployed required', async function () {
const isUpgradeRequiredStub = sandbox.stub(utils, 'isUpgradeRequired').resolves(true);
const showUpgradeRequestModalStub = sandbox.stub(snapsUtil, 'showUpgradeRequestModal').resolves();
let result;
try {
result = await executeTxn(apiParams);
} catch (err) {
result = err;
} finally {
expect(isUpgradeRequiredStub).to.have.been.calledOnceWith(STARKNET_MAINNET_NETWORK, account1.address);
expect(showUpgradeRequestModalStub).to.have.been.calledOnce;
expect(result).to.be.an('Error');
}
});

it('should executeTxn correctly and deploy an account', async function () {
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
sandbox.stub(utils, 'isAccountDeployed').resolves(false);
const createAccountStub = sandbox.stub(createAccountUtils, 'createAccount').resolvesThis();
const stub = sandbox.stub(utils, 'executeTxn').resolves({
Expand Down Expand Up @@ -111,6 +128,7 @@ describe('Test function: executeTxn', function () {
});

it('should executeTxn multiple and deploy an account', async function () {
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
sandbox.stub(utils, 'isAccountDeployed').resolves(false);
const createAccountStub = sandbox.stub(createAccountUtils, 'createAccount').resolvesThis();
const stub = sandbox.stub(utils, 'executeTxn').resolves({
Expand Down Expand Up @@ -171,6 +189,7 @@ describe('Test function: executeTxn', function () {

it('should executeTxn and not deploy an account', async function () {
const createAccountStub = sandbox.stub(createAccountUtils, 'createAccount');
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
sandbox.stub(utils, 'isAccountDeployed').resolves(true);
const stub = sandbox.stub(utils, 'executeTxn').resolves({
transaction_hash: 'transaction_hash',
Expand Down Expand Up @@ -204,6 +223,7 @@ describe('Test function: executeTxn', function () {

it('should executeTxn multiple and not deploy an account', async function () {
const createAccountStub = sandbox.stub(createAccountUtils, 'createAccount');
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
sandbox.stub(utils, 'isAccountDeployed').resolves(true);
const stub = sandbox.stub(utils, 'executeTxn').resolves({
transaction_hash: 'transaction_hash',
Expand Down Expand Up @@ -262,6 +282,7 @@ describe('Test function: executeTxn', function () {
});

it('should throw error if executeTxn fail', async function () {
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
sandbox.stub(utils, 'isAccountDeployed').resolves(true);
const stub = sandbox.stub(utils, 'executeTxn').rejects('error');
const { privateKey } = await utils.getKeysFromAddress(
Expand Down Expand Up @@ -295,6 +316,7 @@ describe('Test function: executeTxn', function () {

it('should return false if user rejected to sign the transaction', async function () {
sandbox.stub(utils, 'isAccountDeployed').resolves(true);
sandbox.stub(utils, 'isUpgradeRequired').resolves(false);
walletStub.rpcStubs.snap_dialog.resolves(false);
const stub = sandbox.stub(utils, 'executeTxn').resolves({
transaction_hash: 'transaction_hash',
Expand Down
Loading
Loading