@bosonprotocol/core-sdk 1.24.0 → 1.24.1-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 +0 -5
- package/dist/cjs/accounts/handler.d.ts.map +1 -1
- package/dist/cjs/accounts/handler.js +1 -10
- package/dist/cjs/accounts/handler.js.map +1 -1
- package/dist/cjs/accounts/interface.d.ts +0 -1
- package/dist/cjs/accounts/interface.d.ts.map +1 -1
- package/dist/cjs/accounts/interface.js +1 -5
- package/dist/cjs/accounts/interface.js.map +1 -1
- package/dist/cjs/accounts/mixin.d.ts +0 -7
- package/dist/cjs/accounts/mixin.d.ts.map +1 -1
- package/dist/cjs/accounts/mixin.js +0 -15
- package/dist/cjs/accounts/mixin.js.map +1 -1
- package/dist/cjs/core-sdk.d.ts +2 -1
- package/dist/cjs/core-sdk.d.ts.map +1 -1
- package/dist/cjs/core-sdk.js +3 -1
- package/dist/cjs/core-sdk.js.map +1 -1
- package/dist/cjs/erc721/handler.d.ts.map +1 -1
- package/dist/cjs/erc721/handler.js +2 -1
- package/dist/cjs/erc721/handler.js.map +1 -1
- package/dist/cjs/meta-tx/handler.d.ts +30 -0
- package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
- package/dist/cjs/meta-tx/handler.js +49 -1
- package/dist/cjs/meta-tx/handler.js.map +1 -1
- package/dist/cjs/meta-tx/mixin.d.ts +8 -0
- package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
- package/dist/cjs/meta-tx/mixin.js +12 -0
- package/dist/cjs/meta-tx/mixin.js.map +1 -1
- package/dist/cjs/offers/handler.d.ts +7 -0
- package/dist/cjs/offers/handler.d.ts.map +1 -1
- package/dist/cjs/offers/handler.js +22 -1
- package/dist/cjs/offers/handler.js.map +1 -1
- package/dist/cjs/offers/interface.d.ts +1 -0
- package/dist/cjs/offers/interface.d.ts.map +1 -1
- package/dist/cjs/offers/interface.js +8 -1
- package/dist/cjs/offers/interface.js.map +1 -1
- package/dist/cjs/offers/mixin.d.ts +9 -0
- package/dist/cjs/offers/mixin.d.ts.map +1 -1
- package/dist/cjs/offers/mixin.js +17 -0
- package/dist/cjs/offers/mixin.js.map +1 -1
- package/dist/cjs/orchestration/handler.d.ts +45 -0
- package/dist/cjs/orchestration/handler.d.ts.map +1 -1
- package/dist/cjs/orchestration/handler.js +78 -1
- package/dist/cjs/orchestration/handler.js.map +1 -1
- package/dist/cjs/orchestration/interface.d.ts +6 -0
- package/dist/cjs/orchestration/interface.d.ts.map +1 -1
- package/dist/cjs/orchestration/interface.js +64 -1
- package/dist/cjs/orchestration/interface.js.map +1 -1
- package/dist/cjs/orchestration/mixin.d.ts +57 -0
- package/dist/cjs/orchestration/mixin.d.ts.map +1 -1
- package/dist/cjs/orchestration/mixin.js +105 -0
- package/dist/cjs/orchestration/mixin.js.map +1 -1
- package/dist/cjs/utils/signature.d.ts.map +1 -1
- package/dist/cjs/utils/signature.js +5 -0
- package/dist/cjs/utils/signature.js.map +1 -1
- package/dist/cjs/voucher/handler.d.ts +32 -0
- package/dist/cjs/voucher/handler.d.ts.map +1 -0
- package/dist/cjs/voucher/handler.js +68 -0
- package/dist/cjs/voucher/handler.js.map +1 -0
- package/dist/cjs/voucher/index.d.ts +3 -0
- package/dist/cjs/voucher/index.d.ts.map +1 -0
- package/dist/cjs/voucher/index.js +29 -0
- package/dist/cjs/voucher/index.js.map +1 -0
- package/dist/cjs/voucher/interface.d.ts +11 -0
- package/dist/cjs/voucher/interface.d.ts.map +1 -0
- package/dist/cjs/voucher/interface.js +43 -0
- package/dist/cjs/voucher/interface.js.map +1 -0
- package/dist/cjs/voucher/mixin.d.ts +53 -0
- package/dist/cjs/voucher/mixin.d.ts.map +1 -0
- package/dist/cjs/voucher/mixin.js +107 -0
- package/dist/cjs/voucher/mixin.js.map +1 -0
- package/dist/esm/accounts/handler.d.ts +0 -5
- package/dist/esm/accounts/handler.d.ts.map +1 -1
- package/dist/esm/accounts/handler.js +1 -7
- package/dist/esm/accounts/handler.js.map +1 -1
- package/dist/esm/accounts/interface.d.ts +0 -1
- package/dist/esm/accounts/interface.d.ts.map +1 -1
- package/dist/esm/accounts/interface.js +0 -3
- package/dist/esm/accounts/interface.js.map +1 -1
- package/dist/esm/accounts/mixin.d.ts +0 -7
- package/dist/esm/accounts/mixin.d.ts.map +1 -1
- package/dist/esm/accounts/mixin.js +0 -13
- package/dist/esm/accounts/mixin.js.map +1 -1
- package/dist/esm/core-sdk.d.ts +2 -1
- package/dist/esm/core-sdk.d.ts.map +1 -1
- package/dist/esm/core-sdk.js +3 -1
- package/dist/esm/core-sdk.js.map +1 -1
- package/dist/esm/erc721/handler.d.ts.map +1 -1
- package/dist/esm/erc721/handler.js +2 -1
- package/dist/esm/erc721/handler.js.map +1 -1
- package/dist/esm/meta-tx/handler.d.ts +30 -0
- package/dist/esm/meta-tx/handler.d.ts.map +1 -1
- package/dist/esm/meta-tx/handler.js +58 -1
- package/dist/esm/meta-tx/handler.js.map +1 -1
- package/dist/esm/meta-tx/mixin.d.ts +8 -0
- package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
- package/dist/esm/meta-tx/mixin.js +18 -0
- package/dist/esm/meta-tx/mixin.js.map +1 -1
- package/dist/esm/offers/handler.d.ts +7 -0
- package/dist/esm/offers/handler.d.ts.map +1 -1
- package/dist/esm/offers/handler.js +19 -1
- package/dist/esm/offers/handler.js.map +1 -1
- package/dist/esm/offers/interface.d.ts +1 -0
- package/dist/esm/offers/interface.d.ts.map +1 -1
- package/dist/esm/offers/interface.js +6 -0
- package/dist/esm/offers/interface.js.map +1 -1
- package/dist/esm/offers/mixin.d.ts +9 -0
- package/dist/esm/offers/mixin.d.ts.map +1 -1
- package/dist/esm/offers/mixin.js +15 -0
- package/dist/esm/offers/mixin.js.map +1 -1
- package/dist/esm/orchestration/handler.d.ts +45 -0
- package/dist/esm/orchestration/handler.d.ts.map +1 -1
- package/dist/esm/orchestration/handler.js +63 -1
- package/dist/esm/orchestration/handler.js.map +1 -1
- package/dist/esm/orchestration/interface.d.ts +6 -0
- package/dist/esm/orchestration/interface.d.ts.map +1 -1
- package/dist/esm/orchestration/interface.js +58 -0
- package/dist/esm/orchestration/interface.js.map +1 -1
- package/dist/esm/orchestration/mixin.d.ts +57 -0
- package/dist/esm/orchestration/mixin.d.ts.map +1 -1
- package/dist/esm/orchestration/mixin.js +95 -0
- package/dist/esm/orchestration/mixin.js.map +1 -1
- package/dist/esm/utils/signature.d.ts.map +1 -1
- package/dist/esm/utils/signature.js +5 -0
- package/dist/esm/utils/signature.js.map +1 -1
- package/dist/esm/voucher/handler.d.ts +32 -0
- package/dist/esm/voucher/handler.d.ts.map +1 -0
- package/dist/esm/voucher/handler.js +41 -0
- package/dist/esm/voucher/handler.js.map +1 -0
- package/dist/esm/voucher/index.d.ts +3 -0
- package/dist/esm/voucher/index.d.ts.map +1 -0
- package/dist/esm/voucher/index.js +3 -0
- package/dist/esm/voucher/index.js.map +1 -0
- package/dist/esm/voucher/interface.d.ts +11 -0
- package/dist/esm/voucher/interface.d.ts.map +1 -0
- package/dist/esm/voucher/interface.js +33 -0
- package/dist/esm/voucher/interface.js.map +1 -0
- package/dist/esm/voucher/mixin.d.ts +53 -0
- package/dist/esm/voucher/mixin.d.ts.map +1 -0
- package/dist/esm/voucher/mixin.js +84 -0
- package/dist/esm/voucher/mixin.js.map +1 -0
- package/package.json +3 -3
- package/src/accounts/handler.ts +0 -12
- package/src/accounts/interface.ts +0 -7
- package/src/accounts/mixin.ts +0 -16
- package/src/core-sdk.ts +5 -2
- package/src/erc721/handler.ts +3 -1
- package/src/meta-tx/handler.ts +95 -1
- package/src/meta-tx/mixin.ts +33 -0
- package/src/offers/handler.ts +42 -1
- package/src/offers/interface.ts +10 -0
- package/src/offers/mixin.ts +22 -0
- package/src/orchestration/handler.ts +138 -1
- package/src/orchestration/interface.ts +97 -0
- package/src/orchestration/mixin.ts +135 -0
- package/src/utils/signature.ts +5 -0
- package/src/voucher/handler.ts +79 -0
- package/src/voucher/index.ts +2 -0
- package/src/voucher/interface.ts +45 -0
- package/src/voucher/mixin.ts +126 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TransactionResponse, Web3LibAdapter } from "@bosonprotocol/common";
|
|
2
|
+
import { Range } from "@bosonprotocol/common/src/types";
|
|
3
|
+
import { BigNumberish } from "@ethersproject/bignumber";
|
|
4
|
+
export declare function burnPremintedVouchers(args: {
|
|
5
|
+
offerId: BigNumberish;
|
|
6
|
+
contractAddress: string;
|
|
7
|
+
web3Lib: Web3LibAdapter;
|
|
8
|
+
}): Promise<TransactionResponse>;
|
|
9
|
+
export declare function getAvailablePreMints(args: {
|
|
10
|
+
offerId: BigNumberish;
|
|
11
|
+
contractAddress: string;
|
|
12
|
+
web3Lib: Web3LibAdapter;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
export declare function getRangeByOfferId(args: {
|
|
15
|
+
offerId: BigNumberish;
|
|
16
|
+
contractAddress: string;
|
|
17
|
+
web3Lib: Web3LibAdapter;
|
|
18
|
+
}): Promise<Range>;
|
|
19
|
+
export declare function preMint(args: {
|
|
20
|
+
offerId: BigNumberish;
|
|
21
|
+
amount: BigNumberish;
|
|
22
|
+
contractAddress: string;
|
|
23
|
+
web3Lib: Web3LibAdapter;
|
|
24
|
+
}): Promise<TransactionResponse>;
|
|
25
|
+
export declare function transferFrom(args: {
|
|
26
|
+
from: BigNumberish;
|
|
27
|
+
to: BigNumberish;
|
|
28
|
+
tokenId: BigNumberish;
|
|
29
|
+
contractAddress: string;
|
|
30
|
+
web3Lib: Web3LibAdapter;
|
|
31
|
+
}): Promise<TransactionResponse>;
|
|
32
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/voucher/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAWxD,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAK/B;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,CAOlB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,KAAK,CAAC,CAYjB;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE;IAClC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAK/B;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,YAAY,CAAC;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAK/B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { decodeGetAvailablePreMints, decodeGetRangeByOfferId, encodeBurnPremintedVouchers, encodeGetAvailablePreMints, encodeGetRangeByOfferId, encodePreMint, encodeTransferFrom } from "./interface";
|
|
2
|
+
export async function burnPremintedVouchers(args) {
|
|
3
|
+
return args.web3Lib.sendTransaction({
|
|
4
|
+
to: args.contractAddress,
|
|
5
|
+
data: encodeBurnPremintedVouchers(args.offerId)
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
export async function getAvailablePreMints(args) {
|
|
9
|
+
const result = await args.web3Lib.call({
|
|
10
|
+
to: args.contractAddress,
|
|
11
|
+
data: encodeGetAvailablePreMints(args.offerId)
|
|
12
|
+
});
|
|
13
|
+
const [count] = decodeGetAvailablePreMints(result);
|
|
14
|
+
return String(count);
|
|
15
|
+
}
|
|
16
|
+
export async function getRangeByOfferId(args) {
|
|
17
|
+
const result = await args.web3Lib.call({
|
|
18
|
+
to: args.contractAddress,
|
|
19
|
+
data: encodeGetRangeByOfferId(args.offerId)
|
|
20
|
+
});
|
|
21
|
+
const [range] = decodeGetRangeByOfferId(result);
|
|
22
|
+
return {
|
|
23
|
+
start: range.start,
|
|
24
|
+
length: range._length,
|
|
25
|
+
minted: range.minted,
|
|
26
|
+
lastBurnedTokenId: range.lastBurnedTokenId
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export async function preMint(args) {
|
|
30
|
+
return args.web3Lib.sendTransaction({
|
|
31
|
+
to: args.contractAddress,
|
|
32
|
+
data: encodePreMint(args.offerId, args.amount)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export async function transferFrom(args) {
|
|
36
|
+
return args.web3Lib.sendTransaction({
|
|
37
|
+
to: args.contractAddress,
|
|
38
|
+
data: encodeTransferFrom(args.from, args.to, args.tokenId)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/voucher/handler.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,aAAa,EACb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAI3C;IACC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC;KAChD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAI1C;IACC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACrC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;KAC/C,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAIvC;IACC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACrC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC;KAC5C,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAK7B;IACC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAMlC;IACC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/voucher/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/voucher/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Interface } from "@ethersproject/abi";
|
|
2
|
+
import { BigNumberish } from "@ethersproject/bignumber";
|
|
3
|
+
export declare const bosonVoucherIface: Interface;
|
|
4
|
+
export declare function encodeBurnPremintedVouchers(offerId: BigNumberish): string;
|
|
5
|
+
export declare function encodeGetAvailablePreMints(offerId: BigNumberish): string;
|
|
6
|
+
export declare function decodeGetAvailablePreMints(result: string): import("@ethersproject/abi").Result;
|
|
7
|
+
export declare function encodeGetRangeByOfferId(offerId: BigNumberish): string;
|
|
8
|
+
export declare function decodeGetRangeByOfferId(result: string): import("@ethersproject/abi").Result;
|
|
9
|
+
export declare function encodePreMint(offerId: BigNumberish, amount: BigNumberish): string;
|
|
10
|
+
export declare function encodeTransferFrom(from: BigNumberish, to: BigNumberish, tokenId: BigNumberish): string;
|
|
11
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/voucher/interface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,eAAO,MAAM,iBAAiB,WAAuC,CAAC;AAEtE,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,YAAY,UAIhE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,YAAY,UAI/D;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,uCAExD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,UAE5D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,uCAErD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,UAExE;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,YAAY,EAClB,EAAE,EAAE,YAAY,EAChB,OAAO,EAAE,YAAY,UAOtB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { abis } from "@bosonprotocol/common";
|
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
|
3
|
+
export const bosonVoucherIface = new Interface(abis.IBosonVoucherABI);
|
|
4
|
+
export function encodeBurnPremintedVouchers(offerId) {
|
|
5
|
+
return bosonVoucherIface.encodeFunctionData("burnPremintedVouchers", [
|
|
6
|
+
offerId
|
|
7
|
+
]);
|
|
8
|
+
}
|
|
9
|
+
export function encodeGetAvailablePreMints(offerId) {
|
|
10
|
+
return bosonVoucherIface.encodeFunctionData("getAvailablePreMints", [
|
|
11
|
+
offerId
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
export function decodeGetAvailablePreMints(result) {
|
|
15
|
+
return bosonVoucherIface.decodeFunctionResult("getAvailablePreMints", result);
|
|
16
|
+
}
|
|
17
|
+
export function encodeGetRangeByOfferId(offerId) {
|
|
18
|
+
return bosonVoucherIface.encodeFunctionData("getRangeByOfferId", [offerId]);
|
|
19
|
+
}
|
|
20
|
+
export function decodeGetRangeByOfferId(result) {
|
|
21
|
+
return bosonVoucherIface.decodeFunctionResult("getRangeByOfferId", result);
|
|
22
|
+
}
|
|
23
|
+
export function encodePreMint(offerId, amount) {
|
|
24
|
+
return bosonVoucherIface.encodeFunctionData("preMint", [offerId, amount]);
|
|
25
|
+
}
|
|
26
|
+
export function encodeTransferFrom(from, to, tokenId) {
|
|
27
|
+
return bosonVoucherIface.encodeFunctionData("transferFrom", [
|
|
28
|
+
from,
|
|
29
|
+
to,
|
|
30
|
+
tokenId
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/voucher/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAEtE,MAAM,UAAU,2BAA2B,CAAC,OAAqB;IAC/D,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,uBAAuB,EAAE;QACnE,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAqB;IAC9D,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,sBAAsB,EAAE;QAClE,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,MAAc;IACvD,OAAO,iBAAiB,CAAC,oBAAoB,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAqB;IAC3D,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,MAAc;IACpD,OAAO,iBAAiB,CAAC,oBAAoB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAqB,EAAE,MAAoB;IACvE,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,IAAkB,EAClB,EAAgB,EAChB,OAAqB;IAErB,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,cAAc,EAAE;QAC1D,IAAI;QACJ,EAAE;QACF,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TransactionResponse } from "@bosonprotocol/common";
|
|
2
|
+
import { Range } from "@bosonprotocol/common/src/types";
|
|
3
|
+
import { BigNumberish } from "@ethersproject/bignumber";
|
|
4
|
+
import { BaseCoreSDK } from "./../mixins/base-core-sdk";
|
|
5
|
+
export declare class VoucherMixin extends BaseCoreSDK {
|
|
6
|
+
/**
|
|
7
|
+
* Burns preminted vouchers from an offer
|
|
8
|
+
* @param offerId - Offer ID
|
|
9
|
+
* @param overrides - Optional overrides.
|
|
10
|
+
* @returns Transaction response.
|
|
11
|
+
*/
|
|
12
|
+
burnPremintedVouchers(offerId: BigNumberish, overrides?: Partial<{
|
|
13
|
+
contractAddress: string;
|
|
14
|
+
}>): Promise<TransactionResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Gets the number of vouchers available to be pre-minted for an offer.
|
|
17
|
+
* @param offerId - Offer ID
|
|
18
|
+
* @param overrides - Optional overrides.
|
|
19
|
+
* @returns Transaction response.
|
|
20
|
+
*/
|
|
21
|
+
getAvailablePreMints(offerId: BigNumberish, overrides?: Partial<{
|
|
22
|
+
contractAddress: string;
|
|
23
|
+
}>): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the range for an offer.
|
|
26
|
+
* @param offerId - Offer ID
|
|
27
|
+
* @param overrides - Optional overrides.
|
|
28
|
+
* @returns Transaction response.
|
|
29
|
+
*/
|
|
30
|
+
getRangeByOfferId(offerId: BigNumberish, overrides?: Partial<{
|
|
31
|
+
contractAddress: string;
|
|
32
|
+
}>): Promise<Range>;
|
|
33
|
+
/**
|
|
34
|
+
* Pre-mints all or part of an offer's reserved vouchers.
|
|
35
|
+
* @param offerId - Offer ID
|
|
36
|
+
* @param overrides - Optional overrides.
|
|
37
|
+
* @returns Transaction response.
|
|
38
|
+
*/
|
|
39
|
+
preMint(offerId: BigNumberish, amount: BigNumberish, overrides?: Partial<{
|
|
40
|
+
contractAddress: string;
|
|
41
|
+
}>): Promise<TransactionResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Pre-mints all or part of an offer's reserved vouchers.
|
|
44
|
+
* @param offerId - Offer ID
|
|
45
|
+
* @param overrides - Optional overrides.
|
|
46
|
+
* @returns Transaction response.
|
|
47
|
+
*/
|
|
48
|
+
transferFrom(offerId: BigNumberish, to: BigNumberish, tokenId: BigNumberish, overrides?: Partial<{
|
|
49
|
+
owner: BigNumberish;
|
|
50
|
+
contractAddress: string;
|
|
51
|
+
}>): Promise<TransactionResponse>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=mixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixin.d.ts","sourceRoot":"","sources":["../../../src/voucher/mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,qBAAa,YAAa,SAAQ,WAAW;IAC3C;;;;;OAKG;IACU,qBAAqB,CAChC,OAAO,EAAE,YAAY,EACrB,SAAS,GAAE,OAAO,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAM,GACN,OAAO,CAAC,mBAAmB,CAAC;IAW/B;;;;;OAKG;IACU,oBAAoB,CAC/B,OAAO,EAAE,YAAY,EACrB,SAAS,GAAE,OAAO,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAM,GACN,OAAO,CAAC,MAAM,CAAC;IAWlB;;;;;OAKG;IACU,iBAAiB,CAC5B,OAAO,EAAE,YAAY,EACrB,SAAS,GAAE,OAAO,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAM,GACN,OAAO,CAAC,KAAK,CAAC;IAWjB;;;;;OAKG;IACU,OAAO,CAClB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,YAAY,EACpB,SAAS,GAAE,OAAO,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAM,GACN,OAAO,CAAC,mBAAmB,CAAC;IAY/B;;;;;OAKG;IACU,YAAY,CACvB,OAAO,EAAE,YAAY,EACrB,EAAE,EAAE,YAAY,EAChB,OAAO,EAAE,YAAY,EACrB,SAAS,GAAE,OAAO,CAAC;QACjB,KAAK,EAAE,YAAY,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAM,GACN,OAAO,CAAC,mBAAmB,CAAC;CAahC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { handler } from ".";
|
|
2
|
+
import { getOfferById } from "../offers/subgraph";
|
|
3
|
+
import { BaseCoreSDK } from "./../mixins/base-core-sdk";
|
|
4
|
+
export class VoucherMixin extends BaseCoreSDK {
|
|
5
|
+
/**
|
|
6
|
+
* Burns preminted vouchers from an offer
|
|
7
|
+
* @param offerId - Offer ID
|
|
8
|
+
* @param overrides - Optional overrides.
|
|
9
|
+
* @returns Transaction response.
|
|
10
|
+
*/
|
|
11
|
+
async burnPremintedVouchers(offerId, overrides = {}) {
|
|
12
|
+
const offerFromSubgraph = await getOfferById(this._subgraphUrl, offerId);
|
|
13
|
+
return handler.burnPremintedVouchers({
|
|
14
|
+
offerId,
|
|
15
|
+
contractAddress: overrides.contractAddress ||
|
|
16
|
+
offerFromSubgraph.seller.voucherCloneAddress,
|
|
17
|
+
web3Lib: this._web3Lib
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets the number of vouchers available to be pre-minted for an offer.
|
|
22
|
+
* @param offerId - Offer ID
|
|
23
|
+
* @param overrides - Optional overrides.
|
|
24
|
+
* @returns Transaction response.
|
|
25
|
+
*/
|
|
26
|
+
async getAvailablePreMints(offerId, overrides = {}) {
|
|
27
|
+
const offerFromSubgraph = await getOfferById(this._subgraphUrl, offerId);
|
|
28
|
+
return handler.getAvailablePreMints({
|
|
29
|
+
offerId,
|
|
30
|
+
contractAddress: overrides.contractAddress ||
|
|
31
|
+
offerFromSubgraph.seller.voucherCloneAddress,
|
|
32
|
+
web3Lib: this._web3Lib
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets the range for an offer.
|
|
37
|
+
* @param offerId - Offer ID
|
|
38
|
+
* @param overrides - Optional overrides.
|
|
39
|
+
* @returns Transaction response.
|
|
40
|
+
*/
|
|
41
|
+
async getRangeByOfferId(offerId, overrides = {}) {
|
|
42
|
+
const offerFromSubgraph = await getOfferById(this._subgraphUrl, offerId);
|
|
43
|
+
return handler.getRangeByOfferId({
|
|
44
|
+
offerId,
|
|
45
|
+
contractAddress: overrides.contractAddress ||
|
|
46
|
+
offerFromSubgraph.seller.voucherCloneAddress,
|
|
47
|
+
web3Lib: this._web3Lib
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pre-mints all or part of an offer's reserved vouchers.
|
|
52
|
+
* @param offerId - Offer ID
|
|
53
|
+
* @param overrides - Optional overrides.
|
|
54
|
+
* @returns Transaction response.
|
|
55
|
+
*/
|
|
56
|
+
async preMint(offerId, amount, overrides = {}) {
|
|
57
|
+
const offerFromSubgraph = await getOfferById(this._subgraphUrl, offerId);
|
|
58
|
+
return handler.preMint({
|
|
59
|
+
offerId,
|
|
60
|
+
amount,
|
|
61
|
+
contractAddress: overrides.contractAddress ||
|
|
62
|
+
offerFromSubgraph.seller.voucherCloneAddress,
|
|
63
|
+
web3Lib: this._web3Lib
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Pre-mints all or part of an offer's reserved vouchers.
|
|
68
|
+
* @param offerId - Offer ID
|
|
69
|
+
* @param overrides - Optional overrides.
|
|
70
|
+
* @returns Transaction response.
|
|
71
|
+
*/
|
|
72
|
+
async transferFrom(offerId, to, tokenId, overrides = {}) {
|
|
73
|
+
const offerFromSubgraph = await getOfferById(this._subgraphUrl, offerId);
|
|
74
|
+
return handler.transferFrom({
|
|
75
|
+
from: overrides.owner || (await this._web3Lib.getSignerAddress()),
|
|
76
|
+
to,
|
|
77
|
+
tokenId,
|
|
78
|
+
contractAddress: overrides.contractAddress ||
|
|
79
|
+
offerFromSubgraph.seller.voucherCloneAddress,
|
|
80
|
+
web3Lib: this._web3Lib
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=mixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixin.js","sourceRoot":"","sources":["../../../src/voucher/mixin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C;;;;;OAKG;IACI,KAAK,CAAC,qBAAqB,CAChC,OAAqB,EACrB,YAEK,EAAE;QAEP,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzE,OAAO,OAAO,CAAC,qBAAqB,CAAC;YACnC,OAAO;YACP,eAAe,EACb,SAAS,CAAC,eAAe;gBACzB,iBAAiB,CAAC,MAAM,CAAC,mBAAmB;YAC9C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,oBAAoB,CAC/B,OAAqB,EACrB,YAEK,EAAE;QAEP,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzE,OAAO,OAAO,CAAC,oBAAoB,CAAC;YAClC,OAAO;YACP,eAAe,EACb,SAAS,CAAC,eAAe;gBACzB,iBAAiB,CAAC,MAAM,CAAC,mBAAmB;YAC9C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB,CAC5B,OAAqB,EACrB,YAEK,EAAE;QAEP,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzE,OAAO,OAAO,CAAC,iBAAiB,CAAC;YAC/B,OAAO;YACP,eAAe,EACb,SAAS,CAAC,eAAe;gBACzB,iBAAiB,CAAC,MAAM,CAAC,mBAAmB;YAC9C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAClB,OAAqB,EACrB,MAAoB,EACpB,YAEK,EAAE;QAEP,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,OAAO;YACP,MAAM;YACN,eAAe,EACb,SAAS,CAAC,eAAe;gBACzB,iBAAiB,CAAC,MAAM,CAAC,mBAAmB;YAC9C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY,CACvB,OAAqB,EACrB,EAAgB,EAChB,OAAqB,EACrB,YAGK,EAAE;QAEP,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAEzE,OAAO,OAAO,CAAC,YAAY,CAAC;YAC1B,IAAI,EAAE,SAAS,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YACjE,EAAE;YACF,OAAO;YACP,eAAe,EACb,SAAS,CAAC,eAAe;gBACzB,iBAAiB,CAAC,MAAM,CAAC,mBAAmB;YAC9C,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/core-sdk",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.1-alpha.1",
|
|
4
4
|
"description": "Facilitates interaction with the contracts and subgraphs of the Boson Protocol",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bosonprotocol/common": "^1.20.
|
|
36
|
+
"@bosonprotocol/common": "^1.20.3-alpha.1",
|
|
37
37
|
"@ethersproject/abi": "^5.5.0",
|
|
38
38
|
"@ethersproject/address": "^5.5.0",
|
|
39
39
|
"@ethersproject/bignumber": "^5.5.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"ts-jest": "^27.1.3",
|
|
55
55
|
"typescript": "^4.5.5"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "4d8620609cf6c9529b47b5d5285311aed2a55d11"
|
|
58
58
|
}
|
package/src/accounts/handler.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
encodeCreateSeller,
|
|
10
10
|
encodeUpdateSeller,
|
|
11
11
|
encodeCreateDisputeResolver,
|
|
12
|
-
encodeActivateDisputeResolver,
|
|
13
12
|
encodeAddFeesToDisputeResolver,
|
|
14
13
|
encodeAddSellersToAllowList,
|
|
15
14
|
encodeRemoveFeesFromDisputeResolver,
|
|
@@ -76,17 +75,6 @@ export async function createDisputeResolver(args: {
|
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
export async function activateDisputeResolver(args: {
|
|
80
|
-
disputeResolverId: BigNumberish;
|
|
81
|
-
contractAddress: string;
|
|
82
|
-
web3Lib: Web3LibAdapter;
|
|
83
|
-
}) {
|
|
84
|
-
return args.web3Lib.sendTransaction({
|
|
85
|
-
to: args.contractAddress,
|
|
86
|
-
data: encodeActivateDisputeResolver(args.disputeResolverId)
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
78
|
export async function addFeesToDisputeResolver(args: {
|
|
91
79
|
disputeResolverId: BigNumberish;
|
|
92
80
|
fees: DisputeResolutionFee[];
|
|
@@ -61,13 +61,6 @@ export function encodeCreateDisputeResolver(args: CreateDisputeResolverArgs) {
|
|
|
61
61
|
]);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function encodeActivateDisputeResolver(disputeResolverId: BigNumberish) {
|
|
65
|
-
return bosonAccountHandlerIface.encodeFunctionData(
|
|
66
|
-
"activateDisputeResolver",
|
|
67
|
-
[disputeResolverId]
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
64
|
export function encodeAddFeesToDisputeResolver(args: {
|
|
72
65
|
disputeResolverId: BigNumberish;
|
|
73
66
|
fees: DisputeResolutionFee[];
|
package/src/accounts/mixin.ts
CHANGED
|
@@ -493,22 +493,6 @@ export class AccountsMixin extends BaseCoreSDK {
|
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
/**
|
|
497
|
-
* Activates a dispute resolver account by calling the `AccountHandlerFacet` contract.
|
|
498
|
-
* Note, that the caller needs to have the ADMIN role.
|
|
499
|
-
* @param disputeResolverId - Id of dispute resolver to activate.
|
|
500
|
-
* @returns Transaction response.
|
|
501
|
-
*/
|
|
502
|
-
public async activateDisputeResolver(
|
|
503
|
-
disputeResolverId: BigNumberish
|
|
504
|
-
): Promise<TransactionResponse> {
|
|
505
|
-
return accounts.handler.activateDisputeResolver({
|
|
506
|
-
disputeResolverId,
|
|
507
|
-
contractAddress: this._protocolDiamond,
|
|
508
|
-
web3Lib: this._web3Lib
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
|
|
512
496
|
/**
|
|
513
497
|
* Adds fees to a dispute resolver account by calling the `AccountHandlerFacet`
|
|
514
498
|
* contract. Note, that the caller must be the specified `admin` address of the dispute
|
package/src/core-sdk.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { OfferMixin } from "./offers/mixin";
|
|
|
18
18
|
import { FundsMixin } from "./funds/mixin";
|
|
19
19
|
import { ExchangesMixin } from "./exchanges/mixin";
|
|
20
20
|
import { EventLogsMixin } from "./event-logs/mixin";
|
|
21
|
+
import { VoucherMixin } from "./voucher/mixin";
|
|
21
22
|
|
|
22
23
|
export class CoreSDK extends BaseCoreSDK {
|
|
23
24
|
/**
|
|
@@ -103,7 +104,8 @@ export interface CoreSDK
|
|
|
103
104
|
NativeMetaTxMixin,
|
|
104
105
|
GroupsMixin,
|
|
105
106
|
OrchestrationMixin,
|
|
106
|
-
EventLogsMixin
|
|
107
|
+
EventLogsMixin,
|
|
108
|
+
VoucherMixin {}
|
|
107
109
|
applyMixins(CoreSDK, [
|
|
108
110
|
MetadataMixin,
|
|
109
111
|
AccountsMixin,
|
|
@@ -115,5 +117,6 @@ applyMixins(CoreSDK, [
|
|
|
115
117
|
NativeMetaTxMixin,
|
|
116
118
|
GroupsMixin,
|
|
117
119
|
OrchestrationMixin,
|
|
118
|
-
EventLogsMixin
|
|
120
|
+
EventLogsMixin,
|
|
121
|
+
VoucherMixin
|
|
119
122
|
]);
|
package/src/erc721/handler.ts
CHANGED
|
@@ -7,9 +7,11 @@ export async function balanceOf(args: {
|
|
|
7
7
|
owner: string;
|
|
8
8
|
web3Lib: Web3LibAdapter;
|
|
9
9
|
}): Promise<string> {
|
|
10
|
+
const data = erc721Iface.encodeFunctionData("balanceOf", [args.owner]);
|
|
11
|
+
|
|
10
12
|
const result = await args.web3Lib.call({
|
|
11
13
|
to: args.contractAddress,
|
|
12
|
-
data:
|
|
14
|
+
data: data
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
const [balance] = erc721Iface.decodeFunctionResult("balanceOf", result);
|
package/src/meta-tx/handler.ts
CHANGED
|
@@ -24,7 +24,8 @@ import { bosonExchangeHandlerIface } from "../exchanges/interface";
|
|
|
24
24
|
import {
|
|
25
25
|
bosonOfferHandlerIface,
|
|
26
26
|
encodeCreateOffer,
|
|
27
|
-
encodeCreateOfferBatch
|
|
27
|
+
encodeCreateOfferBatch,
|
|
28
|
+
encodeReserveRange
|
|
28
29
|
} from "../offers/interface";
|
|
29
30
|
import { prepareDataSignatureParameters } from "../utils/signature";
|
|
30
31
|
import { Biconomy, GetRetriedHashesData } from "./biconomy";
|
|
@@ -34,6 +35,7 @@ import { encodeDepositFunds, encodeWithdrawFunds } from "../funds/interface";
|
|
|
34
35
|
import { bosonDisputeHandlerIface } from "../disputes/interface";
|
|
35
36
|
import { encodeCreateGroup } from "../groups/interface";
|
|
36
37
|
import { encodeCreateOfferWithCondition } from "../orchestration/interface";
|
|
38
|
+
import { encodePreMint } from "../voucher/interface";
|
|
37
39
|
|
|
38
40
|
export type BaseMetaTxArgs = {
|
|
39
41
|
web3Lib: Web3LibAdapter;
|
|
@@ -42,6 +44,14 @@ export type BaseMetaTxArgs = {
|
|
|
42
44
|
chainId: number;
|
|
43
45
|
};
|
|
44
46
|
|
|
47
|
+
export type BaseVoucherMetaTxArgs = {
|
|
48
|
+
web3Lib: Web3LibAdapter;
|
|
49
|
+
nonce: BigNumberish;
|
|
50
|
+
bosonVoucherAddress: string;
|
|
51
|
+
forwarderAddress: string;
|
|
52
|
+
chainId: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
45
55
|
export type SignedMetaTx = {
|
|
46
56
|
functionName: string;
|
|
47
57
|
functionSignature: string;
|
|
@@ -93,6 +103,65 @@ export async function signMetaTx(
|
|
|
93
103
|
};
|
|
94
104
|
}
|
|
95
105
|
|
|
106
|
+
export async function signVoucherMetaTx(
|
|
107
|
+
args: BaseVoucherMetaTxArgs & {
|
|
108
|
+
functionSignature: string;
|
|
109
|
+
}
|
|
110
|
+
): Promise<{
|
|
111
|
+
to: string;
|
|
112
|
+
functionSignature: string;
|
|
113
|
+
r: string;
|
|
114
|
+
s: string;
|
|
115
|
+
v: number;
|
|
116
|
+
}> {
|
|
117
|
+
const forwardType = [
|
|
118
|
+
{ name: "from", type: "address" },
|
|
119
|
+
{ name: "to", type: "address" },
|
|
120
|
+
{ name: "nonce", type: "uint256" },
|
|
121
|
+
{ name: "data", type: "bytes" }
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
const customSignatureType = {
|
|
125
|
+
EIP712Domain: [
|
|
126
|
+
{ name: "name", type: "string" },
|
|
127
|
+
{ name: "version", type: "string" },
|
|
128
|
+
{ name: "chainId", type: "uint256" },
|
|
129
|
+
{ name: "verifyingContract", type: "address" }
|
|
130
|
+
],
|
|
131
|
+
ForwardRequest: forwardType
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
135
|
+
const chainId = await args.web3Lib.getChainId();
|
|
136
|
+
|
|
137
|
+
const message = {
|
|
138
|
+
from: signerAddress,
|
|
139
|
+
to: args.bosonVoucherAddress,
|
|
140
|
+
nonce: args.nonce,
|
|
141
|
+
data: args.functionSignature
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const signature = await prepareDataSignatureParameters({
|
|
145
|
+
...args,
|
|
146
|
+
verifyingContractAddress: args.forwarderAddress,
|
|
147
|
+
customSignatureType,
|
|
148
|
+
primaryType: "ForwardRequest",
|
|
149
|
+
message,
|
|
150
|
+
customDomainData: {
|
|
151
|
+
name: "MockForwarder",
|
|
152
|
+
version: "0.0.1",
|
|
153
|
+
chainId,
|
|
154
|
+
salt: undefined
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
to: message.to,
|
|
160
|
+
functionSignature: args.functionSignature,
|
|
161
|
+
...signature
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
96
165
|
export async function signMetaTxCreateSeller(
|
|
97
166
|
args: BaseMetaTxArgs & {
|
|
98
167
|
createSellerArgs: CreateSellerArgs;
|
|
@@ -274,6 +343,31 @@ export async function signMetaTxCreateGroup(
|
|
|
274
343
|
});
|
|
275
344
|
}
|
|
276
345
|
|
|
346
|
+
export async function signMetaTxReserveRange(
|
|
347
|
+
args: BaseMetaTxArgs & {
|
|
348
|
+
offerId: BigNumberish;
|
|
349
|
+
length: BigNumberish;
|
|
350
|
+
}
|
|
351
|
+
) {
|
|
352
|
+
return signMetaTx({
|
|
353
|
+
...args,
|
|
354
|
+
functionName: "reserveRange(uint256,uint256)",
|
|
355
|
+
functionSignature: encodeReserveRange(args.offerId, args.length)
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export async function signMetaTxPreMint(
|
|
360
|
+
args: BaseVoucherMetaTxArgs & {
|
|
361
|
+
offerId: BigNumberish;
|
|
362
|
+
amount: BigNumberish;
|
|
363
|
+
}
|
|
364
|
+
) {
|
|
365
|
+
return signVoucherMetaTx({
|
|
366
|
+
...args,
|
|
367
|
+
functionSignature: encodePreMint(args.offerId, args.amount)
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
277
371
|
export async function signMetaTxCreateOfferWithCondition(
|
|
278
372
|
args: BaseMetaTxArgs & {
|
|
279
373
|
offerToCreate: CreateOfferArgs;
|
package/src/meta-tx/mixin.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { MetaTxConfig, TransactionResponse } from "@bosonprotocol/common";
|
|
|
2
2
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
3
3
|
import { BytesLike } from "@ethersproject/bytes";
|
|
4
4
|
import { handler } from ".";
|
|
5
|
+
import { getOfferById } from "../offers/subgraph";
|
|
5
6
|
import { BaseCoreSDK } from "./../mixins/base-core-sdk";
|
|
6
7
|
import { GetRetriedHashesData } from "./biconomy";
|
|
7
8
|
export class MetaTxMixin extends BaseCoreSDK {
|
|
@@ -136,6 +137,38 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
public async signMetaTxReserveRange(
|
|
141
|
+
args: Omit<
|
|
142
|
+
Parameters<typeof handler.signMetaTxReserveRange>[0],
|
|
143
|
+
"web3Lib" | "metaTxHandlerAddress" | "chainId"
|
|
144
|
+
>
|
|
145
|
+
) {
|
|
146
|
+
return handler.signMetaTxReserveRange({
|
|
147
|
+
web3Lib: this._web3Lib,
|
|
148
|
+
metaTxHandlerAddress: this._protocolDiamond,
|
|
149
|
+
chainId: this._chainId,
|
|
150
|
+
...args
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public async signMetaTxPreMint(
|
|
155
|
+
args: Omit<
|
|
156
|
+
Parameters<typeof handler.signMetaTxPreMint>[0],
|
|
157
|
+
"web3Lib" | "bosonVoucherAddress" | "chainId"
|
|
158
|
+
>
|
|
159
|
+
) {
|
|
160
|
+
const offerFromSubgraph = await getOfferById(
|
|
161
|
+
this._subgraphUrl,
|
|
162
|
+
args.offerId
|
|
163
|
+
);
|
|
164
|
+
return handler.signMetaTxPreMint({
|
|
165
|
+
web3Lib: this._web3Lib,
|
|
166
|
+
bosonVoucherAddress: offerFromSubgraph.seller.voucherCloneAddress,
|
|
167
|
+
chainId: this._chainId,
|
|
168
|
+
...args
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
139
172
|
/**
|
|
140
173
|
* Encodes and signs a meta transaction for `createOfferWithCondition` that can be relayed.
|
|
141
174
|
* @param args - Meta transaction args.
|