@junobuild/functions 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"../../../chunk-5NZMOUKF.js";import{g as c}from"../../../chunk-EMQQE34V.js";import{a as t}from"../../../chunk-TZVF5LQY.js";import"../../../chunk-7B6WU32N.js";import{i as n,j as e}from"../../../chunk-HANEPD6T.js";import"../../../chunk-4C666HHU.js";var i=t.required();var s=class extends a{constructor(r){i.parse(r),super({canisterId:r.canisterId})}icrc1BalanceOf=async({account:r})=>await c({canisterId:this.canisterId,method:"icrc1_balance_of",args:[[e.Account,r]],result:e.Tokens});icrc1Transfer=async({args:r})=>await c({canisterId:this.canisterId,method:"icrc1_transfer",args:[[e.TransferArg,r]],result:e.TransferResult});icrc2TransferFrom=async({args:r})=>await c({canisterId:this.canisterId,method:"icrc2_transfer_from",args:[[e.TransferFromArgs,r]],result:e.TransferFromResult})};export{i as IcrcCanisterOptionsSchema,n as IcrcIndexNgIdl,s as IcrcLedgerCanister,e as IcrcLedgerIdl};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/canisters/ledger/icrc/schemas.ts", "../../../src/canisters/ledger/icrc/ledger.canister.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as z from 'zod';\nimport {CanisterOptionsSchema} from '../../schemas';\n\n/**\n * @see CanisterOptions\n */\nexport const IcrcCanisterOptionsSchema = CanisterOptionsSchema.required();\n\n/**\n * The options to initialize an Icrc canister.\n */\nexport type IcrcCanisterOptions = z.infer<typeof IcrcCanisterOptionsSchema>;\n", "import {call} from '../../../ic-cdk/call.ic-cdk';\nimport {Canister} from '../../_canister';\nimport {type IcrcLedgerDid, IcrcLedgerIdl} from '../../declarations';\nimport {type IcrcCanisterOptions, IcrcCanisterOptionsSchema} from './schemas';\n\n/**\n * Provides a simple interface to interact with an ICRC Ledger,\n * when developing Juno Serverless Functions in TypeScript.\n *\n * @param {CanisterOptions} [options] - The options providing the ICRC ledger canister ID.\n */\nexport class IcrcLedgerCanister extends Canister {\n constructor(options: IcrcCanisterOptions) {\n IcrcCanisterOptionsSchema.parse(options);\n\n super({canisterId: options.canisterId});\n }\n\n /**\n * Returns the balance of an ICRC account.\n *\n * @param {IcrcLedgerDid.Account} account - The account to query.\n * @returns {Promise<IcrcLedgerDid.Tokens>} The token balance for the account.\n */\n icrc1BalanceOf = async ({\n account\n }: {\n account: IcrcLedgerDid.Account;\n }): Promise<IcrcLedgerDid.Tokens> =>\n await call<
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type * as z from 'zod';\nimport {CanisterOptionsSchema} from '../../schemas';\n\n/**\n * @see CanisterOptions\n */\nexport const IcrcCanisterOptionsSchema = CanisterOptionsSchema.required();\n\n/**\n * The options to initialize an Icrc canister.\n */\nexport type IcrcCanisterOptions = z.infer<typeof IcrcCanisterOptionsSchema>;\n", "import {call} from '../../../ic-cdk/call.ic-cdk';\nimport {Canister} from '../../_canister';\nimport {type IcrcLedgerDid, IcrcLedgerIdl} from '../../declarations';\nimport {type IcrcCanisterOptions, IcrcCanisterOptionsSchema} from './schemas';\n\n/**\n * Provides a simple interface to interact with an ICRC Ledger,\n * when developing Juno Serverless Functions in TypeScript.\n *\n * @param {CanisterOptions} [options] - The options providing the ICRC ledger canister ID.\n */\nexport class IcrcLedgerCanister extends Canister {\n constructor(options: IcrcCanisterOptions) {\n IcrcCanisterOptionsSchema.parse(options);\n\n super({canisterId: options.canisterId});\n }\n\n /**\n * Returns the balance of an ICRC account.\n *\n * @param {IcrcLedgerDid.Account} account - The account to query.\n * @returns {Promise<IcrcLedgerDid.Tokens>} The token balance for the account.\n */\n icrc1BalanceOf = async ({\n account\n }: {\n account: IcrcLedgerDid.Account;\n }): Promise<IcrcLedgerDid.Tokens> =>\n await call<IcrcLedgerDid.Tokens>({\n canisterId: this.canisterId,\n method: 'icrc1_balance_of',\n args: [[IcrcLedgerIdl.Account, account]],\n result: IcrcLedgerIdl.Tokens\n });\n\n /**\n * Transfers tokens using the ICRC-1 `icrc1_transfer` method.\n *\n * Use this to send tokens from the caller's account to another account\n * when writing Juno Serverless Functions in TypeScript.\n *\n * @param {IcrcLedgerDid.TransferArg} args - Transfer arguments (amount, fee, to, memo, created_at_time, etc.).\n * @returns {Promise<IcrcLedgerDid.TransferResult>} The result of the transfer.\n */\n icrc1Transfer = async ({\n args\n }: {\n args: IcrcLedgerDid.TransferArg;\n }): Promise<IcrcLedgerDid.TransferResult> =>\n await call<IcrcLedgerDid.TransferResult>({\n canisterId: this.canisterId,\n method: 'icrc1_transfer',\n args: [[IcrcLedgerIdl.TransferArg, args]],\n result: IcrcLedgerIdl.TransferResult\n });\n\n /**\n * Transfers tokens using the ICRC-2 `icrc2_transfer_from` method.\n *\n * Allows transferring tokens from another user's account when an approval\n * has previously been granted via `icrc2_approve`.\n *\n * @param {IcrcLedgerDid.TransferFromArgs} args - Transfer-from arguments (amount, from_subaccount, spender, etc.).\n * @returns {Promise<IcrcLedgerDid.TransferFromResult>} The result of the transfer-from operation.\n */\n icrc2TransferFrom = async ({\n args\n }: {\n args: IcrcLedgerDid.TransferFromArgs;\n }): Promise<IcrcLedgerDid.TransferFromResult> =>\n await call<IcrcLedgerDid.TransferFromResult>({\n canisterId: this.canisterId,\n method: 'icrc2_transfer_from',\n args: [[IcrcLedgerIdl.TransferFromArgs, args]],\n result: IcrcLedgerIdl.TransferFromResult\n });\n}\n"],
|
|
5
|
+
"mappings": "oQAMO,IAAMA,EAA4BC,EAAsB,SAAS,ECKjE,IAAMC,EAAN,cAAiCC,CAAS,CAC/C,YAAYC,EAA8B,CACxCC,EAA0B,MAAMD,CAAO,EAEvC,MAAM,CAAC,WAAYA,EAAQ,UAAU,CAAC,CACxC,CAQA,eAAiB,MAAO,CACtB,QAAAE,CACF,IAGE,MAAMC,EAA2B,CAC/B,WAAY,KAAK,WACjB,OAAQ,mBACR,KAAM,CAAC,CAACC,EAAc,QAASF,CAAO,CAAC,EACvC,OAAQE,EAAc,MACxB,CAAC,EAWH,cAAgB,MAAO,CACrB,KAAAC,CACF,IAGE,MAAMF,EAAmC,CACvC,WAAY,KAAK,WACjB,OAAQ,iBACR,KAAM,CAAC,CAACC,EAAc,YAAaC,CAAI,CAAC,EACxC,OAAQD,EAAc,cACxB,CAAC,EAWH,kBAAoB,MAAO,CACzB,KAAAC,CACF,IAGE,MAAMF,EAAuC,CAC3C,WAAY,KAAK,WACjB,OAAQ,sBACR,KAAM,CAAC,CAACC,EAAc,iBAAkBC,CAAI,CAAC,EAC7C,OAAQD,EAAc,kBACxB,CAAC,CACL",
|
|
6
6
|
"names": ["IcrcCanisterOptionsSchema", "CanisterOptionsSchema", "IcrcLedgerCanister", "Canister", "options", "IcrcCanisterOptionsSchema", "account", "call", "icrc_ledger_did_idl_exports", "args"]
|
|
7
7
|
}
|
package/package.json
CHANGED