Skip to content

Commit

Permalink
Add message for signing in web3 & documentation for it
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed May 10, 2022
1 parent 119683c commit d5958cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ You will call this on the page where you allow your users to connect to other se

`options` is expecting configuration object. Most often that is going to be: `{ loginStyle: 'popup' }`

##### `freedombase:web3-login`
The `options` object accepts `linkMessage` key where you can set message for signature.

### Server side
#### Accounts.unlinkService(userId, serviceName)
Given the `userId` and the name of the service (`serviceName`) as it is named in the user document (most often lower case name of the service).
Expand Down
9 changes: 8 additions & 1 deletion community-services/web3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Meteor } from 'meteor/meteor'

/**
*
* @param options.linkMessage { String } Message to display on wallet confirmation
* @param callback { Function }
*/
Meteor.linkWithWeb3 = function (options, callback) {
if (!Meteor.userId()) {
throw new Meteor.Error(
Expand All @@ -22,12 +27,14 @@ Meteor.linkWithWeb3 = function (options, callback) {
// Since the flow for Web3 is different we are using a custom flow here.
const credentialRequestCompleteCallback = (error, address) => {
if (error.error === 403) {
Meteor.call('bozhao:linkAccountsWeb3', address, callback)
Meteor.call('bozhao:linkAccountsWeb3', address)
} else {
throw error
}
}
Package['freedombase:web3-login'].loginWithWeb3(
options?.linkMessage ||
`Please verify that you want to link your wallet to ${Meteor.absoluteUrl()}.`,
credentialRequestCompleteCallback
)
}

0 comments on commit d5958cb

Please sign in to comment.