This repository has been archived by the owner on Sep 9, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
7,595 additions
and
185 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"root": ".", | ||
"port": 8083 | ||
} | ||
} |
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,4 @@ | ||
|
||
# 3box Plugin | ||
|
||
**NOTE:** This plugin is currently not supported and will be updated in the future. |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,50 @@ | ||
const Box = require('3box/dist/3box.min') | ||
|
||
// const plug = require('./src/3box-example') | ||
// const plug = require('./src/example1') | ||
const plug = require('./src/3box-example-basic') | ||
function update3Box ({ type, box }, newState) { | ||
console.log('3boxbasic update3Box type:', type); | ||
console.log('3boxbasic update3Box newState:', newState); | ||
return box.private.set(type, JSON.stringify(newState)); | ||
} | ||
|
||
function registerUpdates (box) { | ||
const updatePreferences = update3Box.bind(this, { type: 'preferences', box }); | ||
console.log('3boxbasic registerUpdates:', `updatePreferences:${updatePreferences} box:${box}`); | ||
pluginAPIs.subscribeToPreferencesControllerChanges(updatePreferences); | ||
} | ||
|
||
function restoreFrom3Box (box, address) { | ||
box.private.get('preferences') | ||
.then(backedUpPreferences => { | ||
console.log('backedUpPreferences', backedUpPreferences) | ||
backedUpPreferences && pluginAPIs.updatePreferencesControllerState(JSON.parse(backedUpPreferences)); | ||
registerUpdates(box); | ||
console.log('3boxbasic restoreFrom3Box:', `address:${address} box:${box} backedUpPreferences:${backedUpPreferences}`); | ||
pluginAPIs.updatePluginState({ syncDone3Box: true, threeBoxAddress: address }); | ||
}) | ||
} | ||
|
||
function new3Box (address) { | ||
pluginAPIs.updatePluginState({ syncDone3Box: false }); | ||
console.log('3boxbasic new3Box 1:', `address:${address}`); | ||
pluginAPIs.generateSignature('This app wants to view and update your 3Box profile.', address) | ||
.then(signature => pluginAPIs.Box.openBox( | ||
address, | ||
ethereumProvider, | ||
{ | ||
walletProvidedSignature: signature | ||
} | ||
)) | ||
.then(box => { | ||
box.onSyncDone(() => { | ||
restoreFrom3Box(box, address); | ||
console.log('3boxbasic new3Box 2:', `address:${address} box:${box}`); | ||
pluginAPIs.updatePluginState({ syncDone3Box: true, threeBoxAddress: address }); | ||
}) | ||
}) | ||
} | ||
|
||
function metaPlugin () { | ||
new3Box(pluginData.address) | ||
} | ||
|
||
metaPlugin() |
Oops, something went wrong.