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

Swap near #145

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .github/workflows/reusable_swap_functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ on:
required: false
default: 'develop'
type: string
branch_for_near:
required: false
default: 'add-swap'
type: string
test_filter:
required: false
default: '""'
Expand Down Expand Up @@ -91,6 +95,9 @@ jobs:
- name: tron
repo: app-tron
branch: ${{ inputs.branch_for_tron }}
- name: near
repo: app-near
branch: ${{ inputs.branch_for_near }}

uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions test/python/apps/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .polkadot import DOT_PACKED_DERIVATION_PATH, DOT_CONF
from .tron import TRX_PACKED_DERIVATION_PATH, TRX_CONF
from .tron import TRX_USDT_CONF, TRX_USDC_CONF, TRX_TUSD_CONF, TRX_USDD_CONF
from .near import NEAR_PACKED_DERIVATION_PATH, NEAR_CONF

TICKER_ID_TO_CONF = {
"ETC": ETC_CONF,
Expand All @@ -35,6 +36,7 @@
"USDC": TRX_USDC_CONF,
"TUSD": TRX_TUSD_CONF,
"USDD": TRX_USDD_CONF,
"NEAR": NEAR_CONF,
}

TICKER_ID_TO_PACKED_DERIVATION_PATH = {
Expand All @@ -53,6 +55,7 @@
"USDC": TRX_PACKED_DERIVATION_PATH,
"TUSD": TRX_PACKED_DERIVATION_PATH,
"USDD": TRX_PACKED_DERIVATION_PATH,
"NEAR": NEAR_PACKED_DERIVATION_PATH,
}

# Helper that can be called from outside if we want to generate errors easily
Expand Down
60 changes: 60 additions & 0 deletions test/python/apps/near.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from enum import IntEnum

from ragger.bip import pack_derivation_path
from ragger.utils import create_currency_config, RAPDU
from py_near.transactions import create_transfer_action, Transaction
import ed25519
import base58


ED25519_KEYPAIR = "188d2ce61071d477a2400558c3612ee68957a80aa2e56c29dc4da2dace58e7d8c4f5941e81e071c2fd1dae2e71fd3d859d462484391d9a90bf219211dcbb320f"
PRIVATE_KEY = ed25519.SigningKey(bytes.fromhex(ED25519_KEYPAIR))
PUBLIC_KEY = PRIVATE_KEY.get_verifying_key()

NEAR_CONF = create_currency_config("NEAR", "NEAR")

NEAR_PACKED_DERIVATION_PATH = pack_derivation_path("m/44'/397'/0'/0'/1'")
SIGNER_ID = "blablatest.testnet"
NONCE = 96520360000015
BLOCK_HASH = base58.b58decode("C32rfeBkSMT1xnsrArkV9Mu81ww9qK7n6Kw17NhEbVuK")


class Ins():
SIGN = 0x02


class P1():
START = 0x00
MORE = 0x80


class P2():
UNUSED = 0x57


class NearErrors(IntEnum):
SW_DENY = 0x6985
SW_SWAP_CHECKING_FAIL = 0x6A88


class NearClient:
CLA = 0x80

def __init__(self, backend):
self._backend = backend

def send_simple_sign_tx(self, path: str, destination: str, send_amount: int) -> RAPDU:
packed_path = pack_derivation_path(path)

tx = Transaction(
signer_id="blablatest.testnet",
public_key=PUBLIC_KEY.to_bytes(),
nonce=NONCE,
receiver_id=destination,
actions=[create_transfer_action(send_amount * 10**24)],
block_hash=BLOCK_HASH
)

serialized_tx = bytes(tx.to_vec(PRIVATE_KEY.to_bytes()))

return self._backend.exchange(self.CLA, Ins.SIGN, P1.MORE, P2.UNUSED, packed_path[1:] + serialized_tx)
1 change: 1 addition & 0 deletions test/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"bsc": "Binance Smart Chain",
"DOT": "Polkadot",
"tron": "Tron",
"near": "NEAR",
}

configuration.OPTIONAL.SIDELOADED_APPS_DIR = "test/python/lib_binaries/"
Expand Down
1 change: 1 addition & 0 deletions test/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ xrpl-py
scalecodec
bip32
embit
py-near
--extra-index-url https://test.pypi.org/simple/
ledger_app_clients.ethereum
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.