Skip to content

Uniswap like SC #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ x64/
/test/universe.*
/test/contract0???.???
/test/tmp_file_*

.DS_Store
.clang-format
tmp
23 changes: 23 additions & 0 deletions LICENSE-MIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License (MIT)

Copyright (c) 2013 - 2017 Jason Lee @ calccrypto at gmail.com

Applies to the files src/platform/uint128.h and test/uint128.cpp

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ The above copyright notice and this permission notice shall be included in all c


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This project is licensed under the Anti-Military License. However, it includes
some code licensed under the MIT License. The MIT licensed code is used with
permission and retains its original MIT license.

The MIT licensed code is from the following sources:
- [uint128_t](https://github.com/calccrypto/uint128_t)
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ We recommend to synchronize a Linux / Windows / MacOS machine with NTP permanent
## License
The Anti-Military License. See [LICENSE.md](LICENSE.md).

This project is licensed under the Anti-Military License. However, it includes
some code licensed under the MIT License. The MIT licensed code is used with
permission and retains its original MIT license.

The MIT licensed code is from the following sources:
- [uint128_t](https://github.com/calccrypto/uint128_t)

## Installation and Configuration
Please refer to https://docs.qubic.org

Expand Down
2 changes: 2 additions & 0 deletions src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClInclude Include="assets\net_msg_impl.h" />
<ClInclude Include="common_buffers.h" />
<ClInclude Include="contracts\ComputorControlledFund.h" />
<ClInclude Include="contracts\Qswap.h" />
<ClInclude Include="contracts\SupplyWatcher.h" />
<ClInclude Include="contracts\EmptyTemplate.h" />
<ClInclude Include="contracts\GeneralQuorumProposal.h" />
Expand Down Expand Up @@ -86,6 +87,7 @@
<ClInclude Include="platform\random.h" />
<ClInclude Include="platform\read_write_lock.h" />
<ClInclude Include="platform\stack_size_tracker.h" />
<ClInclude Include="platform\uint128.h" />
<ClInclude Include="platform\time_stamp_counter.h" />
<ClInclude Include="platform\global_var.h" />
<ClInclude Include="score.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@
<ClInclude Include="network_messages\logging.h">
<Filter>network_messages</Filter>
</ClInclude>
<ClInclude Include="contracts\Qswap.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="platform\uint128.h">
<Filter>platform</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
Expand Down
11 changes: 11 additions & 0 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ struct __FunctionOrProcedureBeginEndGuard
#include "contracts/MsVault.h"

// new contracts should be added above this line
#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QSWAP_CONTRACT_INDEX 12
#define CONTRACT_INDEX QSWAP_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QSWAP
#define CONTRACT_STATE2_TYPE QSWAP2
#include "contracts/Qswap.h"

#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
constexpr unsigned short TESTEXA_CONTRACT_INDEX = (CONTRACT_INDEX + 1);
Expand Down Expand Up @@ -250,6 +259,7 @@ constexpr struct ContractDescription
{"QVAULT", 138, 10000, sizeof(IPO)}, // proposal in epoch 136, IPO in 137, construction and first use in 138
{"MSVAULT", 149, 10000, sizeof(MSVAULT)}, // proposal in epoch 147, IPO in 148, construction and first use in 149
// new contracts should be added above this line
{"QSWAP", 150, 10000, sizeof(QSWAP)},
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
{"TESTEXA", 138, 10000, sizeof(IPO)},
{"TESTEXB", 138, 10000, sizeof(IPO)},
Expand Down Expand Up @@ -344,6 +354,7 @@ static void initializeContracts()
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QVAULT);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(MSVAULT);
// new contracts should be added above this line
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QSWAP);
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXB);
Expand Down
6 changes: 6 additions & 0 deletions src/contract_core/qpi_asset_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,9 @@ long long QPI::QpiContextProcedureCall::transferShareOwnershipAndPossession(unsi
}
}
}

bool QPI::QpiContextFunctionCall::isAssetIssued(const m256i& issuer, unsigned long long assetName) const
{
bool res = ::issuanceIndex(issuer, assetName) != NO_ASSET_INDEX;
return res;
}
Loading