-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hbs store and move hbs functionality from holo store (#92)
* add hbs store and move hbs functionality from holo store * rename useHBSStore to useHbsStore
- Loading branch information
Showing
2 changed files
with
42 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { defineStore } from 'pinia' | ||
import { fetchAgentKycLevel, registrationFetchJurisdictions } from '../services/hbs' | ||
|
||
const makeUseHbsStore = ({ useHoloStore }) => { | ||
return defineStore('hbs', { | ||
state: () => ({ | ||
kycLevel: null, | ||
jurisdictions: [] | ||
}), | ||
getters: { | ||
agentKycLevel: state => state.kycLevel, | ||
hbsJurisdictions: state => state.jurisdictions | ||
}, | ||
actions: { | ||
async loadAgentKycLevel(environment, hbsServicePort) { | ||
const payload = { | ||
"email": useHoloStore().agentEmail, | ||
"timestamp": Date.now() - (30 * 1000), // Subtract 30 sec to prevent "future" timestamp error from API | ||
"pubKey": useHoloStore().agentId | ||
} | ||
|
||
const { _, signature } = await await useHoloStore().signPayload(payload) | ||
const kycLevel = await fetchAgentKycLevel(payload, signature, environment, hbsServicePort) | ||
this.kycLevel = kycLevel | ||
return kycLevel | ||
}, | ||
async loadJurisdictions(environment, hbsServicePort) { | ||
try { | ||
registrationFetchJurisdictions(environment, hbsServicePort).then((jurisdictions) => { | ||
this.jurisdictions = jurisdictions.data | ||
}) | ||
} catch (e) { | ||
console.error(`Error fetching jurisdictions: ${e}`) | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
|
||
export default makeUseHbsStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters