Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ cache-zk
artifacts
cache
./**/*.sol
typechain
typechainV6
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ cache-zk
artifacts
cache
typechain
typechainV6
network/volumes
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"*.{ts,js}": ["prettier --write", "eslint --cache --fix"],
"*.{ts,js}": ["prettier --write", "eslint --config ./.eslintrc --ignore-path ./.eslintignore --cache --fix"],
"*.md": ["prettier --write"]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ artifacts
cache
network
typechain
typechainV6
2 changes: 1 addition & 1 deletion deploy/001.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
protocolFee,
retailerFee,
minDeposit,
} from '../src';
} from '../utils/constants';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { network, deployments, getNamedAccounts } = hre;
Expand Down
2 changes: 1 addition & 1 deletion deploy/002.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
protocolFee,
retailerFee,
minDeposit,
} from '../src';
} from '../utils/constants';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { network, deployments, getNamedAccounts } = hre;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@
"typechain": "^8.1.1",
"@typechain/hardhat": "^6.1.6",
"@typechain/ethers-v5": "^10.2.1",
"@typechain/ethers-v6": "^0.3.2",
"dotenv": "^16.0.3"
},
"dependencies": {
"@openzeppelin/contracts-upgradeable": "^4.8.3"
},
"scripts": {
"build:contracts": "hardhat compile",
"build:src": "rm -rf ./lib && tsc -p ./tsconfig.build.json",
"build:src": "rm -rf ./lib && typechain --target=ethers-v6 --out-dir typechainV6 artifacts/**/Config.json artifacts/**/EntitiesRegistry.json artifacts/**/Market.json && tsc -p ./tsconfig.build.json",
"test:contracts": "hardhat test",
"test:src": "mocha -t 60000 --extension spec.ts test/src",
"lint": "solhint . && eslint --ext .ts",
Expand Down
27 changes: 4 additions & 23 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { utils, BigNumber } from 'ethers';

// utils.solidityKeccak256(
// ethers.solidityPackedKeccak256(
// ['string'],
// ['PaymentOption(bytes32 id,uint256 price,address asset)'],
// );
export const PAYMENT_OPTION_TYPE_HASH =
'0x2f8fc0b3ad3f58f6deb367673d38e4112a3c8c64de033c5b780b84ef8f67cde6';

// utils.solidityKeccak256(
// ethers.solidityPackedKeccak256(
// ['string'],
// ['CancelOption(uint256 time,uint256 penalty)'],
// );
export const CANCEL_OPTION_TYPE_HASH =
'0x8ea27057ea8a0239f02c8b75748218a035a5a2a2a0785b53aaa99af91ff538c5';

// utils.solidityKeccak256(
// ethers.solidityPackedKeccak256(
// ['string'],
// [
// 'Offer(bytes32 id,uint256 expire,bytes32 supplierId,uint256 chainId,bytes32 requestHash,bytes32 optionsHash,bytes32 paymentHash,bytes32 cancelHash,bool transferable,uint256 checkIn)',
Expand All @@ -23,28 +21,11 @@ export const CANCEL_OPTION_TYPE_HASH =
export const OFFER_TYPE_HASH =
'0xcf2addd2f89a78825d3f130a17e47b4e9963adfd09837fa9c454569faa073354';

// utils.solidityKeccak256(
// ethers.solidityPackedKeccak256(
// ['string'],
// [
// 'Voucher(bytes32 id,address signer)',
// ],
// );
export const CHECK_IN_TYPE_HASH =
'0xf811d7f3ddb148410001929e2cbfb7fea8779b9349b7c2f650fa91840528d69c';

// Protocol entities types (kinds) as object
export const kinds = {
supplier: utils.formatBytes32String('supplier'),
retailer: utils.formatBytes32String('retailer'),
};

// Protocol entities types (kinds) as values array
export const kindsArr = Object.values(kinds);

// Protocol defaults
export const eip712name = 'Market';
export const eip712version = '1';
export const minDeposit = BigNumber.from('1000000000000000000000');
export const claimPeriod = BigNumber.from('60');
export const protocolFee = BigNumber.from('1');
export const retailerFee = BigNumber.from('1');
2 changes: 1 addition & 1 deletion test/contracts/EntitiesRegistry.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { BigNumber, constants } from 'ethers';
import { minDeposit, kinds } from '../../src';
import { minDeposit, kinds } from '../../utils/constants';
import { randomId, createSupplierId, createPermitSignature } from './utils';
import { User, setup, registerEntity } from './setup';

Expand Down
4 changes: 2 additions & 2 deletions test/contracts/Market.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect } from 'chai';
import { BigNumber, constants } from 'ethers';
import { ethers } from 'hardhat';
import { TransferEventObject } from '../../typechain/contracts/Market';
import { kinds } from '../../src';
import { Offer } from '../../src/types';
import { kinds } from '../../utils/constants';
import { Offer } from '../../utils/types';
import {
structEqual,
buildRandomOffer,
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../typechain';
import { ethers, deployments, getNamedAccounts } from 'hardhat';
import { BigNumber, Contract, VoidSigner } from 'ethers';
import { protocolFee, retailerFee, minDeposit } from '../../src';
import { protocolFee, retailerFee, minDeposit } from '../../utils/constants';
import { structEqual, createSupplierId } from './utils';

export interface Contracts {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OfferPayload,
Offer,
Request,
} from '../../src/types';
} from '../../utils/types';

export const nonces: Record<string, number> = {
request: 1,
Expand Down
18 changes: 18 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { utils, BigNumber } from 'ethers';

// Protocol entities types (kinds) as object
export const kinds = {
supplier: utils.formatBytes32String('supplier'),
retailer: utils.formatBytes32String('retailer'),
};

// Protocol entities types (kinds) as values array
export const kindsArr = Object.values(kinds);

// Protocol defaults
export const eip712name = 'Market';
export const eip712version = '1';
export const minDeposit = BigNumber.from('1000000000000000000000');
export const claimPeriod = BigNumber.from('60');
export const protocolFee = BigNumber.from('1');
export const retailerFee = BigNumber.from('1');
2 changes: 1 addition & 1 deletion src/utils.ts → utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PAYMENT_OPTION_TYPE_HASH,
CANCEL_OPTION_TYPE_HASH,
OFFER_TYPE_HASH,
} from './constants';
} from '../src/constants';
import { MockERC20Dec18Permit } from '../typechain';
import { PaymentOption, CancelOption, OfferPayload, Offer, Request } from './types';

Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,14 @@
lodash "^4.17.15"
ts-essentials "^7.0.1"

"@typechain/ethers-v6@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@typechain/ethers-v6/-/ethers-v6-0.3.2.tgz#c7c9ed2cbe6869a131e55646ce775e3673f0c123"
integrity sha512-LUxAVAHICc6lROLf16JIl/j0FVuCQ93qLkGxlVFM1QCN5V4QRUE2scNwhKLIh8urik1c0FcvFujOPtBV4erqYg==
dependencies:
lodash "^4.17.15"
ts-essentials "^7.0.1"

"@typechain/hardhat@^6.1.6":
version "6.1.6"
resolved "https://registry.yarnpkg.com/@typechain/hardhat/-/hardhat-6.1.6.tgz#1a749eb35e5054c80df531cf440819cb347c62ea"
Expand Down