Skip to content

Commit

Permalink
Change the function that creates the shop ID
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKim20 committed Oct 19, 2023
1 parent 68c11a3 commit a3b7d0b
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 21 deletions.
6 changes: 3 additions & 3 deletions packages/contracts/src/utils/ContractUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ export class ContractUtils {
return signer.signMessage(message);
}

public static getShopId(name: string, account: string): string {
public static getShopId(account: string): string {
const encodedResult = hre.ethers.utils.defaultAbiCoder.encode(
["string", "address", "bytes32"],
[name, account, crypto.randomBytes(32)]
["address", "bytes32"],
[account, crypto.randomBytes(32)]
);
return hre.ethers.utils.keccak256(encodedResult);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/02-ShopCollection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("Test for ShopCollection", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down Expand Up @@ -200,7 +200,7 @@ describe("Test for ShopCollection", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down
11 changes: 5 additions & 6 deletions packages/contracts/test/03-Ledger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { BigNumber, Wallet } from "ethers";
import * as hre from "hardhat";

import { AddressZero } from "@ethersproject/constants";
import { waffle } from "hardhat";

chai.use(solidity);

Expand Down Expand Up @@ -310,7 +309,7 @@ describe("Test for Ledger", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down Expand Up @@ -1485,7 +1484,7 @@ describe("Test for Ledger", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down Expand Up @@ -1724,7 +1723,7 @@ describe("Test for Ledger", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down Expand Up @@ -2204,7 +2203,7 @@ describe("Test for Ledger", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down Expand Up @@ -2643,7 +2642,7 @@ describe("Test for Ledger", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/faker/scripts/createShopId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IShopData } from "../src/types";
async function main() {
const shops = JSON.parse(fs.readFileSync("./src/data/shops.json", "utf8")) as IShopData[];
for (const shop of shops) {
shop.shopId = ContractUtils.getShopId(shop.name, shop.address);
shop.shopId = ContractUtils.getShopId(shop.address);
}
console.log(JSON.stringify(shops));
}
Expand Down
6 changes: 3 additions & 3 deletions packages/faker/src/utils/ContractUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ export class ContractUtils {
return signer.signMessage(message);
}

public static getShopId(name: string, account: string): string {
public static getShopId(account: string): string {
const encodedResult = hre.ethers.utils.defaultAbiCoder.encode(
["string", "address", "bytes32"],
[name, account, crypto.randomBytes(32)]
["address", "bytes32"],
[account, crypto.randomBytes(32)]
);
return hre.ethers.utils.keccak256(encodedResult);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/relay/src/utils/ContractUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ export class ContractUtils {
return res.toLowerCase() === account.toLowerCase();
}

public static getShopId(name: string, account: string): string {
public static getShopId(account: string): string {
const encodedResult = hre.ethers.utils.defaultAbiCoder.encode(
["string", "address", "bytes32"],
[name, account, crypto.randomBytes(32)]
["address", "bytes32"],
[account, crypto.randomBytes(32)]
);
return hre.ethers.utils.keccak256(encodedResult);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/test/Endpoints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe("Test of Server", function () {
context("Test token & point relay endpoints", () => {
before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/relay/test/Shop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe("Test for ShopCollection", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/relay/test/ShopWithdraw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe("Test for ShopCollection", () => {

before("Set Shop ID", async () => {
for (const elem of shopData) {
elem.shopId = ContractUtils.getShopId(elem.name, elem.wallet.address);
elem.shopId = ContractUtils.getShopId(elem.wallet.address);
}
});

Expand Down

0 comments on commit a3b7d0b

Please sign in to comment.