Comparing version 0.0.8-alpha to 0.0.9-alpha
{ | ||
"name": "@ignt/vue", | ||
"version": "0.0.8-alpha", | ||
"version": "0.0.9-alpha", | ||
"description": "Autogenerated Vue API", | ||
@@ -5,0 +5,0 @@ "author": "Ignite Codegen <hello@ignt.com>", |
// THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. | ||
import { OfflineDirectSigner } from '@cosmjs/proto-signing' | ||
import { SigningStargateClient } from '@cosmjs/stargate' | ||
import { createIgnite, Ignite, registry } from '@ignt/client' | ||
import { ToRefs, toRefs, reactive } from 'vue' | ||
import { createIgnite, Ignite, registry, Environment } from '@ignt/client' | ||
import { reactive, Ref, toRefs, ToRefs } from 'vue' | ||
// defaults | ||
let apiURL = process.env.API_COSMOS || 'http://localhost:1317' | ||
let rpcURL = process.env.API_TENDERMINT || 'http://localhost:26657' | ||
let wsURL = process.env.WS_TENDERMINT || 'ws://localhost:26657/websocket' | ||
let prefix = process.env.ADDRESS_PREFIX || 'cosmos' | ||
type State = { | ||
ignite: Ignite | ||
ignite: Ref<Ignite> | ||
} | ||
// singleton state | ||
const state = reactive({ | ||
ignite: createIgnite({ | ||
env: { | ||
apiURL, | ||
rpcURL, | ||
wsURL, | ||
prefix | ||
} | ||
}).connectWS() as Ignite | ||
} as State) | ||
type Response = { | ||
@@ -35,5 +17,35 @@ state: ToRefs<State> | ||
export default function (): Response { | ||
let ignite = state.ignite | ||
type Params = { | ||
env: Environment | ||
autoConnectWS: boolean | ||
} | ||
// singleton state | ||
const state = reactive({} as State) | ||
export default function ( | ||
p: Params = { | ||
env: { | ||
apiURL: 'http://localhost:1317', | ||
rpcURL: 'http://localhost:26657', | ||
wsURL: 'ws://localhost:26657/websocket', | ||
prefix: 'cosmos' | ||
}, | ||
autoConnectWS: true | ||
} | ||
): Response { | ||
if (!state.ignite) { | ||
if (!p.env) { | ||
throw new Error('Ignite: Unable to create instance without env') | ||
} | ||
state.ignite = createIgnite({ | ||
env: p.env | ||
}) as Ignite | ||
if (p.autoConnectWS) { | ||
state.ignite.connectWS() | ||
} | ||
} | ||
let signIn = async (offlineSigner: OfflineDirectSigner) => { | ||
@@ -43,3 +55,3 @@ let [acc] = await offlineSigner.getAccounts() | ||
let stargateClient = await SigningStargateClient.connectWithSigner( | ||
ignite.env.rpcURL, | ||
state.ignite.env.rpcURL, | ||
offlineSigner, | ||
@@ -49,7 +61,7 @@ { registry } | ||
ignite.signIn(stargateClient, acc.address) | ||
state.ignite.signIn(stargateClient, acc.address) | ||
} | ||
let signOut = () => { | ||
ignite.signOut() | ||
state.ignite.signOut() | ||
} | ||
@@ -56,0 +68,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40126
911