1
+
2
+
3
+ export const GoPlusType = {
4
+ EVMTOKEN_SECURITY_CHECK : "EVMTOKEN_SECURITY_CHECK" ,
5
+ SOLTOKEN_SECURITY_CHECK : "SOLTOKEN_SECURITY_CHECK" ,
6
+ SUITOKEN_SECURITY_CHECK : "SUITOKEN_SECURITY_CHECK" ,
7
+ RUGPULL_SECURITY_CHECK : "RUGPULL_SECURITY_CHECK" ,
8
+ NFT_SECURITY_CHECK : "NFT_SECURITY_CHECK" ,
9
+ ADRESS_SECURITY_CHECK : "ADRESS_SECURITY_CHECK" ,
10
+ APPROVAL_SECURITY_CHECK : "APPROVAL_SECURITY_CHECK" ,
11
+ ACCOUNT_ERC20_SECURITY_CHECK : "ACCOUNT_ERC20_SECURITY_CHECK" ,
12
+ ACCOUNT_ERC721_SECURITY_CHECK : "ACCOUNT_ERC721_SECURITY_CHECK" ,
13
+ ACCOUNT_ERC1155_SECURITY_CHECK : "ACCOUNT_ERC1155_SECURITY_CHECK" ,
14
+ SIGNATURE_SECURITY_CHECK : "SIGNATURE_SECURITY_CHECK" ,
15
+ URL_SECURITY_CHECK : "URL_SECURITY_CHECK" ,
16
+ }
17
+
18
+ export type GoPlusType = ( typeof GoPlusType ) [ keyof typeof GoPlusType ]
19
+
20
+ export type GoPlusParamType = {
21
+ "type" : GoPlusType ,
22
+ "network" ?: string ,
23
+ "token" ?: string ,
24
+ "contract" ?: string ,
25
+ "wallet" ?: string ,
26
+ "url" ?: string ,
27
+ "data" ?: string ,
28
+ }
29
+
30
+ export class GoPlusManage {
31
+ private apiKey : string ;
32
+
33
+ constructor ( apiKey : string = null ) {
34
+ this . apiKey = apiKey ;
35
+ }
36
+
37
+ async requestGet ( api : string ) {
38
+ const myHeaders = new Headers ( ) ;
39
+ if ( this . apiKey ) {
40
+ myHeaders . append ( "Authorization" , this . apiKey ) ;
41
+ }
42
+ const url = `https://api.gopluslabs.io/${ api } `
43
+ const res = await fetch ( url , {
44
+ method : "GET" ,
45
+ headers : myHeaders ,
46
+ redirect : "follow"
47
+ } )
48
+
49
+ return await res . json ( ) ;
50
+ }
51
+
52
+ async tokenSecurity ( chainId : string , address : string ) {
53
+ const api = `api/v1/token_security/${ chainId } ?contract_addresses=${ address } ` ;
54
+ return await this . requestGet ( api )
55
+ }
56
+
57
+ async rugpullDetection ( chainId : string , address : string ) {
58
+ const api = `api/v1/rugpull_detecting/${ chainId } ?contract_addresses=${ address } ` ;
59
+ return await this . requestGet ( api )
60
+ }
61
+
62
+ async solanaTokenSecurityUsingGET ( address : string ) {
63
+ const api = `api/v1/solana/token_security?contract_addresses=${ address } ` ;
64
+ return await this . requestGet ( api )
65
+ }
66
+
67
+ async suiTokenSecurityUsingGET ( address : string ) {
68
+ const api = `api/v1/sui/token_security?contract_addresses=${ address } ` ;
69
+ return await this . requestGet ( api )
70
+ }
71
+
72
+ async nftSecurity ( chainId : string , address : string ) {
73
+ const api = `api/v1/nft_security/${ chainId } ?contract_addresses=${ address } ` ;
74
+ return await this . requestGet ( api )
75
+ }
76
+
77
+ async addressSecurity ( address : string ) {
78
+ const api = `api/v1/address_security/${ address } ` ;
79
+ return await this . requestGet ( api )
80
+ }
81
+
82
+ async approvalSecurity ( chainId : string , contract : string ) {
83
+ const api = `api/v1/approval_security/${ chainId } ?contract_addresses=${ contract } ` ;
84
+ return await this . requestGet ( api )
85
+ }
86
+
87
+ async erc20ApprovalSecurity ( chainId : string , wallet : string ) {
88
+ const api = `api/v2/token_approval_security/${ chainId } ?addresses=${ wallet } ` ;
89
+ return await this . requestGet ( api )
90
+ }
91
+
92
+ async erc721ApprovalSecurity ( chainId : string , wallet : string ) {
93
+ const api = `api/v2/nft721_approval_security/${ chainId } ?addresses=${ wallet } ` ;
94
+ return await this . requestGet ( api )
95
+ }
96
+
97
+ async erc1155ApprovalSecurity ( chainId : string , wallet : string ) {
98
+ const api = `api/v2/nft1155_approval_security/${ chainId } ?addresses=${ wallet } ` ;
99
+ return await this . requestGet ( api )
100
+ }
101
+
102
+ async inputDecode ( chainId : string , data : string ) {
103
+ const body = JSON . stringify ( {
104
+ chain_id : chainId ,
105
+ data : data ,
106
+ } )
107
+ const res = await fetch ( "https://api.gopluslabs.io/api/v1/abi/input_decode" , {
108
+ "headers" : {
109
+ "accept" : "*/*" ,
110
+ "accept-language" : "en,zh-CN;q=0.9,zh;q=0.8" ,
111
+ "content-type" : "application/json"
112
+ } ,
113
+ "body" : body ,
114
+ "method" : "POST"
115
+ } ) ;
116
+ return await res . json ( ) ;
117
+ }
118
+
119
+ async dappSecurityAndPhishingSite ( url : string ) {
120
+ const api = `api/v1/dapp_security?url=${ url } ` ;
121
+ const data1 = await this . requestGet ( api )
122
+
123
+ const api2 = `api/v1/phishing_site?url=${ url } ` ;
124
+ const data2 = await this . requestGet ( api2 )
125
+ return {
126
+ data1,
127
+ data2
128
+ }
129
+ }
130
+ }
0 commit comments