- 
                Notifications
    
You must be signed in to change notification settings  - Fork 117
 
Single Asset Vault XLS-65d #814
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
      
      
    
  
     Merged
                    Changes from 18 commits
      Commits
    
    
            Show all changes
          
          
            58 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      f0a0f58
              
                models for SAV transactions and requests
              
              
                ckeshava e4e9ec5
              
                initial framework of integration tests; definitions file
              
              
                ckeshava 5d015a3
              
                provide MPT support for SAV transaction fields
              
              
                ckeshava 6ea3965
              
                Test extreme values in the serialzation of STAmount
              
              
                ckeshava f06f909
              
                Problems in STAmount: Unable to (de)serialize extreme values
              
              
                ckeshava 2858df2
              
                [WIP] use struct library to pack Number data
              
              
                ckeshava 3e86842
              
                Merge remote-tracking branch 'upstream/main' into sav
              
              
                ckeshava ea1ef24
              
                [WIP] VaultClawback integ tests need to be completed; Errors regardin…
              
              
                ckeshava 6966ae7
              
                add integ test for VaultClawback transaction
              
              
                ckeshava 24b4df0
              
                Enforce proper serialization of Number types
              
              
                ckeshava 3646909
              
                docs explanation of transaction models
              
              
                ckeshava 307c515
              
                handle 0 case in Number type
              
              
                ckeshava e97a4b7
              
                simplify the extractNumberParts logic; Avoid using magic numbers;
              
              
                ckeshava 1617cad
              
                introduce model for MPTIssue
              
              
                ckeshava 671690a
              
                Update VaultCreate model to include Withdrawal Policy
              
              
                ckeshava b09b37a
              
                remove irrelevant tests for amount binary codec
              
              
                ckeshava 537cc2f
              
                reorder the REQUIRED fields to be at the top of the transactions mode…
              
              
                ckeshava 6c4f801
              
                pretty print of Number values
              
              
                ckeshava 2765937
              
                update the data member name of the MPTIssue class
              
              
                ckeshava 18bfd1c
              
                pacify linter errors
              
              
                ckeshava f967f23
              
                Update tests/unit/core/binarycodec/types/test_number.py
              
              
                ckeshava eb78553
              
                Accept mypy suggestions
              
              
                ckeshava 4cb1d02
              
                use custom method of Number class for debugging unit tests
              
              
                ckeshava f4830a0
              
                Update definitions, transaction-models with the latest cpp implementa…
              
              
                ckeshava 0abade7
              
                Update CHANGELOG.md
              
              
                ckeshava a1073b3
              
                Model and Integ-tests for VaultInfo Request
              
              
                ckeshava dd20aa8
              
                Merge branch 'main' into sav
              
              
                ckeshava 4e7343b
              
                fix linter errors
              
              
                ckeshava edd5400
              
                remove unused type:ignore directives
              
              
                ckeshava d7a903f
              
                Merge branch 'main' into sav
              
              
                ckeshava c90479c
              
                Use updated name for withdrawal policy
              
              
                ckeshava 5a3b29c
              
                Merge branch 'main' into sav
              
              
                ckeshava 12b7819
              
                Merge branch 'sav' of https://github.com/ckeshava/xrpl-py into HEAD
              
              
                ckeshava f00a4c5
              
                update flag values in VaultCreate transaction
              
              
                ckeshava afbd4e5
              
                Update .ci-config/rippled.cfg
              
              
                ckeshava 27ff509
              
                Merge branch 'main' into sav
              
              
                ckeshava b2c2de7
              
                Update xrpl/core/binarycodec/types/number.py
              
              
                ckeshava 9488ae9
              
                remove duplicate entries in the tec-codes and transaction-types of de…
              
              
                ckeshava ebb70ec
              
                Address comments from Raj Patel
              
              
                ckeshava 2dc7e25
              
                fix: update the length of domain_id field check
              
              
                ckeshava a2619de
              
                VaultCreate: Add enum for representing Withdrawal Strategy input
              
              
                ckeshava 56a19e8
              
                vault_info: additional validation for request input specification'
              
              
                ckeshava de2131e
              
                fix: update the import statements
              
              
                ckeshava 4b2084d
              
                Update tests/unit/models/requests/test_vault_info.py
              
              
                ckeshava eb0260e
              
                fix: Length field check in Hash256 fields for VaultCreate transaction
              
              
                ckeshava 4e9a805
              
                fix: Update length checkk on VaultSet transaction
              
              
                ckeshava 9c11f46
              
                remove integ test -- code is already covered under binary_codec tests
              
              
                ckeshava e6f591f
              
                vault_clawback: do not allow XRP amounts inside VaultClawback transac…
              
              
                ckeshava 3661d9a
              
                address comments from Phu
              
              
                ckeshava 260b69f
              
                Merge branch 'main' into sav
              
              
                ckeshava 217cace
              
                Update xrpl/models/requests/vault_info.py
              
              
                ckeshava 4e728b5
              
                Update xrpl/models/transactions/vault_delete.py
              
              
                ckeshava 6a1be36
              
                Update xrpl/core/binarycodec/definitions/definitions.json
              
              
                ckeshava dfc19ff
              
                address PR comments from Omart
              
              
                ckeshava 34cee18
              
                revert clawback transaction model
              
              
                ckeshava 16bbc80
              
                fix typo in the declaration of Clawback Amount
              
              
                ckeshava 25e204e
              
                remove unneeded import
              
              
                ckeshava 9144d2c
              
                address Omar PR suggestions
              
              
                ckeshava 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
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| 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 import ( | ||
| Payment, | ||
| TrustSet, | ||
| VaultClawback, | ||
| VaultCreate, | ||
| VaultDelete, | ||
| VaultDeposit, | ||
| VaultSet, | ||
| VaultWithdraw, | ||
| ) | ||
| from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount | ||
| from xrpl.models.currencies import IssuedCurrency | ||
| from xrpl.models.requests import AccountObjects | ||
| from xrpl.models.requests.account_objects import AccountObjectType | ||
| from xrpl.models.response import ResponseStatus | ||
| from xrpl.utils import str_to_hex | ||
| from xrpl.wallet import Wallet | ||
| 
     | 
