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'
3
3
4
4
import { pluginFactories } from '../plugins/ramps/allRampPlugins'
5
5
import type { RampPlugin } from '../plugins/ramps/rampPluginTypes'
6
+ import { createStore } from '../plugins/ramps/utils/createStore'
6
7
7
8
interface UseRampPluginsOptions {
8
9
account : EdgeAccount
@@ -25,9 +26,13 @@ export function useRampPlugins({ account }: UseRampPluginsOptions) {
25
26
26
27
for ( const [ pluginId , factory ] of Object . entries ( pluginFactories ) ) {
27
28
try {
29
+ // Create store with pluginId as storeId
30
+ const store = createStore ( pluginId , account . dataStore )
31
+
28
32
// Create a minimal config for the plugin
29
33
const config = {
30
34
initOptions : { } ,
35
+ store,
31
36
account,
32
37
navigation : null as any , // Navigation will be provided by components that need it
33
38
onLogEvent : ( ) => { } ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
8
8
FiatPluginRegionCode ,
9
9
FiatPluginUtils
10
10
} from '../gui/fiatPluginTypes'
11
+ import type { RampPluginStore } from './utils/createStore'
11
12
12
13
// Token support type (kept for internal plugin use if needed)
13
14
export interface ProviderToken {
@@ -91,10 +92,7 @@ export interface RampInfo {
91
92
92
93
export interface RampPluginConfig {
93
94
initOptions ?: unknown
94
- store ?: {
95
- getItem : ( key : string ) => Promise < string >
96
- setItem : ( key : string , value : string ) => Promise < void >
97
- }
95
+ store : RampPluginStore
98
96
makeUuid ?: ( ) => Promise < string >
99
97
100
98
// 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