-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing examples btc based (#327)
- Loading branch information
1 parent
b4e0fde
commit c55ee29
Showing
20 changed files
with
872 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,163 @@ | ||
import { TatumBchSDK } from '@tatumio/bch' | ||
import { REPLACE_ME_WITH_TATUM_API_KEY } from '@tatumio/shared-testing' | ||
import { Currency } from '@tatumio/shared-core' | ||
import { TatumBchSDK } from '@tatumio/bch'; | ||
import { REPLACE_ME_WITH_TATUM_API_KEY } from '@tatumio/shared-testing'; | ||
import { Currency } from '@tatumio/shared-core'; | ||
import { CreateTrade, VirtualCurrency } from '@tatumio/api-client'; | ||
|
||
const bchSDK = TatumBchSDK({ apiKey: REPLACE_ME_WITH_TATUM_API_KEY }) | ||
const bchSDK = TatumBchSDK({ apiKey: REPLACE_ME_WITH_TATUM_API_KEY }); | ||
|
||
export async function bchLedgerAccountsExample() { | ||
const account = await bchSDK.ledger.account.create({ | ||
currency: Currency.BCH, | ||
}) | ||
}); | ||
await bchSDK.ledger.account.activate('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.account.createMultiple({ | ||
accounts: [ | ||
{ currency: Currency.BCH }, | ||
{ currency: Currency.BCH }, | ||
] | ||
}); | ||
await bchSDK.ledger.account.deactivate('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.account.freeze('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.account.unfreeze('5e6be89ee6aa436299950c3f'); | ||
await bchSDK.ledger.account.update('5e6be89ee6aa436299950c3f', { | ||
accountCode: "AC_1011_B", | ||
accountNumber: "123456" | ||
}); | ||
|
||
const accountById = await bchSDK.ledger.account.get('5e68c66581f2ee32bc354087'); | ||
const accounts = await bchSDK.ledger.account.getAll(10); | ||
const balance = await bchSDK.ledger.account.getBalance('5e68c66581f2ee32bc354087'); | ||
const blockedAmount = await bchSDK.ledger.account.getBlockedAmountsByAccountId('5e68c66581f2ee32bc354087'); | ||
const customerAccounts = await bchSDK.ledger.account.getByCustomerId(10, '5e6be89ee6aa436299950c3f'); | ||
} | ||
|
||
export async function bchLedgerBlockAmountExample() { | ||
const accountId = await bchSDK.ledger.blockAmount.block('5e6be89ee6aa436299950c3f', { | ||
amount: "5", | ||
type: "DEBIT_CARD_OP", | ||
description: "Card payment in the shop." | ||
}); | ||
const txResult = await bchSDK.ledger.blockAmount.unblockWithTransaction('5e6be89ee6aa436299950c3f', { | ||
recipientAccountId: "5e6645712b55823de7ea82f2", | ||
amount: "5", | ||
anonymous: false, | ||
compliant: false, | ||
transactionCode: "1_01_EXTERNAL_CODE", | ||
paymentId: "9625", | ||
recipientNote: "Private note", | ||
baseRate: 1, | ||
senderNote: "Sender note" | ||
}); | ||
await bchSDK.ledger.blockAmount.unblock('5e6be89ee6aa436299950c3f'); | ||
} | ||
|
||
export async function bchLedgerCustomerExample() { | ||
await bchSDK.ledger.customer.activate('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.customer.deactivate('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.customer.disable('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.customer.enable('5e68c66581f2ee32bc354087'); | ||
|
||
const customer = await bchSDK.ledger.customer.get('5e68c66581f2ee32bc354087'); | ||
const customers = await bchSDK.ledger.customer.getAll(10); | ||
const updatedCustomer = await bchSDK.ledger.customer.update('5e68c66581f2ee32bc354087', { | ||
externalId: "123654", | ||
}); | ||
} | ||
|
||
export async function bchLedgerOrderbookExample() { | ||
await bchSDK.ledger.orderBook.cancel('5e68c66581f2ee32bc354087'); | ||
await bchSDK.ledger.orderBook.cancelByAccount('5e68c66581f2ee32bc354087'); | ||
|
||
const trade = await bchSDK.ledger.orderBook.get('7c21ed165e294db78b95f0f1'); | ||
const activeBuyTrades = await bchSDK.ledger.orderBook.getActiveBuyTrades({ | ||
id: "7c21ed165e294db78b95f0f1", | ||
customerId: "5e68c66581f2ee32bc354087", | ||
pageSize: 10, | ||
}); | ||
const activeSellTrades = await bchSDK.ledger.orderBook.getActiveSellTrades({ | ||
id: "7c21ed165e294db78b95f0f1", | ||
customerId: "5e68c66581f2ee32bc354087", | ||
pageSize: 10, | ||
}); | ||
const historicalTrades = await bchSDK.ledger.orderBook.getHistorical({ | ||
id: "7c21ed165e294db78b95f0f1", | ||
customerId: "5e68c66581f2ee32bc354087", | ||
pageSize: 10, | ||
}); | ||
const newTrade = await bchSDK.ledger.orderBook.newTrade({ | ||
type: CreateTrade.type.BUY, | ||
price: "8650.4", | ||
amount: "15000", | ||
pair: "BCH/EUR", | ||
currency1AccountId: "7c21ed165e294db78b95f0f1", | ||
currency2AccountId: "7c21ed165e294db78b95f0f1", | ||
feeAccountId: "7c21ed165e294db78b95f0f1", | ||
fee: 1.5, | ||
attr: { | ||
sealDate: 1572031674384, | ||
percentBlock: 1.5, | ||
percentPenalty: 1.5 | ||
} | ||
}); | ||
} | ||
|
||
export async function bchLedgerTransactionExample() { | ||
const transaction = await bchSDK.ledger.transaction.countByAccount({ | ||
id: '5e6be8e9e6aa436299950c41' | ||
}); | ||
const transactionByCustomer = await bchSDK.ledger.transaction.countByCustomer({ | ||
id: '5e6be8e9e6aa436299950c41' | ||
}); | ||
const transactions = await bchSDK.ledger.transaction.getAll({}); | ||
|
||
const transactionByAccount = await bchSDK.ledger.transaction.getAllByAccount({ id: '5e6645712b55823de7ea82f1' }); | ||
const transactionByCUstomer = await bchSDK.ledger.transaction.getAllByCustomer({ | ||
id: '5e6be8e9e6aa436299950c41' | ||
}); | ||
const transactionByReference = await bchSDK.ledger.transaction.getAllByReference('5e6be8e9e6aa436299950c41'); | ||
const transactionResult = await bchSDK.ledger.transaction.send({ | ||
senderAccountId: "5e6645712b55823de7ea82f1", | ||
recipientAccountId: "5e6645712b55823de7ea82f2", | ||
amount: "5", | ||
}); | ||
const batchTxResult = await bchSDK.ledger.transaction.sendMultiple({ | ||
senderAccountId: '5e6645712b55823de7ea82f1', | ||
transaction: [{ | ||
recipientAccountId: "5e6645712b55823de7ea82f2", | ||
amount: "5", | ||
}] | ||
}); | ||
} | ||
|
||
export async function bchLedgerVirtualCurrencyExample() { | ||
const virtualCurrencyAcc = await bchSDK.ledger.virtualCurrency.create({ | ||
name: "VC_VIRTUAL", | ||
supply: "1000000", | ||
basePair: VirtualCurrency.basePair.BCH, | ||
baseRate: 1, | ||
customer: { | ||
accountingCurrency: VirtualCurrency.accountingCurrency.USD, | ||
customerCountry: "US", | ||
externalId: "123654", | ||
providerCountry: "US" | ||
}, | ||
description: "My Virtual Token description.", | ||
accountCode: "AC_1011_B", | ||
accountNumber: "1234567890", | ||
accountingCurrency: VirtualCurrency.accountingCurrency.USD | ||
}); | ||
const virtualCurrency = await bchSDK.ledger.virtualCurrency.getByName('VC_VIRTUAL'); | ||
const mintTx = await bchSDK.ledger.virtualCurrency.mint({ | ||
accountId: "5e68c66581f2ee32bc354087", | ||
amount: "1.5", | ||
}); | ||
const revokeTx = await bchSDK.ledger.virtualCurrency.revoke({ | ||
accountId: "5e68c66581f2ee32bc354087", | ||
amount: "1.5", | ||
}); | ||
await bchSDK.ledger.virtualCurrency.update({ | ||
name: "VC_VIRTUAL", | ||
baseRate: 1, | ||
basePair: VirtualCurrency.basePair.EUR | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
import { REPLACE_ME_WITH_TATUM_API_KEY } from '@tatumio/shared-testing' | ||
import { TatumBtcSDK } from '@tatumio/btc' | ||
import { REPLACE_ME_WITH_TATUM_API_KEY } from '@tatumio/shared-testing'; | ||
import { TatumBtcSDK } from '@tatumio/btc'; | ||
import { BtcTransactionFromAddress } from '@tatumio/api-client'; | ||
|
||
const btcSDK = TatumBtcSDK({ apiKey: REPLACE_ME_WITH_TATUM_API_KEY }) | ||
const btcSDK = TatumBtcSDK({ apiKey: REPLACE_ME_WITH_TATUM_API_KEY }); | ||
|
||
export async function btcApiExample() { | ||
const mempoolTransactionIds = await btcSDK.api.btcGetMempool() | ||
const mempoolTransactionIds = await btcSDK.api.btcGetMempool(); | ||
const block = await btcSDK.api.btcGetBlock( | ||
'0000000000000000000067de34da54c96ff76e6ba172f82c4ed8a25afb112a9e', | ||
) | ||
); | ||
const txHash = await btcSDK.api.btcBroadcast({ txData: '62BD544D1B9031EFC330A3E855CC3A0D51CA5131455C1AB3BCAC6D243F65460D', signatureId: '1f7f7c0c-3906-4aa1-9dfe-4b67c43918f6' }); | ||
const address = await btcSDK.api.btcGenerateAddress('xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid', 0); | ||
const privateKey = await btcSDK.api.btcGenerateAddressPrivateKey({ mnemonic: 'urge pulp usage sister evidence arrest palm math please chief egg abuse', index: 0 }); | ||
const wallet = await btcSDK.api.btcGenerateWallet('urge pulp usage sister evidence arrest palm math please chief egg abuse'); | ||
const balance = await btcSDK.api.btcGetBalanceOfAddress('2MsM67NLa71fHvTUBqNENW15P68nHB2vVXb'); | ||
const blockchainInfo = await btcSDK.api.btcGetBlockChainInfo(); | ||
const hash = await btcSDK.api.btcGetBlockHash(1580117); | ||
const tx = await btcSDK.api.btcGetRawTransaction('1451692ebbfbea1a2d2ec6fe6782596b6aa2e46c0589d04c406f491b5b46bc6a'); | ||
const txByAddress = await btcSDK.api.btcGetTxByAddress('2MsM67NLa71fHvTUBqNENW15P68nHB2vVXb', 50); | ||
const utxo = await btcSDK.api.btcGetUtxo('53faa103e8217e1520f5149a4e8c84aeb58e55bdab11164a95e69a8ca50f8fcc', 0); | ||
const transfer = await btcSDK.api.btcTransferBlockchain({ | ||
fromAddress: [{ | ||
address: "2N9bBiH2qrTDrPCzrNhaFGdkNKS86PJAAAS", | ||
privateKey: "cVX7YtgL5muLTPncHFhP95oitV1mqUUA5VeSn8HeCRJbP" | ||
}], to: [ | ||
{ | ||
address: "2MzNGwuKvMEvKMQogtgzSqJcH2UW3Tc5oc7", | ||
value: 0.02969944 | ||
} | ||
] | ||
} as BtcTransactionFromAddress); | ||
} |
Oops, something went wrong.