||
| 
     | 
||
| class TestSingleAssetVault(IntegrationTestCase): | ||
                
      
                  ckeshava marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| @test_async_and_sync(globals()) | ||
| async def test_sav_lifecycle(self, client): | ||
| 
     | 
||
| vault_owner = Wallet.create() | ||
| await fund_wallet_async(vault_owner) | ||
| 
     | 
||
| issuer_wallet = Wallet.create() | ||
| await fund_wallet_async(issuer_wallet) | ||
| 
     | 
||
| # Step-0.a: Prerequisites: Set up the IOU trust line | ||
| tx = TrustSet( | ||
| account=WALLET.address, | ||
| limit_amount=IssuedCurrencyAmount( | ||
| currency="USD", issuer=issuer_wallet.address, value="1000" | ||
| ), | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, WALLET, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Step-0.b: Send the payment of IOUs from issuer_wallet to WALLET | ||
| tx = Payment( | ||
| account=issuer_wallet.address, | ||
| amount=IssuedCurrencyAmount( | ||
| currency="USD", issuer=issuer_wallet.address, value="1000" | ||
| ), | ||
| destination=WALLET.address, | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, issuer_wallet, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Step-1: Create a vault | ||
| tx = VaultCreate( | ||
| account=vault_owner.address, | ||
| asset=IssuedCurrency(currency="USD", issuer=issuer_wallet.address), | ||
| asset_maximum="1000", | ||
| withdrawal_policy=1, | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, vault_owner, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Verify the existence of the vault with account_objects RPC call | ||
| account_objects_response = await client.request( | ||
| AccountObjects(account=vault_owner.address, type=AccountObjectType.VAULT) | ||
| ) | ||
| self.assertEqual(len(account_objects_response.result["account_objects"]), 1) | ||
| 
     | 
||
| VAULT_ID = account_objects_response.result["account_objects"][0]["index"] | ||
                
      
                  ckeshava marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| # Step-2: Update the characteristics of the vault with VaultSet transaction | ||
| tx = VaultSet( | ||
| account=vault_owner.address, | ||
| vault_id=VAULT_ID, | ||
| data=str_to_hex("auxilliary data pertaining to the vault"), | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, vault_owner, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Step-3: Execute a VaultDeposit transaction | ||
| tx = VaultDeposit( | ||
| account=WALLET.address, | ||
| vault_id=VAULT_ID, | ||
| amount=IssuedCurrencyAmount( | ||
| currency="USD", issuer=issuer_wallet.address, value="10" | ||
| ), | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, WALLET, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Step-4: Execute a VaultWithdraw transaction | ||
| tx = VaultWithdraw( | ||
| account=WALLET.address, | ||
| vault_id=VAULT_ID, | ||
| amount=IssuedCurrencyAmount( | ||
| currency="USD", issuer=issuer_wallet.address, value="9" | ||
| ), | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, WALLET, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Step-5: Execute a VaultClawback transaction from issuer_wallet | ||
| tx = VaultClawback( | ||
| holder=WALLET.address, | ||
| account=issuer_wallet.address, | ||
| vault_id=VAULT_ID, | ||
| # Note: Although the amount is specified as 9, 1 unit of the IOU will be | ||
| # clawed back, because that is the remaining balance in the vault | ||
| amount=IssuedCurrencyAmount( | ||
| currency="USD", issuer=issuer_wallet.address, value="9" | ||
| ), | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, issuer_wallet, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
| 
     | 
||
| # Step-6: Delete the Vault with VaultDelete transaction | ||
| tx = VaultDelete( | ||
| account=vault_owner.address, | ||
| vault_id=VAULT_ID, | ||
| ) | ||
| response = await sign_and_reliable_submission_async(tx, vault_owner, client) | ||
| self.assertEqual(response.status, ResponseStatus.SUCCESS) | ||
| self.assertEqual(response.result["engine_result"], "tesSUCCESS") | ||
  
    
      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,42 @@ | ||
| import unittest | ||
| 
     | 
||
| from xrpl.core.binarycodec.types.number import Number | ||
| 
     | 
||
| 
     | 
||
| class TestNumber(unittest.TestCase): | ||
| def test_serialization_and_deserialization(self): | ||
| serialized_number = Number.from_value("124") | ||
| self.assertEqual(serialized_number.to_json(), "124") | ||
| 
     | 
||
| serialized_number = Number.from_value("1000") | ||
| self.assertEqual(serialized_number.to_json(), "1000") | ||
| 
     | 
||
| serialized_number = Number.from_value("0") | ||
| self.assertEqual(serialized_number.to_json(), "0") | ||
| 
     | 
||
| serialized_number = Number.from_value("-1") | ||
| self.assertEqual(serialized_number.to_json(), "-1") | ||
| 
     | 
||
| serialized_number = Number.from_value("-10") | ||
| self.assertEqual(serialized_number.to_json(), "-10") | ||
| 
     | 
||
| serialized_number = Number.from_value("123.456") | ||
| self.assertEqual(serialized_number.to_json(), "123.456") | ||
| 
     | 
||
| serialized_number = Number.from_value("1.456e-45") | ||
| self.assertEqual(serialized_number.to_json(), "1456000000000000e-60") | ||
| 
     | 
||
| serialized_number = Number.from_value("0.456e34") | ||
| self.assertEqual(serialized_number.to_json(), "4560000000000000e18") | ||
| 
     | 
||
| serialized_number = Number.from_value("4e34") | ||
| self.assertEqual(serialized_number.to_json(), "4000000000000000e19") | ||
| 
     | 
||
                
      
                  ckeshava marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| def extreme_limits(self): | ||
                
      
                  ckeshava marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| lowest_mantissa = "-9223372036854776" | ||
| serialized_number = Number.from_value(lowest_mantissa + "e3") | ||
| self.assertEqual(serialized_number.hex(), "FFDF3B645A1CAC0800000003") | ||
| 
     | 
||
| highest_mantissa = "9223372036854776" | ||
| serialized_number = Number.from_value(highest_mantissa + "e3") | ||
| self.assertEqual(serialized_number.hex(), "0020C49BA5E353F700000003") | ||
  
    
      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
    
  
  
    
              
      
      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.