-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support for Starknet contracts
- Loading branch information
1 parent
0502d90
commit 430a432
Showing
26 changed files
with
1,227 additions
and
461 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "@parcel/config-default", | ||
"transformers": { | ||
"node_modules/@redstone-finance/fuel-connector/src/autogenerated/prices.bin": ["@parcel/transformer-raw"] | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
import { ContractParamsProvider, PricesContractAdapter } from "redstone-sdk"; | ||
import { Contract } from "ethers"; | ||
|
||
import { WrapperBuilder } from "@redstone-finance/evm-connector"; | ||
|
||
export class EvmPricesContractAdapter implements PricesContractAdapter { | ||
constructor(private contract: Contract) {} | ||
|
||
async getPricesFromPayload( | ||
paramsProvider: ContractParamsProvider | ||
): Promise<number[]> { | ||
return await WrapperBuilder.wrap(this.contract) | ||
.usingDataService(paramsProvider.requestParams, paramsProvider.urls) | ||
.getPrices(); | ||
} | ||
|
||
readPricesFromContract( | ||
paramsProvider: ContractParamsProvider | ||
): Promise<number[]> { | ||
throw "Method not supported"; | ||
} | ||
|
||
readTimestampFromContract(): Promise<number> { | ||
throw "Method not supported"; | ||
} | ||
|
||
writePricesFromPayloadToContract( | ||
paramsProvider: ContractParamsProvider | ||
): Promise<string | number[]> { | ||
throw "Method not supported"; | ||
} | ||
} |
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,23 @@ | ||
import { Contract, providers } from "ethers"; | ||
import { IContractConnector, IPricesContractAdapter } from "redstone-sdk"; | ||
import { EvmPricesContractAdapter } from "./EvmPricesContractAdapter"; | ||
import { abi } from "./ShowroomContractAbi.json"; | ||
|
||
export class EvmPricesContractConnector | ||
implements IContractConnector<IPricesContractAdapter> | ||
{ | ||
constructor( | ||
private readonly contractAddress: string, | ||
private readonly signer: providers.JsonRpcSigner | ||
) {} | ||
|
||
getBlockNumber(rpcUrl: string): Promise<number> { | ||
return this.signer.provider.getBlockNumber(); | ||
} | ||
|
||
async getAdapter(): Promise<IPricesContractAdapter> { | ||
return new EvmPricesContractAdapter( | ||
new Contract(this.contractAddress, abi, this.signer) | ||
); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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,41 @@ | ||
import { ChainDetails } from "../config/chains"; | ||
import TxIcon from "../assets/icons/tx.png"; | ||
|
||
interface Props { | ||
txHash: string; | ||
network: ChainDetails; | ||
} | ||
|
||
export const ChainTx = ({ txHash, network }: Props) => ( | ||
<table className="w-3/5 table-auto border mt-8"> | ||
<tbody className="text-md"> | ||
<tr> | ||
<td className="flex items-center gap-3 py-3 px-3"> | ||
<img | ||
className="object-scale-down w-6 h-6" | ||
src={TxIcon} | ||
alt="Contract icon" | ||
/> | ||
Last transaction: | ||
</td> | ||
<td className="py-3 px-3 text-right underline"> | ||
<a | ||
href={network.txExplorerUrl + txHash} | ||
target="blank" | ||
referrerPolicy="no-referrer" | ||
> | ||
{txHash} | ||
</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td colSpan={2} className="text-sm px-3 text-gray-500"> | ||
<i> | ||
This transaction writes a snapshot of current prices to the | ||
contract's storage. | ||
</i> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
); |
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,12 @@ | ||
interface Props { | ||
readPricesFromContract: () => void; | ||
} | ||
|
||
export const ReadPricesButton = ({ readPricesFromContract }: Props) => ( | ||
<button | ||
className="bg-redstone bg-opacity-60 hover:opacity-75 text-white py-3 px-8 rounded-full text-xl" | ||
onClick={readPricesFromContract} | ||
> | ||
Read prices | ||
</button> | ||
); |
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,12 @@ | ||
interface Props { | ||
writePricesToContract: () => void; | ||
} | ||
|
||
export const WritePricesButton = ({ writePricesToContract }: Props) => ( | ||
<button | ||
className="bg-gray-400 hover:opacity-75 text-white py-3 px-8 rounded-full text-xl" | ||
onClick={writePricesToContract} | ||
> | ||
Write prices | ||
</button> | ||
); |
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
Oops, something went wrong.