@@ -107,37 +107,45 @@ echo "[spm-fixes] Completed shared-features-spm fixes"
107107
108108# 2) Patch Web3 EthereumPrivateKey initializers to accept Data as [UInt8]
109109patch_private_key_calls () {
110- local base=" $1 /SourcePackages/checkouts/shared-features-spm"
111- [[ -d " $base " ]] || return 0
112- echo " [spm-fixes] Patching EthereumPrivateKey initializers under $base "
113- # Known occurrences in sources
114- local f1=" $base /Sources/SSFTransferService/WalletConnectTransferServiceAssembly.swift"
115- local f2=" $base /Sources/SSFTransferService/InternalServices/Ethereum/EthereumTransferServiceAssembly.swift"
116- if [[ -f " $f1 " ]]; then
117- # Strict replacement
118- /usr/bin/sed -i ' ' -e ' s/EthereumPrivateKey(privateKey: privateKey\.bytes)/EthereumPrivateKey(privateKey: Array(privateKey))/' " $f1 " || true
119- # Whitespace-tolerant replacement
120- /usr/bin/sed -E -i ' ' -e ' s/EthereumPrivateKey\(\s*privateKey:\s*privateKey\s*\.\s*bytes\s*\)/EthereumPrivateKey(privateKey: Array(privateKey))/' " $f1 " || true
121- # Fallback: replace property access broadly within this file only
122- /usr/bin/sed -E -i ' ' -e ' s/privateKey\s*\.\s*bytes/Array(privateKey)/g' " $f1 " || true
123- fi
124- if [[ -f " $f2 " ]]; then
125- # Strict replacement
126- /usr/bin/sed -i ' ' -e ' s/EthereumPrivateKey(privateKey: secretKeyData\.bytes)/EthereumPrivateKey(privateKey: Array(secretKeyData))/' " $f2 " || true
127- # Whitespace-tolerant replacement
128- /usr/bin/sed -E -i ' ' -e ' s/EthereumPrivateKey\(\s*privateKey:\s*secretKeyData\s*\.\s*bytes\s*\)/EthereumPrivateKey(privateKey: Array(secretKeyData))/' " $f2 " || true
129- # Fallback: replace property access broadly within this file only
130- /usr/bin/sed -E -i ' ' -e ' s/secretKeyData\s*\.\s*bytes/Array(secretKeyData)/g' " $f2 " || true
131- fi
110+ local root=" $1 "
111+ local patched=0
112+ # Look for both known files under any shared-features-spm checkout below the root
113+ while IFS= read -r -d ' ' file; do
114+ echo " [spm-fixes] Patching Data.bytes -> Array(data) in: $file "
115+ # Apply several tolerant patterns
116+ /usr/bin/sed -E -i ' ' \
117+ -e ' s/EthereumPrivateKey\(\s*privateKey:\s*privateKey\s*\.\s*bytes\s*\)/EthereumPrivateKey(privateKey: Array(privateKey))/' \
118+ -e ' s/EthereumPrivateKey\(\s*privateKey:\s*secretKeyData\s*\.\s*bytes\s*\)/EthereumPrivateKey(privateKey: Array(secretKeyData))/' \
119+ -e ' s/([[:<:]]privateKey[[:>:]]\s*)\.\s*bytes/Array(\1)/g' \
120+ -e ' s/([[:<:]]secretKeyData[[:>:]]\s*)\.\s*bytes/Array(\1)/g' \
121+ " $file " || true
122+
123+ # Report remaining occurrences if any
124+ if /usr/bin/grep -n " \.bytes" " $file " > /dev/null 2>&1 ; then
125+ echo " [spm-fixes] After patch, '.bytes' still present in $file :" >&2
126+ /usr/bin/grep -n " \.bytes" " $file " | sed -n ' 1,4p' >&2 || true
127+ else
128+ patched=$(( patched+ 1 ))
129+ fi
130+ done < <( /usr/bin/find " $root " -type f \( \
131+ -path " */checkouts/shared-features-spm/Sources/SSFTransferService/WalletConnectTransferServiceAssembly.swift" -o \
132+ -path " */checkouts/shared-features-spm/Sources/SSFTransferService/InternalServices/Ethereum/EthereumTransferServiceAssembly.swift" \
133+ \) -print0 2> /dev/null)
134+
135+ echo " [spm-fixes] Patched $patched file(s) under $root "
132136}
133137
134- # Apply in workspace and DerivedData
138+ # Apply in workspace and common DerivedData roots
135139patch_private_key_calls " $BASE_DIR "
136- for dd in " $HOME /Library/Developer/Xcode/DerivedData" /* " $BASE_DIR /DerivedData" /* ; do
137- patch_private_key_calls " $dd "
140+ for dd in " $HOME /Library/Developer/Xcode/DerivedData" " $BASE_DIR /DerivedData" ; do
141+ [[ -d " $dd " ]] || continue
142+ for sub in " $dd " /* ; do
143+ [[ -d " $sub " ]] || continue
144+ patch_private_key_calls " $sub "
145+ done
138146done
139147
140- echo " [spm-fixes] Completed EthereumPrivateKey call patches"
148+ echo " [spm-fixes] Completed EthereumPrivateKey call patches (with verification) "
141149
142150# 3) Convert SSFCrypto AddressFactory from enum to struct (allow instantiation)
143151patch_address_factory_struct () {
0 commit comments