/** * A resource account is used to manage resources independent of an account managed by a user. * This contains several utilities to make using resource accounts more effective. * * A dev wishing to use resource accounts for a liquidity pool, would likely do the following: * 1. Create a new account using `Resourceaccount::create_resource_account`. This creates the * account, stores the `signer_cap` within a `Resourceaccount::Container`, and rotates the key to * the current accounts authentication key or a provided authentication key. * 2. Define the LiquidityPool module's address to be the same as the resource account. * 3. Construct a ModuleBundle payload for the resource account using the authentication key used * in step 1. * 4. In the LiquidityPool module's `init_module` function, call `retrieve_resource_account_cap` * which will retrive the `signer_cap` and rotate the resource account's authentication key to * `0x0`, effectively locking it off. * 5. When adding a new coin, the liquidity pool will load the capability and hence the signer to * register and store new LiquidityCoin resources. * * Code snippets to help: * ``` * fun init_module(source: &signer) { * let dev_address = @DEV_ADDR; * let signer_cap = retrieve_resource_account_cap(&source, dev_address); * let lp_signer = create_signer_with_capability(&signer_cap); * let lp = LiquidityPoolInfo { signer_cap: signer_cap, ... }; * move_to(&lp_signer, lp); * } * ``` * * Later on during a coin registration: * ``` * public fun add_coin(lp: &LP, x: Coin, y: Coin) { * if(!exists(LP::Address(lp), LiquidityCoin)) { * let mint, burn = Coin::initialize>(...); * move_to(&create_signer_with_capability(&lp.cap), LiquidityCoin{ mint, burn }); * } * ... * } * ``` * * **Module ID:** `0x1::resource_account` * * @module */ import type * as p from "@movingco/prelude"; /** Type name: `0x1::resource_account::Container` */ export interface IContainer { store: { data: ReadonlyArray<{ key: p.RawAddress; value: { account: p.RawAddress; }; }>; }; } /** Payload arguments for {@link entry.create_resource_account}. */ export declare type CreateResourceAccountArgs = { args: { /** IDL type: `Vector(U8)` */ seed: p.ByteString; /** IDL type: `Vector(U8)` */ optional_auth_key: p.ByteString; }; }; export * as entry from "./entry.js"; export * as entryNames from "./entryNames.js"; export { idl } from "./idl.js"; export * as payloads from "./payloads.js"; /** The address of the module. */ export declare const ADDRESS: "0x1"; /** The full module name. */ export declare const FULL_NAME: "0x1::resource_account"; /** The name of the module. */ export declare const NAME: "resource_account"; /** Module ID information. */ export declare const id: { readonly ADDRESS: "0x1"; readonly FULL_NAME: "0x1::resource_account"; readonly NAME: "resource_account"; }; export * as errors from "./errors.js"; /** Module error codes. */ export declare const errorCodes: { readonly "1": { readonly name: "ECONTAINER_NOT_PUBLISHED"; readonly doc: "Container resource not found in account"; }; }; /** All module function IDLs. */ export declare const functions: { readonly create_resource_account: { readonly name: "create_resource_account"; readonly doc: "Creates a new resource account and rotates the authentication key to either\nthe optional auth key if it is non-empty (though auth keys are 32-bytes)\nor the source accounts current auth key."; readonly ty_args: readonly []; readonly args: readonly [{ readonly name: "seed"; readonly ty: { readonly vector: "u8"; }; }, { readonly name: "optional_auth_key"; readonly ty: { readonly vector: "u8"; }; }]; }; }; /** All struct types with ability `key`. */ export declare const resources: { readonly Container: "0x1::resource_account::Container"; }; /** All struct types. */ export declare const structs: { readonly Container: "0x1::resource_account::Container"; }; /** * A resource account is used to manage resources independent of an account managed by a user. * This contains several utilities to make using resource accounts more effective. * * A dev wishing to use resource accounts for a liquidity pool, would likely do the following: * 1. Create a new account using `Resourceaccount::create_resource_account`. This creates the * account, stores the `signer_cap` within a `Resourceaccount::Container`, and rotates the key to * the current accounts authentication key or a provided authentication key. * 2. Define the LiquidityPool module's address to be the same as the resource account. * 3. Construct a ModuleBundle payload for the resource account using the authentication key used * in step 1. * 4. In the LiquidityPool module's `init_module` function, call `retrieve_resource_account_cap` * which will retrive the `signer_cap` and rotate the resource account's authentication key to * `0x0`, effectively locking it off. * 5. When adding a new coin, the liquidity pool will load the capability and hence the signer to * register and store new LiquidityCoin resources. * * Code snippets to help: * ``` * fun init_module(source: &signer) { * let dev_address = @DEV_ADDR; * let signer_cap = retrieve_resource_account_cap(&source, dev_address); * let lp_signer = create_signer_with_capability(&signer_cap); * let lp = LiquidityPoolInfo { signer_cap: signer_cap, ... }; * move_to(&lp_signer, lp); * } * ``` * * Later on during a coin registration: * ``` * public fun add_coin(lp: &LP, x: Coin, y: Coin) { * if(!exists(LP::Address(lp), LiquidityCoin)) { * let mint, burn = Coin::initialize>(...); * move_to(&create_signer_with_capability(&lp.cap), LiquidityCoin{ mint, burn }); * } * ... * } * ``` */ export declare const moduleDefinition: { readonly errorCodes: { readonly "1": { readonly name: "ECONTAINER_NOT_PUBLISHED"; readonly doc: "Container resource not found in account"; }; }; readonly functions: { readonly create_resource_account: { readonly name: "create_resource_account"; readonly doc: "Creates a new resource account and rotates the authentication key to either\nthe optional auth key if it is non-empty (though auth keys are 32-bytes)\nor the source accounts current auth key."; readonly ty_args: readonly []; readonly args: readonly [{ readonly name: "seed"; readonly ty: { readonly vector: "u8"; }; }, { readonly name: "optional_auth_key"; readonly ty: { readonly vector: "u8"; }; }]; }; }; readonly resources: { readonly Container: "0x1::resource_account::Container"; }; readonly structs: { readonly Container: "0x1::resource_account::Container"; }; readonly ADDRESS: "0x1"; readonly FULL_NAME: "0x1::resource_account"; readonly NAME: "resource_account"; }; //# sourceMappingURL=index.d.ts.map