@1inch/fusion-sdk 0.0.6 → 0.0.7
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/README.md +4 -0
- package/api/fusion-api.d.ts +16 -25
- package/api/fusion-api.js +26 -36
- package/api/index.d.ts +4 -4
- package/api/index.js +8 -8
- package/api/orders/index.d.ts +3 -3
- package/api/orders/index.js +7 -7
- package/api/orders/order-api.spec.d.ts +1 -1
- package/api/orders/order-api.spec.js +397 -479
- package/api/orders/orders.api.d.ts +10 -24
- package/api/orders/orders.api.js +28 -30
- package/api/orders/orders.request.d.ts +18 -22
- package/api/orders/orders.request.js +31 -40
- package/api/orders/types.d.ts +58 -59
- package/api/orders/types.js +16 -17
- package/api/pagination.d.ts +7 -7
- package/api/pagination.js +10 -10
- package/api/pagination.spec.d.ts +1 -1
- package/api/pagination.spec.js +21 -28
- package/api/params.d.ts +1 -3
- package/api/params.js +19 -25
- package/api/quoter/index.d.ts +5 -5
- package/api/quoter/index.js +9 -9
- package/api/quoter/preset.d.ts +13 -13
- package/api/quoter/preset.js +17 -19
- package/api/quoter/quote/index.d.ts +3 -3
- package/api/quoter/quote/index.js +7 -7
- package/api/quoter/quote/order-params.d.ts +7 -6
- package/api/quoter/quote/order-params.js +13 -12
- package/api/quoter/quote/order-params.js.map +1 -1
- package/api/quoter/quote/quote.d.ts +22 -26
- package/api/quoter/quote/quote.js +59 -84
- package/api/quoter/quote/quote.js.map +1 -1
- package/api/quoter/quote/types.d.ts +5 -4
- package/api/quoter/quote/types.js +3 -3
- package/api/quoter/quoter.api.d.ts +9 -12
- package/api/quoter/quoter.api.js +19 -19
- package/api/quoter/quoter.api.spec.d.ts +1 -1
- package/api/quoter/quoter.api.spec.js +24 -30
- package/api/quoter/quoter.api.spec.js.map +1 -1
- package/api/quoter/quoter.request.d.ts +11 -11
- package/api/quoter/quoter.request.js +26 -28
- package/api/quoter/types.d.ts +45 -45
- package/api/quoter/types.js +10 -10
- package/api/relayer/index.d.ts +3 -3
- package/api/relayer/index.js +7 -7
- package/api/relayer/relayer.api.d.ts +9 -12
- package/api/relayer/relayer.api.js +13 -13
- package/api/relayer/relayer.api.spec.d.ts +1 -1
- package/api/relayer/relayer.api.spec.js +79 -96
- package/api/relayer/relayer.request.d.ts +8 -8
- package/api/relayer/relayer.request.js +10 -10
- package/api/relayer/types.d.ts +9 -9
- package/api/relayer/types.js +3 -3
- package/api/types.d.ts +15 -17
- package/api/types.js +3 -3
- package/auction-calculator/auction-calculator.d.ts +13 -22
- package/auction-calculator/auction-calculator.js +45 -70
- package/auction-calculator/auction-calculator.spec.d.ts +1 -1
- package/auction-calculator/auction-calculator.spec.js +32 -45
- package/auction-calculator/calc.d.ts +2 -8
- package/auction-calculator/calc.js +12 -12
- package/auction-calculator/constants.d.ts +1 -1
- package/auction-calculator/constants.js +5 -5
- package/auction-calculator/index.d.ts +3 -3
- package/auction-calculator/index.js +7 -7
- package/auction-salt/auction-salt.d.ts +9 -9
- package/auction-salt/auction-salt.js +23 -34
- package/auction-salt/auction.salt.spec.d.ts +1 -1
- package/auction-salt/auction.salt.spec.js +27 -38
- package/auction-salt/index.d.ts +3 -3
- package/auction-salt/index.js +7 -7
- package/auction-salt/parser/constants.d.ts +9 -9
- package/auction-salt/parser/constants.js +14 -33
- package/auction-salt/parser/index.d.ts +2 -2
- package/auction-salt/parser/index.js +6 -6
- package/auction-salt/parser/parser.d.ts +6 -6
- package/auction-salt/parser/parser.js +22 -33
- package/auction-salt/types.d.ts +6 -6
- package/auction-salt/types.js +3 -3
- package/auction-suffix/auction-suffix.d.ts +9 -9
- package/auction-suffix/auction-suffix.js +23 -36
- package/auction-suffix/auction-suffix.spec.d.ts +1 -1
- package/auction-suffix/auction-suffix.spec.js +15 -20
- package/auction-suffix/constants.d.ts +1 -1
- package/auction-suffix/constants.js +5 -5
- package/auction-suffix/encoder.d.ts +6 -15
- package/auction-suffix/encoder.js +28 -45
- package/auction-suffix/index.d.ts +5 -5
- package/auction-suffix/index.js +9 -9
- package/auction-suffix/parser/constants.d.ts +13 -13
- package/auction-suffix/parser/constants.js +17 -30
- package/auction-suffix/parser/errors.d.ts +2 -1
- package/auction-suffix/parser/errors.js +7 -6
- package/auction-suffix/parser/index.d.ts +4 -4
- package/auction-suffix/parser/index.js +8 -8
- package/auction-suffix/parser/parser.d.ts +8 -28
- package/auction-suffix/parser/parser.js +81 -162
- package/auction-suffix/parser/types.d.ts +22 -22
- package/auction-suffix/parser/types.js +3 -3
- package/auction-suffix/types.d.ts +12 -12
- package/auction-suffix/types.js +3 -3
- package/connector/blockchain/blockchain-provider.connector.d.ts +3 -6
- package/connector/blockchain/blockchain-provider.connector.js +3 -3
- package/connector/blockchain/index.d.ts +3 -3
- package/connector/blockchain/index.js +7 -7
- package/connector/blockchain/private-key-provider.connector.d.ts +10 -15
- package/connector/blockchain/private-key-provider.connector.js +12 -12
- package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/private-key-provider.connector.spec.js +23 -36
- package/connector/blockchain/web3-provider-connector.d.ts +8 -13
- package/connector/blockchain/web3-provider-connector.js +9 -12
- package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/web3-provider.connector.spec.js +26 -37
- package/connector/http/axios-provider.connector.d.ts +3 -3
- package/connector/http/axios-provider.connector.js +13 -13
- package/connector/http/axios-provider.connector.spec.d.ts +1 -1
- package/connector/http/axios-provider.connector.spec.js +31 -37
- package/connector/http/http-provider.connector.d.ts +2 -2
- package/connector/http/http-provider.connector.js +3 -3
- package/connector/http/index.d.ts +2 -2
- package/connector/http/index.js +6 -6
- package/connector/index.d.ts +2 -2
- package/connector/index.js +6 -6
- package/constants.d.ts +6 -10
- package/constants.js +16 -23
- package/fusion-order/fusion-order.d.ts +7 -17
- package/fusion-order/fusion-order.js +12 -14
- package/fusion-order/fusion-order.spec.d.ts +1 -1
- package/fusion-order/fusion-order.spec.js +22 -27
- package/fusion-order/index.d.ts +1 -1
- package/fusion-order/index.js +5 -5
- package/index.d.ts +11 -11
- package/index.js +15 -15
- package/limit-order/eip712/domain.d.ts +9 -10
- package/limit-order/eip712/domain.js +23 -28
- package/limit-order/eip712/eip712.types.d.ts +15 -19
- package/limit-order/eip712/eip712.types.js +3 -3
- package/limit-order/eip712/index.d.ts +3 -3
- package/limit-order/eip712/index.js +7 -7
- package/limit-order/eip712/order-typed-data-builder.d.ts +6 -17
- package/limit-order/eip712/order-typed-data-builder.js +19 -34
- package/limit-order/index.d.ts +4 -4
- package/limit-order/index.js +8 -8
- package/limit-order/interactions-factory.d.ts +1 -1
- package/limit-order/interactions-factory.js +6 -6
- package/limit-order/limit-order.d.ts +25 -31
- package/limit-order/limit-order.js +50 -103
- package/limit-order/limit-order.spec.d.ts +1 -1
- package/limit-order/limit-order.spec.js +51 -75
- package/limit-order/parser/constants.d.ts +9 -9
- package/limit-order/parser/constants.js +5 -5
- package/limit-order/parser/index.d.ts +3 -3
- package/limit-order/parser/index.js +7 -7
- package/limit-order/parser/parser.d.ts +2 -5
- package/limit-order/parser/parser.js +18 -23
- package/limit-order/parser/types.d.ts +3 -3
- package/limit-order/parser/types.js +3 -3
- package/limit-order/predicate-factory.d.ts +5 -9
- package/limit-order/predicate-factory.js +24 -40
- package/limit-order/predicate-factory.spec.d.ts +1 -1
- package/limit-order/predicate-factory.spec.js +29 -44
- package/limit-order/types.d.ts +29 -29
- package/limit-order/types.js +3 -3
- package/limit-order/utils.d.ts +1 -1
- package/limit-order/utils.js +6 -6
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +6 -6
- package/sdk/sdk.d.ts +11 -29
- package/sdk/sdk.js +40 -49
- package/sdk/sdk.js.map +1 -1
- package/sdk/types.d.ts +27 -27
- package/sdk/types.js +3 -3
- package/settlement/encoders/constants.d.ts +1 -1
- package/settlement/encoders/constants.js +5 -5
- package/settlement/encoders/fill-order.encoder.d.ts +2 -2
- package/settlement/encoders/fill-order.encoder.js +12 -26
- package/settlement/encoders/index.d.ts +3 -3
- package/settlement/encoders/index.js +7 -7
- package/settlement/encoders/settlement.encoder.d.ts +4 -13
- package/settlement/encoders/settlement.encoder.js +19 -41
- package/settlement/index.d.ts +4 -4
- package/settlement/index.js +8 -8
- package/settlement/settlement.d.ts +5 -8
- package/settlement/settlement.js +14 -28
- package/settlement/settlement.spec.d.ts +1 -1
- package/settlement/settlement.spec.js +35 -45
- package/settlement/signature-patcher.d.ts +1 -1
- package/settlement/signature-patcher.js +16 -19
- package/settlement/types.d.ts +13 -13
- package/settlement/types.js +3 -3
- package/utils.d.ts +6 -6
- package/utils.js +23 -29
- package/validations.d.ts +2 -2
- package/validations.js +15 -14
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InteractionAdditionalInfo,
|
|
3
|
-
InteractionFlags,
|
|
4
|
-
ParsedAuctionParams,
|
|
5
|
-
PrivateAuctionDeadline,
|
|
6
|
-
ResolversWhitelist,
|
|
7
|
-
TakerFeeData
|
|
8
|
-
} from './types'
|
|
1
|
+
import { InteractionAdditionalInfo, InteractionFlags, ParsedAuctionParams, PrivateAuctionDeadline, ResolversWhitelist, TakerFeeData } from './types';
|
|
9
2
|
/**
|
|
10
3
|
* Order.interactions suffix structure:
|
|
11
4
|
* M*(1 + 3 bytes) - auction points coefficients with seconds delays
|
|
@@ -15,23 +8,10 @@ import {
|
|
|
15
8
|
* 1 byte - flags
|
|
16
9
|
* @param interactions
|
|
17
10
|
*/
|
|
18
|
-
export declare function parseInteractionsSuffix(
|
|
19
|
-
|
|
20
|
-
):
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
): TakerFeeData
|
|
26
|
-
export declare function parsePrivateAuctionDeadline(
|
|
27
|
-
interactions: string
|
|
28
|
-
): PrivateAuctionDeadline
|
|
29
|
-
export declare function parseResolversWhitelist(
|
|
30
|
-
flags: InteractionFlags,
|
|
31
|
-
interactions: string
|
|
32
|
-
): ResolversWhitelist
|
|
33
|
-
export declare function parseAuctionParams(
|
|
34
|
-
flags: InteractionFlags,
|
|
35
|
-
interactions: string
|
|
36
|
-
): ParsedAuctionParams
|
|
37
|
-
export declare function parseFlags(interactions: string): InteractionFlags
|
|
11
|
+
export declare function parseInteractionsSuffix(interactions: string): InteractionAdditionalInfo;
|
|
12
|
+
export declare function minInteractionsLength(flags: InteractionFlags): number;
|
|
13
|
+
export declare function parseTakingFeeAndReturnRemainingInteractions(flags: InteractionFlags, interactions: string): TakerFeeData;
|
|
14
|
+
export declare function parsePrivateAuctionDeadline(interactions: string): PrivateAuctionDeadline;
|
|
15
|
+
export declare function parseResolversWhitelist(flags: InteractionFlags, interactions: string): ResolversWhitelist;
|
|
16
|
+
export declare function parseAuctionParams(flags: InteractionFlags, interactions: string): ParsedAuctionParams;
|
|
17
|
+
export declare function parseFlags(interactions: string): InteractionFlags;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.parseFlags =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.parseInteractionsSuffix =
|
|
10
|
-
void 0
|
|
11
|
-
const constants_1 = require('./constants')
|
|
12
|
-
const bignumber_1 = require('@ethersproject/bignumber')
|
|
13
|
-
const constants_2 = require('../../constants')
|
|
14
|
-
const utils_1 = require('../../utils')
|
|
15
|
-
const errors_1 = require('./errors')
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlags = exports.parseAuctionParams = exports.parseResolversWhitelist = exports.parsePrivateAuctionDeadline = exports.parseTakingFeeAndReturnRemainingInteractions = exports.minInteractionsLength = exports.parseInteractionsSuffix = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
6
|
+
const constants_2 = require("../../constants");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
16
9
|
/**
|
|
17
10
|
* Order.interactions suffix structure:
|
|
18
11
|
* M*(1 + 3 bytes) - auction points coefficients with seconds delays
|
|
@@ -23,229 +16,155 @@ const errors_1 = require('./errors')
|
|
|
23
16
|
* @param interactions
|
|
24
17
|
*/
|
|
25
18
|
function parseInteractionsSuffix(interactions) {
|
|
26
|
-
const flags = parseFlags(interactions)
|
|
19
|
+
const flags = parseFlags(interactions);
|
|
27
20
|
if (interactions.length < minInteractionsLength(flags)) {
|
|
28
|
-
throw new errors_1.BadOrderSuffixError('wrong interactions length')
|
|
21
|
+
throw new errors_1.BadOrderSuffixError('wrong interactions length');
|
|
29
22
|
}
|
|
30
|
-
const interactionsWithoutFlags = interactions.slice(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
34
|
-
const {
|
|
35
|
-
takerFeeReceiver,
|
|
36
|
-
takerFeeRatio,
|
|
37
|
-
interactions: interactionsNoTakingFee
|
|
38
|
-
} = parseTakingFeeAndReturnRemainingInteractions(
|
|
39
|
-
flags,
|
|
40
|
-
interactionsWithoutFlags
|
|
41
|
-
)
|
|
42
|
-
const {deadline, interactions: interactionsNoDeadline} =
|
|
43
|
-
parsePrivateAuctionDeadline(interactionsNoTakingFee)
|
|
44
|
-
const {whitelist, interactions: interactionsWithoutWhitelist} =
|
|
45
|
-
parseResolversWhitelist(flags, interactionsNoDeadline)
|
|
46
|
-
const {points} = parseAuctionParams(flags, interactionsWithoutWhitelist)
|
|
23
|
+
const interactionsWithoutFlags = interactions.slice(0, -constants_1.FLAGS_LENGTH);
|
|
24
|
+
const { takerFeeReceiver, takerFeeRatio, interactions: interactionsNoTakingFee } = parseTakingFeeAndReturnRemainingInteractions(flags, interactionsWithoutFlags);
|
|
25
|
+
const { deadline, interactions: interactionsNoDeadline } = parsePrivateAuctionDeadline(interactionsNoTakingFee);
|
|
26
|
+
const { whitelist, interactions: interactionsWithoutWhitelist } = parseResolversWhitelist(flags, interactionsNoDeadline);
|
|
27
|
+
const { points } = parseAuctionParams(flags, interactionsWithoutWhitelist);
|
|
47
28
|
return {
|
|
48
29
|
whitelist,
|
|
49
30
|
publicResolvingDeadline: deadline,
|
|
50
31
|
takerFeeReceiver,
|
|
51
32
|
takerFeeRatio,
|
|
52
33
|
points
|
|
53
|
-
}
|
|
34
|
+
};
|
|
54
35
|
}
|
|
55
|
-
exports.parseInteractionsSuffix = parseInteractionsSuffix
|
|
36
|
+
exports.parseInteractionsSuffix = parseInteractionsSuffix;
|
|
56
37
|
function minInteractionsLength(flags) {
|
|
57
|
-
const auctionPointsLen =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const whitelistLen =
|
|
61
|
-
flags.resolversCount *
|
|
62
|
-
(constants_1.ALLOWED_TIMESTAMP_LENGTH + constants_1.ADDRESS_LENGTH)
|
|
63
|
-
const requiredLength =
|
|
64
|
-
auctionPointsLen +
|
|
38
|
+
const auctionPointsLen = flags.pointsCount * (constants_1.AUCTION_DELAY_LENGTH + constants_1.AUCTION_BUMP_LENGTH);
|
|
39
|
+
const whitelistLen = flags.resolversCount * (constants_1.ALLOWED_TIMESTAMP_LENGTH + constants_1.ADDRESS_LENGTH);
|
|
40
|
+
const requiredLength = auctionPointsLen +
|
|
65
41
|
whitelistLen +
|
|
66
42
|
constants_1.PRIVATE_AUCTION_DEADLINE_LENGTH +
|
|
67
|
-
constants_1.FLAGS_LENGTH
|
|
43
|
+
constants_1.FLAGS_LENGTH;
|
|
68
44
|
if (flags.takingFeeEnabled) {
|
|
69
|
-
return (
|
|
70
|
-
requiredLength +
|
|
71
|
-
constants_1.TAKER_FEE_RECEIVER_LENGTH +
|
|
72
|
-
constants_1.TAKER_FEE_RATIO_LENGTH
|
|
73
|
-
)
|
|
45
|
+
return (requiredLength + constants_1.TAKER_FEE_RECEIVER_LENGTH + constants_1.TAKER_FEE_RATIO_LENGTH);
|
|
74
46
|
}
|
|
75
|
-
return requiredLength
|
|
47
|
+
return requiredLength;
|
|
76
48
|
}
|
|
77
|
-
exports.minInteractionsLength = minInteractionsLength
|
|
49
|
+
exports.minInteractionsLength = minInteractionsLength;
|
|
78
50
|
function parseTakingFeeAndReturnRemainingInteractions(flags, interactions) {
|
|
79
51
|
if (!flags.takingFeeEnabled) {
|
|
80
52
|
return {
|
|
81
53
|
interactions,
|
|
82
54
|
takerFeeReceiver: constants_2.ZERO_ADDRESS,
|
|
83
55
|
takerFeeRatio: '0'
|
|
84
|
-
}
|
|
56
|
+
};
|
|
85
57
|
}
|
|
86
|
-
const takerFeeDataLen =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const takerFeeReceiverHex = takerFeeData.slice(
|
|
91
|
-
constants_1.TAKER_FEE_RATIO_LENGTH
|
|
92
|
-
)
|
|
93
|
-
const takerFeeReceiver = (0, utils_1.add0x)(takerFeeReceiverHex)
|
|
58
|
+
const takerFeeDataLen = constants_1.TAKER_FEE_RECEIVER_LENGTH + constants_1.TAKER_FEE_RATIO_LENGTH;
|
|
59
|
+
const takerFeeData = interactions.slice(-takerFeeDataLen);
|
|
60
|
+
const takerFeeReceiverHex = takerFeeData.slice(constants_1.TAKER_FEE_RATIO_LENGTH);
|
|
61
|
+
const takerFeeReceiver = (0, utils_1.add0x)(takerFeeReceiverHex);
|
|
94
62
|
if (takerFeeReceiver === constants_2.ZERO_ADDRESS) {
|
|
95
|
-
throw new errors_1.BadOrderSuffixError(
|
|
96
|
-
'takerFeeReceiver cannot be zero address'
|
|
97
|
-
)
|
|
63
|
+
throw new errors_1.BadOrderSuffixError('takerFeeReceiver cannot be zero address');
|
|
98
64
|
}
|
|
99
|
-
const takerFeeRateHex = takerFeeData.slice(
|
|
100
|
-
|
|
101
|
-
constants_1.TAKER_FEE_RATIO_LENGTH
|
|
102
|
-
)
|
|
103
|
-
const takerFeeRatio = bignumber_1.BigNumber.from(
|
|
104
|
-
(0, utils_1.add0x)(takerFeeRateHex)
|
|
105
|
-
)
|
|
65
|
+
const takerFeeRateHex = takerFeeData.slice(0, constants_1.TAKER_FEE_RATIO_LENGTH);
|
|
66
|
+
const takerFeeRatio = bignumber_1.BigNumber.from((0, utils_1.add0x)(takerFeeRateHex));
|
|
106
67
|
if (takerFeeRatio.gt(constants_1.CONTRACT_TAKER_FEE_PRECISION)) {
|
|
107
|
-
throw new errors_1.BadOrderSuffixError('takerFeeRatio cannot be > 1e9')
|
|
68
|
+
throw new errors_1.BadOrderSuffixError('takerFeeRatio cannot be > 1e9');
|
|
108
69
|
}
|
|
109
70
|
return {
|
|
110
71
|
interactions: interactions.slice(0, -takerFeeDataLen),
|
|
111
72
|
takerFeeReceiver,
|
|
112
73
|
takerFeeRatio: takerFeeRatio.toString()
|
|
113
|
-
}
|
|
74
|
+
};
|
|
114
75
|
}
|
|
115
|
-
exports.parseTakingFeeAndReturnRemainingInteractions =
|
|
116
|
-
parseTakingFeeAndReturnRemainingInteractions
|
|
76
|
+
exports.parseTakingFeeAndReturnRemainingInteractions = parseTakingFeeAndReturnRemainingInteractions;
|
|
117
77
|
function parsePrivateAuctionDeadline(interactions) {
|
|
118
|
-
const privateAuctionDeadlineHex = interactions.slice(
|
|
119
|
-
|
|
120
|
-
)
|
|
121
|
-
const privateAuctionDeadline = Number.parseInt(
|
|
122
|
-
privateAuctionDeadlineHex,
|
|
123
|
-
16
|
|
124
|
-
)
|
|
78
|
+
const privateAuctionDeadlineHex = interactions.slice(-constants_1.PRIVATE_AUCTION_DEADLINE_LENGTH);
|
|
79
|
+
const privateAuctionDeadline = Number.parseInt(privateAuctionDeadlineHex, 16);
|
|
125
80
|
if (!privateAuctionDeadline) {
|
|
126
|
-
throw new errors_1.BadOrderSuffixError(
|
|
127
|
-
`Invalid public resolving deadline in interactions`
|
|
128
|
-
)
|
|
81
|
+
throw new errors_1.BadOrderSuffixError(`Invalid public resolving deadline in interactions`);
|
|
129
82
|
}
|
|
130
83
|
return {
|
|
131
84
|
deadline: privateAuctionDeadline,
|
|
132
|
-
interactions: interactions.slice(
|
|
133
|
-
|
|
134
|
-
-constants_1.PRIVATE_AUCTION_DEADLINE_LENGTH
|
|
135
|
-
)
|
|
136
|
-
}
|
|
85
|
+
interactions: interactions.slice(0, -constants_1.PRIVATE_AUCTION_DEADLINE_LENGTH)
|
|
86
|
+
};
|
|
137
87
|
}
|
|
138
|
-
exports.parsePrivateAuctionDeadline = parsePrivateAuctionDeadline
|
|
88
|
+
exports.parsePrivateAuctionDeadline = parsePrivateAuctionDeadline;
|
|
139
89
|
function parseResolversWhitelist(flags, interactions) {
|
|
140
|
-
const whitelist = []
|
|
141
|
-
const allowedTsAndResolverLen =
|
|
142
|
-
|
|
143
|
-
const addressesPacked = interactions.slice(
|
|
144
|
-
-1 * flags.resolversCount * allowedTsAndResolverLen
|
|
145
|
-
)
|
|
90
|
+
const whitelist = [];
|
|
91
|
+
const allowedTsAndResolverLen = constants_1.ADDRESS_LENGTH + constants_1.ALLOWED_TIMESTAMP_LENGTH;
|
|
92
|
+
const addressesPacked = interactions.slice(-1 * flags.resolversCount * allowedTsAndResolverLen);
|
|
146
93
|
if (addressesPacked.length % allowedTsAndResolverLen) {
|
|
147
|
-
throw new errors_1.BadOrderSuffixError(
|
|
148
|
-
`Invalid whitelist addresses in interactions`
|
|
149
|
-
)
|
|
94
|
+
throw new errors_1.BadOrderSuffixError(`Invalid whitelist addresses in interactions`);
|
|
150
95
|
}
|
|
151
96
|
for (let i = 0; i < addressesPacked.length; i += allowedTsAndResolverLen) {
|
|
152
|
-
const tsAndAddress = addressesPacked.slice(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
)
|
|
156
|
-
const timestampHex = tsAndAddress.slice(
|
|
157
|
-
0,
|
|
158
|
-
constants_1.ALLOWED_TIMESTAMP_LENGTH
|
|
159
|
-
)
|
|
160
|
-
const address = tsAndAddress.slice(constants_1.ALLOWED_TIMESTAMP_LENGTH)
|
|
161
|
-
const timestamp = Number.parseInt(timestampHex, 16)
|
|
97
|
+
const tsAndAddress = addressesPacked.slice(i, i + allowedTsAndResolverLen);
|
|
98
|
+
const timestampHex = tsAndAddress.slice(0, constants_1.ALLOWED_TIMESTAMP_LENGTH);
|
|
99
|
+
const address = tsAndAddress.slice(constants_1.ALLOWED_TIMESTAMP_LENGTH);
|
|
100
|
+
const timestamp = Number.parseInt(timestampHex, 16);
|
|
162
101
|
if (timestamp !== 0 && !timestamp) {
|
|
163
|
-
throw new errors_1.BadOrderSuffixError(
|
|
164
|
-
`Invalid resolver allowance timestamp`
|
|
165
|
-
)
|
|
102
|
+
throw new errors_1.BadOrderSuffixError(`Invalid resolver allowance timestamp`);
|
|
166
103
|
}
|
|
167
104
|
whitelist.push({
|
|
168
105
|
address: (0, utils_1.add0x)(address).toLowerCase(),
|
|
169
106
|
allowance: timestamp
|
|
170
|
-
})
|
|
107
|
+
});
|
|
171
108
|
}
|
|
172
109
|
return {
|
|
173
110
|
whitelist,
|
|
174
|
-
interactions: interactions.slice(
|
|
175
|
-
|
|
176
|
-
-(flags.resolversCount * allowedTsAndResolverLen)
|
|
177
|
-
)
|
|
178
|
-
}
|
|
111
|
+
interactions: interactions.slice(0, -(flags.resolversCount * allowedTsAndResolverLen))
|
|
112
|
+
};
|
|
179
113
|
}
|
|
180
|
-
exports.parseResolversWhitelist = parseResolversWhitelist
|
|
114
|
+
exports.parseResolversWhitelist = parseResolversWhitelist;
|
|
181
115
|
function parseAuctionParams(flags, interactions) {
|
|
182
116
|
if (flags.pointsCount === 0) {
|
|
183
117
|
return {
|
|
184
118
|
interactions,
|
|
185
119
|
points: []
|
|
186
|
-
}
|
|
120
|
+
};
|
|
187
121
|
}
|
|
188
|
-
const points = []
|
|
189
|
-
const auctionParamsLength =
|
|
190
|
-
|
|
191
|
-
const paramsPacked = interactions.slice(
|
|
192
|
-
-1 * flags.pointsCount * auctionParamsLength
|
|
193
|
-
)
|
|
122
|
+
const points = [];
|
|
123
|
+
const auctionParamsLength = constants_1.AUCTION_DELAY_LENGTH + constants_1.AUCTION_BUMP_LENGTH;
|
|
124
|
+
const paramsPacked = interactions.slice(-1 * flags.pointsCount * auctionParamsLength);
|
|
194
125
|
if (paramsPacked.length % auctionParamsLength) {
|
|
195
|
-
throw new errors_1.BadOrderSuffixError(
|
|
196
|
-
`Invalid auction params in interactions`
|
|
197
|
-
)
|
|
126
|
+
throw new errors_1.BadOrderSuffixError(`Invalid auction params in interactions`);
|
|
198
127
|
}
|
|
199
128
|
for (let i = 0; i < paramsPacked.length; i += auctionParamsLength) {
|
|
200
|
-
const durationAndBump = paramsPacked.slice(i, i + auctionParamsLength)
|
|
201
|
-
const durationHex = durationAndBump.slice(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
)
|
|
205
|
-
const bumpHex = durationAndBump.slice(constants_1.AUCTION_DELAY_LENGTH)
|
|
206
|
-
const duration = Number.parseInt(durationHex, 16)
|
|
129
|
+
const durationAndBump = paramsPacked.slice(i, i + auctionParamsLength);
|
|
130
|
+
const durationHex = durationAndBump.slice(0, constants_1.AUCTION_DELAY_LENGTH);
|
|
131
|
+
const bumpHex = durationAndBump.slice(constants_1.AUCTION_DELAY_LENGTH);
|
|
132
|
+
const duration = Number.parseInt(durationHex, 16);
|
|
207
133
|
if (!duration) {
|
|
208
|
-
throw new errors_1.BadOrderSuffixError(
|
|
209
|
-
`Invalid auction point duration`
|
|
210
|
-
)
|
|
134
|
+
throw new errors_1.BadOrderSuffixError(`Invalid auction point duration`);
|
|
211
135
|
}
|
|
212
|
-
const bump = Number.parseInt(bumpHex, 16)
|
|
136
|
+
const bump = Number.parseInt(bumpHex, 16);
|
|
213
137
|
if (!bump) {
|
|
214
|
-
throw new errors_1.BadOrderSuffixError(`Invalid auction point bump`)
|
|
138
|
+
throw new errors_1.BadOrderSuffixError(`Invalid auction point bump`);
|
|
215
139
|
}
|
|
216
|
-
points.push({delay: duration, coefficient: bump})
|
|
140
|
+
points.push({ delay: duration, coefficient: bump });
|
|
217
141
|
}
|
|
218
142
|
return {
|
|
219
143
|
points,
|
|
220
|
-
interactions: interactions.slice(
|
|
221
|
-
|
|
222
|
-
flags.pointsCount * auctionParamsLength
|
|
223
|
-
)
|
|
224
|
-
}
|
|
144
|
+
interactions: interactions.slice(0, flags.pointsCount * auctionParamsLength)
|
|
145
|
+
};
|
|
225
146
|
}
|
|
226
|
-
exports.parseAuctionParams = parseAuctionParams
|
|
147
|
+
exports.parseAuctionParams = parseAuctionParams;
|
|
227
148
|
function parseFlags(interactions) {
|
|
228
|
-
const flagsHex = interactions.slice(-constants_1.FLAGS_LENGTH)
|
|
149
|
+
const flagsHex = interactions.slice(-constants_1.FLAGS_LENGTH);
|
|
229
150
|
if (flagsHex.length < constants_1.FLAGS_LENGTH) {
|
|
230
|
-
throw new errors_1.BadOrderSuffixError(`Invalid flags length`)
|
|
151
|
+
throw new errors_1.BadOrderSuffixError(`Invalid flags length`);
|
|
231
152
|
}
|
|
232
|
-
const flags = Number.parseInt(flagsHex, 16)
|
|
153
|
+
const flags = Number.parseInt(flagsHex, 16);
|
|
233
154
|
if (!flags) {
|
|
234
|
-
throw new errors_1.BadOrderSuffixError(`cannot parse flags`)
|
|
155
|
+
throw new errors_1.BadOrderSuffixError(`cannot parse flags`);
|
|
235
156
|
}
|
|
236
|
-
const resolversCount =
|
|
237
|
-
(flags & constants_1.RESOLVERS_LENGTH_MASK) >>
|
|
238
|
-
constants_1.RESOLVERS_LENGTH_OFFSET
|
|
157
|
+
const resolversCount = (flags & constants_1.RESOLVERS_LENGTH_MASK) >> constants_1.RESOLVERS_LENGTH_OFFSET;
|
|
239
158
|
if (resolversCount === 0) {
|
|
240
|
-
throw new errors_1.BadOrderSuffixError(`cannot have 0 resolvers`)
|
|
159
|
+
throw new errors_1.BadOrderSuffixError(`cannot have 0 resolvers`);
|
|
241
160
|
}
|
|
242
|
-
const takingFeeEnabled = (flags & constants_1.HAS_TAKING_FEE_FLAG) !== 0
|
|
243
|
-
const pointsCount = flags & constants_1.POINTS_LENGTH_MASK
|
|
161
|
+
const takingFeeEnabled = (flags & constants_1.HAS_TAKING_FEE_FLAG) !== 0;
|
|
162
|
+
const pointsCount = flags & constants_1.POINTS_LENGTH_MASK;
|
|
244
163
|
return {
|
|
245
164
|
pointsCount,
|
|
246
165
|
takingFeeEnabled,
|
|
247
166
|
resolversCount
|
|
248
|
-
}
|
|
167
|
+
};
|
|
249
168
|
}
|
|
250
|
-
exports.parseFlags = parseFlags
|
|
251
|
-
//# sourceMappingURL=parser.js.map
|
|
169
|
+
exports.parseFlags = parseFlags;
|
|
170
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {AuctionPoint, AuctionWhitelistItem} from '../types'
|
|
1
|
+
import { AuctionPoint, AuctionWhitelistItem } from '../types';
|
|
2
2
|
export declare type InteractionAdditionalInfo = {
|
|
3
|
-
points: AuctionPoint[]
|
|
4
|
-
whitelist: AuctionWhitelistItem[]
|
|
5
|
-
publicResolvingDeadline: number
|
|
6
|
-
takerFeeReceiver: string
|
|
7
|
-
takerFeeRatio: string
|
|
8
|
-
}
|
|
3
|
+
points: AuctionPoint[];
|
|
4
|
+
whitelist: AuctionWhitelistItem[];
|
|
5
|
+
publicResolvingDeadline: number;
|
|
6
|
+
takerFeeReceiver: string;
|
|
7
|
+
takerFeeRatio: string;
|
|
8
|
+
};
|
|
9
9
|
export declare type InteractionFlags = {
|
|
10
|
-
takingFeeEnabled: boolean
|
|
11
|
-
resolversCount: number
|
|
12
|
-
pointsCount: number
|
|
13
|
-
}
|
|
10
|
+
takingFeeEnabled: boolean;
|
|
11
|
+
resolversCount: number;
|
|
12
|
+
pointsCount: number;
|
|
13
|
+
};
|
|
14
14
|
export declare type TakerFeeData = {
|
|
15
|
-
takerFeeRatio: string
|
|
16
|
-
takerFeeReceiver: string
|
|
17
|
-
} & RemainingInteractions
|
|
15
|
+
takerFeeRatio: string;
|
|
16
|
+
takerFeeReceiver: string;
|
|
17
|
+
} & RemainingInteractions;
|
|
18
18
|
export declare type PrivateAuctionDeadline = {
|
|
19
|
-
deadline: number
|
|
20
|
-
} & RemainingInteractions
|
|
19
|
+
deadline: number;
|
|
20
|
+
} & RemainingInteractions;
|
|
21
21
|
export declare type ResolversWhitelist = {
|
|
22
|
-
whitelist: AuctionWhitelistItem[]
|
|
23
|
-
} & RemainingInteractions
|
|
22
|
+
whitelist: AuctionWhitelistItem[];
|
|
23
|
+
} & RemainingInteractions;
|
|
24
24
|
export declare type ParsedAuctionParams = {
|
|
25
|
-
points: AuctionPoint[]
|
|
26
|
-
} & RemainingInteractions
|
|
25
|
+
points: AuctionPoint[];
|
|
26
|
+
} & RemainingInteractions;
|
|
27
27
|
export declare type RemainingInteractions = {
|
|
28
|
-
interactions: string
|
|
29
|
-
}
|
|
28
|
+
interactions: string;
|
|
29
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export declare type AuctionPoint = {
|
|
2
|
-
delay: number
|
|
3
|
-
coefficient: number
|
|
4
|
-
}
|
|
2
|
+
delay: number;
|
|
3
|
+
coefficient: number;
|
|
4
|
+
};
|
|
5
5
|
export declare type AuctionWhitelistItem = {
|
|
6
|
-
address: string
|
|
7
|
-
allowance: number
|
|
8
|
-
}
|
|
6
|
+
address: string;
|
|
7
|
+
allowance: number;
|
|
8
|
+
};
|
|
9
9
|
export declare type SettlementSuffixData = {
|
|
10
|
-
points: AuctionPoint[]
|
|
11
|
-
whitelist: AuctionWhitelistItem[]
|
|
12
|
-
publicResolvingDeadline?: number
|
|
13
|
-
takerFeeReceiver?: string
|
|
14
|
-
takerFeeRatio?: string
|
|
15
|
-
}
|
|
10
|
+
points: AuctionPoint[];
|
|
11
|
+
whitelist: AuctionWhitelistItem[];
|
|
12
|
+
publicResolvingDeadline?: number;
|
|
13
|
+
takerFeeReceiver?: string;
|
|
14
|
+
takerFeeRatio?: string;
|
|
15
|
+
};
|
package/auction-suffix/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {EIP712TypedData} from '../../limit-order'
|
|
1
|
+
import { EIP712TypedData } from '../../limit-order';
|
|
2
2
|
export interface BlockchainProviderConnector {
|
|
3
|
-
signTypedData(
|
|
4
|
-
|
|
5
|
-
typedData: EIP712TypedData
|
|
6
|
-
): Promise<string>
|
|
7
|
-
ethCall(contractAddress: string, callData: string): Promise<string>
|
|
3
|
+
signTypedData(walletAddress: string, typedData: EIP712TypedData): Promise<string>;
|
|
4
|
+
ethCall(contractAddress: string, callData: string): Promise<string>;
|
|
8
5
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
//# sourceMappingURL=blockchain-provider.connector.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=blockchain-provider.connector.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './blockchain-provider.connector'
|
|
2
|
-
export * from './private-key-provider.connector'
|
|
3
|
-
export * from './web3-provider-connector'
|
|
1
|
+
export * from './blockchain-provider.connector';
|
|
2
|
+
export * from './private-key-provider.connector';
|
|
3
|
+
export * from './web3-provider-connector';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const tslib_1 = require(
|
|
4
|
-
tslib_1.__exportStar(require(
|
|
5
|
-
tslib_1.__exportStar(require(
|
|
6
|
-
tslib_1.__exportStar(require(
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./blockchain-provider.connector"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./private-key-provider.connector"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./web3-provider-connector"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {BlockchainProviderConnector} from './blockchain-provider.connector'
|
|
2
|
-
import Web3 from 'web3'
|
|
3
|
-
import {EIP712TypedData} from '../../limit-order'
|
|
4
|
-
export declare class PrivateKeyProviderConnector
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
signTypedData(
|
|
12
|
-
_walletAddress: string,
|
|
13
|
-
typedData: EIP712TypedData
|
|
14
|
-
): Promise<string>
|
|
15
|
-
ethCall(contractAddress: string, callData: string): Promise<string>
|
|
1
|
+
import { BlockchainProviderConnector } from './blockchain-provider.connector';
|
|
2
|
+
import Web3 from 'web3';
|
|
3
|
+
import { EIP712TypedData } from '../../limit-order';
|
|
4
|
+
export declare class PrivateKeyProviderConnector implements BlockchainProviderConnector {
|
|
5
|
+
readonly privateKey: string;
|
|
6
|
+
protected readonly web3Provider: Web3;
|
|
7
|
+
private readonly privateKeyBuffer;
|
|
8
|
+
constructor(privateKey: string, web3Provider: Web3);
|
|
9
|
+
signTypedData(_walletAddress: string, typedData: EIP712TypedData): Promise<string>;
|
|
10
|
+
ethCall(contractAddress: string, callData: string): Promise<string>;
|
|
16
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.PrivateKeyProviderConnector = void 0
|
|
4
|
-
const eth_sig_util_1 = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivateKeyProviderConnector = void 0;
|
|
4
|
+
const eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
5
5
|
class PrivateKeyProviderConnector {
|
|
6
6
|
constructor(privateKey, web3Provider) {
|
|
7
|
-
this.privateKey = privateKey
|
|
8
|
-
this.web3Provider = web3Provider
|
|
9
|
-
this.privateKeyBuffer = Buffer.from(privateKey.replace('0x', ''), 'hex')
|
|
7
|
+
this.privateKey = privateKey;
|
|
8
|
+
this.web3Provider = web3Provider;
|
|
9
|
+
this.privateKeyBuffer = Buffer.from(privateKey.replace('0x', ''), 'hex');
|
|
10
10
|
}
|
|
11
11
|
signTypedData(_walletAddress, typedData) {
|
|
12
12
|
const result = (0, eth_sig_util_1.signTypedData)({
|
|
@@ -15,15 +15,15 @@ class PrivateKeyProviderConnector {
|
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
data: typedData,
|
|
17
17
|
version: eth_sig_util_1.SignTypedDataVersion.V4
|
|
18
|
-
})
|
|
19
|
-
return Promise.resolve(result)
|
|
18
|
+
});
|
|
19
|
+
return Promise.resolve(result);
|
|
20
20
|
}
|
|
21
21
|
ethCall(contractAddress, callData) {
|
|
22
22
|
return this.web3Provider.eth.call({
|
|
23
23
|
to: contractAddress,
|
|
24
24
|
data: callData
|
|
25
|
-
})
|
|
25
|
+
});
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
exports.PrivateKeyProviderConnector = PrivateKeyProviderConnector
|
|
29
|
-
//# sourceMappingURL=private-key-provider.connector.js.map
|
|
28
|
+
exports.PrivateKeyProviderConnector = PrivateKeyProviderConnector;
|
|
29
|
+
//# sourceMappingURL=private-key-provider.connector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|