@1inch/fusion-sdk 0.0.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/README.md +28 -0
- package/api/fusion-api.d.ts +13 -0
- package/api/fusion-api.js +36 -0
- package/api/fusion-api.js.map +1 -0
- package/api/index.d.ts +4 -0
- package/api/index.js +8 -0
- package/api/index.js.map +1 -0
- package/api/params.d.ts +1 -0
- package/api/params.js +27 -0
- package/api/params.js.map +1 -0
- package/api/quoter/index.d.ts +5 -0
- package/api/quoter/index.js +9 -0
- package/api/quoter/index.js.map +1 -0
- package/api/quoter/preset.d.ts +15 -0
- package/api/quoter/preset.js +31 -0
- package/api/quoter/preset.js.map +1 -0
- package/api/quoter/quote/index.d.ts +3 -0
- package/api/quoter/quote/index.js +7 -0
- package/api/quoter/quote/index.js.map +1 -0
- package/api/quoter/quote/order-params.d.ts +8 -0
- package/api/quoter/quote/order-params.js +22 -0
- package/api/quoter/quote/order-params.js.map +1 -0
- package/api/quoter/quote/quote.d.ts +23 -0
- package/api/quoter/quote/quote.js +78 -0
- package/api/quoter/quote/quote.js.map +1 -0
- package/api/quoter/quote/types.d.ts +5 -0
- package/api/quoter/quote/types.js +3 -0
- package/api/quoter/quote/types.js.map +1 -0
- package/api/quoter/quoter.api.d.ts +11 -0
- package/api/quoter/quoter.api.js +30 -0
- package/api/quoter/quoter.api.js.map +1 -0
- package/api/quoter/quoter.api.spec.d.ts +1 -0
- package/api/quoter/quoter.api.spec.js +102 -0
- package/api/quoter/quoter.api.spec.js.map +1 -0
- package/api/quoter/quoter.request.d.ts +13 -0
- package/api/quoter/quoter.request.js +56 -0
- package/api/quoter/quoter.request.js.map +1 -0
- package/api/quoter/types.d.ts +54 -0
- package/api/quoter/types.js +10 -0
- package/api/quoter/types.js.map +1 -0
- package/api/relayer/index.d.ts +3 -0
- package/api/relayer/index.js +7 -0
- package/api/relayer/index.js.map +1 -0
- package/api/relayer/relayer.api.d.ts +11 -0
- package/api/relayer/relayer.api.js +23 -0
- package/api/relayer/relayer.api.js.map +1 -0
- package/api/relayer/relayer.api.spec.d.ts +1 -0
- package/api/relayer/relayer.api.spec.js +85 -0
- package/api/relayer/relayer.api.spec.js.map +1 -0
- package/api/relayer/relayer.request.d.ts +10 -0
- package/api/relayer/relayer.request.js +22 -0
- package/api/relayer/relayer.request.js.map +1 -0
- package/api/relayer/types.d.ts +11 -0
- package/api/relayer/types.js +3 -0
- package/api/relayer/types.js.map +1 -0
- package/api/types.d.ts +7 -0
- package/api/types.js +3 -0
- package/api/types.js.map +1 -0
- package/auction-calculator/auction-calculator.d.ts +19 -0
- package/auction-calculator/auction-calculator.js +71 -0
- package/auction-calculator/auction-calculator.js.map +1 -0
- package/auction-calculator/auction-calculator.spec.d.ts +1 -0
- package/auction-calculator/auction-calculator.spec.js +24 -0
- package/auction-calculator/auction-calculator.spec.js.map +1 -0
- package/auction-calculator/calc.d.ts +10 -0
- package/auction-calculator/calc.js +22 -0
- package/auction-calculator/calc.js.map +1 -0
- package/auction-calculator/constants.d.ts +1 -0
- package/auction-calculator/constants.js +5 -0
- package/auction-calculator/constants.js.map +1 -0
- package/auction-calculator/index.d.ts +3 -0
- package/auction-calculator/index.js +7 -0
- package/auction-calculator/index.js.map +1 -0
- package/auction-salt/auction-salt.d.ts +11 -0
- package/auction-salt/auction-salt.js +40 -0
- package/auction-salt/auction-salt.js.map +1 -0
- package/auction-salt/auction.salt.spec.d.ts +1 -0
- package/auction-salt/auction.salt.spec.js +59 -0
- package/auction-salt/auction.salt.spec.js.map +1 -0
- package/auction-salt/index.d.ts +3 -0
- package/auction-salt/index.js +7 -0
- package/auction-salt/index.js.map +1 -0
- package/auction-salt/parser/constants.d.ts +10 -0
- package/auction-salt/parser/constants.js +14 -0
- package/auction-salt/parser/constants.js.map +1 -0
- package/auction-salt/parser/index.d.ts +2 -0
- package/auction-salt/parser/index.js +6 -0
- package/auction-salt/parser/index.js.map +1 -0
- package/auction-salt/parser/parser.d.ts +6 -0
- package/auction-salt/parser/parser.js +34 -0
- package/auction-salt/parser/parser.js.map +1 -0
- package/auction-salt/types.d.ts +7 -0
- package/auction-salt/types.js +3 -0
- package/auction-salt/types.js.map +1 -0
- package/auction-suffix/auction-suffix.d.ts +11 -0
- package/auction-suffix/auction-suffix.js +38 -0
- package/auction-suffix/auction-suffix.js.map +1 -0
- package/auction-suffix/auction-suffix.spec.d.ts +1 -0
- package/auction-suffix/auction-suffix.spec.js +46 -0
- package/auction-suffix/auction-suffix.spec.js.map +1 -0
- package/auction-suffix/constants.d.ts +1 -0
- package/auction-suffix/constants.js +5 -0
- package/auction-suffix/constants.js.map +1 -0
- package/auction-suffix/encoder.d.ts +6 -0
- package/auction-suffix/encoder.js +45 -0
- package/auction-suffix/encoder.js.map +1 -0
- package/auction-suffix/index.d.ts +5 -0
- package/auction-suffix/index.js +9 -0
- package/auction-suffix/index.js.map +1 -0
- package/auction-suffix/parser/constants.d.ts +13 -0
- package/auction-suffix/parser/constants.js +17 -0
- package/auction-suffix/parser/constants.js.map +1 -0
- package/auction-suffix/parser/errors.d.ts +2 -0
- package/auction-suffix/parser/errors.js +7 -0
- package/auction-suffix/parser/errors.js.map +1 -0
- package/auction-suffix/parser/index.d.ts +4 -0
- package/auction-suffix/parser/index.js +8 -0
- package/auction-suffix/parser/index.js.map +1 -0
- package/auction-suffix/parser/parser.d.ts +17 -0
- package/auction-suffix/parser/parser.js +170 -0
- package/auction-suffix/parser/parser.js.map +1 -0
- package/auction-suffix/parser/types.d.ts +29 -0
- package/auction-suffix/parser/types.js +3 -0
- package/auction-suffix/parser/types.js.map +1 -0
- package/auction-suffix/types.d.ts +15 -0
- package/auction-suffix/types.js +3 -0
- package/auction-suffix/types.js.map +1 -0
- package/connector/blockchain/blockchain-provider.connector.d.ts +5 -0
- package/connector/blockchain/blockchain-provider.connector.js +3 -0
- package/connector/blockchain/blockchain-provider.connector.js.map +1 -0
- package/connector/blockchain/index.d.ts +3 -0
- package/connector/blockchain/index.js +7 -0
- package/connector/blockchain/index.js.map +1 -0
- package/connector/blockchain/private-key-provider.connector.d.ts +11 -0
- package/connector/blockchain/private-key-provider.connector.js +29 -0
- package/connector/blockchain/private-key-provider.connector.js.map +1 -0
- package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -0
- package/connector/blockchain/private-key-provider.connector.spec.js +48 -0
- package/connector/blockchain/private-key-provider.connector.spec.js.map +1 -0
- package/connector/blockchain/web3-provider-connector.d.ts +9 -0
- package/connector/blockchain/web3-provider-connector.js +28 -0
- package/connector/blockchain/web3-provider-connector.js.map +1 -0
- package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -0
- package/connector/blockchain/web3-provider.connector.spec.js +51 -0
- package/connector/blockchain/web3-provider.connector.spec.js.map +1 -0
- package/connector/http/axios-provider.connector.d.ts +5 -0
- package/connector/http/axios-provider.connector.js +21 -0
- package/connector/http/axios-provider.connector.js.map +1 -0
- package/connector/http/axios-provider.connector.spec.d.ts +1 -0
- package/connector/http/axios-provider.connector.spec.js +33 -0
- package/connector/http/axios-provider.connector.spec.js.map +1 -0
- package/connector/http/http-provider.connector.d.ts +4 -0
- package/connector/http/http-provider.connector.js +3 -0
- package/connector/http/http-provider.connector.js.map +1 -0
- package/connector/http/index.d.ts +2 -0
- package/connector/http/index.js +6 -0
- package/connector/http/index.js.map +1 -0
- package/connector/index.d.ts +2 -0
- package/connector/index.js +6 -0
- package/connector/index.js.map +1 -0
- package/constants.d.ts +10 -0
- package/constants.js +23 -0
- package/constants.js.map +1 -0
- package/fusion-order/fusion-order.d.ts +9 -0
- package/fusion-order/fusion-order.js +18 -0
- package/fusion-order/fusion-order.js.map +1 -0
- package/fusion-order/fusion-order.spec.d.ts +1 -0
- package/fusion-order/fusion-order.spec.js +52 -0
- package/fusion-order/fusion-order.spec.js.map +1 -0
- package/fusion-order/index.d.ts +1 -0
- package/fusion-order/index.js +5 -0
- package/fusion-order/index.js.map +1 -0
- package/index.d.ts +10 -0
- package/index.js +14 -0
- package/index.js.map +1 -0
- package/limit-order/eip712/domain.d.ts +11 -0
- package/limit-order/eip712/domain.js +25 -0
- package/limit-order/eip712/domain.js.map +1 -0
- package/limit-order/eip712/eip712.types.d.ts +24 -0
- package/limit-order/eip712/eip712.types.js +3 -0
- package/limit-order/eip712/eip712.types.js.map +1 -0
- package/limit-order/eip712/index.d.ts +3 -0
- package/limit-order/eip712/index.js +7 -0
- package/limit-order/eip712/index.js.map +1 -0
- package/limit-order/eip712/order-typed-data-builder.d.ts +6 -0
- package/limit-order/eip712/order-typed-data-builder.js +36 -0
- package/limit-order/eip712/order-typed-data-builder.js.map +1 -0
- package/limit-order/index.d.ts +4 -0
- package/limit-order/index.js +8 -0
- package/limit-order/index.js.map +1 -0
- package/limit-order/interactions-factory.d.ts +3 -0
- package/limit-order/interactions-factory.js +10 -0
- package/limit-order/interactions-factory.js.map +1 -0
- package/limit-order/limit-order.d.ts +27 -0
- package/limit-order/limit-order.js +89 -0
- package/limit-order/limit-order.js.map +1 -0
- package/limit-order/limit-order.spec.d.ts +1 -0
- package/limit-order/limit-order.spec.js +196 -0
- package/limit-order/limit-order.spec.js.map +1 -0
- package/limit-order/parser/constants.d.ts +10 -0
- package/limit-order/parser/constants.js +14 -0
- package/limit-order/parser/constants.js.map +1 -0
- package/limit-order/parser/index.d.ts +3 -0
- package/limit-order/parser/index.js +7 -0
- package/limit-order/parser/index.js.map +1 -0
- package/limit-order/parser/parser.d.ts +2 -0
- package/limit-order/parser/parser.js +29 -0
- package/limit-order/parser/parser.js.map +1 -0
- package/limit-order/parser/types.d.ts +3 -0
- package/limit-order/parser/types.js +3 -0
- package/limit-order/parser/types.js.map +1 -0
- package/limit-order/predicate-factory.d.ts +25 -0
- package/limit-order/predicate-factory.js +60 -0
- package/limit-order/predicate-factory.js.map +1 -0
- package/limit-order/predicate-factory.spec.d.ts +1 -0
- package/limit-order/predicate-factory.spec.js +35 -0
- package/limit-order/predicate-factory.spec.js.map +1 -0
- package/limit-order/types.d.ts +32 -0
- package/limit-order/types.js +3 -0
- package/limit-order/types.js.map +1 -0
- package/limit-order/utils.d.ts +1 -0
- package/limit-order/utils.js +8 -0
- package/limit-order/utils.js.map +1 -0
- package/package.json +80 -0
- package/sdk/index.d.ts +2 -0
- package/sdk/index.js +6 -0
- package/sdk/index.js.map +1 -0
- package/sdk/sdk.d.ts +9 -0
- package/sdk/sdk.js +70 -0
- package/sdk/sdk.js.map +1 -0
- package/sdk/types.d.ts +31 -0
- package/sdk/types.js +3 -0
- package/sdk/types.js.map +1 -0
- package/utils.d.ts +6 -0
- package/utils.js +41 -0
- package/utils.js.map +1 -0
- package/validations.d.ts +2 -0
- package/validations.js +21 -0
- package/validations.js.map +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuctionPoint, AuctionWhitelistItem } from '../types';
|
|
2
|
+
export declare type InteractionAdditionalInfo = {
|
|
3
|
+
points: AuctionPoint[];
|
|
4
|
+
whitelist: AuctionWhitelistItem[];
|
|
5
|
+
publicResolvingDeadline: number;
|
|
6
|
+
takerFeeReceiver: string;
|
|
7
|
+
takerFeeRatio: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type InteractionFlags = {
|
|
10
|
+
takingFeeEnabled: boolean;
|
|
11
|
+
resolversCount: number;
|
|
12
|
+
pointsCount: number;
|
|
13
|
+
};
|
|
14
|
+
export declare type TakerFeeData = {
|
|
15
|
+
takerFeeRatio: string;
|
|
16
|
+
takerFeeReceiver: string;
|
|
17
|
+
} & RemainingInteractions;
|
|
18
|
+
export declare type PrivateAuctionDeadline = {
|
|
19
|
+
deadline: number;
|
|
20
|
+
} & RemainingInteractions;
|
|
21
|
+
export declare type ResolversWhitelist = {
|
|
22
|
+
whitelist: AuctionWhitelistItem[];
|
|
23
|
+
} & RemainingInteractions;
|
|
24
|
+
export declare type ParsedAuctionParams = {
|
|
25
|
+
points: AuctionPoint[];
|
|
26
|
+
} & RemainingInteractions;
|
|
27
|
+
export declare type RemainingInteractions = {
|
|
28
|
+
interactions: string;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/auction-suffix/parser/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type AuctionPoint = {
|
|
2
|
+
delay: number;
|
|
3
|
+
coefficient: number;
|
|
4
|
+
};
|
|
5
|
+
export declare type AuctionWhitelistItem = {
|
|
6
|
+
address: string;
|
|
7
|
+
allowance: number;
|
|
8
|
+
};
|
|
9
|
+
export declare type SettlementSuffixData = {
|
|
10
|
+
points: AuctionPoint[];
|
|
11
|
+
whitelist: AuctionWhitelistItem[];
|
|
12
|
+
publicResolvingDeadline?: number;
|
|
13
|
+
takerFeeReceiver?: string;
|
|
14
|
+
takerFeeRatio?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auction-suffix/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockchain-provider.connector.js","sourceRoot":"","sources":["../../../src/connector/blockchain/blockchain-provider.connector.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connector/blockchain/index.ts"],"names":[],"mappings":";;;AAAA,0EAA+C;AAC/C,2EAAgD;AAChD,oEAAyC"}
|
|
@@ -0,0 +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 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>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
class PrivateKeyProviderConnector {
|
|
6
|
+
constructor(privateKey, web3Provider) {
|
|
7
|
+
this.privateKey = privateKey;
|
|
8
|
+
this.web3Provider = web3Provider;
|
|
9
|
+
this.privateKeyBuffer = Buffer.from(privateKey.replace('0x', ''), 'hex');
|
|
10
|
+
}
|
|
11
|
+
signTypedData(_walletAddress, typedData) {
|
|
12
|
+
const result = (0, eth_sig_util_1.signTypedData)({
|
|
13
|
+
privateKey: this.privateKeyBuffer,
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
data: typedData,
|
|
17
|
+
version: eth_sig_util_1.SignTypedDataVersion.V4
|
|
18
|
+
});
|
|
19
|
+
return Promise.resolve(result);
|
|
20
|
+
}
|
|
21
|
+
ethCall(contractAddress, callData) {
|
|
22
|
+
return this.web3Provider.eth.call({
|
|
23
|
+
to: contractAddress,
|
|
24
|
+
data: callData
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.PrivateKeyProviderConnector = PrivateKeyProviderConnector;
|
|
29
|
+
//# sourceMappingURL=private-key-provider.connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-key-provider.connector.js","sourceRoot":"","sources":["../../../src/connector/blockchain/private-key-provider.connector.ts"],"names":[],"mappings":";;;AAEA,yDAA0E;AAG1E,MAAa,2BAA2B;IAKpC,YACa,UAAkB,EACR,YAAkB;QAD5B,eAAU,GAAV,UAAU,CAAQ;QACR,iBAAY,GAAZ,YAAY,CAAM;QAErC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;IAC5E,CAAC;IAED,aAAa,CACT,cAAsB,EACtB,SAA0B;QAE1B,MAAM,MAAM,GAAG,IAAA,4BAAa,EAAC;YACzB,UAAU,EAAE,IAAI,CAAC,gBAAgB;YACjC,6DAA6D;YAC7D,aAAa;YACb,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,mCAAoB,CAAC,EAAE;SACnC,CAAC,CAAA;QAEF,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,CAAC,eAAuB,EAAE,QAAgB;QAC7C,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAC9B,EAAE,EAAE,eAAe;YACnB,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAA;IACN,CAAC;CACJ;AAjCD,kEAiCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const ts_mockito_1 = require("ts-mockito");
|
|
5
|
+
const private_key_provider_connector_1 = require("./private-key-provider.connector");
|
|
6
|
+
const limit_order_1 = require("../../limit-order");
|
|
7
|
+
describe('Private Key provider connector', () => {
|
|
8
|
+
let web3Provider;
|
|
9
|
+
let privateKeyProviderConnector;
|
|
10
|
+
const testPrivateKey = '0xd8d1f95deb28949ea0ecc4e9a0decf89e98422c2d76ab6e5f736792a388c56c7';
|
|
11
|
+
const limitOrder = {
|
|
12
|
+
salt: '618054093254',
|
|
13
|
+
makerAsset: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
|
|
14
|
+
takerAsset: '0x111111111117dc0aa78b770fa6a738034120c302',
|
|
15
|
+
maker: '0xfb3c7eb936cAA12B5A884d612393969A557d4307',
|
|
16
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
17
|
+
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
18
|
+
makingAmount: '1000000000000000000',
|
|
19
|
+
takingAmount: '1000000000000000000',
|
|
20
|
+
offsets: '9813420589127697917471531885823684359047649055178615469676279994777600',
|
|
21
|
+
// eslint-disable-next-line max-len
|
|
22
|
+
interactions: '0x20b83f2d0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400007e2d21830000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000bfa7514300000000000000000000000000000000000000000000000000000068000000240000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006863592c2b0000000000000000000000000000000000000000000000000000000063593ad9cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d43070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
|
|
23
|
+
};
|
|
24
|
+
const typedData = {
|
|
25
|
+
primaryType: 'Order',
|
|
26
|
+
types: {
|
|
27
|
+
EIP712Domain: limit_order_1.EIP712Domain,
|
|
28
|
+
Order: limit_order_1.Order
|
|
29
|
+
},
|
|
30
|
+
domain: {
|
|
31
|
+
name: limit_order_1.LimitOrderV3TypeDataName,
|
|
32
|
+
version: limit_order_1.LimitOrderV3TypeDataVersion,
|
|
33
|
+
chainId: 1,
|
|
34
|
+
verifyingContract: limit_order_1.VerifyingContract
|
|
35
|
+
},
|
|
36
|
+
message: limitOrder
|
|
37
|
+
};
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
web3Provider = (0, ts_mockito_1.mock)();
|
|
40
|
+
privateKeyProviderConnector = new private_key_provider_connector_1.PrivateKeyProviderConnector(testPrivateKey, (0, ts_mockito_1.instance)(web3Provider));
|
|
41
|
+
});
|
|
42
|
+
it('should sign typed data by private key', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const walletAddress = '0xa07c1d51497fb6e66aa2329cecb86fca0a957fdb';
|
|
44
|
+
const signature = yield privateKeyProviderConnector.signTypedData(walletAddress, typedData);
|
|
45
|
+
expect(signature).toBe('0x464f41de691938f7aaec6a157abb072684c7ba9ba5fe631b53e09ba6b66e5d0b5029927710662a15ba6f157d3269ed368447542240bdbcb8c433450caf84c93e1c');
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=private-key-provider.connector.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-key-provider.connector.spec.js","sourceRoot":"","sources":["../../../src/connector/blockchain/private-key-provider.connector.spec.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC,qFAA4E;AAC5E,mDAQ0B;AAE1B,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC5C,IAAI,YAAkB,CAAA;IACtB,IAAI,2BAAwD,CAAA;IAE5D,MAAM,cAAc,GAChB,oEAAoE,CAAA;IAExE,MAAM,UAAU,GAAuB;QACnC,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,4CAA4C;QACxD,UAAU,EAAE,4CAA4C;QACxD,KAAK,EAAE,4CAA4C;QACnD,QAAQ,EAAE,4CAA4C;QACtD,aAAa,EAAE,4CAA4C;QAC3D,YAAY,EAAE,qBAAqB;QACnC,YAAY,EAAE,qBAAqB;QACnC,OAAO,EACH,wEAAwE;QAC5E,mCAAmC;QACnC,YAAY,EACR,4tBAA4tB;KACnuB,CAAA;IAED,MAAM,SAAS,GAAoB;QAC/B,WAAW,EAAE,OAAO;QACpB,KAAK,EAAE;YACH,YAAY,EAAE,0BAAY;YAC1B,KAAK,EAAE,mBAAK;SACf;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,sCAAwB;YAC9B,OAAO,EAAE,yCAA2B;YACpC,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,+BAAiB;SACvC;QACD,OAAO,EAAE,UAAU;KACtB,CAAA;IAED,UAAU,CAAC,GAAG,EAAE;QACZ,YAAY,GAAG,IAAA,iBAAI,GAAQ,CAAA;QAC3B,2BAA2B,GAAG,IAAI,4DAA2B,CACzD,cAAc,EACd,IAAA,qBAAQ,EAAC,YAAY,CAAC,CACzB,CAAA;IACL,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uCAAuC,EAAE,GAAS,EAAE;QACnD,MAAM,aAAa,GAAG,4CAA4C,CAAA;QAElE,MAAM,SAAS,GAAG,MAAM,2BAA2B,CAAC,aAAa,CAC7D,aAAa,EACb,SAAS,CACZ,CAAA;QAED,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAClB,sIAAsI,CACzI,CAAA;IACL,CAAC,CAAA,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BlockchainProviderConnector } from './blockchain-provider.connector';
|
|
2
|
+
import Web3 from 'web3';
|
|
3
|
+
import { EIP712TypedData } from '../../limit-order';
|
|
4
|
+
export declare class Web3ProviderConnector implements BlockchainProviderConnector {
|
|
5
|
+
protected readonly web3Provider: Web3;
|
|
6
|
+
constructor(web3Provider: Web3);
|
|
7
|
+
signTypedData(walletAddress: string, typedData: EIP712TypedData): Promise<string>;
|
|
8
|
+
ethCall(contractAddress: string, callData: string): Promise<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Web3ProviderConnector = void 0;
|
|
4
|
+
class Web3ProviderConnector {
|
|
5
|
+
constructor(web3Provider) {
|
|
6
|
+
this.web3Provider = web3Provider;
|
|
7
|
+
}
|
|
8
|
+
signTypedData(walletAddress, typedData) {
|
|
9
|
+
const extendedWeb3 = this.web3Provider.extend({
|
|
10
|
+
methods: [
|
|
11
|
+
{
|
|
12
|
+
name: 'signTypedDataV4',
|
|
13
|
+
call: 'eth_signTypedData_v4',
|
|
14
|
+
params: 2
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
return extendedWeb3.signTypedDataV4(walletAddress, JSON.stringify(typedData));
|
|
19
|
+
}
|
|
20
|
+
ethCall(contractAddress, callData) {
|
|
21
|
+
return this.web3Provider.eth.call({
|
|
22
|
+
to: contractAddress,
|
|
23
|
+
data: callData
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Web3ProviderConnector = Web3ProviderConnector;
|
|
28
|
+
//# sourceMappingURL=web3-provider-connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3-provider-connector.js","sourceRoot":"","sources":["../../../src/connector/blockchain/web3-provider-connector.ts"],"names":[],"mappings":";;;AAQA,MAAa,qBAAqB;IAC9B,YAA+B,YAAkB;QAAlB,iBAAY,GAAZ,YAAY,CAAM;IAAG,CAAC;IAErD,aAAa,CACT,aAAqB,EACrB,SAA0B;QAE1B,MAAM,YAAY,GAAiB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YACxD,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,iBAAiB;oBACvB,IAAI,EAAE,sBAAsB;oBAC5B,MAAM,EAAE,CAAC;iBACZ;aACJ;SACJ,CAAC,CAAA;QAEF,OAAO,YAAY,CAAC,eAAe,CAC/B,aAAa,EACb,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAC5B,CAAA;IACL,CAAC;IAED,OAAO,CAAC,eAAuB,EAAE,QAAgB;QAC7C,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAC9B,EAAE,EAAE,eAAe;YACnB,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAA;IACN,CAAC;CACJ;AA7BD,sDA6BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const ts_mockito_1 = require("ts-mockito");
|
|
5
|
+
const limit_order_1 = require("../../limit-order");
|
|
6
|
+
const web3_provider_connector_1 = require("./web3-provider-connector");
|
|
7
|
+
describe('Web3 provider connector', () => {
|
|
8
|
+
let web3Provider;
|
|
9
|
+
let web3ProviderConnector;
|
|
10
|
+
const limitOrder = {
|
|
11
|
+
salt: '618054093254',
|
|
12
|
+
makerAsset: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
|
|
13
|
+
takerAsset: '0x111111111117dc0aa78b770fa6a738034120c302',
|
|
14
|
+
maker: '0xfb3c7eb936cAA12B5A884d612393969A557d4307',
|
|
15
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
16
|
+
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
17
|
+
makingAmount: '1000000000000000000',
|
|
18
|
+
takingAmount: '1000000000000000000',
|
|
19
|
+
offsets: '9813420589127697917471531885823684359047649055178615469676279994777600',
|
|
20
|
+
// eslint-disable-next-line max-len
|
|
21
|
+
interactions: '0x20b83f2d0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400007e2d21830000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000bfa7514300000000000000000000000000000000000000000000000000000068000000240000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006863592c2b0000000000000000000000000000000000000000000000000000000063593ad9cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d43070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
|
|
22
|
+
};
|
|
23
|
+
const typedData = {
|
|
24
|
+
primaryType: 'Order',
|
|
25
|
+
types: {
|
|
26
|
+
EIP712Domain: limit_order_1.EIP712Domain,
|
|
27
|
+
Order: limit_order_1.Order
|
|
28
|
+
},
|
|
29
|
+
domain: {
|
|
30
|
+
name: limit_order_1.LimitOrderV3TypeDataName,
|
|
31
|
+
version: limit_order_1.LimitOrderV3TypeDataVersion,
|
|
32
|
+
chainId: 1,
|
|
33
|
+
verifyingContract: limit_order_1.VerifyingContract
|
|
34
|
+
},
|
|
35
|
+
message: limitOrder
|
|
36
|
+
};
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
web3Provider = (0, ts_mockito_1.mock)();
|
|
39
|
+
web3ProviderConnector = new web3_provider_connector_1.Web3ProviderConnector((0, ts_mockito_1.instance)(web3Provider));
|
|
40
|
+
});
|
|
41
|
+
it('should call eth_signTypedData_v4 rpc method', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
const walletAddress = '0xasd';
|
|
43
|
+
const extendedWeb3 = {
|
|
44
|
+
signTypedDataV4: jest.fn()
|
|
45
|
+
};
|
|
46
|
+
(0, ts_mockito_1.when)(web3Provider.extend((0, ts_mockito_1.anything)())).thenReturn(extendedWeb3);
|
|
47
|
+
yield web3ProviderConnector.signTypedData(walletAddress, typedData);
|
|
48
|
+
expect(extendedWeb3.signTypedDataV4).toHaveBeenCalledWith(walletAddress, JSON.stringify(typedData));
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=web3-provider.connector.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3-provider.connector.spec.js","sourceRoot":"","sources":["../../../src/connector/blockchain/web3-provider.connector.spec.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AAEzD,mDAQ0B;AAC1B,uEAA+D;AAE/D,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACrC,IAAI,YAAkB,CAAA;IACtB,IAAI,qBAA4C,CAAA;IAEhD,MAAM,UAAU,GAAuB;QACnC,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,4CAA4C;QACxD,UAAU,EAAE,4CAA4C;QACxD,KAAK,EAAE,4CAA4C;QACnD,QAAQ,EAAE,4CAA4C;QACtD,aAAa,EAAE,4CAA4C;QAC3D,YAAY,EAAE,qBAAqB;QACnC,YAAY,EAAE,qBAAqB;QACnC,OAAO,EACH,wEAAwE;QAC5E,mCAAmC;QACnC,YAAY,EACR,4tBAA4tB;KACnuB,CAAA;IAED,MAAM,SAAS,GAAoB;QAC/B,WAAW,EAAE,OAAO;QACpB,KAAK,EAAE;YACH,YAAY,EAAE,0BAAY;YAC1B,KAAK,EAAE,mBAAK;SACf;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,sCAAwB;YAC9B,OAAO,EAAE,yCAA2B;YACpC,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,+BAAiB;SACvC;QACD,OAAO,EAAE,UAAU;KACtB,CAAA;IAED,UAAU,CAAC,GAAG,EAAE;QACZ,YAAY,GAAG,IAAA,iBAAI,GAAQ,CAAA;QAC3B,qBAAqB,GAAG,IAAI,+CAAqB,CAC7C,IAAA,qBAAQ,EAAC,YAAY,CAAC,CACzB,CAAA;IACL,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAS,EAAE;QACzD,MAAM,aAAa,GAAG,OAAO,CAAA;QAE7B,MAAM,YAAY,GAAG;YACjB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;SAC7B,CAAA;QAED,IAAA,iBAAI,EAAC,YAAY,CAAC,MAAM,CAAC,IAAA,qBAAQ,GAAE,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;QAE9D,MAAM,qBAAqB,CAAC,aAAa,CAAC,aAAa,EAAE,SAAS,CAAC,CAAA;QAEnE,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,oBAAoB,CACrD,aAAa,EACb,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAC5B,CAAA;IACL,CAAC,CAAA,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AxiosProviderConnector = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
class AxiosProviderConnector {
|
|
7
|
+
get(url) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const res = yield axios_1.default.get(url);
|
|
10
|
+
return res.data;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
post(url, data) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const res = yield axios_1.default.post(url, data);
|
|
16
|
+
return res.data;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.AxiosProviderConnector = AxiosProviderConnector;
|
|
21
|
+
//# sourceMappingURL=axios-provider.connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-provider.connector.js","sourceRoot":"","sources":["../../../src/connector/http/axios-provider.connector.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,MAAa,sBAAsB;IACzB,GAAG,CAAI,GAAW;;YACpB,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,GAAG,CAAI,GAAG,CAAC,CAAA;YAEnC,OAAO,GAAG,CAAC,IAAI,CAAA;QACnB,CAAC;KAAA;IAEK,IAAI,CAAI,GAAW,EAAE,IAAa;;YACpC,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,IAAI,CAAI,GAAG,EAAE,IAAI,CAAC,CAAA;YAE1C,OAAO,GAAG,CAAC,IAAI,CAAA;QACnB,CAAC;KAAA;CACJ;AAZD,wDAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const axios_provider_connector_1 = require("./axios-provider.connector");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
describe('Axios Http provider connector', () => {
|
|
7
|
+
let httpConnector;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
httpConnector = new axios_provider_connector_1.AxiosProviderConnector();
|
|
10
|
+
});
|
|
11
|
+
it('should make get() request', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const url = 'https://123.com/test/?val=1';
|
|
13
|
+
const returnedValue = {
|
|
14
|
+
data: { a: 1 }
|
|
15
|
+
};
|
|
16
|
+
jest.spyOn(axios_1.default, 'get').mockImplementationOnce(() => Promise.resolve(returnedValue));
|
|
17
|
+
const res = yield httpConnector.get(url);
|
|
18
|
+
expect(res).toStrictEqual(returnedValue.data);
|
|
19
|
+
expect(axios_1.default.get).toHaveBeenCalledWith(url);
|
|
20
|
+
}));
|
|
21
|
+
it('should make post() request', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const url = 'https://123.com/test/?val=1';
|
|
23
|
+
const body = { info: 123 };
|
|
24
|
+
const returnedValue = {
|
|
25
|
+
data: { a: 1 }
|
|
26
|
+
};
|
|
27
|
+
jest.spyOn(axios_1.default, 'post').mockImplementationOnce(() => Promise.resolve(returnedValue));
|
|
28
|
+
const res = yield httpConnector.post(url, body);
|
|
29
|
+
expect(res).toStrictEqual(returnedValue.data);
|
|
30
|
+
expect(axios_1.default.post).toHaveBeenCalledWith(url, body);
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=axios-provider.connector.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-provider.connector.spec.js","sourceRoot":"","sources":["../../../src/connector/http/axios-provider.connector.spec.ts"],"names":[],"mappings":";;;AAAA,yEAAiE;AACjE,0DAAyB;AAEzB,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC3C,IAAI,aAAqC,CAAA;IAEzC,UAAU,CAAC,GAAG,EAAE;QACZ,aAAa,GAAG,IAAI,iDAAsB,EAAE,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2BAA2B,EAAE,GAAS,EAAE;QACvC,MAAM,GAAG,GAAG,6BAA6B,CAAA;QACzC,MAAM,aAAa,GAAG;YAClB,IAAI,EAAE,EAAC,CAAC,EAAE,CAAC,EAAC;SACf,CAAA;QACD,IAAI,CAAC,KAAK,CAAC,eAAK,EAAE,KAAK,CAAC,CAAC,sBAAsB,CAAC,GAAG,EAAE,CACjD,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CACjC,CAAA;QACD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACxC,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QAC7C,MAAM,CAAC,eAAK,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,4BAA4B,EAAE,GAAS,EAAE;QACxC,MAAM,GAAG,GAAG,6BAA6B,CAAA;QACzC,MAAM,IAAI,GAAG,EAAC,IAAI,EAAE,GAAG,EAAC,CAAA;QACxB,MAAM,aAAa,GAAG;YAClB,IAAI,EAAE,EAAC,CAAC,EAAE,CAAC,EAAC;SACf,CAAA;QACD,IAAI,CAAC,KAAK,CAAC,eAAK,EAAE,MAAM,CAAC,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAClD,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CACjC,CAAA;QACD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAC/C,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QAC7C,MAAM,CAAC,eAAK,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC,CAAA,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-provider.connector.js","sourceRoot":"","sources":["../../../src/connector/http/http-provider.connector.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./http-provider.connector"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./axios-provider.connector"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connector/http/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyC;AACzC,qEAA0C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./blockchain/index"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./http/index"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,uDAA4B"}
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const NATIVE_CURRENCY = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
2
|
+
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
3
|
+
export declare const ZX = "0x";
|
|
4
|
+
export declare enum NetworkEnum {
|
|
5
|
+
ETHEREUM = 1,
|
|
6
|
+
POLYGON = 137,
|
|
7
|
+
BINANCE = 56
|
|
8
|
+
}
|
|
9
|
+
export declare const WRAPPER_ADDRESS_MAP: Record<NetworkEnum, string>;
|
|
10
|
+
export declare const UNWRAPPER_CONTRACT_ADDRESS_MAP: Record<NetworkEnum, string>;
|
package/constants.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNWRAPPER_CONTRACT_ADDRESS_MAP = exports.WRAPPER_ADDRESS_MAP = exports.NetworkEnum = exports.ZX = exports.ZERO_ADDRESS = exports.NATIVE_CURRENCY = void 0;
|
|
4
|
+
exports.NATIVE_CURRENCY = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
|
|
5
|
+
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
6
|
+
exports.ZX = '0x';
|
|
7
|
+
var NetworkEnum;
|
|
8
|
+
(function (NetworkEnum) {
|
|
9
|
+
NetworkEnum[NetworkEnum["ETHEREUM"] = 1] = "ETHEREUM";
|
|
10
|
+
NetworkEnum[NetworkEnum["POLYGON"] = 137] = "POLYGON";
|
|
11
|
+
NetworkEnum[NetworkEnum["BINANCE"] = 56] = "BINANCE";
|
|
12
|
+
})(NetworkEnum = exports.NetworkEnum || (exports.NetworkEnum = {}));
|
|
13
|
+
exports.WRAPPER_ADDRESS_MAP = {
|
|
14
|
+
[NetworkEnum.ETHEREUM]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
15
|
+
[NetworkEnum.BINANCE]: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
|
|
16
|
+
[NetworkEnum.POLYGON]: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'
|
|
17
|
+
};
|
|
18
|
+
exports.UNWRAPPER_CONTRACT_ADDRESS_MAP = {
|
|
19
|
+
[NetworkEnum.ETHEREUM]: '0x08b067ad41e45babe5bbb52fc2fe7f692f628b06',
|
|
20
|
+
[NetworkEnum.BINANCE]: '0x0eee00137d807a461702e9e0640c599de663e7e4',
|
|
21
|
+
[NetworkEnum.POLYGON]: '0x18d410f651289bb978fc32f90d2d7e608f4f4560'
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=constants.js.map
|
package/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,4CAA4C,CAAA;AAC9D,QAAA,YAAY,GAAG,4CAA4C,CAAA;AAC3D,QAAA,EAAE,GAAG,IAAI,CAAA;AAEtB,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,qDAAY,CAAA;IACZ,qDAAa,CAAA;IACb,oDAAY,CAAA;AAChB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAEY,QAAA,mBAAmB,GAAgC;IAC5D,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,4CAA4C;IACpE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,4CAA4C;IACnE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,4CAA4C;CACtE,CAAA;AAEY,QAAA,8BAA8B,GAAgC;IACvE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,4CAA4C;IACpE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,4CAA4C;IACnE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,4CAA4C;CACtE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuctionSalt } from '../auction-salt';
|
|
2
|
+
import { AuctionSuffix } from '../auction-suffix';
|
|
3
|
+
import { LimitOrder, InteractionsData, LimitOrderV3Struct, OrderInfoData } from '../limit-order';
|
|
4
|
+
export declare class FusionOrder extends LimitOrder {
|
|
5
|
+
private readonly auction;
|
|
6
|
+
private readonly auctionSuffix;
|
|
7
|
+
constructor(orderInfo: OrderInfoData, auction: AuctionSalt, auctionSuffix: AuctionSuffix, interactions?: InteractionsData);
|
|
8
|
+
build(): LimitOrderV3Struct;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FusionOrder = void 0;
|
|
4
|
+
const limit_order_1 = require("../limit-order");
|
|
5
|
+
class FusionOrder extends limit_order_1.LimitOrder {
|
|
6
|
+
constructor(orderInfo, auction, auctionSuffix, interactions) {
|
|
7
|
+
super(orderInfo, interactions);
|
|
8
|
+
this.auction = auction;
|
|
9
|
+
this.auctionSuffix = auctionSuffix;
|
|
10
|
+
}
|
|
11
|
+
build() {
|
|
12
|
+
this.salt = this.auction.build();
|
|
13
|
+
const order = super.build();
|
|
14
|
+
return Object.assign(Object.assign({}, order), { interactions: order.interactions + this.auctionSuffix.build() });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.FusionOrder = FusionOrder;
|
|
18
|
+
//# sourceMappingURL=fusion-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusion-order.js","sourceRoot":"","sources":["../../src/fusion-order/fusion-order.ts"],"names":[],"mappings":";;;AAEA,gDAKuB;AAEvB,MAAa,WAAY,SAAQ,wBAAU;IACvC,YACI,SAAwB,EACP,OAAoB,EACpB,aAA4B,EAC7C,YAA+B;QAE/B,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;QAJb,YAAO,GAAP,OAAO,CAAa;QACpB,kBAAa,GAAb,aAAa,CAAe;IAIjD,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAE3B,uCACO,KAAK,KACR,YAAY,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAChE;IACL,CAAC;CACJ;AAnBD,kCAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const fusion_order_1 = require("./fusion-order");
|
|
5
|
+
const auction_salt_1 = require("../auction-salt");
|
|
6
|
+
const auction_suffix_1 = require("../auction-suffix");
|
|
7
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
8
|
+
describe('Fusion Order', () => {
|
|
9
|
+
jest.spyOn(crypto_1.default, 'randomInt').mockImplementation(() => 10000);
|
|
10
|
+
it('should create fusion order', () => {
|
|
11
|
+
const salt = new auction_salt_1.AuctionSalt({
|
|
12
|
+
duration: 180,
|
|
13
|
+
auctionStartTime: 1673548149,
|
|
14
|
+
initialRateBump: 50000,
|
|
15
|
+
bankFee: '0'
|
|
16
|
+
});
|
|
17
|
+
const suffix = new auction_suffix_1.AuctionSuffix({
|
|
18
|
+
points: [
|
|
19
|
+
{
|
|
20
|
+
coefficient: 20000,
|
|
21
|
+
delay: 12
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
whitelist: [
|
|
25
|
+
{
|
|
26
|
+
address: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
27
|
+
allowance: 0
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
const order = new fusion_order_1.FusionOrder({
|
|
32
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
33
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
34
|
+
makingAmount: '1000000000000000000',
|
|
35
|
+
takingAmount: '1420000000',
|
|
36
|
+
maker: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
37
|
+
}, salt, suffix);
|
|
38
|
+
expect(order.build()).toStrictEqual({
|
|
39
|
+
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
40
|
+
interactions: '0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
|
|
41
|
+
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
42
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
43
|
+
makingAmount: '1000000000000000000',
|
|
44
|
+
offsets: '0',
|
|
45
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
46
|
+
salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
|
|
47
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
48
|
+
takingAmount: '1420000000'
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=fusion-order.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusion-order.spec.js","sourceRoot":"","sources":["../../src/fusion-order/fusion-order.spec.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAC1C,kDAA2C;AAC3C,sDAA+C;AAC/C,4DAA2B;AAE3B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,KAAK,CAAC,gBAAM,EAAE,WAAW,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IAE/D,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAClC,MAAM,IAAI,GAAG,IAAI,0BAAW,CAAC;YACzB,QAAQ,EAAE,GAAG;YACb,gBAAgB,EAAE,UAAU;YAC5B,eAAe,EAAE,KAAK;YACtB,OAAO,EAAE,GAAG;SACf,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,IAAI,8BAAa,CAAC;YAC7B,MAAM,EAAE;gBACJ;oBACI,WAAW,EAAE,KAAK;oBAClB,KAAK,EAAE,EAAE;iBACZ;aACJ;YACD,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,4CAA4C;oBACrD,SAAS,EAAE,CAAC;iBACf;aACJ;SACJ,CAAC,CAAA;QAEF,MAAM,KAAK,GAAG,IAAI,0BAAW,CACzB;YACI,UAAU,EAAE,4CAA4C;YACxD,UAAU,EAAE,4CAA4C;YACxD,YAAY,EAAE,qBAAqB;YACnC,YAAY,EAAE,YAAY;YAC1B,KAAK,EAAE,4CAA4C;SACtD,EACD,IAAI,EACJ,MAAM,CACT,CAAA;QAED,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC;YAChC,aAAa,EAAE,4CAA4C;YAC3D,YAAY,EACR,wEAAwE;YAC5E,KAAK,EAAE,4CAA4C;YACnD,UAAU,EAAE,4CAA4C;YACxD,YAAY,EAAE,qBAAqB;YACnC,OAAO,EAAE,GAAG;YACZ,QAAQ,EAAE,4CAA4C;YACtD,IAAI,EAAE,+EAA+E;YACrF,UAAU,EAAE,4CAA4C;YACxD,YAAY,EAAE,YAAY;SAC7B,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fusion-order';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fusion-order/index.ts"],"names":[],"mappings":";;;AAAA,yDAA8B"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './auction-suffix/index';
|
|
2
|
+
export * from './auction-salt/index';
|
|
3
|
+
export * from './fusion-order/index';
|
|
4
|
+
export * from './limit-order/index';
|
|
5
|
+
export * from './auction-calculator/index';
|
|
6
|
+
export * from './connector/index';
|
|
7
|
+
export * from './sdk/index';
|
|
8
|
+
export * from './constants';
|
|
9
|
+
export * from './utils';
|
|
10
|
+
export * from './validations';
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./auction-suffix/index"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./auction-salt/index"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./fusion-order/index"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./limit-order/index"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./auction-calculator/index"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./connector/index"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./sdk/index"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./validations"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,+DAAoC;AACpC,+DAAoC;AACpC,8DAAmC;AACnC,qEAA0C;AAC1C,4DAAiC;AACjC,sDAA2B;AAC3B,sDAA2B;AAC3B,kDAAuB;AACvB,wDAA6B"}
|