PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@dfinity/agent/lib/esm

Просмотр файла: fetch_candid.js

import { Principal } from '@dfinity/principal';
import * as CanisterStatus from './canisterStatus/index';
import { HttpAgent } from './agent/http';
import { Actor } from './actor';
/**
 * Retrieves the Candid interface for the specified canister.
 *
 * @param agent The agent to use for the request (usually an `HttpAgent`)
 * @param canisterId A string corresponding to the canister ID
 * @returns Candid source code
 */
export async function fetchCandid(canisterId, agent) {
    if (!agent) {
        // Create an anonymous `HttpAgent` (adapted from Candid UI)
        agent = await HttpAgent.create();
    }
    // Attempt to use canister metadata
    const status = await CanisterStatus.request({
        agent,
        canisterId: Principal.fromText(canisterId),
        paths: ['candid'],
    });
    const candid = status.get('candid');
    if (candid) {
        return candid;
    }
    // Use `__get_candid_interface_tmp_hack` for canisters without Candid metadata
    const tmpHackInterface = ({ IDL }) => IDL.Service({
        __get_candid_interface_tmp_hack: IDL.Func([], [IDL.Text], ['query']),
    });
    const actor = Actor.createActor(tmpHackInterface, { agent, canisterId });
    return (await actor.__get_candid_interface_tmp_hack());
}
//# sourceMappingURL=fetch_candid.js.map

Выполнить команду


Для локальной разработки. Не используйте в интернете!