Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-vue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emmanuel Salomon
duniter-vue
Commits
3b487f7c
Commit
3b487f7c
authored
11 months ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
wip dynamic import for web3
parent
fe367969
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common.ts
+3
-3
3 additions, 3 deletions
src/common.ts
src/login.ts
+2
-2
2 additions, 2 deletions
src/login.ts
src/main.ts
+4
-4
4 additions, 4 deletions
src/main.ts
with
9 additions
and
9 deletions
src/common.ts
+
3
−
3
View file @
3b487f7c
import
type
{
ApiPromise
}
from
'
@polkadot/api
'
import
type
{
ApiPromise
}
from
'
@polkadot/api
'
import
{
web3FromAddress
}
from
'
@polkadot/extension-dapp
'
import
type
{
Vec
,
u32
}
from
'
@polkadot/types-codec
'
import
type
{
Vec
,
u32
}
from
'
@polkadot/types-codec
'
import
type
{
ISubmittableResult
,
RegistryError
}
from
'
@polkadot/types/types
'
import
type
{
ISubmittableResult
,
RegistryError
}
from
'
@polkadot/types/types
'
import
type
{
Ref
}
from
'
vue
'
import
type
{
Ref
}
from
'
vue
'
import
{
loginAccount
}
from
'
./global
'
import
{
loginAccount
}
from
'
./global
'
import
type
{
SubmittableExtrinsic
}
from
'
@polkadot/api/promise/types
'
import
type
{
SubmittableExtrinsic
}
from
'
@polkadot/api/promise/types
'
import
type
{
AugmentedSubmittable
}
from
'
@polkadot/api-base/types
'
/// fetch authorities
/// fetch authorities
export
function
fetchAuthorities
(
export
function
fetchAuthorities
(
...
@@ -36,7 +34,9 @@ export async function signAndSend(
...
@@ -36,7 +34,9 @@ export async function signAndSend(
successCallback
:
()
=>
void
successCallback
:
()
=>
void
)
{
)
{
const
address
=
loginAccount
.
value
!
.
address
const
address
=
loginAccount
.
value
!
.
address
const
injector
=
await
web3FromAddress
(
address
)
const
injector
=
await
import
(
'
@polkadot/extension-dapp
'
).
then
((
web3
)
=>
web3
.
web3FromAddress
(
address
)
)
try
{
try
{
await
tx
.
signAndSend
(
await
tx
.
signAndSend
(
address
,
address
,
...
...
This diff is collapsed.
Click to expand it.
src/login.ts
+
2
−
2
View file @
3b487f7c
...
@@ -17,7 +17,6 @@ import type {
...
@@ -17,7 +17,6 @@ import type {
import
type
{
InjectedAccountWithMeta
}
from
'
@polkadot/extension-inject/types
'
import
type
{
InjectedAccountWithMeta
}
from
'
@polkadot/extension-inject/types
'
import
type
{
ApiPromise
}
from
'
@polkadot/api
'
import
type
{
ApiPromise
}
from
'
@polkadot/api
'
import
{
type
u32
,
Option
}
from
'
@polkadot/types-codec
'
import
{
type
u32
,
Option
}
from
'
@polkadot/types-codec
'
import
{
web3Accounts
}
from
'
@polkadot/extension-dapp
'
import
type
{
IdtyNameQuery
}
from
'
@/generated/squid
'
import
type
{
IdtyNameQuery
}
from
'
@/generated/squid
'
import
{
getItem
,
setItem
,
sk
}
from
'
./storage
'
import
{
getItem
,
setItem
,
sk
}
from
'
./storage
'
import
{
IdtyName
}
from
'
@/squid/wot.gql
'
import
{
IdtyName
}
from
'
@/squid/wot.gql
'
...
@@ -31,7 +30,8 @@ export async function tryConnectAccount(
...
@@ -31,7 +30,8 @@ export async function tryConnectAccount(
api
:
ApiPromise
,
api
:
ApiPromise
,
apollo
:
ApolloClient
<
NormalizedCacheObject
>
apollo
:
ApolloClient
<
NormalizedCacheObject
>
)
{
)
{
if
(
allAccounts
.
value
.
length
==
0
)
allAccounts
.
value
=
await
web3Accounts
()
if
(
allAccounts
.
value
.
length
==
0
)
allAccounts
.
value
=
await
import
(
'
@polkadot/extension-dapp
'
).
then
((
web3
)
=>
web3
.
web3Accounts
())
const
allAcc
=
allAccounts
.
value
const
allAcc
=
allAccounts
.
value
allAccounts
.
value
=
allAcc
allAccounts
.
value
=
allAcc
const
defaultLogin
=
getItem
<
string
>
(
sk
.
defaultAccount
)
const
defaultLogin
=
getItem
<
string
>
(
sk
.
defaultAccount
)
...
...
This diff is collapsed.
Click to expand it.
src/main.ts
+
4
−
4
View file @
3b487f7c
...
@@ -3,7 +3,6 @@ import { createApp } from 'vue'
...
@@ -3,7 +3,6 @@ import { createApp } from 'vue'
import
App
from
'
./App.vue
'
import
App
from
'
./App.vue
'
import
router
from
'
./router
'
import
router
from
'
./router
'
import
{
initStateFromStorage
,
initStateFromApis
}
from
'
./global
'
import
{
initStateFromStorage
,
initStateFromApis
}
from
'
./global
'
import
{
web3Enable
}
from
'
@polkadot/extension-dapp
'
import
{
initLocalStorage
}
from
'
./storage
'
import
{
initLocalStorage
}
from
'
./storage
'
import
{
initDatapod
,
initRpc
,
initSquid
,
initp2p
}
from
'
./network
'
import
{
initDatapod
,
initRpc
,
initSquid
,
initp2p
}
from
'
./network
'
import
{
ApolloClients
}
from
'
@vue/apollo-composable
'
import
{
ApolloClients
}
from
'
@vue/apollo-composable
'
...
@@ -12,9 +11,6 @@ import { ApolloClients } from '@vue/apollo-composable'
...
@@ -12,9 +11,6 @@ import { ApolloClients } from '@vue/apollo-composable'
initLocalStorage
()
initLocalStorage
()
initStateFromStorage
()
initStateFromStorage
()
// ask browser extension for web3 support
web3Enable
(
'
duniter-vue
'
)
// ===== APP =====
// ===== APP =====
const
app
=
createApp
(
App
)
const
app
=
createApp
(
App
)
...
@@ -32,3 +28,7 @@ Promise.all([initRpc(), initSquid(), initDatapod()]).then(([api, apolloSquid, ap
...
@@ -32,3 +28,7 @@ Promise.all([initRpc(), initSquid(), initDatapod()]).then(([api, apolloSquid, ap
// also provide datapod ipfs stack
// also provide datapod ipfs stack
initp2p
().
then
((
p2p
)
=>
app
.
provide
(
'
p2p
'
,
p2p
))
initp2p
().
then
((
p2p
)
=>
app
.
provide
(
'
p2p
'
,
p2p
))
// === dynamic imports ===
// ask browser extension for web3 support
import
(
'
@polkadot/extension-dapp
'
).
then
((
web3
)
=>
web3
.
web3Enable
(
'
duniter-vue
'
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment