-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): add
getProtocolVersion
function (#76)
* add: getProtocolVersion function * fix: prettier * fix: linting * Update sdk/src/introspection.ts Co-authored-by: Carles <[email protected]> * Update sdk/src/introspection.ts Co-authored-by: Michael Heuer <[email protected]> * Update sdk/test/unit/introspection.test.ts Co-authored-by: Michael Heuer <[email protected]> * remove: constant ADDRESS_ONE * fix: prettier * update: changelog and package version * fix: export of addres one * fix: update getProtocolVersion return comment * chore: add ADDRESS_ONE to constants --------- Co-authored-by: Carles <[email protected]> Co-authored-by: Michael Heuer <[email protected]>
- Loading branch information
1 parent
2093fe6
commit b3bd6da
Showing
8 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export function mockContractProtocolVersion( | ||
version: [number, number, number] = [1, 0, 0], | ||
throwException: boolean = false | ||
) { | ||
jest | ||
.spyOn(jest.requireActual('@ethersproject/contracts'), 'Contract') | ||
.mockImplementation(() => { | ||
return { | ||
protocolVersion: () => { | ||
if (throwException) { | ||
throw new Error('Error'); | ||
} | ||
return Promise.resolve(version); | ||
}, | ||
}; | ||
}); | ||
} | ||
|
||
export function mockJSONRPCProvider( | ||
chainId: number = 1, | ||
blockNumber: number = 1 | ||
) { | ||
return jest | ||
.spyOn(jest.requireActual('@ethersproject/providers'), 'JsonRpcProvider') | ||
.mockImplementation(() => { | ||
return { | ||
getNetwork: () => { | ||
return { | ||
chainId, | ||
}; | ||
}, | ||
getBlockNumber: () => { | ||
return Promise.resolve(blockNumber); | ||
}, | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters