Skip to content

Instantly share code, notes, and snippets.

@tobowers tobowers/working.ts
Last active Aug 20, 2019

Embed
What would you like to do?
import { Community, ChainTree } from 'tupelo-wasm-sdk'
const getBlockchainData = async () => {
console.log('start')
let tipId = 'did:tupelo:0xaD2F7DBB91bf3ab9273D97ff44484fb6205f9772'
let community = await Community.getDefault()
console.log('before next update')
await community.nextUpdate()
// Doesn't go beyong that point
console.log('after next update')
const tip = await community.getTip(tipId)
console.log('tip')
console.log(tip)
const tree = new ChainTree({
store: community.blockservice,
tip: tip
})
console.log('tree')
console.log(tree)
return tree.resolve(['tree', 'data'])
}
getBlockchainData().then((resp)=> {
console.log("response: ", resp);
process.exit(1)
}, (err)=> {
console.error(err);
})
@tobowers

This comment has been minimized.

Copy link
Owner Author

tobowers commented Aug 20, 2019

$ ts-node test.ts
start
before next update
after next update
tip
CID {
version: 1,
codec: 'dag-cbor',
multihash:
<Buffer 12 20 1f af 47 3f f2 5c 06 8a 95 71 01 03 12 e9 78 86 e4 b9 c2 5b 10 6e fe 9e a8 65 25 6e 7c 55 b0 e6>,
multibaseName: 'base32' }
tree
ChainTree {
tip:
CID {
version: 1,
codec: 'dag-cbor',
multihash:
<Buffer 12 20 1f af 47 3f f2 5c 06 8a 95 71 01 03 12 e9 78 86 e4 b9 c2 5b 10 6e fe 9e a8 65 25 6e 7c 55 b0 e6>,
multibaseName: 'base32' },
dagStore:
IPLDResolver {
bs: WrappedBlockService { blockservice: [BlockService] },
resolvers: { '85': [Object], '112': [Object], '113': [Object] },
loadFormat: [Function] },
key: undefined,
store:
WrappedBlockService {
blockservice: BlockService { _repo: [IpfsRepo], _bitswap: [Bitswap] } } }
response: { remainderPath: [],
value:
{ hello:
CID {
version: 1,
codec: 'dag-cbor',
multihash:
<Buffer 12 20 fb 44 f3 f3 ed 5c 03 d9 9b 60 67 03 41 7d 0e 80 33 f9 a2 c4 29 1d a3 2c a9 90 59 59 21 9d 9e 65>,
multibaseName: 'base32' } } }
14:13 ~/code/tupelo-wasm-sdk/examples/set-and-get-data (master) $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.