@bitflowlabs/core-sdk 2.3.2 → 2.4.1

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.
Files changed (66) hide show
  1. package/README.md +43 -36
  2. package/dist/src/helpers/callReadOnlyHelper.js +68 -52
  3. package/dist/src/helpers/callReadOnlyHelper.js.map +1 -1
  4. package/dist/src/helpers/convertValuesHelper.js +24 -4
  5. package/dist/src/helpers/convertValuesHelper.js.map +1 -1
  6. package/dist/src/helpers/handleResultHelper.js +10 -10
  7. package/dist/src/helpers/handleResultHelper.js.map +1 -1
  8. package/dist/src/helpers/newPostConditionsHelper.js +6 -1
  9. package/dist/src/helpers/newPostConditionsHelper.js.map +1 -1
  10. package/dist/src/helpers/postConditionsHelper.js +6 -1
  11. package/dist/src/helpers/postConditionsHelper.js.map +1 -1
  12. package/dist/test/BitflowSDK.test.d.ts +1 -0
  13. package/dist/test/BitflowSDK.test.js +1143 -0
  14. package/dist/test/BitflowSDK.test.js.map +1 -0
  15. package/dist/test/config.test.d.ts +1 -0
  16. package/dist/test/config.test.js +89 -0
  17. package/dist/test/config.test.js.map +1 -0
  18. package/dist/test/helpers/callGetSwapParams.test.d.ts +1 -0
  19. package/dist/test/helpers/callGetSwapParams.test.js +85 -0
  20. package/dist/test/helpers/callGetSwapParams.test.js.map +1 -0
  21. package/dist/test/helpers/callReadOnlyHelper.test.d.ts +1 -0
  22. package/dist/test/helpers/callReadOnlyHelper.test.js +345 -0
  23. package/dist/test/helpers/callReadOnlyHelper.test.js.map +1 -0
  24. package/dist/test/helpers/callSwapHelper.test.d.ts +1 -0
  25. package/dist/test/helpers/callSwapHelper.test.js +209 -0
  26. package/dist/test/helpers/callSwapHelper.test.js.map +1 -0
  27. package/dist/test/helpers/constructFunctionArgs.test.d.ts +1 -0
  28. package/dist/test/helpers/constructFunctionArgs.test.js +63 -0
  29. package/dist/test/helpers/constructFunctionArgs.test.js.map +1 -0
  30. package/dist/test/helpers/convertValuesHelper.test.d.ts +1 -0
  31. package/dist/test/helpers/convertValuesHelper.test.js +207 -0
  32. package/dist/test/helpers/convertValuesHelper.test.js.map +1 -0
  33. package/dist/test/helpers/fetchContractInterfaceHelper.test.d.ts +1 -0
  34. package/dist/test/helpers/fetchContractInterfaceHelper.test.js +70 -0
  35. package/dist/test/helpers/fetchContractInterfaceHelper.test.js.map +1 -0
  36. package/dist/test/helpers/fetchDataHelper.test.d.ts +1 -0
  37. package/dist/test/helpers/fetchDataHelper.test.js +162 -0
  38. package/dist/test/helpers/fetchDataHelper.test.js.map +1 -0
  39. package/dist/test/helpers/fetchPossibleSwap.test.d.ts +1 -0
  40. package/dist/test/helpers/fetchPossibleSwap.test.js +154 -0
  41. package/dist/test/helpers/fetchPossibleSwap.test.js.map +1 -0
  42. package/dist/test/helpers/getContractInterfaceAndFunction.test.d.ts +1 -0
  43. package/dist/test/helpers/getContractInterfaceAndFunction.test.js +25 -0
  44. package/dist/test/helpers/getContractInterfaceAndFunction.test.js.map +1 -0
  45. package/dist/test/helpers/getFunctionArgs.test.d.ts +1 -0
  46. package/dist/test/helpers/getFunctionArgs.test.js +25 -0
  47. package/dist/test/helpers/getFunctionArgs.test.js.map +1 -0
  48. package/dist/test/helpers/getTokenDecimalsHelper.test.d.ts +1 -0
  49. package/dist/test/helpers/getTokenDecimalsHelper.test.js +229 -0
  50. package/dist/test/helpers/getTokenDecimalsHelper.test.js.map +1 -0
  51. package/dist/test/helpers/getTokenNameHelper.test.d.ts +1 -0
  52. package/dist/test/helpers/getTokenNameHelper.test.js +258 -0
  53. package/dist/test/helpers/getTokenNameHelper.test.js.map +1 -0
  54. package/dist/test/helpers/handleResultHelper.test.d.ts +1 -0
  55. package/dist/test/helpers/handleResultHelper.test.js +72 -0
  56. package/dist/test/helpers/handleResultHelper.test.js.map +1 -0
  57. package/dist/test/helpers/newPostConditionsHelper.test.d.ts +1 -0
  58. package/dist/test/helpers/newPostConditionsHelper.test.js +348 -0
  59. package/dist/test/helpers/newPostConditionsHelper.test.js.map +1 -0
  60. package/dist/test/helpers/postConditionsHelper.test.d.ts +1 -0
  61. package/dist/test/helpers/postConditionsHelper.test.js +262 -0
  62. package/dist/test/helpers/postConditionsHelper.test.js.map +1 -0
  63. package/dist/test/keeper/keeperAPI.test.d.ts +1 -0
  64. package/dist/test/keeper/keeperAPI.test.js +283 -0
  65. package/dist/test/keeper/keeperAPI.test.js.map +1 -0
  66. package/package.json +1 -1
