@bosonprotocol/core-sdk 1.43.3 → 1.44.0-alpha.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 (302) hide show
  1. package/dist/cjs/accounts/handler.d.ts +115 -1
  2. package/dist/cjs/accounts/handler.d.ts.map +1 -1
  3. package/dist/cjs/accounts/handler.js +126 -28
  4. package/dist/cjs/accounts/handler.js.map +1 -1
  5. package/dist/cjs/accounts/mixin.d.ts +105 -8
  6. package/dist/cjs/accounts/mixin.d.ts.map +1 -1
  7. package/dist/cjs/accounts/mixin.js +162 -122
  8. package/dist/cjs/accounts/mixin.js.map +1 -1
  9. package/dist/cjs/core-sdk.d.ts +6 -6
  10. package/dist/cjs/core-sdk.d.ts.map +1 -1
  11. package/dist/cjs/core-sdk.js.map +1 -1
  12. package/dist/cjs/disputes/handler.d.ts +77 -1
  13. package/dist/cjs/disputes/handler.d.ts.map +1 -1
  14. package/dist/cjs/disputes/handler.js +90 -20
  15. package/dist/cjs/disputes/handler.js.map +1 -1
  16. package/dist/cjs/disputes/mixin.d.ts +29 -11
  17. package/dist/cjs/disputes/mixin.d.ts.map +1 -1
  18. package/dist/cjs/disputes/mixin.js +97 -88
  19. package/dist/cjs/disputes/mixin.js.map +1 -1
  20. package/dist/cjs/erc1155/mixin.d.ts +2 -1
  21. package/dist/cjs/erc1155/mixin.d.ts.map +1 -1
  22. package/dist/cjs/erc1155/mixin.js.map +1 -1
  23. package/dist/cjs/erc165/mixin.d.ts +2 -1
  24. package/dist/cjs/erc165/mixin.d.ts.map +1 -1
  25. package/dist/cjs/erc165/mixin.js.map +1 -1
  26. package/dist/cjs/erc20/handler.d.ts +11 -2
  27. package/dist/cjs/erc20/handler.d.ts.map +1 -1
  28. package/dist/cjs/erc20/handler.js +8 -1
  29. package/dist/cjs/erc20/handler.js.map +1 -1
  30. package/dist/cjs/erc20/mixin.d.ts +20 -3
  31. package/dist/cjs/erc20/mixin.d.ts.map +1 -1
  32. package/dist/cjs/erc20/mixin.js +15 -10
  33. package/dist/cjs/erc20/mixin.js.map +1 -1
  34. package/dist/cjs/erc721/handler.d.ts +11 -2
  35. package/dist/cjs/erc721/handler.d.ts.map +1 -1
  36. package/dist/cjs/erc721/handler.js +8 -2
  37. package/dist/cjs/erc721/handler.js.map +1 -1
  38. package/dist/cjs/erc721/mixin.d.ts +2 -1
  39. package/dist/cjs/erc721/mixin.d.ts.map +1 -1
  40. package/dist/cjs/erc721/mixin.js.map +1 -1
  41. package/dist/cjs/errors/mixin.d.ts +2 -1
  42. package/dist/cjs/errors/mixin.d.ts.map +1 -1
  43. package/dist/cjs/errors/mixin.js.map +1 -1
  44. package/dist/cjs/event-logs/mixin.d.ts +2 -1
  45. package/dist/cjs/event-logs/mixin.d.ts.map +1 -1
  46. package/dist/cjs/event-logs/mixin.js.map +1 -1
  47. package/dist/cjs/exchanges/handler.d.ts +44 -1
  48. package/dist/cjs/exchanges/handler.d.ts.map +1 -1
  49. package/dist/cjs/exchanges/handler.js +76 -17
  50. package/dist/cjs/exchanges/handler.js.map +1 -1
  51. package/dist/cjs/exchanges/mixin.d.ts +24 -8
  52. package/dist/cjs/exchanges/mixin.d.ts.map +1 -1
  53. package/dist/cjs/exchanges/mixin.js +72 -72
  54. package/dist/cjs/exchanges/mixin.js.map +1 -1
  55. package/dist/cjs/funds/handler.d.ts +27 -1
  56. package/dist/cjs/funds/handler.d.ts.map +1 -1
  57. package/dist/cjs/funds/handler.js +28 -7
  58. package/dist/cjs/funds/handler.js.map +1 -1
  59. package/dist/cjs/funds/mixin.d.ts +50 -17
  60. package/dist/cjs/funds/mixin.d.ts.map +1 -1
  61. package/dist/cjs/funds/mixin.js +48 -46
  62. package/dist/cjs/funds/mixin.js.map +1 -1
  63. package/dist/cjs/groups/handler.d.ts +8 -1
  64. package/dist/cjs/groups/handler.d.ts.map +1 -1
  65. package/dist/cjs/groups/handler.js +9 -2
  66. package/dist/cjs/groups/handler.js.map +1 -1
  67. package/dist/cjs/groups/mixin.d.ts +12 -4
  68. package/dist/cjs/groups/mixin.d.ts.map +1 -1
  69. package/dist/cjs/groups/mixin.js +10 -8
  70. package/dist/cjs/groups/mixin.js.map +1 -1
  71. package/dist/cjs/marketplaces/mixin.d.ts +2 -1
  72. package/dist/cjs/marketplaces/mixin.d.ts.map +1 -1
  73. package/dist/cjs/marketplaces/mixin.js.map +1 -1
  74. package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
  75. package/dist/cjs/meta-tx/handler.js +4 -2
  76. package/dist/cjs/meta-tx/handler.js.map +1 -1
  77. package/dist/cjs/meta-tx/mixin.d.ts +2 -2
  78. package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
  79. package/dist/cjs/meta-tx/mixin.js.map +1 -1
  80. package/dist/cjs/metadata/mixin.d.ts +2 -1
  81. package/dist/cjs/metadata/mixin.d.ts.map +1 -1
  82. package/dist/cjs/metadata/mixin.js.map +1 -1
  83. package/dist/cjs/mixins/base-core-sdk.d.ts +4 -4
  84. package/dist/cjs/mixins/base-core-sdk.d.ts.map +1 -1
  85. package/dist/cjs/mixins/base-core-sdk.js.map +1 -1
  86. package/dist/cjs/native-meta-tx/handler.d.ts.map +1 -1
  87. package/dist/cjs/native-meta-tx/handler.js +2 -1
  88. package/dist/cjs/native-meta-tx/handler.js.map +1 -1
  89. package/dist/cjs/native-meta-tx/mixin.d.ts +2 -2
  90. package/dist/cjs/native-meta-tx/mixin.d.ts.map +1 -1
  91. package/dist/cjs/native-meta-tx/mixin.js.map +1 -1
  92. package/dist/cjs/offers/handler.d.ts +81 -1
  93. package/dist/cjs/offers/handler.d.ts.map +1 -1
  94. package/dist/cjs/offers/handler.js +81 -20
  95. package/dist/cjs/offers/handler.js.map +1 -1
  96. package/dist/cjs/offers/mixin.d.ts +54 -2
  97. package/dist/cjs/offers/mixin.d.ts.map +1 -1
  98. package/dist/cjs/offers/mixin.js +102 -97
  99. package/dist/cjs/offers/mixin.js.map +1 -1
  100. package/dist/cjs/orchestration/handler.d.ts +86 -1
  101. package/dist/cjs/orchestration/handler.d.ts.map +1 -1
  102. package/dist/cjs/orchestration/handler.js +64 -16
  103. package/dist/cjs/orchestration/handler.js.map +1 -1
  104. package/dist/cjs/orchestration/mixin.d.ts +2 -2
  105. package/dist/cjs/orchestration/mixin.d.ts.map +1 -1
  106. package/dist/cjs/orchestration/mixin.js.map +1 -1
  107. package/dist/cjs/price-discovery/handler.d.ts +11 -1
  108. package/dist/cjs/price-discovery/handler.d.ts.map +1 -1
  109. package/dist/cjs/price-discovery/handler.js +9 -2
  110. package/dist/cjs/price-discovery/handler.js.map +1 -1
  111. package/dist/cjs/price-discovery/mixin.d.ts +16 -4
  112. package/dist/cjs/price-discovery/mixin.d.ts.map +1 -1
  113. package/dist/cjs/price-discovery/mixin.js +14 -12
  114. package/dist/cjs/price-discovery/mixin.js.map +1 -1
  115. package/dist/cjs/protocol-config/handler.d.ts +9 -0
  116. package/dist/cjs/protocol-config/handler.d.ts.map +1 -1
  117. package/dist/cjs/protocol-config/handler.js +10 -3
  118. package/dist/cjs/protocol-config/handler.js.map +1 -1
  119. package/dist/cjs/protocol-config/mixin.d.ts +2 -1
  120. package/dist/cjs/protocol-config/mixin.d.ts.map +1 -1
  121. package/dist/cjs/protocol-config/mixin.js.map +1 -1
  122. package/dist/cjs/subgraph/mixin.d.ts +2 -2
  123. package/dist/cjs/subgraph/mixin.d.ts.map +1 -1
  124. package/dist/cjs/subgraph/mixin.js.map +1 -1
  125. package/dist/cjs/voucher/handler.d.ts +56 -1
  126. package/dist/cjs/voucher/handler.d.ts.map +1 -1
  127. package/dist/cjs/voucher/handler.js +56 -14
  128. package/dist/cjs/voucher/handler.js.map +1 -1
  129. package/dist/cjs/voucher/mixin.d.ts +66 -22
  130. package/dist/cjs/voucher/mixin.d.ts.map +1 -1
  131. package/dist/cjs/voucher/mixin.js +75 -61
  132. package/dist/cjs/voucher/mixin.js.map +1 -1
  133. package/dist/esm/accounts/handler.d.ts +115 -1
  134. package/dist/esm/accounts/handler.d.ts.map +1 -1
  135. package/dist/esm/accounts/handler.js +126 -28
  136. package/dist/esm/accounts/handler.js.map +1 -1
  137. package/dist/esm/accounts/mixin.d.ts +105 -8
  138. package/dist/esm/accounts/mixin.d.ts.map +1 -1
  139. package/dist/esm/accounts/mixin.js +249 -116
  140. package/dist/esm/accounts/mixin.js.map +1 -1
  141. package/dist/esm/core-sdk.d.ts +6 -6
  142. package/dist/esm/core-sdk.d.ts.map +1 -1
  143. package/dist/esm/core-sdk.js.map +1 -1
  144. package/dist/esm/disputes/handler.d.ts +77 -1
  145. package/dist/esm/disputes/handler.d.ts.map +1 -1
  146. package/dist/esm/disputes/handler.js +90 -20
  147. package/dist/esm/disputes/handler.js.map +1 -1
  148. package/dist/esm/disputes/mixin.d.ts +29 -11
  149. package/dist/esm/disputes/mixin.d.ts.map +1 -1
  150. package/dist/esm/disputes/mixin.js +155 -90
  151. package/dist/esm/disputes/mixin.js.map +1 -1
  152. package/dist/esm/erc1155/mixin.d.ts +2 -1
  153. package/dist/esm/erc1155/mixin.d.ts.map +1 -1
  154. package/dist/esm/erc1155/mixin.js.map +1 -1
  155. package/dist/esm/erc165/mixin.d.ts +2 -1
  156. package/dist/esm/erc165/mixin.d.ts.map +1 -1
  157. package/dist/esm/erc165/mixin.js.map +1 -1
  158. package/dist/esm/erc20/handler.d.ts +11 -2
  159. package/dist/esm/erc20/handler.d.ts.map +1 -1
  160. package/dist/esm/erc20/handler.js +9 -2
  161. package/dist/esm/erc20/handler.js.map +1 -1
  162. package/dist/esm/erc20/mixin.d.ts +20 -3
  163. package/dist/esm/erc20/mixin.d.ts.map +1 -1
  164. package/dist/esm/erc20/mixin.js +24 -8
  165. package/dist/esm/erc20/mixin.js.map +1 -1
  166. package/dist/esm/erc721/handler.d.ts +11 -2
  167. package/dist/esm/erc721/handler.d.ts.map +1 -1
  168. package/dist/esm/erc721/handler.js +8 -2
  169. package/dist/esm/erc721/handler.js.map +1 -1
  170. package/dist/esm/erc721/mixin.d.ts +2 -1
  171. package/dist/esm/erc721/mixin.d.ts.map +1 -1
  172. package/dist/esm/erc721/mixin.js.map +1 -1
  173. package/dist/esm/errors/mixin.d.ts +2 -1
  174. package/dist/esm/errors/mixin.d.ts.map +1 -1
  175. package/dist/esm/errors/mixin.js.map +1 -1
  176. package/dist/esm/event-logs/mixin.d.ts +2 -1
  177. package/dist/esm/event-logs/mixin.d.ts.map +1 -1
  178. package/dist/esm/event-logs/mixin.js.map +1 -1
  179. package/dist/esm/exchanges/handler.d.ts +44 -1
  180. package/dist/esm/exchanges/handler.d.ts.map +1 -1
  181. package/dist/esm/exchanges/handler.js +80 -16
  182. package/dist/esm/exchanges/handler.js.map +1 -1
  183. package/dist/esm/exchanges/mixin.d.ts +24 -8
  184. package/dist/esm/exchanges/mixin.d.ts.map +1 -1
  185. package/dist/esm/exchanges/mixin.js +120 -72
  186. package/dist/esm/exchanges/mixin.js.map +1 -1
  187. package/dist/esm/funds/handler.d.ts +27 -1
  188. package/dist/esm/funds/handler.d.ts.map +1 -1
  189. package/dist/esm/funds/handler.js +28 -7
  190. package/dist/esm/funds/handler.js.map +1 -1
  191. package/dist/esm/funds/mixin.d.ts +50 -17
  192. package/dist/esm/funds/mixin.d.ts.map +1 -1
  193. package/dist/esm/funds/mixin.js +62 -42
  194. package/dist/esm/funds/mixin.js.map +1 -1
  195. package/dist/esm/groups/handler.d.ts +8 -1
  196. package/dist/esm/groups/handler.d.ts.map +1 -1
  197. package/dist/esm/groups/handler.js +9 -2
  198. package/dist/esm/groups/handler.js.map +1 -1
  199. package/dist/esm/groups/mixin.d.ts +12 -4
  200. package/dist/esm/groups/mixin.d.ts.map +1 -1
  201. package/dist/esm/groups/mixin.js +16 -8
  202. package/dist/esm/groups/mixin.js.map +1 -1
  203. package/dist/esm/marketplaces/mixin.d.ts +2 -1
  204. package/dist/esm/marketplaces/mixin.d.ts.map +1 -1
  205. package/dist/esm/marketplaces/mixin.js.map +1 -1
  206. package/dist/esm/meta-tx/handler.d.ts.map +1 -1
  207. package/dist/esm/meta-tx/handler.js +4 -2
  208. package/dist/esm/meta-tx/handler.js.map +1 -1
  209. package/dist/esm/meta-tx/mixin.d.ts +2 -2
  210. package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
  211. package/dist/esm/meta-tx/mixin.js.map +1 -1
  212. package/dist/esm/metadata/mixin.d.ts +2 -1
  213. package/dist/esm/metadata/mixin.d.ts.map +1 -1
  214. package/dist/esm/metadata/mixin.js.map +1 -1
  215. package/dist/esm/mixins/base-core-sdk.d.ts +4 -4
  216. package/dist/esm/mixins/base-core-sdk.d.ts.map +1 -1
  217. package/dist/esm/mixins/base-core-sdk.js.map +1 -1
  218. package/dist/esm/native-meta-tx/handler.d.ts.map +1 -1
  219. package/dist/esm/native-meta-tx/handler.js +2 -1
  220. package/dist/esm/native-meta-tx/handler.js.map +1 -1
  221. package/dist/esm/native-meta-tx/mixin.d.ts +2 -2
  222. package/dist/esm/native-meta-tx/mixin.d.ts.map +1 -1
  223. package/dist/esm/native-meta-tx/mixin.js.map +1 -1
  224. package/dist/esm/offers/handler.d.ts +81 -1
  225. package/dist/esm/offers/handler.d.ts.map +1 -1
  226. package/dist/esm/offers/handler.js +83 -18
  227. package/dist/esm/offers/handler.js.map +1 -1
  228. package/dist/esm/offers/mixin.d.ts +54 -2
  229. package/dist/esm/offers/mixin.d.ts.map +1 -1
  230. package/dist/esm/offers/mixin.js +162 -97
  231. package/dist/esm/offers/mixin.js.map +1 -1
  232. package/dist/esm/orchestration/handler.d.ts +86 -1
  233. package/dist/esm/orchestration/handler.d.ts.map +1 -1
  234. package/dist/esm/orchestration/handler.js +64 -16
  235. package/dist/esm/orchestration/handler.js.map +1 -1
  236. package/dist/esm/orchestration/mixin.d.ts +2 -2
  237. package/dist/esm/orchestration/mixin.d.ts.map +1 -1
  238. package/dist/esm/orchestration/mixin.js.map +1 -1
  239. package/dist/esm/price-discovery/handler.d.ts +11 -1
  240. package/dist/esm/price-discovery/handler.d.ts.map +1 -1
  241. package/dist/esm/price-discovery/handler.js +9 -2
  242. package/dist/esm/price-discovery/handler.js.map +1 -1
  243. package/dist/esm/price-discovery/mixin.d.ts +16 -4
  244. package/dist/esm/price-discovery/mixin.d.ts.map +1 -1
  245. package/dist/esm/price-discovery/mixin.js +19 -11
  246. package/dist/esm/price-discovery/mixin.js.map +1 -1
  247. package/dist/esm/protocol-config/handler.d.ts +9 -0
  248. package/dist/esm/protocol-config/handler.d.ts.map +1 -1
  249. package/dist/esm/protocol-config/handler.js +10 -3
  250. package/dist/esm/protocol-config/handler.js.map +1 -1
  251. package/dist/esm/protocol-config/mixin.d.ts +2 -1
  252. package/dist/esm/protocol-config/mixin.d.ts.map +1 -1
  253. package/dist/esm/protocol-config/mixin.js.map +1 -1
  254. package/dist/esm/subgraph/mixin.d.ts +2 -2
  255. package/dist/esm/subgraph/mixin.d.ts.map +1 -1
  256. package/dist/esm/subgraph/mixin.js.map +1 -1
  257. package/dist/esm/voucher/handler.d.ts +56 -1
  258. package/dist/esm/voucher/handler.d.ts.map +1 -1
  259. package/dist/esm/voucher/handler.js +56 -14
  260. package/dist/esm/voucher/handler.js.map +1 -1
  261. package/dist/esm/voucher/mixin.d.ts +66 -22
  262. package/dist/esm/voucher/mixin.d.ts.map +1 -1
  263. package/dist/esm/voucher/mixin.js +93 -55
  264. package/dist/esm/voucher/mixin.js.map +1 -1
  265. package/package.json +3 -3
  266. package/src/accounts/handler.ts +369 -42
  267. package/src/accounts/mixin.ts +644 -57
  268. package/src/core-sdk.ts +26 -26
  269. package/src/disputes/handler.ts +257 -31
  270. package/src/disputes/mixin.ts +273 -42
  271. package/src/erc1155/mixin.ts +2 -1
  272. package/src/erc165/mixin.ts +2 -1
  273. package/src/erc20/handler.ts +36 -4
  274. package/src/erc20/mixin.ts +77 -10
  275. package/src/erc721/handler.ts +34 -4
  276. package/src/erc721/mixin.ts +2 -1
  277. package/src/errors/mixin.ts +2 -2
  278. package/src/event-logs/mixin.ts +2 -1
  279. package/src/exchanges/handler.ts +235 -25
  280. package/src/exchanges/mixin.ts +223 -32
  281. package/src/funds/handler.ts +99 -13
  282. package/src/funds/mixin.ts +177 -39
  283. package/src/groups/handler.ts +28 -3
  284. package/src/groups/mixin.ts +50 -7
  285. package/src/marketplaces/mixin.ts +2 -1
  286. package/src/meta-tx/handler.ts +4 -2
  287. package/src/meta-tx/mixin.ts +3 -2
  288. package/src/metadata/mixin.ts +2 -1
  289. package/src/mixins/base-core-sdk.ts +5 -5
  290. package/src/native-meta-tx/handler.ts +2 -1
  291. package/src/native-meta-tx/mixin.ts +8 -2
  292. package/src/offers/handler.ts +280 -28
  293. package/src/offers/mixin.ts +401 -35
  294. package/src/orchestration/handler.ts +259 -24
  295. package/src/orchestration/mixin.ts +8 -2
  296. package/src/price-discovery/handler.ts +35 -4
  297. package/src/price-discovery/mixin.ts +60 -9
  298. package/src/protocol-config/handler.ts +26 -4
  299. package/src/protocol-config/mixin.ts +4 -1
  300. package/src/subgraph/mixin.ts +6 -2
  301. package/src/voucher/handler.ts +192 -22
  302. package/src/voucher/mixin.ts +244 -66
