amp-wallet
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -42,2 +42,2 @@ import { AccountResponse } from 'stellar-sdk'; | ||
*/ | ||
export declare function createWallet(disctpub: string): Promise<void>; | ||
export declare function createWallet(disctpub: string): Promise<object>; |
@@ -5,2 +5,3 @@ export declare function config(): { | ||
friendbot: string; | ||
openingAccount: string; | ||
}; |
@@ -8,5 +8,6 @@ "use strict"; | ||
networkPassphrase: 'Standalone Network ; February 2017 ; ebd4136c0113b9e044326f0b6250ef33a51d0235625f2acf07cc599b87a1664c', | ||
friendbot: 'https://friendbot.server.amanatpay.com/' | ||
friendbot: 'https://friendbot.server.amanatpay.com/', | ||
openingAccount: '1000' | ||
}; | ||
} | ||
exports.config = config; |
@@ -23,8 +23,9 @@ import { AccountResponse } from 'stellar-sdk'; | ||
* @param {string} distSecret disturber account secret key | ||
* @return (object} accountDetails: direct return from blockchain key: keypair , public and private keys | ||
*/ | ||
export declare function createAccount(distSecret: string): Promise<void>; | ||
export declare function createAccount(distSecret: string): Promise<object>; | ||
/** | ||
* load gas from friend bot | ||
* load gas from friend-bot | ||
* @param {string} pub public key for any wallet | ||
*/ | ||
export declare function friendbot(pub: string): Promise<import("axios").AxiosResponse<any, any>>; |
@@ -129,23 +129,41 @@ "use strict"; | ||
* @param {string} distSecret disturber account secret key | ||
* @return (object} accountDetails: direct return from blockchain key: keypair , public and private keys | ||
*/ | ||
function createAccount(distSecret) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var server, keyPair, provisioner, transaction; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var server, keyPair, provisionerKeyPair, provisioner, transaction, e_2; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 4, , 5]); | ||
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)]; | ||
keyPair = _b.sent(); | ||
provisionerKeyPair = stellar_sdk_1.Keypair.fromSecret(distSecret); | ||
return [4 /*yield*/, server.loadAccount(provisionerKeyPair.publicKey())]; | ||
case 2: | ||
provisioner = _a.sent(); | ||
transaction = new stellar_sdk_1.TransactionBuilder(provisioner) | ||
provisioner = _b.sent(); | ||
transaction = new stellar_sdk_1.TransactionBuilder(provisioner, { fee: stellar_sdk_1.BASE_FEE }) | ||
.addOperation(stellar_sdk_1.Operation.createAccount({ | ||
destination: keyPair.publicKey, | ||
startingBalance: '1000' | ||
})).build(); | ||
transaction.sign(); | ||
return [2 /*return*/]; | ||
startingBalance: (0, setting_1.config)().openingAccount | ||
})) | ||
.setNetworkPassphrase("".concat((0, setting_1.config)().networkPassphrase)) | ||
.setTimeout(30) | ||
.build(); | ||
transaction.sign(provisionerKeyPair); | ||
_a = {}; | ||
return [4 /*yield*/, server.submitTransaction(transaction)]; | ||
case 3: return [2 /*return*/, (_a.accountDetails = _b.sent(), | ||
_a.key = { | ||
publicKey: keyPair.publicKey, | ||
secret: keyPair.secretKey | ||
}, | ||
_a)]; | ||
case 4: | ||
e_2 = _b.sent(); | ||
throw e_2; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -157,3 +175,3 @@ }); | ||
/** | ||
* load gas from friend bot | ||
* load gas from friend-bot | ||
* @param {string} pub public key for any wallet | ||
@@ -163,3 +181,3 @@ */ | ||
return __awaiter(this, void 0, void 0, function () { | ||
var e_2; | ||
var e_3; | ||
return __generator(this, function (_a) { | ||
@@ -172,4 +190,4 @@ switch (_a.label) { | ||
case 2: | ||
e_2 = _a.sent(); | ||
throw e_2; | ||
e_3 = _a.sent(); | ||
throw e_3; | ||
case 3: return [2 /*return*/]; | ||
@@ -176,0 +194,0 @@ } |
{ | ||
"name": "amp-wallet", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Amanatpay Blockchain Wallet", | ||
@@ -38,2 +38,3 @@ "main": "lib/index.js", | ||
"gulp-uglify": "^3.0.2", | ||
"jest": "^27.4.3", | ||
"jsdoc-babel": "^0.5.0", | ||
@@ -40,0 +41,0 @@ "jsdoc-to-markdown": "^7.1.0", |
34904
584
19