Skip to content
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

feat: Multi-Purpose Tokens (MPT) #732

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3bde9eb
update definitions
khancode Jul 15, 2024
5051728
add MPTokenIssuanceCreate
khancode Jul 19, 2024
0510c09
update CHANGELOG
khancode Jul 19, 2024
b048781
remove redundant account
khancode Jul 19, 2024
6993c1b
add int to hex util and MPTokenIssuanceCreate integ test (commented)
khancode Jul 23, 2024
2a5bcb8
fix lint error
khancode Jul 23, 2024
c793141
fix return types of int_conversions
khancode Jul 23, 2024
9fdee49
add MPTAmount support in Payment tx and binary-codec
khancode Aug 14, 2024
0566f25
fix Self import in MPTAmount
khancode Aug 14, 2024
bc6ea59
Revert "fix Self import in MPTAmount"
khancode Aug 14, 2024
6a55a1d
Revert "add MPTAmount support in Payment tx and binary-codec"
khancode Aug 14, 2024
1d75779
use Python ^3.11 and poetry update dependencies
khancode Aug 14, 2024
54471cd
Revert "use Python ^3.11 and poetry update dependencies"
khancode Aug 14, 2024
84421b6
use Python ^3.10 and poetry update dependencies
khancode Aug 14, 2024
88c6f32
Revert "use Python ^3.10 and poetry update dependencies"
khancode Aug 14, 2024
76de09f
remove Python 3.7 support to fix dependency installation and use 3.8 …
khancode Aug 14, 2024
af6ee29
remove python 3.7 from unit test; part of #737
khancode Aug 14, 2024
a995cf1
Revert "Revert "add MPTAmount support in Payment tx and binary-codec""
khancode Aug 14, 2024
dbeb5e7
Revert "Revert "fix Self import in MPTAmount""
khancode Aug 14, 2024
71de9df
resolve lint errors
khancode Aug 14, 2024
8cbf809
resolve mypy errors
khancode Aug 15, 2024
5c14d23
Merge branch 'main' into mpt
khancode Aug 15, 2024
c1a9b4d
add MPTokenAuthorize tx
khancode Aug 18, 2024
75ada8b
fix lint error
khancode Aug 18, 2024
5c1bd40
fix lint on REQUIRED
khancode Aug 18, 2024
e5ebdcd
add mpt_issuance and mptoken to ledger entries
khancode Aug 18, 2024
2f4991d
add ledger entry tests
khancode Aug 18, 2024
715fb36
add MPT support to Clawback tx
khancode Aug 18, 2024
77e6951
add MPTokenIssuanceSet tx and fix imports
khancode Aug 18, 2024
0ae0bb5
add MPTokenIssuanceDestroy tx
khancode Aug 18, 2024
eda3fb7
update version to 4.0.0b0
khancode Aug 21, 2024
2a11523
update definitions
khancode Sep 19, 2024
aa8710b
bump version
khancode Sep 19, 2024
21c7c92
update definitions.json
khancode Oct 16, 2024
1d5a660
use base 10 serialization for all amount fields in MPT
khancode Oct 16, 2024
ed7e993
resolve lint errors
khancode Oct 16, 2024
a595e67
resolve more lint errors
khancode Oct 16, 2024
e256253
Merge branch 'main' into mpt
khancode Oct 16, 2024
02efe76
bump version
khancode Oct 16, 2024
68bc036
Merge branch 'main' into mpt
khancode Nov 11, 2024
200ccf7
update poetry.lock
khancode Nov 11, 2024
ac03053
update definitions, rename MPTokenHolder to Holder, remove LockedAmount
khancode Nov 11, 2024
0716f79
bump version to 4.0.0b3
khancode Nov 11, 2024
761e42d
Merge branch 'main' into mpt
khancode Nov 13, 2024
6e8b76f
fix definitions
khancode Nov 13, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [[Unreleased]]

### Added
- Support for the Multi-Purpose Tokens (MPT) amendment (XLS-33)
- Add `include_deleted` to ledger_entry request

