Explorar el Código

add functions

Shawn Lu hace 1 año
padre
commit
4c52af23e0
Se han modificado 1 ficheros con 32 adiciones y 0 borrados
  1. 32 0
      src/lunchClient.ts

+ 32 - 0
src/lunchClient.ts

@@ -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
   }
 }