메서드

Wepin Compose Multiplatform Widget SDK 에서 제공하는 메서드입니다.

changeLanguage

fun changeLanguage(options: WidgetAttributes)

위젯의 속성(언어, 통화)을 변경합니다.

Parameters

  • attributes <WidgetAttributes>

    • defaultLanguage <String> 위젯 언어 설정

    • defaultCurrency <String> 위젯 통화 설

Returns

  • None

Exception

Example

wepinWidgetSDK.changeLanguage(WidgetAttributes(defaultLanguage = "ko", defaultCurrency = "KRW"))

getStatus

suspend fun getStatus(): WepinLifeCycle {

WepinWidgetSDK 의 Lifecycle 상태 값을 반환합니다.

Parameters

  • None

Returns

  • <WepinLifeCycle>

    • NOT_INITIALIZED - WepinWidgetSDK 가 초기화되지 않음

    • INITIALIZING - WepinWidgetSDK 초기화 진행 중

    • INITIALIZED - WepinWidgetSDK 초기화 완료

    • BEFORE_LOGIN - WepinWidgetSDK은 초기화 했으나 사용자는 로그인 되지 않음

    • LOGIN - 사용자가 로그인 되었고, Wepin App 에도 등록되어 있음

    • LOGIN_BEFORE_REGISTER - 사용자가 로그인 되었으나, Wepin App 에 등록되지 않음

Exception

Example

coroutineScope.launch {
    val status = wepinWidgetSDK.getStatus()
}

login

login 변수는 다양한 인증 방법을 포함한 Wepin 로그인 라이브러리로, 사용자가 여러 방식으로 로그인할 수 있도록 합니다. 이메일 및 비밀번호 로그인, OAuth 제공자 로그인, ID 토큰 또는 Access 토큰을 사용한 로그인 등을 지원합니다. 각 메서드에 대한 자세한 정보는 공식 라이브러리 문서 Login Library 가이드에서 확인할 수 있습니다.

Available Methods

이 메서드들은 다양한 로그인 시나리오를 지원하며, 필요에 맞는 적절한 방법을 선택할 수 있습니다.

Exception

Example

coroutineScope.launch { 
    //WepinLogin instance 생성
    val wepinLogin: WepinLogin = WepinLogin(
        WepinLoginOptions(
            context = context,
            appId = appId,
            appKey = appKey
        )
    )
    //WepinLogin 초기화
    wepinLogin.init()
    {
        //OAuth Provider 를 사용한 로그인
        val response = wepinLogin.loginWithOauthProvider(
            LoginOauth2Params(
                provider = "google",
                clientId = "your-google-client-id"
            )
        )
        //sign 값 가져오기
        val sign = wepinLogin.getSignForLogin(
            privateKeyHex = "private key", 
            message = response.token
        )
        var loginResult: LoginResult? = null
        if (response.provider == "naver" || response.provider = "discord") {
            //Access Token 을 이용한 로그인
            loginResult = wepinLogin.loginWithAccessToken(
                LoginOauthAccessTokenRequest(
                    provider = response.provider,
                    token = response.token,
                    sign = sign
                )
            )
        } else {
            //ID Token 을 이용한 로그인
            loginResult = wepinLogin.loginWithIdToken(
                LoginOauthIdTokenRequest(
                    idToken = response.token,
                    sign = sign
                )
            )
        }
    }
    or 
    {
        //email, password 를 이용한 로그인
        val loginResult = wepinLogin.loginWithEmailAndPassword(
            LoginWithEmailParams(
                email = "abc@defg.kr",
                password = "abcdefg$"
            )
        )
    }
    //Wepin Login
    val userInfo = wepinLogin.loginWepin(loginResult)
}

openWidget

suspend fun openWidget()

위젯 창을 열어줍니다. 사용자가 로그인되어 있지 않으면 위젯 창이 정상적으로 열리지 않으므로, openWidget을 호출하기 전에 반드시 사용자가 Wepin 에 로그인되어 있어야 합니다. 로그인하려면 login 변수의 loginWepin 메서드를 사용해야 합니다.

Parameters

  • None

Returns

  • None

Exception

Example

wepinWidgetSDK.openWidget()

closeWidget

fun closeWidget()

위젯 창을 닫습니다. 위젯 창을 닫아도 로그아웃 되지 않습니다.

Parameters

  • None

Returns

  • None

Exception

Example

wepinWidgetSDK.closeWidget()

register

suspend fun register(): WepinUser?

사용자를 Wepin App 에 등록합니다. 가입 및 로그인 후 Wepin 위젯의 등록 페이지가 열리며, Wepin 서비스에 등록(지갑 생성 및 계정 생성)을 진행합니다. 이 기능은 WepinWidgetSDKWepinLifeCycleloginBeforeRegister 상태일 때만 사용할 수 있습니다. login 변수의 loginWepin() 메서드를 호출한 후, userStatusloginStatus 값이 'complete'가 아니면 이 메서드를 호출해야 합니다.

Parameters

  • None

Returns

  • <WepinUser> optional

    • status <'success' | 'fail'> 로그인 상태

    • userInfo <UserInfo> 사용자 정보 (optional)

      • userId <String> 사용자의 ID

      • email <String> 사용자의 이메일

      • provider <'google' | 'apple' | 'naver' | 'discord' | 'email' | 'external_token'> 로그인 Provider

      • use2FA <Boolean> 사용자가 이중 인증을 사용하는지 여부

    • walletId <String> 사용자의 지갑 ID

    • userStatus <UserStatus> 사용자의 Wepin 로그인 상태 (optional)

      • loginStatus <WepinLoginStatus - 'complete' | 'pinRequired' | 'registerRequired'> 사용자의 loginStatus 가 'complete' 상태가 아닌 경우, 사용자는 Wepin 에 register 해야 합니다.

      • pinRequired <Boolean> PIN 이 필요한지 여부

    • token <Token> 사용자의 Wepin 토큰

      • accessToken <String> Access Token

      • refreshToken <String> Refresh Token

Exception

Example

coroutineScope.launch {
    wepinWidget.register()
}

getAccounts

suspend fun getAccounts(networks: List<String>? = null, withEoa: Boolean? = null): ArrayList<Account>?

앱에서 사용 가능한 사용자의 계정 정보(네트워크와 주소)를 반환합니다. 이 기능은 Wepin 에 로그인한 후에만 사용할 수 있습니다. 파라미터가 없는 경우에는 사용자의 모든 정보가 반환됩니다.

Parameters

  • networks <List<String>> optional 반환받고자 하는 계정의 네트워크 입니다. 네트워크로 지원하는 블록체인 목록은 아래 지원 블록체인 페이지에서 확인 가능합니다.

  • withEoa <Boolean> optional AA계정이 있는 경우, EOA 계정도 포함하여 반환할지 여부를 지정합니다.

지원 블록체인

Returns

  • <ArrayList<Account>> optional

    • network <String> 사용자 계정의 네트워크 종류

    • address <String> 사용자 계정의 주소

    • contract <String> optional 토큰의 Contract 주소

    • isAA <Boolean> optional 해당 계정이 AA 계정인지 여부 표시

Exception

Example

coroutineScope.launch {
    wepinWidget.getAccounts(
        networks: listOf("Ethereum"),
        withEoa: true
    )
}

getBalance

suspend fun getBalance(accounts: ArrayList<Account>): ArrayList<AccountBalanceInfo>

사용자 계정의 잔액(수량) 정보를 반환합니다. 이 기능은 Wepin에 로그인 한 후에만 사용할 수 있습니다.

accounts 파라미터가 없는 경우에는 사용자의 모든 계정의 잔액이 반환됩니다.

Parameters

  • accounts <ArrayList<Account>>

    • network <String> 잔액을 조회할 사용자 계정의 네트워크 종류

    • address <String> 잔액을 조회할 사용자 계정의 주소

    • contract <String> optional 토큰의 Contract 주소

    • isAA <Boolean> optional 해당 계정이 AA 계정인지 여부 표시

Returns

  • <ArrayList<AccountBalanceInfo>>

    • address <String> 사용자 계정의 네트워크 종류

    • network <String> 사용자 계정의 주소

    • symbol <String> 네트워크 심볼

    • balance <String> 보유하고 있는 네트워크 코인의 수량

    • tokens <TokenBalanceInfo>

      • symbol <String> 토큰 심볼

      • balance <String> 보유하고 있는 토큰의 수량

      • contract <String> 토큰 Contract 주소

Exception

Example

coroutineScope.launch {
    val accountList: ArrayList<Account> = wepinWidget.getAccounts()
    wepinWidget.getBalance(accountList)
}

getNFTs

suspend fun getNFTs(refresh: Boolean, networks: List<String>? = null): ArrayList<WepinNFT>

사용자의 NFT를 반환합니다. 이 기능은 Wepin에 로그인 한 후에만 사용할 수 있습니다.

networks 파라미터가 없는 경우에는 사용자의 모든 NFT 정보가 반환됩니다.

Parameters

  • refresh <Boolean> optional NFT를 onchain 에서 새로 조회할 지 여부

  • networks <List<String>> NFT를 필터링할 네트워크 이름 목록

Returns

  • <ArrayList<WepinNFT>>

    • account <Account>

      • network <String> 사용자 계정의 네트워크 종류

      • address <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와 관련된 이미지 URl

    • contentUrl <String> optional - NFT와 연결된 콘텐츠의 URL

    • quantity <Int> NFT 의 수량

    • contentType <String> NFT 콘텐츠의 유형<'image' | 'video>

    • state <Int> NFT의 상태

Exception

Example

coroutineScope.launch {
    wepinWidget.getNFTs(
        refresh = true,
        networks = listOf("Ethereum")
    )
}

send

suspend fun send(sendData: SendData): SendResponse

위젯을 이용하여 send기능을 수행하고 send 트랜젝션의 ID정보를 반환합니다. 이 기능은 Wepin에 로그인한 후에만 사용할 수 있습니다.

Parameters

  • sendData <SendData>

    • account <Account> 전송하는 사용자의 계정 정보

      • network <String> 전송하는 네트워크 종류

      • address <String> 전송하는 계정의 주소

      • contract <String> optional 전송하는 토큰의 Contract 주소

      • isAA <Boolean> optional 해당 계정이 AA 계정인지 여부 표시

    • txData <TxData>

      • toAddress <String> 전송 받을 주소

      • amount <String> 전송할 수량

Returns

  • <SendResponse>

    • txId <String> send 트렌젝션의 ID

Exception

Example

coroutineScope.launch {
    val result = wepinWidgetSDK.send(
        SendData(
            account = Account(
                network = "Ethereum",
                address = "0x0000001111112222223333334444445555556666"
            ),
            txData = TxData(
                toAddress = "0x9999991111112222223333334444445555556666",
                amount = "0.1"
            )
        )
    )
}

finalize

fun finalize()

WepinWidgetSDK 의 사용을 종료합니다. WepinLifeCycle이 NOT_INITALIZED 로 변경됩니다.

Parameters

  • None

Returns

  • None

Exception

Example

wepinWidgetSDK.finalize()

WepinError

Error CodeError MessageError Description

invalidAppKey

"InvalidAppKey"

The Wepin app key is invalid.

invalidParameters `

"InvalidParameters"

One or more parameters provided are invalid or missing.

invalidLoginProvider

"InvalidLoginProvider"

The login provider specified is not supported or is invalid.

invalidToken

"InvalidToken"

The token does not exist.

invalidLoginSession

"InvalidLoginSession"

The login session information does not exist.

notInitialized

"NotInitialized"

The WepinLoginLibrary has not been properly initialized.

alreadyInitialized

"AlreadyInitialized"

The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again.

userCancelled

"UserCancelled"

The user has cancelled the operation.

unknownError

"UnknownError"

An unknown error has occurred, and the cause is not identified.

notConnectedInternet

"NotConnectedInternet"

The system is unable to detect an active internet connection.

failedLogin

"FailedLogin"

The login attempt has failed due to incorrect credentials or other issues.

alreadyLogout

"AlreadyLogout"

The user is already logged out, so the logout operation cannot be performed again.

invalidEmailDomain

"InvalidEmailDomain"

The provided email address's domain is not allowed or recognized by the system.

failedSendEmail

"FailedSendEmail"

The system encountered an error while sending an email. This is because the email address is invalid or we sent verification emails too often. Please change your email or try again after 1 minute.

requiredEmailVerified

"RequiredEmailVerified"

Email verification is required to proceed with the requested operation.

incorrectEmailForm

"incorrectEmailForm"

The provided email address does not match the expected format.

incorrectPasswordForm

"IncorrectPasswordForm"

The provided password does not meet the required format or criteria.

notInitializedNetwork

"NotInitializedNetwork"

The network or connection required for the operation has not been properly initialized.

requiredSignupEmail

"RequiredSignupEmail"

The user needs to sign up with an email address to proceed.

failedEmailVerified

"FailedEmailVerified"

The WepinLoginLibrary encountered an issue while attempting to verify the provided email address.

failedPasswordStateSetting

"FailedPasswordStateSetting"

Failed to set the password state. This error may occur during password management operations, potentially due to invalid input or system issues.

failedPasswordSetting

"failedPasswordSetting"

Failed to set the password. This could be due to issues with the provided password or internal errors during the password setting process.

existedEmail

"ExistedEmail"

The provided email address is already registered. This error occurs when attempting to sign up with an email that is already in use.

apiRequestError

"ApiRequestError"

There was an error while making the API request. This can happen due to network issues, invalid endpoints, or server errors.

incorrectLifecycleException

"IncorrectLifecycleException"

The lifecycle of the Wepin SDK is incorrect for the requested operation. Ensure that the SDK is in the correct state (e.g., initialized and login) before proceeding.

failedRegister

"FailedRegister"

Failed to register the user. This can occur due to issues with the provided registration details or internal errors during the registration process.

accountNotFound

"AccountNotFound"

The specified account was not found. This error is returned when attempting to access an account that does not exist in the Wepin.

nftNotFound

"NftNotFound"

The specified NFT was not found. This error occurs when the requested NFT does not exist or is not accessible within the user's account.

failedSend

"FailedSend"

Failed to send the required data or request. This error could be due to network issues, incorrect data, or internal server errors.

Last updated