Skip to content

Commit bff23ef

Browse files
Replace connection parameter
1 parent 40af80c commit bff23ef

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

packages/keychain/src/components/DeployController.stories.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ import type { Meta, StoryObj } from "@storybook/react";
33
import { DeployController } from "./DeployController";
44
import { constants, num } from "starknet";
55
import { JsControllerError } from "@cartridge/account-wasm/controller";
6-
import Controller from "#utils/controller";
6+
import { useConnection, createMockConnection } from "#hooks/connection.mock";
77

88
const meta = {
99
component: DeployController,
10-
parameters: {
11-
connection: {
12-
controller: {
13-
chainId: () => constants.StarknetChainId.SN_SEPOLIA as string,
14-
callContract: () =>
15-
Promise.resolve([num.toHex("2000000000000000000"), "0x0"]),
16-
username: () => "test-account",
17-
address: () =>
18-
"0x0000000000000000000000000000000000000000000000000000000000000000",
19-
} as Partial<Controller>,
20-
},
10+
beforeEach: () => {
11+
useConnection.mockReturnValue(
12+
createMockConnection({
13+
controller: {
14+
chainId: () => constants.StarknetChainId.SN_SEPOLIA as string,
15+
callContract: () =>
16+
Promise.resolve([num.toHex("2000000000000000000"), "0x0"]),
17+
username: () => "test-account",
18+
address: () =>
19+
"0x0000000000000000000000000000000000000000000000000000000000000000",
20+
},
21+
}),
22+
);
2123
},
2224
} satisfies Meta<typeof DeployController>;
2325

packages/keychain/src/components/connect/SessionConsent.stories.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22

33
import { SessionConsent } from "./SessionConsent";
4+
import { useConnection, createMockConnection } from "#hooks/connection.mock";
45

56
const meta = {
67
// tags: ["autodocs"],
78
component: SessionConsent,
8-
parameters: {
9-
connection: {
10-
origin: "https://cartridge.gg",
11-
},
9+
beforeEach: () => {
10+
useConnection.mockReturnValue(
11+
createMockConnection({
12+
origin: "https://cartridge.gg",
13+
}),
14+
);
1215
},
1316
args: {
1417
isVerified: true,

packages/keychain/src/components/funding/index.stories.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import type { Meta, StoryObj } from "@storybook/react";
22

33
import { Funding } from ".";
44
import { num } from "starknet";
5+
import { useConnection, createMockConnection } from "#hooks/connection.mock";
56

67
const meta = {
78
component: Funding,
8-
parameters: {
9-
connection: {
10-
controller: {
11-
callContract: () =>
12-
Promise.resolve([num.toHex("2000000000000000000"), "0x0"]),
13-
},
14-
},
9+
beforeEach: () => {
10+
useConnection.mockReturnValue(
11+
createMockConnection({
12+
controller: {
13+
callContract: () =>
14+
Promise.resolve([num.toHex("2000000000000000000"), "0x0"]),
15+
},
16+
}),
17+
);
1518
},
1619
} satisfies Meta<typeof Funding>;
1720

packages/keychain/src/components/slot/fund.stories.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ import type { Meta, StoryObj } from "@storybook/react";
22

33
import { Fund } from "./fund";
44
import { num } from "starknet";
5+
import { useConnection, createMockConnection } from "#hooks/connection.mock";
56

67
const meta: Meta<typeof Fund> = {
78
component: Fund,
89
decorators: [(Story) => <Story />],
9-
parameters: {
10-
connection: {
11-
controller: {
12-
callContract: () =>
13-
Promise.resolve([num.toHex("2000000000000000000"), "0x0"]),
14-
},
15-
},
10+
beforeEach: () => {
11+
useConnection.mockReturnValue(
12+
createMockConnection({
13+
controller: {
14+
callContract: () =>
15+
Promise.resolve([num.toHex("2000000000000000000"), "0x0"]),
16+
},
17+
}),
18+
);
1619
},
1720
};
1821

0 commit comments

Comments
 (0)