@@ -0,0 +1,348 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const transactions_1 = require("@stacks/transactions");
4
+ const newPostConditionsHelper_1 = require("../../src/helpers/newPostConditionsHelper");
5
+ // Mock @stacks/transactions
6
+ jest.mock("@stacks/transactions", () => ({
7
+ Pc: {
8
+ principal: jest.fn(() => ({
9
+ willSendEq: jest.fn(() => ({
10
+ ustx: jest.fn(() => ({})),
11
+ ft: jest.fn(() => ({}))
12
+ })),
13
+ willSendGte: jest.fn(() => ({
14
+ ustx: jest.fn(() => ({})),
15
+ ft: jest.fn(() => ({}))
16
+ }))
17
+ }))
18
+ }
19
+ }));
20
+ describe("newPostConditionsHelper", () => {
21
+ const mockPc = transactions_1.Pc;
22
+ const mockPrincipal = mockPc.principal;
23
+ const mockWillSendEq = jest.fn();
24
+ const mockWillSendGte = jest.fn();
25
+ const mockUstx = jest.fn();
26
+ const mockFt = jest.fn();
27
+ beforeEach(() => {
28
+ jest.clearAllMocks();
29
+ // Setup mock chain
30
+ mockWillSendEq.mockReturnValue({ ustx: mockUstx, ft: mockFt });
31
+ mockWillSendGte.mockReturnValue({ ustx: mockUstx, ft: mockFt });
32
+ mockUstx.mockReturnValue({});
33
+ mockFt.mockReturnValue({});
34
+ mockPrincipal.mockReturnValue({
35
+ willSendEq: mockWillSendEq,
36
+ willSendGte: mockWillSendGte
37
+ });
38
+ });
39
+ describe("createSwapPostConditions", () => {
40
+ it("should create STX post conditions for tx-sender", async () => {
41
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
42
+ const postConditionsData = {
43
+ pc1: {
44
+ senderAddress: "tx-sender",
45
+ shareFeeContract: null,
46
+ dikoStx: null,
47
+ tokenContract: "token-stx",
48
+ tokenName: "token-stx",
49
+ tokenDecimals: 6
50
+ }
51
+ };
52
+ const senderAddress = "ST1234567890123456789012345678901234567890";
53
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
54
+ expect(result).toHaveLength(1);
55
+ expect(mockPrincipal).toHaveBeenCalledWith(senderAddress);
56
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(1000000));
57
+ expect(mockUstx).toHaveBeenCalled();
58
+ });
59
+ it("should create STX post conditions for specific address", async () => {
60
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
61
+ const postConditionsData = {
62
+ pc1: {
63
+ senderAddress: "ST9876543210987654321098765432109876543210",
64
+ shareFeeContract: null,
65
+ dikoStx: null,
66
+ tokenContract: "token-stx",
67
+ tokenName: "token-stx",
68
+ tokenDecimals: 6
69
+ }
70
+ };
71
+ const senderAddress = "ST1234567890123456789012345678901234567890";
72
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
73
+ expect(result).toHaveLength(1);
74
+ expect(mockPrincipal).toHaveBeenCalledWith("ST9876543210987654321098765432109876543210");
75
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(1000000));
76
+ expect(mockUstx).toHaveBeenCalled();
77
+ });
78
+ it("should create fungible token post conditions", async () => {
79
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
80
+ const postConditionsData = {
81
+ pc1: {
82
+ senderAddress: "tx-sender",
83
+ shareFeeContract: null,
84
+ dikoStx: null,
85
+ tokenContract: "ST1234567890123456789012345678901234567890.token-a",
86
+ tokenName: "token-a",
87
+ tokenDecimals: 6
88
+ }
89
+ };
90
+ const senderAddress = "ST1234567890123456789012345678901234567890";
91
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
92
+ expect(result).toHaveLength(1);
93
+ expect(mockPrincipal).toHaveBeenCalledWith(senderAddress);
94
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(1000000));
95
+ expect(mockFt).toHaveBeenCalledWith("ST1234567890123456789012345678901234567890.token-a", "token-a");
96
+ });
97
+ it("should handle WSTXv2 token with STX post condition", async () => {
98
+ const functionArgs = {
99
+ dx: BigInt(1000000),
100
+ "min-dy": BigInt(500000),
101
+ tokenContract: "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-wstx-v2"
102
+ };
103
+ const postConditionsData = {
104
+ pc1: {
105
+ senderAddress: "tx-sender",
106
+ shareFeeContract: null,
107
+ dikoStx: null,
108
+ tokenContract: "token-stx",
109
+ tokenName: "token-stx",
110
+ tokenDecimals: 6
111
+ }
112
+ };
113
+ const senderAddress = "ST1234567890123456789012345678901234567890";
114
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
115
+ expect(result).toHaveLength(1);
116
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(10000)); // Divided by 100
117
+ });
118
+ it("should handle auto-alex-v3 token with willSendGte and zero amount", async () => {
119
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
120
+ const postConditionsData = {
121
+ pc1: {
122
+ senderAddress: "tx-sender",
123
+ shareFeeContract: null,
124
+ dikoStx: null,
125
+ tokenContract: "ST1234567890123456789012345678901234567890.auto-alex-v3",
126
+ tokenName: "auto-alex-v3",
127
+ tokenDecimals: 6
128
+ }
129
+ };
130
+ const senderAddress = "ST1234567890123456789012345678901234567890";
131
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
132
+ expect(result).toHaveLength(1);
133
+ expect(mockWillSendGte).toHaveBeenCalledWith(BigInt(0));
134
+ });
135
+ it("should handle lqstx token with willSendGte and zero amount", async () => {
136
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
137
+ const postConditionsData = {
138
+ pc1: {
139
+ senderAddress: "tx-sender",
140
+ shareFeeContract: null,
141
+ dikoStx: null,
142
+ tokenContract: "ST1234567890123456789012345678901234567890.lqstx",
143
+ tokenName: "lqstx",
144
+ tokenDecimals: 6
145
+ }
146
+ };
147
+ const senderAddress = "ST1234567890123456789012345678901234567890";
148
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
149
+ expect(result).toHaveLength(1);
150
+ expect(mockWillSendGte).toHaveBeenCalledWith(BigInt(0));
151
+ });
152
+ it("should handle last post condition with min-dy", async () => {
153
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
154
+ const postConditionsData = {
155
+ pc1: {
156
+ senderAddress: "tx-sender",
157
+ shareFeeContract: null,
158
+ dikoStx: null,
159
+ tokenContract: "ST1234567890123456789012345678901234567890.token-a",
160
+ tokenName: "token-a",
161
+ tokenDecimals: 6
162
+ },
163
+ pc2: {
164
+ senderAddress: "tx-sender",
165
+ shareFeeContract: null,
166
+ dikoStx: null,
167
+ tokenContract: "ST1234567890123456789012345678901234567890.token-b",
168
+ tokenName: "token-b",
169
+ tokenDecimals: 6
170
+ }
171
+ };
172
+ const senderAddress = "ST1234567890123456789012345678901234567890";
173
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
174
+ expect(result).toHaveLength(2);
175
+ // First post condition should use dx
176
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(1000000));
177
+ // Second post condition should use min-dy
178
+ expect(mockWillSendGte).toHaveBeenCalledWith(BigInt(500000));
179
+ });
180
+ it("should handle decimal adjustments for non-STX tokens", async () => {
181
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
182
+ const postConditionsData = {
183
+ pc1: {
184
+ senderAddress: "tx-sender",
185
+ shareFeeContract: null,
186
+ dikoStx: null,
187
+ tokenContract: "ST1234567890123456789012345678901234567890.token-a",
188
+ tokenName: "token-a",
189
+ tokenDecimals: 4 // Lower decimals than tokenX (6)
190
+ }
191
+ };
192
+ const senderAddress = "ST1234567890123456789012345678901234567890";
193
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, // tokenXDecimals
194
+ 6 // tokenYDecimals
195
+ );
196
+ expect(result).toHaveLength(1);
197
+ // Should divide by 10^(6-4) = 100
198
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(10000));
199
+ });
200
+ it("should handle decimal adjustments for last post condition", async () => {
201
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
202
+ const postConditionsData = {
203
+ pc1: {
204
+ senderAddress: "tx-sender",
205
+ shareFeeContract: null,
206
+ dikoStx: null,
207
+ tokenContract: "ST1234567890123456789012345678901234567890.token-b",
208
+ tokenName: "token-b",
209
+ tokenDecimals: 8 // Higher decimals than tokenY (6)
210
+ }
211
+ };
212
+ const senderAddress = "ST1234567890123456789012345678901234567890";
213
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, // tokenXDecimals
214
+ 6 // tokenYDecimals
215
+ );
216
+ expect(result).toHaveLength(1);
217
+ // Since this is the only post condition, it's treated as first (not last)
218
+ // So it uses dx and willSendEq, then applies decimal adjustment
219
+ // Should multiply by 10^(6-8) = 1/100, but since it's first, it uses dx
220
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(100000000));
221
+ });
222
+ it("should handle shareFeeContract post conditions", async () => {
223
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
224
+ const postConditionsData = {
225
+ pc1: {
226
+ senderAddress: "tx-sender",
227
+ shareFeeContract: "ST9876543210987654321098765432109876543210.share-fee",
228
+ dikoStx: null,
229
+ tokenContract: "token-stx",
230
+ tokenName: "token-stx",
231
+ tokenDecimals: 6
232
+ }
233
+ };
234
+ const senderAddress = "ST1234567890123456789012345678901234567890";
235
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
236
+ expect(result).toHaveLength(2); // One for sender, one for shareFeeContract
237
+ expect(mockPrincipal).toHaveBeenCalledWith("ST9876543210987654321098765432109876543210.share-fee");
238
+ expect(mockWillSendGte).toHaveBeenCalledWith(0);
239
+ });
240
+ it("should handle dikoStx post conditions for tx-sender", async () => {
241
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
242
+ const postConditionsData = {
243
+ pc1: {
244
+ senderAddress: "tx-sender",
245
+ shareFeeContract: null,
246
+ dikoStx: "ST9876543210987654321098765432109876543210.diko-stx",
247
+ tokenContract: "token-stx",
248
+ tokenName: "token-stx",
249
+ tokenDecimals: 6
250
+ }
251
+ };
252
+ const senderAddress = "ST1234567890123456789012345678901234567890";
253
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
254
+ expect(result).toHaveLength(2); // One for sender, one for dikoStx
255
+ expect(mockPrincipal).toHaveBeenCalledWith(senderAddress);
256
+ expect(mockFt).toHaveBeenCalledWith("ST9876543210987654321098765432109876543210.diko-stx", "wstx");
257
+ });
258
+ it("should handle dikoStx post conditions for specific address", async () => {
259
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
260
+ const postConditionsData = {
261
+ pc1: {
262
+ senderAddress: "ST9876543210987654321098765432109876543210",
263
+ shareFeeContract: null,
264
+ dikoStx: "ST1111111111111111111111111111111111111111.diko-stx",
265
+ tokenContract: "token-stx",
266
+ tokenName: "token-stx",
267
+ tokenDecimals: 6
268
+ }
269
+ };
270
+ const senderAddress = "ST1234567890123456789012345678901234567890";
271
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
272
+ expect(result).toHaveLength(2); // One for sender, one for dikoStx
273
+ // The function calls principal with the sender address first, then with the dikoStx address
274
+ expect(mockPrincipal).toHaveBeenCalledWith("ST9876543210987654321098765432109876543210");
275
+ expect(mockFt).toHaveBeenCalledWith("ST1111111111111111111111111111111111111111.diko-stx", "wstx");
276
+ });
277
+ it("should handle nested WSTXv2 detection", async () => {
278
+ const functionArgs = {
279
+ dx: BigInt(1000000),
280
+ "min-dy": BigInt(500000),
281
+ nested: {
282
+ token: "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-wstx-v2"
283
+ }
284
+ };
285
+ const postConditionsData = {
286
+ pc1: {
287
+ senderAddress: "tx-sender",
288
+ shareFeeContract: null,
289
+ dikoStx: null,
290
+ tokenContract: "token-stx",
291
+ tokenName: "token-stx",
292
+ tokenDecimals: 6
293
+ }
294
+ };
295
+ const senderAddress = "ST1234567890123456789012345678901234567890";
296
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
297
+ expect(result).toHaveLength(1);
298
+ expect(mockWillSendEq).toHaveBeenCalledWith(BigInt(10000)); // Divided by 100
299
+ });
300
+ it("should handle error in post condition creation", async () => {
301
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
302
+ const postConditionsData = {
303
+ pc1: {
304
+ senderAddress: "tx-sender",
305
+ shareFeeContract: null,
306
+ dikoStx: null,
307
+ tokenContract: "token-stx",
308
+ tokenName: "token-stx",
309
+ tokenDecimals: 6
310
+ }
311
+ };
312
+ const senderAddress = "ST1234567890123456789012345678901234567890";
313
+ // Mock Pc.principal to throw an error
314
+ mockPrincipal.mockImplementation(() => {
315
+ throw new Error("Mock error");
316
+ });
317
+ const consoleSpy = jest.spyOn(console, "error").mockImplementation();
318
+ await expect((0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6)).rejects.toThrow("Failed to create post condition for pc1: Mock error");
319
+ expect(consoleSpy).toHaveBeenCalledWith("Error creating post condition for pc1:", expect.any(Error));
320
+ consoleSpy.mockRestore();
321
+ });
322
+ it("should handle multiple post conditions with different types", async () => {
323
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(500000) };
324
+ const postConditionsData = {
325
+ pc1: {
326
+ senderAddress: "tx-sender",
327
+ shareFeeContract: "ST9876543210987654321098765432109876543210.share-fee",
328
+ dikoStx: "ST1111111111111111111111111111111111111111.diko-stx",
329
+ tokenContract: "token-stx",
330
+ tokenName: "token-stx",
331
+ tokenDecimals: 6
332
+ },
333
+ pc2: {
334
+ senderAddress: "ST9876543210987654321098765432109876543210",
335
+ shareFeeContract: null,
336
+ dikoStx: null,
337
+ tokenContract: "ST1234567890123456789012345678901234567890.token-a",
338
+ tokenName: "token-a",
339
+ tokenDecimals: 6
340
+ }
341
+ };
342
+ const senderAddress = "ST1234567890123456789012345678901234567890";
343
+ const result = await (0, newPostConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, 6, 6);
344
+ expect(result).toHaveLength(4); // 2 main + 1 shareFeeContract + 1 dikoStx
345
+ });
346
+ });
347
+ });
348
+ //# sourceMappingURL=newPostConditionsHelper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"newPostConditionsHelper.test.js","sourceRoot":"","sources":["../../../test/helpers/newPostConditionsHelper.test.ts"],"names":[],"mappings":";;AAAA,uDAAyD;AACzD,uFAAqF;AAErF,4BAA4B;AAC5B,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,EAAE,EAAE;QACF,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;YACxB,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;gBACzB,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;gBACzB,EAAE,EAAE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YAEnE,MAAM,MAAM,GAAG,MAAM,IAAA,kDAAwB,EAC3C,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,CAAC,EACD,CAAC,CACF,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,0CAA0C;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const postConditionsHelper_1 = require("../../src/helpers/postConditionsHelper");
4
+ // Mock Pc to avoid actual post condition creation
5
+ jest.mock("@stacks/transactions", () => ({
6
+ FungibleConditionCode: {
7
+ Equal: 1,
8
+ GreaterEqual: 2,
9
+ },
10
+ Pc: {
11
+ principal: jest.fn((address) => {
12
+ if (address === "invalid-address") {
13
+ throw new Error("Invalid address");
14
+ }
15
+ return {
16
+ willSendEq: jest.fn(() => ({
17
+ ustx: jest.fn(() => ({ type: "stx-post-condition" })),
18
+ ft: jest.fn(() => ({ type: "fungible-post-condition" })),
19
+ })),
20
+ willSendGte: jest.fn(() => ({
21
+ ustx: jest.fn(() => ({ type: "stx-post-condition" })),
22
+ ft: jest.fn(() => ({ type: "fungible-post-condition" })),
23
+ })),
24
+ };
25
+ }),
26
+ },
27
+ }));
28
+ describe("postConditionsHelper", () => {
29
+ beforeEach(() => {
30
+ jest.clearAllMocks();
31
+ });
32
+ describe("createSwapPostConditions", () => {
33
+ it("should create STX post conditions for tx-sender", async () => {
34
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
35
+ const postConditionsData = {
36
+ "0": {
37
+ senderAddress: "tx-sender",
38
+ tokenContract: "token-stx",
39
+ tokenName: "token-stx",
40
+ tokenDecimals: 6,
41
+ shareFeeContract: null,
42
+ dikoStx: null,
43
+ },
44
+ };
45
+ const senderAddress = "ST1234567890123456789012345678901234567890";
46
+ const tokenXDecimals = 6;
47
+ const tokenYDecimals = 6;
48
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
49
+ expect(result).toHaveLength(1);
50
+ expect(result[0]).toEqual({ type: "stx-post-condition" });
51
+ });
52
+ it("should create fungible token post conditions for tx-sender", async () => {
53
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
54
+ const postConditionsData = {
55
+ "0": {
56
+ senderAddress: "tx-sender",
57
+ tokenContract: "ST1234567890123456789012345678901234567890.token",
58
+ tokenName: "test-token",
59
+ tokenDecimals: 6,
60
+ shareFeeContract: null,
61
+ dikoStx: null,
62
+ },
63
+ };
64
+ const senderAddress = "ST1234567890123456789012345678901234567890";
65
+ const tokenXDecimals = 6;
66
+ const tokenYDecimals = 6;
67
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
68
+ expect(result).toHaveLength(1);
69
+ expect(result[0]).toEqual({ type: "fungible-post-condition" });
70
+ });
71
+ it("should create contract post conditions", async () => {
72
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
73
+ const postConditionsData = {
74
+ "0": {
75
+ senderAddress: "ST1234567890123456789012345678901234567890.contract",
76
+ tokenContract: "ST1234567890123456789012345678901234567890.token",
77
+ tokenName: "test-token",
78
+ tokenDecimals: 6,
79
+ shareFeeContract: null,
80
+ dikoStx: null,
81
+ },
82
+ };
83
+ const senderAddress = "ST1234567890123456789012345678901234567890";
84
+ const tokenXDecimals = 6;
85
+ const tokenYDecimals = 6;
86
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
87
+ expect(result).toHaveLength(1);
88
+ expect(result[0]).toEqual({ type: "fungible-post-condition" });
89
+ });
90
+ it("should handle auto-alex-v3 and lqstx tokens", async () => {
91
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
92
+ const postConditionsData = {
93
+ "0": {
94
+ senderAddress: "tx-sender",
95
+ tokenContract: "ST1234567890123456789012345678901234567890.auto-alex-v3",
96
+ tokenName: "auto-alex-v3",
97
+ tokenDecimals: 6,
98
+ shareFeeContract: null,
99
+ dikoStx: null,
100
+ },
101
+ };
102
+ const senderAddress = "ST1234567890123456789012345678901234567890";
103
+ const tokenXDecimals = 6;
104
+ const tokenYDecimals = 6;
105
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
106
+ expect(result).toHaveLength(1);
107
+ expect(result[0]).toEqual({ type: "fungible-post-condition" });
108
+ });
109
+ it("should handle WSTXv2 token adjustments", async () => {
110
+ const functionArgs = {
111
+ dx: BigInt(1000000),
112
+ "min-dy": BigInt(950000),
113
+ token: "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-wstx-v2"
114
+ };
115
+ const postConditionsData = {
116
+ "0": {
117
+ senderAddress: "tx-sender",
118
+ tokenContract: "token-stx",
119
+ tokenName: "token-stx",
120
+ tokenDecimals: 6,
121
+ shareFeeContract: null,
122
+ dikoStx: null,
123
+ },
124
+ };
125
+ const senderAddress = "ST1234567890123456789012345678901234567890";
126
+ const tokenXDecimals = 6;
127
+ const tokenYDecimals = 6;
128
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
129
+ expect(result).toHaveLength(1);
130
+ expect(result[0]).toEqual({ type: "stx-post-condition" });
131
+ });
132
+ it("should handle decimal adjustments for non-STX tokens", async () => {
133
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
134
+ const postConditionsData = {
135
+ "0": {
136
+ senderAddress: "tx-sender",
137
+ tokenContract: "ST1234567890123456789012345678901234567890.token",
138
+ tokenName: "test-token",
139
+ tokenDecimals: 4, // Different from tokenXDecimals
140
+ shareFeeContract: null,
141
+ dikoStx: null,
142
+ },
143
+ };
144
+ const senderAddress = "ST1234567890123456789012345678901234567890";
145
+ const tokenXDecimals = 6;
146
+ const tokenYDecimals = 6;
147
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
148
+ expect(result).toHaveLength(1);
149
+ expect(result[0]).toEqual({ type: "fungible-post-condition" });
150
+ });
151
+ it("should handle share fee contracts", async () => {
152
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
153
+ const postConditionsData = {
154
+ "0": {
155
+ senderAddress: "tx-sender",
156
+ tokenContract: "token-stx",
157
+ tokenName: "token-stx",
158
+ tokenDecimals: 6,
159
+ shareFeeContract: "ST1234567890123456789012345678901234567890.share-fee",
160
+ dikoStx: null,
161
+ },
162
+ };
163
+ const senderAddress = "ST1234567890123456789012345678901234567890";
164
+ const tokenXDecimals = 6;
165
+ const tokenYDecimals = 6;
166
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
167
+ expect(result).toHaveLength(2); // Main condition + share fee condition
168
+ expect(result[0]).toEqual({ type: "stx-post-condition" });
169
+ expect(result[1]).toEqual({ type: "stx-post-condition" });
170
+ });
171
+ it("should handle DIKO STX conditions", async () => {
172
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
173
+ const postConditionsData = {
174
+ "0": {
175
+ senderAddress: "tx-sender",
176
+ tokenContract: "token-stx",
177
+ tokenName: "token-stx",
178
+ tokenDecimals: 6,
179
+ shareFeeContract: null,
180
+ dikoStx: "ST1234567890123456789012345678901234567890.diko",
181
+ },
182
+ };
183
+ const senderAddress = "ST1234567890123456789012345678901234567890";
184
+ const tokenXDecimals = 6;
185
+ const tokenYDecimals = 6;
186
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
187
+ expect(result).toHaveLength(2); // Main condition + DIKO condition
188
+ expect(result[0]).toEqual({ type: "stx-post-condition" });
189
+ expect(result[1]).toEqual({ type: "fungible-post-condition" });
190
+ });
191
+ it("should handle multiple post conditions", async () => {
192
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
193
+ const postConditionsData = {
194
+ "0": {
195
+ senderAddress: "tx-sender",
196
+ tokenContract: "token-stx",
197
+ tokenName: "token-stx",
198
+ tokenDecimals: 6,
199
+ shareFeeContract: null,
200
+ dikoStx: null,
201
+ },
202
+ "1": {
203
+ senderAddress: "ST1234567890123456789012345678901234567890.contract",
204
+ tokenContract: "ST1234567890123456789012345678901234567890.token",
205
+ tokenName: "test-token",
206
+ tokenDecimals: 6,
207
+ shareFeeContract: null,
208
+ dikoStx: null,
209
+ },
210
+ };
211
+ const senderAddress = "ST1234567890123456789012345678901234567890";
212
+ const tokenXDecimals = 6;
213
+ const tokenYDecimals = 6;
214
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
215
+ expect(result).toHaveLength(2);
216
+ expect(result[0]).toEqual({ type: "stx-post-condition" });
217
+ expect(result[1]).toEqual({ type: "fungible-post-condition" });
218
+ });
219
+ it("should handle empty post conditions data", async () => {
220
+ const functionArgs = { dx: BigInt(1000000), "min-dy": BigInt(950000) };
221
+ const postConditionsData = {};
222
+ const senderAddress = "ST1234567890123456789012345678901234567890";
223
+ const tokenXDecimals = 6;
224
+ const tokenYDecimals = 6;
225
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
226
+ expect(result).toEqual([]);
227
+ });
228
+ it("should handle complex scenarios with all features", async () => {
229
+ const functionArgs = {
230
+ dx: BigInt(1000000),
231
+ "min-dy": BigInt(950000),
232
+ token: "SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.token-wstx-v2"
233
+ };
234
+ const postConditionsData = {
235
+ "0": {
236
+ senderAddress: "tx-sender",
237
+ tokenContract: "token-stx",
238
+ tokenName: "token-stx",
239
+ tokenDecimals: 6,
240
+ shareFeeContract: "ST1234567890123456789012345678901234567890.share-fee",
241
+ dikoStx: "ST1234567890123456789012345678901234567890.diko",
242
+ },
243
+ "1": {
244
+ senderAddress: "ST1234567890123456789012345678901234567890.contract",
245
+ tokenContract: "ST1234567890123456789012345678901234567890.token",
246
+ tokenName: "test-token",
247
+ tokenDecimals: 4,
248
+ shareFeeContract: null,
249
+ dikoStx: null,
250
+ },
251
+ };
252
+ const senderAddress = "ST1234567890123456789012345678901234567890";
253
+ const tokenXDecimals = 6;
254
+ const tokenYDecimals = 8;
255
+ const result = await (0, postConditionsHelper_1.createSwapPostConditions)(functionArgs, postConditionsData, senderAddress, tokenXDecimals, tokenYDecimals);
256
+ expect(result.length).toBeGreaterThan(0);
257
+ // Should have conditions for both post conditions plus share fee and DIKO
258
+ expect(result.length).toBeGreaterThanOrEqual(4);
259
+ });
260
+ });
261
+ });
262
+ //# sourceMappingURL=postConditionsHelper.test.js.map