Selaa lähdekoodia

add functions

Shawn Lu 1 vuosi sitten
vanhempi
commit
4c52af23e0
1 muutettua tiedostoa jossa 32 lisäystä ja 0 poistoa
  1. 32 0
      src/lunchClient.ts

+ 32 - 0
src/lunchClient.ts

@@ -21,6 +21,7 @@ export class LunchClient {
   axiosClient: AxiosInstance
   axiosClient: AxiosInstance
   proxyAgent: HttpsProxyAgent<any>
   proxyAgent: HttpsProxyAgent<any>
   key: MnemonicKey
   key: MnemonicKey
+  isLogin: boolean = false
   constructor(mnemonic: string, useProxy: boolean = true) {
   constructor(mnemonic: string, useProxy: boolean = true) {
     this.mnemonic = mnemonic
     this.mnemonic = mnemonic
     this.proxyAgent = useProxy ? getProxyAgent() : undefined
     this.proxyAgent = useProxy ? getProxyAgent() : undefined
@@ -140,5 +141,36 @@ export class LunchClient {
         deviceOS: account.deviceOS,
         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
   }
   }
 }
 }