-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e942a9d
commit 4df4ae7
Showing
4 changed files
with
47 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { CompiledContract, RawCalldata } from '../types'; | ||
import { parse } from './json'; | ||
import { isHex, toBN, toHex } from './number'; | ||
import { compressProgram } from './stark'; | ||
|
||
export function wait(delay: number) { | ||
return new Promise((res) => { | ||
setTimeout(res, delay); | ||
}); | ||
} | ||
|
||
export function parseCalldata(calldata: RawCalldata = []) { | ||
return calldata.map((data) => { | ||
if (typeof data === 'string' && isHex(data as string)) { | ||
return data; | ||
} | ||
return toHex(toBN(data)); | ||
}); | ||
} | ||
|
||
export function parseContract(contract: CompiledContract | string) { | ||
const parsedContract = | ||
typeof contract === 'string' ? (parse(contract) as CompiledContract) : contract; | ||
return { | ||
...parsedContract, | ||
program: compressProgram(parsedContract.program), | ||
}; | ||
} |