@@ -1,6 +1,10 @@
1
1
  import { BaseCoreSDK } from "./../mixins/base-core-sdk";
2
2
  import * as subgraph from "../subgraph";
3
- import { TransactionResponse } from "@bosonprotocol/common";
3
+ import {
4
+ TransactionResponse,
5
+ TransactionRequest,
6
+ Web3LibAdapter
7
+ } from "@bosonprotocol/common";
4
8
  import { BigNumberish } from "@ethersproject/bignumber";
5
9
  import { AddressZero } from "@ethersproject/constants";
6
10
  import {
@@ -10,90 +14,224 @@ import {
10
14
  } from "./handler";
11
15
  import { getFundsById, getFunds } from "./subgraph";
12
16
 
13
- export class FundsMixin extends BaseCoreSDK {
17
+ export class FundsMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
14
18
  /* -------------------------------------------------------------------------- */
15
19
  /* Funds related methods */
16
20
  /* -------------------------------------------------------------------------- */
17
21
 
18
22
  /**
19
23
  * Deposit funds by calling the `FundsHandlerFacet` contract.
24
+ * This transaction only succeeds if there is an existing seller account for connected signer.
20
25
  * @param sellerId - ID of seller account to deposit funds for.
21
26
  * @param fundsAmount - Amount of funds.
22
27
  * @param fundsTokenAddress - Address of funds token.
28
+ * @param overrides - Optional overrides.
23
29
  * @returns Transaction response.
24
30
  */
31
+ // Overload: returnTxInfo is true → returns TransactionRequest
32
+ public async depositFunds(
33
+ sellerId: BigNumberish,
34
+ fundsAmount: BigNumberish,
35
+ fundsTokenAddress: string,
36
+ overrides: Partial<{
37
+ contractAddress: string;
38
+ txRequest: TransactionRequest;
39
+ returnTxInfo: true;
40
+ }>
41
+ ): Promise<TransactionRequest>;
42
+
43
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
25
44
  public async depositFunds(
26
45
  sellerId: BigNumberish,
27
46
  fundsAmount: BigNumberish,
28
- fundsTokenAddress: string = AddressZero
29
- ): Promise<TransactionResponse> {
30
- return depositFunds({
47
+ fundsTokenAddress?: string,
48
+ overrides?: Partial<{
49
+ contractAddress: string;
50
+ txRequest: TransactionRequest;
51
+ returnTxInfo?: false | undefined;
52
+ }>
53
+ ): Promise<TransactionResponse>;
54
+
55
+ // Implementation
56
+ public async depositFunds(
57
+ sellerId: BigNumberish,
58
+ fundsAmount: BigNumberish,
59
+ fundsTokenAddress: string = AddressZero,
60
+ overrides: Partial<{
61
+ contractAddress: string;
62
+ txRequest: TransactionRequest;
63
+ returnTxInfo?: boolean;
64
+ }> = {}
65
+ ): Promise<TransactionResponse | TransactionRequest> {
66
+ const { returnTxInfo } = overrides;
67
+
68
+ const depositArgs = {
31
69
  sellerId,
32
70
  fundsAmount,
33
71
  fundsTokenAddress,
34
- contractAddress: this._protocolDiamond,
35
- web3Lib: this._web3Lib
36
- });
37
- }
72
+ web3Lib: this._web3Lib,
73
+ contractAddress: overrides.contractAddress || this._protocolDiamond
74
+ } as const satisfies Parameters<typeof depositFunds>[0];
38
75
 
39
- /**
40
- * Returns funds entity from subgraph.
41
- * @param fundsId - ID of funds entity.
42
- * @param queryVars - Optional query variables to skip, order or filter.
43
- * @returns Funds entity from subgraph.
44
- */
45
- public async getFundsById(
46
- fundsId: BigNumberish,
47
- queryVars?: subgraph.GetFundsByIdQueryVariables
48
- ): Promise<subgraph.FundsEntityFieldsFragment> {
49
- return getFundsById(this._subgraphUrl, fundsId, queryVars);
50
- }
51
-
52
- /**
53
- * Returns funds entities from subgraph.
54
- * @param queryVars - Optional query variables to skip, order or filter.
55
- * @returns Funds entities from subgraph.
56
- */
57
- public async getFunds(
58
- queryVars?: subgraph.GetFundsQueryVariables
59
- ): Promise<subgraph.FundsEntityFieldsFragment[]> {
60
- return getFunds(this._subgraphUrl, queryVars);
76
+ if (returnTxInfo === true) {
77
+ return depositFunds({
78
+ ...depositArgs,
79
+ returnTxInfo: true
80
+ });
81
+ } else {
82
+ return depositFunds({
83
+ ...depositArgs,
84
+ returnTxInfo: false
85
+ });
86
+ }
61
87
  }
62
88
 
63
89
  /**
64
90
  * Withdraw selected funds by calling the `FundsHandlerFacet` contract.
91
+ * This transaction only succeeds if there is an existing account for connected signer.
65
92
  * @param entityId - ID of seller/buyer/agent account to withdraw funds for.
66
93
  * @param tokensToWithdraw - Addresses of funds tokens to withdraw.
67
94
  * @param amountsToWithdraw - Amounts of funds token to withdraw.
95
+ * @param overrides - Optional overrides.
68
96
  * @returns Transaction response.
69
97
  */
98
+ // Overload: returnTxInfo is true → returns TransactionRequest
99
+ public async withdrawFunds(
100
+ entityId: BigNumberish,
101
+ tokensToWithdraw: Array<string>,
102
+ amountsToWithdraw: Array<BigNumberish>,
103
+ overrides: Partial<{
104
+ contractAddress: string;
105
+ txRequest: TransactionRequest;
106
+ returnTxInfo: true;
107
+ }>
108
+ ): Promise<TransactionRequest>;
109
+
110
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
70
111
  public async withdrawFunds(
71
112
  entityId: BigNumberish,
72
113
  tokensToWithdraw: Array<string>,
73
- amountsToWithdraw: Array<BigNumberish>
74
- ): Promise<TransactionResponse> {
75
- return withdrawFunds({
114
+ amountsToWithdraw: Array<BigNumberish>,
115
+ overrides?: Partial<{
116
+ contractAddress: string;
117
+ txRequest: TransactionRequest;
118
+ returnTxInfo?: false | undefined;
119
+ }>
120
+ ): Promise<TransactionResponse>;
121
+
122
+ // Implementation
123
+ public async withdrawFunds(
124
+ entityId: BigNumberish,
125
+ tokensToWithdraw: Array<string>,
126
+ amountsToWithdraw: Array<BigNumberish>,
127
+ overrides: Partial<{
128
+ contractAddress: string;
129
+ txRequest: TransactionRequest;
130
+ returnTxInfo?: boolean;
131
+ }> = {}
132
+ ): Promise<TransactionResponse | TransactionRequest> {
133
+ const { returnTxInfo } = overrides;
134
+
135
+ const withdrawArgs = {
76
136
  entityId,
77
137
  tokensToWithdraw,
78
138
  amountsToWithdraw,
79
139
  contractAddress: this._protocolDiamond,
80
140
  web3Lib: this._web3Lib
81
- });
141
+ } as const satisfies Parameters<typeof withdrawFunds>[0];
142
+
143
+ if (returnTxInfo === true) {
144
+ return withdrawFunds({
145
+ ...withdrawArgs,
146
+ returnTxInfo: true
147
+ });
148
+ } else {
149
+ return withdrawFunds({
150
+ ...withdrawArgs,
151
+ returnTxInfo: false
152
+ });
153
+ }
82
154
  }
83
155
 
84
156
  /**
85
157
  * Withdraw all available funds by calling the `FundsHandlerFacet` contract.
158
+ * This transaction only succeeds if there is an existing account for connected signer.
86
159
  * @param entityId - ID of seller/buyer/agent account to withdraw funds for.
160
+ * @param overrides - Optional overrides.
87
161
  * @returns Transaction response.
88
162
  */
163
+ // Overload: returnTxInfo is true → returns TransactionRequest
164
+ public async withdrawAllAvailableFunds(
165
+ entityId: BigNumberish,
166
+ overrides: Partial<{
167
+ contractAddress: string;
168
+ txRequest: TransactionRequest;
169
+ returnTxInfo: true;
170
+ }>
171
+ ): Promise<TransactionRequest>;
172
+
173
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
174
+ public async withdrawAllAvailableFunds(
175
+ entityId: BigNumberish,
176
+ overrides?: Partial<{
177
+ contractAddress: string;
178
+ txRequest: TransactionRequest;
179
+ returnTxInfo?: false | undefined;
180
+ }>
181
+ ): Promise<TransactionResponse>;
182
+
183
+ // Implementation
89
184
  public async withdrawAllAvailableFunds(
90
- entityId: BigNumberish
91
- ): Promise<TransactionResponse> {
92
- return withdrawAllAvailableFunds({
185
+ entityId: BigNumberish,
186
+ overrides: Partial<{
187
+ contractAddress: string;
188
+ txRequest: TransactionRequest;
189
+ returnTxInfo?: boolean;
190
+ }> = {}
191
+ ): Promise<TransactionResponse | TransactionRequest> {
192
+ const { returnTxInfo } = overrides;
193
+
194
+ const withdrawAllArgs = {
93
195
  entityId,
94
196
  subgraphUrl: this._subgraphUrl,
95
197
  contractAddress: this._protocolDiamond,
96
198
  web3Lib: this._web3Lib
97
- });
199
+ } as const satisfies Parameters<typeof withdrawAllAvailableFunds>[0];
200
+
201
+ if (returnTxInfo === true) {
202
+ return withdrawAllAvailableFunds({
203
+ ...withdrawAllArgs,
204
+ returnTxInfo: true
205
+ });
206
+ } else {
207
+ return withdrawAllAvailableFunds({
208
+ ...withdrawAllArgs,
209
+ returnTxInfo: false
210
+ });
211
+ }
212
+ }
213
+
214
+ /**
215
+ * Returns funds entity from subgraph.
216
+ * @param fundsId - ID of funds entity.
217
+ * @param queryVars - Optional query variables to skip, order or filter.
218
+ * @returns Funds entity from subgraph.
219
+ */
220
+ public async getFundsById(
221
+ fundsId: BigNumberish,
222
+ queryVars?: subgraph.GetFundsByIdQueryVariables
223
+ ): Promise<subgraph.FundsEntityFieldsFragment> {
224
+ return getFundsById(this._subgraphUrl, fundsId, queryVars);
225
+ }
226
+
227
+ /**
228
+ * Returns funds entities from subgraph.
229
+ * @param queryVars - Optional query variables to skip, order or filter.
230
+ * @returns Funds entities from subgraph.
231
+ */
232
+ public async getFunds(
233
+ queryVars?: subgraph.GetFundsQueryVariables
234
+ ): Promise<subgraph.FundsEntityFieldsFragment[]> {
235
+ return getFunds(this._subgraphUrl, queryVars);
98
236
  }
99
237
  }
@@ -1,17 +1,42 @@
1
1
  import {
2
2
  TransactionResponse,
3
+ TransactionRequest,
3
4
  CreateGroupArgs,
4
5
  Web3LibAdapter
5
6
  } from "@bosonprotocol/common";
6
7
  import { encodeCreateGroup } from "./interface";
7
8
 
9
+ // Overload: returnTxInfo is true -> returns TransactionRequest
8
10
  export async function createGroup(args: {
9
11
  groupToCreate: CreateGroupArgs;
10
12
  contractAddress: string;
11
13
  web3Lib: Web3LibAdapter;
12
- }): Promise<TransactionResponse> {
13
- return args.web3Lib.sendTransaction({
14
+ returnTxInfo: true;
15
+ }): Promise<TransactionRequest>;
16
+
17
+ // Overload: returnTxInfo is false or undefined -> returns TransactionResponse
18
+ export async function createGroup(args: {
19
+ groupToCreate: CreateGroupArgs;
20
+ contractAddress: string;
21
+ web3Lib: Web3LibAdapter;
22
+ returnTxInfo?: false | undefined;
23
+ }): Promise<TransactionResponse>;
24
+
25
+ // Implementation
26
+ export async function createGroup(args: {
27
+ groupToCreate: CreateGroupArgs;
28
+ contractAddress: string;
29
+ web3Lib: Web3LibAdapter;
30
+ returnTxInfo?: boolean;
31
+ }): Promise<TransactionRequest | TransactionResponse> {
32
+ const transactionRequest: TransactionRequest = {
14
33
  to: args.contractAddress,
15
34
  data: encodeCreateGroup(args.groupToCreate)
16
- });
35
+ };
36
+
37
+ if (args.returnTxInfo) {
38
+ return transactionRequest;
39
+ } else {
40
+ return args.web3Lib.sendTransaction(transactionRequest);
41
+ }
17
42
  }
