Skip to content

Commit

Permalink
Merge branch 'main' into fix-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Oct 25, 2023
2 parents c4f5d35 + 18f6a1e commit 6a6a7bb
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 82 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [[Unreleased]]

## [0.3.3] - 2023-10-10

### Fixed

- Updated xrpl-py version to the latest to fix `XChainCreateBridge`` serialization

## [0.3.2] - 2023-09-25

### Fixed

- Updated xrpl-py beta version to add support for Network ID feature

## [0.3.1] - 2023-07-12

### Fixed

- Better error handling for the `account_objects` call in `bridge create`
Expand Down
24 changes: 12 additions & 12 deletions poetry.lock

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

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xbridge-cli"
version = "0.3.1"
version = "0.3.3"
description = "A CLI that helps you set up an XRPL-XRPL bridge."
readme = "README.md"
repository = "https://github.com/xpring-eng/xbridge-cli"
Expand Down Expand Up @@ -30,7 +30,7 @@ websockets = "^10.3"
Jinja2 = "^3.1.2"
psutil = "^5.9.2"
docker = "^6.0.0"
xrpl-py = "1.9.0b1"
xrpl-py = "^2.4.0"
pycryptodome = "^3.17"

[tool.poetry.dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ xbridge-cli server start-all
xbridge-cli server list
xbridge-cli explorer
xbridge-cli bridge build --name=bridge --fund-locking
xbridge-cli fund locking_chain raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym
xbridge-cli bridge create-account --from-locking --bridge bridge --from snqs2zzXuMA71w9isKHPTrvFn1HaJ --to rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi --amount 10
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from snqs2zzXuMA71w9isKHPTrvFn1HaJ --to snyEJjY2Xi5Dxdh81Jy9Mj3AiYRQM
xbridge-cli fund locking_chain rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV
xbridge-cli bridge create-account --from-locking --bridge bridge --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to rHLrQ3SjzxmkoYgrZ5d4kgHRPF6MdMWpAV --amount 10
xbridge-cli bridge transfer --bridge bridge --from-locking --amount 10 --from sEdTSHsMvrzomUN9uYgVEd64CEQqwo2 --to sEdTSHsMvrzomUN9uYgVEd64CEQqwo2
2 changes: 2 additions & 0 deletions tests/bridge/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def test_bridge_prod_build_xrp(self):
"--fund-locking",
"--funding-seed",
"snoPBrXtMeMyMHUVTgbuqAfg1SUTb",
"--funding-algorithm",
"secp256k1",
"--verbose",
],
)
Expand Down
44 changes: 25 additions & 19 deletions xbridge_cli/bridge/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
AccountObjects,
AccountObjectType,
AccountSet,
AccountSetFlag,
AccountSetAsfFlag,
Currency,
IssuedCurrency,
Payment,
Expand All @@ -42,7 +42,7 @@

_GENESIS_ACCOUNT = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
_GENESIS_SEED = "snoPBrXtMeMyMHUVTgbuqAfg1SUTb"
_GENESIS_WALLET = Wallet(_GENESIS_SEED, 0)
_GENESIS_WALLET = Wallet.from_seed(_GENESIS_SEED, algorithm=CryptoAlgorithm.SECP256K1)

LSF_DISABLE_MASTER = 0x00100000

Expand All @@ -69,6 +69,7 @@
)
@click.option(
"--funding-seed",
"funding_seed",
help=(
"The master key of an account on the locking chain that can fund accounts on "
"the issuing chain. This is only needed for an XRP-XRP bridge."
Expand Down Expand Up @@ -207,19 +208,25 @@ def setup_bridge(
min_create1_rippled = str(min_create1) if min_create1 is not None else None
min_create2_rippled = str(min_create2) if min_create2 is not None else None

funding_wallet_algo = (
CryptoAlgorithm(funding_algorithm)
if funding_algorithm
else CryptoAlgorithm.ED25519
)
if funding_seed is None:
if is_xrp_bridge and funding_seed is None:
if close_ledgers:
funding_seed = "snoPBrXtMeMyMHUVTgbuqAfg1SUTb"
funding_seed = _GENESIS_SEED
funding_wallet_algo = CryptoAlgorithm.SECP256K1
else:
raise XBridgeCLIException(
"Must include `funding_seed` for external XRP-XRP bridge."
)
funding_wallet_algo = (
CryptoAlgorithm(funding_algorithm) if funding_algorithm else None
)

funding_wallet = (
Wallet(funding_seed, 0, algorithm=funding_wallet_algo) if funding_seed else None
Wallet.from_seed(funding_seed, algorithm=funding_wallet_algo)
if funding_seed
else None
)

accounts_locking_check = set(
Expand Down Expand Up @@ -281,13 +288,13 @@ def setup_bridge(

locking_door_seed = bootstrap_locking["DoorAccount"]["Seed"]
locking_door_seed_algo = bootstrap_locking["DoorAccount"]["KeyType"]
locking_door_wallet = Wallet(
locking_door_seed, 0, algorithm=CryptoAlgorithm(locking_door_seed_algo)
locking_door_wallet = Wallet.from_seed(
locking_door_seed, algorithm=CryptoAlgorithm(locking_door_seed_algo)
)
issuing_door_seed = bootstrap_issuing["DoorAccount"]["Seed"]
issuing_door_seed_algo = bootstrap_issuing["DoorAccount"]["KeyType"]
issuing_door_wallet = Wallet(
issuing_door_seed, 0, algorithm=CryptoAlgorithm(issuing_door_seed_algo)
issuing_door_wallet = Wallet.from_seed(
issuing_door_seed, algorithm=CryptoAlgorithm(issuing_door_seed_algo)
)

###################################################################################
Expand Down Expand Up @@ -383,7 +390,9 @@ def setup_bridge(
# disable the master key
if not locking_account_info["Flags"] & LSF_DISABLE_MASTER:
locking_txs.append(
AccountSet(account=locking_door, set_flag=AccountSetFlag.ASF_DISABLE_MASTER)
AccountSet(
account=locking_door, set_flag=AccountSetAsfFlag.ASF_DISABLE_MASTER
)
)

# submit transactions
Expand All @@ -400,12 +409,7 @@ def setup_bridge(

if is_xrp_bridge:
# we need to create the witness reward + submission accounts

assert funding_seed is not None # for typing purposes - checked earlier
funding_wallet_algo = (
CryptoAlgorithm(funding_algorithm) if funding_algorithm else None
)
funding_wallet = Wallet(funding_seed, 0, algorithm=funding_wallet_algo)
assert funding_wallet is not None # for typing purposes

# TODO: add param to customize amount
amount = str(min_create2 * 2) # submit accounts need spare funds
Expand Down Expand Up @@ -505,7 +509,9 @@ def setup_bridge(
# disable the master key
if not issuing_account_info["Flags"] & LSF_DISABLE_MASTER:
issuing_txs.append(
AccountSet(account=issuing_door, set_flag=AccountSetFlag.ASF_DISABLE_MASTER)
AccountSet(
account=issuing_door, set_flag=AccountSetAsfFlag.ASF_DISABLE_MASTER
)
)

# submit transactions
Expand Down
6 changes: 4 additions & 2 deletions xbridge_cli/bridge/create_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ def create_xchain_account(
)
create_amount = xrp_to_drops(amount)

wallet_algorithm = CryptoAlgorithm(algorithm) if algorithm else None
from_wallet = Wallet(from_seed, 0, algorithm=wallet_algorithm)
wallet_algorithm = (
CryptoAlgorithm(algorithm) if algorithm else CryptoAlgorithm.ED25519
)
from_wallet = Wallet.from_seed(from_seed, algorithm=wallet_algorithm)

# submit XChainAccountCreate tx
fund_tx = XChainAccountCreateCommit(
Expand Down
28 changes: 6 additions & 22 deletions xbridge_cli/bridge/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@

import click
from xrpl.clients import JsonRpcClient
from xrpl.models import (
XRP,
Currency,
IssuedCurrency,
Response,
Transaction,
Tx,
XChainCommit,
XChainCreateClaimID,
)
from xrpl.utils import xrp_to_drops
from xrpl.models import Response, Transaction, Tx, XChainCommit, XChainCreateClaimID
from xrpl.wallet import Wallet

from xbridge_cli.exceptions import XBridgeCLIException
Expand Down Expand Up @@ -175,24 +165,18 @@ def send_transfer(
"Must use `--no-close-ledgers` on a non-standalone node."
)

if isinstance(from_issue, IssuedCurrency):
original_issue: Currency = from_issue
else:
original_issue = XRP()
amount = int(xrp_to_drops(amount))

try:
from_wallet = Wallet(from_account, 0)
from_wallet = Wallet.from_seed(from_account)
except ValueError as error:
raise XBridgeCLIException(f"Invalid `from` seed: {from_account}") from error
try:
to_wallet = Wallet(to_account, 0)
to_wallet = Wallet.from_seed(to_account)
except ValueError as error:
raise XBridgeCLIException(f"Invalid `to` seed: {to_account}") from error

transfer_amount = original_issue.to_amount(amount) # type: ignore
transfer_amount = from_issue.to_amount(amount)

# XChainSeqNumCreate
# XChainCreateClaimID
if tutorial:
click.pause(
info=click.style(
Expand Down Expand Up @@ -224,7 +208,7 @@ def send_transfer(
assert len(claim_ids_ledger_entries) == 1, len(claim_ids_ledger_entries)
xchain_claim_id = claim_ids_ledger_entries[0]["NewFields"]["XChainClaimID"]

# XChainTransfer
# XChainCommit
if tutorial:
click.pause(
info=click.style("\nLocking the funds on the source chain...", fg="blue")
Expand Down
5 changes: 4 additions & 1 deletion xbridge_cli/misc/fund.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import List

import click
from xrpl import CryptoAlgorithm
from xrpl.models import AccountInfo, Payment, Transaction
from xrpl.utils import xrp_to_drops
from xrpl.wallet import Wallet
Expand Down Expand Up @@ -56,7 +57,9 @@ def fund_account(
chain_config = get_config().get_chain(chain)
client = chain_config.get_client()

wallet = Wallet("snoPBrXtMeMyMHUVTgbuqAfg1SUTb", 0)
wallet = Wallet.from_seed(
"snoPBrXtMeMyMHUVTgbuqAfg1SUTb", algorithm=CryptoAlgorithm.SECP256K1
)
payments: List[Transaction] = []
for account in accounts:
payments.append(
Expand Down
2 changes: 1 addition & 1 deletion xbridge_cli/misc/trust.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def set_trustline(

trust_sets: List[Transaction] = []
for account in accounts:
wallet = Wallet(account, 0)
wallet = Wallet.from_seed(account)
trust_sets.append(
TrustSet(
account=wallet.classic_address,
Expand Down
Loading

0 comments on commit 6a6a7bb

Please sign in to comment.