### BREAKING CHANGE:
Expand Down
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xrpl-py"
version = "3.0.0"
version = "4.0.0b3"
description = "A complete Python library for interacting with the XRP ledger"
readme = "README.md"
repository = "https://github.com/XRPLF/xrpl-py"
Expand Down Expand Up @@ -50,6 +50,9 @@ coverage = "^7.2.7"
Sphinx = "^7.1.2"
poethepoet = "^0.29.0"

[tool.poetry.group.dev.dependencies]
packaging = "^24.1"

[tool.isort]
# Make sure that isort's settings line up with black
profile = "black"
Expand Down
101 changes: 99 additions & 2 deletions tests/integration/transactions/test_clawback.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from tests.integration.integration_test_case import IntegrationTestCase
from tests.integration.it_utils import (
from tests.integration.it_utils import ( # fund_wallet_async,
fund_wallet,
sign_and_reliable_submission_async,
test_async_and_sync,
)
from tests.integration.reusable_values import WALLET
from xrpl.models import (
from xrpl.models import ( # MPTAmount,
AccountSet,
AccountSetAsfFlag,
Clawback,
Expand All @@ -14,6 +14,14 @@
TrustSet,
TrustSetFlag,
)

# from xrpl.models.requests import LedgerEntry, Tx
# from xrpl.models.requests.ledger_entry import MPToken
# from xrpl.models.transactions import (
# MPTokenAuthorize,
# MPTokenIssuanceCreate,
# MPTokenIssuanceCreateFlag,
# )
from xrpl.wallet import Wallet

HOLDER = Wallet.create()
Expand Down Expand Up @@ -71,3 +79,92 @@ async def test_basic_functionality(self, client):
client,
)
self.assertTrue(response.is_successful())

# TODO: uncomment test when rippled Docker image supports MPT feature
# @test_async_and_sync(globals())
# async def test_mptoken(self, client):
# wallet2 = Wallet.create()
# await fund_wallet_async(wallet2)

# tx = MPTokenIssuanceCreate(
# account=WALLET.classic_address,
# flags=MPTokenIssuanceCreateFlag.TF_MPT_CAN_CLAWBACK,
# )

# 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"]

# 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")

# await sign_and_reliable_submission_async(
# Payment(
# account=WALLET.classic_address,
# destination=wallet2.classic_address,
# amount=MPTAmount(
# mpt_issuance_id=mpt_issuance_id, value="9223372036854775807"
# ),
# ),
# WALLET,
# )

# ledger_entry_res = await client.request(
# LedgerEntry(
# mptoken=MPToken(
# mpt_issuance_id=mpt_issuance_id, account=wallet2.classic_address
# )
# )
# )
# self.assertEqual(
# ledger_entry_res.result["node"]["MPTAmount"], "7fffffffffffffff"
# )

# # actual test - clawback
# response = await sign_and_reliable_submission_async(
# Clawback(
# account=WALLET.classic_address,
# amount=MPTAmount(
# mpt_issuance_id=mpt_issuance_id,
# value="500",
# ),
# holder=wallet2.classic_address,
# ),
# WALLET,
# client,
# )

# self.assertTrue(response.is_successful())
# self.assertEqual(auth_res.result["engine_result"], "tesSUCCESS")

# ledger_entry_res = await client.request(
# LedgerEntry(
# mptoken=MPToken(
# mpt_issuance_id=mpt_issuance_id, account=wallet2.classic_address
# )
# )
# )
# self.assertEqual(
# ledger_entry_res.result["node"]["MPTAmount"], "7ffffffffffffe0b"
# )
114 changes: 114 additions & 0 deletions tests/integration/transactions/test_mptoken_authorize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# TODO: uncomment test module when rippled Docker image supports MPT feature
# 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)
38 changes: 38 additions & 0 deletions tests/integration/transactions/test_mptoken_issuance_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# TODO: uncomment test module when rippled Docker image supports MPT feature
# 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)
Loading