Skip to content

Instantly share code, notes, and snippets.

@Sajjon
Last active March 18, 2021 13:40
Show Gist options
  • Save Sajjon/999c214052e9ee348cc96eec1a8e91e1 to your computer and use it in GitHub Desktop.
Save Sajjon/999c214052e9ee348cc96eec1a8e91e1 to your computer and use it in GitHub Desktop.
Radix API sneakpeak
it('radix flow', async (done) => {
const subs = new Subscription()
const loadKeystoreFN = () => Promise.resolve(keystoreForTest.keystore)
const password = keystoreForTest.password
const walletResult = await Wallet.byLoadingAndDecryptingKeystore({
password,
load: loadKeystoreFN
})
if (walletResult.isErr()) {
done(new Error('Failed to decrypt wallet'))
return
}
const wallet = walletResult.value
const radix = Radix.create()
radix.node.subscribe(
n => console.log(`✅💻 Did connect to node: ${n.url.toString()}`)
).add(subs)
radix.wallet.subscribe(
w => console.log(`✅ 💷 Got wallet`)
).add(subs)
radix.activeAddress.subscribe(
address => {
console.log(`🙋🏽‍♀️ my active address is: ${address.toString()}`)
done()
}
).add(subs)
radix
.withWallet(wallet)
.connect(new URL('https://api.radixdlt.com'))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment