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
import { | |
CloudWatchLogsClient, | |
StartQueryCommand, | |
GetQueryResultsCommand, | |
LogGroup, | |
DescribeLogGroupsCommand, | |
ResultField | |
} from '@aws-sdk/client-cloudwatch-logs'; | |
import { writeFileSync } from 'fs'; | |
import { DateTime } from 'luxon'; |
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
export function encode(unencoded: string) { | |
return Buffer.from(unencoded).toString('base64'); | |
}; | |
export function decode(encoded: string) { | |
return Buffer.from(encoded, 'base64').toString('utf8'); | |
}; | |
export function urlEncode(unencoded: string) { | |
let encoded = encode(unencoded); |
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
import { DocumentClient } from 'aws-sdk/clients/dynamodb'; | |
function ReplaceSets(item: any) { | |
const keys = Object.keys(item); | |
for (let index = 0; index < keys.length; index++) { | |
const element = item[keys[index]]; | |
if (typeof element === 'object' && element instanceof Set) { | |
if (element.size === 0){ | |
item[keys[index]] = null; | |
} else { |
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
// Your DocClient ... | |
function SplitBatch(params) { | |
const max_items = 25; | |
let tables = Object.entries(params.RequestItems); | |
let transactions = {}; | |
for (const [table, requests] of tables) { | |
for (let index = 0; index < requests.length; index += max_items) { | |
let block = requests.slice(index, index + max_items); |
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
const generateUpdateQuery = (fields) => { | |
let exp = { | |
UpdateExpression: 'set', | |
ExpressionAttributeNames: {}, | |
ExpressionAttributeValues: {} | |
} | |
Object.entries(fields).forEach(([key, item]) => { | |
exp.UpdateExpression += ` #${key} = :${key},`; | |
exp.ExpressionAttributeNames[`#${key}`] = key; | |
exp.ExpressionAttributeValues[`:${key}`] = item |
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
{ id: 'A', | |
chn: | |
[ { id: 'B', chn: [ { id: 'D', chn: [] } ] }, | |
{ id: 'C', | |
chn: | |
[ { id: 'E', chn: [] }, | |
{ id: 'F', chn: [] }, | |
{ id: 'G', | |
chn: | |
[ { id: 'H', chn: [ { id: 'I', chn: [] }, { id: 'J', chn: [] } ] } ] } ] } ] } |
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
const StellarSdk = require('stellar-sdk'); | |
StellarSdk.Network.useTestNetwork(); // StellarSdk.Network.usePublicNetwork(); | |
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org'); // const server = new StellarSdk.Server('https://horizon.stellar.org'); | |
// an arbitary list of trusted assets | |
const ASSETS = { | |
'XPORT': new StellarSdk.Asset('XPORT', 'GCC4HAL7SOR7AZBF53SUTVAJT4OHYLBHOUJMM3IAF5YLFF7OVVAWLVFT'), | |
'USDT': new StellarSdk.Asset('USDT', 'GCQTGZQQ5G4PTM2GL7CDIFKUBIPEC52BROAQIAPW53XBRJVN6ZJVTG6V'), | |
'MOBI' : new StellarSdk.Asset('MOBI', 'GA6HCMBLTZS5VYYBCATRBRZ3BZJMAFUDKYYF6AH6MVCMGWMRDNSWJPIH'), |
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
const StellarSdk = require('stellar-sdk'); | |
StellarSdk.Network.useTestNetwork(); // StellarSdk.Network.usePublicNetwork(); | |
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org'); // const server = new StellarSdk.Server('https://horizon.stellar.org'); | |
// convenience method: returns a PaymentCallBuilder | |
// https://stellar.github.io/js-stellar-sdk/PaymentCallBuilder_PaymentCallBuilder.html#stream | |
// there are similar CallBuilders for other network events, this one is specific to payments | |
var stream = server | |
.payments() |
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
const StellarSdk = require('stellar-sdk'); | |
StellarSdk.Network.useTestNetwork(); // StellarSdk.Network.usePublicNetwork(); | |
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org'); // const server = new StellarSdk.Server('https://horizon.stellar.org'); | |
// an arbitary list of trusted assets | |
const ASSETS = { | |
'XPORT': new StellarSdk.Asset('XPORT', 'GCC4HAL7SOR7AZBF53SUTVAJT4OHYLBHOUJMM3IAF5YLFF7OVVAWLVFT'), | |
'USDT': new StellarSdk.Asset('USDT', 'GCQTGZQQ5G4PTM2GL7CDIFKUBIPEC52BROAQIAPW53XBRJVN6ZJVTG6V'), | |
'MOBI' : new StellarSdk.Asset('MOBI', 'GA6HCMBLTZS5VYYBCATRBRZ3BZJMAFUDKYYF6AH6MVCMGWMRDNSWJPIH'), |
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
const StellarSdk = require('stellar-sdk'); | |
StellarSdk.Network.useTestNetwork(); // StellarSdk.Network.usePublicNetwork(); | |
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org'); // const server = new StellarSdk.Server('https://horizon.stellar.org'); | |
// Note: this solution trusts the accounts asset codes alone. | |
// For general accounts you may need to verify the issuing account id: b.asset_issuer | |
const getBalance = (account, currency) => { | |
let balance = 0; | |
if (currency == 'XLM') { | |
balance = Number.parseFloat(account.balances.find(b => b.asset_type == 'native').balance); |
NewerOlder