Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amp-wallet

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amp-wallet - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

lib/interface/account.d.ts

32

lib/index.d.ts

@@ -1,1 +0,31 @@

export declare function getAllAccountBalances(publicKey: string): Promise<import("./interface/balance").SimpleBalance[]>;
import { AccountResponse } from 'stellar-sdk';
import { SimpleAccountObj } from './interface/account';
/**
* Description: return all wallet's balances includes asset's type
* @param {string} publicKey Wallet public key
* @return {object[]} returns array of all balance objects
*/
export declare function getAllAccountBalances(publicKey: string): Promise<object[]>;
/**
* Description: confirm the wallet's existence in AmanatPay Blockchain
* @param {string} publicKey Wallet public key
* @return {boolean}
*/
export declare function isWalletExists(publicKey: string): Promise<boolean>;
/**
* Description: get single wallet in details.
* @param {string} publicKey Wallet public key
* @return {AccountResponse} class of AmanatPay Blockchain account
*/
export declare function getWallet(publicKey: string): Promise<AccountResponse>;
/**
* Description: send payment through Amanatpay blockchain network, using multiple assets.
* @param {SimpleAccountObj} senderWallet source/sender Wallet you want to transfer payment from
* @param {string} receiver wallet ID (public key) of receiving party
* @param {number} amount amount
* @param {string} asset asset you want to transfer
* @param {string} issuerAccount token issuer account public key
* @param {string} memo nullable if you need send transfer descriptions
* @param {boolean} validateWallet it is false by default, if you need to function do validation of wallets turn true
*/
export declare function sendPayment(senderWallet: SimpleAccountObj, receiver: string, amount: number, asset: string, issuerAccount: string, memo?: string, validateWallet?: boolean): Promise<any>;

@@ -39,5 +39,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllAccountBalances = void 0;
exports.sendPayment = exports.getWallet = exports.isWalletExists = exports.getAllAccountBalances = void 0;
var payment_1 = require("./interface/payment");
var wallet_1 = require("./wallet");
//----- Get all account Balances ----------------
/**
* Description: return all wallet's balances includes asset's type
* @param {string} publicKey Wallet public key
* @return {object[]} returns array of all balance objects
*/
function getAllAccountBalances(publicKey) {

@@ -57,1 +62,90 @@ return __awaiter(this, void 0, void 0, function () {

exports.getAllAccountBalances = getAllAccountBalances;
/**
* Description: confirm the wallet's existence in AmanatPay Blockchain
* @param {string} publicKey Wallet public key
* @return {boolean}
*/
function isWalletExists(publicKey) {
return __awaiter(this, void 0, void 0, function () {
var e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, (0, wallet_1.getWalletObj)(publicKey)];
case 1:
_a.sent();
return [2 /*return*/, true];
case 2:
e_1 = _a.sent();
throw e_1;
case 3: return [2 /*return*/];
}
});
});
}
exports.isWalletExists = isWalletExists;
/**
* Description: get single wallet in details.
* @param {string} publicKey Wallet public key
* @return {AccountResponse} class of AmanatPay Blockchain account
*/
function getWallet(publicKey) {
return __awaiter(this, void 0, void 0, function () {
var e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, (0, wallet_1.getWalletObj)(publicKey)];
case 1: return [2 /*return*/, _a.sent()];
case 2:
e_2 = _a.sent();
throw e_2;
case 3: return [2 /*return*/];
}
});
});
}
exports.getWallet = getWallet;
/**
* Description: send payment through Amanatpay blockchain network, using multiple assets.
* @param {SimpleAccountObj} senderWallet source/sender Wallet you want to transfer payment from
* @param {string} receiver wallet ID (public key) of receiving party
* @param {number} amount amount
* @param {string} asset asset you want to transfer
* @param {string} issuerAccount token issuer account public key
* @param {string} memo nullable if you need send transfer descriptions
* @param {boolean} validateWallet it is false by default, if you need to function do validation of wallets turn true
*/
//TODO: change in such a way that makes function transfer native token too
function sendPayment(senderWallet, receiver, amount, asset, issuerAccount, memo, validateWallet) {
if (validateWallet === void 0) { validateWallet = false; }
return __awaiter(this, void 0, void 0, function () {
var e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 6, , 7]);
if (!validateWallet) return [3 /*break*/, 4];
return [4 /*yield*/, isWalletExists(senderWallet.publicKey)];
case 1:
_a.sent();
return [4 /*yield*/, isWalletExists(receiver)];
case 2:
_a.sent();
return [4 /*yield*/, isWalletExists(issuerAccount)];
case 3:
_a.sent();
_a.label = 4;
case 4: return [4 /*yield*/, (0, payment_1.send)(senderWallet, receiver, amount, asset, issuerAccount, memo)];
case 5: return [2 /*return*/, _a.sent()];
case 6:
e_3 = _a.sent();
throw e_3;
case 7: return [2 /*return*/];
}
});
});
}
exports.sendPayment = sendPayment;
export declare function config(): {
horizon_url: string;
networkPassphrase: string;
};

