@neardefi/shade-agent-js
Version:
This library is intended to be used in conjunction with the [shade agent template](https://github.com/NearDeFi/shade-agent-template/).
65 lines (63 loc) • 2.3 kB
text/typescript
/**
* @typedef {Object} ContractArgs
* @property {string} methodName - The name of the method to call.
* @property {Object} args - The arguments to pass to the method.
*/
type ContractArgs = {
methodName: string;
args: Record<string, any>;
};
/**
* Calls a method on the agent account instance inside the API
*
* @param {string} methodName - The name of the agent method to call
* @param {any} args - Arguments to pass to the agent account method
* @returns A promise that resolves with the result of the agent method call.
*/
declare function agent(methodName: string, args?: any): Promise<any>;
/**
* Retrieves the account ID of the agent.
*
* @returns {Promise<any>} A promise that resolves to the agent's account ID.
*/
declare const agentAccountId: () => Promise<{
accountId: string;
}>;
/**
* Retrieves the agent's record from the agent contract
*
* @returns {Promise<any>} A promise that resolves to the agent's account ID.
*/
declare const agentInfo: () => Promise<{
codehash: string;
checksum: string;
}>;
/**
* Contract view from agent account inside the API
*
* @param {ContractArgs} args - The arguments for the contract view method.
* @returns A promise that resolves with the result of the view method.
*/
declare const agentView: (args: ContractArgs) => Promise<any>;
/**
* Contract call from agent account inside the API
*
* @param {ContractArgs} args - The arguments for the contract call method.
* @returns A promise that resolves with the result of the call method.
*/
declare const agentCall: (args: ContractArgs) => Promise<any>;
/**
* Requests a digital signature from the agent for a given payload and path.
*
* @param {Object} params - The parameters for the signature request.
* @param {string} params.path - The path associated with the signature request.
* @param {string} params.payload - The payload to be signed.
* @param {string} params.keyType - The type of key to use for signing (default is 'Ecdsa').
* @returns A promise that resolves with the result of the signature request.
*/
declare const requestSignature: ({ path, payload, keyType, }: {
path: string;
payload: string;
keyType: string;
}) => Promise<any>;
export { agent, agentAccountId, agentCall, agentInfo, agentView, requestSignature };