Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cardano-wasm/examples/basic/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function do_async_work() {

let PREVIEW_MAGIC_NUMBER = 2;
let secretKey = "addr_sk1648253w4tf6fv5fk28dc7crsjsaw7d9ymhztd4favg3cwkhz7x8sl5u3ms";
let wallet = await api.wallet.testnet.restoreTestnetPaymentWalletFromSigningKeyBech32(PREVIEW_MAGIC_NUMBER, secretKey);
let wallet = await api.wallet.testnet.restorePaymentWalletFromSigningKeyBech32(PREVIEW_MAGIC_NUMBER, secretKey);
let bech32Address = await wallet.getAddressBech32();

log("Bech32 of address:");
Expand Down
6 changes: 3 additions & 3 deletions cardano-wasm/examples/simple-wallet/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function do_async_work() {

// State
let showPrivateKey = false;
let wallet = await api.wallet.testnet.generateTestnetPaymentWallet(42);
let wallet = await api.wallet.testnet.generatePaymentWallet(42);
let transactionInputs = [];
let transactionOutputs = [];

Expand Down Expand Up @@ -188,7 +188,7 @@ async function do_async_work() {

// Callbacks
async function generateAddress() {
wallet = await api.wallet.testnet.generateTestnetPaymentWallet(TESTNET_MAGIC);
wallet = await api.wallet.testnet.generatePaymentWallet(TESTNET_MAGIC);
await refresh();
}

Expand All @@ -205,7 +205,7 @@ async function do_async_work() {
async function loadPrivateKey() {
let pki = document.getElementById("private-key-input");
// @ts-ignore
wallet = await api.restoreTestnetPaymentWalletFromSigningKeyBech32(TESTNET_MAGIC, pki.value);
wallet = await api.wallet.testnet.restorePaymentWalletFromSigningKeyBech32(TESTNET_MAGIC, pki.value);
await refresh();
};

Expand Down
8 changes: 4 additions & 4 deletions cardano-wasm/lib-wrapper/cardano-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@ declare interface CardanoApi {
* @param networkMagic The network magic for the testnet.
* @returns A promise that resolves to a new `Wallet` object.
*/
generateTestnetPaymentWallet(networkMagic: number): Promise<Wallet>;
generatePaymentWallet(networkMagic: number): Promise<Wallet>;

/**
* Generate a stake wallet for testnet, given the testnet's network magic.
* @param networkMagic The network magic for the testnet.
* @returns A promise that resolves to a new `Wallet` object.
*/
generateTestnetStakeWallet(networkMagic: number): Promise<Wallet>;
generateStakeWallet(networkMagic: number): Promise<Wallet>;

/**
* Restore a testnet payment wallet from a Bech32 encoded signing key.
* @param networkMagic The network magic for the testnet.
* @param signingKeyBech32 The Bech32 encoded signing key.
* @returns A promise that resolves to a new `Wallet` object.
*/
restoreTestnetPaymentWalletFromSigningKeyBech32(networkMagic: number, signingKeyBech32: string): Promise<Wallet>;
restorePaymentWalletFromSigningKeyBech32(networkMagic: number, signingKeyBech32: string): Promise<Wallet>;

/**
* Restore a testnet stake wallet from Bech32 encoded signing keys.
Expand All @@ -114,7 +114,7 @@ declare interface CardanoApi {
* @param stakeSigningKeyBech32 The Bech32 encoded stake signing key.
* @returns A promise that resolves to a new `Wallet` object.
*/
restoreTestnetStakeWalletFromSigningKeyBech32(networkMagic: number, paymentSigningKeyBech32: string, stakeSigningKeyBech32: string): Promise<Wallet>;
restoreStakeWalletFromSigningKeyBech32(networkMagic: number, paymentSigningKeyBech32: string, stakeSigningKeyBech32: string): Promise<Wallet>;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cardano-wasm/lib-wrapper/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function createInitializer(getWasi, loadWasmModule, createClient) {
if (method.return.type === "fluent") {
// Fluent methods are synchronous and update the provider
// A fluent method is one that returns the same object type
target[method.name] = fixateArgs(method.params, function (...args) {
target[method.simpleName] = fixateArgs(method.params, function (...args) {
const previousProvider = currentHaskellValueProvider;
// We update the provider so that it resolves the previous provider and chains the next call
currentHaskellValueProvider = async () => {
Expand All @@ -124,7 +124,7 @@ export function createInitializer(getWasi, loadWasmModule, createClient) {
});
} else {
// Non-fluent methods (newObject or other) are async and apply the accumulated method calls
target[method.name] = fixateArgs(method.params, async function (...args) {
target[method.simpleName] = fixateArgs(method.params, async function (...args) {
const haskellValue = await currentHaskellValueProvider(); // Resolve accumulated method calls
const resultPromise = instance.exports[method.name](haskellValue, ...args); // Call the non-fluent method

Expand All @@ -149,7 +149,7 @@ export function createInitializer(getWasi, loadWasmModule, createClient) {
// Populate the main API object with static methods

function populateStaticMethod(method, target) {
target[method.name] = async function (...args) {
target[method.simpleName] = async function (...args) {
if (method.group) {
if (!target[method.group]) {
target[method.group] = {};
Expand Down
4 changes: 2 additions & 2 deletions cardano-wasm/npm-wrapper/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('Cardano API', () => {
const outputAddress = "addr_test1vzpfxhjyjdlgk5c0xt8xw26avqxs52rtf69993j4tajehpcue4v2v";

// Restore wallet and verify the address
const wallet = await api.wallet.testnet.restoreTestnetPaymentWalletFromSigningKeyBech32(PREVIEW_MAGIC_NUMBER, secretKey);
const wallet = await api.wallet.testnet.restorePaymentWalletFromSigningKeyBech32(PREVIEW_MAGIC_NUMBER, secretKey);

const bech32Address = await wallet.getAddressBech32();
expect(bech32Address).toBe(expectedAddress);

Expand Down
Loading
Loading