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

breaking: Refactored wallet class and removed wallet sequence #477

Merged
merged 53 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
09f7cc1
Set up wallet tests
connorjchen Oct 24, 2022
b11be17
Change list to List
connorjchen Oct 24, 2022
2a840ec
Wrote some wallet tests
connorjchen Oct 25, 2022
7c28d0f
Isolate bad test
connorjchen Oct 26, 2022
c144ad2
Removed a test
connorjchen Oct 26, 2022
5164e8e
Add address alias
connorjchen Nov 1, 2022
864ef1c
Fix default algorithm for public/private key
connorjchen Nov 3, 2022
336cbfa
Wrote main wallet tests for generation
connorjchen Nov 3, 2022
1695392
Add from_secret tests
connorjchen Nov 3, 2022
60fd94d
Merge branch 'master' into wallet-generation
connorjchen Nov 3, 2022
babb5da
Remove breaking change for algorithm optional on wallet init
connorjchen Nov 3, 2022
80a11fd
Merge branch 'wallet-generation' of https://github.com/connorjchen/xr…
connorjchen Nov 3, 2022
7bd8f7c
Remove default algo for wallet init
connorjchen Nov 3, 2022
597510c
Reverted behavior of default algorithm for from_seed and init
connorjchen Nov 4, 2022
f6bfa6c
Fix docstrings
connorjchen Nov 4, 2022
8bf5176
Deprecate wallet create
connorjchen Nov 4, 2022
4cf72bb
Changed wallet class to look alike xrpljs
connorjchen Nov 21, 2022
6627b05
Add tests to wallet refactor
connorjchen Nov 21, 2022
a2a556b
Remove changelog changes
connorjchen Nov 21, 2022
ce5db90
Fix changelog difference'
connorjchen Nov 21, 2022
3119fd4
Shortened address function
connorjchen Nov 22, 2022
7e62397
Empty test commit
connorjchen Nov 22, 2022
6669b3c
Updated CHANGELOG
connorjchen Nov 22, 2022
028613e
Fix tests for sequence removal
connorjchen Nov 23, 2022
eab1a85
Fix get next valid seq num imports
connorjchen Nov 23, 2022
4e26153
Add from_secret tests
connorjchen Nov 23, 2022
c257cae
Changed generate back to create and cleaned up docs
connorjchen Nov 29, 2022
f02552c
Fix typo
connorjchen Nov 29, 2022
be82c9e
Fix from_entropy
connorjchen Nov 30, 2022
618ecd4
Fix leading zero for key formatting
connorjchen Nov 30, 2022
671ff3d
Merge from master
connorjchen Dec 1, 2022
cdc5eba
Changed from_entropy to take in hex string
connorjchen Dec 2, 2022
eed7416
Update core keypairs docs
connorjchen Dec 2, 2022
7ffa39e
Fix up core keypairs tests
connorjchen Dec 2, 2022
79dc668
Merge branch 'xrpl-py-2.0' into xrpl-py2.0
connorjchen Dec 5, 2022
9babcf3
Fix integration tests
connorjchen Dec 5, 2022
fe6456e
Merge branch 'xrpl-py-2.0' into xrpl-py2.0
connorjchen Dec 8, 2022
2e154fd
Fix integ test
connorjchen Dec 8, 2022
d66c67d
Fix integ test
connorjchen Dec 8, 2022
9bba9f1
Added to changelog
connorjchen Dec 8, 2022
6e130c4
Added to changelog
connorjchen Dec 8, 2022
18dc416
Decreased check size integration test
connorjchen Dec 9, 2022
9f878c0
Refactor individual test to have own wallet
connorjchen Dec 12, 2022
e990d19
Throw error instead truncate for generate seed with entropy
connorjchen Dec 12, 2022
e7841ee
Fix docs
connorjchen Dec 12, 2022
edbd0f2
Removed sequence from many integ tests + relocated ensure classic add…
connorjchen Dec 13, 2022
f0115f5
Refactor test main wallet generation suite
connorjchen Dec 13, 2022
72e5a7d
Fix latest ledger sequence
connorjchen Dec 13, 2022
5dbde61
Remove poe test
connorjchen Dec 13, 2022
a469002
Remove poe test
connorjchen Dec 13, 2022
de1f1e1
Fix spacing linting
connorjchen Dec 13, 2022
8d7b347
Fix spacing linting
connorjchen Dec 13, 2022
32efcac
Resolve comments
connorjchen Dec 14, 2022
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ 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).