3

lib/setting.js

@@ -6,5 +6,6 @@ "use strict";

return {
horizon_url: 'https://chain.amanatpay.com'
horizon_url: 'https://chain.amanatpay.com',
networkPassphrase: 'Standalone Network ; February 2017 ; ebd4136c0113b9e044326f0b6250ef33a51d0235625f2acf07cc599b87a1664c'
};
}
exports.config = config;
import { AccountResponse } from 'stellar-sdk';
import { SimpleBalance } from './interface/balance';
import { SimpleAccountObj } from './interface/account';
/**
* get wallet's object from Amanatpay blockchain
* @param {string} publicKey wallet public key
* @return {AccountResponse} wallet object on Amanatpay blockchain
*/
export declare function getWalletObj(publicKey: string): Promise<AccountResponse>;
export declare function getAllBalances(wallet: AccountResponse): Promise<SimpleBalance[]>;
/**
* return array of wallet's balances of different assets
* @param {AccountResponse} wallet wallet as Amanatpay blockchain object
* @return {array} array of balances
*/
export declare function getAllBalances(wallet: AccountResponse): Promise<object[]>;
/**
* Create a key pair for creating account
* @return {SimpleAccountObj}
*/
export declare function createPair(): Promise<SimpleAccountObj>;

@@ -38,7 +38,15 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllBalances = exports.getWalletObj = void 0;
var stellar_sdk_1 = require("stellar-sdk");
exports.createPair = exports.getAllBalances = exports.getWalletObj = void 0;
var stellar_sdk_1 = __importDefault(require("stellar-sdk"));
var setting_1 = require("./setting");
//---------get Wallet object from blockchain----------
/**
* get wallet's object from Amanatpay blockchain
* @param {string} publicKey wallet public key
* @return {AccountResponse} wallet object on Amanatpay blockchain
*/
function getWalletObj(publicKey) {

@@ -64,23 +72,17 @@ return __awaiter(this, void 0, void 0, function () {

//---------get all wallet balances and assets ---------
/**
* return array of wallet's balances of different assets
* @param {AccountResponse} wallet wallet as Amanatpay blockchain object
* @return {array} array of balances
*/
function getAllBalances(wallet) {
return __awaiter(this, void 0, void 0, function () {
var accountBalance_1, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
accountBalance_1 = [];
return [4 /*yield*/, wallet.balances.forEach(function (balance) {
accountBalance_1.push({
asset: balance.asset_type, balance: balance.balance
});
})];
case 1:
_a.sent();
return [2 /*return*/, accountBalance_1];
case 2:
e_2 = _a.sent();
throw e_2;
case 3: return [2 /*return*/];
try {
return [2 /*return*/, wallet.balances];
}
catch (e) {
throw e;
}
return [2 /*return*/];
});

@@ -90,1 +92,25 @@ });

exports.getAllBalances = getAllBalances;
/**
* Create a key pair for creating account
* @return {SimpleAccountObj}
*/
function createPair() {
return __awaiter(this, void 0, void 0, function () {
var pair;
return __generator(this, function (_a) {
pair = stellar_sdk_1.default.Keypair.random();
return [2 /*return*/, {
publicKey: pair.publicKey(),
secretKey: pair.secret()
}];
});
});
}
exports.createPair = createPair;
// export async function getInitGas(wallet: SimpleAccountObj) {
// try {
//
// }catch (e) {
// throw e
// }
// }
{
"name": "amp-wallet",
"version": "1.0.6",
"version": "1.0.7",
"description": "Amanatpay Blockchain Wallet",

@@ -9,3 +9,3 @@ "main": "lib/index.js",

"test": "jest --config jestconfig.json",
"build": "tsc",
"build": "tsc --esModuleInterop",
"build:doc": "jsdoc2md --files ./src/*.ts --configure ./jsdoc2md.json > ./docs/file.md"

@@ -12,0 +12,0 @@

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