-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ππ½ββοΈ Ethereum provider.js ekle
- Loading branch information
1 parent
0b070b8
commit 151f224
Showing
5 changed files
with
43 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @param {!eth.Provider} provider | ||
* @param {string} contract Contract adddress given with the 0x prefix | ||
* @param {string} calldata Calldata transmitted to the contract verbatim. | ||
* @return {!Promise<string>} | ||
*/ | ||
const callMethod = (provider, contract, calldata) => | ||
provider.request(/** @type {!eth.Request} */({ | ||
method: "eth_call", | ||
params: [/** @type {!eth.Transaction} */({ | ||
to: contract, | ||
data: calldata | ||
}), "latest"] | ||
})); | ||
|
||
/** | ||
* @param {string} address starting with 0x | ||
* @return {string} length 64 string, padded for calldata | ||
*/ | ||
const address = (address) => "0".repeat(24) + address.slice(2); | ||
|
||
/** | ||
* @param {string} value | ||
* @return {boolean} | ||
*/ | ||
const isNonzero = (value) => value.replaceAll("0", "") != 'x'; | ||
|
||
export { | ||
address, | ||
callMethod, | ||
isNonzero, | ||
}; |