Skip to content

Commit b9fd22c

Browse files
committed
Fix tests
1 parent 21f5465 commit b9fd22c

File tree

5 files changed

+330
-53
lines changed

5 files changed

+330
-53
lines changed

packages/nextjs/app/token-vendor/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ const TokenVendor: NextPage = () => {
4444

4545
const { data: vendorContractBalance } = useBalance({
4646
address: vendorContractData?.address,
47-
watch: true,
48-
blockIdentifier: "pending" as BlockNumber, // to-do: Improve this
47+
watch: true,
48+
blockIdentifier: "pending" as BlockNumber, // to-do: Improve this
4949
});
5050

5151
const { data: tokensPerEth } = useScaffoldReadContract({
5252
contractName: "Vendor",
5353
functionName: "tokens_per_eth",
5454
});
5555

56-
// const { writeAsync: transferTokens } = useScaffoldWriteContract({
57-
// contractName: "YourToken",
58-
// functionName: "transfer",
59-
// args: [toAddress, multiplyTo1e18(tokensToSend)],
60-
// });
56+
// const { writeAsync: transferTokens } = useScaffoldWriteContract({
57+
// contractName: "YourToken",
58+
// functionName: "transfer",
59+
// args: [toAddress, multiplyTo1e18(tokensToSend)],
60+
// });
6161

6262
const eth_to_spent = getTokenPrice(
6363
tokensToBuy,

packages/nextjs/contracts/deployedContracts.ts

Lines changed: 284 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const deployedContracts = {
77
devnet: {
88
YourToken: {
99
address:
10-
"0x043c53b09fbfd4a921253cd5ba549904edc8ac5195597e58cad3aaaf91181dc2",
10+
"0x07ad7a12a7671e2abc24681007cf0f2a36a0f5fb0f8867e4363c6612ebb52ce4",
1111
abi: [
1212
{
1313
type: "impl",
@@ -307,6 +307,289 @@ const deployedContracts = {
307307
},
308308
],
309309
},
310+
Vendor: {
311+
address:
312+
"0x024a7d92cb64b9e4c2b59a38a616a5c2d3c12677e47abb04cb6205256bd5ed54",
313+
abi: [
314+
{
315+
type: "impl",
316+
name: "VendorImpl",
317+
interface_name: "contracts::Vendor::IVendor",
318+
},
319+
{
320+
type: "struct",
321+
name: "core::integer::u256",
322+
members: [
323+
{
324+
name: "low",
325+
type: "core::integer::u128",
326+
},
327+
{
328+
name: "high",
329+
type: "core::integer::u128",
330+
},
331+
],
332+
},
333+
{
334+
type: "interface",
335+
name: "contracts::Vendor::IVendor",
336+
items: [
337+
{
338+
type: "function",
339+
name: "buy_tokens",
340+
inputs: [
341+
{
342+
name: "eth_amount_wei",
343+
type: "core::integer::u256",
344+
},
345+
],
346+
outputs: [],
347+
state_mutability: "external",
348+
},
349+
{
350+
type: "function",
351+
name: "withdraw",
352+
inputs: [],
353+
outputs: [],
354+
state_mutability: "external",
355+
},
356+
{
357+
type: "function",
358+
name: "sell_tokens",
359+
inputs: [
360+
{
361+
name: "amount_tokens",
362+
type: "core::integer::u256",
363+
},
364+
],
365+
outputs: [],
366+
state_mutability: "external",
367+
},
368+
{
369+
type: "function",
370+
name: "send_tokens",
371+
inputs: [
372+
{
373+
name: "to",
374+
type: "core::starknet::contract_address::ContractAddress",
375+
},
376+
{
377+
name: "amount_tokens",
378+
type: "core::integer::u256",
379+
},
380+
],
381+
outputs: [],
382+
state_mutability: "external",
383+
},
384+
{
385+
type: "function",
386+
name: "tokens_per_eth",
387+
inputs: [],
388+
outputs: [
389+
{
390+
type: "core::integer::u256",
391+
},
392+
],
393+
state_mutability: "view",
394+
},
395+
{
396+
type: "function",
397+
name: "your_token",
398+
inputs: [],
399+
outputs: [
400+
{
401+
type: "core::starknet::contract_address::ContractAddress",
402+
},
403+
],
404+
state_mutability: "view",
405+
},
406+
{
407+
type: "function",
408+
name: "eth_token",
409+
inputs: [],
410+
outputs: [
411+
{
412+
type: "core::starknet::contract_address::ContractAddress",
413+
},
414+
],
415+
state_mutability: "view",
416+
},
417+
],
418+
},
419+
{
420+
type: "impl",
421+
name: "OwnableImpl",
422+
interface_name: "openzeppelin::access::ownable::interface::IOwnable",
423+
},
424+
{
425+
type: "interface",
426+
name: "openzeppelin::access::ownable::interface::IOwnable",
427+
items: [
428+
{
429+
type: "function",
430+
name: "owner",
431+
inputs: [],
432+
outputs: [
433+
{
434+
type: "core::starknet::contract_address::ContractAddress",
435+
},
436+
],
437+
state_mutability: "view",
438+
},
439+
{
440+
type: "function",
441+
name: "transfer_ownership",
442+
inputs: [
443+
{
444+
name: "new_owner",
445+
type: "core::starknet::contract_address::ContractAddress",
446+
},
447+
],
448+
outputs: [],
449+
state_mutability: "external",
450+
},
451+
{
452+
type: "function",
453+
name: "renounce_ownership",
454+
inputs: [],
455+
outputs: [],
456+
state_mutability: "external",
457+
},
458+
],
459+
},
460+
{
461+
type: "constructor",
462+
name: "constructor",
463+
inputs: [
464+
{
465+
name: "eth_token_address",
466+
type: "core::starknet::contract_address::ContractAddress",
467+
},
468+
{
469+
name: "your_token_address",
470+
type: "core::starknet::contract_address::ContractAddress",
471+
},
472+
],
473+
},
474+
{
475+
type: "event",
476+
name: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred",
477+
kind: "struct",
478+
members: [
479+
{
480+
name: "previous_owner",
481+
type: "core::starknet::contract_address::ContractAddress",
482+
kind: "key",
483+
},
484+
{
485+
name: "new_owner",
486+
type: "core::starknet::contract_address::ContractAddress",
487+
kind: "key",
488+
},
489+
],
490+
},
491+
{
492+
type: "event",
493+
name: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
494+
kind: "struct",
495+
members: [
496+
{
497+
name: "previous_owner",
498+
type: "core::starknet::contract_address::ContractAddress",
499+
kind: "key",
500+
},
501+
{
502+
name: "new_owner",
503+
type: "core::starknet::contract_address::ContractAddress",
504+
kind: "key",
505+
},
506+
],
507+
},
508+
{
509+
type: "event",
510+
name: "openzeppelin::access::ownable::ownable::OwnableComponent::Event",
511+
kind: "enum",
512+
variants: [
513+
{
514+
name: "OwnershipTransferred",
515+
type: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred",
516+
kind: "nested",
517+
},
518+
{
519+
name: "OwnershipTransferStarted",
520+
type: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
521+
kind: "nested",
522+
},
523+
],
524+
},
525+
{
526+
type: "event",
527+
name: "contracts::Vendor::Vendor::BuyTokens",
528+
kind: "struct",
529+
members: [
530+
{
531+
name: "buyer",
532+
type: "core::starknet::contract_address::ContractAddress",
533+
kind: "data",
534+
},
535+
{
536+
name: "eth_amount",
537+
type: "core::integer::u256",
538+
kind: "data",
539+
},
540+
{
541+
name: "tokens_amount",
542+
type: "core::integer::u256",
543+
kind: "data",
544+
},
545+
],
546+
},
547+
{
548+
type: "event",
549+
name: "contracts::Vendor::Vendor::SellTokens",
550+
kind: "struct",
551+
members: [
552+
{
553+
name: "seller",
554+
type: "core::starknet::contract_address::ContractAddress",
555+
kind: "key",
556+
},
557+
{
558+
name: "tokens_amount",
559+
type: "core::integer::u256",
560+
kind: "data",
561+
},
562+
{
563+
name: "eth_amount",
564+
type: "core::integer::u256",
565+
kind: "data",
566+
},
567+
],
568+
},
569+
{
570+
type: "event",
571+
name: "contracts::Vendor::Vendor::Event",
572+
kind: "enum",
573+
variants: [
574+
{
575+
name: "OwnableEvent",
576+
type: "openzeppelin::access::ownable::ownable::OwnableComponent::Event",
577+
kind: "flat",
578+
},
579+
{
580+
name: "BuyTokens",
581+
type: "contracts::Vendor::Vendor::BuyTokens",
582+
kind: "nested",
583+
},
584+
{
585+
name: "SellTokens",
586+
type: "contracts::Vendor::Vendor::SellTokens",
587+
kind: "nested",
588+
},
589+
],
590+
},
591+
],
592+
},
310593
},
311594
sepolia: {
312595
YourCollectible: {

packages/snfoundry/contracts/src/Vendor.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod Vendor {
9292

9393
fn tokens_per_eth(
9494
self: @ContractState
95-
) -> u256 { // Modify the return value to return the amount of tokens per 1 ETH.
95+
) -> u256 { // Modify to return the amount of tokens per 1 ETH.
9696
0
9797
}
9898

packages/snfoundry/contracts/src/test/TestContract.cairo

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ fn deploy_mock_eth_token() -> ContractAddress {
2323
// Should deploy the YourToken contract
2424
fn deploy_your_token_token() -> ContractAddress {
2525
let erc20_class_hash = declare("YourToken").unwrap();
26-
let NAME: ByteArray = "Gold";
27-
let SYMBOL: ByteArray = "GLD";
28-
let INITIAL_SUPPLY: u256 = 2000000000000000000000; // 2000_GLD_IN_WEI
2926
let mut calldata = array![];
30-
calldata.append_serde(NAME);
31-
calldata.append_serde(SYMBOL);
32-
calldata.append_serde(INITIAL_SUPPLY);
3327
calldata.append_serde(RECIPIENT());
3428
let (your_token_address, _) = erc20_class_hash.deploy(@calldata).unwrap();
3529
println!("-- YourToken contract deployed on: {:?}", your_token_address);

0 commit comments

Comments
 (0)