Skip to content

Commit

Permalink
Apply version 2.0.0 of loyalty-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKim20 committed May 23, 2024
1 parent 81b0729 commit 275930b
Show file tree
Hide file tree
Showing 42 changed files with 952 additions and 245 deletions.
19 changes: 10 additions & 9 deletions active_contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
},
"loyalty_devnet": {
"LoyaltyToken": "0xB1A90a5C6e30d64Ab6f64C30eD392F46eDBcb022",
"Validator": "0x4Ca91738C7cD24895467c6d550D96BE8dC4b33AA",
"CurrencyRate": "0x979a62090BDCff36F2e140F6915fbAdA7510cb6a",
"LoyaltyBurner": "0x5B4f8F9566706D4dB7f5E3020cE0485f96415749",
"LoyaltyProvider": "0xDD91A65534847537c290FEbc721cf8457f860744",
"LoyaltyConsumer": "0xb9CE93eeb00a74Deeec319cBCD37938b5aAE6314",
"LoyaltyExchanger": "0x1ae7b2564Ae7a7Fb1E7976F3F71cAF43ef49ac6F",
"PhoneLinkCollection": "0x4Ca91738C7cD24895467c6d550D96BE8dC4b33AA",
"Validator": "0x979a62090BDCff36F2e140F6915fbAdA7510cb6a",
"CurrencyRate": "0x5B4f8F9566706D4dB7f5E3020cE0485f96415749",
"LoyaltyBurner": "0xDD91A65534847537c290FEbc721cf8457f860744",
"LoyaltyProvider": "0xb9CE93eeb00a74Deeec319cBCD37938b5aAE6314",
"LoyaltyConsumer": "0x1ae7b2564Ae7a7Fb1E7976F3F71cAF43ef49ac6F",
"LoyaltyExchanger": "0xd73e6a2f2e47236F1Ff737E72497f598652122F9",
"LoyaltyTransfer": "0xcAE5A9f266991dcEdc62bb9291f15E112f212820",
"BridgeValidator": "0xE7D4f38Fad1C1C5EAA8A1280678B860a7A9519c1",
"LoyaltyBridge": "0xd73e6a2f2e47236F1Ff737E72497f598652122F9",
"Shop": "0xB4B0d4D6aAd2f963CC2FaeCBb4B8C94C3eeE6DB8",
"Ledger": "0xcAde85D03A2ABd41b608004BBB25440D28C64912"
"LoyaltyBridge": "0xB4B0d4D6aAd2f963CC2FaeCBb4B8C94C3eeE6DB8",
"Shop": "0x0c6B5326058F28Daf7D9ED40Ff2e3755a0bb664d",
"Ledger": "0x0E41917eBc8e06f01e47693a3D79Da136c10A1Eb"
}
}
4 changes: 2 additions & 2 deletions packages/contracts-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dms-osx-lib",
"version": "2.14.0",
"name": "dms-contracts-lib-v2",
"version": "2.0.0",
"description": "",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts/contracts/Reference.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import "multisig-wallet-contracts/contracts/MultiSigWallet.sol";
import "loyalty-tokens/contracts/LoyaltyToken.sol";
import "loyalty-tokens/contracts/LYT.sol";

import "dms-bridge-contracts/contracts/interfaces/IBridge.sol";
import "dms-bridge-contracts/contracts/interfaces/IBridgeLiquidity.sol";
import "dms-bridge-contracts/contracts/interfaces/IBridgeValidator.sol";
import "dms-bridge-contracts/contracts/bridge/Bridge.sol";
import "dms-bridge-contracts/contracts/bridge/BridgeValidator.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridge.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridgeLiquidity.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridgeValidator.sol";
import "dms-bridge-contracts-v2/contracts/bridge/Bridge.sol";
import "dms-bridge-contracts-v2/contracts/bridge/BridgeValidator.sol";
19 changes: 15 additions & 4 deletions packages/contracts/contracts/controllers/LoyaltyBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "loyalty-tokens/contracts/BIP20/BIP20DelegatedTransfer.sol";

import "dms-bridge-contracts/contracts/interfaces/IBridge.sol";
import "dms-bridge-contracts/contracts/interfaces/IBridgeValidator.sol";
import "dms-bridge-contracts/contracts/lib/BridgeLib.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridge.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridgeValidator.sol";
import "dms-bridge-contracts-v2/contracts/lib/BridgeLib.sol";

