amp-wallet
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -119,3 +119,2 @@ "use strict"; | ||
*/ | ||
//TODO: change in such a way that makes function transfer native token too | ||
function sendPayment(senderWallet, receiver, amount, asset, issuerAccount, memo, validateWallet) { | ||
@@ -140,3 +139,3 @@ if (validateWallet === void 0) { validateWallet = false; } | ||
_a.label = 4; | ||
case 4: return [4 /*yield*/, (0, payment_1.send)(senderWallet, receiver, amount, asset, issuerAccount, memo)]; | ||
case 4: return [4 /*yield*/, (0, payment_1.transaction)(senderWallet, receiver, amount, asset, issuerAccount)]; | ||
case 5: return [2 /*return*/, _a.sent()]; | ||
@@ -143,0 +142,0 @@ case 6: |
@@ -9,4 +9,3 @@ import { SimpleAccountObj } from './account'; | ||
* @param {string} issuerAccount asset issuer account's public key | ||
* @param {string} memo any descriptions such as invoice or meta | ||
*/ | ||
export declare function send(senderWallet: SimpleAccountObj, receiver: string, amount: number, assetName: string, issuerAccount: string, memo: string | undefined): Promise<any>; | ||
export declare function transaction(senderWallet: SimpleAccountObj, receiver: string, amount: number, assetName: string, issuerAccount: string): Promise<any>; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -57,7 +38,9 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.send = void 0; | ||
var stellar_sdk_1 = __importStar(require("stellar-sdk")); | ||
exports.transaction = void 0; | ||
var stellar_sdk_1 = __importDefault(require("stellar-sdk")); | ||
var setting_1 = require("../setting"); | ||
var wallet_1 = require("../wallet"); | ||
/** | ||
@@ -70,32 +53,36 @@ * send function only for non native assets | ||
* @param {string} issuerAccount asset issuer account's public key | ||
* @param {string} memo any descriptions such as invoice or meta | ||
*/ | ||
function send(senderWallet, receiver, amount, assetName, issuerAccount, memo) { | ||
function transaction(senderWallet, receiver, amount, assetName, issuerAccount) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var server, assetObj, account, A, paymentOp, tx; | ||
return __generator(this, function (_a) { | ||
server = new stellar_sdk_1.default.Server((0, setting_1.config)().horizon_url); | ||
assetObj = new stellar_sdk_1.default.Asset(assetName, issuerAccount); | ||
account = (0, wallet_1.getWalletObj)(senderWallet.publicKey); | ||
A = stellar_sdk_1.default.Keypair.fromSecret(senderWallet.secretKey); | ||
paymentOp = stellar_sdk_1.default.Operation.payment({ | ||
destination: "".concat(receiver), | ||
asset: assetObj, | ||
amount: "".concat(amount), | ||
}); | ||
tx = new stellar_sdk_1.default.TransactionBuilder(account, { fee: stellar_sdk_1.default.BASE_FEE }) | ||
.addOperation(paymentOp) | ||
.addMemo(stellar_sdk_1.default.Memo.text("".concat(stellar_sdk_1.Memo))) | ||
.setNetworkPassphrase("".concat((0, setting_1.config)().networkPassphrase)) | ||
.setTimeout(30) | ||
.build(); | ||
tx.sign(A); | ||
return [2 /*return*/, server.submitTransaction(tx).then(function (resp) { | ||
return resp; | ||
}).catch(function (err) { | ||
throw (err); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
server = new stellar_sdk_1.default.Server((0, setting_1.config)().horizon_url); | ||
assetObj = new stellar_sdk_1.default.Asset(assetName, issuerAccount); | ||
return [4 /*yield*/, server.loadAccount(senderWallet.publicKey)]; | ||
case 1: | ||
account = _a.sent(); | ||
A = stellar_sdk_1.default.Keypair.fromSecret(senderWallet.secretKey); | ||
paymentOp = stellar_sdk_1.default.Operation.payment({ | ||
destination: "".concat(receiver), | ||
asset: assetObj, | ||
amount: "".concat(amount), | ||
}); | ||
tx = new stellar_sdk_1.default.TransactionBuilder(account, { fee: 100 }) | ||
.addOperation(paymentOp) | ||
.setNetworkPassphrase("".concat((0, setting_1.config)().networkPassphrase)) | ||
.setTimeout(30) | ||
.build(); | ||
tx.sign(A); | ||
return [4 /*yield*/, server.submitTransaction(tx).then(function (resp) { | ||
return resp; | ||
}).catch(function (err) { | ||
throw (err); | ||
})]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.send = send; | ||
exports.transaction = transaction; |
@@ -20,1 +20,2 @@ import { AccountResponse } from 'stellar-sdk'; | ||
export declare function createPair(): Promise<SimpleAccountObj>; | ||
export declare function createAccount(distSecret: string): Promise<void>; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -38,8 +57,5 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createPair = exports.getAllBalances = exports.getWalletObj = void 0; | ||
var stellar_sdk_1 = __importDefault(require("stellar-sdk")); | ||
exports.createAccount = exports.createPair = exports.getAllBalances = exports.getWalletObj = void 0; | ||
var stellar_sdk_1 = __importStar(require("stellar-sdk")); | ||
var setting_1 = require("./setting"); | ||
@@ -108,8 +124,26 @@ //---------get Wallet object from blockchain---------- | ||
exports.createPair = createPair; | ||
// export async function getInitGas(wallet: SimpleAccountObj) { | ||
// try { | ||
// | ||
// }catch (e) { | ||
// throw e | ||
// } | ||
// } | ||
function createAccount(distSecret) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var server, keyPair, provisioner, transaction; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
server = new stellar_sdk_1.Server((0, setting_1.config)().horizon_url); | ||
return [4 /*yield*/, createPair()]; | ||
case 1: | ||
keyPair = _a.sent(); | ||
return [4 /*yield*/, server.loadAccount(distSecret)]; | ||
case 2: | ||
provisioner = _a.sent(); | ||
transaction = new stellar_sdk_1.TransactionBuilder(provisioner) | ||
.addOperation(stellar_sdk_1.Operation.createAccount({ | ||
destination: keyPair.publicKey, | ||
startingBalance: '1000' | ||
})).build(); | ||
transaction.sign(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.createAccount = createAccount; |
{ | ||
"name": "amp-wallet", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Amanatpay Blockchain Wallet", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27990
472
0