@@ -1,24 +1,67 @@
1
- import { CreateGroupArgs, TransactionResponse } from "@bosonprotocol/common";
1
+ import {
2
+ CreateGroupArgs,
3
+ TransactionResponse,
4
+ TransactionRequest,
5
+ Web3LibAdapter
6
+ } from "@bosonprotocol/common";
2
7
  import { handler } from ".";
3
8
  import { BaseCoreSDK } from "./../mixins/base-core-sdk";
4
9
 
5
- export class GroupsMixin extends BaseCoreSDK {
10
+ export class GroupsMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
6
11
  /**
7
- * Creates a group of contract addresses
8
- * @param groupToCreate - group with the contract condition
12
+ * Creates a group of contract addresses by calling the contract.
13
+ * This transaction only succeeds if there is an existing account for connected signer.
14
+ * @param groupToCreate - Group with the contract condition.
9
15
  * @param overrides - Optional overrides.
10
16
  * @returns Transaction response.
11
17
  */
18
+ // Overload: returnTxInfo is true → returns TransactionRequest
12
19
  public async createGroup(
13
20
  groupToCreate: CreateGroupArgs,
14
21
  overrides: Partial<{
15
22
  contractAddress: string;
23
+ txRequest: TransactionRequest;
24
+ returnTxInfo: true;
25
+ }>
26
+ ): Promise<TransactionRequest>;
27
+
28
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
29
+ public async createGroup(
30
+ groupToCreate: CreateGroupArgs,
31
+ overrides?: Partial<{
32
+ contractAddress: string;
33
+ txRequest: TransactionRequest;
34
+ returnTxInfo?: false | undefined;
35
+ }>
36
+ ): Promise<TransactionResponse>;
37
+
38
+ // Implementation
39
+ public async createGroup(
40
+ groupToCreate: CreateGroupArgs,
41
+ overrides: Partial<{
42
+ contractAddress: string;
43
+ txRequest: TransactionRequest;
44
+ returnTxInfo?: boolean;
16
45
  }> = {}
17
- ): Promise<TransactionResponse> {
18
- return handler.createGroup({
46
+ ): Promise<TransactionResponse | TransactionRequest> {
47
+ const { returnTxInfo } = overrides;
48
+
49
+ const groupArgs = {
19
50
  groupToCreate,
20
51
  contractAddress: overrides.contractAddress || this._protocolDiamond,
21
52
  web3Lib: this._web3Lib
22
- });
53
+ } as const satisfies Parameters<typeof handler.createGroup>[0];
54
+
55
+ if (returnTxInfo === true) {
56
+ return handler.createGroup({
57
+ ...groupArgs,
58
+ returnTxInfo: true
59
+ });
60
+ } else {
61
+ return handler.createGroup({
62
+ ...groupArgs,
63
+ returnTxInfo: false
64
+ });
65
+ }
23
66
  }
24
67
  }
@@ -1,3 +1,4 @@
1
+ import { Web3LibAdapter } from "@bosonprotocol/common";
1
2
  import { BaseCoreSDK } from "./../mixins/base-core-sdk";
2
3
  import { OpenSeaMarketplace, OpenSeaSDKHandler } from "./opensea";
3
4
  import { MarketplaceType, MarketplaceHandler } from "./types";
@@ -6,7 +7,7 @@ type MarketplaceTypeToClass = {
6
7
  [MarketplaceType.OPENSEA]: OpenSeaMarketplace;
7
8
  };
8
9
 
9
- export class MarketplaceMixin extends BaseCoreSDK {
10
+ export class MarketplaceMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
10
11
  public marketplace<T extends keyof MarketplaceTypeToClass>(
11
12
  type: T,
12
13
  handler: T extends MarketplaceType.OPENSEA
@@ -379,7 +379,8 @@ export async function relayBiconomyMetaTransaction(args: {
379
379
  transactionHash: txHash,
380
380
  logs: txReceipt?.logs || [],
381
381
  effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice),
382
- blockNumber: txReceipt.blockNumber
382
+ blockNumber: txReceipt.blockNumber,
383
+ gasUsed: txReceipt.gasUsed
383
384
  };
384
385
  },
385
386
  hash: relayTxResponse.txHash
@@ -1281,7 +1282,8 @@ export async function relayMetaTransaction(args: {
1281
1282
  transactionHash: txHash,
1282
1283
  logs: txReceipt?.logs || [],
1283
1284
  effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice),
1284
- blockNumber: txReceipt?.blockNumber
1285
+ blockNumber: txReceipt?.blockNumber,
1286
+ gasUsed: txReceipt.gasUsed
1285
1287
  };
1286
1288
  },
