-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from codenamejason/jax/test-updates
Add Tests
- Loading branch information
Showing
36 changed files
with
2,443 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Will4Us NFT Deployments | ||
|
||
## Arbitrum Mainnet | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0x0 | [LINK](https://goerli.arbiscan.io/address/0x0) | | ||
|
||
## Arbitrum Testnet | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0xe2e1f1c872842350c85623c2323914fd24a6c17c | [LINK](https://goerli.arbiscan.io/address/0xe2e1f1c872842350c85623c2323914fd24a6c17c) | | ||
|
||
## Goerli Testnet | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0x0 | [LINK](https://goerli.etherscan.io/address/0x0) | | ||
|
||
## Base Goerli | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0x0 | [LINK](https://basescan.org/address/0x0) | | ||
|
||
## Base Mainnet | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0x0 | [LINK](https://basescan.org/address/0x0) | | ||
|
||
## Optimism Goerli | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0x0 | [LINK](https://optimistic.etherscan.io/address/0x0) | | ||
|
||
## Optimism Mainnet | ||
|
||
| Contract | Address | Link | | ||
| --- | --- | --- | | ||
| Will4UsNFT | 0x0 | [LINK](https://optimistic.etherscan.io/address/0x0) | |
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
Submodule eas-contracts
added at
9df0f7
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,86 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.20; | ||
|
||
import "@chainlink/src/v0.8/ChainlinkClient.sol"; | ||
import "@chainlink/src/v0.8/shared/access/ConfirmedOwner.sol"; | ||
|
||
/** | ||
* @title The APIConsumer contract | ||
* @notice An API Consumer contract that makes GET requests | ||
*/ | ||
contract APIConsumer is ChainlinkClient, ConfirmedOwner { | ||
using Chainlink for Chainlink.Request; | ||
|
||
bytes32 private jobId; | ||
uint256 private fee; | ||
|
||
mapping(address => bool) public isKYCApproved; | ||
|
||
event DataFullfilled(bytes32 requestId, bool isKYCApproved); | ||
|
||
/** | ||
* @notice Initialize the link token and target oracle | ||
* | ||
* Sepolia Testnet details: | ||
* Link Token: 0x779877A7B0D9E8603169DdbD7836e478b4624789 | ||
* Oracle: 0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD (Chainlink DevRel) | ||
* jobId: ca98366cc7314957b8c012c72f05aeeb | ||
* | ||
*/ | ||
constructor() ConfirmedOwner(msg.sender) { | ||
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789); | ||
setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD); | ||
jobId = "ca98366cc7314957b8c012c72f05aeeb"; | ||
fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job) | ||
} | ||
/** | ||
* @notice Creates a Chainlink request to retrieve API response and update the mapping | ||
* | ||
* @return requestId - ID of the request | ||
*/ | ||
|
||
function requestKYCData() public returns (bytes32 requestId) { | ||
Chainlink.Request memory request = | ||
buildChainlinkRequest(jobId, address(this), this.fulfill.selector); | ||
|
||
// Set the URL to perform the GET request on | ||
request.add("get", "set url here"); | ||
|
||
// Set the path to find the desired data in the API response, where the response format is: | ||
// {"RAW": | ||
// {"ETH": | ||
// {"USD": | ||
// { | ||
// "VOLUME24HOUR": xxx.xxx, | ||
// } | ||
// } | ||
// } | ||
// } | ||
// Chainlink node versions prior to 1.0.0 supported this format | ||
// request.add("path", "RAW.ETH.USD.VOLUME24HOUR"); | ||
request.add("path", ""); | ||
|
||
// Sends the request | ||
return sendChainlinkRequest(request, fee); | ||
} | ||
|
||
/** | ||
* Receive the response in the form of uint256 | ||
*/ | ||
function fulfill(bytes32 _requestId, bool _isKYCApproved) | ||
public | ||
recordChainlinkFulfillment(_requestId) | ||
{ | ||
isKYCApproved[address(0)] = _isKYCApproved; | ||
|
||
emit DataFullfilled(_requestId, _isKYCApproved); | ||
} | ||
|
||
/** | ||
* Allow withdraw of Link tokens from the contract | ||
*/ | ||
function withdrawLink() public onlyOwner { | ||
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress()); | ||
require(link.transfer(msg.sender, link.balanceOf(address(this))), "Unable to transfer"); | ||
} | ||
} |
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,97 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.20; | ||
|
||
import { FunctionsClient } from "@chainlink/src/v0.8/functions/dev/1_0_0/FunctionsClient.sol"; | ||
import { ConfirmedOwner } from "@chainlink/src/v0.8/shared/access/ConfirmedOwner.sol"; | ||
import { FunctionsRequest } from | ||
"@chainlink/src/v0.8/functions/dev/1_0_0/libraries/FunctionsRequest.sol"; | ||
|
||
/** | ||
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY. | ||
* THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. | ||
* DO NOT USE THIS CODE IN PRODUCTION. | ||
*/ | ||
contract FunctionsConsumer is FunctionsClient, ConfirmedOwner { | ||
using FunctionsRequest for FunctionsRequest.Request; | ||
|
||
bytes32 public s_lastRequestId; | ||
bytes public s_lastResponse; | ||
bytes public s_lastError; | ||
|
||
error UnexpectedRequestID(bytes32 requestId); | ||
|
||
event Response(bytes32 indexed requestId, bytes response, bytes err); | ||
|
||
constructor(address router) FunctionsClient(router) ConfirmedOwner(msg.sender) { } | ||
|
||
/** | ||
* @notice Send a simple request | ||
* @param source JavaScript source code | ||
* @param encryptedSecretsUrls Encrypted URLs where to fetch user secrets | ||
* @param donHostedSecretsSlotID Don hosted secrets slotId | ||
* @param donHostedSecretsVersion Don hosted secrets version | ||
* @param args List of arguments accessible from within the source code | ||
* @param bytesArgs Array of bytes arguments, represented as hex strings | ||
* @param subscriptionId Billing ID | ||
*/ | ||
function sendRequest( | ||
string memory source, | ||
bytes memory encryptedSecretsUrls, | ||
uint8 donHostedSecretsSlotID, | ||
uint64 donHostedSecretsVersion, | ||
string[] memory args, | ||
bytes[] memory bytesArgs, | ||
uint64 subscriptionId, | ||
uint32 gasLimit, | ||
bytes32 jobId | ||
) external onlyOwner returns (bytes32 requestId) { | ||
FunctionsRequest.Request memory req; | ||
req.initializeRequestForInlineJavaScript(source); | ||
if (encryptedSecretsUrls.length > 0) { | ||
req.addSecretsReference(encryptedSecretsUrls); | ||
} else if (donHostedSecretsVersion > 0) { | ||
req.addDONHostedSecrets(donHostedSecretsSlotID, donHostedSecretsVersion); | ||
} | ||
if (args.length > 0) req.setArgs(args); | ||
if (bytesArgs.length > 0) req.setBytesArgs(bytesArgs); | ||
s_lastRequestId = _sendRequest(req.encodeCBOR(), subscriptionId, gasLimit, jobId); | ||
return s_lastRequestId; | ||
} | ||
|
||
/** | ||
* @notice Send a pre-encoded CBOR request | ||
* @param request CBOR-encoded request data | ||
* @param subscriptionId Billing ID | ||
* @param gasLimit The maximum amount of gas the request can consume | ||
* @param jobId ID of the job to be invoked | ||
* @return requestId The ID of the sent request | ||
*/ | ||
function sendRequestCBOR( | ||
bytes memory request, | ||
uint64 subscriptionId, | ||
uint32 gasLimit, | ||
bytes32 jobId | ||
) external onlyOwner returns (bytes32 requestId) { | ||
s_lastRequestId = _sendRequest(request, subscriptionId, gasLimit, jobId); | ||
return s_lastRequestId; | ||
} | ||
|
||
/** | ||
* @notice Store latest result/error | ||
* @param requestId The request ID, returned by sendRequest() | ||
* @param response Aggregated response from the user code | ||
* @param err Aggregated error from the user code or from the execution pipeline | ||
* Either response or error parameter will be set, but never both | ||
*/ | ||
function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) | ||
internal | ||
override | ||
{ | ||
if (s_lastRequestId != requestId) { | ||
revert UnexpectedRequestID(requestId); | ||
} | ||
s_lastResponse = response; | ||
s_lastError = err; | ||
emit Response(requestId, s_lastResponse, s_lastError); | ||
} | ||
} |
Oops, something went wrong.