Created
April 8, 2024 18:27
-
-
Save thelissimus/36d6bf8b180ccc8aff24f35f9e003fc5 to your computer and use it in GitHub Desktop.
ReScript FFI example bindings for ethers.
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
@module("ethers") external decodeBase58Unsafe: string => bigint = "decodeBase58" | |
@get external code: Js.Exn.t => string = "code" | |
@get external argument: Js.Exn.t => string = "argument" | |
@get external value: Js.Exn.t => string = "value" | |
@get external shortMessage: Js.Exn.t => string = "shortMessage" | |
type decodeBase58Error = | |
| UnknownError | |
| InputError({ | |
code: string, | |
argument: string, | |
value: string, | |
shortMessage: string, | |
}) | |
let decodeBase58 = s => { | |
try { | |
Ok(decodeBase58Unsafe(s)) | |
} catch { | |
| Js.Exn.Error(err) => | |
Error( | |
InputError({ | |
code: code(err), | |
argument: argument(err), | |
value: value(err), | |
shortMessage: shortMessage(err), | |
}), | |
) | |
| _ => Error(UnknownError) | |
} | |
} |
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
let decodeBase58Unsafe: string => bigint | |
type decodeBase58Error = | |
| UnknownError | |
| InputError({ | |
code: string, | |
argument: string, | |
value: string, | |
shortMessage: string, | |
}) | |
let decodeBase58: string => result<bigint, decodeBase58Error> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment