@frak-labs/core-sdk 0.1.0-beta.8d103039 → 0.1.0-beta.d9302e66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +20 -16
- package/src/actions/displayEmbeddedWallet.test.ts +194 -0
- package/src/actions/displayModal.test.ts +387 -0
- package/src/actions/getProductInformation.test.ts +133 -0
- package/src/actions/index.ts +19 -19
- package/src/actions/openSso.test.ts +407 -0
- package/src/actions/prepareSso.test.ts +223 -0
- package/src/actions/referral/processReferral.ts +1 -1
- package/src/actions/referral/referralInteraction.ts +1 -1
- package/src/actions/sendInteraction.test.ts +219 -0
- package/src/actions/trackPurchaseStatus.test.ts +287 -0
- package/src/actions/watchWalletStatus.test.ts +372 -0
- package/src/bundle.ts +1 -1
- package/src/clients/createIFrameFrakClient.ts +2 -2
- package/src/clients/index.ts +1 -1
- package/src/clients/setupClient.ts +3 -1
- package/src/clients/transports/iframeLifecycleManager.ts +3 -1
- package/src/index.ts +72 -74
- package/src/interactions/index.ts +2 -2
- package/src/interactions/pressEncoder.test.ts +215 -0
- package/src/interactions/pressEncoder.ts +1 -1
- package/src/interactions/purchaseEncoder.test.ts +291 -0
- package/src/interactions/purchaseEncoder.ts +8 -3
- package/src/interactions/referralEncoder.test.ts +170 -0
- package/src/interactions/retailEncoder.test.ts +107 -0
- package/src/interactions/retailEncoder.ts +1 -1
- package/src/interactions/webshopEncoder.test.ts +56 -0
- package/src/types/index.ts +51 -50
- package/src/types/lifecycle/index.ts +1 -1
- package/src/types/rpc/embedded/loggedIn.ts +1 -1
- package/src/types/rpc/embedded/loggedOut.ts +1 -1
- package/src/types/rpc/modal/index.ts +11 -11
- package/src/utils/FrakContext.test.ts +338 -0
- package/src/utils/FrakContext.ts +8 -2
- package/src/utils/compression/b64.test.ts +181 -0
- package/src/utils/compression/compress.test.ts +123 -0
- package/src/utils/compression/decompress.test.ts +145 -0
- package/src/utils/compression/index.ts +1 -1
- package/src/utils/computeProductId.test.ts +80 -0
- package/src/utils/constants.test.ts +23 -0
- package/src/utils/formatAmount.test.ts +113 -0
- package/src/utils/getCurrencyAmountKey.test.ts +44 -0
- package/src/utils/getSupportedCurrency.test.ts +51 -0
- package/src/utils/getSupportedLocale.test.ts +64 -0
- package/src/utils/iframeHelper.test.ts +450 -0
- package/src/utils/iframeHelper.ts +4 -3
- package/src/utils/index.ts +12 -12
- package/src/utils/sso.test.ts +361 -0
- package/src/utils/trackEvent.test.ts +162 -0
- package/cdn/bundle.js +0 -19
- package/cdn/bundle.js.LICENSE.txt +0 -10
- package/dist/actions.cjs +0 -1
- package/dist/actions.d.cts +0 -1481
- package/dist/actions.d.ts +0 -1481
- package/dist/actions.js +0 -1
- package/dist/bundle.cjs +0 -13
- package/dist/bundle.d.cts +0 -2087
- package/dist/bundle.d.ts +0 -2087
- package/dist/bundle.js +0 -13
- package/dist/index.cjs +0 -13
- package/dist/index.d.cts +0 -1387
- package/dist/index.d.ts +0 -1387
- package/dist/index.js +0 -13
- package/dist/interactions.cjs +0 -1
- package/dist/interactions.d.cts +0 -182
- package/dist/interactions.d.ts +0 -182
- package/dist/interactions.js +0 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for prepareSso action
|
|
3
|
+
* Tests SSO URL generation via RPC
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it, vi } from "../../tests/vitest-fixtures";
|
|
7
|
+
import type {
|
|
8
|
+
FrakClient,
|
|
9
|
+
PrepareSsoParamsType,
|
|
10
|
+
PrepareSsoReturnType,
|
|
11
|
+
} from "../types";
|
|
12
|
+
import { prepareSso } from "./prepareSso";
|
|
13
|
+
|
|
14
|
+
describe("prepareSso", () => {
|
|
15
|
+
describe("success cases", () => {
|
|
16
|
+
it("should call client.request with correct method and params", async () => {
|
|
17
|
+
const mockResponse: PrepareSsoReturnType = {
|
|
18
|
+
ssoUrl: "https://wallet.frak.id/sso?params=xyz",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const mockClient = {
|
|
22
|
+
config: {
|
|
23
|
+
metadata: {
|
|
24
|
+
name: "Test App",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
28
|
+
} as unknown as FrakClient;
|
|
29
|
+
|
|
30
|
+
const params: PrepareSsoParamsType = {
|
|
31
|
+
directExit: true,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
await prepareSso(mockClient, params);
|
|
35
|
+
|
|
36
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
37
|
+
method: "frak_prepareSso",
|
|
38
|
+
params: [params, "Test App", undefined],
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should return SSO URL", async () => {
|
|
43
|
+
const mockResponse: PrepareSsoReturnType = {
|
|
44
|
+
ssoUrl: "https://wallet.frak.id/sso?params=abc123",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const mockClient = {
|
|
48
|
+
config: {
|
|
49
|
+
metadata: {
|
|
50
|
+
name: "Test App",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
54
|
+
} as unknown as FrakClient;
|
|
55
|
+
|
|
56
|
+
const params: PrepareSsoParamsType = {
|
|
57
|
+
directExit: false,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const result = await prepareSso(mockClient, params);
|
|
61
|
+
|
|
62
|
+
expect(result).toEqual(mockResponse);
|
|
63
|
+
expect(result.ssoUrl).toBe(
|
|
64
|
+
"https://wallet.frak.id/sso?params=abc123"
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should include custom CSS when provided", async () => {
|
|
69
|
+
const mockResponse: PrepareSsoReturnType = {
|
|
70
|
+
ssoUrl: "https://wallet.frak.id/sso?params=custom",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const mockClient = {
|
|
74
|
+
config: {
|
|
75
|
+
metadata: {
|
|
76
|
+
name: "Styled App",
|
|
77
|
+
},
|
|
78
|
+
customizations: {
|
|
79
|
+
css: "body { background: red; }",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
83
|
+
} as unknown as FrakClient;
|
|
84
|
+
|
|
85
|
+
const params: PrepareSsoParamsType = {
|
|
86
|
+
directExit: true,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
await prepareSso(mockClient, params);
|
|
90
|
+
|
|
91
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
92
|
+
method: "frak_prepareSso",
|
|
93
|
+
params: [params, "Styled App", "body { background: red; }"],
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should handle params with redirectUrl", async () => {
|
|
98
|
+
const mockResponse: PrepareSsoReturnType = {
|
|
99
|
+
ssoUrl: "https://wallet.frak.id/sso?redirect=https://example.com",
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const mockClient = {
|
|
103
|
+
config: {
|
|
104
|
+
metadata: {
|
|
105
|
+
name: "Test App",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
109
|
+
} as unknown as FrakClient;
|
|
110
|
+
|
|
111
|
+
const params: PrepareSsoParamsType = {
|
|
112
|
+
redirectUrl: "https://example.com/callback",
|
|
113
|
+
directExit: false,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
await prepareSso(mockClient, params);
|
|
117
|
+
|
|
118
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
119
|
+
method: "frak_prepareSso",
|
|
120
|
+
params: [params, "Test App", undefined],
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should handle params with metadata", async () => {
|
|
125
|
+
const mockResponse: PrepareSsoReturnType = {
|
|
126
|
+
ssoUrl: "https://wallet.frak.id/sso?metadata=xyz",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const mockClient = {
|
|
130
|
+
config: {
|
|
131
|
+
metadata: {
|
|
132
|
+
name: "App with Metadata",
|
|
133
|
+
logoUrl: "https://example.com/logo.png",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
137
|
+
} as unknown as FrakClient;
|
|
138
|
+
|
|
139
|
+
const params: PrepareSsoParamsType = {
|
|
140
|
+
metadata: {
|
|
141
|
+
logoUrl: "https://custom.com/logo.png",
|
|
142
|
+
homepageLink: "https://custom.com",
|
|
143
|
+
},
|
|
144
|
+
directExit: true,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
await prepareSso(mockClient, params);
|
|
148
|
+
|
|
149
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
150
|
+
method: "frak_prepareSso",
|
|
151
|
+
params: [params, "App with Metadata", undefined],
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("should pass client metadata name to request", async () => {
|
|
156
|
+
const mockResponse: PrepareSsoReturnType = {
|
|
157
|
+
ssoUrl: "https://wallet.frak.id/sso?name=MyApp",
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const mockClient = {
|
|
161
|
+
config: {
|
|
162
|
+
metadata: {
|
|
163
|
+
name: "MyApp",
|
|
164
|
+
logoUrl: "https://example.com/logo.png",
|
|
165
|
+
},
|
|
166
|
+
customizations: {
|
|
167
|
+
css: "body { color: blue; }",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
171
|
+
} as unknown as FrakClient;
|
|
172
|
+
|
|
173
|
+
const params: PrepareSsoParamsType = {};
|
|
174
|
+
|
|
175
|
+
await prepareSso(mockClient, params);
|
|
176
|
+
|
|
177
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
178
|
+
method: "frak_prepareSso",
|
|
179
|
+
params: [params, "MyApp", "body { color: blue; }"],
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe("error handling", () => {
|
|
185
|
+
it("should propagate errors from client.request", async () => {
|
|
186
|
+
const error = new Error("SSO preparation failed");
|
|
187
|
+
const mockClient = {
|
|
188
|
+
config: {
|
|
189
|
+
metadata: {
|
|
190
|
+
name: "Test App",
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
request: vi.fn().mockRejectedValue(error),
|
|
194
|
+
} as unknown as FrakClient;
|
|
195
|
+
|
|
196
|
+
const params: PrepareSsoParamsType = {
|
|
197
|
+
directExit: true,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
await expect(prepareSso(mockClient, params)).rejects.toThrow(
|
|
201
|
+
"SSO preparation failed"
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("should handle network errors", async () => {
|
|
206
|
+
const error = new Error("Network timeout");
|
|
207
|
+
const mockClient = {
|
|
208
|
+
config: {
|
|
209
|
+
metadata: {
|
|
210
|
+
name: "Test App",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
request: vi.fn().mockRejectedValue(error),
|
|
214
|
+
} as unknown as FrakClient;
|
|
215
|
+
|
|
216
|
+
const params: PrepareSsoParamsType = {};
|
|
217
|
+
|
|
218
|
+
await expect(prepareSso(mockClient, params)).rejects.toThrow(
|
|
219
|
+
"Network timeout"
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -61,7 +61,7 @@ export type ProcessReferralOptions = {
|
|
|
61
61
|
* @see {@link displayModal} for more details about the displayed modal
|
|
62
62
|
* @see {@link sendInteraction} for more details on the interaction submission part
|
|
63
63
|
* @see {@link ReferralInteractionEncoder} for more details about the referred interaction
|
|
64
|
-
* @see {@link ModalStepTypes} for more details on each modal steps types
|
|
64
|
+
* @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
|
|
65
65
|
*/
|
|
66
66
|
export async function processReferral(
|
|
67
67
|
client: FrakClient,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
* @description This function will automatically handle the referral interaction process
|
|
21
21
|
*
|
|
22
22
|
* @see {@link processReferral} for more details on the automatic referral handling process
|
|
23
|
-
* @see {@link ModalStepTypes} for more details on each modal steps types
|
|
23
|
+
* @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
|
|
24
24
|
*/
|
|
25
25
|
export async function referralInteraction(
|
|
26
26
|
client: FrakClient,
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for sendInteraction action
|
|
3
|
+
* Tests sending user interactions via RPC
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Hex } from "viem";
|
|
7
|
+
import { vi } from "vitest";
|
|
8
|
+
|
|
9
|
+
// Mock computeProductId - must be before imports
|
|
10
|
+
vi.mock("../utils/computeProductId", () => ({
|
|
11
|
+
computeProductId: vi.fn(
|
|
12
|
+
() =>
|
|
13
|
+
"0xcomputed1234567890123456789012345678901234567890123456789012" as Hex
|
|
14
|
+
),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
import { describe, expect, it } from "../../tests/vitest-fixtures";
|
|
18
|
+
import type {
|
|
19
|
+
FrakClient,
|
|
20
|
+
PreparedInteraction,
|
|
21
|
+
SendInteractionParamsType,
|
|
22
|
+
SendInteractionReturnType,
|
|
23
|
+
} from "../types";
|
|
24
|
+
import { sendInteraction } from "./sendInteraction";
|
|
25
|
+
|
|
26
|
+
describe("sendInteraction", () => {
|
|
27
|
+
const mockInteraction: PreparedInteraction = {
|
|
28
|
+
interactionData: "0xdata" as Hex,
|
|
29
|
+
handlerTypeDenominator: "0x01" as Hex,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
describe("with productId provided", () => {
|
|
33
|
+
it("should use provided productId", async () => {
|
|
34
|
+
const mockResponse: SendInteractionReturnType = {
|
|
35
|
+
delegationId: "delegation-123",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const mockClient = {
|
|
39
|
+
config: {
|
|
40
|
+
domain: "example.com",
|
|
41
|
+
},
|
|
42
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
43
|
+
} as unknown as FrakClient;
|
|
44
|
+
|
|
45
|
+
const params: SendInteractionParamsType = {
|
|
46
|
+
productId:
|
|
47
|
+
"0xprovidedid567890123456789012345678901234567890123456789012" as Hex,
|
|
48
|
+
interaction: mockInteraction,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
await sendInteraction(mockClient, params);
|
|
52
|
+
|
|
53
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
54
|
+
method: "frak_sendInteraction",
|
|
55
|
+
params: [
|
|
56
|
+
"0xprovidedid567890123456789012345678901234567890123456789012",
|
|
57
|
+
mockInteraction,
|
|
58
|
+
undefined,
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should return delegationId", async () => {
|
|
64
|
+
const mockResponse: SendInteractionReturnType = {
|
|
65
|
+
delegationId: "delegation-456",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const mockClient = {
|
|
69
|
+
config: {
|
|
70
|
+
domain: "example.com",
|
|
71
|
+
},
|
|
72
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
73
|
+
} as unknown as FrakClient;
|
|
74
|
+
|
|
75
|
+
const params: SendInteractionParamsType = {
|
|
76
|
+
productId:
|
|
77
|
+
"0xprovidedid567890123456789012345678901234567890123456789012" as Hex,
|
|
78
|
+
interaction: mockInteraction,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const result = await sendInteraction(mockClient, params);
|
|
82
|
+
|
|
83
|
+
expect(result).toEqual(mockResponse);
|
|
84
|
+
expect(result.delegationId).toBe("delegation-456");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("should include validation signature when provided", async () => {
|
|
88
|
+
const mockResponse: SendInteractionReturnType = {
|
|
89
|
+
delegationId: "delegation-789",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const mockClient = {
|
|
93
|
+
config: {
|
|
94
|
+
domain: "example.com",
|
|
95
|
+
},
|
|
96
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
97
|
+
} as unknown as FrakClient;
|
|
98
|
+
|
|
99
|
+
const params: SendInteractionParamsType = {
|
|
100
|
+
productId:
|
|
101
|
+
"0xprovidedid567890123456789012345678901234567890123456789012" as Hex,
|
|
102
|
+
interaction: mockInteraction,
|
|
103
|
+
validation: "0xsignature1234567890" as Hex,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
await sendInteraction(mockClient, params);
|
|
107
|
+
|
|
108
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
109
|
+
method: "frak_sendInteraction",
|
|
110
|
+
params: [
|
|
111
|
+
"0xprovidedid567890123456789012345678901234567890123456789012",
|
|
112
|
+
mockInteraction,
|
|
113
|
+
"0xsignature1234567890",
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("without productId provided", () => {
|
|
120
|
+
it("should compute productId from client.config", async () => {
|
|
121
|
+
const { computeProductId } = await import(
|
|
122
|
+
"../utils/computeProductId"
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const mockResponse: SendInteractionReturnType = {
|
|
126
|
+
delegationId: "delegation-computed",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const mockClient = {
|
|
130
|
+
config: {
|
|
131
|
+
domain: "example.com",
|
|
132
|
+
},
|
|
133
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
134
|
+
} as unknown as FrakClient;
|
|
135
|
+
|
|
136
|
+
const params: SendInteractionParamsType = {
|
|
137
|
+
interaction: mockInteraction,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
await sendInteraction(mockClient, params);
|
|
141
|
+
|
|
142
|
+
expect(computeProductId).toHaveBeenCalledWith(mockClient.config);
|
|
143
|
+
expect(mockClient.request).toHaveBeenCalledWith({
|
|
144
|
+
method: "frak_sendInteraction",
|
|
145
|
+
params: [
|
|
146
|
+
"0xcomputed1234567890123456789012345678901234567890123456789012",
|
|
147
|
+
mockInteraction,
|
|
148
|
+
undefined,
|
|
149
|
+
],
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("should work with different interaction types", async () => {
|
|
154
|
+
const mockResponse: SendInteractionReturnType = {
|
|
155
|
+
delegationId: "delegation-different",
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const mockClient = {
|
|
159
|
+
config: {
|
|
160
|
+
domain: "example.com",
|
|
161
|
+
},
|
|
162
|
+
request: vi.fn().mockResolvedValue(mockResponse),
|
|
163
|
+
} as unknown as FrakClient;
|
|
164
|
+
|
|
165
|
+
const differentInteraction: PreparedInteraction = {
|
|
166
|
+
interactionData: "0xdifferentdata" as Hex,
|
|
167
|
+
handlerTypeDenominator: "0x02" as Hex,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const params: SendInteractionParamsType = {
|
|
171
|
+
interaction: differentInteraction,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const result = await sendInteraction(mockClient, params);
|
|
175
|
+
|
|
176
|
+
expect(result).toEqual(mockResponse);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
describe("error handling", () => {
|
|
181
|
+
it("should propagate errors from client.request", async () => {
|
|
182
|
+
const error = new Error("Send interaction failed");
|
|
183
|
+
const mockClient = {
|
|
184
|
+
config: {
|
|
185
|
+
domain: "example.com",
|
|
186
|
+
},
|
|
187
|
+
request: vi.fn().mockRejectedValue(error),
|
|
188
|
+
} as unknown as FrakClient;
|
|
189
|
+
|
|
190
|
+
const params: SendInteractionParamsType = {
|
|
191
|
+
productId:
|
|
192
|
+
"0xprovidedid567890123456789012345678901234567890123456789012" as Hex,
|
|
193
|
+
interaction: mockInteraction,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
await expect(sendInteraction(mockClient, params)).rejects.toThrow(
|
|
197
|
+
"Send interaction failed"
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("should handle network errors", async () => {
|
|
202
|
+
const error = new Error("Network timeout");
|
|
203
|
+
const mockClient = {
|
|
204
|
+
config: {
|
|
205
|
+
domain: "example.com",
|
|
206
|
+
},
|
|
207
|
+
request: vi.fn().mockRejectedValue(error),
|
|
208
|
+
} as unknown as FrakClient;
|
|
209
|
+
|
|
210
|
+
const params: SendInteractionParamsType = {
|
|
211
|
+
interaction: mockInteraction,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
await expect(sendInteraction(mockClient, params)).rejects.toThrow(
|
|
215
|
+
"Network timeout"
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|