Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
getWalletAddress
effect to NamiWallet
- Loading branch information
Showing
5 changed files
with
53 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
"use strict"; | ||
|
||
const Buffer = require("buffer/").Buffer; | ||
const serLib = require("@emurgo/cardano-serialization-lib-nodejs"); | ||
|
||
// _hexToBytes :: Hex -> Buffer | ||
exports._hexToBytes = (hex) => Buffer.from(hex, "hex"); | ||
|
||
// _addrFromBytes :: Buffer -> Address | ||
exports._addrFromBytes = (buf) => { | ||
const addr = serLib.Address.from_bytes(buf); | ||
const baseAddr = serLib.BaseAddress.from_address(addr); | ||
return { | ||
AddrType: { | ||
network: addr.network_id(), | ||
stake: baseAddr.stake_cred(), | ||
payment: baseAddr.payment_cred(), | ||
}, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
module Lib.Serialization | ||
( Buffer | ||
, Hex(..) | ||
, _addrFromBytes | ||
, _hexToBytes | ||
) where | ||
|
||
import Prelude | ||
import Types.Transaction (Address) | ||
|
||
newtype Hex | ||
= Hex String | ||
|
||
foreign import data Buffer :: Type | ||
|
||
foreign import _hexToBytes :: Hex -> Buffer | ||
|
||
foreign import _addrFromBytes :: Buffer -> Address |
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