@@ -183,18 +183,34 @@ export interface KzgLibrary {
183
183
* while providing a stable external API.
184
184
*/
185
185
export type KzgLibraryLike = KzgLibrary | {
186
+ // kzg-wasm >= 0.5.0
186
187
blobToKZGCommitment : ( blob : string ) => string ;
187
188
computeBlobKZGProof : ( blob : string , commitment : string ) => string ;
189
+ } | {
190
+ // micro-ecc-signer
191
+ blobToKzgCommitment : ( blob : string ) => string | Uint8Array ;
192
+ computeBlobProof : ( blob : string , commitment : string ) => string | Uint8Array ;
188
193
} ;
189
194
190
195
function getKzgLibrary ( kzg : KzgLibraryLike ) : KzgLibrary {
196
+
191
197
const blobToKzgCommitment = ( blob : Uint8Array ) => {
192
- // API <0.5.0; blobToKzgCommitment(Uint8Array) => Uint8Array
193
- if ( "blobToKzgCommitment" in kzg && typeof ( kzg . blobToKzgCommitment ) === "function" ) {
194
- return kzg . blobToKzgCommitment ( blob ) ;
198
+
199
+ if ( "computeBlobProof" in kzg ) {
200
+ // micro-ecc-signer; check for computeBlobProof since this API
201
+ // expects a string while the kzg-wasm below expects a Unit8Array
202
+
203
+ if ( "blobToKzgCommitment" in kzg && typeof ( kzg . blobToKzgCommitment ) === "function" ) {
204
+ return getBytes ( kzg . blobToKzgCommitment ( hexlify ( blob ) ) )
205
+ }
206
+
207
+ } else if ( "blobToKzgCommitment" in kzg && typeof ( kzg . blobToKzgCommitment ) === "function" ) {
208
+ // kzg-wasm <0.5.0; blobToKzgCommitment(Uint8Array) => Uint8Array
209
+
210
+ return getBytes ( kzg . blobToKzgCommitment ( blob ) ) ;
195
211
}
196
212
197
- // API >= 0.5.0; blobToKZGCommitment(string) => string
213
+ // kzg-wasm >= 0.5.0; blobToKZGCommitment(string) => string
198
214
if ( "blobToKZGCommitment" in kzg && typeof ( kzg . blobToKZGCommitment ) === "function" ) {
199
215
return getBytes ( kzg . blobToKZGCommitment ( hexlify ( blob ) ) ) ;
200
216
}
@@ -203,12 +219,18 @@ function getKzgLibrary(kzg: KzgLibraryLike): KzgLibrary {
203
219
} ;
204
220
205
221
const computeBlobKzgProof = ( blob : Uint8Array , commitment : Uint8Array ) => {
206
- // API <0.5.0; computeBlobKzgProof(Uint8Array, Uint8Array) => Uint8Array
222
+
223
+ // micro-ecc-signer
224
+ if ( "computeBlobProof" in kzg && typeof ( kzg . computeBlobProof ) === "function" ) {
225
+ return getBytes ( kzg . computeBlobProof ( hexlify ( blob ) , hexlify ( commitment ) ) )
226
+ }
227
+
228
+ // kzg-wasm <0.5.0; computeBlobKzgProof(Uint8Array, Uint8Array) => Uint8Array
207
229
if ( "computeBlobKzgProof" in kzg && typeof ( kzg . computeBlobKzgProof ) === "function" ) {
208
230
return kzg . computeBlobKzgProof ( blob , commitment ) ;
209
231
}
210
232
211
- // API >= 0.5.0; computeBlobKZGProof(string, string) => string
233
+ // kzg-wasm >= 0.5.0; computeBlobKZGProof(string, string) => string
212
234
if ( "computeBlobKZGProof" in kzg && typeof ( kzg . computeBlobKZGProof ) === "function" ) {
213
235
return getBytes ( kzg . computeBlobKZGProof ( hexlify ( blob ) , hexlify ( commitment ) ) ) ;
214
236
}
@@ -749,7 +771,7 @@ export class Transaction implements TransactionLike<string> {
749
771
case 3 : case "cancun" : case "eip-4844" :
750
772
this . #type = 3 ;
751
773
break ;
752
- case 4 : case "eip-7702" :
774
+ case 4 : case "pectra" : case " eip-7702" :
753
775
this . #type = 4 ;
754
776
break ;
755
777
default :
0 commit comments