require "spec_helper" RSpec.describe PortalConnectors::KeyPortalClient do describe "#create_coin_seed" do context "valid chain" do it "returns id and xpubkey", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.create_coin_seed(chain: "sol") expect(ok).to be true expect(response).to eq( "id" => 18, "xpubkey" => "xpub661MyMwAqRbcFjTJcB9PPecoom2m3NaYrpPYhiTUMP1Ansq4KVyVan8mcq3q6aKNtiDyS1SZGi7z3M64XoEHb3KHERcy4Ah5QP4i8gtpbNC", ) PortalConnectors.requester = "remitano" end end context "invalid chain" do it "returns error", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.create_coin_seed(chain: "solana") expect(ok).to be false expect(response).to eq("error" => "Failed to create new coin seed") PortalConnectors.requester = "remitano" end end end describe "#coin_seed_xpubkey" do context "coin seed exists" do it "returns id and xpubkey", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.coin_seed_xpubkey(chain: "sol", id: 18) expect(ok).to be true expect(response).to eq( "id" => 18, "xpubkey" => "xpub661MyMwAqRbcFjTJcB9PPecoom2m3NaYrpPYhiTUMP1Ansq4KVyVan8mcq3q6aKNtiDyS1SZGi7z3M64XoEHb3KHERcy4Ah5QP4i8gtpbNC", ) PortalConnectors.requester = "remitano" end end context "coin seed does not exists" do it "returns error", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.coin_seed_xpubkey(chain: "btc", id: 18) expect(ok).to be false expect(response).to eq( "id" => nil, "xpubkey" => nil, ) PortalConnectors.requester = "remitano" end end end describe "#generate_coin_address" do context "with format" do it "returns address", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.generate_coin_address(chain: "btc", hd_path: "m/20", format: "segwit") expect(ok).to be(true) expect(response).to eq( "address" => "39BPsAgCYeMFsDRLidA69csN4LmpsLzHN6", "coin_seed_id" => 10, "public_key" => "024d366775893781bb374a657319a2bc7a9c2b11d6aa639445fed22572aa79edc2" ) PortalConnectors.requester = "remitano" end end context "without format" do it "returns address", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.generate_coin_address(chain: "sol", hd_path: "m/10") expect(ok).to be(true) expect(response).to eq( "address" => "CfX6eoXH6hj3evTgSYYJamEkbmUR4Tti1JYE7myvXJc7", "coin_seed_id" => 4, "public_key" => "035db8d4c2e1bca48b5ca3d73a9059b4588e5f80f8e271e75f45a87ab0b7c64727" ) PortalConnectors.requester = "remitano" end end context "with coin_seed_id" do it "returns address", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.generate_coin_address(chain: "eth", hd_path: "m/20", coin_seed_id: 5) expect(ok).to be(true) expect(response).to eq( "address" => "0x217efe3ae2874cb3897f5870592cdac4db0b2033", "coin_seed_id" => 5, "public_key" => "0331421ea46e3b49ce15f864e2306086f8e54298e14d6f03339cee391c528c6883" ) PortalConnectors.requester = "remitano" end end end describe "#sol_based_build_transfer_coin_tx" do context "when transfer native currency on sol chain" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_tx( chain: "sol", sender_hd_path: "m/5", sender_coin_seed_id: 2, nonce: "EnyKaDRkA7P3TXBHFz82nqF2fSDen6DAPn2YsgN5knKH", recipient_address: "6vHLpKKajt5KRiH68RZAtYrVqgAmendK4HrbrUB5mymr", amount_in_lamport: 50_000_000, payer_hd_path: "m/7", payer_coin_seed_id: 2, nonce_account_address: nil ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "zXz98VrE2EycRqhHu88UYTe9wCXATQKmssftMQrcnisqRkkutZrZVQHv2urpKkQeCxdubB4RTzxRT2yhn2p88KM" ) expect(response["raw_tx"]).to eq( "AEmR1pt6YmV8oXnwNshFxD2SA8ZapCvY2khN2dQNCSDwqSyQn5GLzA9iv1cwwbxKgX6p"\ "XciWzZQZTiYVXReDdFuZbrV1NWKLKzhYKJavCwXnN7SEyu2d22cieTgayUHh4tiYfKyc"\ "pJosWsfx55MVpRvUWzEgEPAptDV1pfjE12VCgMdWtu4U2yAggsQBcEbm2yYajH15LBg5"\ "HEzMYHSB5LBhZzzXZAyaSAGJeSBmQX7JQ6Zge9dd7eqpv7g1KDaYHfQi8mJFvHnf7aZF"\ "QafadLpqUUeLdyib4tjuF6jUtemMdQQqRUimSc8j8DGHHJVhwUafPvYN2ER31AYq7Mp1"\ "rcdrDSn8xi4Rm5cpmyZCJ9qy7ZNVPAH4iaP93yM62wBiJeiDGPetw2X5TFk2H9NRdoGc"\ "thRTPVJgJKiqPSo1" ) PortalConnectors.requester = "remitano" end end context "when transfer token on sol chain" do it "returns tx_hash and raw tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_tx( chain: "sol", sender_hd_path: "m/5", sender_coin_seed_id: 2, nonce: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", recipient_address: "6vHLpKKajt5KRiH68RZAtYrVqgAmendK4HrbrUB5mymr", amount_in_lamport: nil, payer_hd_path: "m/7", payer_coin_seed_id: 2, nonce_account_address: nil, from_token_address: "GGSTqkryG9NCsDbwmYE2daSs2KRzpeCbPnhVmgHRFxQr", to_token_address: "BtPUymJdkRKWzBN1QUVeBhdhQaV9f5XJ29DZqEEcNp5M", token_amount_integer: 112 ) expect(response["tx_hash"]).to eq( "3PUXzHLNjv79DJ6cC9RWpzz8LYZZmaEAed6tb6jNtEetGHkXdB88hFiBCWYNXMDGpd2iNpZknJQ33kyLDjVjd4Fh" ) expect(response["raw_tx"]).to eq( "ABizvWDgfr76FbF8gTkzEEhetXg13rXLpZaW46KX5c4W8fnvjUe8cXxGymcsnPUTqsmz"\ "b5LshLj3KdvHCTCgnkHPzBoqkZ8NbPjFCcUcE782RGJo8JzWumS2HoRwnMj1c4YbfQSb"\ "jqndZwtp3AXsqcJAUhrRXrUXxTLp8MATB1D3TajQSXJ6RrMnTPgd8thePVnh5Ema1Lz9"\ "KPKyVbpFAbyAPamt3gUkt6iBQSiRUtRu6ThphJ5PY8dKUxHwFrcosniyYXFTYVMh2kTY"\ "kvHx7a8ahdVsNeoUzP7HYydXXCVhhLExer8es154T9QFgrM1rbkF1VdnSUGRzPD3Aojo"\ "GhkF7AX3jQqAchpvFMTHp6raUYbnYsPzwUrYP2yzo2PCd5k2saf6mVZvubeG2gpg6VYz"\ "T7YoS5wDPMZ1tVikEFdV76nbteGPBBTifzFJzA1b7hzzk3b9WFtzpb927" ) PortalConnectors.requester = "remitano" end end context "when transfer native currency on sol chain, using priority fee" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_tx( chain: "sol", sender_hd_path: "m/5", sender_coin_seed_id: 4, nonce: "EnyKaDRkA7P3TXBHFz82nqF2fSDen6DAPn2YsgN5knKH", recipient_address: "6vHLpKKajt5KRiH68RZAtYrVqgAmendK4HrbrUB5mymr", amount_in_lamport: 50_000_000, payer_hd_path: "m/7", payer_coin_seed_id: 4, nonce_account_address: nil, priority_fee_per_unit: 111 # micro-lamports ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "33QoR6nSbe5USi5mEvurvvcnqU1xbhc4b3pWctAvfUKjm6Zf8XeJmy5cTsJbzNeRDDr6BychKsxRkrArPWjHB1cC" ) expect(response["raw_tx"]).to eq( "FVk3qo8B7m568hYpxpQeCQGPn4C71jeBD6Mf24UTaVQc8SNQJMe7KPU8P5YrS9psQH" \ "8u9M11DiD4dPXzzs9SUMjtNNz7fPvkpUqSGjCsoPXyTEjPyvpK1qqxUGqHbE3VR3" \ "ntyrVqJBrLhDukAw9npXyVFMVqLzySdcXoZWUqBiV5VAixeTfckUULiLYkuy1dTF" \ "CPdCYLTyGFgYhhoZapZsYKtpaS29NHvbuGzeZPu2CtzyGn1gJukpKvMpM91EqD9S" \ "9kLqGQD5T4gVfELUPn5nmsF8aUicZGA4wnzKSWcVX8VuoqNPnq8KLuoXr1aS2zyj" \ "WMpQFE6rxgcJUrDnNSzR2W7w7XrRdXS9HRyp3WGqeKU72eeJPMpSxGNwuxHiuZic" \ "CqptpGLAGERRj7Lr8W636UmjsZRmT5m2GiwmjU141Nm6hDPcv5CVrS73UsMBDP42" \ "s3tBvyXVfFYBmJANvxkVTtBa7GebP14wd9" ) PortalConnectors.requester = "remitano" end end end describe "#sol_based_build_transfer_coin_tx_v2" do context "when transfer native currency on sol chain" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_tx_v2( chain: "sol", sender_hd_path: "m/5", sender_coin_seed_id: 4, nonce: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", recipient_address: "6vHLpKKajt5KRiH68RZAtYrVqgAmendK4HrbrUB5mymr", amount_in_lamport: 50_000_000, payer_hd_path: "m/7", payer_coin_seed_id: 4, nonce_account_address: nil, priority_fee_per_unit: 111 # micro-lamports ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "5qFnJ2pP89zV7eqX3rhuZdbBPX2icj1AUXkeW6VvMU6jwrZDAi5dhhLLDdHywgbRvQDCriQg8vxpVsWffwfLXpUr" ) expect(response["raw_tx"]).to eq( "JnpMznGcY5kLaBjABygcev2n7uEmWGhKLpkwmjuKi8vVPqzBw4DYzZbMrpdWHT6FSk" \ "phnmQH8cn9R6AWgwmeuo8kWkPzgj2i9Bp9gusVGbz8WHsEG4cq7xiegRoH75oirj" \ "594aBi7tCNyN4zL5tksZiFyXvdJRtM39rvo1g1zQA649J4ihmVYq2rbcDhpPb5py" \ "62mbbEwW49SPCoeNhp4TJDjzz3qPSuKmpMajc7H6TLXbEr3ThaUYSsMaq9mQ3dyR" \ "r5TZimZjTbLC3HdCxHUfHHsRVp74wnD435VH8iZHHhRHXq1N6681eVf9XcKVu2fm" \ "VqqpPEZ65knTqvs26MmGryWBXYHWFHQNZAo6rhxvYD1n7XK5zcfcaHtUYZm5F8Cu" \ "ZdLy7nCFPNSqzQiqKwrjvut7dmd59ZTHQxRbPhQfcJzGX36T56Qd7DbUTaaqzhSf" \ "WYF3aoUAshDUUVsgzW3hg19yJERxMb8Lbh" ) PortalConnectors.requester = "remitano" end end context "when transfer token on sol chain" do it "returns tx_hash and raw tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_tx_v2( chain: "sol", sender_hd_path: "m/5", sender_coin_seed_id: 4, nonce: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", recipient_address: "6vHLpKKajt5KRiH68RZAtYrVqgAmendK4HrbrUB5mymr", amount_in_lamport: 0, payer_hd_path: "m/7", payer_coin_seed_id: 4, nonce_account_address: nil, contract_address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", token_amount_integer: 900_000, priority_fee_per_unit: 111 # micro-lamports ) expect(response["tx_hash"]).to eq( "2ExLrcSBWaVoEhDZVSnGS8RHS5xMc858VwyxAr6AAjrEUGW1nDgSwmVGVMP39VN5i8ZDLAUvCink2wUtrjwUvcFv" ) expect(response["raw_tx"]).to eq( "2Lr7ZoZpqXf7Vthb7w6kDT3JpfuTTkypVbGEyVFsCwix4UtrdV75V37nFV8VrDcUyM" \ "bHAZCczTUrfUpGdDynNfkNwdJYYQApxt8A1zq2Gd5bCzs2rnq5EqhGJAotqD96xp" \ "r2ssBLCn96JdD1nb4Y37j5QxMRyZqCjZci1qE22JR18c9JNfbVKaptUxRxKmZKud" \ "AUfFPrGUXRDHnkgLkenEWEmWhhbjNvqzNhJcdb7FXG79jYuuJFEJRcvBC8BdezBu" \ "EvsdTCWoVRCjrXFTbwZUfEChD6v8Fyt5gf6Uw6beqcqpimeWFCKwvMdbcMQwzkim" \ "iLrmqBWmsCbGvZvhNsUowwc9iBRmQTrdKY7PqJpMfimfSVXF4XZ2LBGGAvtgjXr2" \ "HXFPdUr8nLeHZkvrCZRuJRrQSwUKhdc7a7wYWpSCKpdbjx19Y69C4uog2wLpnAtk" \ "CC2SrJAq9bY2VfCfXfVD5H2M9xvHzohKVPyCsjBMZDnMxmhTBGHQddSLMvXNHCh1" \ "7RJXAK15hYhWKrmb7wrETF8fNa86z5YPwX3TSNrD954h7udKEVZZijXhiBKZp4rL" \ "G1G2gjn7fCKnY2y1NJ6utd7wEb289mhyCnU8FCsEgiEGopKRjQXVUYQSxZFmTqXv" \ "mPbNTajZ7XM9ND9L6cRwoAstzKDkbkVy7CrvVeYRfpyW7BHqBwGMDTxTjAkJemZMjTLMsGZu" ) PortalConnectors.requester = "remitano" end end context "when transfer token on sol chain to off-curve receiver" do it "returns tx_hash and raw tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_tx_v2( chain: "sol", sender_hd_path: "m/5", sender_coin_seed_id: 4, nonce: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", recipient_address: "2x1YnEPrc1GuXy3sXEmhhN1w13fcCWzdLkTKHgjPH5Ds", amount_in_lamport: 0, payer_hd_path: "m/7", payer_coin_seed_id: 4, nonce_account_address: nil, contract_address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", token_amount_integer: 900_000, priority_fee_per_unit: 111, # micro-lamports allow_off_curve_receiver: "1" ) expect(response["tx_hash"]).to eq( "3dXc2ztiABcTYreTNJdo3Pc6AchK1bGxCBGfD8LnowmuaBvQ8MrtcB9WBfGE3MCSHEdv2WK6QUGRnSVLh9pLzmBM" ) expect(response["raw_tx"]).to eq( "bZk91Cr96E4KKPF15oBW35Fkm2t7i7gd61RRRfVWCgRGJdThWQxGqVkzxsawTU4fYB" \ "sCZ9DHtc2ToGjk5JFd81GpnUCsXP2nQRDHLVg6YEddwLiPUMpqJ8rjh6Ydivau9r9Y" \ "p4C68skEm8v23dCWN79edXcfKonGZC4Ygsw3bh9mCsKuxEKYZDgU2Hb452Fbu3etrF" \ "JKdohBgZeaSGUNXV5YsXuZWZSxxtA12fzt9WH3a9hLxYKF3ciY5puY8m8dfzLoXiJU" \ "a3sxYgACmDzDfjX5gE88PVZetCxiFdgXh3eYn7kjDEA8WEUcttzfJBYago9WLCmaNC" \ "9CwThPvxKqTYGZGMJxzNak5DXNuFt345mbnTaPNqivZ7ZPdAcEBHmVqBtkBTsFN7YP" \ "emNXYFNPzuEH4Jemf3ga2NrfmGheyKZ2ndD1EjTSQCFTkXwdFrA6KuurUwhaTvaaHr" \ "ww5kPKRQKtR1RVQzPZJbkyktQrc88uLwWrZ722Wsxn7YSfktRcCPo8vMAJM6QJXf3F" \ "BZdLUHapTKCvvEfppq9oxiUFHYwN2wa4GZV737dVBvhE28oeBeYp4F" ) PortalConnectors.requester = "remitano" end end end describe "#sol_based_build_transfer_coin_to_multi_destinations_tx" do context "transfer renec" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_transfer_coin_to_multi_destinations_tx( chain: "renec", sender_hd_path: "m/1", sender_coin_seed_id: 16, payer_hd_path: "m/2", payer_coin_seed_id: 16, recipient_addresses_and_lamport_amounts: { "6vHLpKKajt5KRiH68RZAtYrVqgAmendK4HrbrUB5mymr" => 50_000_000, "BQyxJE3E54faKmxXmqFSoeKSv8ygr4yM7cg3SeEuEGKn" => 60_000_000, }, nonce: "3kH9jFexWzycyrzspm3kSxff1XxYFuGTzaPxv5dc1ESZ", nonce_account_address: nil, ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "5jsvJeiymoE7XjBxF5ui84YsphkL6RnakSusLVYfWuptPMpseNwEBaL7jgheppUjetwxub3TehvQ3JwgGvMcx3HY" ) expect(response["raw_tx"]).to eq( "9oeu1bTyqh7D9zf6ZSVVkvUuWBjocur2TUBARWSYxdARLJWEAEFZDteA5hu4vLZ8oD"\ "zJpLazsdJSF9xf6TPNJzeuLGJTXHmjc4UMiKgKnLkuW3wJKGnjiKYvTjBzUEx7VjPS"\ "hoPdYC4ASMdm8LCsQGySHU2DUpGcNT6hMoBrdK8vKdbgWmS7e5e88Cr5JJv26RiKkT"\ "vcGHBjDDZH3s6HjDuaiHB3vm6akKLRfKRLo5nfhm2mPYnNaQHnpkQN6qqYFs2m8pcU"\ "NRfqfkWeEn6Eo1EusXPvMntvD3ScXhPmDHjHHa3BPrA63uubkcsfRePx6194RkHnfG"\ "AAnamLZ1JrVB9cnKrWLMiM9qiuBLR3JfeRmt5YZUUcojDGKPMfupNKaR5jRzJ7UZ5U"\ "2NmcaFGb45ztjDfuWmGNNmEtyd9MURFmtUxLkDC5akQjJ6p5pdQq2G2Hx5aKqfuLcQ"\ "ZCM6x2BC72MN5ucFM5Cpz5mtQhG6s", ) PortalConnectors.requester = "remitano" end end end describe "#sol_based_build_create_nonce_account_tx" do it "returns tx hash and raw tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_create_nonce_account_tx( chain: "sol", recent_blockhash: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", buffer_hd_path: "m/5", buffer_coin_seed_id: 4, nonce_account_hd_path: "m/6", nonce_account_coin_seed_id: 4, amount_in_lamport: 2_000_000 ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "4fAQURJdLcJwqjY166oFgjcd5zbJK6KjSvSLZ2dpstYAYYBgbvNJXkV3E8vaxC38Pm82PLPzTB2ETsbA6WTQZ5vA" ) expect(response["raw_tx"]).to eq( "4BYBzWPrQo5BRmoPByseYh1Pv1diFnJnUToTfQiejrBGXGU6g7ui8sApocLdPsaR8Gu9wb"\ "RZH9ztE7PqcXmveHD38wvJSP2CsEtDizjRNtYbt2CFGEMbHaJYjams5i9K3iJu9fE8nYtt"\ "uEoGSBq3RBa39WUaMZ1kWZCYLPy5zVK56GUGaq4gG9jyK5BLDBqoQEYuX1vTdw9bA1h1iK"\ "qoHAbUSyv8ZzLKFeQ5uBGyJ1rw3h3mSxoY5QhcUgj1e9C6MjLy4QWK5y7TCkG8K6Mp9wKc"\ "XLYTUWESxx7KxV6y7AjDzNfj12tnmn4WMihCNNWfGc7Wh1soHQHVi5ZyhzvPd5DEqaNyLu"\ "EoWvmJNDrunaCnV73PQRU6rdTd22Y6sEtabZWG9ZvQ584iJdKeMtPiK7j1jss2FDgTTC7D"\ "FfyaCbRuafRCaQbmvsb8CYeG2ruqaHBMosTTEpYi6LP1Aojhy7fNQ51YMHpXzEG7FP2CFo"\ "jD9hLoCSRyuC6QymU8ehaMLgSxKE4fkqRYE3BGPGfLiF4ZSSGE64QSPBQgaRqNJyTL9ZT4"\ "FbSeQ3dKZ47Psd9UvB4W" ) PortalConnectors.requester = "remitano" end end describe "#sol_based_build_create_token_account_tx" do it "returns tx hash and raw tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_create_token_account_tx( chain: "sol", recent_blockhash: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", fee_payer_hd_path: "m/5", fee_payer_coin_seed_id: 4, contract_address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", owner_address: "MEW6o2W4zTxMZ4GfTv3En4dW4wMk9DUCfbqjax7d7eP" ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "5bTvYTdoDVpYGQQo6ajN8jhyrAvPP5nRujfH6PnV9HbMugN8qsjufUP2ZN8yXv37H8SeNvcApmEpUiHnecEquWeR" ) expect(response["raw_tx"]).to eq( "5DVy5DXzzdb8Am37RbnP8CdX1khyMZWHVCcZHLS5zBVbNzCmjRLocPiUmphuitKEAiDjk4"\ "2LZ9fHxrhLhS8965vefXnbtBEWbkTxjHQMyFYvC3v2PMZYVHtqbnPbcqqkBCQPCeXyheEQ"\ "Jxq7MXM9fhjq5KxMvt7UhVncckhrx488oqbkkiyScsuaTjH3rzTRA1TZMGqdzZR5YzYiz7"\ "FqkZ8dWRBbA2KJqshYW6ez99KZqtuXJcGSyRV7vBJC5fWDFecVATEJSwkxjxBvdE9jMy4x"\ "KYpgMcvozLX8BtabPXd4k9RHohVrBjaZmLg1i7pmVtmKtSypGkU2ebkbnxBbsFL48sZpJf"\ "1vgHcV3LffKHRztaaCgEqHHSy2VG5opcedWkcBXkoavQH9fE9MCctyfCrHNQ6DYWnFdVxc"\ "uUwfTAY5vp5RktE2VTXdMpdRu7hxLZfgmteoDfzMTybTQ8XXH4Sq91iRKgF4DSu2eB8E3Q"\ "DDquiSrPZLRd" ) PortalConnectors.requester = "remitano" end context "using priority fee" do it "returns tx hash and raw tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.sol_based_build_create_token_account_tx( chain: "sol", recent_blockhash: "EnyKaDRkA7P3TXBHFz82nqF4fSDen6DAPn2YsgN5knKH", fee_payer_hd_path: "m/5", fee_payer_coin_seed_id: 4, contract_address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", owner_address: "MEW6o2W4zTxMZ4GfTv3En4dW4wMk9DUCfbqjax7d7eP", priority_fee_per_unit: 111 # micro-lamports ) expect(ok).to be(true) expect(response["tx_hash"]).to eq( "jvvoyCwEDBRMEqs3m3J28a7us7cizr8538tgdTwZMdHtiUevy29nEJEA1DUycYh68Fx4QZraBkgYLShS6sZv14F" ) expect(response["raw_tx"]).to eq( "4eeR283XKnmjn2Az9D2npesX4JcRBmcxtwbrtFfDT1vDqXFsPLGqATiwgSbvnKCrbM" \ "6xkr1m7TbwhU9iTyGrWjZPPgE39A8JGJHPn2gMwPMj9E2SsWZKEdFxdfnodDGdBC" \ "zHKtV7wNYYEBr8qPGGQNBFGB4jzQUctFAa2g6ympfoRZjakbdq6C6LmCSBigCWiQ" \ "NSREQ1M9tarm7m81nduBJBd9KGYWc6n2EadyiKYqsMFQc2V4JNNfLSuwuhY3Q1Tr" \ "fQjpKdbbQPMRSWCEoCiVu3GCpk8d42miRn5UwRv2srYUYnkKTT52vzJEJXoENE1P" \ "T3SVpMeriKkjb3tCvn6jWbygY5Jz19pa32i336nFgGd8x6skVd8GmV9KAnQ9J71H" \ "8kPhV85VUT7WLWe7dRaNfbysquvDC8FbxwA39cZNViZLaRQbi6aen2aFtQ7WBN7p" \ "51ffEDtarUuMp1VuqY4PAVguEpuDvqT9gRq4fvXZ8XWsKyeoSEG9TGPYZTdWjXTt" \ "dFBHwz8jct8gaVCPFGh4XuoUbJKXKzJMBxxNj7N3LMvucGRV" ) PortalConnectors.requester = "remitano" end end end describe "#eth_based_build_transfer_coin_tx" do context "transfers native currency eth" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.eth_based_build_transfer_coin_tx( chain: "eth", sender_hd_path: "m/27", sender_coin_seed_id: 5, recipient_address: "0xacdc812f6f7628630d177bf23ea5be77de3f0f47", nonce_as_hex: "0x1b", wei_amount_as_hex: "0x6f05b59d3b20000", gas_limit_as_hex: "0x5208", gas_wei_price_as_hex: "0x12a05f2000", max_priority_wei_fee_per_gas_as_hex: "0x3b9aca00" ) expect(ok).to be true expect(response["tx_hash"]).to eq( "0x7ea7a3bc8bbd42066ea33dd89c4547bc4feb1daff905e0f3b070567353abd95f" ) expect(response["raw_tx"]).to eq( "0x02f873011b843b9aca008512a05f200082520894acdc812f6f7628630d177bf23e"\ "a5be77de3f0f478806f05b59d3b2000080c001a01fe95971cd156f9651160724e75c"\ "d6d8aaca292f767cf3b5c2ab50d3b5c73b2ba05b1bf764b32952a44d317db2ab41fe"\ "78cb8f1740524f2a9efeeabf06730cf4a8" ) PortalConnectors.requester = "remitano" end end context "transfers token on eth chain" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.eth_based_build_transfer_coin_tx( chain: "eth", sender_hd_path: "m/29", sender_coin_seed_id: 5, recipient_address: "0xb8c77482e45f1f44de1745f52c74426c631bdd52", nonce_as_hex: "0x1b", wei_amount_as_hex: "0x0", gas_limit_as_hex: "0x15f90", gas_wei_price_as_hex: "0xa7a358200", max_priority_wei_fee_per_gas_as_hex: "0x3b9aca00", raw_data: "0xa9059cbb0000000000000000000000002789e2a5c4f3835740c89c34"\ "22cce4ae3a4ce8f50000000000000000000000000000000000000000000000000000000000000064" ) expect(ok).to be true expect(response["tx_hash"]).to eq( "0x62b0f7f787e27cc7500479d6244d48ef69e4d188d02d6f97a97ed75c52ae7a5c" ) expect(response["raw_tx"]).to eq( "0x02f8b1011b843b9aca00850a7a35820083015f9094b8c77482e45f1f44de1745f5"\ "2c74426c631bdd5280b844a9059cbb0000000000000000000000002789e2a5c4f383"\ "5740c89c3422cce4ae3a4ce8f5000000000000000000000000000000000000000000"\ "0000000000000000000064c001a01a1ea87e25872e5ae286943566ff668436f0f84d"\ "590309efb19ba827df33f2c2a0306b191fa0b80e943ad1c53621d76b191c5bb79401"\ "6355f0b8bdb3d234b38e00" ) PortalConnectors.requester = "remitano" end end context "transfers matic from BNB address" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.eth_based_build_transfer_coin_tx( chain: "matic", sender_hd_path: "m/11", sender_coin_seed_id: 6, recipient_address: "0xacdc812f6f7628630d177bf23ea5be77de3f0f47", nonce_as_hex: "0x14", wei_amount_as_hex: "0x2386f26fc10000", gas_limit_as_hex: "0x5208", gas_wei_price_as_hex: "0x8bb2c97000", max_priority_wei_fee_per_gas_as_hex: "0x6fc23ac00", sender_chain: "bnb", ) expect(ok).to be true expect(response["tx_hash"]).to eq( "0x99f5c6767d4715078f95959a69843b783dfea613d222e040b68e4c71f1fd2780" ) expect(response["raw_tx"]).to eq( "0x02f8748189148506fc23ac00858bb2c9700082520894acdc812f6f7628630d17"\ "7bf23ea5be77de3f0f47872386f26fc1000080c080a017741c04a60d90a1fc651e"\ "ebd987129c6154ca968a2ca32cc7cedc2bb34686b2a01d12db0bde9810cf879214"\ "ee6593bc5b887edf851abae92dda17038c89e6468b", ) PortalConnectors.requester = "remitano" end end end describe "#trx_sign_tx" do it "returns signed tx as json object", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.trx_sign_tx( hd_path: "m/5/1/1", coin_seed_id: 13, unsigned_tx_json_str: "{\"txID\":\"f46844d97b58c673a141c87e55cede8b305e2b70f7ef9a1d662a588579557a40\",\"raw_data\":{\"contract\":[{\"parameter\":{\"value\":{\"amount\":1123400,\"owner_address\":\"4197a4839401b803090518e7ff32a896e4cd49d6f0\",\"to_address\":\"41569a38e293bf3feeeb8cbe6dd7016b4119bd0a75\"},\"type_url\":\"type.googleapis.com/protocol.TransferContract\"},\"type\":\"TransferContract\"}],\"ref_block_bytes\":\"5f78\",\"ref_block_hash\":\"801318ea379e21b4\",\"expiration\":1698297909000,\"timestamp\":1698215050745},\"raw_data_hex\":\"0a025f782208801318ea379e21b440889ec6d3b6315a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a154197a4839401b803090518e7ff32a896e4cd49d6f0121541569a38e293bf3feeeb8cbe6dd7016b4119bd0a7518c8c84470f9fb84acb631\",\"visible\":false}" ) expect(ok).to be(true) expect(response["signed_tx_json_obj"]).to eq( { "txID" => "f46844d97b58c673a141c87e55cede8b305e2b70f7ef9a1d662a588579557a40", "raw_data" => { "contract" => [{ "parameter" => { "value" => { "amount" => 1123400, "owner_address" => "4197a4839401b803090518e7ff32a896e4cd49d6f0", "to_address" => "41569a38e293bf3feeeb8cbe6dd7016b4119bd0a75" }, "type_url" => "type.googleapis.com/protocol.TransferContract" }, "type" => "TransferContract" }], "ref_block_bytes" => "5f78", "ref_block_hash" => "801318ea379e21b4", "expiration" => 1698297909000, "timestamp" => 1698215050745 }, "raw_data_hex" => "0a025f782208801318ea379e21b440889ec6d3b6315a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a154197a4839401b803090518e7ff32a896e4cd49d6f0121541569a38e293bf3feeeb8cbe6dd7016b4119bd0a7518c8c84470f9fb84acb631", "visible" => false, "signature" => ["c4b2eadbf9ded30efd7606cd219fa6ec2fd78a315a42eece1fa6bfafa36086f452cbc5c167f2abeb4a627efc90d9982e6b6b8007135c95502c9321d5dc93909000"] } ) PortalConnectors.requester = "remitano" end end describe "#xrp_sign_tx" do it "returns signed tx as json object", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.xrp_sign_tx( hd_path: "m/5/1/0", coin_seed_id: 15, unsigned_tx_json_str: "{\"TransactionType\":\"Payment\",\"Account\":\"rbGo6KKJJhNQPmr4fcT5oFKvaoEP839qK\",\"Destination\":\"rG5UyEqao5KWqwZanaQtWFFhvJENqxZCLV\",\"Amount\":\"900000000\",\"Flags\":2147483648,\"DestinationTag\":1001,\"LastLedgerSequence\":122000,\"Fee\":\"12000\",\"Sequence\":1}" ) expect(ok).to be(true) expect(response["signed_tx_json_obj"]).to eq( { "txJSON" => { "TransactionType" => "Payment", "Flags" => 2147483648, "Sequence" => 1, "DestinationTag" => 1001, "LastLedgerSequence" => 122000, "Amount" => "900000000", "Fee" => "12000", "SigningPubKey" => "03365C3681071961A27B9531036E2E7B244FE83F1BD56966E9E772F77188C1E565", "TxnSignature" => "3045022100A45D36DD6689728880FD1BFBE64DD563EF9A138D64F715D5ACFD523DC92314E502204CBF9131784177A28DFE29DD54A6FB56D8278F3C62B747295B29D2ADFDDA7A1F", "Account" => "rbGo6KKJJhNQPmr4fcT5oFKvaoEP839qK", "Destination" => "rG5UyEqao5KWqwZanaQtWFFhvJENqxZCLV" }, "txHash" => "1362EE7039F683142849E6DA200F2BF08951972652386B17420758DA945D9088", "txPayload" => "120000228000000024000000012E000003E9201B0001DC90614000000035A4E900684000000000002EE0732103365C3681071961A27B9531036E2E7B244FE83F1BD56966E9E772F77188C1E56574473045022100A45D36DD6689728880FD1BFBE64DD563EF9A138D64F715D5ACFD523DC92314E502204CBF9131784177A28DFE29DD54A6FB56D8278F3C62B747295B29D2ADFDDA7A1F8114067B560C35EE191DDB94EF8587C13D9BB8486D198314AC54EEE4ECD96B55338ADFAA24C6E3BB4E375445" } ) PortalConnectors.requester = "remitano" end end describe "#ton_sign_tx" do it "returns signed tx as json object", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.ton_sign_tx( hd_path: "m/11", coin_seed_id: 3, amount: 1, is_contract_deployed: false, to_address: "UQBVUbkUh7Nvi_n3IEh3U5l0TGuu2XGt-Z_UzU-a4CmrI7rX", message: "some_message", bounce: false, seqno: 1, is_contract_deployed: false ) expect(ok).to be(true) expect(response["signed_tx_json_obj"]).to eq({ "txHash"=>"aebGFYPTxnTZt402IlAsd8Qd7vl1rRqeDXrxLtNqZ08=", "rawTransaction"=>"te6cckEBAgEAugAB4YgBno1TrK2R6aIp/llOm0Wmxp4r90wsH6hdTFVnXZBiQrID6+GuEZPobLIUYoObfZOcFhs8pY1e3jw0lWfvoVSfRCHuUSvbmiwCQMFv/ldL3gF3QbA5JvlxSy0TDhwQP60wAAAAAAs0DGAgAAAACAAMAQCIQgAqqNyKQ9m3xfz7kCQ7qcy6JjXXbLjW/M/qZqfNcBTVkaHc1lAAAAAAAAAAAAAAAAAAAAAAAABzb21lX21lc3NhZ2U0+3no" }) PortalConnectors.requester = "remitano" end end describe "#jetton_sign_tx" do it "returns signed tx as json object", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.jetton_sign_tx( hd_path: "m/11", coin_seed_id: 3, jetton_sender_address: "EQC_npgMEQeyU7R2-vL4WI02Fu8cxDg1C_x-5dGnj_u7F9XI", message: "test jetton 1", jetton_amount: "1130000", # 1.13 usdt receiver_address: "UQAKEkpUXmiS6D3SnTAMtK-jNaCsppzx8bmKuiotR9FlrwUP", forward_ton_amount: "10000000", # 0.01 ton attached_ton_amount: "50000000", # 0.05 ton seqno: "1" ) expect(ok).to be(true) expect(response["signed_tx_json_obj"]).to eq({ "txHash"=>"mLXRXm0aDD1tzlGNAyntQe6n1njL1CHUCzdcvz+G2tY=", "rawTransaction"=>"te6cckECAwEAARQAAeGIAZ6NU6ytkemiKf5ZTptFpsaeK/dMLB+oXUxVZ12QYkKyAm+mtH/KtjWSt4dqOMs07yF/fMPBU0YO4rVikSOYJGq8PgaqW/s6+hvvQsd2PfXorUbEIjieKR6ZzAWAlcHycCFNTRi7NJxd6AAAAAgAHAEBaGIAX89MBgiD2SnaO315fCxGmwt3jmIcGoX+P3Lo08f93YugF9eEAAAAAAAAAAAAAAAAAAECAM4Pin6lAAAAAAAAAAAxE+EIABQklKi80SXQe6U6YBlpX0ZrQVlNOePjcxV0VFqPostfADPRqnWVsj00RT/LKdNotNjTxX7phYP1C6mKrOuyDEhWRzEtAAAAAAB0ZXN0IGpldHRvbiAxF/T3lg==" }) PortalConnectors.requester = "remitano" end end describe "#btc_based_sign_tx" do context "transfers btc" do it "returns unpacked signed tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.btc_based_sign_tx( chain: "btc", sender_hd_path: "m/27", sender_coin_seed_id: 10, unpacked_signature_hash: "395c56d49e3c80bea2dd84a9e29384738032e63766039a29397fc51cf4a97ac0", ) expect(ok).to be true expect(response["unpacked_signed_tx"]).to eq( "3045022100fc80d6ab0cec8f998cefb7912ac86d1492bf6100303c284b86bf4be8"\ "c1d67c9002204912a412a622bdf42bfb5f9105847c6acdb22a8b8419ff3f7c8b1e8c642f4f04" ) PortalConnectors.requester = "remitano" end end context "transfers bch" do it "returns unpacked signed tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.btc_based_sign_tx( chain: "bch", sender_hd_path: "m/27", sender_coin_seed_id: 12, unpacked_signature_hash: "840e35c0df6b97a7abc30f9de597e541a94c7329f9e5cdeaa9a0050c3e8a357e", ) expect(ok).to be true expect(response["unpacked_signed_tx"]).to eq( "3045022100ed8c4c4ef48fb5f8539deef3c30b1872bd991100f58a64ba374815d92"\ "148d8b80220410fad168b6db892022a925bf76e4597bec98363cf75a6214b811e2a7e4832e7" ) PortalConnectors.requester = "remitano" end end context "transfers ltc" do it "returns unpacked signed tx", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.btc_based_sign_tx( chain: "ltc", sender_hd_path: "m/27", sender_coin_seed_id: 11, unpacked_signature_hash: "395c56d49e3c80bea2dd84a9e29384738032e63766039a29397fc51cf4a97ac0", ) expect(ok).to be true expect(response["unpacked_signed_tx"]).to eq( "3045022100e957a4848bcce7bf028bf2c9c9e57ed97f6cff62d79d9f922ce53e78"\ "d8c2f9d70220219a75bee4f5eb2d4e17bfa2d963d6c86a7e4ea566c76206dd0375b7b8c35a9f" ) PortalConnectors.requester = "remitano" end end end describe "#btc_based_sign_txes" do context "transfers btc" do it "returns unpacked signed txes", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.btc_based_sign_txes( chain: "btc", sender_hd_paths: ["m/27", "m/29"], sender_coin_seed_ids: [22, 23], unpacked_signature_hashes: [ "371a79e5a37104db2b69d3259f48eeb4f58a67e0c6bf251f2cdf3d8b57ee653f", "840e35c0df6b97a7abc30f9de597e541a94c7329f9e5cdeaa9a0050c3e8a357e", ], ) expect(ok).to be true expect(response["unpacked_signed_txes"]).to eq( [ "304402202f0ef66460d90db080c323fa72b224ea826e77c6687232adee86d0e1" \ "20739f7d02206c6f7f5f3e81edaf1be9f4970316bfd41b4c72016d3ca70a8d4038e12c06fc49", "304402206400cfa147e2a985f9a1f13c0cbfea9229c72faff63aa6f389f17697" \ "31cd815d02202df076ceed37869b2133db8037ced5b6f69bb0a16b3ef0f62929ad5223d1ea3c", ] ) PortalConnectors.requester = "remitano" end end end describe "#btc_based_sign_txes_v2" do context "transfers btc" do it "returns unpacked signed txes", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton response, ok = client.btc_based_sign_txes_v2( chain: "btc", sender_hd_paths: ["m/27", "m/29"], sender_coin_seed_ids: [22, 23], unpacked_signature_hashes: [ "371a79e5a37104db2b69d3259f48eeb4f58a67e0c6bf251f2cdf3d8b57ee653f", "840e35c0df6b97a7abc30f9de597e541a94c7329f9e5cdeaa9a0050c3e8a357e", ], ) expect(ok).to be true expect(response["unpacked_signed_txes"]).to eq( [ "304402205e078cfc550bf923fdd58a3cad8849483b90ed91e179cc2c859642e9" \ "1ea1f86e022029c612c48dda5a087d6c371b631dddd62ebd4807e36ce19241ba50e64e55d17e", "3045022100e1f1fc19b7d662d65f1b8923f2094afc6e4b4c1a41301f59173d" \ "9fc1d142c83d02205da421eaf787e2b2f889714e3905e7655380b6b890b7ec1a89342cf1b00b2858", ] ) PortalConnectors.requester = "remitano" end end end describe "#unsupported_eth_based_sign_tx" do context "transfer native coin on any unsupported eth-based chain from bnb address" do it "returns tx_hash and raw", :vcr do PortalConnectors.requester = "coin_portal" client = PortalConnectors::KeyPortalClient.singleton unsigned_tx_json_str = "{\"to\":\"0xA48567A7374fD6Ea2495534491a2e4D9FF77d274\","\ "\"value\":\"0x16345785d8a0000\",\"data\":\"0x\",\"type\":2,"\ "\"from\":\"0xc9aAD004e656153e7Ea4633BbF3Dc10BcE7a50fb\","\ "\"maxFeePerGas\":{\"type\":\"BigNumber\",\"hex\":\"0x59682f22\"},"\ "\"maxPriorityFeePerGas\":{\"type\":\"BigNumber\",\"hex\":\"0x59682f00\"},"\ "\"nonce\":0,\"gasLimit\":{\"type\":\"BigNumber\",\"hex\":\"0x5208\"},\"chainId\":80001}" response, ok = client.unsupported_eth_based_sign_tx( sender_chain: "bnb", sender_hd_path: "m/1/2", sender_coin_seed_id: 6, unsigned_tx_json_str: unsigned_tx_json_str, ) expect(ok).to be true expect(response["tx_hash"]).to eq( "0x14d8f0e08e54b0facc407dbd354c37589451c801b9e04d89e995dda42b173948", ) expect(response["raw_tx"]).to eq( "0x02f87583013881808459682f008459682f2282520894a48567a7374fd6ea2495"\ "534491a2e4d9ff77d27488016345785d8a000080c001a07c1911be216e07fa029e"\ "1c0f8d2fb5a0345d4e2d5ebca733cec3fa54a6466cdea0217c9638784ef4ead02b"\ "1e2a72ecae02029a57a50edf426683b359888e5282d8", ) PortalConnectors.requester = "remitano" end end end describe "#portal_name" do it "related to the class name" do client = PortalConnectors::KeyPortalClient.singleton expect(client.send(:portal_name)).to eq "key_portal" end end end