Skip to content

Commit 1f6a49b

Browse files
committed
feat: 🎸 Utils and types are added to the module exports
1 parent b94db6b commit 1f6a49b

File tree

4 files changed

+377
-4
lines changed

4 files changed

+377
-4
lines changed

src/constants.ts

+31-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
1-
// ethers.utils.solidityKeccak256(
1+
import { utils, BigNumber } from 'ethers';
2+
3+
// utils.solidityKeccak256(
24
// ['string'],
35
// ['PaymentOption(bytes32 id,uint256 price,address asset)'],
46
// );
57
export const PAYMENT_OPTION_TYPE_HASH =
68
'0x2f8fc0b3ad3f58f6deb367673d38e4112a3c8c64de033c5b780b84ef8f67cde6';
79

8-
// ethers.utils.solidityKeccak256(
10+
// utils.solidityKeccak256(
911
// ['string'],
1012
// ['CancelOption(uint256 time,uint256 penalty)'],
1113
// );
1214
export const CANCEL_OPTION_TYPE_HASH =
1315
'0x8ea27057ea8a0239f02c8b75748218a035a5a2a2a0785b53aaa99af91ff538c5';
1416

15-
// ethers.utils.solidityKeccak256(
17+
// utils.solidityKeccak256(
1618
// ['string'],
1719
// [
1820
// 'Offer(bytes32 id,uint256 expire,bytes32 supplierId,uint256 chainId,bytes32 requestHash,bytes32 optionsHash,bytes32 paymentHash,bytes32 cancelHash,bool transferable,uint256 checkIn)',
1921
// ],
2022
// );
2123
export const OFFER_TYPE_HASH =
2224
'0xcf2addd2f89a78825d3f130a17e47b4e9963adfd09837fa9c454569faa073354';
25+
26+
// utils.solidityKeccak256(
27+
// ['string'],
28+
// [
29+
// 'Voucher(bytes32 id,address signer)',
30+
// ],
31+
// );
32+
export const CHECK_IN_TYPE_HASH =
33+
'0xf811d7f3ddb148410001929e2cbfb7fea8779b9349b7c2f650fa91840528d69c';
34+
35+
// Protocol entities types (kinds) as object
36+
export const kinds = {
37+
supplier: utils.formatBytes32String('supplier'),
38+
retailer: utils.formatBytes32String('retailer'),
39+
};
40+
41+
// Protocol entities types (kinds) as values array
42+
export const kindsArr = Object.values(kinds);
43+
44+
// Protocol defaults
45+
export const eip712name = 'Market';
46+
export const eip712version = '1';
47+
export const minDeposit = BigNumber.from('1000000000000000000000');
48+
export const claimPeriod = BigNumber.from('60');
49+
export const protocolFee = BigNumber.from('1');
50+
export const retailerFee = BigNumber.from('1');

src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import ConfigJson from '../artifacts/contracts/Config.sol/Config.json';
2+
import EntitiesRegistryJson from '../artifacts/contracts/EntitiesRegistry.sol/EntitiesRegistry.json';
13
import MarketJson from '../artifacts/contracts/Market.sol/Market.json';
24

35
export * from '../typechain';
46
export * from './constants';
5-
export { MarketJson };
7+
export { ConfigJson, EntitiesRegistryJson, MarketJson };

src/types.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { BigNumber } from 'ethers';
2+
3+
export interface Request {
4+
id: string;
5+
expire: BigNumber;
6+
nonce: BigNumber;
7+
topic: string;
8+
query: unknown;
9+
}
10+
11+
export interface PaymentOption {
12+
id: string;
13+
price: BigNumber;
14+
asset: string;
15+
}
16+
17+
export interface CancelOption {
18+
time: BigNumber;
19+
penalty: BigNumber;
20+
}
21+
22+
export interface OfferPayload {
23+
id: string;
24+
expire: BigNumber;
25+
supplierId: string;
26+
chainId: BigNumber;
27+
requestHash: string;
28+
optionsHash: string;
29+
paymentHash: string;
30+
cancelHash: string;
31+
transferable: boolean;
32+
checkIn: BigNumber;
33+
checkOut: BigNumber;
34+
}
35+
36+
export interface Offer {
37+
request: Request;
38+
options: unknown;
39+
payment: PaymentOption[];
40+
cancel: CancelOption[];
41+
payload: OfferPayload;
42+
signature: string;
43+
}

0 commit comments

Comments
 (0)