Skip to content

Commit

Permalink
export walletFromSeed (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljttl3q04t authored Jul 29, 2024
1 parent ac64bff commit 5f72802
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions packages/translucent/src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export type {
InputBuilderResult as CInputBuilderResult,
MintBuilderResult as CMintBuilderResult,
NativeScript as CNativeScript,
NativeScripts as CNativeScripts,
PlutusData as CPlutusData,
PlutusScript as CPlutusScript,
PlutusV2Script as CPlutusV2Script,
Expand All @@ -110,6 +111,7 @@ export type {
ScriptRef as CScriptRef,
StakeCredential as CStakeCredential,
Transaction as CTransaction,
TransactionBody as CTransactionBody,
TransactionBuilder as CTransactionBuilder,
TransactionBuilderConfig as CTransactionBuilderConfig,
TransactionHash as CTransactionHash,
Expand All @@ -121,6 +123,7 @@ export type {
TransactionWitnessSet as CTransactionWitnessSet,
Value as CValue,
WithdrawalBuilderResult as CWithdrawalBuilderResult,
Withdrawals as CWithdrawals,
} from "@dcspark/cardano-multiplatform-lib-nodejs";

export {
Expand Down
1 change: 1 addition & 0 deletions packages/translucent/src/misc/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { walletFromSeed } from "./wallet";
13 changes: 8 additions & 5 deletions packages/translucent/src/misc/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {
Address,
C,
CNativeScripts,
CTransaction,
CTransactionBody,
CWithdrawals,
fromHex,
getAddressDetails,
KeyHash,
Expand All @@ -10,8 +13,8 @@ import {
RewardAddress,
toHex,
UTxO,
} from "../mod.ts";
import { mnemonicToEntropy } from "./bip39.ts";
} from "../mod";
import { mnemonicToEntropy } from "./bip39";

type FromSeed = {
address: Address;
Expand Down Expand Up @@ -114,7 +117,7 @@ export function discoverOwnUsedTxKeyHashes(
const txBody = tx.body();

// key hashes from certificates
function keyHashFromCert(txBody: C.TransactionBody) {
function keyHashFromCert(txBody: CTransactionBody) {
const certs = txBody.certs();
if (!certs) return;
for (let i = 0; i < certs.len(); i++) {
Expand Down Expand Up @@ -172,7 +175,7 @@ export function discoverOwnUsedTxKeyHashes(
// key hashes from withdrawals

const withdrawals = txBody.withdrawals();
function keyHashFromWithdrawal(withdrawals: C.Withdrawals) {
function keyHashFromWithdrawal(withdrawals: CWithdrawals) {
const rewardAddresses = withdrawals.keys();
for (let i = 0; i < rewardAddresses.len(); i++) {
const credential = rewardAddresses.get(i).payment_cred();
Expand All @@ -185,7 +188,7 @@ export function discoverOwnUsedTxKeyHashes(

// key hashes from scripts
const scripts = tx.witness_set().native_scripts();
function keyHashFromScript(scripts: C.NativeScripts) {
function keyHashFromScript(scripts: CNativeScripts) {
for (let i = 0; i < scripts.len(); i++) {
const script = scripts.get(i);
if (script.kind() === 0) {
Expand Down
7 changes: 4 additions & 3 deletions packages/translucent/src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export { walletFromSeed } from "./misc/mod";
export * from "./core/mod";
export * from "./translucent/mod";
export * from "./plutus/mod";
export * from "./provider/mod";
export * from "./translucent/mod";
export * from "./types/mod";
export * from "./utils/mod";
export * from "./wallets/mod";
export * from "./plutus/mod";
export * from "./wallets/mod";

0 comments on commit 5f72802

Please sign in to comment.