Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add katana method to "mock" paymaster locally #2818

Open
MartianGreed opened this issue Dec 17, 2024 · 2 comments
Open

Add katana method to "mock" paymaster locally #2818

MartianGreed opened this issue Dec 17, 2024 · 2 comments

Comments

@MartianGreed
Copy link
Contributor

I want to be able to use Controller on my local infra. (katana and torii running on localhost)

Be sure to use proper dojo.js branch : https://github.com/dojoengine/dojo.js/tree/feat/cairo-types

cd dojo.js
git fetch --all && git checkout feat/cairo-types

For testing, we'll use dojo.js frontend examples located at :
dojo.js/examples/example-vite-kitchen-sink and worlds/onchain-dash.

Make sure mkcert is installed.

start stack :

katana --dev --dev.no-fee --htt.cors_origins '*'
sozo migrate
torii -w 0x0338b87c85e7d798cf3c6e3605bf4d233a54328e9811c00c0b27ea3a20305615 --http.cors_origins '*'

Start client locally :

pnpm dev

Open browser on https://localhost:5173

click on bottom left button and try to connect to controller using your actual username.

Fund your account :

sozo execute 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 transfer -c 
0x022ec087151f643e816ea1197c6f3d80d42a326590fc6ed05f5debada7f1b24e,u256:10000000000000000

Declare controller class hash :

starkli declare --account katana-0 ~/Downloads/controller_last.json --rpc http://localhost:5050 --compiler-version 2.8.5

Click on controller again and try to upgrade.

You should see an error like {"__wbg_ptr":1384752}

Imo, here is the request causing this issue :

curl 'http://localhost:5050/' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Origin: https://x.cartridge.gg' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: cross-site' \
  -H 'Sec-GPC: 1' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
  -H 'content-type: application/json' \
  -H 'sec-ch-ua: "Brave";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw '{"id":1,"jsonrpc":"2.0","method":"cartridge_addExecuteOutsideTransaction","params":{"address":"0x22ec087151f643e816ea1197c6f3d80d42a326590fc6ed05f5debada7f1b24e","outside_execution":{"caller":"0x414e595f43414c4c4552","nonce":"0x574ff2ae0bba3503802c7483906f0c3c7fde9f356414118831802d9b9567e70","execute_after":"0x0","execute_before":"0x67619c47","calls":[{"to":"0x22ec087151f643e816ea1197c6f3d80d42a326590fc6ed05f5debada7f1b24e","selector":"0xf2f7c15cbe06c8d94597cd91fd7f3369eae842359235712def5584f8d270cd","calldata":["0x511dd75da368f5311134dee2356356ac4da1538d2ad18aa66d57c47e3757d59"]}]},"signature":["0x1","0x4","0x16","0x68","0x74","0x74","0x70","0x73","0x3a","0x2f","0x2f","0x78","0x2e","0x63","0x61","0x72","0x74","0x72","0x69","0x64","0x67","0x65","0x2e","0x67","0x67","0x9d0aec9905466c9adf79584fa75fed3","0x20a97ec3f8efbc2aca0cf7cabb420b4a","0x1d95b17e4f0394060913173a9246dc40","0xd9254a771cd0576caaf95ffb3cca28e9","0x15","0x2c","0x22","0x63","0x72","0x6f","0x73","0x73","0x4f","0x72","0x69","0x67","0x69","0x6e","0x22","0x3a","0x66","0x61","0x6c","0x73","0x65","0x7d","0x1d","0x0","0x84f53524d4695e1739dd8ac643844bc3","0x2a8ec44e0c99ad444605aaf422c0f1f2","0x5391249e533f1d9c4c8e978898addc03","0x3e044b0aee07cc449bcf64e4d9707871","0x1"]}}'

controller_last.json

@tarrencev
Copy link
Contributor

Hey @MartianGreed,

You can use controller with katana using katana --slot.controller. It doesn't support the paymaster though.

We have a mock implementation of the paymaster rpc we use for testing at https://github.com/cartridge-gg/controller/blob/6650fbe880440ed8bbd87318e85dbcb3618239f3/packages/account_sdk/src/tests/runners/cartridge.rs#L40

It would be fairly simple to generalize that, making the executor (prefunded) account configurable, and wrapping the katana rpc with the proxy when --slot.controller is enabled.

Would you be interested in contributing that?

@MartianGreed
Copy link
Contributor Author

Hey, I tried katana with the --slot.controller option but I still went through the paymaster error. I've discussed about this with @glihm and I think @kariy is on his way to add mock implementation into katana directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants