|
@@ -21,6 +21,7 @@ export class LunchClient {
|
|
|
axiosClient: AxiosInstance
|
|
|
proxyAgent: HttpsProxyAgent<any>
|
|
|
key: MnemonicKey
|
|
|
+ isLogin: boolean = false
|
|
|
constructor(mnemonic: string, useProxy: boolean = true) {
|
|
|
this.mnemonic = mnemonic
|
|
|
this.proxyAgent = useProxy ? getProxyAgent() : undefined
|
|
@@ -140,5 +141,36 @@ export class LunchClient {
|
|
|
deviceOS: account.deviceOS,
|
|
|
},
|
|
|
})
|
|
|
+ this.isLogin = true
|
|
|
+ }
|
|
|
+
|
|
|
+ async submitOnchain(txHash: string) {
|
|
|
+ if (!this.isLogin) throw new Error('Please login first')
|
|
|
+ await this.axiosClient.post(
|
|
|
+ `https://api.lunchlunch.xyz/v1/dish/submit-action/onchain`,
|
|
|
+ {
|
|
|
+ dishId: 8,
|
|
|
+ txHash: txHash,
|
|
|
+ },
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ async claimEgg(txHash: string) {
|
|
|
+ if (!this.isLogin) throw new Error('Please login first')
|
|
|
+ await this.axiosClient.post(
|
|
|
+ `https://api.lunchlunch.xyz/v1/dish/submit-claim/egg`,
|
|
|
+ {
|
|
|
+ dishId: 8,
|
|
|
+ txHash: txHash,
|
|
|
+ },
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ async getEggBalance() {
|
|
|
+ if (!this.isLogin) throw new Error('Please login first')
|
|
|
+ const resp = await this.axiosClient.get(
|
|
|
+ 'https://api.lunchlunch.xyz/v1/member/egg/balance',
|
|
|
+ )
|
|
|
+ return resp.data
|
|
|
}
|
|
|
}
|