How to use the @iota/core.createGetBalances function in @iota/core

To help you get started, we’ve selected a few @iota/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotaledger / iota.js / packages / account / src / preset.ts View on Github external
export function networkAdapter({ provider }: NetworkParams): Network {
    const httpClient = createHttpClient({ provider })
    const getBalances = createGetBalances(httpClient)
    const getTrytes = createGetTrytes(httpClient)
    const getLatestInclusion = createGetLatestInclusion(httpClient)

    return {
        getTrytes: hashes => (hashes.length > 0 ? getTrytes(hashes) : Promise.resolve([])),
        getBalance: (address): Promise => getBalances([address], 100).then(({ balances }) => balances[0]),
        getBalances,
        getConsistency: createCheckConsistency(httpClient),
        getLatestInclusion: hashes => (hashes.length > 0 ? getLatestInclusion(hashes) : Promise.resolve([])),
        getBundlesFromAddresses: createGetBundlesFromAddresses(httpClient, 'lib'),
        findTransactions: createFindTransactions(httpClient),
        sendTrytes: createSendTrytes(httpClient),
        setSettings: httpClient.setSettings,
        getTransactionsToApprove: createGetTransactionsToApprove(httpClient),
        attachToTangle: createAttachToTangle(httpClient),
        storeAndBroadcast: createStoreAndBroadcast(httpClient),
github iotaledger / iota.js / packages / multisig / src / multisig.ts View on Github external
.then((sanitizedTransfers: ReadonlyArray) =>
                input.balance
                    ? createBundle(input, sanitizedTransfers, remainderAddress)
                    : (createGetBalances(this.provider) as any)([input.address], 100)
                          .then(
                              (res: Balances): MultisigInput => ({
                                  ...input,
                                  balance: res.balances[0],
                              })
                          )
                          .then((inputWithBalance: MultisigInput) =>
                              createBundle(inputWithBalance, sanitizedTransfers, remainderAddress)
                          )
            )