-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from AElfProject/feature/update-aelf-bridge
Feature/update aelf bridge
- Loading branch information
Showing
15 changed files
with
86 additions
and
27 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
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
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
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
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
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,44 @@ | ||
export interface Storage { | ||
getItem(key: string, ...args: Array<any>): any; | ||
setItem(key: string, value: any, ...args: Array<any>): any; | ||
removeItem(key: string, ...args: Array<any>): any; | ||
clear(): void; | ||
} | ||
|
||
const localStorageMock = (function () { | ||
let store: { [key: string]: string } = {}; | ||
|
||
return { | ||
getItem: function (key: string): string | null { | ||
return store[key] || null; | ||
}, | ||
setItem: function (key: string, value: string) { | ||
store[key] = value.toString(); | ||
}, | ||
removeItem: function (key: string) { | ||
delete store[key]; | ||
}, | ||
clear: function () { | ||
store = {}; | ||
}, | ||
}; | ||
})(); | ||
|
||
// let enhancedLocalStorage: Storage = {} as Storage; | ||
// if (typeof window !== 'undefined') { | ||
// enhancedLocalStorage = window.localStorage; | ||
// } else { | ||
// import('node-localstorage').then(({ LocalStorage }) => { | ||
// enhancedLocalStorage = new LocalStorage('./scratch'); | ||
// }); | ||
// } | ||
// export { enhancedLocalStorage }; | ||
|
||
let enhancedLocalStorage: Storage; | ||
if (typeof window !== 'undefined') { | ||
console.log('enhancedLocalStorage in window'); | ||
enhancedLocalStorage = window.localStorage; | ||
} else { | ||
enhancedLocalStorage = localStorageMock; | ||
} | ||
export { enhancedLocalStorage, localStorageMock }; |
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
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
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
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
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
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
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
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
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