File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as React from 'react'
33
44import { pluginFactories } from '../plugins/ramps/allRampPlugins'
55import type { RampPlugin } from '../plugins/ramps/rampPluginTypes'
6+ import { createStore } from '../plugins/ramps/utils/createStore'
67
78interface UseRampPluginsOptions {
89 account : EdgeAccount
@@ -25,9 +26,13 @@ export function useRampPlugins({ account }: UseRampPluginsOptions) {
2526
2627 for ( const [ pluginId , factory ] of Object . entries ( pluginFactories ) ) {
2728 try {
29+ // Create store with pluginId as storeId
30+ const store = createStore ( pluginId , account . dataStore )
31+
2832 // Create a minimal config for the plugin
2933 const config = {
3034 initOptions : { } ,
35+ store,
3136 account,
3237 navigation : null as any , // Navigation will be provided by components that need it
3338 onLogEvent : ( ) => { } ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
88 FiatPluginRegionCode ,
99 FiatPluginUtils
1010} from '../gui/fiatPluginTypes'
11+ import type { RampPluginStore } from './utils/createStore'
1112
1213// Token support type (kept for internal plugin use if needed)
1314export interface ProviderToken {
@@ -91,10 +92,7 @@ export interface RampInfo {
9192
9293export interface RampPluginConfig {
9394 initOptions ?: unknown
94- store ?: {
95- getItem : ( key : string ) => Promise < string >
96- setItem : ( key : string , value : string ) => Promise < void >
97- }
95+ store : RampPluginStore
9896 makeUuid ?: ( ) => Promise < string >
9997
10098 // Dependencies for plugin operations
Original file line number Diff line number Diff line change 1+ import type { EdgeDataStore } from 'edge-core-js'
2+
3+ export interface RampPluginStore {
4+ readonly deleteItem : ( itemId : string ) => Promise < void >
5+ readonly listItemIds : ( ) => Promise < string [ ] >
6+ readonly getItem : ( itemId : string ) => Promise < string >
7+ readonly setItem : ( itemId : string , value : string ) => Promise < void >
8+ }
9+
10+ export const createStore = (
11+ storeId : string ,
12+ store : EdgeDataStore
13+ ) : RampPluginStore => {
14+ return {
15+ deleteItem : async ( itemId : string ) => {
16+ await store . deleteItem ( storeId , itemId )
17+ } ,
18+ listItemIds : async ( ) => await store . listItemIds ( storeId ) ,
19+ getItem : async ( itemId : string ) => await store . getItem ( storeId , itemId ) ,
20+ setItem : async ( itemId : string , value : string ) => {
21+ await store . setItem ( storeId , itemId , value )
22+ }
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments