Last active
August 20, 2019 12:14
-
-
Save tobowers/1658a892b12577013013ec6447eb6c21 to your computer and use it in GitHub Desktop.
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 { 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); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ 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) $