Skip to content

Commit

Permalink
added functionality for cache warmup
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 committed Jul 18, 2024
1 parent 23661aa commit 2845d67
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 4 deletions.
56 changes: 54 additions & 2 deletions app/container-imp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BaseLogger } from '@credo-ts/core'
import {
Container,
TOKENS,
Expand All @@ -14,6 +15,7 @@ import {
Screens,
} from '@hyperledger/aries-bifold-core'
import { RemoteLogger, RemoteLoggerOptions } from '@hyperledger/aries-bifold-remote-logs'
import { useProofRequestTemplates } from '@hyperledger/aries-bifold-verifier'
import { BrandingOverlayType, RemoteOCABundleResolver } from '@hyperledger/aries-oca/build/legacy'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { NavigationProp } from '@react-navigation/native'
Expand All @@ -32,8 +34,6 @@ import Developer from './src/screens/Developer'
import Preface from './src/screens/Preface'
import Terms, { TermsVersion } from './src/screens/Terms'
import { BCLocalStorageKeys, BCState, DismissPersonCredentialOffer, IASEnvironment, initialState } from './src/store'
import { useProofRequestTemplates } from '@hyperledger/aries-bifold-verifier'
import { BaseLogger } from '@credo-ts/core'

export class AppContainer implements Container {
private _container: DependencyContainer
Expand Down Expand Up @@ -75,6 +75,58 @@ export class AppContainer implements Container {
},
},
])
this._container.registerInstance(TOKENS.CACHE_CRED_DEFS, [
// { did: "4WW6792ksq62UroZyfd6nQ", id: "4WW6792ksq62UroZyfd6nQ:3:CL:1098:SellingItRight" },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:3:CL:224665:Selling It Right' },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:3:CL:400095:SellingItRight' },
{ did: 'Ttmj1pEotg8FbKZZD81S7i', id: 'Ttmj1pEotg8FbKZZD81S7i:3:CL:184:SellingItRight' },
// { did: "4WW6792ksq62UroZyfd6nQ", id: "4WW6792ksq62UroZyfd6nQ:3:CL:1098:ServingItRight" },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:3:CL:224665:Serving It Right' },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:3:CL:400095:ServingItRight' },
{ did: 'Ttmj1pEotg8FbKZZD81S7i', id: 'Ttmj1pEotg8FbKZZD81S7i:3:CL:184:ServingItRight' },
// { did: "4WW6792ksq62UroZyfd6nQ", id: "4WW6792ksq62UroZyfd6nQ:3:CL:1098:SpecialEventServer" },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:3:CL:224665:Special Event Server' },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:3:CL:400095:SpecialEventServer' },
{ did: 'Ttmj1pEotg8FbKZZD81S7i', id: 'Ttmj1pEotg8FbKZZD81S7i:3:CL:184:SpecialEventServer' },

{ did: '4xE68b6S5VRFrKMMG1U95M', id: '4xE68b6S5VRFrKMMG1U95M:3:CL:59232:default' },
{ did: 'L6ASjmDDbDH7yPL1t2yFj9', id: 'L6ASjmDDbDH7yPL1t2yFj9:3:CL:7162:member_card' },
{ did: 'M6dhuFj5UwbhWkSLmvYSPc', id: 'M6dhuFj5UwbhWkSLmvYSPc:3:CL:834686:member_card' },
{ did: 'QEquAHkM35w4XVT3Ku5yat', id: 'QEquAHkM35w4XVT3Ku5yat:3:CL:834674:member_card' },
{ did: 'AuJrigKQGRLJajKAebTgWu', id: 'AuJrigKQGRLJajKAebTgWu:3:CL:209526:default' },

{ did: 'RGjWbW1eycP7FrMf4QJvX8', id: 'RGjWbW1eycP7FrMf4QJvX8:3:CL:13:Person' },
{ did: 'L6ASjmDDbDH7yPL1t2yFj9', id: 'L6ASjmDDbDH7yPL1t2yFj9:3:CL:257:Person' },
{ did: 'M6dhuFj5UwbhWkSLmvYSPc', id: 'M6dhuFj5UwbhWkSLmvYSPc:3:CL:834685:Person' },
{ did: 'QEquAHkM35w4XVT3Ku5yat', id: 'QEquAHkM35w4XVT3Ku5yat:3:CL:834664:Person' },
{ did: 'KCxVC8GkKywjhWJnUfCmkW', id: 'KCxVC8GkKywjhWJnUfCmkW:3:CL:20:PersonQA' },
{ did: '7xjfawcnyTUcduWVysLww5', id: '7xjfawcnyTUcduWVysLww5:3:CL:28075:PersonSIT' },
{ did: 'XpgeQa93eZvGSZBZef3PHn', id: 'XpgeQa93eZvGSZBZef3PHn:3:CL:28075:PersonDEV' },

{ did: 'AcZpBDz3oxmKrpcuPcdKai', id: 'AcZpBDz3oxmKrpcuPcdKai:3:CL:350:default' },
{ did: 'K9igebFysBL6jcBwR8bKuN', id: 'K9igebFysBL6jcBwR8bKuN:3:CL:61:default' },
])
this._container.registerInstance(TOKENS.CACHE_SCHEMAS, [
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:2:LCRB:1.1.1' },
{ did: 'TeT8SJGHruVL9up3Erp4o', id: 'TeT8SJGHruVL9up3Erp4o:2:LCRBSirSes:1.0.0' },
{ did: 'Ttmj1pEotg8FbKZZD81S7i', id: 'Ttmj1pEotg8FbKZZD81S7i:2:LCRBSirSes:1.0.0' },

{ did: '4xE68b6S5VRFrKMMG1U95M', id: '4xE68b6S5VRFrKMMG1U95M:2:Member Card:1.5.1' },
{ did: 'L6ASjmDDbDH7yPL1t2yFj9', id: 'L6ASjmDDbDH7yPL1t2yFj9:2:member_card:1.53' },
{ did: 'M6dhuFj5UwbhWkSLmvYSPc', id: 'M6dhuFj5UwbhWkSLmvYSPc:2:member_card:1.54' },
{ did: 'QEquAHkM35w4XVT3Ku5yat', id: 'QEquAHkM35w4XVT3Ku5yat:2:member_card:1.54' },
{ did: 'AuJrigKQGRLJajKAebTgWu', id: 'AuJrigKQGRLJajKAebTgWu:2:Member Card:1.5.1' },

{ did: 'RGjWbW1eycP7FrMf4QJvX8', id: 'RGjWbW1eycP7FrMf4QJvX8:2:Person:1.0' },
{ did: 'L6ASjmDDbDH7yPL1t2yFj9', id: 'L6ASjmDDbDH7yPL1t2yFj9:2:Person:1.2' },
{ did: 'M6dhuFj5UwbhWkSLmvYSPc', id: 'M6dhuFj5UwbhWkSLmvYSPc:2:Person:1.3' },
{ did: 'QEquAHkM35w4XVT3Ku5yat', id: 'QEquAHkM35w4XVT3Ku5yat:2:Person:1.3' },
{ did: 'KCxVC8GkKywjhWJnUfCmkW', id: 'KCxVC8GkKywjhWJnUfCmkW:2:Person:1.0' },
{ did: 'XpgeQa93eZvGSZBZef3PHn', id: 'XpgeQa93eZvGSZBZef3PHn:2:Person:1.0' },

{ did: 'AcZpBDz3oxmKrpcuPcdKai', id: 'AcZpBDz3oxmKrpcuPcdKai:2:Digital Business Card:1.0.0' },
{ did: 'K9igebFysBL6jcBwR8bKuN', id: 'K9igebFysBL6jcBwR8bKuN:2:Digital Business Card:1.0.0' },
])
this._container.registerInstance(TOKENS.SCREEN_TERMS, { screen: Terms, version: TermsVersion })
this._container.registerInstance(TOKENS.SCREEN_DEVELOPER, Developer)

Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@hyperledger/aries-oca": "1.0.0-alpha.274",
"@hyperledger/aries-react-native-attestation": "1.0.0-alpha.274",
"@hyperledger/indy-vdr-react-native": "0.2.2",
"@hyperledger/indy-vdr-shared": "0.2.2",
"@react-native-async-storage/async-storage": "1.15.11",
"@react-native-community/masked-view": "0.1.11",
"@react-native-community/netinfo": "9.3.7",
Expand Down
1 change: 1 addition & 0 deletions app/src/localization/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const translation = {
"GettingCredentials": "Getting wallet credentials...",
"RegisteringTransports": "Registering transports...",
"InitializingAgent": "Initializing agent...",
"CacheWarmup": "Warming up cache...",
"ConnectingLedgers": "Connecting to ledgers...",
"SettingAgent": "Setting agent...",
"Finishing": "Finishing..."
Expand Down
1 change: 1 addition & 0 deletions app/src/localization/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const translation = {
"GettingCredentials": "Récupération des identifiants du portefeuille...",
"RegisteringTransports": "Enregistrement des transports...",
"InitializingAgent": "Initialisation de l'agent...",
"CacheWarmup": "Warming up cache... (FR)",
"ConnectingLedgers": "Connexion aux registres...",
"SettingAgent": "Paramétrage de l'agent...",
"Finishing": "Finalisation...",
Expand Down
1 change: 1 addition & 0 deletions app/src/localization/pt-br/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const translation = {
"GettingCredentials": "Getting wallet credentials... (PT-BR)",
"RegisteringTransports": "Registering transports... (PT-BR)",
"InitializingAgent": "Initializing agent... (PT-BR)",
"CacheWarmup": "Warming up cache... (PT-BR)",
"ConnectingLedgers": "Connecting to ledgers... (PT-BR)",
"SettingAgent": "Setting agent... (PT-BR)",
"Finishing": "Finishing... (PT-BR)",
Expand Down
22 changes: 20 additions & 2 deletions app/src/screens/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
useContainer,
} from '@hyperledger/aries-bifold-core'
import { RemoteOCABundleResolver } from '@hyperledger/aries-oca/build/legacy'
import { GetCredentialDefinitionRequest, GetSchemaRequest } from '@hyperledger/indy-vdr-shared'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { CommonActions, useNavigation } from '@react-navigation/native'
import moment from 'moment'
Expand Down Expand Up @@ -142,6 +143,7 @@ const Splash = () => {
t('Init.GettingCredentials'),
t('Init.RegisteringTransports'),
t('Init.InitializingAgent'),
t('Init.CacheWarmup'),
t('Init.ConnectingLedgers'),
t('Init.SettingAgent'),
t('Init.Finishing'),
Expand Down Expand Up @@ -410,15 +412,31 @@ const Splash = () => {
}

setStep(6)
await createLinkSecretIfRequired(newAgent)
const credDefs = container.resolve(TOKENS.CACHE_CRED_DEFS)
const schemas = container.resolve(TOKENS.CACHE_SCHEMAS)

credDefs.forEach(async ({ did, id }) => {
const pool = await poolService.getPoolForDid(newAgent.context, did)
const credDefRequest = new GetCredentialDefinitionRequest({ credentialDefinitionId: id })
await pool.pool.submitRequest(credDefRequest)
})

schemas.forEach(async ({ did, id }) => {
const pool = await poolService.getPoolForDid(newAgent.context, did)
const schemaRequest = new GetSchemaRequest({ schemaId: id })
await pool.pool.submitRequest(schemaRequest)
})

setStep(7)
await createLinkSecretIfRequired(newAgent)

setStep(8)
setAgent(newAgent)
if (store.preferences.usePushNotifications) {
activate(newAgent)
}

setStep(8)
setStep(9)
navigation.dispatch(
CommonActions.reset({
index: 0,
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8968,6 +8968,7 @@ __metadata:
"@hyperledger/aries-oca": "npm:1.0.0-alpha.274"
"@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.274"
"@hyperledger/indy-vdr-react-native": "npm:0.2.2"
"@hyperledger/indy-vdr-shared": "npm:0.2.2"
"@react-native-async-storage/async-storage": "npm:1.15.11"
"@react-native-community/masked-view": "npm:0.1.11"
"@react-native-community/netinfo": "npm:9.3.7"
Expand Down

0 comments on commit 2845d67

Please sign in to comment.