Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function makeUiContext(opts: EdgeUiContextOptions) {
const {
apiKey,
appId,
hideKeys = false,
vendorName = '',
vendorImageUrl = ''
} = opts
// Core context:
const core: EdgeContext = await makeEdgeContext({
apiKey,
appId,
hideKeys,
plugins: [ethereumCurrencyPluginFactory, shapeshiftPlugin, coincapPlugin]
})
// iframe root:
const root = document.getElementById('app')
if (root == null) throw new Error('Cannot find document root')
// State:
let localUsers: Array = core.localUsers
let windowVisible = false
const out: EdgeUiContext = {
on: onMethod,
async function makeFrameState (opts: ConnectionMessage): Promise {
const {
apiKey,
appId,
hideKeys,
vendorName = '',
vendorImageUrl = '',
clientDispatch
} = opts
const context = await makeEdgeContext({ apiKey, appId })
return {
accounts: {},
context,
hideKeys,
nextAccountId: 0,
page: '',
pageAccount: null,
vendorImageUrl,
vendorName,
clientDispatch
}
}
export async function makeCoreContext (): Promise {
const opts: EdgeContextOptions = {
apiKey: AIRBITZ_API_KEY,
appId: '',
shapeshiftKey: SHAPESHIFT_API_KEY,
changellyInit: CHANGELLY_INIT,
changeNowKey: CHANGE_NOW_API_KEY,
faastInit: FAAST_INIT
}
return makeEdgeContext(opts)
}
constructor(props) {
super(props)
makeEdgeContext({
apiKey: '3ad0717b3eb31f745aba7bd9d51e7fd1b2926431',
appId: 'com.mydomain.myapp'
}).then(context => this.setState({ context }))
this.state = {
account: null,
closed: false,
context: null
}
}