1287
1289
  hash: relayTxResponse.txHash
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  AuthTokenType,
3
3
  MetaTxConfig,
4
- TransactionResponse
4
+ TransactionResponse,
5
+ Web3LibAdapter
5
6
  } from "@bosonprotocol/common";
6
7
  import { BigNumberish } from "@ethersproject/bignumber";
7
8
  import { BytesLike } from "@ethersproject/bytes";
@@ -12,7 +13,7 @@ import { GetRetriedHashesData } from "./biconomy";
12
13
  import { accounts } from "..";
13
14
  import { AccountsMixin } from "../accounts/mixin";
14
15
  import { SellerFieldsFragment } from "../subgraph";
15
- export class MetaTxMixin extends BaseCoreSDK {
16
+ export class MetaTxMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
16
17
  /* -------------------------------------------------------------------------- */
17
18
  /* Meta Tx related methods */
18
19
  /* -------------------------------------------------------------------------- */
@@ -11,8 +11,9 @@ import {
11
11
  getAllProductsWithNotVoidedVariants,
12
12
  getBundleMetadataEntities
13
13
  } from "./subgraph";
14
+ import { Web3LibAdapter } from "@bosonprotocol/common";
14
15
 
15
- export class MetadataMixin extends BaseCoreSDK {
16
+ export class MetadataMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
16
17
  /* -------------------------------------------------------------------------- */
17
18
  /* Metadata related methods */
18
19
  /* -------------------------------------------------------------------------- */
@@ -9,8 +9,8 @@ import {
9
9
  import { TokenInfoManager } from "../utils/tokenInfoManager";
10
10
  import { Biconomy } from "../meta-tx/biconomy";
11
11
 
12
- export class BaseCoreSDK {
13
- protected _web3Lib: Web3LibAdapter;
12
+ export class BaseCoreSDK<T extends Web3LibAdapter = Web3LibAdapter> {
13
+ protected _web3Lib: T;
14
14
  protected _metadataStorage?: MetadataStorage;
15
15
  protected _theGraphStorage?: MetadataStorage;
16
16
 
@@ -35,7 +35,7 @@ export class BaseCoreSDK {
35
35
  * @param args - Constructor args
36
36
  */
37
37
  constructor(opts: {
38
- web3Lib: Web3LibAdapter;
38
+ web3Lib: T;
39
39
  subgraphUrl: string;
40
40
  protocolDiamond: string;
41
41
  metadataStorage?: MetadataStorage;
@@ -118,8 +118,8 @@ export class BaseCoreSDK {
118
118
 
119
119
  // Doc: https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern
120
120
  export function applyMixins(
121
- derivedCtor: typeof BaseCoreSDK,
122
- constructors: (typeof BaseCoreSDK)[]
121
+ derivedCtor: typeof BaseCoreSDK<Web3LibAdapter>,
122
+ constructors: (typeof BaseCoreSDK<Web3LibAdapter>)[]
123
123
  ) {
124
124
  constructors.forEach((baseCtor) => {
125
125
  Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
@@ -184,7 +184,8 @@ export async function relayNativeMetaTransaction(args: {
184
184
  transactionHash: txHash,
185
185
  logs: txReceipt?.logs || [],
186
186
  effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice),
187
- blockNumber: txReceipt.blockNumber
187
+ blockNumber: txReceipt.blockNumber,
188
+ gasUsed: txReceipt.gasUsed
188
189
  };
189
190
  },
190
191
  hash: relayTxResponse.txHash
@@ -1,10 +1,16 @@
1
- import { MetaTxConfig, TransactionResponse } from "@bosonprotocol/common";
1
+ import {
2
+ MetaTxConfig,
3
+ TransactionResponse,
4
+ Web3LibAdapter
5
+ } from "@bosonprotocol/common";
2
6
  import { BigNumberish } from "@ethersproject/bignumber";
3
7
  import { BytesLike } from "@ethersproject/bytes";
4
8
  import { handler } from ".";
5
9
  import { BaseCoreSDK } from "./../mixins/base-core-sdk";
6
10
 
7
- export class NativeMetaTxMixin extends BaseCoreSDK {
11
+ export class NativeMetaTxMixin<
12
+ T extends Web3LibAdapter
13
+ > extends BaseCoreSDK<T> {
8
14
  /**
9
15
  * Encodes and signs a native "token.approve()" meta transaction that can be relayed.
10
16
  * @param exchangeToken - The address of the token contract.