## [2.0.0]
### Added:
- Wallet support for regular key compatibility
- Added new ways of wallet generation: `from_seed`, `from_secret`, `from_entropy`
- Added address alias to `Wallet.classic_address `

### Changed:
- Updated params for Wallet class constructor
- `Wallet.address` and `Wallet.classic_address` are 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

## [[Unreleased]]
### Added:
- Created function alias to `safe_sign_transaction` called `sign` - safe originally used to indicate local offline signing (keys aren't exposed)
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ 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)
test_wallet.sequence = get_next_valid_seq_number(test_wallet.classic_address, client)

# prepare the transaction
# the amount is expressed in drops, not XRP
Expand All @@ -177,7 +176,7 @@ my_tx_payment = Payment(
amount="2200000",
destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
last_ledger_sequence=current_validated_ledger + 20,
sequence=test_wallet.sequence,
sequence=get_next_valid_seq_number(test_wallet.classic_address, client),
fee="10",
)
# sign the transaction
Expand Down Expand Up @@ -285,7 +284,6 @@ async_client = AsyncJsonRpcClient(JSON_RPC_URL)

async def submit_sample_transaction():
current_validated_ledger = await get_latest_validated_ledger_sequence(async_client)
test_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
Expand All @@ -295,7 +293,7 @@ async def submit_sample_transaction():
amount="2200000",
destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
last_ledger_sequence=current_validated_ledger + 20,
sequence=test_wallet.sequence,
sequence=await get_next_valid_seq_number(test_wallet.classic_address, async_client),
fee="10",
)
# sign the transaction
Expand Down
9 changes: 3 additions & 6 deletions tests/integration/it_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
from time import sleep

import xrpl # noqa: F401 - needed for sync tests
from xrpl.account import get_next_valid_seq_number
from xrpl.asyncio.account import get_next_valid_seq_number as get_seq_num_async
from xrpl.asyncio.clients import AsyncJsonRpcClient, AsyncWebsocketClient
from xrpl.asyncio.clients.async_client import AsyncClient
from xrpl.asyncio.transaction import (
safe_sign_and_submit_transaction as sign_and_submit_async,
)
from xrpl.clients import Client, JsonRpcClient, WebsocketClient
from xrpl.clients.sync_client import SyncClient
from xrpl.constants import CryptoAlgorithm
from xrpl.models import GenericRequest, Payment, Request, Response, Transaction
from xrpl.transaction import ( # noqa: F401 - needed for sync tests
autofill_and_sign,
Expand Down Expand Up @@ -56,8 +55,8 @@
}

MASTER_ACCOUNT = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
MASTER_SECRET = "snoPBrXtMeMyMHUVTgbuqAfg1SUTb"
MASTER_WALLET = Wallet(MASTER_SECRET, 0)
MASTER_SEED = "snoPBrXtMeMyMHUVTgbuqAfg1SUTb"
MASTER_WALLET = Wallet.from_seed(MASTER_SEED, algorithm=CryptoAlgorithm.SECP256K1)
FUNDING_AMOUNT = "1200000000"

LEDGER_ACCEPT_REQUEST = GenericRequest(method="ledger_accept")
Expand Down Expand Up @@ -106,7 +105,6 @@ def fund_wallet_sync(wallet: Wallet) -> None:
)
safe_sign_and_submit_transaction(payment, MASTER_WALLET, client, check_fee=True)
client.request(LEDGER_ACCEPT_REQUEST)
wallet.sequence = get_next_valid_seq_number(wallet.classic_address, client)


