amp-wallet
Advanced tools
Comparing version 1.0.19 to 1.0.20
import { AccountResponse } from 'stellar-sdk'; | ||
import { SimpleAccountObj } from './interface/account'; | ||
import { keyPair } from './wallet'; | ||
/** | ||
@@ -40,9 +41,25 @@ * Description: return all wallet's balances includes asset's type | ||
* create new wallet and load 1000 native gas | ||
*@param {string} disctpub disturber secret key to load 1000 native gas into the account | ||
*@param {string} distpub disturber secret key to load 1000 native gas into the account | ||
*/ | ||
export declare function createWallet(disctpub: string): Promise<object>; | ||
export declare function createWallet(distpub: string): Promise<{ | ||
accountDetails: object; | ||
key: keyPair; | ||
}>; | ||
/** | ||
* Wallet's transactions for all assets | ||
* | ||
*@param {string} pub public key | ||
*/ | ||
export declare function History(pub: string): Promise<any>; | ||
/** | ||
*CREATE an asset that's are include issue account and distributor | ||
*/ | ||
export declare function createAsset(name: string, distPub: string, startingAmount: number): Promise<{ | ||
issuer: { | ||
accountDetails: object; | ||
key: keyPair; | ||
}; | ||
dist: { | ||
accountDetails: object; | ||
key: keyPair; | ||
}; | ||
}>; |
@@ -39,3 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.History = exports.createWallet = exports.loadFriendBot = exports.sendPayment = exports.getWallet = exports.isWalletExists = exports.getAllAccountBalances = void 0; | ||
exports.createAsset = exports.History = exports.createWallet = exports.loadFriendBot = exports.sendPayment = exports.getWallet = exports.isWalletExists = exports.getAllAccountBalances = void 0; | ||
var payment_1 = require("./interface/payment"); | ||
@@ -176,5 +176,5 @@ var wallet_1 = require("./wallet"); | ||
* create new wallet and load 1000 native gas | ||
*@param {string} disctpub disturber secret key to load 1000 native gas into the account | ||
*@param {string} distpub disturber secret key to load 1000 native gas into the account | ||
*/ | ||
function createWallet(disctpub) { | ||
function createWallet(distpub) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -186,3 +186,3 @@ var e_5; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, (0, wallet_1.createAccount)(disctpub)]; | ||
return [4 /*yield*/, (0, wallet_1.createAccount)(distpub)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -200,3 +200,3 @@ case 2: | ||
* Wallet's transactions for all assets | ||
* | ||
*@param {string} pub public key | ||
*/ | ||
@@ -221,1 +221,52 @@ function History(pub) { | ||
exports.History = History; | ||
/** | ||
*CREATE an asset that's are include issue account and distributor | ||
*/ | ||
function createAsset(name, distPub, startingAmount) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var issuer, dist, e_7; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 6, , 7]); | ||
return [4 /*yield*/, (0, wallet_1.createAccount)(distPub)]; | ||
case 1: | ||
issuer = _a.sent(); | ||
return [4 /*yield*/, (0, wallet_1.setupIssuer)(issuer.key.secret) | ||
//create distributor wallet | ||
]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, (0, wallet_1.createAccount)(distPub) | ||
//create trust-line between wallets | ||
]; | ||
case 3: | ||
dist = _a.sent(); | ||
//create trust-line between wallets | ||
return [4 /*yield*/, (0, wallet_1.createTrustLine)(issuer.key, dist.key, name) | ||
//send payment from issuer to distributor | ||
]; | ||
case 4: | ||
//create trust-line between wallets | ||
_a.sent(); | ||
//send payment from issuer to distributor | ||
return [4 /*yield*/, sendPayment(issuer.key, dist.key.publicKey, startingAmount, name, issuer.key.publicKey) | ||
//return object of all wallets | ||
]; | ||
case 5: | ||
//send payment from issuer to distributor | ||
_a.sent(); | ||
//return object of all wallets | ||
return [2 /*return*/, { | ||
issuer: issuer, | ||
dist: dist | ||
}]; | ||
case 6: | ||
e_7 = _a.sent(); | ||
throw e_7; | ||
case 7: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.createAsset = createAsset; |
@@ -7,3 +7,3 @@ /** | ||
publicKey: string; | ||
secretKey: string; | ||
secret: string; | ||
}; |
@@ -64,3 +64,3 @@ "use strict"; | ||
account = _a.sent(); | ||
A = stellar_sdk_1.default.Keypair.fromSecret(senderWallet.secretKey); | ||
A = stellar_sdk_1.default.Keypair.fromSecret(senderWallet.secret); | ||
paymentOp = stellar_sdk_1.default.Operation.payment({ | ||
@@ -67,0 +67,0 @@ destination: "".concat(receiver), |
@@ -38,2 +38,6 @@ import { AccountResponse } from 'stellar-sdk'; | ||
} | ||
export interface keyPair { | ||
publicKey: string; | ||
secret: string; | ||
} | ||
/** | ||
@@ -61,3 +65,6 @@ * get wallet's object from Amanatpay blockchain | ||
*/ | ||
export declare function createAccount(distSecret: string): Promise<object>; | ||
export declare function createAccount(distSecret: string): Promise<{ | ||
accountDetails: object; | ||
key: keyPair; | ||
}>; | ||
/** | ||
@@ -79,2 +86,16 @@ * load gas from friend-bot | ||
export declare function convertTransactionHistory(history: history): Promise<any[]>; | ||
/** | ||
* change account options for Issuer account( new assets) | ||
* @param {string} Issuer | ||
* @return transaction server transaction result | ||
*/ | ||
export declare function setupIssuer(Issuer: string): Promise<any>; | ||
/** | ||
* create trust-line in between issuer account , asset and account | ||
* @param {keyPair} issuer object of publicKey and secret | ||
* @param {keyPair} account object of publicKey and secret | ||
* @param {keyPair} asset object of publicKey and secret | ||
* @return transaction server transaction result | ||
*/ | ||
export declare function createTrustLine(issuer: keyPair, account: keyPair, asset: string): Promise<any>; | ||
export {}; |
@@ -61,3 +61,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertTransactionHistory = exports.transactionHistory = exports.friendbot = exports.createAccount = exports.createPair = exports.getAllBalances = exports.getWalletObj = void 0; | ||
exports.createTrustLine = exports.setupIssuer = exports.convertTransactionHistory = exports.transactionHistory = exports.friendbot = exports.createAccount = exports.createPair = exports.getAllBalances = exports.getWalletObj = void 0; | ||
var axios_1 = __importDefault(require("axios")); | ||
@@ -121,3 +121,3 @@ var stellar_sdk_1 = __importStar(require("stellar-sdk")); | ||
publicKey: pair.publicKey(), | ||
secretKey: pair.secret() | ||
secret: pair.secret() | ||
}]; | ||
@@ -163,3 +163,3 @@ }); | ||
publicKey: keyPair.publicKey, | ||
secret: keyPair.secretKey | ||
secret: keyPair.secret | ||
}, | ||
@@ -259,1 +259,70 @@ _a)]; | ||
exports.convertTransactionHistory = convertTransactionHistory; | ||
/** | ||
* change account options for Issuer account( new assets) | ||
* @param {string} Issuer | ||
* @return transaction server transaction result | ||
*/ | ||
function setupIssuer(Issuer) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var server, issuerKeyPair, issuingAccount, transaction; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
server = new stellar_sdk_1.default.Server((0, setting_1.config)().horizon_url); | ||
issuerKeyPair = stellar_sdk_1.Keypair.fromSecret(Issuer); | ||
return [4 /*yield*/, server.loadAccount(issuerKeyPair.publicKey())]; | ||
case 1: | ||
issuingAccount = _a.sent(); | ||
transaction = new stellar_sdk_1.TransactionBuilder(issuingAccount) | ||
.addOperation(stellar_sdk_1.Operation.setOptions({ | ||
// @ts-ignore | ||
setFlags: stellar_sdk_1.AuthRevocableFlag | stellar_sdk_1.AuthRequiredFlag | ||
})) | ||
.build(); | ||
transaction.sign(issuerKeyPair); | ||
return [4 /*yield*/, server.submitTransaction(transaction)]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.setupIssuer = setupIssuer; | ||
/** | ||
* create trust-line in between issuer account , asset and account | ||
* @param {keyPair} issuer object of publicKey and secret | ||
* @param {keyPair} account object of publicKey and secret | ||
* @param {keyPair} asset object of publicKey and secret | ||
* @return transaction server transaction result | ||
*/ | ||
function createTrustLine(issuer, account, asset) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var server, acc, transaction, e_5; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
server = new stellar_sdk_1.default.Server((0, setting_1.config)().horizon_url); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 5]); | ||
return [4 /*yield*/, server.loadAccount(account.publicKey)]; | ||
case 2: | ||
acc = _a.sent(); | ||
transaction = new stellar_sdk_1.TransactionBuilder(acc) | ||
.addOperation(stellar_sdk_1.Operation.changeTrust({ | ||
// @ts-ignore | ||
asset: asset, | ||
issuer: issuer.publicKey | ||
})) | ||
.build(); | ||
transaction.sign(acc); | ||
return [4 /*yield*/, server.submitTransaction(transaction)]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
case 4: | ||
e_5 = _a.sent(); | ||
throw e_5; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.createTrustLine = createTrustLine; |
{ | ||
"name": "amp-wallet", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"description": "Amanatpay Blockchain Wallet", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,3 +0,4 @@ | ||
[![Codecov Coverage](https://img.shields.io/codecov/c/github/caki0915/my-awesome-greeter/coverage.svg?style=flat-square)](https://codecov.io/gh/caki0915/my-awesome-greeter/) | ||
#function | ||
<a href="www.amanatpay.com">Amanatpay Wallet Operation</href> | ||
## Functions | ||
<dl> | ||
@@ -14,6 +15,8 @@ <dt><a href="#getAllAccountBalances">getAllAccountBalances(publicKey)</a> ⇒ <code>Array.<object></code></dt> | ||
<dd><p>load 1000 friend bot to wallet if it's native balance is below 100</p></dd> | ||
<dt><a href="#createWallet">createWallet(disctpub)</a></dt> | ||
<dt><a href="#createWallet">createWallet(distpub)</a></dt> | ||
<dd><p>create new wallet and load 1000 native gas</p></dd> | ||
<dt><a href="#History">History()</a></dt> | ||
<dt><a href="#History">History(pub)</a></dt> | ||
<dd><p>Wallet's transactions for all assets</p></dd> | ||
<dt><a href="#createAsset">createAsset()</a></dt> | ||
<dd><p>CREATE an asset that's are include issue account and distributor</p></dd> | ||
<dt><a href="#getWalletObj">getWalletObj(publicKey)</a> ⇒ <code>AccountResponse</code></dt> | ||
@@ -33,2 +36,6 @@ <dd><p>get wallet's object from Amanatpay blockchain</p></dd> | ||
<dd><p>convert raw transactions list ( payment) to needed details</p></dd> | ||
<dt><a href="#setupIssuer">setupIssuer(Issuer)</a> ⇒</dt> | ||
<dd><p>change account options for Issuer account( new assets)</p></dd> | ||
<dt><a href="#createTrustLine">createTrustLine(issuer, account, asset)</a> ⇒</dt> | ||
<dd><p>create trust-line in between issuer account , asset and account</p></dd> | ||
</dl> | ||
@@ -102,3 +109,3 @@ | ||
## createWallet(disctpub) | ||
## createWallet(distpub) | ||
<p>create new wallet and load 1000 native gas</p> | ||
@@ -110,9 +117,20 @@ | ||
| --- | --- | --- | | ||
| disctpub | <code>string</code> | <p>disturber secret key to load 1000 native gas into the account</p> | | ||
| distpub | <code>string</code> | <p>disturber secret key to load 1000 native gas into the account</p> | | ||
<a name="History"></a> | ||
## History() | ||
## History(pub) | ||
<p>Wallet's transactions for all assets</p> | ||
**Kind**: global function | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| pub | <code>string</code> | <p>public key</p> | | ||
<a name="createAsset"></a> | ||
## createAsset() | ||
<p>CREATE an asset that's are include issue account and distributor</p> | ||
**Kind**: global function | ||
@@ -195,1 +213,27 @@ <a name="getWalletObj"></a> | ||
<a name="setupIssuer"></a> | ||
## setupIssuer(Issuer) ⇒ | ||
<p>change account options for Issuer account( new assets)</p> | ||
**Kind**: global function | ||
**Returns**: <p>transaction server transaction result</p> | ||
| Param | Type | | ||
| --- | --- | | ||
| Issuer | <code>string</code> | | ||
<a name="createTrustLine"></a> | ||
## createTrustLine(issuer, account, asset) ⇒ | ||
<p>create trust-line in between issuer account , asset and account</p> | ||
**Kind**: global function | ||
**Returns**: <p>transaction server transaction result</p> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| issuer | <code>keyPair</code> | <p>object of publicKey and secret</p> | | ||
| account | <code>keyPair</code> | <p>object of publicKey and secret</p> | | ||
| asset | <code>keyPair</code> | <p>object of publicKey and secret</p> | | ||
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
48435
877
235