New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tangany/waas

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tangany/waas - npm Package Compare versions

Comparing version 1.0.0-beta.7 to 1.0.0-beta.8

dist/blockchain-wallet.d.ts

16

CHANGELOG.MD

@@ -6,2 +6,18 @@ # Changelog

## [Unreleased]
### Fixed
### Added
### Changed
## [1.0.0-beta.8]
### Fixed
- Fixed invalid ethereum data string in a failing E2E test
### Added
* Supporting [WaaS 1.4](https://tangany.com/blog/release-notes-1-4/):
* Ethereum and Bitcoin signing
* Asynchronous sending and request status
* Universal Ethereum smart contracts
* `ethereumGasPrice` & `useGasTank` header
### Changed
## [1.0.0-beta.7]

@@ -8,0 +24,0 @@ ### Fixed

22

dist/btc-wallet.d.ts

@@ -0,4 +1,4 @@

import { BlockchainWallet } from "./blockchain-wallet";
import { Waas } from "./waas";
import { IBitcoinTransactionEstimation, IRecipient, ITransaction, IWalletBalance } from "./interfaces";
import { IWaasMethod } from "./waas-method";
import { IBitcoinTransactionEstimation, ITransmittableTransaction, IRecipient, ITransaction, IWalletBalance } from "./interfaces";
import { Wallet } from "./wallet";

@@ -10,10 +10,7 @@ /**

*/
export declare class BtcWallet implements IWaasMethod {
waas: Waas;
private readonly walletInstance;
export declare class BtcWallet extends BlockchainWallet {
constructor(waas: Waas, walletInstance: Wallet);
get wallet(): string | undefined;
/**
* Returns wallet metrics for the Bitcoin blockchain (BTC balance, wallet address)
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/get-btc-balance}
* @see [docs]{@link https://docs.tangany.com/?version=latest#ccedf387-e9f9-4118-985c-d434e762b6fe}
*/

@@ -24,9 +21,16 @@ get(): Promise<IWalletBalance>;

* @param recipients - Recipient configuration
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/make-btc-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#62b0f6e4-641b-4230-8cf2-1cb8b2181812}
*/
send(recipients: IRecipient[] | IRecipient): Promise<ITransaction>;
/**
* Creates an RLP encoded transaction that is already signed and can be manually transmitted
* to compatible blockchain networks at a later stage.
* @param recipients - Recipient configuration
* @see [docs]{@link https://docs.tangany.com/?version=latest#53017845-c0e8-4100-bb24-6168b00bd225}
*/
sign(recipients: IRecipient[] | IRecipient): Promise<ITransmittableTransaction>;
/**
* Estimate sending fee in BTC for given recipients
* @param recipientsObject - a recipients configuration object
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/estimate-btc-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#7272d8f1-38d5-4ee7-9c69-2154405bb83b}
*/

@@ -33,0 +37,0 @@ estimateFee(recipientsObject: IRecipient[] | IRecipient): Promise<IBitcoinTransactionEstimation>;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {

@@ -50,2 +63,3 @@ __assign = Object.assign || function(t) {

Object.defineProperty(exports, "__esModule", { value: true });
var blockchain_wallet_1 = require("./blockchain-wallet");
var waas_1 = require("./waas");

@@ -58,7 +72,6 @@ var t = require("typeforce");

*/
var BtcWallet = /** @class */ (function () {
var BtcWallet = /** @class */ (function (_super) {
__extends(BtcWallet, _super);
function BtcWallet(waas, walletInstance) {
var _this = this;
this.waas = waas;
this.walletInstance = walletInstance;
var _this = _super.call(this, waas, walletInstance) || this;
/**

@@ -68,3 +81,3 @@ * @deprecated do not use outside of unit tests

// tslint:disable-next-line:variable-name
this.__test_getRecipientsData = function () {
_this.__test_getRecipientsData = function () {
var args = [];

@@ -79,3 +92,3 @@ for (var _i = 0; _i < arguments.length; _i++) {

*/
this.getRecipientsData = function (recipients) {
_this.getRecipientsData = function (recipients) {
var data = {};

@@ -101,14 +114,7 @@ var checkType = function (recipient) {

};
return _this;
}
Object.defineProperty(BtcWallet.prototype, "wallet", {
get: function () {
t("String", this.walletInstance.wallet);
return this.walletInstance.wallet;
},
enumerable: true,
configurable: true
});
/**
* Returns wallet metrics for the Bitcoin blockchain (BTC balance, wallet address)
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/get-btc-balance}
* @see [docs]{@link https://docs.tangany.com/?version=latest#ccedf387-e9f9-4118-985c-d434e762b6fe}
*/

@@ -126,3 +132,3 @@ BtcWallet.prototype.get = function () {

* @param recipients - Recipient configuration
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/make-btc-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#62b0f6e4-641b-4230-8cf2-1cb8b2181812}
*/

@@ -138,5 +144,20 @@ BtcWallet.prototype.send = function (recipients) {

/**
* Creates an RLP encoded transaction that is already signed and can be manually transmitted
* to compatible blockchain networks at a later stage.
* @param recipients - Recipient configuration
* @see [docs]{@link https://docs.tangany.com/?version=latest#53017845-c0e8-4100-bb24-6168b00bd225}
*/
BtcWallet.prototype.sign = function (recipients) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, this.waas.wrap(function () { return _this.waas.instance
.post("btc/wallet/" + _this.wallet + "/sign", _this.getRecipientsData(recipients)); })];
});
});
};
/**
* Estimate sending fee in BTC for given recipients
* @param recipientsObject - a recipients configuration object
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/estimate-btc-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#7272d8f1-38d5-4ee7-9c69-2154405bb83b}
*/

@@ -153,4 +174,4 @@ BtcWallet.prototype.estimateFee = function (recipientsObject) {

return BtcWallet;
}());
}(blockchain_wallet_1.BlockchainWallet));
exports.BtcWallet = BtcWallet;
//# sourceMappingURL=btc-wallet.js.map

@@ -16,3 +16,3 @@ import { IBitcoinTransactionStatus } from "./interfaces";

* Returns the status for a Bitcoin transaction
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/get-btc-tx-status}
* @see [docs]{@link https://docs.tangany.com/?version=latest#e9f7074c-50ea-432c-8835-1d278ad68f1c}
*/

@@ -19,0 +19,0 @@ get(): Promise<IBitcoinTransactionStatus>;

@@ -62,3 +62,3 @@ "use strict";

* Returns the status for a Bitcoin transaction
* @see {@link https://tangany.docs.stoplight.io/api/bitcoin/get-btc-tx-status}
* @see [docs]{@link https://docs.tangany.com/?version=latest#e9f7074c-50ea-432c-8835-1d278ad68f1c}
*/

@@ -65,0 +65,0 @@ Bitcoin.prototype.get = function () {

@@ -0,4 +1,4 @@

import { BlockchainWallet } from "./blockchain-wallet";
import { IRecipient, ITokenBalance, ITransaction } from "./interfaces";
import { Waas } from "./waas";
import { IWaasMethod } from "./waas-method";
import { Wallet } from "./wallet";

@@ -11,11 +11,8 @@ /**

*/
export declare class EthErc20Wallet implements IWaasMethod {
waas: Waas;
readonly walletInstance: Wallet;
export declare class EthErc20Wallet extends BlockchainWallet {
readonly address: string;
get wallet(): string | undefined;
constructor(waas: Waas, walletInstance: Wallet, address: string);
/**
* Retrieves the token balance for given wallet
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/get-token-balance}
* @see [docs]{@link https://docs.tangany.com/?version=latest#f3c0c795-3cc4-45f4-ac6b-ca03f23e568c}
*/

@@ -26,3 +23,3 @@ get(): Promise<ITokenBalance>;

* @param recipient - {@link IRecipient}
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/make-token-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#8113cb99-b664-49b4-be12-35654f2190ef}
*/

@@ -34,3 +31,3 @@ send(recipient: IRecipient): Promise<ITransaction>;

* @param amount - Float amount of tokens formatted as a string
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-approve}
* @see [docs]{@link https://docs.tangany.com/?version=latest#7a676b3d-93c9-4bed-b8ea-94c938909c61}
*/

@@ -45,3 +42,3 @@ approve({ to, amount }: {

* @param amount - Float amount of tokens to withdraw formatted as a string
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-transfer-from}
* @see [docs]{@link https://docs.tangany.com/?version=latest#3e92b48b-4626-4323-853e-3743237fc1f0}
*/

@@ -55,3 +52,3 @@ transferFrom({ from, amount }: {

* @param amount - Float amount of tokens to burn from the wallet formatted as a string
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-burn}
* @see [docs]{@link https://docs.tangany.com/?version=latest#ab52e66d-dffa-4bf7-aa4a-62ab5093f219}
*/

@@ -65,3 +62,3 @@ burn({ amount }: {

* @param [to] - Ethereum address to assign the mined tokens to. If omitted, tokens are assigned to the wallet address
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-mint}
* @see [docs]{@link https://docs.tangany.com/?version=latest#16d4bf9c-4bfb-4be5-bde4-cf4cdc938b29}
*/

@@ -68,0 +65,0 @@ mint({ amount, to }: {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -40,2 +53,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var t = require("typeforce");
var blockchain_wallet_1 = require("./blockchain-wallet");
var waas_1 = require("./waas");

@@ -56,8 +70,7 @@ var METHOD;

*/
var EthErc20Wallet = /** @class */ (function () {
var EthErc20Wallet = /** @class */ (function (_super) {
__extends(EthErc20Wallet, _super);
function EthErc20Wallet(waas, walletInstance, address) {
var _this = this;
this.waas = waas;
this.walletInstance = walletInstance;
this.address = address;
var _this = _super.call(this, waas, walletInstance) || this;
_this.address = address;
/**

@@ -67,3 +80,3 @@ * @deprecated do not use outside of unit tests

// tslint:disable-next-line:variable-name
this.__test_getRecipientsData = function () {
_this.__test_getRecipientsData = function () {
var args = [];

@@ -78,3 +91,3 @@ for (var _i = 0; _i < arguments.length; _i++) {

*/
this.getRecipientsData = function (method) { return function (_a) {
_this.getRecipientsData = function (method) { return function (_a) {
var to = _a.to, amount = _a.amount, from = _a.from;

@@ -132,14 +145,7 @@ switch (method) {

t("String", address);
return _this;
}
Object.defineProperty(EthErc20Wallet.prototype, "wallet", {
get: function () {
t("String", this.walletInstance.wallet);
return this.walletInstance.wallet;
},
enumerable: true,
configurable: true
});
/**
* Retrieves the token balance for given wallet
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/get-token-balance}
* @see [docs]{@link https://docs.tangany.com/?version=latest#f3c0c795-3cc4-45f4-ac6b-ca03f23e568c}
*/

@@ -157,3 +163,3 @@ EthErc20Wallet.prototype.get = function () {

* @param recipient - {@link IRecipient}
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/make-token-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#8113cb99-b664-49b4-be12-35654f2190ef}
*/

@@ -174,3 +180,3 @@ EthErc20Wallet.prototype.send = function (recipient) {

* @param amount - Float amount of tokens formatted as a string
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-approve}
* @see [docs]{@link https://docs.tangany.com/?version=latest#7a676b3d-93c9-4bed-b8ea-94c938909c61}
*/

@@ -192,3 +198,3 @@ EthErc20Wallet.prototype.approve = function (_a) {

* @param amount - Float amount of tokens to withdraw formatted as a string
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-transfer-from}
* @see [docs]{@link https://docs.tangany.com/?version=latest#3e92b48b-4626-4323-853e-3743237fc1f0}
*/

@@ -209,3 +215,3 @@ EthErc20Wallet.prototype.transferFrom = function (_a) {

* @param amount - Float amount of tokens to burn from the wallet formatted as a string
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-burn}
* @see [docs]{@link https://docs.tangany.com/?version=latest#ab52e66d-dffa-4bf7-aa4a-62ab5093f219}
*/

@@ -227,3 +233,3 @@ EthErc20Wallet.prototype.burn = function (_a) {

* @param [to] - Ethereum address to assign the mined tokens to. If omitted, tokens are assigned to the wallet address
* @see {@link https://tangany.docs.stoplight.io/api/ethereum-erc20/execute-eth-erc20-mint}
* @see [docs]{@link https://docs.tangany.com/?version=latest#16d4bf9c-4bfb-4be5-bde4-cf4cdc938b29}
*/

@@ -242,4 +248,4 @@ EthErc20Wallet.prototype.mint = function (_a) {

return EthErc20Wallet;
}());
}(blockchain_wallet_1.BlockchainWallet));
exports.EthErc20Wallet = EthErc20Wallet;
//# sourceMappingURL=eth-erc20-wallet.js.map

@@ -0,5 +1,7 @@

import { BlockchainWallet } from "./blockchain-wallet";
import { EthContractWallet } from "./eth-contract-wallet";
import { Request } from "./request";
import { Waas } from "./waas";
import { IWalletBalance, ITransaction, IEthereumRecipient } from "./interfaces";
import { IWalletBalance, ITransaction, IEthereumRecipient, ITransmittableTransaction } from "./interfaces";
import { EthErc20Wallet } from "./eth-erc20-wallet";
import { IWaasMethod } from "./waas-method";
import { Wallet } from "./wallet";

@@ -12,19 +14,29 @@ /**

*/
export declare class EthWallet implements IWaasMethod {
waas: Waas;
private readonly walletInstance;
export declare class EthWallet extends BlockchainWallet {
constructor(waas: Waas, walletInstance: Wallet);
get wallet(): string | undefined;
/**
* Returns wallet metrics for the Ethereum blockchain like ether balance and the address
* @see {@link https://tangany.docs.stoplight.io/api/ethereum/get-wallet-balance}
* @see [docs]{@link https://docs.tangany.com/?version=latest#0d926cca-e0bd-4045-864d-18845425adfe}
*/
get(): Promise<IWalletBalance>;
/**
* Send Ether to address from given wallet
* Sends Ether to address from given wallet
* @param recipient - {@link IEthereumRecipient}
* @see {@link https://tangany.docs.stoplight.io/api/ethereum/make-wallet-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#1d76974c-579a-47aa-9912-c7cfddf55889}
*/
send(recipient: IEthereumRecipient): Promise<ITransaction>;
/**
* Sends Ether to address from given wallet *asynchronously*
* @param recipient - {@link IEthereumRecipient}
* @see [docs]{@link https://docs.tangany.com/?version=latest#29e9ed85-f4a1-42bc-88fa-8e1f96fb426f}
*/
sendAsync(recipient: IEthereumRecipient): Promise<Request>;
/**
* Creates an RLP encoded transaction that is already signed and can be manually transmitted
* to compatible blockchain networks at a later stage.
* @param recipient - {@link IEthereumRecipient}
* @see [docs]{@link https://docs.tangany.com/?version=latest#925fd26a-daff-4321-9595-8509dd2ed6b3}
*/
sign(recipient: IEthereumRecipient): Promise<ITransmittableTransaction>;
/**
* Returns wallet calls for the Ethereum ERC20 token

@@ -34,2 +46,15 @@ * @param tokenAddress - Ethereum ERC20 token address for given eth network

erc20(tokenAddress: string): EthErc20Wallet;
/**
* Returns wallet calls for universal Smart Contract method calling
*/
contract(address: string): EthContractWallet;
/**
* @deprecated Do not use this outside unit testing
*/
__test_validateRecipient: (...args: any) => void;
/**
* Throws an exception if the passed recipient is invalid or otherwise ends successfully without a return value.
* @param recipient - Recipient to be validated ({@link IEthereumRecipient})
*/
private validateRecipient;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {

@@ -51,2 +64,5 @@ __assign = Object.assign || function(t) {

var t = require("typeforce");
var blockchain_wallet_1 = require("./blockchain-wallet");
var eth_contract_wallet_1 = require("./eth-contract-wallet");
var request_1 = require("./request");
var waas_1 = require("./waas");

@@ -60,18 +76,22 @@ var eth_erc20_wallet_1 = require("./eth-erc20-wallet");

*/
var EthWallet = /** @class */ (function () {
var EthWallet = /** @class */ (function (_super) {
__extends(EthWallet, _super);
function EthWallet(waas, walletInstance) {
this.waas = waas;
this.walletInstance = walletInstance;
var _this = _super.call(this, waas, walletInstance) || this;
/**
* @deprecated Do not use this outside unit testing
*/
// tslint:disable-next-line:variable-name
_this.__test_validateRecipient = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return _this.validateRecipient.apply(_this, args);
};
return _this;
}
Object.defineProperty(EthWallet.prototype, "wallet", {
get: function () {
t("String", this.walletInstance.wallet);
return this.walletInstance.wallet;
},
enumerable: true,
configurable: true
});
/**
* Returns wallet metrics for the Ethereum blockchain like ether balance and the address
* @see {@link https://tangany.docs.stoplight.io/api/ethereum/get-wallet-balance}
* @see [docs]{@link https://docs.tangany.com/?version=latest#0d926cca-e0bd-4045-864d-18845425adfe}
*/

@@ -88,5 +108,5 @@ EthWallet.prototype.get = function () {

/**
* Send Ether to address from given wallet
* Sends Ether to address from given wallet
* @param recipient - {@link IEthereumRecipient}
* @see {@link https://tangany.docs.stoplight.io/api/ethereum/make-wallet-transaction}
* @see [docs]{@link https://docs.tangany.com/?version=latest#1d76974c-579a-47aa-9912-c7cfddf55889}
*/

@@ -97,9 +117,3 @@ EthWallet.prototype.send = function (recipient) {

return __generator(this, function (_a) {
if (!recipient.to) {
throw new Error("Missing 'to' argument");
}
if (!recipient.amount) {
throw new Error("Missing 'amount' argument");
}
t(waas_1.ethereumRecipientType, recipient, true);
this.validateRecipient(recipient);
return [2 /*return*/, this.waas.wrap(function () { return _this.waas.instance

@@ -111,2 +125,41 @@ .post("eth/wallet/" + _this.wallet + "/send", __assign({}, recipient)); })];

/**
* Sends Ether to address from given wallet *asynchronously*
* @param recipient - {@link IEthereumRecipient}
* @see [docs]{@link https://docs.tangany.com/?version=latest#29e9ed85-f4a1-42bc-88fa-8e1f96fb426f}
*/
EthWallet.prototype.sendAsync = function (recipient) {
return __awaiter(this, void 0, void 0, function () {
var rawResponse, id;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.validateRecipient(recipient);
return [4 /*yield*/, this.waas.wrap(function () { return _this.waas.instance
.post("eth/wallet/" + _this.wallet + "/send-async", __assign({}, recipient)); })];
case 1:
rawResponse = _a.sent();
id = this.extractRequestId(rawResponse);
return [2 /*return*/, new request_1.Request(this.waas, id)];
}
});
});
};
/**
* Creates an RLP encoded transaction that is already signed and can be manually transmitted
* to compatible blockchain networks at a later stage.
* @param recipient - {@link IEthereumRecipient}
* @see [docs]{@link https://docs.tangany.com/?version=latest#925fd26a-daff-4321-9595-8509dd2ed6b3}
*/
EthWallet.prototype.sign = function (recipient) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
this.validateRecipient(recipient);
return [2 /*return*/, this.waas.wrap(function () { return _this.waas.instance
.post("eth/wallet/" + _this.wallet + "/sign", __assign({}, recipient)); })];
});
});
};
/**
* Returns wallet calls for the Ethereum ERC20 token

@@ -118,5 +171,24 @@ * @param tokenAddress - Ethereum ERC20 token address for given eth network

};
/**
* Returns wallet calls for universal Smart Contract method calling
*/
EthWallet.prototype.contract = function (address) {
return new eth_contract_wallet_1.EthContractWallet(this.waas, this.walletInstance, address);
};
/**
* Throws an exception if the passed recipient is invalid or otherwise ends successfully without a return value.
* @param recipient - Recipient to be validated ({@link IEthereumRecipient})
*/
EthWallet.prototype.validateRecipient = function (recipient) {
if (!recipient.to) {
throw new Error("Missing 'to' argument");
}
if (!recipient.amount) {
throw new Error("Missing 'amount' argument");
}
t(waas_1.ethereumRecipientType, recipient, true);
};
return EthWallet;
}());
}(blockchain_wallet_1.BlockchainWallet));
exports.EthWallet = EthWallet;
//# sourceMappingURL=eth-wallet.js.map

@@ -20,3 +20,3 @@ import { Waas } from "./waas";

* Returns the status for an Ethereum transaction. The transaction is not mined until a blockNr is assigned.
* @see {@link https://tangany.docs.stoplight.io/api/ethereum/get-eth-tx-status}
* @see [docs]{@link https://docs.tangany.com/?version=latest#5b262285-c8a0-4e36-8a41-4a2b1f0cdb1b}
*/

@@ -23,0 +23,0 @@ get(): Promise<IEthereumTransactionStatus>;

@@ -78,3 +78,3 @@ "use strict";

* Returns the status for an Ethereum transaction. The transaction is not mined until a blockNr is assigned.
* @see {@link https://tangany.docs.stoplight.io/api/ethereum/get-eth-tx-status}
* @see [docs]{@link https://docs.tangany.com/?version=latest#5b262285-c8a0-4e36-8a41-4a2b1f0cdb1b}
*/

@@ -81,0 +81,0 @@ Ethereum.prototype.get = function () {

@@ -97,1 +97,29 @@ import { WalletSecurity, WalletVersion } from "./waas";

}
/**
* Represents the current state of an asynchronous request
*/
export interface IAsyncRequestStatus {
process: string;
status: {
stage: string;
[k: string]: string;
};
created: Date;
updated: Date;
output: null | {
[k: string]: any;
};
}
/**
* Represents an RLP encoded transaction that is already signed
*/
export interface ITransmittableTransaction {
rawTransaction: string;
}
/**
* Represents the configuration of a Smart Contract method call
*/
export interface IContractMethod {
function: string;
inputs: string[];
}

@@ -6,2 +6,3 @@ import { AxiosInstance } from "axios";

import { BlockchainTransactionStatuses, IBlockchainTransactionStatus } from "./interfaces";
import { Request } from "./request";
import { Wallet } from "./wallet";

@@ -51,2 +52,4 @@ export declare enum WalletVersion {

ethereumTxConfirmations?: BlockchainTxConfirmations;
ethereumGasPrice?: string;
useGasTank?: boolean;
bitcoinNetwork?: BitcoinNetwork;

@@ -70,6 +73,6 @@ bitcoinTxConfirmations?: BlockchainTxConfirmations;

* @param options.vaultUrl - Tangany vault url
* @param options.ethereumNetwork - Public Ethereum network name (@see https://tangany.docs.stoplight.io/api/models/ethereum-public-network) or private Ethereum network url (@see https://tangany.docs.stoplight.io/api/models/ethereum-private-network)
* @param options.ethereumNetwork - Public Ethereum network name or private Ethereum network url
* @param options.ethereumTxConfirmations - Amount of block confirmations required to consider an Ethereum transaction as valid
* @param options.ethereumTxSpeed - Amount of additional gas fee that is added to the base gas fee for the given Ethereum network to speed up the mining process of the transaction
* @param options.bitcoinNetwork - Public Bitcoin network name (@see https://tangany.docs.stoplight.io/api/models/bitcoin-network)
* @param options.bitcoinNetwork - Public Bitcoin network name
* @param options.bitcoinTxConfirmations - Amount of block confirmations required for Bitcoin balance outputs to be included in the total wallet balance calculation

@@ -113,2 +116,7 @@ * @param options.bitcoinTxSpeed - Target amount of block confirmations for the transaction to be included to the Bitcoin network

/**
* read api calls for asynchronous requests
* @param id - Unique identifier for an asynchronous request
*/
request(id: string): Request;
/**
* wrap async call to the bottleneck limiter

@@ -115,0 +123,0 @@ * @param fn - function that returns a promise function. Pass the promise function's arguments via the functions argument

@@ -57,2 +57,3 @@ "use strict";

var limiter_1 = require("./limiter");
var request_1 = require("./request");
var wallet_1 = require("./wallet");

@@ -119,6 +120,6 @@ var debug = Debug("waas-js-sdk:main");

* @param options.vaultUrl - Tangany vault url
* @param options.ethereumNetwork - Public Ethereum network name (@see https://tangany.docs.stoplight.io/api/models/ethereum-public-network) or private Ethereum network url (@see https://tangany.docs.stoplight.io/api/models/ethereum-private-network)
* @param options.ethereumNetwork - Public Ethereum network name or private Ethereum network url
* @param options.ethereumTxConfirmations - Amount of block confirmations required to consider an Ethereum transaction as valid
* @param options.ethereumTxSpeed - Amount of additional gas fee that is added to the base gas fee for the given Ethereum network to speed up the mining process of the transaction
* @param options.bitcoinNetwork - Public Bitcoin network name (@see https://tangany.docs.stoplight.io/api/models/bitcoin-network)
* @param options.bitcoinNetwork - Public Bitcoin network name
* @param options.bitcoinTxConfirmations - Amount of block confirmations required for Bitcoin balance outputs to be included in the total wallet balance calculation

@@ -152,2 +153,4 @@ * @param options.bitcoinTxSpeed - Target amount of block confirmations for the transaction to be included to the Bitcoin network

ethereumTxSpeed: "?String",
ethereumGasPrice: "?String",
useGasTank: "?Boolean",
bitcoinNetwork: "?String",

@@ -191,2 +194,8 @@ bitcoinTxSpeed: "?String",

}
if (_options.ethereumGasPrice) {
api.headers["tangany-ethereum-gas-price"] = _options.ethereumGasPrice;
}
if (_options.useGasTank) {
api.headers["tangany-use-gas-tank"] = _options.useGasTank;
}
if (_options.bitcoinNetwork) {

@@ -372,2 +381,9 @@ api.headers["tangany-bitcoin-network"] = _options.bitcoinNetwork;

/**
* read api calls for asynchronous requests
* @param id - Unique identifier for an asynchronous request
*/
Waas.prototype.request = function (id) {
return new request_1.Request(this, id);
};
/**
* wrap async call to the bottleneck limiter

@@ -374,0 +390,0 @@ * @param fn - function that returns a promise function. Pass the promise function's arguments via the functions argument

@@ -20,3 +20,3 @@ import { BtcWallet } from "./btc-wallet";

* @param [skiptoken] - "skiptoken" value returned in the api response to fetch the next batch of wallets
* @see {@link https://tangany.docs.stoplight.io/api/wallet/list-wallets}
* @see [docs]{@link https://docs.tangany.com/?version=latest#5f27c76b-48a1-45d1-9d8b-44d5afbb1ef3}
*/

@@ -28,3 +28,3 @@ list(skiptoken?: string): Promise<IWalletList>;

* @param [useHsm] - Use a hardware secure module to store the wallet private key
* @see {@link https://tangany.docs.stoplight.io/api/wallet/create-wallet}
* @see [docs]{@link https://docs.tangany.com/?version=latest#88ca3b1c-fd97-4e92-bc42-89c5744f25d2}
*/

@@ -34,3 +34,3 @@ create(wallet?: string, useHsm?: boolean): Promise<IWallet>;

* Soft-deletes a wallet so not writing operations cannot be executed for the associated blockchain account. Wallet recovery endpoints are not yet implemented into the API. Contact the support team to recover soft-deleted wallets during the retention period.
* @see {@link https://tangany.docs.stoplight.io/api/wallet/delete-wallet}
* @see [docs]{@link https://docs.tangany.com/?version=latest#e0b207c8-5cdc-4dce-af6d-a6a655a1cf20}
*/

@@ -40,3 +40,3 @@ delete(): Promise<ISoftDeletedWallet>;

* Returns information for given wallet name
* @see {@link https://tangany.docs.stoplight.io/api/wallet/get-wallet}
* @see [docs]{@link https://docs.tangany.com/?version=latest#f95ba7a2-5526-4eef-b0da-7d7a13be34d2}
*/

@@ -43,0 +43,0 @@ get(): Promise<IWallet>;

@@ -66,3 +66,3 @@ "use strict";

* @param [skiptoken] - "skiptoken" value returned in the api response to fetch the next batch of wallets
* @see {@link https://tangany.docs.stoplight.io/api/wallet/list-wallets}
* @see [docs]{@link https://docs.tangany.com/?version=latest#5f27c76b-48a1-45d1-9d8b-44d5afbb1ef3}
*/

@@ -88,3 +88,3 @@ Wallet.prototype.list = function (skiptoken) {

* @param [useHsm] - Use a hardware secure module to store the wallet private key
* @see {@link https://tangany.docs.stoplight.io/api/wallet/create-wallet}
* @see [docs]{@link https://docs.tangany.com/?version=latest#88ca3b1c-fd97-4e92-bc42-89c5744f25d2}
*/

@@ -114,3 +114,3 @@ Wallet.prototype.create = function (wallet, useHsm) {

* Soft-deletes a wallet so not writing operations cannot be executed for the associated blockchain account. Wallet recovery endpoints are not yet implemented into the API. Contact the support team to recover soft-deleted wallets during the retention period.
* @see {@link https://tangany.docs.stoplight.io/api/wallet/delete-wallet}
* @see [docs]{@link https://docs.tangany.com/?version=latest#e0b207c8-5cdc-4dce-af6d-a6a655a1cf20}
*/

@@ -128,3 +128,3 @@ Wallet.prototype.delete = function () {

* Returns information for given wallet name
* @see {@link https://tangany.docs.stoplight.io/api/wallet/get-wallet}
* @see [docs]{@link https://docs.tangany.com/?version=latest#f95ba7a2-5526-4eef-b0da-7d7a13be34d2}
*/

@@ -131,0 +131,0 @@ Wallet.prototype.get = function () {

{
"name": "@tangany/waas",
"version": "1.0.0-beta.7",
"version": "1.0.0-beta.8",
"description": "node.js SDK for Tangany Wallet as a Service API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -11,3 +11,3 @@ <div align="center">

[![NPM version](https://raw.githubusercontent.com/Tangany/waas-js-sdk/master/docs/package-badge.svg?sanitize=true)](https://www.npmjs.com/package/@tangany/waas)
[![WaaS API version](https://raw.githubusercontent.com/Tangany/waas-js-sdk/master/docs/sdk-badge.svg?sanitize=true)](https://tangany.docs.stoplight.io/)
[![WaaS API version](https://raw.githubusercontent.com/Tangany/waas-js-sdk/master/docs/sdk-badge.svg?sanitize=true)](https://docs.tangany.com/?version=latest)

@@ -72,2 +72,4 @@ ## Getting started

ethereumTxSpeed | Additional gas fee that is added to the base gas fee for the given Ethereum network to speed up the mining process of the transaction. The usage of `none` value may result in the transaction never gets mined and is only intended to use for custom Ethereum networks that employ zero gas price policies. The speed levels correspond with following Ethereum fees (in gwei): `none`: 0, `slow`: 2, `default`: 5, `fast`: 15 | `default` |
ethereumGasPrice | Enforces custom base transaction fee in wei. This prevents the dynamic gas price calculation by the network and nullifies `ethereumTxSpeed`. Example: `7000000000` | `auto` |
useGasTank | Allows to pre-fund the transaction fee for the desired wallet transaction. Supported values: `false`, `true` | `false`
bitcoinNetwork | Public Bitcoin network name. Supported networks: `bitcoin`, `testnet` | `bitcoin` |

@@ -82,7 +84,4 @@ bitcoinTxConfirmations | Minimum amount of block confirmations required for Bitcoin balance outputs ("utxo", "coins") to be included in the total wallet balance calculation. The exclusion of unconfirmed outputs prevents the posthumous invalidation of own wallet transaction by the parent utxo sending party. The levels correspond with following target block confirmations amounts (# of confirmations): `none`: 0, `default`: 1, `secure`: 6 | `default` |

#### Wallet interface
*Global wallet management*
https://tangany.docs.stoplight.io/api/wallet/
[*Global wallet management*](https://docs.tangany.com/?version=latest#39e3a3fe-42fa-4188-b64a-12d8258ad98d)
````javascript
(async () => {

@@ -102,3 +101,3 @@ const api = new Waas();

#### General Ethereum interface
*Ethereum calls that are not wallet based*
[*Ethereum calls that are not wallet based*](https://docs.tangany.com/?version=latest#7b314b47-012c-4baa-b928-dd32c7db1e41)
````javascript

@@ -115,4 +114,3 @@ (async () => {

#### Ethereum interface for wallet
*Wallet based Ethereum calls*
https://tangany.docs.stoplight.io/api/ethereum/
[*Wallet based Ethereum calls*](https://docs.tangany.com/?version=latest#4a31e7ea-f62b-44db-81bd-b6802099955e)
````javascript

@@ -123,2 +121,6 @@ (async () => {

const { hash } = await api.eth().send({to: someOtherWalletAddress, amount: "0.043", data: "0xf03"});
// send Ether asynchronously (see examples for request interface to retrieve status details)
const req = await api.eth().sendAsync({to: someOtherWalletAddress, amount: "0.043", data: "0xf03"});
// create a signed transaction that can be manually transmitted
const { rawTransaction } = await api.eth().sign({to: someOtherWalletAddress, amount: "0.043", data: "0xf03"});
// get eth balance and wallet address

@@ -130,4 +132,3 @@ const { currency, balance, address } = await api.eth().get();

#### Ethereum ERC20 token interface for wallet
*Wallet based calls for Ethereum ERC20 token management*
https://tangany.docs.stoplight.io/api/ethereum-erc20
[*Wallet based calls for Ethereum ERC20 token management*](https://docs.tangany.com/?version=latest#1cbcb11f-f2ca-4334-82b3-9729f4d5e7d8)
````javascript

@@ -151,4 +152,17 @@ (async () => {

#### Universal Ethereum Smart Contract interface for wallet
[*Wallet based calls for universal smart contract token management*](https://docs.tangany.com/?version=9bc7df56-b03b-4b25-9697-59aea9774174#945c237f-5273-4e85-bf9d-1ba2b132df17)
````javascript
(async () => {
const api = new Waas().wallet("my-wallet").eth().contract(tokenAddress);
// send token asynchronously (see examples for request interface to retrieve status details)
const req = api.sendAsync({
function: "transfer(address,uint256)",
inputs: [someOtherWalletAddress, "2500000000000000"]
});
})();
````
#### General Bitcoin interface
*Bitcoin calls that are not wallet based*
[*Bitcoin calls that are not wallet based*](https://docs.tangany.com/?version=latest#2fe57cbc-410e-4141-8161-fd335cfc05c8)
````javascript

@@ -165,4 +179,3 @@ (async () => {

#### Bitcoin interface for wallet
*Wallet based Bitcoin calls*
https://tangany.docs.stoplight.io/api/bitcoin/
[*Wallet based Bitcoin calls*](https://docs.tangany.com/?version=latest#11dafda1-03e7-4911-b18f-091e4e2dd94e)
````javascript

@@ -177,2 +190,4 @@ (async () => {

await api.btc().send([{to: someAddress, amount: "0.324"}, {to: someOtherAddress, amount: "0.021"}]);
// create a signed transaction that can be manually transmitted
const { rawTransaction } = await api.btc().sign({to: someAddress, amount: "0.021"});
// get BTC balance and wallet address

@@ -183,2 +198,22 @@ const { balance,address,currency } = await api.btc().get();

#### Request interface
[*Calls to obtain the status of asynchronous requests*](https://docs.tangany.com/?version=9bc7df56-b03b-4b25-9697-59aea9774174#a6351116-3e2c-4f02-add8-d424c6212f60)
````javascript
(async () => {
const api = new Waas();
// execute an arbitrary call to an asynchronous endpoint
const req = await api.wallet("my-wallet").eth().sendAsync({to: someOtherWalletAddress, amount: "0.539"});
// retrieve status details
const { process, status, output } = await req.get();
// transaction hash is available in the status field as soon as the transaction is executed
const { hash } = status;
// once it is confirmed, further details are available as output of the request
if (process === "Completed") {
const { hash, blockNr, data, status } = output;
}
// obtain the status of a given request id
const anotherStatus = await api.request("a2e19473b9ec44cf97f71c9d4615e364").get();
})();
````
## Affinity Cookies

@@ -210,3 +245,3 @@ WaaS employs its own load-balanced full-node backend to transmit transactions to the blockchains. Due to the nature of blockchain, full nodes sync their states only in the event of a new block. One implication of this behavior is that sending multiple transactions from the same wallet during a time frame of a single block may lead to an overlap of backend memory pool assignments which subsequent may result in transactions being cancelled and discarded from the blockchain.

## API documentation
Full API documentation is available at https://tangany.docs.stoplight.io/
Full API documentation is available at https://docs.tangany.com

@@ -213,0 +248,0 @@ ***

@@ -63,2 +63,7 @@ const { Waas, BITCOIN_NETWORK, BITCOIN_TX_CONFIRMATIONS } = require("../dist");

});
it("should create a signed transaction that can be manually transmitted", async function () {
const { rawTransaction } = await noConfirmationsBtcApi.wallet(wallet).btc().sign(recipients);
console.log(`signing endpoint returned '${rawTransaction}'`);
});
});

@@ -21,3 +21,3 @@ const { Waas } = require("../dist");

const tokenAmount = "0.0032"; // Token amount used for transactions
const etherAmount = "0.001"; // Token amount used for transactions
const etherAmount = "0.001"; // Ether amount used for transactions
let tokenWalletAddress; // Token wallet address

@@ -155,2 +155,18 @@ let createdWallet; // Random created wallet name

it("should interact with a smart contract using the universal contract endpoint", async function () {
const request = await api.wallet(tokenWallet).eth().contract(tokenAddress).sendAsync({
function: "transfer(address,uint256)",
inputs: [createdWalletAddress, "2500000000000000"]
});
console.log(`asynchronous transaction request '${request.id}' started. Waiting for the process to finish...`);
});
it("should create a signed transaction that can be manually transmitted", async function () {
const { rawTransaction } = await api.wallet(tokenWallet).eth().sign({
to: createdWalletAddress,
amount: etherAmount
});
console.log(`signing endpoint returned '${rawTransaction}'`);
});
it("should delete the new wallet", async function () {

@@ -157,0 +173,0 @@ const { recoveryId, scheduledPurgeDate } = await api.wallet(createdWallet).delete();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc