@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.
- package/dist/cjs/accounts/handler.d.ts +115 -1
- package/dist/cjs/accounts/handler.d.ts.map +1 -1
- package/dist/cjs/accounts/handler.js +126 -28
- package/dist/cjs/accounts/handler.js.map +1 -1
- package/dist/cjs/accounts/mixin.d.ts +105 -8
- package/dist/cjs/accounts/mixin.d.ts.map +1 -1
- package/dist/cjs/accounts/mixin.js +162 -122
- package/dist/cjs/accounts/mixin.js.map +1 -1
- package/dist/cjs/core-sdk.d.ts +6 -6
- package/dist/cjs/core-sdk.d.ts.map +1 -1
- package/dist/cjs/core-sdk.js.map +1 -1
- package/dist/cjs/disputes/handler.d.ts +77 -1
- package/dist/cjs/disputes/handler.d.ts.map +1 -1
- package/dist/cjs/disputes/handler.js +90 -20
- package/dist/cjs/disputes/handler.js.map +1 -1
- package/dist/cjs/disputes/mixin.d.ts +29 -11
- package/dist/cjs/disputes/mixin.d.ts.map +1 -1
- package/dist/cjs/disputes/mixin.js +97 -88
- package/dist/cjs/disputes/mixin.js.map +1 -1
- package/dist/cjs/erc1155/mixin.d.ts +2 -1
- package/dist/cjs/erc1155/mixin.d.ts.map +1 -1
- package/dist/cjs/erc1155/mixin.js.map +1 -1
- package/dist/cjs/erc165/mixin.d.ts +2 -1
- package/dist/cjs/erc165/mixin.d.ts.map +1 -1
- package/dist/cjs/erc165/mixin.js.map +1 -1
- package/dist/cjs/erc20/handler.d.ts +11 -2
- package/dist/cjs/erc20/handler.d.ts.map +1 -1
- package/dist/cjs/erc20/handler.js +8 -1
- package/dist/cjs/erc20/handler.js.map +1 -1
- package/dist/cjs/erc20/mixin.d.ts +20 -3
- package/dist/cjs/erc20/mixin.d.ts.map +1 -1
- package/dist/cjs/erc20/mixin.js +15 -10
- package/dist/cjs/erc20/mixin.js.map +1 -1
- package/dist/cjs/erc721/handler.d.ts +11 -2
- package/dist/cjs/erc721/handler.d.ts.map +1 -1
- package/dist/cjs/erc721/handler.js +8 -2
- package/dist/cjs/erc721/handler.js.map +1 -1
- package/dist/cjs/erc721/mixin.d.ts +2 -1
- package/dist/cjs/erc721/mixin.d.ts.map +1 -1
- package/dist/cjs/erc721/mixin.js.map +1 -1
- package/dist/cjs/errors/mixin.d.ts +2 -1
- package/dist/cjs/errors/mixin.d.ts.map +1 -1
- package/dist/cjs/errors/mixin.js.map +1 -1
- package/dist/cjs/event-logs/mixin.d.ts +2 -1
- package/dist/cjs/event-logs/mixin.d.ts.map +1 -1
- package/dist/cjs/event-logs/mixin.js.map +1 -1
- package/dist/cjs/exchanges/handler.d.ts +44 -1
- package/dist/cjs/exchanges/handler.d.ts.map +1 -1
- package/dist/cjs/exchanges/handler.js +76 -17
- package/dist/cjs/exchanges/handler.js.map +1 -1
- package/dist/cjs/exchanges/mixin.d.ts +24 -8
- package/dist/cjs/exchanges/mixin.d.ts.map +1 -1
- package/dist/cjs/exchanges/mixin.js +72 -72
- package/dist/cjs/exchanges/mixin.js.map +1 -1
- package/dist/cjs/funds/handler.d.ts +27 -1
- package/dist/cjs/funds/handler.d.ts.map +1 -1
- package/dist/cjs/funds/handler.js +28 -7
- package/dist/cjs/funds/handler.js.map +1 -1
- package/dist/cjs/funds/mixin.d.ts +50 -17
- package/dist/cjs/funds/mixin.d.ts.map +1 -1
- package/dist/cjs/funds/mixin.js +48 -46
- package/dist/cjs/funds/mixin.js.map +1 -1
- package/dist/cjs/groups/handler.d.ts +8 -1
- package/dist/cjs/groups/handler.d.ts.map +1 -1
- package/dist/cjs/groups/handler.js +9 -2
- package/dist/cjs/groups/handler.js.map +1 -1
- package/dist/cjs/groups/mixin.d.ts +12 -4
- package/dist/cjs/groups/mixin.d.ts.map +1 -1
- package/dist/cjs/groups/mixin.js +10 -8
- package/dist/cjs/groups/mixin.js.map +1 -1
- package/dist/cjs/marketplaces/mixin.d.ts +2 -1
- package/dist/cjs/marketplaces/mixin.d.ts.map +1 -1
- package/dist/cjs/marketplaces/mixin.js.map +1 -1
- package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
- package/dist/cjs/meta-tx/handler.js +4 -2
- package/dist/cjs/meta-tx/handler.js.map +1 -1
- package/dist/cjs/meta-tx/mixin.d.ts +2 -2
- package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
- package/dist/cjs/meta-tx/mixin.js.map +1 -1
- package/dist/cjs/metadata/mixin.d.ts +2 -1
- package/dist/cjs/metadata/mixin.d.ts.map +1 -1
- package/dist/cjs/metadata/mixin.js.map +1 -1
- package/dist/cjs/mixins/base-core-sdk.d.ts +4 -4
- package/dist/cjs/mixins/base-core-sdk.d.ts.map +1 -1
- package/dist/cjs/mixins/base-core-sdk.js.map +1 -1
- package/dist/cjs/native-meta-tx/handler.d.ts.map +1 -1
- package/dist/cjs/native-meta-tx/handler.js +2 -1
- package/dist/cjs/native-meta-tx/handler.js.map +1 -1
- package/dist/cjs/native-meta-tx/mixin.d.ts +2 -2
- package/dist/cjs/native-meta-tx/mixin.d.ts.map +1 -1
- package/dist/cjs/native-meta-tx/mixin.js.map +1 -1
- package/dist/cjs/offers/handler.d.ts +81 -1
- package/dist/cjs/offers/handler.d.ts.map +1 -1
- package/dist/cjs/offers/handler.js +81 -20
- package/dist/cjs/offers/handler.js.map +1 -1
- package/dist/cjs/offers/mixin.d.ts +54 -2
- package/dist/cjs/offers/mixin.d.ts.map +1 -1
- package/dist/cjs/offers/mixin.js +102 -97
- package/dist/cjs/offers/mixin.js.map +1 -1
- package/dist/cjs/orchestration/handler.d.ts +86 -1
- package/dist/cjs/orchestration/handler.d.ts.map +1 -1
- package/dist/cjs/orchestration/handler.js +64 -16
- package/dist/cjs/orchestration/handler.js.map +1 -1
- package/dist/cjs/orchestration/mixin.d.ts +2 -2
- package/dist/cjs/orchestration/mixin.d.ts.map +1 -1
- package/dist/cjs/orchestration/mixin.js.map +1 -1
- package/dist/cjs/price-discovery/handler.d.ts +11 -1
- package/dist/cjs/price-discovery/handler.d.ts.map +1 -1
- package/dist/cjs/price-discovery/handler.js +9 -2
- package/dist/cjs/price-discovery/handler.js.map +1 -1
- package/dist/cjs/price-discovery/mixin.d.ts +16 -4
- package/dist/cjs/price-discovery/mixin.d.ts.map +1 -1
- package/dist/cjs/price-discovery/mixin.js +14 -12
- package/dist/cjs/price-discovery/mixin.js.map +1 -1
- package/dist/cjs/protocol-config/handler.d.ts +9 -0
- package/dist/cjs/protocol-config/handler.d.ts.map +1 -1
- package/dist/cjs/protocol-config/handler.js +10 -3
- package/dist/cjs/protocol-config/handler.js.map +1 -1
- package/dist/cjs/protocol-config/mixin.d.ts +2 -1
- package/dist/cjs/protocol-config/mixin.d.ts.map +1 -1
- package/dist/cjs/protocol-config/mixin.js.map +1 -1
- package/dist/cjs/subgraph/mixin.d.ts +2 -2
- package/dist/cjs/subgraph/mixin.d.ts.map +1 -1
- package/dist/cjs/subgraph/mixin.js.map +1 -1
- package/dist/cjs/voucher/handler.d.ts +56 -1
- package/dist/cjs/voucher/handler.d.ts.map +1 -1
- package/dist/cjs/voucher/handler.js +56 -14
- package/dist/cjs/voucher/handler.js.map +1 -1
- package/dist/cjs/voucher/mixin.d.ts +66 -22
- package/dist/cjs/voucher/mixin.d.ts.map +1 -1
- package/dist/cjs/voucher/mixin.js +75 -61
- package/dist/cjs/voucher/mixin.js.map +1 -1
- package/dist/esm/accounts/handler.d.ts +115 -1
- package/dist/esm/accounts/handler.d.ts.map +1 -1
- package/dist/esm/accounts/handler.js +126 -28
- package/dist/esm/accounts/handler.js.map +1 -1
- package/dist/esm/accounts/mixin.d.ts +105 -8
- package/dist/esm/accounts/mixin.d.ts.map +1 -1
- package/dist/esm/accounts/mixin.js +249 -116
- package/dist/esm/accounts/mixin.js.map +1 -1
- package/dist/esm/core-sdk.d.ts +6 -6
- package/dist/esm/core-sdk.d.ts.map +1 -1
- package/dist/esm/core-sdk.js.map +1 -1
- package/dist/esm/disputes/handler.d.ts +77 -1
- package/dist/esm/disputes/handler.d.ts.map +1 -1
- package/dist/esm/disputes/handler.js +90 -20
- package/dist/esm/disputes/handler.js.map +1 -1
- package/dist/esm/disputes/mixin.d.ts +29 -11
- package/dist/esm/disputes/mixin.d.ts.map +1 -1
- package/dist/esm/disputes/mixin.js +155 -90
- package/dist/esm/disputes/mixin.js.map +1 -1
- package/dist/esm/erc1155/mixin.d.ts +2 -1
- package/dist/esm/erc1155/mixin.d.ts.map +1 -1
- package/dist/esm/erc1155/mixin.js.map +1 -1
- package/dist/esm/erc165/mixin.d.ts +2 -1
- package/dist/esm/erc165/mixin.d.ts.map +1 -1
- package/dist/esm/erc165/mixin.js.map +1 -1
- package/dist/esm/erc20/handler.d.ts +11 -2
- package/dist/esm/erc20/handler.d.ts.map +1 -1
- package/dist/esm/erc20/handler.js +9 -2
- package/dist/esm/erc20/handler.js.map +1 -1
- package/dist/esm/erc20/mixin.d.ts +20 -3
- package/dist/esm/erc20/mixin.d.ts.map +1 -1
- package/dist/esm/erc20/mixin.js +24 -8
- package/dist/esm/erc20/mixin.js.map +1 -1
- package/dist/esm/erc721/handler.d.ts +11 -2
- package/dist/esm/erc721/handler.d.ts.map +1 -1
- package/dist/esm/erc721/handler.js +8 -2
- package/dist/esm/erc721/handler.js.map +1 -1
- package/dist/esm/erc721/mixin.d.ts +2 -1
- package/dist/esm/erc721/mixin.d.ts.map +1 -1
- package/dist/esm/erc721/mixin.js.map +1 -1
- package/dist/esm/errors/mixin.d.ts +2 -1
- package/dist/esm/errors/mixin.d.ts.map +1 -1
- package/dist/esm/errors/mixin.js.map +1 -1
- package/dist/esm/event-logs/mixin.d.ts +2 -1
- package/dist/esm/event-logs/mixin.d.ts.map +1 -1
- package/dist/esm/event-logs/mixin.js.map +1 -1
- package/dist/esm/exchanges/handler.d.ts +44 -1
- package/dist/esm/exchanges/handler.d.ts.map +1 -1
- package/dist/esm/exchanges/handler.js +80 -16
- package/dist/esm/exchanges/handler.js.map +1 -1
- package/dist/esm/exchanges/mixin.d.ts +24 -8
- package/dist/esm/exchanges/mixin.d.ts.map +1 -1
- package/dist/esm/exchanges/mixin.js +120 -72
- package/dist/esm/exchanges/mixin.js.map +1 -1
- package/dist/esm/funds/handler.d.ts +27 -1
- package/dist/esm/funds/handler.d.ts.map +1 -1
- package/dist/esm/funds/handler.js +28 -7
- package/dist/esm/funds/handler.js.map +1 -1
- package/dist/esm/funds/mixin.d.ts +50 -17
- package/dist/esm/funds/mixin.d.ts.map +1 -1
- package/dist/esm/funds/mixin.js +62 -42
- package/dist/esm/funds/mixin.js.map +1 -1
- package/dist/esm/groups/handler.d.ts +8 -1
- package/dist/esm/groups/handler.d.ts.map +1 -1
- package/dist/esm/groups/handler.js +9 -2
- package/dist/esm/groups/handler.js.map +1 -1
- package/dist/esm/groups/mixin.d.ts +12 -4
- package/dist/esm/groups/mixin.d.ts.map +1 -1
- package/dist/esm/groups/mixin.js +16 -8
- package/dist/esm/groups/mixin.js.map +1 -1
- package/dist/esm/marketplaces/mixin.d.ts +2 -1
- package/dist/esm/marketplaces/mixin.d.ts.map +1 -1
- package/dist/esm/marketplaces/mixin.js.map +1 -1
- package/dist/esm/meta-tx/handler.d.ts.map +1 -1
- package/dist/esm/meta-tx/handler.js +4 -2
- package/dist/esm/meta-tx/handler.js.map +1 -1
- package/dist/esm/meta-tx/mixin.d.ts +2 -2
- package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
- package/dist/esm/meta-tx/mixin.js.map +1 -1
- package/dist/esm/metadata/mixin.d.ts +2 -1
- package/dist/esm/metadata/mixin.d.ts.map +1 -1
- package/dist/esm/metadata/mixin.js.map +1 -1
- package/dist/esm/mixins/base-core-sdk.d.ts +4 -4
- package/dist/esm/mixins/base-core-sdk.d.ts.map +1 -1
- package/dist/esm/mixins/base-core-sdk.js.map +1 -1
- package/dist/esm/native-meta-tx/handler.d.ts.map +1 -1
- package/dist/esm/native-meta-tx/handler.js +2 -1
- package/dist/esm/native-meta-tx/handler.js.map +1 -1
- package/dist/esm/native-meta-tx/mixin.d.ts +2 -2
- package/dist/esm/native-meta-tx/mixin.d.ts.map +1 -1
- package/dist/esm/native-meta-tx/mixin.js.map +1 -1
- package/dist/esm/offers/handler.d.ts +81 -1
- package/dist/esm/offers/handler.d.ts.map +1 -1
- package/dist/esm/offers/handler.js +83 -18
- package/dist/esm/offers/handler.js.map +1 -1
- package/dist/esm/offers/mixin.d.ts +54 -2
- package/dist/esm/offers/mixin.d.ts.map +1 -1
- package/dist/esm/offers/mixin.js +162 -97
- package/dist/esm/offers/mixin.js.map +1 -1
- package/dist/esm/orchestration/handler.d.ts +86 -1
- package/dist/esm/orchestration/handler.d.ts.map +1 -1
- package/dist/esm/orchestration/handler.js +64 -16
- package/dist/esm/orchestration/handler.js.map +1 -1
- package/dist/esm/orchestration/mixin.d.ts +2 -2
- package/dist/esm/orchestration/mixin.d.ts.map +1 -1
- package/dist/esm/orchestration/mixin.js.map +1 -1
- package/dist/esm/price-discovery/handler.d.ts +11 -1
- package/dist/esm/price-discovery/handler.d.ts.map +1 -1
- package/dist/esm/price-discovery/handler.js +9 -2
- package/dist/esm/price-discovery/handler.js.map +1 -1
- package/dist/esm/price-discovery/mixin.d.ts +16 -4
- package/dist/esm/price-discovery/mixin.d.ts.map +1 -1
- package/dist/esm/price-discovery/mixin.js +19 -11
- package/dist/esm/price-discovery/mixin.js.map +1 -1
- package/dist/esm/protocol-config/handler.d.ts +9 -0
- package/dist/esm/protocol-config/handler.d.ts.map +1 -1
- package/dist/esm/protocol-config/handler.js +10 -3
- package/dist/esm/protocol-config/handler.js.map +1 -1
- package/dist/esm/protocol-config/mixin.d.ts +2 -1
- package/dist/esm/protocol-config/mixin.d.ts.map +1 -1
- package/dist/esm/protocol-config/mixin.js.map +1 -1
- package/dist/esm/subgraph/mixin.d.ts +2 -2
- package/dist/esm/subgraph/mixin.d.ts.map +1 -1
- package/dist/esm/subgraph/mixin.js.map +1 -1
- package/dist/esm/voucher/handler.d.ts +56 -1
- package/dist/esm/voucher/handler.d.ts.map +1 -1
- package/dist/esm/voucher/handler.js +56 -14
- package/dist/esm/voucher/handler.js.map +1 -1
- package/dist/esm/voucher/mixin.d.ts +66 -22
- package/dist/esm/voucher/mixin.d.ts.map +1 -1
- package/dist/esm/voucher/mixin.js +93 -55
- package/dist/esm/voucher/mixin.js.map +1 -1
- package/package.json +3 -3
- package/src/accounts/handler.ts +369 -42
- package/src/accounts/mixin.ts +644 -57
- package/src/core-sdk.ts +26 -26
- package/src/disputes/handler.ts +257 -31
- package/src/disputes/mixin.ts +273 -42
- package/src/erc1155/mixin.ts +2 -1
- package/src/erc165/mixin.ts +2 -1
- package/src/erc20/handler.ts +36 -4
- package/src/erc20/mixin.ts +77 -10
- package/src/erc721/handler.ts +34 -4
- package/src/erc721/mixin.ts +2 -1
- package/src/errors/mixin.ts +2 -2
- package/src/event-logs/mixin.ts +2 -1
- package/src/exchanges/handler.ts +235 -25
- package/src/exchanges/mixin.ts +223 -32
- package/src/funds/handler.ts +99 -13
- package/src/funds/mixin.ts +177 -39
- package/src/groups/handler.ts +28 -3
- package/src/groups/mixin.ts +50 -7
- package/src/marketplaces/mixin.ts +2 -1
- package/src/meta-tx/handler.ts +4 -2
- package/src/meta-tx/mixin.ts +3 -2
- package/src/metadata/mixin.ts +2 -1
- package/src/mixins/base-core-sdk.ts +5 -5
- package/src/native-meta-tx/handler.ts +2 -1
- package/src/native-meta-tx/mixin.ts +8 -2
- package/src/offers/handler.ts +280 -28
- package/src/offers/mixin.ts +401 -35
- package/src/orchestration/handler.ts +259 -24
- package/src/orchestration/mixin.ts +8 -2
- package/src/price-discovery/handler.ts +35 -4
- package/src/price-discovery/mixin.ts +60 -9
- package/src/protocol-config/handler.ts +26 -4
- package/src/protocol-config/mixin.ts +4 -1
- package/src/subgraph/mixin.ts +6 -2
- package/src/voucher/handler.ts +192 -22
- package/src/voucher/mixin.ts +244 -66
package/src/funds/mixin.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BaseCoreSDK } from "./../mixins/base-core-sdk";
|
|
2
2
|
import * as subgraph from "../subgraph";
|
|
3
|
-
import {
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
72
|
+
web3Lib: this._web3Lib,
|
|
73
|
+
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
74
|
+
} as const satisfies Parameters<typeof depositFunds>[0];
|
|
38
75
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
}
|
package/src/groups/handler.ts
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
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
|
}
|
package/src/groups/mixin.ts
CHANGED
|
@@ -1,24 +1,67 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
package/src/meta-tx/handler.ts
CHANGED
|
@@ -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
|
package/src/meta-tx/mixin.ts
CHANGED
|
@@ -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
|
/* -------------------------------------------------------------------------- */
|
package/src/metadata/mixin.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
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 {
|
|
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
|
|
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.
|