mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-02-03 01:49:54 -05:00
rename to getNewDepositAddress()
This commit is contained in:
parent
1a08f3d15f
commit
8594483c27
@ -583,12 +583,12 @@ test("Has a Monero wallet", async () => {
|
|||||||
|
|
||||||
// get new deposit addresses
|
// get new deposit addresses
|
||||||
for (let i = 0; i < 0; i++) {
|
for (let i = 0; i < 0; i++) {
|
||||||
let address = await alice.getNewDepositSubaddress(); // TODO: rename to getNewDepositAddress()
|
let address = await alice.getNewDepositAddress();
|
||||||
MoneroUtils.validateAddress(address, MoneroNetworkType.STAGNET);
|
MoneroUtils.validateAddress(address, MoneroNetworkType.STAGNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create withdraw tx
|
// create withdraw tx
|
||||||
let destination = new XmrDestination().setAddress(await alice.getNewDepositSubaddress()).setAmount("100000000000");
|
let destination = new XmrDestination().setAddress(await alice.getNewDepositAddress()).setAmount("100000000000");
|
||||||
let tx = await alice.createXmrTx([destination]);
|
let tx = await alice.createXmrTx([destination]);
|
||||||
testTx(tx, {isCreatedTx: true});
|
testTx(tx, {isCreatedTx: true});
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ test("Can complete a trade", async () => {
|
|||||||
// bob takes offer
|
// bob takes offer
|
||||||
let startTime = Date.now();
|
let startTime = Date.now();
|
||||||
HavenoUtils.log(1, "Bob taking offer");
|
HavenoUtils.log(1, "Bob taking offer");
|
||||||
let trade: TradeInfo = await bob.takeOffer(offer.getId(), paymentAccount.getId()); // TODO (woodser): this returns before trade is fully initialized
|
let trade: TradeInfo = await bob.takeOffer(offer.getId(), paymentAccount.getId());
|
||||||
expect(trade.getPhase()).toEqual("DEPOSIT_PUBLISHED");
|
expect(trade.getPhase()).toEqual("DEPOSIT_PUBLISHED");
|
||||||
HavenoUtils.log(1, "Bob done taking offer in " + (Date.now() - startTime) + " ms");
|
HavenoUtils.log(1, "Bob done taking offer in " + (Date.now() - startTime) + " ms");
|
||||||
|
|
||||||
@ -1303,7 +1303,7 @@ test("Cannot make or take offer with insufficient unlocked funds", async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// alice posts offer
|
// alice posts offer
|
||||||
let offers: OfferInfo[] = await alice.getMyOffers("ETH", "buy"); // TODO: support alice.getMyOffers() without direction
|
let offers: OfferInfo[] = await alice.getMyOffers("ETH");
|
||||||
let offer: OfferInfo;
|
let offer: OfferInfo;
|
||||||
if (offers.length) offer = offers[0];
|
if (offers.length) offer = offers[0];
|
||||||
else {
|
else {
|
||||||
@ -1316,7 +1316,7 @@ test("Cannot make or take offer with insufficient unlocked funds", async () => {
|
|||||||
|
|
||||||
// charlie cannot take offer with insufficient funds
|
// charlie cannot take offer with insufficient funds
|
||||||
try {
|
try {
|
||||||
await charlie.takeOffer(offer.getId(), paymentAccount.getId()); // TODO (woodser): this returns before trade is fully initialized
|
await charlie.takeOffer(offer.getId(), paymentAccount.getId());
|
||||||
throw new Error("Should have failed taking offer with insufficient funds")
|
throw new Error("Should have failed taking offer with insufficient funds")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let errTyped = err as grpcWeb.RpcError;
|
let errTyped = err as grpcWeb.RpcError;
|
||||||
@ -1330,7 +1330,7 @@ test("Cannot make or take offer with insufficient unlocked funds", async () => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
let errTyped = err as grpcWeb.RpcError;
|
let errTyped = err as grpcWeb.RpcError;
|
||||||
assert.equal(errTyped.code, 3);
|
assert.equal(errTyped.code, 3);
|
||||||
assert(errTyped.message.includes("trade with id '" + offer.getId() + "' not found")); // TODO (woodser): error message does not contain stacktrace
|
assert(errTyped.message.includes("trade with id '" + offer.getId() + "' not found"));
|
||||||
}
|
}
|
||||||
} catch (err2) {
|
} catch (err2) {
|
||||||
err = err2;
|
err = err2;
|
||||||
@ -1659,7 +1659,7 @@ async function waitForUnlockedBalance(amount: bigint, ...wallets: any[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDepositAddress(): Promise<string> {
|
async getDepositAddress(): Promise<string> {
|
||||||
if (this._wallet instanceof haveno) return await this._wallet.getNewDepositSubaddress();
|
if (this._wallet instanceof haveno) return await this._wallet.getNewDepositAddress();
|
||||||
else return (await this._wallet.createSubaddress()).getAddress();
|
else return (await this._wallet.createSubaddress()).getAddress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import {HavenoUtils} from "./utils/HavenoUtils";
|
|||||||
import {TaskLooper} from "./utils/TaskLooper";
|
import {TaskLooper} from "./utils/TaskLooper";
|
||||||
import * as grpcWeb from 'grpc-web';
|
import * as grpcWeb from 'grpc-web';
|
||||||
import {GetVersionClient, AccountClient, MoneroConnectionsClient, DisputesClient, DisputeAgentsClient, NotificationsClient, WalletsClient, PriceClient, OffersClient, PaymentAccountsClient, TradesClient, ShutdownServerClient, MoneroNodeClient} from './protobuf/GrpcServiceClientPb';
|
import {GetVersionClient, AccountClient, MoneroConnectionsClient, DisputesClient, DisputeAgentsClient, NotificationsClient, WalletsClient, PriceClient, OffersClient, PaymentAccountsClient, TradesClient, ShutdownServerClient, MoneroNodeClient} from './protobuf/GrpcServiceClientPb';
|
||||||
import {GetVersionRequest, GetVersionReply, IsAppInitializedRequest, IsAppInitializedReply, RegisterDisputeAgentRequest, MarketPriceRequest, MarketPriceReply, MarketPricesRequest, MarketPricesReply, MarketPriceInfo, MarketDepthRequest, MarketDepthReply, MarketDepthInfo, GetBalancesRequest, GetBalancesReply, XmrBalanceInfo, GetMyOfferRequest, GetMyOfferReply, GetOffersRequest, GetOffersReply, OfferInfo, GetPaymentMethodsRequest, GetPaymentMethodsReply, GetPaymentAccountFormRequest, CreatePaymentAccountRequest, CreatePaymentAccountReply, GetPaymentAccountFormReply, GetPaymentAccountsRequest, GetPaymentAccountsReply, CreateCryptoCurrencyPaymentAccountRequest, CreateCryptoCurrencyPaymentAccountReply, CreateOfferRequest, CreateOfferReply, CancelOfferRequest, TakeOfferRequest, TakeOfferReply, TradeInfo, GetTradeRequest, GetTradeReply, GetTradesRequest, GetTradesReply, GetNewDepositSubaddressRequest, GetNewDepositSubaddressReply, ConfirmPaymentStartedRequest, ConfirmPaymentReceivedRequest, XmrTx, GetXmrTxsRequest, GetXmrTxsReply, XmrDestination, CreateXmrTxRequest, CreateXmrTxReply, RelayXmrTxRequest, RelayXmrTxReply, CreateAccountRequest, AccountExistsRequest, AccountExistsReply, DeleteAccountRequest, OpenAccountRequest, IsAccountOpenRequest, IsAccountOpenReply, CloseAccountRequest, ChangePasswordRequest, BackupAccountRequest, BackupAccountReply, RestoreAccountRequest, StopRequest, NotificationMessage, RegisterNotificationListenerRequest, SendNotificationRequest, UrlConnection, AddConnectionRequest, RemoveConnectionRequest, GetConnectionRequest, GetConnectionsRequest, SetConnectionRequest, CheckConnectionRequest, CheckConnectionsReply, CheckConnectionsRequest, StartCheckingConnectionsRequest, StopCheckingConnectionsRequest, GetBestAvailableConnectionRequest, SetAutoSwitchRequest, CheckConnectionReply, GetConnectionsReply, GetConnectionReply, GetBestAvailableConnectionReply, GetDisputeRequest, GetDisputeReply, GetDisputesRequest, GetDisputesReply, OpenDisputeRequest, ResolveDisputeRequest, SendDisputeChatMessageRequest, SendChatMessageRequest, GetChatMessagesRequest, GetChatMessagesReply, StartMoneroNodeRequest, StopMoneroNodeRequest, IsMoneroNodeRunningRequest, IsMoneroNodeRunningReply, GetMoneroNodeSettingsRequest, GetMoneroNodeSettingsReply} from './protobuf/grpc_pb';
|
import {GetVersionRequest, GetVersionReply, IsAppInitializedRequest, IsAppInitializedReply, RegisterDisputeAgentRequest, MarketPriceRequest, MarketPriceReply, MarketPricesRequest, MarketPricesReply, MarketPriceInfo, MarketDepthRequest, MarketDepthReply, MarketDepthInfo, GetBalancesRequest, GetBalancesReply, XmrBalanceInfo, GetMyOfferRequest, GetMyOfferReply, GetOffersRequest, GetOffersReply, OfferInfo, GetPaymentMethodsRequest, GetPaymentMethodsReply, GetPaymentAccountFormRequest, CreatePaymentAccountRequest, CreatePaymentAccountReply, GetPaymentAccountFormReply, GetPaymentAccountsRequest, GetPaymentAccountsReply, CreateCryptoCurrencyPaymentAccountRequest, CreateCryptoCurrencyPaymentAccountReply, CreateOfferRequest, CreateOfferReply, CancelOfferRequest, TakeOfferRequest, TakeOfferReply, TradeInfo, GetTradeRequest, GetTradeReply, GetTradesRequest, GetTradesReply, GetNewDepositAddressRequest, GetNewDepositAddressReply, ConfirmPaymentStartedRequest, ConfirmPaymentReceivedRequest, XmrTx, GetXmrTxsRequest, GetXmrTxsReply, XmrDestination, CreateXmrTxRequest, CreateXmrTxReply, RelayXmrTxRequest, RelayXmrTxReply, CreateAccountRequest, AccountExistsRequest, AccountExistsReply, DeleteAccountRequest, OpenAccountRequest, IsAccountOpenRequest, IsAccountOpenReply, CloseAccountRequest, ChangePasswordRequest, BackupAccountRequest, BackupAccountReply, RestoreAccountRequest, StopRequest, NotificationMessage, RegisterNotificationListenerRequest, SendNotificationRequest, UrlConnection, AddConnectionRequest, RemoveConnectionRequest, GetConnectionRequest, GetConnectionsRequest, SetConnectionRequest, CheckConnectionRequest, CheckConnectionsReply, CheckConnectionsRequest, StartCheckingConnectionsRequest, StopCheckingConnectionsRequest, GetBestAvailableConnectionRequest, SetAutoSwitchRequest, CheckConnectionReply, GetConnectionsReply, GetConnectionReply, GetBestAvailableConnectionReply, GetDisputeRequest, GetDisputeReply, GetDisputesRequest, GetDisputesReply, OpenDisputeRequest, ResolveDisputeRequest, SendDisputeChatMessageRequest, SendChatMessageRequest, GetChatMessagesRequest, GetChatMessagesReply, StartMoneroNodeRequest, StopMoneroNodeRequest, IsMoneroNodeRunningRequest, IsMoneroNodeRunningReply, GetMoneroNodeSettingsRequest, GetMoneroNodeSettingsReply} from './protobuf/grpc_pb';
|
||||||
import {PaymentMethod, PaymentAccount, AvailabilityResult, Attachment, DisputeResult, Dispute, ChatMessage, MoneroNodeSettings} from './protobuf/pb_pb';
|
import {PaymentMethod, PaymentAccount, AvailabilityResult, Attachment, DisputeResult, Dispute, ChatMessage, MoneroNodeSettings} from './protobuf/pb_pb';
|
||||||
|
|
||||||
const console = require('console');
|
const console = require('console');
|
||||||
@ -691,10 +691,10 @@ class haveno {
|
|||||||
*
|
*
|
||||||
* @return {string} the deposit address (a subaddress in the Haveno wallet)
|
* @return {string} the deposit address (a subaddress in the Haveno wallet)
|
||||||
*/
|
*/
|
||||||
async getNewDepositSubaddress(): Promise<string> {
|
async getNewDepositAddress(): Promise<string> {
|
||||||
let that = this;
|
let that = this;
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
that._walletsClient.getNewDepositSubaddress(new GetNewDepositSubaddressRequest(), {password: that._password}, function(err: grpcWeb.RpcError, response: GetNewDepositSubaddressReply) {
|
that._walletsClient.getNewDepositAddress(new GetNewDepositAddressRequest(), {password: that._password}, function(err: grpcWeb.RpcError, response: GetNewDepositAddressReply) {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
else resolve(response.getSubaddress());
|
else resolve(response.getSubaddress());
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user