Skip to content

Commit

Permalink
feat(sudt): add explorer service
Browse files Browse the repository at this point in the history
  • Loading branch information
Daryl-L committed Oct 25, 2023
1 parent 0d440b4 commit 7cbb4e9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/samples/sudt/src/services/explorer.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export class ExplorerService {
constructor(private host = '') {}

updateSUDT = async (params: {
typeHash: string
symbol: string
fullName: string
decimal: string
totalAmount: string
description: string
operatorWebsite: string
iconFile: string
uan: string
displayName: string
email: string
token?: string
}) => {
const res = await fetch(`${this.host}/api/v1/udts/${params.typeHash}`, { method: 'POST', body: JSON.stringify({}) })
if (!res.ok) {
throw new Error('Internal Service Error')
}

switch (Math.ceil(res.status / 100)) {
case 2:
return true
case 3:
throw new Error('Redirect')
case 4:
throw new Error('Client Error')
}
}
}

0 comments on commit 7cbb4e9

Please sign in to comment.