import "../interfaces/ILedger.sol";
import "./LoyaltyBridgeStorage.sol";
Expand Down Expand Up @@ -81,14 +81,25 @@ contract LoyaltyBridge is LoyaltyBridgeStorage, Initializable, OwnableUpgradeabl
bytes32 _depositId,
address _account,
uint256 _amount,
uint256 _expiry,
bytes calldata _signature
) external payable override notExistDeposit(_depositId) {
require(_tokenId == tokenId, "1713");
require(_account != foundationAccount, "1052");

bytes32 dataHash = keccak256(
abi.encode(_account, address(this), _amount, block.chainid, ledgerContract.nonceOf(_account))
abi.encode(
block.chainid,
address(tokenContract),
_account,
address(this),
_amount,
ledgerContract.nonceOf(_account),
_expiry
)
);
require(ECDSA.recover(ECDSA.toEthSignedMessageHash(dataHash), _signature) == _account, "1501");
require(_expiry > block.timestamp, "1506");
require(ledgerContract.tokenBalanceOf(_account) >= _amount, "1511");
require(_amount % 1 gwei == 0, "1030");
require(_amount > fee * 2, "1031");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pragma solidity ^0.8.2;

import "loyalty-tokens/contracts/BIP20/BIP20DelegatedTransfer.sol";

import "dms-bridge-contracts/contracts/interfaces/IBridge.sol";
import "dms-bridge-contracts/contracts/interfaces/IBridgeValidator.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridge.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridgeValidator.sol";

import "../interfaces/ILedger.sol";

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/controllers/LoyaltyBurner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/IValidator.sol";
import "../interfaces/ILedger.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.2;

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/IValidator.sol";
import "../interfaces/ILedger.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/IShop.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/ILedger.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.2;

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/ILedger.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/IValidator.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.2;

import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/IValidator.sol";
Expand Down
13 changes: 11 additions & 2 deletions packages/contracts/contracts/controllers/LoyaltyTransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,20 @@ contract LoyaltyTransfer is LoyaltyTransferStorage, Initializable, OwnableUpgrad
require(_msgSender() == owner(), "Unauthorized access");
}

function transferToken(address _from, address _to, uint256 _amount, bytes calldata _signature) external {
function transferToken(
address _from,
address _to,
uint256 _amount,
uint256 _expiry,
bytes calldata _signature
) external {
require(_from != foundationAccount, "1051");
require(_to != foundationAccount, "1052");
bytes32 dataHash = keccak256(abi.encode(_from, _to, _amount, block.chainid, ledgerContract.nonceOf(_from)));
bytes32 dataHash = keccak256(
abi.encode(block.chainid, address(this), _from, _to, _amount, ledgerContract.nonceOf(_from), _expiry)
);
require(ECDSA.recover(ECDSA.toEthSignedMessageHash(dataHash), _signature) == _from, "1501");
require(_expiry > block.timestamp, "1506");
require(ledgerContract.tokenBalanceOf(_from) >= _amount + fee, "1511");
require(_amount % 1 gwei == 0, "1030");

Expand Down
11 changes: 11 additions & 0 deletions packages/contracts/contracts/interfaces/IPhoneLinkCollection.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.2;

interface IPhoneLinkCollection {
function toAddress(bytes32 _phone) external view returns (address);

function toPhone(address _wallet) external view returns (bytes32);

function nonceOf(address _wallet) external view returns (uint256);
}
13 changes: 9 additions & 4 deletions packages/contracts/contracts/ledger/Ledger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "loyalty-tokens/contracts/BIP20/BIP20DelegatedTransfer.sol";
import "dms-bridge-contracts/contracts/interfaces/IBridgeLiquidity.sol";
import "dms-bridge-contracts/contracts/lib/BridgeLib.sol";
import "dms-bridge-contracts-v2/contracts/interfaces/IBridgeLiquidity.sol";
import "dms-bridge-contracts-v2/contracts/lib/BridgeLib.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/ILedger.sol";
Expand Down Expand Up @@ -383,12 +383,17 @@ contract Ledger is LedgerStorage, Initializable, OwnableUpgradeable, UUPSUpgrade
}

/// @notice 브리지를 위한 유동성 자금을 예치합니다.
function depositLiquidity(bytes32 _tokenId, uint256 _amount, bytes calldata _signature) external payable override {
function depositLiquidity(
bytes32 _tokenId,
uint256 _amount,
uint256 _expiry,
bytes calldata _signature
) external payable override {
require(_tokenId == tokenId, "1713");
require(tokenContract.balanceOf(_msgSender()) >= _amount, "1511");
require(_amount % 1 gwei == 0, "1030");

if (tokenContract.delegatedTransfer(_msgSender(), address(this), _amount, _signature)) {
if (tokenContract.delegatedTransfer(_msgSender(), address(this), _amount, _expiry, _signature)) {
tokenBalances[bridgeAddress] += _amount;
liquidity[_msgSender()] += _amount;
emit DepositedLiquidity(_tokenId, _msgSender(), _amount, liquidity[_msgSender()]);
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/ledger/LedgerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.2;

import "loyalty-tokens/contracts/BIP20/IBIP20DelegatedTransfer.sol";
import "del-osx-artifacts/contracts/interfaces/IPhoneLinkCollection.sol";
import "../interfaces/IPhoneLinkCollection.sol";

import "../interfaces/ICurrencyRate.sol";
import "../interfaces/ILedger.sol";
Expand Down
Loading

0 comments on commit 275930b

Please sign in to comment.