Skip to content

Commit 25592ec

Browse files
committed
'bump'
1 parent 41af8f0 commit 25592ec

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

configs/dequanto.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ blockchainExplorer:
1818
www: 'https://bscscan.com'
1919
eth:
2020
key: 'FGCTXVXMZAPPW91KCZ91AMZFGBY1GZZB51'
21-
host: 'https://api.etherscan.io'
21+
api: 'https://api.etherscan.io/v2/api?chainid=1'
2222
www: 'https://etherscan.io'
2323
eth:goerli:
2424
key: 'FGCTXVXMZAPPW91KCZ91AMZFGBY1GZZB51'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dequanto",
3-
"version": "0.1.48",
3+
"version": "0.1.49",
44
"author": {
55
"name": "Alex Kit",
66
"email": "alex.kit@atmajs.com"

src/explorer/BlockchainExplorer.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,14 @@ export class BlockchainExplorer implements IBlockchainExplorer {
132132
return info;
133133
}
134134

135-
async getContractCreation(address: TAddress): Promise<{ creator: TAddress, txHash: TEth.Hex }> {
135+
private formatUri (query: string) {
136136
let apiUrl = this.config.api.url;
137-
let url = `${apiUrl}?module=contract&action=getcontractcreation&contractaddresses=${address}&apikey=${this.config.api.key}`;
137+
let c = apiUrl.includes('?') ? '&' : '?';
138+
return `${apiUrl}${c}${query}&apikey=${this.config.api.key}`
139+
}
140+
141+
async getContractCreation(address: TAddress): Promise<{ creator: TAddress, txHash: TEth.Hex }> {
142+
let url = this.formatUri(`module=contract&action=getcontractcreation&contractaddresses=${address}`);
138143
let result = await this.client.get(url);
139144
let json = Array.isArray(result) ? result[0] : result;
140145
if (json == null) {
@@ -163,8 +168,7 @@ export class BlockchainExplorer implements IBlockchainExplorer {
163168
return { abi: info.abi, implementation: address }
164169
}
165170

166-
let apiUrl = this.config.api.url;
167-
let url = `${apiUrl}?module=contract&action=getabi&address=${address}&apikey=${this.config.api.key}`;
171+
let url = this.formatUri(`module=contract&action=getabi&address=${address}`);
168172
let abi: string;
169173

170174
try {
@@ -324,8 +328,8 @@ export class BlockchainExplorer implements IBlockchainExplorer {
324328
ContractName: string
325329
ABI: string
326330
}> {
327-
let apiUrl = this.config.api.url;
328-
let url = `${apiUrl}?module=contract&action=getsourcecode&address=${address}&apikey=${this.config.api.key}`;
331+
332+
let url = this.formatUri(`module=contract&action=getsourcecode&address=${address}`);
329333
let result = await this.client.get(url);
330334
let json = Array.isArray(result) ? result[0] : result;
331335

@@ -458,8 +462,7 @@ export class BlockchainExplorer implements IBlockchainExplorer {
458462
size?: number,
459463
sort?: 'asc' | 'desc'
460464
}) {
461-
let apiUrl = this.config.api.url;
462-
let url = `${apiUrl}?module=account&action=${type}&address=${address}&sort=${params.sort ?? 'desc'}&apikey=${this.config.api.key}`;
465+
let url = this.formatUri(`module=account&action=${type}&address=${address}&sort=${params.sort ?? 'desc'}`);
463466
if (params.fromBlockNumber != null) {
464467
url += `&startblock=${params.fromBlockNumber}`
465468
}

src/utils/$http.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export namespace $http {
3434
async function doFetch <T = any> (opts: IHttpFetch): Promise<THttpResponse<T>> {
3535
let url = opts.url;
3636
if (opts.params) {
37-
url += '?' + new URLSearchParams(opts.params).toString();
37+
let c = url.includes('?') ? '&' : '?';
38+
url += c + new URLSearchParams(opts.params).toString();
3839
}
3940
let headers = new Headers(opts.headers ?? {});
4041
let body = opts.body;

0 commit comments

Comments
 (0)