Skip to content

Commit

Permalink
0.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI committed Mar 2, 2024
1 parent 53dc6fb commit 2b1c011
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instadapp/utils",
"version": "0.7.1",
"version": "0.7.2",
"description": "",
"repository": "instadapp/utils",
"license": "MIT",
Expand Down
20 changes: 20 additions & 0 deletions src/abi/fetcher/AbiFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ export class AbiFetcher {
implementationAddress = await contract.comptrollerImplementation()
implementationAbi = await this._get(implementationAddress, network, metadata)
return proxyFetchMode === 'implementationOnly' ? implementationAbi : [...originalAbi, ...implementationAbi]
} else if (JSON.stringify(originalAbi || []).includes('implementation')) {
try {
const provider = new JsonRpcRetryProvider(rpcProviderUrl[network])

for (const implementationStorageLocation of implementationStorageLocations) {
try {
const implementation = await provider.getStorageAt(contractAddress, implementationStorageLocation)
const address = getAddress(`0x${implementation.slice(-40)}`)

if (address && address !== '0x0000000000000000000000000000000000000000') {
const implementationAbi = await this._get(address, network, metadata)
return proxyFetchMode === 'implementationOnly' ? implementationAbi : [...originalAbi, ...implementationAbi]
}
} catch (error) {

}
}
} catch (error) {

}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/blockscan/blockscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export class Blockscan {
return await retry(async () => {
try {
const { data } = await axios.get(this.apiUrl, { params })

if (data.status !== '1') {
throw new Error(typeof data.result === 'string' ? data.result : data.message)
}
Expand Down
5 changes: 5 additions & 0 deletions test/abi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ describe.concurrent('abi', () => {

expect(abi.length).to.be.greaterThan(0)
})

test('support fluid proxy implementation address', async () => {
const abi = await defaultAbiFetcher.get('0x264786EF916af64a1DB19F513F24a3681734ce92', 'mainnet', 'implementationOnly')
expect(abi.length).to.be.greaterThan(0)
})
}, {
retry: 2
})
21 changes: 10 additions & 11 deletions test/blockscan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import { Blockscan, Chain } from '../src'
const etherscan = new Blockscan(Chain.Mainnet, process.env.MAINNET_ETHERSCAN_API_KEY)

describe.concurrent('blockscan', () => {
test('custom', async () => {
const scan = Blockscan.custom(
'https://basescan.org',
'https://api.basescan.org/api',
process.env.MAINNET_ETHERSCAN_API_KEY
)

const source = await scan.contractSourceCode('0x833589fcd6edb6e08f4c7c32d4f71b54bda02913')

expect(source).toBeDefined()
})
// test('custom', async () => {
// const scan = Blockscan.custom(
// 'https://basescan.org',
// 'https://api.basescan.org/api',
// process.env.MAINNET_ETHERSCAN_API_KEY
// )

// const source = await scan.contractSourceCode('0x833589fcd6edb6e08f4c7c32d4f71b54bda02913')
// expect(source).toBeDefined()
// })

test('getSourceCode', async () => {
const source = await etherscan.contractSourceCode('0x06012c8cf97bead5deae237070f9587f8e7a266d')
Expand Down

0 comments on commit 2b1c011

Please sign in to comment.