Methods
The following shows the methods provided by the Wepin React SDK.
openWidget
openWidget
The openWidget
method shows the widget window.
Returned Value
<void>
closeWidget
closeWidget
The closeWidget
method closes the widget window.
Returned value
<void>
getAccounts
getAccounts
The getAccounts
method returns user accounts of the networks available in the app. getAccounts
is a method available after widget login.
Parameters
networks
: Array of string It is thenetwork
of the address you want to receive. If nonetwork
is specified, all addresses available in the app are returned. The names of blockchain networks that can be put intonetworks
can be found on the following page.
Returned Value
Promise
<Array>If a user is logged in, it returns a
Promise
object resolved with array ofaccount
of networks.Type of
account
is assigned at@wepin/types
asIAccount
account
IAccountaddress
Stringnetwork
Stringcontract
String optionaltoken contract address. (
@wepin/types
(from version0.0.12
and above) is defined inIAccount
.)
If
networks
aren't passed, it returns aPromise
object resolved with array ofaccount
of all networks.Example
Promise
<void>If user is not logged in, it returns
Promise
.
getStatus
(Supported from version 0.0.6-alpha and above.)
getStatus
(Supported from version 0.0.6-alpha and above.)The getStatus()
method returns lifecycle of wepin
.
Returned Value
<WepinLifeCycle>
The
WepinLifeCycle
is defined at@wepin/types
as (Supports version 0.0.7 and above.)not_initialized
: ifwepin
is not initializedinitializing
: ifwepin
is initializinginitialized
: ifwepin
is initializedbefore_login
: ifwepin
is initialized but the user is not logged inlogin
: if the user is logged in
login
(Supported from version 0.0.6-alpha and above.)
login
(Supported from version 0.0.6-alpha and above.)The login()
method returns information of the logged-in user. If a user is not logged in, Wepin widget will show login page.
Parameters
email
<String> optionalThis parameter is used when attempting to log in with a specific email address.
Returned Value
Promise
<IWepinUser>
Type of
IWepinUser
is defined in@wepin/types
(Supported from version0.0.8
and above.)status
String <'success'|'fail'>userInfo
Object (optional)userId
Stringemail
Stringprovider
String <'google'|'apple'|'email'|'naver'|'discord'|'external_token'>
Example
logout
(Supported from version 0.0.6-alpha and above.)
logout
(Supported from version 0.0.6-alpha and above.)The logout()
method performs a wepin
logout.
Returned Value
Promise
<void>
signUpWithEmailAndPassword
(Supported from version 0.0.9-alpha and above.)
signUpWithEmailAndPassword
(Supported from version 0.0.9-alpha and above.)It makes users sign up with Wepin using email and password.
Parameters
email
<String>User's Email Address
password
<String>User's Password
Returned Value
Promise
<boolean>
loginWithEmailAndPassword
(Supported from version 0.0.9-alpha and above.)
loginWithEmailAndPassword
(Supported from version 0.0.9-alpha and above.)It makes users login with Wepin using email and password.
Parameters
email
<String>User's Email Address
password
<String>User's Password
Returned Value
Promise
<IWepinUser>
Type of
IWepinUser
is defined in@wepin/types
(Supported from version0.0.8
and above.)status
String <'success'|'fail'>userInfo
Object (optional)userId
Stringemail
Stringprovider
<'email'>
Example
require/wepin-register
: If this exception occurs, you should execute thewepin.register(pin)
method.
register
(Supported from version 0.0.9-alpha and above.)
register
(Supported from version 0.0.9-alpha and above.)The Wepin service creates a wallet and registers the user's PIN. After the sign-up and login processes are successfully completed, the Wepin service performs the registration process.
Parameters
pin <String>
The user's wallet PIN number
Returned Value
Promise
<boolean>
If the registration process is successfully completed, it returns true.
After a successful registration, you should perform the login process once again.
getBalance
(Supported from version 0.0.9-alpha and above.)
getBalance
(Supported from version 0.0.9-alpha and above.)It returns the account balance information. This action can only be performed after logging in.
Parameters
account
<IAccount
>Type of
IAccount
is defined in@wepin/types
Returned value
Promise
<IAccountBalance
>Type of
IAccountBalance
andITokenBalance
is defined in@wepin/types
(Support from version0.0.8
)symbol
<string> - symbol of accountbalance
<string> - balance of accounttokens
<Array<ITokenBalance
>> - token balance information for accountname
<string> - token namecontract
<string> - token contract addresssymbol
<string> - token symbolbalance
<string> - token balance
Example
loginWithExternalToken
(Supported from version 0.0.19-alpha and above.)
loginWithExternalToken
(Supported from version 0.0.19-alpha and above.)It logs in to the Wepin with external token(e.g., idToken
). The loginWithExternalToken()
method returns information of the logged-in user.
If the user is not registered on Wepin, and the withUI
value is set to true, the registration page will be displayed in the widget. However, if the withUI
value is set to false or not defined, a require/wepin-register
exception will be triggered.
Parameters
token
<string>External token value to be used for login (e.g., idToken).
sign
<string>Signature value for the token provided as the first parameter. (Signature Generation Methods)
The key for signing can be obtained from Wepin Workspace. In the Development Tools menu, click Get your authentication key on the Login tab to retrieve the authentication key.
withUI
<boolean> optionalIndicates whether to display the Wepin widget screen if registration is required.
Returned Value
Promise
<IWepinUser>Type of
IWepinUser
is defined in@wepin/types
(Supports version0.0.7
and above.)status
<'success'|'fail'>userInfo
<object> optionaluserId
<string>email
<string>provider
<'external_token'>
Example
require/wepin-register
: If this error occurs, you have to perform thewepin.register(pin)
method.
send
(Supported from version 0.0.20-alpha
and above.)
send
(Supported from version 0.0.20-alpha
and above.)The "send" is performed using the widget, and returns the ID information of the "send" transaction. It can only be used after logging into Wepin.
Parameters
account
<IAccount
> - User emailType of
IAccount
is defined in@wepin/types
options
<ISendOptions
> - The information required for the "send".The
ISendOptions
is defined at@wepin/types
.toAddress
<string
> - The address to send tokensamount
<string
> - The amount of tokens to send (in network units)
Example
Return Value
Promise
<string
>txID (Transaction ID) of the "send" transaction
Example
Exceptions
The error message types of the admin method are as follows.
invalid/email-format
invalid email format
invalid/password-format
invalid password format (A minimum of 8 characters consisting of letters, numbers and special characters. )
invalid/pin-format
invalid PIN format (6-8 digit number) (*Do not use the same number more than four times when registering)
invalid/firebase-token
invalid firebase token
invalid/wepin-api-key
invalid wepin api key
invalid/account
invalid account
invalid/email-domain
invalid email domain
invalid/to-address
invalid to address
auth/existed-email
existed email
auth/too-many-requests
too mandy firebase requests
auth/wrong-password
wrong password
auth/expired-token
expired login session
auth/unknown/${string}
unknown auth error
fail/send-email
failed to sent validation email
fail/reset-password
failed to set password
fail/email-verified
failed to verify email
fail/wepin-login
login wepin failed
fail/wepin-register
failed to register with wepin
fail/get-balance
failed to get balance
fail/check-email
failed to check email
fail/requireFee
insufficient fee
fail/requireNetworkFee
insufficient network fee(only token transaction request)
require/email-verified
email verification required
require/signup
wepin sign-up required
require/wepin-register
wepin registration required
require/login
wepin login required
unknown/${string}
unknown error
Last updated