From 6f37548bfbde9a99d8c87d0b91fc0b02db60f341 Mon Sep 17 00:00:00 2001 From: Michael Kim Date: Thu, 25 Apr 2024 17:25:55 +0900 Subject: [PATCH] [Contract] Remove KRW exchange rate --- packages/contracts-lib/package.json | 2 +- packages/contracts/contracts/currency/CurrencyRate.sol | 9 +++------ .../contracts/contracts/currency/CurrencyStorage.sol | 1 - packages/contracts/package.json | 4 ++-- packages/contracts/test/helper/Deployments.ts | 4 ++++ packages/faker/package.json | 4 ++-- packages/relay/package.json | 4 ++-- packages/relay/test/helper/Deployments.ts | 4 ++++ yarn.lock | 8 ++++---- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/contracts-lib/package.json b/packages/contracts-lib/package.json index 349123c2..e410df7b 100644 --- a/packages/contracts-lib/package.json +++ b/packages/contracts-lib/package.json @@ -1,6 +1,6 @@ { "name": "dms-osx-lib", - "version": "2.11.0", + "version": "2.12.0", "description": "", "main": "dist/bundle-cjs.js", "module": "dist/bundle-esm.js", diff --git a/packages/contracts/contracts/currency/CurrencyRate.sol b/packages/contracts/contracts/currency/CurrencyRate.sol index 172d3ae0..dc3e68d7 100644 --- a/packages/contracts/contracts/currency/CurrencyRate.sol +++ b/packages/contracts/contracts/currency/CurrencyRate.sol @@ -28,7 +28,6 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP validator = IValidator(_validator); tokenSymbol = _tokenSymbol; - rates["krw"] = MULTIPLE; rates["point"] = MULTIPLE; prevHeight = 0; @@ -89,8 +88,6 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP rates[_data[idx].symbol] = _data[idx].rate; emit SetRate(_data[idx].symbol, _data[idx].rate); } - rates["krw"] = MULTIPLE; - rates["KRW"] = MULTIPLE; rates["point"] = MULTIPLE; rates["POINT"] = MULTIPLE; } @@ -132,7 +129,7 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP /// @param _symbol 통화명 function convertCurrencyToPoint(uint256 _amount, string calldata _symbol) external view override returns (uint256) { bytes32 byteCurrency = keccak256(abi.encodePacked(_symbol)); - if ((byteCurrency == BASE_CURRENCY) || (byteCurrency == NULL_CURRENCY)) { + if (byteCurrency == NULL_CURRENCY) { return _amount; } else { return DMS.zeroGWEI((_amount * _get(_symbol)) / MULTIPLE); @@ -166,8 +163,8 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP bytes32 bSymbol1 = keccak256(abi.encodePacked(_symbol1)); bytes32 bSymbol2 = keccak256(abi.encodePacked(_symbol2)); if (bSymbol1 == bSymbol2) return _amount; - uint256 rate1 = ((bSymbol1 == BASE_CURRENCY) || (bSymbol1 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol1); - uint256 rate2 = ((bSymbol2 == BASE_CURRENCY) || (bSymbol2 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol2); + uint256 rate1 = ((bSymbol1 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol1); + uint256 rate2 = ((bSymbol2 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol2); return DMS.zeroGWEI((_amount * rate1) / rate2); } diff --git a/packages/contracts/contracts/currency/CurrencyStorage.sol b/packages/contracts/contracts/currency/CurrencyStorage.sol index 4d798946..bcd18833 100644 --- a/packages/contracts/contracts/currency/CurrencyStorage.sol +++ b/packages/contracts/contracts/currency/CurrencyStorage.sol @@ -6,7 +6,6 @@ import "../interfaces/IValidator.sol"; /// @notice 토큰 가격을 제공하는 스마트컨트랙트 contract CurrencyStorage { - bytes32 public constant BASE_CURRENCY = keccak256(abi.encodePacked("krw")); bytes32 public constant NULL_CURRENCY = keccak256(abi.encodePacked("")); uint256 public constant MULTIPLE = 1000000000; mapping(string => uint256) internal rates; diff --git a/packages/contracts/package.json b/packages/contracts/package.json index dee3f008..d003c04d 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "dms-osx-artifacts", - "version": "2.11.0", + "version": "2.12.0", "description": "Smart contracts that decentralized point systems", "files": [ "**/*.sol" @@ -67,7 +67,7 @@ }, "dependencies": { "del-osx-artifacts": "^2.3.0", - "dms-bridge-contracts": "^1.2.3", + "dms-bridge-contracts": "^1.3.0", "multisig-wallet-contracts": "^1.1.0", "loyalty-tokens": "^1.1.0" } diff --git a/packages/contracts/test/helper/Deployments.ts b/packages/contracts/test/helper/Deployments.ts index 5cb7051d..34a9a15a 100644 --- a/packages/contracts/test/helper/Deployments.ts +++ b/packages/contracts/test/helper/Deployments.ts @@ -436,6 +436,10 @@ async function deployCurrencyRate(accounts: IAccount, deployment: Deployments) { symbol: "LYT", rate: multiple.mul(150), }, + { + symbol: "krw", + rate: multiple, + }, { symbol: "usd", rate: multiple.mul(1000), diff --git a/packages/faker/package.json b/packages/faker/package.json index df7706c2..e3155f0f 100644 --- a/packages/faker/package.json +++ b/packages/faker/package.json @@ -51,8 +51,8 @@ "axios": "^1.6.7", "chai": "^4.3.7", "del-osx-artifacts": "^2.3.0", - "dms-bridge-contracts": "^1.2.3", - "dms-osx-artifacts": "^2.11.0", + "dms-bridge-contracts": "^1.3.0", + "dms-osx-artifacts": "^2.12.0", "dotenv": "^10.0.0", "ethereum-waffle": "^4.0.10", "ethers": "5.7.0", diff --git a/packages/relay/package.json b/packages/relay/package.json index f26560b6..23cbfe5b 100644 --- a/packages/relay/package.json +++ b/packages/relay/package.json @@ -70,8 +70,8 @@ "chai-http": "^4.3.7", "cors": "^2.8.5", "del-osx-artifacts": "^2.3.0", - "dms-bridge-contracts": "^1.2.3", - "dms-osx-artifacts": "^2.11.0", + "dms-bridge-contracts": "^1.3.0", + "dms-osx-artifacts": "^2.12.0", "dotenv": "^10.0.0", "ethereum-waffle": "^4.0.10", "ethereumjs-util": "^7.1.5", diff --git a/packages/relay/test/helper/Deployments.ts b/packages/relay/test/helper/Deployments.ts index 8d9fe182..0030da5a 100644 --- a/packages/relay/test/helper/Deployments.ts +++ b/packages/relay/test/helper/Deployments.ts @@ -383,6 +383,10 @@ async function deployCurrencyRate(accounts: IAccount, deployment: Deployments) { symbol: "LYT", rate: multiple.mul(150), }, + { + symbol: "krw", + rate: multiple, + }, { symbol: "usd", rate: multiple.mul(1000), diff --git a/yarn.lock b/yarn.lock index 46c245de..757c608d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3350,10 +3350,10 @@ discontinuous-range@1.0.0: resolved "https://registry.yarnpkg.com/discontinuous-range/-/discontinuous-range-1.0.0.tgz#e38331f0844bba49b9a9cb71c771585aab1bc65a" integrity sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ== -dms-bridge-contracts@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/dms-bridge-contracts/-/dms-bridge-contracts-1.2.3.tgz#e46b4aec8691ffe2b8aaff5f76247d306f8b8eae" - integrity sha512-PNFR8tQ/C6rjPR3WNJZwJjdg9AXyxusdCEvXL2izzqGSYPMIqJu+kdwNeyAHebhlq30Wrr+AxFv+iQO/HT7+/Q== +dms-bridge-contracts@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/dms-bridge-contracts/-/dms-bridge-contracts-1.3.0.tgz#ba37c2171c49571aef9184cc917e5f1570162d96" + integrity sha512-o/s8iJwRJl+tNGYN0BddojF3LbAXZG6aKnsl+qUmpo/QO3QWwx4N4LJsxgiSwDLCrcbdEBHS5kP7GwqfwO2mOA== dns-over-http-resolver@^1.2.3: version "1.2.3"