async def fund_wallet(
Expand All @@ -119,7 +117,6 @@ async def fund_wallet(
)
await sign_and_submit_async(payment, MASTER_WALLET, client, check_fee=True)
await client.request(LEDGER_ACCEPT_REQUEST)
wallet.sequence = await get_seq_num_async(wallet.classic_address, client)


def submit_transaction(
Expand Down
10 changes: 4 additions & 6 deletions tests/integration/reqs/test_submit_multisigned.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
test_async_and_sync,
)
from tests.integration.reusable_values import WALLET
from xrpl.asyncio.account import get_next_valid_seq_number
from xrpl.core.binarycodec import encode_for_multisigning
from xrpl.core.keypairs import sign
from xrpl.ledger import get_fee
Expand All @@ -21,15 +22,12 @@

FEE = get_fee(JSON_RPC_CLIENT)

#
# Set up signer list
FIRST_SIGNER = Wallet.create()
SECOND_SIGNER = Wallet.create()
LIST_SET_TX = sign_and_reliable_submission(
SignerListSet(
account=WALLET.classic_address,
sequence=WALLET.sequence,
last_ledger_sequence=WALLET.sequence + 10,
fee=FEE,
signer_quorum=2,
signer_entries=[
Expand All @@ -48,7 +46,7 @@


class TestSubmitMultisigned(IntegrationTestCase):
@test_async_and_sync(globals())
@test_async_and_sync(globals(), ["xrpl.account.get_next_valid_seq_number"])
async def test_basic_functionality(self, client):
#
# Perform multisign
Expand All @@ -59,7 +57,7 @@ async def test_basic_functionality(self, client):
issuer = Wallet.create()
tx = TrustSet(
account=WALLET.classic_address,
sequence=WALLET.sequence,
sequence=await get_next_valid_seq_number(WALLET.classic_address, client),
connorjchen marked this conversation as resolved.
Show resolved Hide resolved
fee=FEE,
flags=TrustSetFlag.TF_SET_NO_RIPPLE,
limit_amount=IssuedCurrencyAmount(
Expand Down Expand Up @@ -89,7 +87,7 @@ async def test_basic_functionality(self, client):
)
multisigned_tx = TrustSet(
account=WALLET.classic_address,
sequence=WALLET.sequence,
sequence=await get_next_valid_seq_number(WALLET.classic_address, client),
fee=FEE,
flags=TrustSetFlag.TF_SET_NO_RIPPLE,
limit_amount=IssuedCurrencyAmount(
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/reqs/test_submit_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

TX = OfferCreate(
account=WALLET.classic_address,
sequence=WALLET.sequence,
last_ledger_sequence=WALLET.sequence + 10,
taker_gets="13100000",
taker_pays=IssuedCurrencyAmount(
currency="USD",
Expand All @@ -24,6 +22,7 @@ class TestSubmitOnly(IntegrationTestCase):
@test_async_and_sync(globals(), ["xrpl.transaction.autofill_and_sign"])
async def test_basic_functionality(self, client):
transaction = await autofill_and_sign(TX, WALLET, client)

tx_json = transaction.to_xrpl()
tx_blob = encode(tx_json)
response = await client.request(
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/reusable_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ async def _set_up_reusable_values():
OFFER = await sign_and_reliable_submission_async(
OfferCreate(
account=WALLET.classic_address,
sequence=WALLET.sequence,
taker_gets="13100000",
taker_pays=IssuedCurrencyAmount(
currency="USD",
Expand All @@ -28,20 +27,17 @@ async def _set_up_reusable_values():
),
WALLET,
)
WALLET.sequence += 1

PAYMENT_CHANNEL = await sign_and_reliable_submission_async(
PaymentChannelCreate(
account=WALLET.classic_address,
sequence=WALLET.sequence,
amount="1",
destination=DESTINATION.classic_address,
settle_delay=86400,
public_key=WALLET.public_key,
),
WALLET,
)
WALLET.sequence += 1

return (
WALLET,
Expand Down
1 change: 0 additions & 1 deletion tests/integration/sugar/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ async def test_get_latest_transaction(self, client):
amount=amount,
)
await sign_and_reliable_submission_async(payment, WALLET)
WALLET.sequence += 1

response = await get_latest_transaction(WALLET.classic_address, client)
self.assertEqual(len(response.result["transactions"]), 1)
Expand Down
Loading