-
Notifications
You must be signed in to change notification settings - Fork 116
feat: Multi-Purpose Tokens (MPT) #732
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
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
3bde9eb
update definitions
khancode 5051728
add MPTokenIssuanceCreate
khancode 0510c09
update CHANGELOG
khancode b048781
remove redundant account
khancode 6993c1b
add int to hex util and MPTokenIssuanceCreate integ test (commented)
khancode 2a5bcb8
fix lint error
khancode c793141
fix return types of int_conversions
khancode 9fdee49
add MPTAmount support in Payment tx and binary-codec
khancode 0566f25
fix Self import in MPTAmount
khancode bc6ea59
Revert "fix Self import in MPTAmount"
khancode 6a55a1d
Revert "add MPTAmount support in Payment tx and binary-codec"
khancode 1d75779
use Python ^3.11 and poetry update dependencies
khancode 54471cd
Revert "use Python ^3.11 and poetry update dependencies"
khancode 84421b6
use Python ^3.10 and poetry update dependencies
khancode 88c6f32
Revert "use Python ^3.10 and poetry update dependencies"
khancode 76de09f
remove Python 3.7 support to fix dependency installation and use 3.8 …
khancode af6ee29
remove python 3.7 from unit test; part of #737
khancode a995cf1
Revert "Revert "add MPTAmount support in Payment tx and binary-codec""
khancode dbeb5e7
Revert "Revert "fix Self import in MPTAmount""
khancode 71de9df
resolve lint errors
khancode 8cbf809
resolve mypy errors
khancode 5c14d23
Merge branch 'main' into mpt
khancode c1a9b4d
add MPTokenAuthorize tx
khancode 75ada8b
fix lint error
khancode 5c1bd40
fix lint on REQUIRED
khancode e5ebdcd
add mpt_issuance and mptoken to ledger entries
khancode 2f4991d
add ledger entry tests
khancode 715fb36
add MPT support to Clawback tx
khancode 77e6951
add MPTokenIssuanceSet tx and fix imports
khancode 0ae0bb5
add MPTokenIssuanceDestroy tx
khancode eda3fb7
update version to 4.0.0b0
khancode 2a11523
update definitions
khancode aa8710b
bump version
khancode 21c7c92
update definitions.json
khancode 1d5a660
use base 10 serialization for all amount fields in MPT
khancode ed7e993
resolve lint errors
khancode a595e67
resolve more lint errors
khancode e256253
Merge branch 'main' into mpt
khancode 02efe76
bump version
khancode 68bc036
Merge branch 'main' into mpt
khancode 200ccf7
update poetry.lock
khancode ac03053
update definitions, rename MPTokenHolder to Holder, remove LockedAmount
khancode 0716f79
bump version to 4.0.0b3
khancode 761e42d
Merge branch 'main' into mpt
khancode 6e8b76f
fix definitions
khancode b39c1d0
Merge branch 'main' into mpt
khancode 81e272e
set version to regular 4.0.0
khancode a8a25e3
update Docker image
khancode 9ed5f8e
update docker run command
khancode 4831a88
fix docker run command
khancode ec3fcf3
uncomment MPT integ tests
khancode ed88c61
Revert "uncomment MPT integ tests"
khancode 20f6e56
uncomment issuance create integ test
khancode 6e3ad2d
debug MaximumAmount base10 regex match
khancode 0d7f384
fix field.name not passed in uint64
khancode bf85918
uncomment issuance destroy integ test
khancode f467d2d
uncomment authorize and issuance set integ tests
khancode b70414a
uncomment mpt payment integ test
khancode bf36ce0
uncomment mpt clawback integ test
khancode fdb43e3
fix test_clawback integ test
khancode babb8f9
fix mpt clawback integ test
khancode f05bca8
fix docstrings
khancode b7786c3
remove typo
khancode 6eba955
add test to verify uint64 parsing
khancode a19326c
make error message more specific
khancode 7e91c4c
add TODO comment for MPT balance
khancode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
tests/integration/transactions/test_mptoken_authorize.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| from tests.integration.integration_test_case import IntegrationTestCase | ||
| from tests.integration.it_utils import ( | ||
| fund_wallet_async, | ||
| sign_and_reliable_submission_async, | ||
| test_async_and_sync, | ||
| ) | ||
| from tests.integration.reusable_values import WALLET | ||
| from xrpl.models.requests.account_objects import AccountObjects, AccountObjectType | ||
| from xrpl.models.requests.tx import Tx | ||
| from xrpl.models.transactions import ( | ||
| MPTokenAuthorize, | ||
| MPTokenAuthorizeFlag, | ||
| MPTokenIssuanceCreate, | ||
| MPTokenIssuanceCreateFlag, | ||
| ) | ||
| from xrpl.wallet.main import Wallet | ||
|
|
||
|
|
||
| class TestMPTokenAuthorize(IntegrationTestCase): | ||
| @test_async_and_sync(globals()) | ||
| async def test_basic_functionality(self, client): | ||
| tx = MPTokenIssuanceCreate( | ||
| account=WALLET.classic_address, | ||
| flags=MPTokenIssuanceCreateFlag.TF_MPT_REQUIRE_AUTH, | ||
| ) | ||
|
|
||
| create_res = await sign_and_reliable_submission_async( | ||
| tx, | ||
| WALLET, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(create_res.is_successful()) | ||
| self.assertEqual(create_res.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| tx_hash = create_res.result["tx_json"]["hash"] | ||
|
|
||
| tx_res = await client.request(Tx(transaction=tx_hash)) | ||
| mpt_issuance_id = tx_res.result["meta"]["mpt_issuance_id"] | ||
|
|
||
| # confirm MPTokenIssuance ledger object was created | ||
| account_objects_response = await client.request( | ||
| AccountObjects(account=WALLET.address, type=AccountObjectType.MPT_ISSUANCE) | ||
| ) | ||
|
|
||
| # subsequent integration tests (sync/async + json/websocket) add one | ||
| # MPTokenIssuance object to the account | ||
| self.assertTrue(len(account_objects_response.result["account_objects"]) > 0) | ||
|
|
||
| wallet2 = Wallet.create() | ||
| await fund_wallet_async(wallet2) | ||
|
|
||
| auth_tx = MPTokenAuthorize( | ||
| account=wallet2.classic_address, | ||
| mptoken_issuance_id=mpt_issuance_id, | ||
| ) | ||
|
|
||
| auth_res = await sign_and_reliable_submission_async( | ||
| auth_tx, | ||
| wallet2, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(auth_res.is_successful()) | ||
| self.assertEqual(auth_res.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| # confirm MPToken ledger object was created | ||
| account_objects_response2 = await client.request( | ||
| AccountObjects(account=wallet2.address, type=AccountObjectType.MPTOKEN) | ||
| ) | ||
|
|
||
| # subsequent integration tests (sync/async + json/websocket) add one | ||
| # MPToken object to the account | ||
| self.assertTrue(len(account_objects_response2.result["account_objects"]) > 0) | ||
|
|
||
| auth_tx2 = MPTokenAuthorize( | ||
| account=WALLET.classic_address, | ||
| mptoken_issuance_id=mpt_issuance_id, | ||
| holder=wallet2.classic_address, | ||
| ) | ||
|
|
||
| auth_res2 = await sign_and_reliable_submission_async( | ||
| auth_tx2, | ||
| WALLET, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(auth_res2.is_successful()) | ||
| self.assertEqual(auth_res2.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| auth_tx3 = MPTokenAuthorize( | ||
| account=wallet2.classic_address, | ||
| mptoken_issuance_id=mpt_issuance_id, | ||
| flags=MPTokenAuthorizeFlag.TF_MPT_UNAUTHORIZE, | ||
| ) | ||
|
|
||
| auth_res3 = await sign_and_reliable_submission_async( | ||
| auth_tx3, | ||
| wallet2, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(auth_res3.is_successful()) | ||
| self.assertEqual(auth_res3.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| # confirm MPToken ledger object is removed | ||
| account_objects_response3 = await client.request( | ||
| AccountObjects(account=wallet2.address, type=AccountObjectType.MPTOKEN) | ||
| ) | ||
|
|
||
| # Should no longer hold an MPToken ledger object | ||
| self.assertTrue(len(account_objects_response3.result["account_objects"]) == 0) |
36 changes: 36 additions & 0 deletions
36
tests/integration/transactions/test_mptoken_issuance_create.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from tests.integration.integration_test_case import IntegrationTestCase | ||
| from tests.integration.it_utils import ( | ||
| sign_and_reliable_submission_async, | ||
| test_async_and_sync, | ||
| ) | ||
| from tests.integration.reusable_values import WALLET | ||
| from xrpl.models.requests.account_objects import AccountObjects, AccountObjectType | ||
| from xrpl.models.transactions import MPTokenIssuanceCreate | ||
|
|
||
|
|
||
| class TestMPTokenIssuanceCreate(IntegrationTestCase): | ||
| @test_async_and_sync(globals()) | ||
| async def test_basic_functionality(self, client): | ||
| tx = MPTokenIssuanceCreate( | ||
| account=WALLET.classic_address, | ||
| maximum_amount="9223372036854775807", # "7fffffffffffffff" | ||
| asset_scale=2, | ||
| ) | ||
|
|
||
| response = await sign_and_reliable_submission_async( | ||
| tx, | ||
| WALLET, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(response.is_successful()) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| # confirm MPTokenIssuance ledger object was created | ||
| account_objects_response = await client.request( | ||
| AccountObjects(account=WALLET.address, type=AccountObjectType.MPT_ISSUANCE) | ||
| ) | ||
|
|
||
| # subsequent integration tests (sync/async + json/websocket) add one | ||
| # MPTokenIssuance object to the account | ||
| self.assertTrue(len(account_objects_response.result["account_objects"]) > 0) |
64 changes: 64 additions & 0 deletions
64
tests/integration/transactions/test_mptoken_issuance_destroy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| from tests.integration.integration_test_case import IntegrationTestCase | ||
| from tests.integration.it_utils import ( | ||
| sign_and_reliable_submission_async, | ||
| test_async_and_sync, | ||
| ) | ||
| from tests.integration.reusable_values import WALLET | ||
| from xrpl.models.requests.account_objects import AccountObjects, AccountObjectType | ||
| from xrpl.models.requests.tx import Tx | ||
| from xrpl.models.transactions import MPTokenIssuanceCreate, MPTokenIssuanceDestroy | ||
|
|
||
|
|
||
| class TestMPTokenIssuanceDestroy(IntegrationTestCase): | ||
| @test_async_and_sync(globals()) | ||
| async def test_basic_functionality(self, client): | ||
| tx = MPTokenIssuanceCreate( | ||
| account=WALLET.classic_address, | ||
| ) | ||
|
|
||
| create_res = await sign_and_reliable_submission_async( | ||
| tx, | ||
| WALLET, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(create_res.is_successful()) | ||
| self.assertEqual(create_res.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| tx_hash = create_res.result["tx_json"]["hash"] | ||
|
|
||
| tx_res = await client.request(Tx(transaction=tx_hash)) | ||
| mpt_issuance_id = tx_res.result["meta"]["mpt_issuance_id"] | ||
|
|
||
| # confirm MPTokenIssuance ledger object was created | ||
| account_objects_response = await client.request( | ||
| AccountObjects( | ||
| account=WALLET.classic_address, type=AccountObjectType.MPT_ISSUANCE | ||
| ) | ||
| ) | ||
|
|
||
| # subsequent integration tests (sync/async + json/websocket) add one | ||
| # MPTokenIssuance object to the account | ||
| self.assertTrue(len(account_objects_response.result["account_objects"]) > 0) | ||
|
|
||
| destroy_res = await sign_and_reliable_submission_async( | ||
| MPTokenIssuanceDestroy( | ||
| account=WALLET.classic_address, | ||
| mptoken_issuance_id=mpt_issuance_id, | ||
| ), | ||
| WALLET, | ||
| client, | ||
| ) | ||
|
|
||
| self.assertTrue(destroy_res.is_successful()) | ||
| self.assertEqual(destroy_res.result["engine_result"], "tesSUCCESS") | ||
|
|
||
| # confirm MPToken ledger object is removed | ||
| account_objects_response3 = await client.request( | ||
| AccountObjects( | ||
| account=WALLET.classic_address, type=AccountObjectType.MPTOKEN | ||
| ) | ||
| ) | ||
|
|
||
| # Should no longer hold an MPToken ledger object | ||
| self.assertTrue(len(account_objects_response3.result["account_objects"]) == 0) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.