Skip to content

Commit 97812b9

Browse files
committed
feat: added app_id feature
1 parent e46b571 commit 97812b9

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/components/Swap/Swap.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,24 @@ export const TonJiggle: Story = {
153153
},
154154
},
155155
};
156+
157+
export const WithAppId: Story = {
158+
args: {
159+
theme: {
160+
border: "#004A6533",
161+
primary: "#177594",
162+
background: "#181F34",
163+
input_card: "#27272A",
164+
input_token: "#1D2939",
165+
light_shade: "#193349",
166+
slippage_box: "#D1D1E0",
167+
text_black: "#FFFFFF",
168+
text_white: "#FFFFFF",
169+
text_fade: "#6B7280",
170+
skeleton_shine: "#585959",
171+
},
172+
options: {
173+
app_id: "tonjiggle",
174+
},
175+
},
176+
};

lib/store/options.store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type SwapOptions = {
55
default_pay_token?: string;
66
default_receive_token?: string;
77
pin_tokens?: string[];
8+
app_id?: string;
89
};
910

1011
type SwapOptionsStates = {
@@ -13,7 +14,7 @@ type SwapOptionsStates = {
1314
};
1415

1516
type SwapOptionsActions = {
16-
setOptions: (colors: SwapOptions) => void;
17+
setOptions: (options: SwapOptions) => void;
1718
};
1819

1920
export const useOptionsStore = create<SwapOptionsActions & SwapOptionsStates>(

lib/utils/swap.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import {
88
} from "@tonconnect/ui-react";
99
import { useSwapStore } from "../store/swap.store";
1010
import catchError from "./catchErrors";
11+
import { useOptionsStore } from "../store/options.store";
1112

1213
export default async function swap(
1314
tonconnect: TonConnectUI,
1415
bestRoute: BestRoute
1516
) {
1617
const client = new MyTonSwapClient();
18+
const app_id = useOptionsStore.getState().options.app_id;
1719
const rawMessageResult = await catchError(() =>
18-
client.swap.createSwap(tonconnect.account!.address, bestRoute)
20+
client.swap.createSwap(tonconnect.account!.address, bestRoute, app_id)
1921
);
2022
if (rawMessageResult.error) return console.log("make this alert!");
2123
const rawMessage = rawMessageResult.data;

0 commit comments

Comments
 (0)