Skip to content

Commit

Permalink
Fix: Update contracts, readme and react components
Browse files Browse the repository at this point in the history
  • Loading branch information
gianalarcon committed Jul 25, 2024
1 parent 4fba620 commit db4ae53
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ yarn start

> 👩‍💻 Edit `YourToken.cairo` to reuse the **ERC20** token standard from OpenZeppelin. To accomplish this, you can use [`Cairo Components`](https://book.cairo-lang.org/ch16-02-00-composability-and-components.html) to embed the `ERC20` logic inside your contract.
> Mint **2000** (\* 10 \*\* 18) to your frontend address using the `constructor()`. In devnet, by default we choose the first pre-deployed account: `0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691`, to deploy the contracts. In order to complete this checkpoint, you need to connect to devnet using the same address. In testnet, you can use your own address to deploy the contracts. Edi the .env file in the `snfoundry` package to set the `ACCOUNT_ADDRESS_SEPOLIA` to your own address.
> Mint **2000** (\* 10 \*\* 18) to your frontend address using the `constructor()`. In devnet, by default we choose the first pre-deployed account: `0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691`, to deploy the contracts. In order to complete this checkpoint, you need to connect to devnet using the same address. In testnet, you can use your own address to deploy the contracts. Edit the .env file in the `snfoundry` package to set the `ACCOUNT_ADDRESS_SEPOLIA` to your own address.
(Your frontend address is the address in the top right of <http://localhost:3000>)

Expand Down Expand Up @@ -277,4 +277,4 @@ For production-grade applications, it's recommended to obtain your own API keys
---

> 🏃 Head to your next challenge [here](https://github.com/Quantum3-Labs/speedrunstark/tree/dice-game).
> � Problems, questions, comments on the stack? Post them to the [🏗 Scaffold-Stark developers chat](https://t.me/+wO3PtlRAreo4MDI9)
> � Problems, questions, comments on the stack? Post them to the [🏗 Scaffold-Stark developers chat](https://t.me/+wO3PtlRAreo4MDI9)
6 changes: 3 additions & 3 deletions packages/nextjs/app/token-vendor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const TokenVendor: NextPage = () => {
}
};

// FixMe: This is a hack to get the symbol of the token. Propose a better way to do this.
const parsedSymbol = yourTokenSymbol
? byteArray.stringFromByteArray(yourTokenSymbol as any)
: "";
Expand All @@ -125,7 +126,6 @@ const TokenVendor: NextPage = () => {
{parseFloat(formatEther(yourTokenBalance?.toString() || 0n))}
</span>
<span className="font-bold ml-1">{parsedSymbol}</span>
{/* FixMe: Improve this parsing */}
</div>
</div>
{/* Vendor Balances */}
Expand Down Expand Up @@ -168,7 +168,7 @@ const TokenVendor: NextPage = () => {
>
Buy Tokens
</button>
</div>
</div>*/}

{!!yourTokenBalance && (
<div className="flex flex-col items-center space-y-4 bg-base-100 border-8 border-secondary rounded-xl p-6 mt-8 w-full max-w-lg">
Expand Down Expand Up @@ -196,7 +196,7 @@ const TokenVendor: NextPage = () => {
Send Tokens
</button>
</div>
)} */}
)}

{/* Sell Tokens */}
{/* {!!yourTokenBalance && (
Expand Down
20 changes: 2 additions & 18 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const deployedContracts = {
devnet: {
YourToken: {
address:
"0x0428d10c79b47354e26b20d9ad5b0f56f6b1c56e554708a8e1d93c846a6ea709",
"0x050994d27ce101acd0c5545ec12912c0ffaaa5e21d797fd8aadc87c30d84bd10",
abi: [
{
type: "impl",
Expand Down Expand Up @@ -309,7 +309,7 @@ const deployedContracts = {
},
Vendor: {
address:
"0x01b069cb55cbc425b6f58fbbfd413f002f60684b011eb8460f7ad6f29cde2555",
"0x057ab241d9cebe65a67bf93e775059b598c036539655f7bc376b222bbc1b6535",
abi: [
{
type: "impl",
Expand Down Expand Up @@ -365,22 +365,6 @@ const deployedContracts = {
outputs: [],
state_mutability: "external",
},
{
type: "function",
name: "send_tokens",
inputs: [
{
name: "to",
type: "core::starknet::contract_address::ContractAddress",
},
{
name: "amount_tokens",
type: "core::integer::u256",
},
],
outputs: [],
state_mutability: "external",
},
{
type: "function",
name: "tokens_per_eth",
Expand Down
6 changes: 0 additions & 6 deletions packages/snfoundry/contracts/src/Vendor.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub trait IVendor<T> {
fn buy_tokens(ref self: T, eth_amount_wei: u256);
fn withdraw(ref self: T);
fn sell_tokens(ref self: T, amount_tokens: u256);
fn send_tokens(ref self: T, to: ContractAddress, amount_tokens: u256);
fn tokens_per_eth(self: @T) -> u256;
fn your_token(self: @T) -> ContractAddress;
fn eth_token(self: @T) -> ContractAddress;
Expand Down Expand Up @@ -85,11 +84,6 @@ mod Vendor {
) { // Implement your function sell_tokens here.
}

fn send_tokens(ref self: ContractState, to: ContractAddress, amount_tokens: u256) {
let sent = self.your_token.read().transfer(to, amount_tokens);
assert(sent, 'Token Transfer failed');
}

fn tokens_per_eth(
self: @ContractState
) -> u256 { // Modify to return the amount of tokens per 1 ETH.
Expand Down

0 comments on commit db4ae53

Please sign in to comment.