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

Rebase 2.0 into master #605

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4f0776e
Merge main (#486)
connorjchen Dec 1, 2022
beb12be
Merge branch 'xrpl-py-2.0' of https://github.com/XRPLF/xrpl-py into x…
connorjchen Dec 1, 2022
53d4eb9
Trigger Build
connorjchen Dec 1, 2022
cfc174b
Merge branch 'xrpl-py-2.0' of https://github.com/XRPLF/xrpl-py into x…
connorjchen Dec 1, 2022
d28b72e
Merge branch 'xrpl-py-2.0' of https://github.com/XRPLF/xrpl-py into x…
connorjchen Dec 1, 2022
e49bbf2
Merge branch 'xrpl-py-2.0' of https://github.com/XRPLF/xrpl-py into x…
connorjchen Dec 5, 2022
0a9ba8b
Merge branch 'xrpl-py-2.0' of https://github.com/XRPLF/xrpl-py into x…
connorjchen Dec 6, 2022
2be6a3e
breaking: Refactored wallet class and removed wallet sequence (#477)
connorjchen Dec 14, 2022
e24adfd
feat: generate wallet from secret numbers (#492)
connorjchen Dec 15, 2022
ebf1d24
Merge master into xrpl-py-2.0
connorjchen Dec 15, 2022
1d7b3ea
Merge branch 'master' into xrpl-py-2.0
JST5000 May 24, 2023
42ece52
Merge branch 'master' into xrpl-py-2.0
JST5000 May 31, 2023
87c24e3
chore: Remove deprecated request functions (attempt 2) (#581)
JST5000 Jun 1, 2023
51bbf93
Fix a mix up with AccountSet flags (#524)
rikublock Jun 1, 2023
6f81b6e
feat: Remove `send_reliable_submission` (#592)
JST5000 Jun 12, 2023
03b8ef1
Remove long aliases for signing/submitting functions (#599)
JST5000 Jun 15, 2023
aba2141
Make `sign` synchronous (#598)
JST5000 Jun 15, 2023
10d4e6d
refactor: Make param order for signing/submitting consistent (#600)
JST5000 Jun 15, 2023
ac36415
refactor(wallet): Rename `Wallet.classic_address` to `Wallet.address`…
JST5000 Jun 27, 2023
87bfc43
[BREAKING] fix: XRP().to_amount now expects XRP instead of drops (#554)
mvadari Jun 27, 2023
5a0663d
Merge main (#486)
connorjchen Dec 1, 2022
132e21f
Trigger Build
connorjchen Dec 1, 2022
3e164eb
breaking: Refactored wallet class and removed wallet sequence (#477)
connorjchen Dec 14, 2022
47e02cf
feat: generate wallet from secret numbers (#492)
connorjchen Dec 15, 2022
4bf1a40
chore: Remove deprecated request functions (attempt 2) (#581)
JST5000 Jun 1, 2023
aa2bcfd
Fix a mix up with AccountSet flags (#524)
rikublock Jun 1, 2023
b0c6a14
feat: Remove `send_reliable_submission` (#592)
JST5000 Jun 12, 2023
30227d6
Remove long aliases for signing/submitting functions (#599)
JST5000 Jun 15, 2023
4738d88
Make `sign` synchronous (#598)
JST5000 Jun 15, 2023
204c803
refactor: Make param order for signing/submitting consistent (#600)
JST5000 Jun 15, 2023
afb621a
refactor(wallet): Rename `Wallet.classic_address` to `Wallet.address`…
JST5000 Jun 27, 2023
caa0036
[BREAKING] fix: XRP().to_amount now expects XRP instead of drops (#554)
mvadari Jun 27, 2023
a8af0f5
Merge branch 'xrpl-py-2.0' into rebase-2.0-into-master
JST5000 Jun 28, 2023
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
5 changes: 3 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ env:
jobs:
integration-test:
name: Integration test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
# we have to use 3.7.1 to get around openssl issues
python-version: ['3.7.1', '3.8', '3.9', '3.10', '3.11']

steps:
- name: Checkout code
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
jobs:
lint-and-type-check:
name: Lint and type-check
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

env:
PYTHON_VERSION: "3.11"
Expand Down Expand Up @@ -57,10 +57,11 @@ jobs:

unit-test:
name: Unit test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
# we have to use 3.7.1 to get around openssl issues
python-version: ['3.7.1', '3.8', '3.9', '3.10', '3.11']

steps:
- name: Checkout code
Expand Down
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,48 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [[Unreleased]]
## [2.0.0]
### Added:
- Wallet support for regular key compatibility
- Added new ways of wallet generation: `from_seed`, `from_secret`, `from_entropy`, `from_secret_numbers`
- Replaced `Wallet.classic_address` with `Wallet.address` to avoid confusion. (`classic_address` is the same as your XRPL account `address`, and is only called classic since it's an older standard than `x-address`)

### Changed:
- Updated params for Wallet class constructor
- `Wallet.address` is now readonly
- Removed Sequence from Wallet class
- Core keypairs generate seed must take in hexstring instead of bytestring
- Core keypairs formatting for ED25519 is now padded with zeros if length of keystring is less than 64
- Removed deprecated request wrappers (the preferred method is to directly do client.request instead)
- Replaced the flags defined in `AccountSetFlag` (now defines the transaction `tf` flags, previously not defined anywhere)
- `sign` is now synchronous instead of async (done by removing the optional `check_fee` param & moving checks up to other functions)
- In order to be internally consistent, all signing/submitting functions will follow the parameter order of `transaction`, `client`, `wallet`, and then other parameters. (This is because `wallet` is optional for `submit_and_wait` and so must come after `client`)
- `XRP.to_amount` now converts from XRP to drops, instead of expecting a drops amount

### Removed:
- Longer aliases for signing/submitting functions have been removed. Specifically
- `submit_transaction` is now `submit`
- `safe_sign_transaction` is now `sign`
- `safe_sign_and_submit_transaction` is now `sign_and_submit`
- The param order for `sign_and_submit` moves `wallet` after `client` to be consistent with `submit_and_wait`
- `safe_sign_and_autofill_transaction` is now `autofill_and_sign`
- The param order for `autofill_and_sign` moves `wallet` after `client` to be consistent with `submit_and_wait`

### Fixed:
- Added a sort of the account IDs in `multisign`, so that the `multisign` always works.
- Add `ledger_hash` and `ledger_index` to `account_nfts`, `nft_buy_offers`, and `nft_sell_offers` requests.
- Add `nft_page` to `ledger_entry` request.

## [1.9.0] - 2023-06-13

### Added:
- Added `submit_and_wait` to sign (if needed), autofill, submit a transaction and wait for its final outcome
- `submit` and `send_reliable_submission` now accept an optional boolean param `fail_hard` (if `True` halt the submission if it's not immediately validated)
- Added sidechain devnet support to faucet generation
- Added `user_agent` and `usage_context` to `generate_faucet_wallet`

### Changed:
- Replaced the flags defined in `AccountSetFlag` (now defines the transaction `tf` flags, previously not defined anywhere)
- Allowed keypairs.sign to take a hex string in addition to bytes

### Fixed:
Expand All @@ -40,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `getNFTokenID` to get the NFTokenID after minting a token.
- Added `LedgerEntryType` enum and added `type` field to `Ledger` and `LedgerData` requests
- Added the algorithm used to encode a wallet's seed to the wallet.
- Created function alias to `safe_sign_transaction` called `sign` - safe originally used to indicate local offline signing (keys aren't exposed)

### Changed:
- `check_fee` now has a higher limit that is less likely to be hit
Expand Down
47 changes: 21 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_wallet = generate_faucet_wallet(client)
print(test_wallet)
public_key: ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56
private_key: -HIDDEN-
classic_address: rBtXmAdEYcno9LWRnAGfT9qBxCeDvuVRZo
address: rBtXmAdEYcno9LWRnAGfT9qBxCeDvuVRZo

# look up account info
from xrpl.models import AccountInfo
Expand Down Expand Up @@ -103,18 +103,18 @@ Use the [`xrpl.wallet`](https://xrpl-py.readthedocs.io/en/stable/source/xrpl.wal
To create a wallet from a seed (in this case, the value generated using [`xrpl.keypairs`](#xrpl-keypairs)):

```py
wallet_from_seed = xrpl.wallet.Wallet(seed, 0)
wallet_from_seed = xrpl.wallet.Wallet.from_seed(seed)
print(wallet_from_seed)
# pub_key: ED46949E414A3D6D758D347BAEC9340DC78F7397FEE893132AAF5D56E4D7DE77B0
# priv_key: -HIDDEN-
# classic_address: rG5ZvYsK5BPi9f1Nb8mhFGDTNMJhEhufn6
# address: rG5ZvYsK5BPi9f1Nb8mhFGDTNMJhEhufn6
```

To create a wallet from a Testnet faucet:

```py
test_wallet = generate_faucet_wallet(client)
test_account = test_wallet.classic_address
test_account = test_wallet.address
print("Classic address:", test_account)
# Classic address: rEQB2hhp3rg7sHj6L8YyR4GG47Cb7pfcuw
```
Expand Down Expand Up @@ -157,34 +157,33 @@ Use the [`xrpl.transaction`](https://xrpl-py.readthedocs.io/en/stable/source/xrp

* [`sign`](https://xrpl-py.readthedocs.io/en/stable/source/xrpl.transaction.html#xrpl.transaction.sign) — Signs a transaction locally. This method **does not** submit the transaction to the XRP Ledger.

* [`send_reliable_submission`](https://xrpl-py.readthedocs.io/en/stable/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission) — An implementation of the [reliable transaction submission guidelines](https://xrpl.org/reliable-transaction-submission.html#reliable-transaction-submission), this method submits a signed transaction to the XRP Ledger and then verifies that it has been included in a validated ledger (or has failed to do so). Use this method to submit transactions for production purposes.
* `submit_and_wait` — An implementation of the [reliable transaction submission guidelines](https://xrpl.org/reliable-transaction-submission.html#reliable-transaction-submission), this method submits a signed transaction to the XRP Ledger and then verifies that it has been included in a validated ledger (or has failed to do so). Use this method to submit transactions for production purposes.


```py
from xrpl.models import Payment
from xrpl.transaction import sign, send_reliable_submission
from xrpl.models.transactions import Payment
from xrpl.transaction import sign, submit_and_wait
from xrpl.ledger import get_latest_validated_ledger_sequence
from xrpl.account import get_next_valid_seq_number

current_validated_ledger = get_latest_validated_ledger_sequence(client)
wallet_sequence = get_next_valid_seq_number(test_wallet.classic_address, client)

# prepare the transaction
# the amount is expressed in drops, not XRP
# see https://xrpl.org/basic-data-types.html#specifying-currency-amounts
my_tx_payment = Payment(
account=test_wallet.classic_address,
account=test_wallet.address,
amount="2200000",
destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
last_ledger_sequence=current_validated_ledger + 20,
sequence=wallet_sequence,
sequence=get_next_valid_seq_number(test_wallet.address, client),
fee="10",
)
# sign the transaction
my_tx_payment_signed = sign(my_tx_payment,test_wallet)

# submit the transaction
tx_response = send_reliable_submission(my_tx_payment_signed, client)
tx_response = submit_and_wait(my_tx_payment_signed, client)
```

#### Get fee from the XRP Ledger
Expand All @@ -204,20 +203,20 @@ print(fee)
The `xrpl-py` library automatically populates the `fee`, `sequence` and `last_ledger_sequence` fields when you create transactions. In the example above, you could omit those fields and let the library fill them in for you.

```py
from xrpl.models import Payment
from xrpl.transaction import send_reliable_submission, autofill_and_sign
from xrpl.models.transactions import Payment
from xrpl.transaction import submit_and_wait, autofill_and_sign
# prepare the transaction
# the amount is expressed in drops, not XRP
# see https://xrpl.org/basic-data-types.html#specifying-currency-amounts
my_tx_payment = Payment(
account=test_wallet.classic_address,
account=test_wallet.address,
amount="2200000",
destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
)

# sign the transaction with the autofill method
# (this will auto-populate the fee, sequence, and last_ledger_sequence)
my_tx_payment_signed = autofill_and_sign(my_tx_payment, test_wallet, client)
my_tx_payment_signed = autofill_and_sign(my_tx_payment, client, test_wallet)
print(my_tx_payment_signed)
# Payment(
# account='rMPUKmzmDWEX1tQhzQ8oGFNfAEhnWNFwz',
Expand All @@ -242,7 +241,7 @@ print(my_tx_payment_signed)
# )

# submit the transaction
tx_response = send_reliable_submission(my_tx_payment_signed, client)
tx_response = submit_and_wait(my_tx_payment_signed, client)
```


Expand Down Expand Up @@ -275,8 +274,8 @@ This sample code is the asynchronous equivalent of the above section on submitti

```py
import asyncio
from xrpl.models import Payment
from xrpl.asyncio.transaction import sign, send_reliable_submission
from xrpl.models.transactions import Payment
from xrpl.asyncio.transaction import sign, submit_and_wait
from xrpl.asyncio.ledger import get_latest_validated_ledger_sequence
from xrpl.asyncio.account import get_next_valid_seq_number
from xrpl.asyncio.clients import AsyncJsonRpcClient
Expand All @@ -285,24 +284,20 @@ async_client = AsyncJsonRpcClient(JSON_RPC_URL)

async def submit_sample_transaction():
current_validated_ledger = await get_latest_validated_ledger_sequence(async_client)
wallet_sequence = await get_next_valid_seq_number(test_wallet.classic_address, async_client)

# prepare the transaction
# the amount is expressed in drops, not XRP
# see https://xrpl.org/basic-data-types.html#specifying-currency-amounts
my_tx_payment = Payment(
account=test_wallet.classic_address,
account=test_wallet.address,
amount="2200000",
destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
last_ledger_sequence=current_validated_ledger + 20,
sequence=wallet_sequence,
sequence=await get_next_valid_seq_number(test_wallet.address, async_client),
fee="10",
)
# sign the transaction
my_tx_payment_signed = await sign(my_tx_payment,test_wallet)

# submit the transaction
tx_response = await send_reliable_submission(my_tx_payment_signed, async_client)
# sign and submit the transaction
tx_response = await submit_and_wait(my_tx_payment_signed, async_client, test_wallet)

asyncio.run(submit_sample_transaction())
```
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xrpl-py"
version = "1.9.0"
version = "2.0.0"
description = "A complete Python library for interacting with the XRP ledger"
readme = "README.md"
repository = "https://github.com/XRPLF/xrpl-py"
Expand Down
8 changes: 4 additions & 4 deletions snippets/multisign.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
signer_wallet_2 = Wallet.create()

signer_entries = [
SignerEntry(account=signer_wallet_1.classic_address, signer_weight=1),
SignerEntry(account=signer_wallet_2.classic_address, signer_weight=1),
SignerEntry(account=signer_wallet_1.address, signer_weight=1),
SignerEntry(account=signer_wallet_2.address, signer_weight=1),
]
signer_list_set_tx = SignerListSet(
account=master_wallet.classic_address,
account=master_wallet.address,
signer_quorum=2,
signer_entries=signer_entries,
)
Expand All @@ -34,7 +34,7 @@
# Now that we've set up multisigning, let's try using it to submit an AccountSet
# transaction.
account_set_tx = AccountSet(
account=master_wallet.classic_address, domain=str_to_hex("example.com")
account=master_wallet.address, domain=str_to_hex("example.com")
)
autofilled_account_set_tx = autofill(account_set_tx, client, len(signer_entries))
print("AccountSet transaction is ready to be multisigned")
Expand Down
30 changes: 15 additions & 15 deletions snippets/partial_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

# Create a TrustSet to issue an IOU `FOO` and set limit on it
trust_set_tx = TrustSet(
account=wallet2.classic_address,
account=wallet2.address,
limit_amount=IssuedCurrencyAmount(
currency="FOO",
value="10000000000",
issuer=wallet1.classic_address,
issuer=wallet1.address,
),
)

Expand All @@ -38,19 +38,19 @@

# Both balances should be zero since nothing has been sent yet
print("Balances after trustline is claimed:")
print((client.request(AccountLines(account=wallet1.classic_address))).result["lines"])
print((client.request(AccountLines(account=wallet2.classic_address))).result["lines"])
print((client.request(AccountLines(account=wallet1.address))).result["lines"])
print((client.request(AccountLines(account=wallet2.address))).result["lines"])

# Create a Payment to send 3840 FOO from wallet1 (issuer) to destination (wallet2)
issue_quantity = "3840"
payment_tx = Payment(
account=wallet1.classic_address,
account=wallet1.address,
amount=IssuedCurrencyAmount(
currency="FOO",
value=issue_quantity,
issuer=wallet1.classic_address,
issuer=wallet1.address,
),
destination=wallet2.classic_address,
destination=wallet2.address,
)

# Sign and autofill, then send transaction to the ledger
Expand All @@ -59,8 +59,8 @@

# Issuer (wallet1) should have -3840 FOO and destination (wallet2) should have 3840 FOO
print("Balances after wallet1 sends 3840 FOO to wallet2:")
print((client.request(AccountLines(account=wallet1.classic_address))).result["lines"])
print((client.request(AccountLines(account=wallet2.classic_address))).result["lines"])
print((client.request(AccountLines(account=wallet1.address))).result["lines"])
print((client.request(AccountLines(account=wallet2.address))).result["lines"])

# Send money less than the amount specified on 2 conditions:
# 1. Sender has less money than the amount specified in the payment Tx.
Expand All @@ -72,18 +72,18 @@

# Create Payment to send 4000 (of 3840) FOO from wallet2 to wallet1
partial_payment_tx = Payment(
account=wallet2.classic_address,
account=wallet2.address,
amount=IssuedCurrencyAmount(
currency="FOO",
value="4000",
issuer=wallet1.classic_address,
issuer=wallet1.address,
),
destination=wallet1.classic_address,
destination=wallet1.address,
flags=[PaymentFlag.TF_PARTIAL_PAYMENT],
send_max=IssuedCurrencyAmount(
currency="FOO",
value="1000000",
issuer=wallet1.classic_address,
issuer=wallet1.address,
),
)

Expand All @@ -93,5 +93,5 @@

# Tried sending 4000 of 3840 FOO -> wallet1 and wallet2 should have 0 FOO
print("Balances after Partial Payment, when wallet2 tried to send 4000 FOOs")
print((client.request(AccountLines(account=wallet1.classic_address))).result["lines"])
print((client.request(AccountLines(account=wallet2.classic_address))).result["lines"])
print((client.request(AccountLines(account=wallet1.address))).result["lines"])
print((client.request(AccountLines(account=wallet2.address))).result["lines"])
6 changes: 3 additions & 3 deletions snippets/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Create a RipplePathFind request and have the client call it
path_request = RipplePathFind(
source_account=wallet.classic_address,
source_account=wallet.address,
source_currencies=[XRP()],
destination_account=destination_account,
destination_amount=destination_amount,
Expand All @@ -38,10 +38,10 @@

# # Create a Payment to send money from wallet to destination_account using path
payment_tx = Payment(
account=wallet.classic_address,
account=wallet.address,
amount=destination_amount,
destination=destination_account,
paths=paths,
)

print("signed: ", autofill_and_sign(payment_tx, wallet, client))
print("signed: ", autofill_and_sign(payment_tx, client, wallet))
Loading