메서드
Wepin React Native Widget SDK에서 제공하는 메서드입니다.
getStatus
await wepinWidget.getStatus();
WepinWidgetSDK
의 Lifecycle 상태 값을 반환합니다.
Parameters
None
Return value
Promise<WepinLifeCycle>
'not_initialized':
WepinSDK
이 초기화되지 않음'initializing' :
WepinSDK
초기화 진행 중'initialized':
WepinSDK
초기화 완료'before_login':
WepinSDK
은 초기화되었으나 사용자는 로그인 되지 않음'login': 사용자가 로그인 되었고 위핀에도 가입되어있음
'login_before_register': 사용자가 로그인하였으나 위핀에 가입되지 않음
Example
const status = await wepinWidget.getStatus();
login
login
변수는 다양한 인증 방법을 포함한 위핀 로그인 라이브러리로, 사용자가 여러 방식으로 로그인할 수 있도록 합니다. 이메일 및 비밀번호 로그인, OAuth 프로바이더 로그인, ID Token 또는 Access Token을 사용한 로그인 등을 지원합니다. 각 메서드에 대한 자세한 정보는 공식 라이브러리 문서 Login Library 가이드에서 확인할 수 있습니다.
Available Methods
loginWithOauthProvider
signUpWithEmailAndPassword
loginWithEmailAndPassword
loginWithIdToken
loginWithAccessToken
getRefreshFirebaseToken
loginWepin
getCurrentWepinUser
logout
getSignForLogin
이 메서드들은 다양한 로그인 시나리오를 지원하며, 필요에 맞는 적절한 방법을 선택할 수 있습니다.
Example
// Login using an OAuth provider
const oauthResult = await wepinWidget.login.loginWithOauthProvider({
provider: 'google',
clientId: 'your-client-id',
});
// Sign up and log in using email and password
const signUpResult = await wepinWidget.login.signUpWithEmailAndPassword(
'[email protected]',
'password123'
);
// Log in using an ID token
const idTokenResult = await wepinWidget.login.loginWithIdToken({
token: 'your-id-token',
sign: 'your-sign',
});
// Log in to Wepin
const wepinLoginResult = await wepinWidget.login.loginWepin(idTokenResult);
// Get the currently logged-in user
const currentUser = await wepinWidget.login.getCurrentWepinUser();
// Logout
await wepinWidget.login.logout();
loginWithUI
loginWithUI()
메서드는 위젯을 사용하여 로그인하는 기능을 제공하며, 로그인된 사용자의 정보를 반환합니다. 사용자가 이미 로그인되어 있는 경우, 위젯을 표시하지 않고 로그인된 사용자의 정보를 바로 반환합니다. 위젯 없이 로그인을 수행하려면, login
변수의 loginWepin()
메서드를 대신 사용해야 합니다.
OAuth 로그인 기능(예: loginWithUI)을 사용하려면 OAuth 로그인 프로바이더를 설정해야 합니다. 이를 위해 먼저 위핀 워크스페이스에 OAuth 로그인 프로바이더 정보를 등록해야 합니다. OAuth 프로바이더 설정에 대한 자세한 내용은 소셜 로그인 인증 프로바이더 문서를 참고하세요.
Parameters
providers
<{provider: string, clientId: string}[]> - 위젯을 구성할 로그인 프로바이더들의 목록입니다. 빈 목록이 제공되면 이메일 로그인 기능만 사용할 수 있습니다.provider
<string> -OAuth 로그인 프로바이더(예: 'google', 'naver', 'discord', 'apple')clientId
<string> - OAuth 로그인 프로바이더의 클라이언트 ID입니다.
email
<string> optional - 위젯에서 로그인할 때 지정된 이메일 주소로 로그인할 수 있도록 합니다.
Return value
Promise<WepinUser>
status
<'success'|'fail'>userInfo
<object> optionaluserId
<string> - Wepin 사용자 IDemail
<string> - 위핀에 로그인된 사용자의 이메일 주소provider
- 로그인 프로바이더 <'google'|'apple'|'naver'|'discord'|'email'|'external_token'>use2FA
<boolean> - 사용자 지갑에 2FA가 활성화되어 있는지 여부
userStatus
: <object> - 사용자의 로그인 상태loginStatus
: <'complete' | 'pinRequired' | 'registerRequired'> - 사용자의 loginStatus 값이 'complete'가 아닌 경우, 위핀에 register 해야 합니다.pinRequired
optional : 사용자 PIN 번호 필요 여부
walletId
<string> optional : 사용자의 지갑 IDtoken
: <object> - 사용자의 Wepin 토큰 정보accessToken
: <string> - Wepin Access token.refreshToken
: <string> - Wepin Refresh token.
Exception
Example
// google, apple, discord, naver login
const loginProviders = [
{ provider: 'google', clientId: 'google-client-id' },
{ provider: 'apple', clientId: 'apple-client-id' },
{ provider: 'discord', clientId: 'discord-client-id' },
{ provider: 'naver', clientId: 'naver-client-id' },
];
const userInfo = await wepinWidget.loginWithUI(loginProviders);
// only email login
const userInfo = await wepinWidget.loginWithUI([]);
// with specified email address
const userInfo = await wepinWidget.loginWithUI([], '[email protected]');
response
{
"status": "success",
"userInfo": {
"userId": "120349034824234234",
"email": "[email protected]",
"provider": "google",
"use2FA": true
},
"userStatus": {
"loginStatus": "complete",
"pinRequired": false
},
"walletId": "abcdsfsf123",
"token": {
"accessToken": "",
"refreshToken": ""
}
}
openWidget
위젯 창을 열어줍니다. 사용자가 로그인되어 있지 않으면 위젯 창이 열리지 않으므로, openWidget
을 호출하기 전에 반드시 사용자가 위핀에 로그인되어 있어야 합니다. 로그인하려면 loginWithUI
매서드 또는 login
변수의 loginWepin
메서드를 사용해야 합니다.
Parameters
None
Return value
Promise <boolean>
Example
await wepinWidget.openWidget();
closeWidget
위젯 창을 닫습니다. 창을 닫아도 로그아웃되지 않습니다.
Parameters
None
Return value
Promise <boolean>
Example
await wepinWidget.closeWidget();
register
await wepinSDK.register(BuildContext context)
사용자를 위에 등록합니다. 가입 및 로그인 후 위핀 위젯의 등록 페이지가 열리며, 위핀 서비스에 등록(지갑 생성 및 계정 생성)을 진행합니다. 이 기능은 WepinSDK
의 WepinLifeCycle
이 loginBeforeRegister
상태일 때만 사용할 수 있습니다. loginWithUI
매서드 또는 login
변수의 loginWepin
메서드를 호출한 후, userStatus
의 loginStatus
값이 'complete'가 아니면 이 메서드를 호출해야 합니다.
Parameters
None
Return value
Promise<WepinUser>
status
<'success'|'fail'>userInfo
<object> optionaluserId
<string> - Wepin 사용자 IDemail
<string> - 위핀에 로그인된 사용자의 이메일 주소provider
- 로그인 프로바이더 <'google'|'apple'|'naver'|'discord'|'email'|'external_token'>use2FA
<boolean> - 사용자 지갑에 2FA가 활성화되어 있는지 여부
userStatus
: <object> - 사용자의 로그인 상태loginStatus
: <'complete' | 'pinRequired' | 'registerRequired'> - 사용자의 loginStatus 값이 'complete'가 아닌 경우, 위핀에 register 해야 합니다.pinRequired
optional : 사용자 PIN 번호 필요 여부
walletId
<string> optional : 사용자의 지갑 IDtoken
: <object> - 사용자의 Wepin 토큰 정보accessToken
: <string> - Wepin Access token.refreshToken
: <string> - Wepin Refresh token.
Example
const userInfo = await wepinWidget.register();
getAccounts
앱에서 사용 가능한 사용자의 계정 정보(네트워크와 주소)를 반환합니다. 이 기능은 위핀에 로그인한 후에만 사용할 수 있습니다. 파라미터가 없는 경우에는 사용자의 모든 계정 정보가 반환됩니다.
Parameters
options
<object>networks
: <string[]> optional - 반환받고자 하는 계정의 네트워크입니다. 네트워크로 지원하는 블록체인 목록은 아래 지원 블록체인 페이지에서 확인 가능합니다.withEoa
: <boolean> optional - AA 계정이 있는 경우, EOA 계정도 포함하여 반환할지 여부를 지정합니다.
Return value
Promise <WepinAccount[]> - A promise that resolves to an array of the user's accounts.
address
<string> - 사용자 계정의 주소network
<string> - 사용자 계정의 네트워크 종류contract
<string> optional - 토큰 Contract 주소isAA
<boolean> optional - AA 계정인지 여부
Example
const result = await wepinWidget.getAccounts({
networks: ['ETHEREUM'],
withEoa: true,
});
response
[
{
"address": "0x0000001111112222223333334444445555556666",
"network": "ETHEREUM"
},
{
"address": "0x0000001111112222223333334444445555556666",
"network": "ETHEREUM",
"contract": "0x777777888888999999000000111111222222333333"
},
{
"address": "0x4444445555556666000000111111222222333333",
"network": "ETHEREUM",
"isAA": true
}
]
getBalance
정의 잔액(수량) 정보를 반환합니다. 이 기능은 위핀에 로그인한 후에만 사용할 수 있습니다.
accounts
파라미터가 없는 경우에는 사용자의 모든 계정의 잔액이 반환됩니다.
Parameters
accounts
<WepinAccount[]> optionalnetwork
<string> - 잔액을 조회할 사용자 계정의 네트워크 종류address
<string> - 잔액을 조회할 사용자 계정의 주소contract
<string> optional - 토큰 Contract 주소isAA
<boolean> optional - AA 계정인지 여부
Return value
Promise <WepinAccountBalanceInfo[]>
network
<string> - 사용자 계정의 네트워크 종류address
<string> - 사용자 계정의 주소symbol
<string> - 네트워크 심볼balance
<string> -보유하고 있는 네트워크 코인의 수량tokens
<WepinTokenBalanceInfo[]> - 계정의 토큰 잔액 정보symbol
<string> - 토큰 심볼balance
<string> - 보유하고 있는 토큰의 수량contract
<string> - 토큰 Contract 주소
Example
const result = await wepinWidget.getBalance([
{
address: '0x0000001111112222223333334444445555556666',
network: 'Ethereum',
},
]);
response
[
{
"network": "Ethereum",
"address": "0x0000001111112222223333334444445555556666",
"symbol": "ETH",
"balance": "1.1",
"tokens": [
{
"contract": "0x123...213",
"symbol": "TEST",
"balance": "10"
}
]
}
]
getNFTs
사용자의 NFT를 반환합니다. 이 기능은 위핀에 로그인한 후에만 사용할 수 있습니다.
networks
파라미터가 없는 경우에는 사용자의 모든 NFT 정보가 반환됩니다.
Parameters
options
<object>refresh
<boolean> - NFT 데이터를 새로 조회할지 여부networks
<string[]> optional - NFT를 필터링할 네트워크 이름 목록
Return value
Promise <WepinNFT[]> - A promise that resolves to an array of the user's NFTs.
account
<WepinAccount>address
<string> - 사용자 계정의 주소network
<string> - 사용자 계정의 네트워크 종류contract
<string> optional - 토큰의 Contract 주소isAA
<boolean> optional - AA 계정인지 여부
contract
<WepinNFTContract>name
<string> - NFT Contract 이름address
<string> - NFT Contract 주소scheme
<string> - NFT의 스킴description
<string> optional - NFT Contract의 설명network
<string> - NFT Contract과 연결된 네트워크externalLink
<string> optional - NFT Contract와 관련된 외부 링크imageUrl
<string> optional - NFT Contract와 관련된 이미지 URL
name
<string> - NFT의 이름description
<string> - NFT의 설명externalLink
<string> - NFT와 관련된 외부 링크imageUrl
<string> - NFT와 관련된 이미지 URLcontentUrl
<string> optional - NFT와 연결된 콘텐츠의 URLquantity
<number> - NFT의 수량contentType
<string> - NFT의 콘텐츠 유형<'image' | 'video'>state
<number> - NFT의 상태
Example
const result = await wepinWidget.getNFTs({ refresh: false });
response
[
{
"account": {
"address": "0x0000001111112222223333334444445555556666",
"network": "Ethereum",
"contract": "0x777777888888999999000000111111222222333333",
"isAA": true
},
"contract": {
"name": "NFT Collection",
"address": "0x777777888888999999000000111111222222333333",
"scheme": "ERC721",
"description": "An example NFT collection",
"network": "Ethereum",
"externalLink": "https://example.com",
"imageUrl": "https://example.com/image.png"
},
"name": "Sample NFT",
"description": "A sample NFT description",
"externalLink": "https://example.com/nft",
"imageUrl": "https://example.com/nft-image.png",
"contentUrl": "https://example.com/nft-content.png",
"quantity": 1,
"contentType": "image/png",
"state": 0
}
]
send
위젯을 이용하여 send기능을 수행하고 send 트랜젝션의 ID정보를 반환합니다. 이 기능은 위핀에 로그인한 후에만 사용할 수 있습니다.
Parameters
account
<Account> - 전송할 사용자의 계정 정보network
<string> - 전송할 네트워크 종류address
<string> - 전송할 계정의 주소contract
<string> optional - 토큰의 Contract 주소
txData
<object> optionaltoAddress
<string> - 전송 받을 주소amount
<string> - 전송할 수량
Return value
Promise <object>
txId
<string> - send 트랜잭션의 txID
Example
const result = await wepinWidget.send({
account: {
address: '0x0000001111112222223333334444445555556666',
network: 'Ethereum',
},
txData: {
toAddress: '0x9999991111112222223333334444445555556666',
amount: '0.1',
},
});
response
{
"txId": "0x76bafd4b700ed959999d08ab76f95d7b6ab2249c0446921c62a6336a70b84f32"
}
receive
receive
메서드는 지정된 계정과 연관된 계정 정보 페이지를 엽니다. 이 메서드는 위핀에 로그인한 후에만 사용할 수 있습니다.
Parameters
account
<WepinAccount> - 오픈할 페이지에 대한 계정을 제공합니다.network
<string> - 계정과 연관된 네트워크address
<string> - 계정의 주소contract
<string> optional - 토큰의 Contract 주소
Return value
Promise <object> - A promise that resolves to a
WepinReceiveResponse
object containing the information about the opened account.account
<WepinAccount> - 오픈된 페이지의 계정 정보network
<string> - 계정과 연관된 네트워크address
<string> - 계정의 주소contract
<string> optional - 토큰의 Contract 주소
Example
// Opening an account page
const result = await wepinWidget.receive({
address: '0x0000001111112222223333334444445555556666',
network: 'Ethereum',
});
// Opening a token page
const result = await wepinWidget.receive({
address: '0x0000001111112222223333334444445555556666',
network: 'Ethereum',
contract: '0x9999991111112222223333334444445555556666',
});
response
{
"account": {
"address": "0x0000001111112222223333334444445555556666",
"network": "Ethereum",
"contract": "0x9999991111112222223333334444445555556666"
}
}
finalize
WepinSDK 사용을 종료합니다. WepinLifeCycle
이 notInitialized
로 변경됩니다.
Parameters
None
Return value
Promise<void>
Example
await wepinWidget.finalize();
WepinError
이 섹션에서는 Wepin SDK 기능을 사용하는 동안 발생할 수 있는 다양한 오류 코드에 대한 설명을 제공합니다. 각 오류 코드는 특정 문제에 대응하며, 이를 이해하면 디버깅 및 오류 처리를 보다 효과적으로 수행할 수 있습니다.
ApiRequestError
There was an error while making the API request.
InvalidParameters
One or more parameters provided are invalid or missing.
NotInitialized
The Wepin SDK has not been properly initialized.
InvalidAppKey
The Wepin app key is invalid.
InvalidLoginProvider
The login provider specified is not supported or is invalid.
InvalidToken
The token does not exist.
InvalidLoginSession
The login session information does not exist.
UserCancelled
The user has cancelled the operation.
UnknownError
An unknown error has occurred, and the cause is not identified.
NotConnectedInternet
The system is unable to detect an active internet connection.
FailedLogin
The login attempt has failed due to incorrect credentials or other issues.
AlreadyLogout
The user is already logged out, so the logout operation cannot be performed again.
AlreadyInitialized
The Wepin SDK is already initialized.
InvalidEmailDomain
The provided email address's domain is not allowed or recognized by the system.
FailedSendEmail
The system encountered an error while sending an email.
RequiredEmailVerified
Email verification is required to proceed with the requested operation.
IncorrectEmailForm
The provided email address does not match the expected format.
IncorrectPasswordForm
The provided password does not meet the required format or criteria.
NotInitializedNetwork
The network or connection required for the operation has not been properly initialized.
RequiredSignupEmail
The user needs to sign up with an email address to proceed.
FailedEmailVerified
The Wepin SDK encountered an issue while attempting to verify the provided email address.
FailedPasswordStateSetting
Failed to set the password state.
FailedPasswordSetting
The Wepin SDK failed to set the password.
ExistedEmail
The provided email address is already registered in Wepin.
NotActivity
The Context is not an activity.
Last updated
Was this helpful?