candidate: He was appointed as Attorney General of the Territory of Orleans after the Louisiana Purchase ; he also helped untangle layers of French and Spanish colonial law in the territory and subsequent state of Louisiana .