Skip to content

Commit

Permalink
Swap NEAR OK \o/
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed Dec 16, 2024
1 parent 7496c2e commit 98e4d6d
Show file tree
Hide file tree
Showing 58 changed files with 80 additions and 22 deletions.
98 changes: 78 additions & 20 deletions test/python/apps/near.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class P2():

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


class NearClient:
Expand All @@ -33,24 +33,82 @@ def __init__(self, backend):
def send_simple_sign_tx(self, path: str, destination: str, send_amount: int) -> RAPDU:
packed_path = pack_derivation_path(path)

"""
1234.56 NEAR
Transaction {
signer_id: "blablatest.testnet",
public_key: ed25519:EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U,
nonce: 103595482000005,
receiver_id: "speculos.testnet",
block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E,
actions: [
Transfer(
TransferAction {
deposit: 1234560000000000000000000000,
},
),
],
}
"""

tx = bytes.fromhex("12000000626c61626c61746573742e746573746e657400c4f5941e81e071c2fd1dae2e71fd3d859d462484391d9a90bf219211dcbb320f85aae733385e00001000000073706563756c6f732e746573746e6574ac299ac1376e375cd39338d8b29225613ef947424b74a3207c1226863a72583101000000030000001049f203b43f34fd0300000000")
if destination == "speculos.testnet" and send_amount == 1234560000000000000000000000:
"""
1234.56 NEAR
Transaction {
signer_id: "blablatest.testnet",
public_key: ed25519:EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U,
nonce: 103595482000005,
receiver_id: "speculos.testnet",
block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E,
actions: [
Transfer(
TransferAction {
deposit: 1234560000000000000000000000,
},
),
],
}
"""
tx = bytes.fromhex("12000000626c61626c61746573742e746573746e657400c4f5941e81e071c2fd1dae2e71fd3d859d462484391d9a90bf219211dcbb320f85aae733385e00001000000073706563756c6f732e746573746e6574ac299ac1376e375cd39338d8b29225613ef947424b74a3207c1226863a72583101000000030000001049f203b43f34fd0300000000")

elif destination == "speculos.testnet" and send_amount == 500000000000000000000000:
"""
0.5 NEAR
Transaction {
signer_id: "blablatest.testnet",
public_key: ed25519:EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U,
nonce: 103595482000005,
receiver_id: "speculos.testnet",
block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E,
actions: [
Transfer(
TransferAction {
deposit: 500000000000000000000000,
},
),
],
}
"""
tx = bytes.fromhex("12000000626c61626c61746573742e746573746e657400c4f5941e81e071c2fd1dae2e71fd3d859d462484391d9a90bf219211dcbb320f85aae733385e00001000000073706563756c6f732e746573746e6574ac299ac1376e375cd39338d8b29225613ef947424b74a3207c1226863a7258310100000003000080d07666e70de169000000000000")
elif destination == "ledger.testnet" and send_amount == 1234560000000000000000000000:
"""
1234.56 NEAR
Transaction {
signer_id: "blablatest.testnet",
public_key: ed25519:EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U,
nonce: 103595482000005,
receiver_id: "ledger.testnet",
block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E,
actions: [
Transfer(
TransferAction {
deposit: 1234560000000000000000000000,
},
),
],
}
"""
tx = bytes.fromhex("12000000626c61626c61746573742e746573746e657400c4f5941e81e071c2fd1dae2e71fd3d859d462484391d9a90bf219211dcbb320f85aae733385e00000e0000006c65646765722e746573746e6574ac299ac1376e375cd39338d8b29225613ef947424b74a3207c1226863a72583101000000030000001049f203b43f34fd0300000000")
else:
"""
0.5 NEAR
Transaction {
signer_id: "blablatest.testnet",
public_key: ed25519:EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U,
nonce: 103595482000005,
receiver_id: "ledger.testnet",
block_hash: Cb3vKNiF3MUuVoqfjuEFCgSNPT79pbuVfXXd2RxDXc5E,
actions: [
Transfer(
TransferAction {
deposit: 500000000000000000000000,
},
),
],
}
"""
tx = bytes.fromhex("12000000626c61626c61746573742e746573746e657400c4f5941e81e071c2fd1dae2e71fd3d859d462484391d9a90bf219211dcbb320f85aae733385e00000e0000006c65646765722e746573746e6574ac299ac1376e375cd39338d8b29225613ef947424b74a3207c1226863a7258310100000003000080d07666e70de169000000000000")

return self._backend.exchange(self.CLA, Ins.SIGN, P1.MORE, P2.UNUSED, packed_path[1:] + tx)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_fund_valid_1/review/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_fund_valid_1/review/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_fund_valid_1/review/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_fund_valid_2/review/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_fund_valid_2/review/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_sell_valid_1/review/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_sell_valid_1/review/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/stax/test_near_sell_valid_2/review/00000.png
Binary file modified test/python/snapshots/stax/test_near_sell_valid_2/review/00002.png
Binary file modified test/python/snapshots/stax/test_near_swap_valid_2/review/00000.png
Binary file modified test/python/snapshots/stax/test_near_swap_valid_2/review/00002.png
4 changes: 2 additions & 2 deletions test/python/test_near.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class NearTests(ExchangeTestRunner):
currency_configuration = cal.NEAR_CURRENCY_CONFIGURATION
valid_destination_1 = "speculos.testnet"
valid_destination_memo_1 = ""
valid_destination_2 = "speculos.testnet"
valid_destination_2 = "ledger.testnet"
valid_destination_memo_2 = ""
valid_refund = "EFr6nRvgKKeteKoEH7hudt8UHYiu94Liq2yMM7x2AU9U"
valid_refund_memo = ""
valid_send_amount_1 = 1234560000000000000000000000
valid_send_amount_2 = 1234560000000000000000000000
valid_send_amount_2 = 500000000000000000000000
valid_fees_1 = 0
valid_fees_2 = 0
fake_refund = "abcdabcd"
Expand Down

0 comments on commit 98e4d6d

Please sign in to comment.