@waves/waves-transactions
Advanced tools
@@ -36,2 +36,15 @@ import { ICancelOrder, IOrder, TRANSACTION_TYPE, TTx, TTxParams } from './transactions'; | ||
/** | ||
* Retrieve information about waves account balance | ||
* @param address - waves address as base58 string | ||
* @param nodeUrl - node address to ask balance from. E.g. https://nodes.wavesplatform.com/ | ||
*/ | ||
export declare function addressBalance(address: string, nodeUrl: string): Promise<number>; | ||
/** | ||
* Retrieve information about waves account balance | ||
* @param address - waves address as base58 string | ||
* @param key - dictionary key | ||
* @param nodeUrl - node address to ask balance from. E.g. https://nodes.wavesplatform.com/ | ||
*/ | ||
export declare function addressDataByKey(address: string, key: string, nodeUrl: string): Promise<number | Uint8Array | string | null>; | ||
/** | ||
* Sends order to matcher | ||
@@ -38,0 +51,0 @@ * @param ord - transaction to send |
@@ -84,2 +84,38 @@ "use strict"; | ||
/** | ||
* Retrieve information about waves account balance | ||
* @param address - waves address as base58 string | ||
* @param nodeUrl - node address to ask balance from. E.g. https://nodes.wavesplatform.com/ | ||
*/ | ||
function addressBalance(address, nodeUrl) { | ||
return axios_1.default.get(`addresses/balance/${address}`, { baseURL: nodeUrl }) | ||
.then(x => x.data && x.data.balance) | ||
.catch(e => Promise.reject(e.response && e.response.status === 400 ? new Error(e.response.data.message) : e)); | ||
} | ||
exports.addressBalance = addressBalance; | ||
/** | ||
* Retrieve information about waves account balance | ||
* @param address - waves address as base58 string | ||
* @param key - dictionary key | ||
* @param nodeUrl - node address to ask balance from. E.g. https://nodes.wavesplatform.com/ | ||
*/ | ||
function addressDataByKey(address, key, nodeUrl) { | ||
return axios_1.default.get(`addresses/data/${address}/${key}`, { baseURL: nodeUrl }) | ||
.then(x => { | ||
switch (x.data.type) { | ||
case 'integer': | ||
case 'string': | ||
return x.data.value; | ||
case 'binary': | ||
return marshall_1.serializePrimitives.BASE64_STRING(x.data.value); | ||
case 'boolean': | ||
return x.data.value === 'true'; | ||
} | ||
return null; | ||
}) | ||
.catch(e => e.response && e.response.status === 404 ? | ||
Promise.resolve(null) : | ||
Promise.reject(e.response && e.response.status === 400 ? new Error(e.response.data.message) : e)); | ||
} | ||
exports.addressDataByKey = addressDataByKey; | ||
/** | ||
* Sends order to matcher | ||
@@ -86,0 +122,0 @@ * @param ord - transaction to send |
@@ -16,3 +16,3 @@ export { massTransfer } from './transactions/mass-transfer'; | ||
export { contractInvocation } from './transactions/contract-invocation'; | ||
export { signTx, broadcast, verify, serialize, submitOrder, cancelSubmittedOrder } from './general'; | ||
export { signTx, broadcast, verify, serialize, submitOrder, cancelSubmittedOrder, addressBalance, addressDataByKey } from './general'; | ||
export { waitForTx } from './generic'; | ||
@@ -19,0 +19,0 @@ export { ITransaction, TTx, TTxParams, IAliasTransaction, IAliasParams, IIssueTransaction, IIssueParams, IReissueTransaction, IReissueParams, IBurnTransaction, IBurnParams, IExchangeTransaction, ILeaseTransaction, ILeaseParams, ICancelLeaseTransaction, ICancelLeaseParams, ITransferTransaction, ITransferParams, IMassTransferTransaction, IMassTransferParams, ISetAssetScriptTransaction, ISetScriptParams, IDataTransaction, IDataParams, ISetScriptTransaction, ISetAssetScriptParams, IContractInvocationTransaction, IContractInvocationParams, IOrder, IOrderParams, ICancelOrder, ICancelOrderParams, WithId, } from './transactions'; |
@@ -51,2 +51,4 @@ "use strict"; | ||
exports.cancelSubmittedOrder = general_1.cancelSubmittedOrder; | ||
exports.addressBalance = general_1.addressBalance; | ||
exports.addressDataByKey = general_1.addressDataByKey; | ||
var generic_1 = require("./generic"); | ||
@@ -53,0 +55,0 @@ exports.waitForTx = generic_1.waitForTx; |
@@ -31,3 +31,3 @@ import { IAliasParams, IAliasTransaction, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "C3WG3Zfv49tC8JkUqXQRUry9DWb5fW1ey7dwMSk9PVpH", | ||
* "id": "AVz6fWKuwTzppfzNH2SnTW26if1t2AaCkSRT1btxeTVK", | ||
* "type": 10, | ||
@@ -38,6 +38,6 @@ * "version": 2, | ||
* "fee": 100000, | ||
* "timestamp": 1550759474488, | ||
* "timestamp": 1550821721482, | ||
* "chainId": 87, | ||
* "proofs": [ | ||
* "4q8MLayy3qQ512fkcQW78M4u3ay8HiUC4WrvTy5qEWECftwYBRNnoovuaxyFuHjEF6bt7HgowMWqaiQA6FUTwB1j" | ||
* "3aWs5m14ATAyVSA9ynB3x17Y8CqjExFT2svBmbxM3SwgbgbpLumjvEvtrsEznJ1LBV2vympGkgN4vfXq3o8YLvw9" | ||
* ] | ||
@@ -44,0 +44,0 @@ * } |
@@ -32,3 +32,3 @@ import { IBurnTransaction, IBurnParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "575Kjo42eNEY63Bzdnd3ENrUjSUdq6BxYDKWCYmu8GLj", | ||
* "id": "3R7jJ6ouquvtmee1wjV6mfLd8JmscLzed8ghgcfTo5yt", | ||
* "type": 6, | ||
@@ -41,5 +41,5 @@ * "version": 2, | ||
* "fee": 100000, | ||
* "timestamp": 1550759474292, | ||
* "timestamp": 1550821721068, | ||
* "proofs": [ | ||
* "3HmCB5Nyaew7dNniAtjzbyAsrVMxsQbhms7rkbTBRStaMtyksEyDYHEFEJx9guHy4tgNNfToNU5UEwsaHyGtLeNA" | ||
* "57gVoQV7RqxuCaKooqDThEheDns6ZzYJC2ApFw1vdunwJVjj5tCYFqSWb5ipsY8quCsMkYT5i3m53PdnUPXTDUVX" | ||
* ] | ||
@@ -46,0 +46,0 @@ * } |
@@ -31,3 +31,3 @@ import { ICancelLeaseTransaction, ICancelLeaseParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "CnDWkdcQtCuerFhxdc7wNy83xqv7rZyCgq4tdSuwsPy3", | ||
* "id": "DyiWLvBoNAvZ7dpoMJUyEBvG9Exnh5CQnH8uh2mBVbhs", | ||
* "type": 9, | ||
@@ -38,6 +38,6 @@ * "version": 2, | ||
* "fee": 100000, | ||
* "timestamp": 1550759474341, | ||
* "timestamp": 1550821721165, | ||
* "chainId": 87, | ||
* "proofs": [ | ||
* "5B7dVrspRgj9xnvJL6kqpahUBzyqck9sLn8kP5PPwwTTQBWGbBRmxNxkPsmZW9geUEPZ94YujpCpiiYxVx5getkh" | ||
* "4k9ncLpmWwYf9XZbF961CeeHycM4NHPWoMVgrHoSUZjnnPFB6ga2Sxg1FHvz4G9Tcjua92MwyRHtuJhmvd3uWgVg" | ||
* ] | ||
@@ -44,0 +44,0 @@ * } |
@@ -40,3 +40,3 @@ /// <reference types="node" /> | ||
* { | ||
* "id": "7JKZC1z384Dpc7zMLNwp6kAJg5SG8ioQZsGpapF4Gr6C", | ||
* "id": "8CdXWGH19aFR5rd9oGGFRKkp9fjw27FRMaievVsHbEwk", | ||
* "type": 12, | ||
@@ -46,5 +46,5 @@ * "version": 1, | ||
* "fee": 100000, | ||
* "timestamp": 1550759474366, | ||
* "timestamp": 1550821721214, | ||
* "proofs": [ | ||
* "23KgU7ZML6jgTyHocn6ty6yKhwru3ANFBJnZrPz8XkziMZv9YQV6vihMRQzP6Xn7ZcxH8mY5WMRx8WVXaMRU7vzC" | ||
* "3n23SbJPkkScn1TvBKKW3XEEJMwJewsRPfhBAJcKJfc5Vf3rbV775tcPRBkQDyvu3Q4JFmN6SedFohAg7vGLFHhy" | ||
* ], | ||
@@ -51,0 +51,0 @@ * "data": [ |
@@ -35,3 +35,3 @@ import { IIssueTransaction, IIssueParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "AFGgzfzUSi8ssnTDRDKDCaH4Hw7axRgP6er6nbVyoWPi", | ||
* "id": "G7diRUwxThepB4nYzEiAfy354G9bs4K4YkG2TeuuKXFv", | ||
* "type": 3, | ||
@@ -46,6 +46,6 @@ * "version": 2, | ||
* "fee": 100000000, | ||
* "timestamp": 1550759474391, | ||
* "timestamp": 1550821721285, | ||
* "chainId": 87, | ||
* "proofs": [ | ||
* "5BTC21kRfzagRT3enCKZS1aS2x5LdbvMFmCRr1WEucoLZGXU2Y3J7mRhEGgiPFyxGxTP59wXqZB4Rdaj9a5YBu59" | ||
* "2G6Ap6FSKGmXypcXqcTG8vwTX9nPy6a2HdwJKRxcBwvKj8LT3f9SxaW96E5WbR29EXETh2pgFrCutTHU4TbkG7VH" | ||
* ] | ||
@@ -52,0 +52,0 @@ * } |
@@ -31,3 +31,3 @@ import { ILeaseTransaction, ILeaseParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "8M3i6ABmyLANYLFmJSYYZCv8TLYSpS5WgRkSw2Qikrif", | ||
* "id": "DMYkn3oknfSUHPupFkPtKfXaf1pXok9rLCcU17fFwiZt", | ||
* "type": 8, | ||
@@ -39,5 +39,5 @@ * "version": 2, | ||
* "fee": 100000, | ||
* "timestamp": 1550759474424, | ||
* "timestamp": 1550821721325, | ||
* "proofs": [ | ||
* "2f9t8zhwGZ8u8UwzNoNSuwjNvwuQWV2Xx17JAMMCgNbZm2WfRbe4uHZDn9P625fV5XMRF2kp5vtV3jNMjJ6nj9H1" | ||
* "2JoGp7YztyzSgXHEUvqPGkLnSDiTLwMU5DnzmHYSc7jYLL6GaYpmQLRLLe3GM8ZdDuTdScWpz9tQ25YxFhAb1gi8" | ||
* ] | ||
@@ -44,0 +44,0 @@ * } |
@@ -39,3 +39,3 @@ import { IMassTransferTransaction, IMassTransferParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "8CWC3tkBKhscSQkhGsbgbPCpjWGnimoZF2ZSCcJegYhc", | ||
* "id": "J7ratoawKtV4ZxwTUt4PsG7JSqPunuwMYNEiUxFVt53V", | ||
* "type": 11, | ||
@@ -55,6 +55,6 @@ * "version": 1, | ||
* "fee": 200000, | ||
* "timestamp": 1550759474437, | ||
* "timestamp": 1550821721415, | ||
* "attachment": "", | ||
* "proofs": [ | ||
* "tTJ7cSv4ULirxfYCNv1fpKuy8dwEJ2n4bqvxqkAhQrXLXWm1SCitVENxif1rNixKM3Zfx6aPp5k5Lb9xsr3NCz9" | ||
* "4pxk7VkwZGsjAoE11bGSRGtJq1s8mtCN2w4VXeS1Gu9X4BdNBrqG13WvpsWCeZJPfZLoffexpneFpTjkVMs9ECn6" | ||
* ] | ||
@@ -61,0 +61,0 @@ * } |
@@ -33,3 +33,3 @@ import { IReissueTransaction, IReissueParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "5v8PrqCyM8n8aLzMfwjaB7qxXnYSUsy3SFdbRsTYMmME", | ||
* "id": "24rFisG6iudmUgaXANW1kjAMwL7Wov5wsYxdQV2WMTSj", | ||
* "type": 5, | ||
@@ -43,5 +43,5 @@ * "version": 2, | ||
* "fee": 100000000, | ||
* "timestamp": 1550759474450, | ||
* "timestamp": 1550821721448, | ||
* "proofs": [ | ||
* "57WJ1McbdNqijV4tDALu9WotV4KPBGwjuHcgaE5fYtHMm1B5GJTRUC9fXAEjdxQ23MwXb2d6SBs8kg7VqFUNYDBK" | ||
* "65NEiVVLtmQUAWxY7rgwvXwYsYa22c3d9VetmyyiUe6jvhuNBjq1yuWKc5ARroY4PebPWPuT2CfTPTpT9NBMS4Bq" | ||
* ] | ||
@@ -48,0 +48,0 @@ * } |
@@ -31,3 +31,3 @@ import { ISetScriptTransaction, ISetScriptParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "ABLafa59vHq8ahabrKHXcMPVeJxxkJDyagRaPN78LLWN", | ||
* "id": "7QoFU4HpQ3nLbY41thda5rBeGSzWtEYJJJbkZV7qciek", | ||
* "type": 13, | ||
@@ -38,5 +38,5 @@ * "version": 1, | ||
* "fee": 1000000, | ||
* "timestamp": 1550759474498, | ||
* "timestamp": 1550821721500, | ||
* "proofs": [ | ||
* "4p65GJar6tj28TJ7cJCsh4nNoSujfGLhx5Lt6uPKr6K1CDba9rQtjyjC4VJTTr1Jh29MqTgEGwLLJGUnNkAuAPkj" | ||
* "4M1Xv8RhQb64bo4Ffxp9Xt1JuRvjCo9fPzqNmFae2GethZK7abzAcMb39qm88xE7eMwSGyMqHNesZjAzxGHSjJWw" | ||
* ], | ||
@@ -43,0 +43,0 @@ * "script": "base64:AQa3b8tH" |
@@ -35,3 +35,3 @@ import { ITransferTransaction, ITransferParams, WithId, WithSender } from '../transactions'; | ||
* { | ||
* "id": "B5LkhWA5cyxA5d5pi7HnjFqHvcgrhfbQba3up8Deher2", | ||
* "id": "CSq6rAMFriA2oLiMPVfRLos312aQdBHm6hHejyDLacrJ", | ||
* "type": 4, | ||
@@ -44,5 +44,5 @@ * "version": 2, | ||
* "fee": 100000, | ||
* "timestamp": 1550759474477, | ||
* "timestamp": 1550821721464, | ||
* "proofs": [ | ||
* "64x4BmpgwKjw6hvw7s1Bh11pxVuyYHbpk5QftqdHk4oTV6nYaELzVAkQpvPrBYNLA7pR6fELdteDpFhHVnZByThm" | ||
* "v3Ze9B4WZLWNsKUu5AymNWWtZRVveFycgrGg67kVQcHNHbof4Bp2vVE8yjePURmc2dYJRd52x5F9Vkibed6Duw5" | ||
* ] | ||
@@ -49,0 +49,0 @@ * } |
{ | ||
"name": "@waves/waves-transactions", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"description": "Build and sign(multi-sign) transactions for Waves blockchain.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import axios from 'axios' | ||
import { binary, json } from '@waves/marshall' | ||
import { binary, json, serializePrimitives } from '@waves/marshall' | ||
import { verifySignature } from '@waves/waves-crypto' | ||
@@ -95,2 +95,38 @@ import { | ||
/** | ||
* Retrieve information about waves account balance | ||
* @param address - waves address as base58 string | ||
* @param nodeUrl - node address to ask balance from. E.g. https://nodes.wavesplatform.com/ | ||
*/ | ||
export function addressBalance(address: string, nodeUrl: string): Promise<number> { | ||
return axios.get(`addresses/balance/${address}`, { baseURL: nodeUrl }) | ||
.then(x => x.data && x.data.balance) | ||
.catch(e => Promise.reject(e.response && e.response.status === 400 ? new Error(e.response.data.message) : e)) | ||
} | ||
/** | ||
* Retrieve information about waves account balance | ||
* @param address - waves address as base58 string | ||
* @param key - dictionary key | ||
* @param nodeUrl - node address to ask balance from. E.g. https://nodes.wavesplatform.com/ | ||
*/ | ||
export function addressDataByKey(address: string, key: string, nodeUrl: string): Promise<number | Uint8Array | string | null> { | ||
return axios.get(`addresses/data/${address}/${key}`, { baseURL: nodeUrl }) | ||
.then(x => { | ||
switch (x.data.type) { | ||
case 'integer': | ||
case 'string': | ||
return x.data.value | ||
case 'binary': | ||
return serializePrimitives.BASE64_STRING(x.data.value) | ||
case 'boolean': | ||
return x.data.value === 'true' | ||
} | ||
return null | ||
}) | ||
.catch(e => e.response && e.response.status === 404 ? | ||
Promise.resolve(null) : | ||
Promise.reject(e.response && e.response.status === 400 ? new Error(e.response.data.message) : e)) | ||
} | ||
/** | ||
* Sends order to matcher | ||
@@ -97,0 +133,0 @@ * @param ord - transaction to send |
@@ -21,3 +21,3 @@ // Copyright (c) 2018 Yuriy Naydenov | ||
export { contractInvocation } from './transactions/contract-invocation' | ||
export { signTx, broadcast, verify, serialize, submitOrder, cancelSubmittedOrder } from './general' | ||
export { signTx, broadcast, verify, serialize, submitOrder, cancelSubmittedOrder, addressBalance, addressDataByKey } from './general' | ||
export { waitForTx } from './generic' | ||
@@ -24,0 +24,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
499450
1.05%1525
73.49%11827
0.72%0
-100%