Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ concurrency:
env:
GH_TOKEN: ${{ github.token }}
# TODO: Remove below env once stable release of starknet foundry is available
SNFOUNDRY_SHA: 3d227d0aa6bf896f912144088f3c7bf0424f4c13
SNFOUNDRY_SHA: 208348df1ef1bfa4e332af0d3997d5e5fc4c57d4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some time ago we did a breaking change (by mistake) in sncast and removed command field in from json response. It's a commit from foundry-rs/starknet-foundry#3551 which restores it.


jobs:
test_and_lint:
runs-on: macos-15
env:
DEVNET_SHA: aafa74e4297734bacba72d0faa7c711eacecfc7a # v0.5.0-rc.1
DEVNET_SHA: b4460c7b5d0679632d471bf72b9713805d38c0f0 # v0.6.0
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
Expand Down
13 changes: 5 additions & 8 deletions Tests/StarknetTests/Utils/DevnetClient/DevnetClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Foundation

protocol DevnetClientProtocol {
var rpcUrl: String { get }
var mintUrl: String { get }

var host: String { get }
var port: Int { get }
Expand Down Expand Up @@ -155,7 +154,6 @@ func makeDevnetClient() -> DevnetClientProtocol {
let seed: Int
let baseUrl: String
let rpcUrl: String
let mintUrl: String

let constants: DevnetClientConstants.Type = DevnetClientConstants.self

Expand All @@ -166,7 +164,6 @@ func makeDevnetClient() -> DevnetClientProtocol {

baseUrl = "http://\(host):\(port)"
rpcUrl = "\(baseUrl)/rpc"
mintUrl = "\(baseUrl)/mint"

devnetPath = ProcessInfo.processInfo.environment["DEVNET_PATH"] ?? "starknet-devnet"
scarbPath = ProcessInfo.processInfo.environment["SCARB_PATH"] ?? "scarb"
Expand Down Expand Up @@ -305,18 +302,18 @@ func makeDevnetClient() -> DevnetClientProtocol {
public func prefundAccount(address: Felt, amount: BigUInt, unit: StarknetPriceUnit) async throws {
try guardDevnetIsRunning()

let url = URL(string: mintUrl)!
let url = URL(string: rpcUrl)!
var request = URLRequest(url: url)
request.httpMethod = "POST"

let payload = PrefundPayload(address: address, amount: amount, unit: unit)

let mintPayload = PrefundPayload(address: address, amount: amount, unit: unit)
let requestPayload = DevnetMintRequest(params: mintPayload)
// TODO(#209): Once we can use UInt128, we can simply set
// body as `request.httpBody = try JSONEncoder().encode(payload)`
// body as `request.httpBody = try JSONEncoder().encode(requestPayload)`
// Following adjustment is needed to remove quotes from the amount field
// in the JSON body, because ATM we can't use UInt128 in the payload.

let data = try JSONEncoder().encode(payload)
let data = try JSONEncoder().encode(requestPayload)

guard var json = String(data: data, encoding: .utf8) else {
throw DevnetClientError.prefundError
Expand Down
14 changes: 14 additions & 0 deletions Tests/StarknetTests/Utils/DevnetClient/DevnetClientModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ struct PrefundPayload: Codable {
}
}

struct DevnetMintRequest: Codable {
let jsonrpc: String
let method: String
let params: PrefundPayload
let id: Int

init(params: PrefundPayload, id: Int = 0) {
self.jsonrpc = "2.0"
self.method = "devnet_mint"
self.params = params
self.id = id
}
}

// Simplified receipt that is intended to support any JSON-RPC version starting 0.3,
// to avoid DevnetClient relying on StarknetTransactionReceipt.
// Only use it for checking whether a transaction was successful.
Expand Down
Loading