@junobuild/functions 0.8.4-next-2026-04-17.3 → 0.9.0
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 as
|
|
1
|
+
import{a as O}from"../../../chunk-ZBCLFWQJ.js";import{g as p}from"../../../chunk-YHNBR22R.js";import"../../../chunk-JU5CZHLY.js";import{a as z}from"../../../chunk-JI3RCRR6.js";import{j as x,k as i}from"../../../chunk-I3WMKZTG.js";import"../../../chunk-4C666HHU.js";import{schemaFromIdl as d,schemaToIdl as u}from"@junobuild/schema/utils";import{j as e}from"@junobuild/schema";import*as t from"zod";var _=z.required(),l=e.uint8Array(),s=e.strictObject({owner:e.principal(),subaccount:l.optional()}),a=e.nat(),b=e.strictObject({to:s,fee:a.optional(),memo:e.uint8Array().optional(),from_subaccount:l.optional(),created_at_time:e.bigint().optional(),amount:a}),h=t.union([t.strictObject({GenericError:t.strictObject({message:t.string(),error_code:t.bigint()})}),t.strictObject({TemporarilyUnavailable:t.null()}),t.strictObject({BadBurn:t.strictObject({min_burn_amount:t.bigint()})}),t.strictObject({Duplicate:t.strictObject({duplicate_of:t.bigint()})}),t.strictObject({BadFee:t.strictObject({expected_fee:t.bigint()})}),t.strictObject({CreatedInFuture:t.strictObject({ledger_time:t.bigint()})}),t.strictObject({TooOld:t.null()}),t.strictObject({InsufficientFunds:t.strictObject({balance:t.bigint()})})]),A=t.union([t.strictObject({Ok:t.bigint()}),t.strictObject({Err:h})]),m=e.strictObject({to:s,fee:a.optional(),spender_subaccount:l.optional(),from:s,memo:e.uint8Array().optional(),created_at_time:e.bigint().optional(),amount:a}),I=t.union([t.strictObject({GenericError:t.strictObject({message:t.string(),error_code:t.bigint()})}),t.strictObject({TemporarilyUnavailable:t.null()}),t.strictObject({InsufficientAllowance:t.strictObject({allowance:t.bigint()})}),t.strictObject({BadBurn:t.strictObject({min_burn_amount:t.bigint()})}),t.strictObject({Duplicate:t.strictObject({duplicate_of:t.bigint()})}),t.strictObject({BadFee:t.strictObject({expected_fee:t.bigint()})}),t.strictObject({CreatedInFuture:t.strictObject({ledger_time:t.bigint()})}),t.strictObject({TooOld:t.null()}),t.strictObject({InsufficientFunds:t.strictObject({balance:t.bigint()})})]),j=t.union([t.strictObject({Ok:t.bigint()}),t.strictObject({Err:I})]),g=e.strictObject({fee:a.optional(),memo:e.uint8Array().optional(),from_subaccount:l.optional(),created_at_time:e.bigint().optional(),amount:a,expected_allowance:a.optional(),expires_at:e.bigint().optional(),spender:s}),y=t.union([t.strictObject({GenericError:t.strictObject({message:t.string(),error_code:t.bigint()})}),t.strictObject({TemporarilyUnavailable:t.null()}),t.strictObject({Duplicate:t.strictObject({duplicate_of:t.bigint()})}),t.strictObject({BadFee:t.strictObject({expected_fee:t.bigint()})}),t.strictObject({AllowanceChanged:t.strictObject({current_allowance:t.bigint()})}),t.strictObject({CreatedInFuture:t.strictObject({ledger_time:t.bigint()})}),t.strictObject({TooOld:t.null()}),t.strictObject({Expired:t.strictObject({ledger_time:t.bigint()})}),t.strictObject({InsufficientFunds:t.strictObject({balance:t.bigint()})})]),T=t.union([t.strictObject({Ok:t.bigint()}),t.strictObject({Err:y})]);var f=class extends O{constructor(r){_.parse(r),super({canisterId:r.canisterId})}icrc1BalanceOf=async({account:r})=>{let c=s.parse(r),n=u({schema:s,value:c});return await p({canisterId:this.canisterId,method:"icrc1_balance_of",args:[[i.Account,n]],result:i.Tokens})};icrc1Transfer=async({args:r})=>{let c=b.parse(r),n=u({schema:b,value:c}),o=await p({canisterId:this.canisterId,method:"icrc1_transfer",args:[[i.TransferArg,n]],result:i.TransferResult});return d({schema:A,value:o})};icrc2TransferFrom=async({args:r})=>{let c=m.parse(r),n=u({schema:m,value:c}),o=await p({canisterId:this.canisterId,method:"icrc2_transfer_from",args:[[i.TransferFromArgs,n]],result:i.TransferFromResult});return d({schema:j,value:o})};icrc2Approve=async({args:r})=>{let c=g.parse(r),n=u({schema:g,value:c}),o=await p({canisterId:this.canisterId,method:"icrc2_approve",args:[[i.ApproveArgs,n]],result:i.ApproveResult});return d({schema:T,value:o})}};export{s as AccountSchema,g as ApproveArgsSchema,y as ApproveErrorSchema,T as ApproveResultSchema,_ as IcrcCanisterOptionsSchema,x as IcrcIndexIdl,f as IcrcLedgerCanister,i as IcrcLedgerIdl,l as SubaccountSchema,a as TokensSchema,b as TransferArgsSchema,h as TransferErrorSchema,m as TransferFromArgsSchema,I as TransferFromErrorSchema,j as TransferFromResultSchema,A as TransferResultSchema};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/canisters/ledger/icrc/ledger.canister.ts", "../../../src/canisters/ledger/icrc/schema.ts"],
|
|
4
|
-
"sourcesContent": ["import {schemaFromIdl, schemaToIdl} from '@junobuild/schema/utils';\nimport {call} from '../../../ic-cdk/call.ic-cdk';\nimport {Canister} from '../../_canister';\nimport {IcrcLedgerIdl} from '../../declarations';\nimport {\n AccountSchema,\n IcrcCanisterOptionsSchema,\n TransferArgsSchema,\n TransferFromArgsSchema,\n TransferFromResultSchema,\n TransferResultSchema,\n type Account,\n type IcrcCanisterOptions,\n type TransferArgs,\n type TransferFromArgs,\n type TransferFromResult,\n type TransferResult\n} from './schema';\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 {Account} account - The account to query.\n * @returns {Promise<bigint>} The token balance for the account.\n */\n icrc1BalanceOf = async ({account}: {account: Account}): Promise<bigint> => {\n const parsed = AccountSchema.parse(account);\n const idlArgs = schemaToIdl({schema: AccountSchema, value: parsed});\n\n return await call<bigint>({\n canisterId: this.canisterId,\n method: 'icrc1_balance_of',\n args: [[IcrcLedgerIdl.Account, idlArgs]],\n result: IcrcLedgerIdl.Tokens\n });\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 {TransferArgs} args - Transfer arguments (amount, fee, to, memo, created_at_time, etc.).\n * @returns {Promise<TransferResult>} The result of the transfer.\n */\n icrc1Transfer = async ({args}: {args: TransferArgs}): Promise<TransferResult> => {\n const parsed = TransferArgsSchema.parse(args);\n const idlArgs = schemaToIdl({schema: TransferArgsSchema, value: parsed});\n\n const idlResult = await call<TransferResult>({\n canisterId: this.canisterId,\n method: 'icrc1_transfer',\n args: [[IcrcLedgerIdl.TransferArg, idlArgs]],\n result: IcrcLedgerIdl.TransferResult\n });\n\n return schemaFromIdl({schema: TransferResultSchema, value: idlResult}) as 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 {TransferFromArgs} args - Transfer-from arguments (amount, from_subaccount, spender, etc.).\n * @returns {Promise<TransferFromResult>} The result of the transfer-from operation.\n */\n icrc2TransferFrom = async ({args}: {args: TransferFromArgs}): Promise<TransferFromResult> => {\n const parsed = TransferFromArgsSchema.parse(args);\n const idlArgs = schemaToIdl({schema: TransferFromArgsSchema, value: parsed});\n\n const idlResult = await call<TransferFromResult>({\n canisterId: this.canisterId,\n method: 'icrc2_transfer_from',\n args: [[IcrcLedgerIdl.TransferFromArgs, idlArgs]],\n result: IcrcLedgerIdl.TransferFromResult\n });\n\n return schemaFromIdl({\n schema: TransferFromResultSchema,\n value: idlResult\n }) as TransferFromResult;\n };\n}\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport {j} from '@junobuild/schema';\nimport * as z from 'zod';\nimport {CanisterOptionsSchema} from '../../schema';\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\nexport const SubaccountSchema = j.uint8Array();\n\nexport const AccountSchema = j.strictObject({\n owner: j.principal(),\n subaccount: SubaccountSchema.optional()\n});\n\nexport const TokensSchema = j.nat();\n\n// icrc1_transfer\nexport const TransferArgsSchema = j.strictObject({\n to: AccountSchema,\n fee: TokensSchema.optional(),\n memo: j.uint8Array().optional(),\n from_subaccount: SubaccountSchema.optional(),\n created_at_time: j.bigint().optional(),\n amount: TokensSchema\n});\n\nexport const TransferErrorSchema = z.union([\n z.strictObject({GenericError: z.strictObject({message: z.string(), error_code: z.bigint()})}),\n z.strictObject({TemporarilyUnavailable: z.null()}),\n z.strictObject({BadBurn: z.strictObject({min_burn_amount: z.bigint()})}),\n z.strictObject({Duplicate: z.strictObject({duplicate_of: z.bigint()})}),\n z.strictObject({BadFee: z.strictObject({expected_fee: z.bigint()})}),\n z.strictObject({CreatedInFuture: z.strictObject({ledger_time: z.bigint()})}),\n z.strictObject({TooOld: z.null()}),\n z.strictObject({InsufficientFunds: z.strictObject({balance: z.bigint()})})\n]);\n\nexport const TransferResultSchema = z.union([\n z.strictObject({Ok: z.bigint()}),\n z.strictObject({Err: TransferErrorSchema})\n]);\n\n// icrc2_transfer_from\nexport const TransferFromArgsSchema = j.strictObject({\n to: AccountSchema,\n fee: TokensSchema.optional(),\n spender_subaccount: SubaccountSchema.optional(),\n from: AccountSchema,\n memo: j.uint8Array().optional(),\n created_at_time: j.bigint().optional(),\n amount: TokensSchema\n});\n\nexport const TransferFromErrorSchema = z.union([\n z.strictObject({GenericError: z.strictObject({message: z.string(), error_code: z.bigint()})}),\n z.strictObject({TemporarilyUnavailable: z.null()}),\n z.strictObject({InsufficientAllowance: z.strictObject({allowance: z.bigint()})}),\n z.strictObject({BadBurn: z.strictObject({min_burn_amount: z.bigint()})}),\n z.strictObject({Duplicate: z.strictObject({duplicate_of: z.bigint()})}),\n z.strictObject({BadFee: z.strictObject({expected_fee: z.bigint()})}),\n z.strictObject({CreatedInFuture: z.strictObject({ledger_time: z.bigint()})}),\n z.strictObject({TooOld: z.null()}),\n z.strictObject({InsufficientFunds: z.strictObject({balance: z.bigint()})})\n]);\n\nexport const TransferFromResultSchema = z.union([\n z.strictObject({Ok: z.bigint()}),\n z.strictObject({Err: TransferFromErrorSchema})\n]);\n\n/**\n * Subaccount is an arbitrary 32-byte array used to compute the source address.\n */\nexport type Subaccount = Uint8Array;\n\n/**\n * An ICRC account, consisting of an owner principal and an optional subaccount.\n */\nexport interface Account {\n /** The account owner. */\n owner: Principal;\n /** An optional subaccount to distinguish multiple accounts for the same owner. */\n subaccount?: Subaccount;\n}\n\n/**\n * Errors that can occur during an ICRC-1 transfer.\n */\nexport type TransferError =\n /** An error not covered by the other variants. */\n | {GenericError: {message: string; error_code: bigint}}\n /** The ledger is temporarily unavailable. */\n | {TemporarilyUnavailable: null}\n /** The burn amount is below the minimum. */\n | {BadBurn: {min_burn_amount: bigint}}\n /** The transaction is a duplicate. */\n | {Duplicate: {duplicate_of: bigint}}\n /** The fee does not match the expected fee. */\n | {BadFee: {expected_fee: bigint}}\n /** The `created_at_time` is too far in the future. */\n | {CreatedInFuture: {ledger_time: bigint}}\n /** The transaction is too old. */\n | {TooOld: null}\n /** The account does not have enough funds. */\n | {InsufficientFunds: {balance: bigint}};\n\n/**\n * The result of an ICRC-1 `icrc1_transfer` call.\n * Returns the block index of the transaction on success.\n */\nexport type TransferResult = {Ok: bigint} | {Err: TransferError};\n\n/**\n * Arguments for the ICRC-1 `icrc1_transfer` call.\n */\nexport interface TransferArgs {\n /** The destination account. */\n to: Account;\n /** An optional fee. Uses the default ledger fee if not provided. */\n fee?: bigint;\n /** An optional memo for the transaction. */\n memo?: Uint8Array;\n /** An optional subaccount to transfer from. Uses the default subaccount if not provided. */\n from_subaccount?: Subaccount;\n /** An optional timestamp. Uses current IC time if not provided. */\n created_at_time?: bigint;\n /** The amount to transfer. */\n amount: bigint;\n}\n\n/**\n * Errors that can occur during an ICRC-2 transfer-from.\n */\nexport type TransferFromError =\n /** An error not covered by the other variants. */\n | {GenericError: {message: string; error_code: bigint}}\n /** The ledger is temporarily unavailable. */\n | {TemporarilyUnavailable: null}\n /** The spender's allowance is insufficient. */\n | {InsufficientAllowance: {allowance: bigint}}\n /** The burn amount is below the minimum. */\n | {BadBurn: {min_burn_amount: bigint}}\n /** The transaction is a duplicate. */\n | {Duplicate: {duplicate_of: bigint}}\n /** The fee does not match the expected fee. */\n | {BadFee: {expected_fee: bigint}}\n /** The `created_at_time` is too far in the future. */\n | {CreatedInFuture: {ledger_time: bigint}}\n /** The transaction is too old. */\n | {TooOld: null}\n /** The account does not have enough funds. */\n | {InsufficientFunds: {balance: bigint}};\n\n/**\n * The result of an ICRC-2 `icrc2_transfer_from` call.\n * Returns the block index of the transaction on success.\n */\nexport type TransferFromResult = {Ok: bigint} | {Err: TransferFromError};\n\n/**\n * Arguments for the ICRC-2 `icrc2_transfer_from` call.\n */\nexport interface TransferFromArgs {\n /** The destination account. */\n to: Account;\n /** An optional fee. Uses the default ledger fee if not provided. */\n fee?: bigint;\n /** An optional subaccount of the spender. */\n spender_subaccount?: Subaccount;\n /** The account to transfer from. */\n from: Account;\n /** An optional memo for the transaction. */\n memo?: Uint8Array;\n /** An optional timestamp. Uses current IC time if not provided. */\n created_at_time?: bigint;\n /** The amount to transfer. */\n amount: bigint;\n}\n\n/**\n * Amount of ICRC tokens, represented as a natural number.\n */\nexport type Tokens = bigint;\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["schemaFromIdl", "schemaToIdl", "j", "z", "IcrcCanisterOptionsSchema", "CanisterOptionsSchema", "SubaccountSchema", "j", "AccountSchema", "TokensSchema", "TransferArgsSchema", "TransferErrorSchema", "TransferResultSchema", "TransferFromArgsSchema", "TransferFromErrorSchema", "TransferFromResultSchema", "IcrcLedgerCanister", "Canister", "options", "IcrcCanisterOptionsSchema", "account", "parsed", "AccountSchema", "idlArgs", "schemaToIdl", "call", "icrc_ledger_did_idl_exports", "args", "TransferArgsSchema", "idlResult", "schemaFromIdl", "TransferResultSchema", "TransferFromArgsSchema", "TransferFromResultSchema"]
|
|
4
|
+
"sourcesContent": ["import {schemaFromIdl, schemaToIdl} from '@junobuild/schema/utils';\nimport {call} from '../../../ic-cdk/call.ic-cdk';\nimport {Canister} from '../../_canister';\nimport {IcrcLedgerIdl} from '../../declarations';\nimport {\n AccountSchema,\n ApproveArgsSchema,\n ApproveResultSchema,\n IcrcCanisterOptionsSchema,\n TransferArgsSchema,\n TransferFromArgsSchema,\n TransferFromResultSchema,\n TransferResultSchema,\n type Account,\n type ApproveArgs,\n type ApproveResult,\n type IcrcCanisterOptions,\n type TransferArgs,\n type TransferFromArgs,\n type TransferFromResult,\n type TransferResult\n} from './schema';\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 {Account} account - The account to query.\n * @returns {Promise<bigint>} The token balance for the account.\n */\n icrc1BalanceOf = async ({account}: {account: Account}): Promise<bigint> => {\n const parsed = AccountSchema.parse(account);\n const idlArgs = schemaToIdl({schema: AccountSchema, value: parsed});\n\n return await call<bigint>({\n canisterId: this.canisterId,\n method: 'icrc1_balance_of',\n args: [[IcrcLedgerIdl.Account, idlArgs]],\n result: IcrcLedgerIdl.Tokens\n });\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 {TransferArgs} args - Transfer arguments (amount, fee, to, memo, created_at_time, etc.).\n * @returns {Promise<TransferResult>} The result of the transfer.\n */\n icrc1Transfer = async ({args}: {args: TransferArgs}): Promise<TransferResult> => {\n const parsed = TransferArgsSchema.parse(args);\n const idlArgs = schemaToIdl({schema: TransferArgsSchema, value: parsed});\n\n const idlResult = await call<TransferResult>({\n canisterId: this.canisterId,\n method: 'icrc1_transfer',\n args: [[IcrcLedgerIdl.TransferArg, idlArgs]],\n result: IcrcLedgerIdl.TransferResult\n });\n\n return schemaFromIdl({schema: TransferResultSchema, value: idlResult}) as 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 {TransferFromArgs} args - Transfer-from arguments (amount, from_subaccount, spender, etc.).\n * @returns {Promise<TransferFromResult>} The result of the transfer-from operation.\n */\n icrc2TransferFrom = async ({args}: {args: TransferFromArgs}): Promise<TransferFromResult> => {\n const parsed = TransferFromArgsSchema.parse(args);\n const idlArgs = schemaToIdl({schema: TransferFromArgsSchema, value: parsed});\n\n const idlResult = await call<TransferFromResult>({\n canisterId: this.canisterId,\n method: 'icrc2_transfer_from',\n args: [[IcrcLedgerIdl.TransferFromArgs, idlArgs]],\n result: IcrcLedgerIdl.TransferFromResult\n });\n\n return schemaFromIdl({\n schema: TransferFromResultSchema,\n value: idlResult\n }) as TransferFromResult;\n };\n\n /**\n * Approves a spender to transfer tokens on behalf of the caller using the ICRC-2 `icrc2_approve` method.\n *\n * @param {ApproveArgs} args - Approve arguments (amount, spender, fee, expires_at, etc.).\n * @returns {Promise<ApproveResult>} The result of the approval.\n */\n icrc2Approve = async ({args}: {args: ApproveArgs}): Promise<ApproveResult> => {\n const parsed = ApproveArgsSchema.parse(args);\n const idlArgs = schemaToIdl({schema: ApproveArgsSchema, value: parsed});\n\n const idlResult = await call<ApproveResult>({\n canisterId: this.canisterId,\n method: 'icrc2_approve',\n args: [[IcrcLedgerIdl.ApproveArgs, idlArgs]],\n result: IcrcLedgerIdl.ApproveResult\n });\n\n return schemaFromIdl({schema: ApproveResultSchema, value: idlResult}) as ApproveResult;\n };\n}\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport {j} from '@junobuild/schema';\nimport * as z from 'zod';\nimport {CanisterOptionsSchema} from '../../schema';\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\nexport const SubaccountSchema = j.uint8Array();\n\nexport const AccountSchema = j.strictObject({\n owner: j.principal(),\n subaccount: SubaccountSchema.optional()\n});\n\nexport const TokensSchema = j.nat();\n\n// icrc1_transfer\nexport const TransferArgsSchema = j.strictObject({\n to: AccountSchema,\n fee: TokensSchema.optional(),\n memo: j.uint8Array().optional(),\n from_subaccount: SubaccountSchema.optional(),\n created_at_time: j.bigint().optional(),\n amount: TokensSchema\n});\n\nexport const TransferErrorSchema = z.union([\n z.strictObject({GenericError: z.strictObject({message: z.string(), error_code: z.bigint()})}),\n z.strictObject({TemporarilyUnavailable: z.null()}),\n z.strictObject({BadBurn: z.strictObject({min_burn_amount: z.bigint()})}),\n z.strictObject({Duplicate: z.strictObject({duplicate_of: z.bigint()})}),\n z.strictObject({BadFee: z.strictObject({expected_fee: z.bigint()})}),\n z.strictObject({CreatedInFuture: z.strictObject({ledger_time: z.bigint()})}),\n z.strictObject({TooOld: z.null()}),\n z.strictObject({InsufficientFunds: z.strictObject({balance: z.bigint()})})\n]);\n\nexport const TransferResultSchema = z.union([\n z.strictObject({Ok: z.bigint()}),\n z.strictObject({Err: TransferErrorSchema})\n]);\n\n// icrc2_transfer_from\nexport const TransferFromArgsSchema = j.strictObject({\n to: AccountSchema,\n fee: TokensSchema.optional(),\n spender_subaccount: SubaccountSchema.optional(),\n from: AccountSchema,\n memo: j.uint8Array().optional(),\n created_at_time: j.bigint().optional(),\n amount: TokensSchema\n});\n\nexport const TransferFromErrorSchema = z.union([\n z.strictObject({GenericError: z.strictObject({message: z.string(), error_code: z.bigint()})}),\n z.strictObject({TemporarilyUnavailable: z.null()}),\n z.strictObject({InsufficientAllowance: z.strictObject({allowance: z.bigint()})}),\n z.strictObject({BadBurn: z.strictObject({min_burn_amount: z.bigint()})}),\n z.strictObject({Duplicate: z.strictObject({duplicate_of: z.bigint()})}),\n z.strictObject({BadFee: z.strictObject({expected_fee: z.bigint()})}),\n z.strictObject({CreatedInFuture: z.strictObject({ledger_time: z.bigint()})}),\n z.strictObject({TooOld: z.null()}),\n z.strictObject({InsufficientFunds: z.strictObject({balance: z.bigint()})})\n]);\n\nexport const TransferFromResultSchema = z.union([\n z.strictObject({Ok: z.bigint()}),\n z.strictObject({Err: TransferFromErrorSchema})\n]);\n\n// icrc2_approve\nexport const ApproveArgsSchema = j.strictObject({\n fee: TokensSchema.optional(),\n memo: j.uint8Array().optional(),\n from_subaccount: SubaccountSchema.optional(),\n created_at_time: j.bigint().optional(),\n amount: TokensSchema,\n expected_allowance: TokensSchema.optional(),\n expires_at: j.bigint().optional(),\n spender: AccountSchema\n});\n\nexport const ApproveErrorSchema = z.union([\n z.strictObject({GenericError: z.strictObject({message: z.string(), error_code: z.bigint()})}),\n z.strictObject({TemporarilyUnavailable: z.null()}),\n z.strictObject({Duplicate: z.strictObject({duplicate_of: z.bigint()})}),\n z.strictObject({BadFee: z.strictObject({expected_fee: z.bigint()})}),\n z.strictObject({AllowanceChanged: z.strictObject({current_allowance: z.bigint()})}),\n z.strictObject({CreatedInFuture: z.strictObject({ledger_time: z.bigint()})}),\n z.strictObject({TooOld: z.null()}),\n z.strictObject({Expired: z.strictObject({ledger_time: z.bigint()})}),\n z.strictObject({InsufficientFunds: z.strictObject({balance: z.bigint()})})\n]);\n\nexport const ApproveResultSchema = z.union([\n z.strictObject({Ok: z.bigint()}),\n z.strictObject({Err: ApproveErrorSchema})\n]);\n\n/**\n * Subaccount is an arbitrary 32-byte array used to compute the source address.\n */\nexport type Subaccount = Uint8Array;\n\n/**\n * An ICRC account, consisting of an owner principal and an optional subaccount.\n */\nexport interface Account {\n /** The account owner. */\n owner: Principal;\n /** An optional subaccount to distinguish multiple accounts for the same owner. */\n subaccount?: Subaccount;\n}\n\n/**\n * Errors that can occur during an ICRC-1 transfer.\n */\nexport type TransferError =\n /** An error not covered by the other variants. */\n | {GenericError: {message: string; error_code: bigint}}\n /** The ledger is temporarily unavailable. */\n | {TemporarilyUnavailable: null}\n /** The burn amount is below the minimum. */\n | {BadBurn: {min_burn_amount: bigint}}\n /** The transaction is a duplicate. */\n | {Duplicate: {duplicate_of: bigint}}\n /** The fee does not match the expected fee. */\n | {BadFee: {expected_fee: bigint}}\n /** The `created_at_time` is too far in the future. */\n | {CreatedInFuture: {ledger_time: bigint}}\n /** The transaction is too old. */\n | {TooOld: null}\n /** The account does not have enough funds. */\n | {InsufficientFunds: {balance: bigint}};\n\n/**\n * The result of an ICRC-1 `icrc1_transfer` call.\n * Returns the block index of the transaction on success.\n */\nexport type TransferResult = {Ok: bigint} | {Err: TransferError};\n\n/**\n * Arguments for the ICRC-1 `icrc1_transfer` call.\n */\nexport interface TransferArgs {\n /** The destination account. */\n to: Account;\n /** An optional fee. Uses the default ledger fee if not provided. */\n fee?: bigint;\n /** An optional memo for the transaction. */\n memo?: Uint8Array;\n /** An optional subaccount to transfer from. Uses the default subaccount if not provided. */\n from_subaccount?: Subaccount;\n /** An optional timestamp. Uses current IC time if not provided. */\n created_at_time?: bigint;\n /** The amount to transfer. */\n amount: bigint;\n}\n\n/**\n * Errors that can occur during an ICRC-2 transfer-from.\n */\nexport type TransferFromError =\n /** An error not covered by the other variants. */\n | {GenericError: {message: string; error_code: bigint}}\n /** The ledger is temporarily unavailable. */\n | {TemporarilyUnavailable: null}\n /** The spender's allowance is insufficient. */\n | {InsufficientAllowance: {allowance: bigint}}\n /** The burn amount is below the minimum. */\n | {BadBurn: {min_burn_amount: bigint}}\n /** The transaction is a duplicate. */\n | {Duplicate: {duplicate_of: bigint}}\n /** The fee does not match the expected fee. */\n | {BadFee: {expected_fee: bigint}}\n /** The `created_at_time` is too far in the future. */\n | {CreatedInFuture: {ledger_time: bigint}}\n /** The transaction is too old. */\n | {TooOld: null}\n /** The account does not have enough funds. */\n | {InsufficientFunds: {balance: bigint}};\n\n/**\n * The result of an ICRC-2 `icrc2_transfer_from` call.\n * Returns the block index of the transaction on success.\n */\nexport type TransferFromResult = {Ok: bigint} | {Err: TransferFromError};\n\n/**\n * Arguments for the ICRC-2 `icrc2_transfer_from` call.\n */\nexport interface TransferFromArgs {\n /** The destination account. */\n to: Account;\n /** An optional fee. Uses the default ledger fee if not provided. */\n fee?: bigint;\n /** An optional subaccount of the spender. */\n spender_subaccount?: Subaccount;\n /** The account to transfer from. */\n from: Account;\n /** An optional memo for the transaction. */\n memo?: Uint8Array;\n /** An optional timestamp. Uses current IC time if not provided. */\n created_at_time?: bigint;\n /** The amount to transfer. */\n amount: bigint;\n}\n\n/**\n * Amount of ICRC tokens, represented as a natural number.\n */\nexport type Tokens = bigint;\n\n/**\n * Arguments for the ICRC-2 `icrc2_approve` call.\n */\nexport interface ApproveArgs {\n /** An optional fee. Uses the default ledger fee if not provided. */\n fee?: bigint;\n /** An optional memo for the transaction. */\n memo?: Uint8Array;\n /** An optional subaccount of the approver. */\n from_subaccount?: Subaccount;\n /** An optional timestamp. Uses current IC time if not provided. */\n created_at_time?: bigint;\n /** The amount to approve. */\n amount: bigint;\n /** An optional expected current allowance for optimistic concurrency control. */\n expected_allowance?: bigint;\n /** An optional expiry timestamp for the approval. */\n expires_at?: bigint;\n /** The spender account being approved. */\n spender: Account;\n}\n\n/**\n * Errors that can occur during an ICRC-2 approve.\n */\nexport type ApproveError =\n | {GenericError: {message: string; error_code: bigint}}\n | {TemporarilyUnavailable: null}\n | {Duplicate: {duplicate_of: bigint}}\n | {BadFee: {expected_fee: bigint}}\n | {AllowanceChanged: {current_allowance: bigint}}\n | {CreatedInFuture: {ledger_time: bigint}}\n | {TooOld: null}\n | {Expired: {ledger_time: bigint}}\n | {InsufficientFunds: {balance: bigint}};\n\n/**\n * The result of an ICRC-2 `icrc2_approve` call.\n * Returns the block index of the approval on success.\n */\nexport type ApproveResult = {Ok: bigint} | {Err: ApproveError};\n"],
|
|
5
|
+
"mappings": "yQAAA,OAAQ,iBAAAA,EAAe,eAAAC,MAAkB,0BCCzC,OAAQ,KAAAC,MAAQ,oBAChB,UAAYC,MAAO,MAMZ,IAAMC,EAA4BC,EAAsB,SAAS,EAO3DC,EAAmBC,EAAE,WAAW,EAEhCC,EAAgBD,EAAE,aAAa,CAC1C,MAAOA,EAAE,UAAU,EACnB,WAAYD,EAAiB,SAAS,CACxC,CAAC,EAEYG,EAAeF,EAAE,IAAI,EAGrBG,EAAqBH,EAAE,aAAa,CAC/C,GAAIC,EACJ,IAAKC,EAAa,SAAS,EAC3B,KAAMF,EAAE,WAAW,EAAE,SAAS,EAC9B,gBAAiBD,EAAiB,SAAS,EAC3C,gBAAiBC,EAAE,OAAO,EAAE,SAAS,EACrC,OAAQE,CACV,CAAC,EAEYE,EAAwB,QAAM,CACvC,eAAa,CAAC,aAAgB,eAAa,CAAC,QAAW,SAAO,EAAG,WAAc,SAAO,CAAC,CAAC,CAAC,CAAC,EAC1F,eAAa,CAAC,uBAA0B,OAAK,CAAC,CAAC,EAC/C,eAAa,CAAC,QAAW,eAAa,CAAC,gBAAmB,SAAO,CAAC,CAAC,CAAC,CAAC,EACrE,eAAa,CAAC,UAAa,eAAa,CAAC,aAAgB,SAAO,CAAC,CAAC,CAAC,CAAC,EACpE,eAAa,CAAC,OAAU,eAAa,CAAC,aAAgB,SAAO,CAAC,CAAC,CAAC,CAAC,EACjE,eAAa,CAAC,gBAAmB,eAAa,CAAC,YAAe,SAAO,CAAC,CAAC,CAAC,CAAC,EACzE,eAAa,CAAC,OAAU,OAA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AC,OAAQK,EAAqB,MAAON,CAAS,CAAC,CACtE,CACF",
|
|
6
|
+
"names": ["schemaFromIdl", "schemaToIdl", "j", "z", "IcrcCanisterOptionsSchema", "CanisterOptionsSchema", "SubaccountSchema", "j", "AccountSchema", "TokensSchema", "TransferArgsSchema", "TransferErrorSchema", "TransferResultSchema", "TransferFromArgsSchema", "TransferFromErrorSchema", "TransferFromResultSchema", "ApproveArgsSchema", "ApproveErrorSchema", "ApproveResultSchema", "IcrcLedgerCanister", "Canister", "options", "IcrcCanisterOptionsSchema", "account", "parsed", "AccountSchema", "idlArgs", "schemaToIdl", "call", "icrc_ledger_did_idl_exports", "args", "TransferArgsSchema", "idlResult", "schemaFromIdl", "TransferResultSchema", "TransferFromArgsSchema", "TransferFromResultSchema", "ApproveArgsSchema", "ApproveResultSchema"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Canister } from '../../_canister';
|
|
2
|
-
import { type Account, type IcrcCanisterOptions, type TransferArgs, type TransferFromArgs, type TransferFromResult, type TransferResult } from './schema';
|
|
2
|
+
import { type Account, type ApproveArgs, type ApproveResult, type IcrcCanisterOptions, type TransferArgs, type TransferFromArgs, type TransferFromResult, type TransferResult } from './schema';
|
|
3
3
|
/**
|
|
4
4
|
* Provides a simple interface to interact with an ICRC Ledger,
|
|
5
5
|
* when developing Juno Serverless Functions in TypeScript.
|
|
@@ -41,4 +41,13 @@ export declare class IcrcLedgerCanister extends Canister {
|
|
|
41
41
|
icrc2TransferFrom: ({ args }: {
|
|
42
42
|
args: TransferFromArgs;
|
|
43
43
|
}) => Promise<TransferFromResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Approves a spender to transfer tokens on behalf of the caller using the ICRC-2 `icrc2_approve` method.
|
|
46
|
+
*
|
|
47
|
+
* @param {ApproveArgs} args - Approve arguments (amount, spender, fee, expires_at, etc.).
|
|
48
|
+
* @returns {Promise<ApproveResult>} The result of the approval.
|
|
49
|
+
*/
|
|
50
|
+
icrc2Approve: ({ args }: {
|
|
51
|
+
args: ApproveArgs;
|
|
52
|
+
}) => Promise<ApproveResult>;
|
|
44
53
|
}
|
|
@@ -178,6 +178,91 @@ export declare const TransferFromResultSchema: z.ZodUnion<readonly [z.ZodObject<
|
|
|
178
178
|
}, z.core.$strict>;
|
|
179
179
|
}, z.core.$strict>]>;
|
|
180
180
|
}, z.core.$strict>]>;
|
|
181
|
+
export declare const ApproveArgsSchema: z.ZodObject<{
|
|
182
|
+
fee: z.ZodOptional<z.ZodBigInt>;
|
|
183
|
+
memo: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
184
|
+
from_subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
185
|
+
created_at_time: z.ZodOptional<z.ZodBigInt>;
|
|
186
|
+
amount: z.ZodBigInt;
|
|
187
|
+
expected_allowance: z.ZodOptional<z.ZodBigInt>;
|
|
188
|
+
expires_at: z.ZodOptional<z.ZodBigInt>;
|
|
189
|
+
spender: z.ZodObject<{
|
|
190
|
+
owner: z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>;
|
|
191
|
+
subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
192
|
+
}, z.core.$strict>;
|
|
193
|
+
}, z.core.$strict>;
|
|
194
|
+
export declare const ApproveErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
195
|
+
GenericError: z.ZodObject<{
|
|
196
|
+
message: z.ZodString;
|
|
197
|
+
error_code: z.ZodBigInt;
|
|
198
|
+
}, z.core.$strict>;
|
|
199
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
200
|
+
TemporarilyUnavailable: z.ZodNull;
|
|
201
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
202
|
+
Duplicate: z.ZodObject<{
|
|
203
|
+
duplicate_of: z.ZodBigInt;
|
|
204
|
+
}, z.core.$strict>;
|
|
205
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
206
|
+
BadFee: z.ZodObject<{
|
|
207
|
+
expected_fee: z.ZodBigInt;
|
|
208
|
+
}, z.core.$strict>;
|
|
209
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
210
|
+
AllowanceChanged: z.ZodObject<{
|
|
211
|
+
current_allowance: z.ZodBigInt;
|
|
212
|
+
}, z.core.$strict>;
|
|
213
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
214
|
+
CreatedInFuture: z.ZodObject<{
|
|
215
|
+
ledger_time: z.ZodBigInt;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
218
|
+
TooOld: z.ZodNull;
|
|
219
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
220
|
+
Expired: z.ZodObject<{
|
|
221
|
+
ledger_time: z.ZodBigInt;
|
|
222
|
+
}, z.core.$strict>;
|
|
223
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
224
|
+
InsufficientFunds: z.ZodObject<{
|
|
225
|
+
balance: z.ZodBigInt;
|
|
226
|
+
}, z.core.$strict>;
|
|
227
|
+
}, z.core.$strict>]>;
|
|
228
|
+
export declare const ApproveResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
229
|
+
Ok: z.ZodBigInt;
|
|
230
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
231
|
+
Err: z.ZodUnion<readonly [z.ZodObject<{
|
|
232
|
+
GenericError: z.ZodObject<{
|
|
233
|
+
message: z.ZodString;
|
|
234
|
+
error_code: z.ZodBigInt;
|
|
235
|
+
}, z.core.$strict>;
|
|
236
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
237
|
+
TemporarilyUnavailable: z.ZodNull;
|
|
238
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
239
|
+
Duplicate: z.ZodObject<{
|
|
240
|
+
duplicate_of: z.ZodBigInt;
|
|
241
|
+
}, z.core.$strict>;
|
|
242
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
243
|
+
BadFee: z.ZodObject<{
|
|
244
|
+
expected_fee: z.ZodBigInt;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
247
|
+
AllowanceChanged: z.ZodObject<{
|
|
248
|
+
current_allowance: z.ZodBigInt;
|
|
249
|
+
}, z.core.$strict>;
|
|
250
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
251
|
+
CreatedInFuture: z.ZodObject<{
|
|
252
|
+
ledger_time: z.ZodBigInt;
|
|
253
|
+
}, z.core.$strict>;
|
|
254
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
255
|
+
TooOld: z.ZodNull;
|
|
256
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
257
|
+
Expired: z.ZodObject<{
|
|
258
|
+
ledger_time: z.ZodBigInt;
|
|
259
|
+
}, z.core.$strict>;
|
|
260
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
261
|
+
InsufficientFunds: z.ZodObject<{
|
|
262
|
+
balance: z.ZodBigInt;
|
|
263
|
+
}, z.core.$strict>;
|
|
264
|
+
}, z.core.$strict>]>;
|
|
265
|
+
}, z.core.$strict>]>;
|
|
181
266
|
/**
|
|
182
267
|
* Subaccount is an arbitrary 32-byte array used to compute the source address.
|
|
183
268
|
*/
|
|
@@ -353,3 +438,70 @@ export interface TransferFromArgs {
|
|
|
353
438
|
* Amount of ICRC tokens, represented as a natural number.
|
|
354
439
|
*/
|
|
355
440
|
export type Tokens = bigint;
|
|
441
|
+
/**
|
|
442
|
+
* Arguments for the ICRC-2 `icrc2_approve` call.
|
|
443
|
+
*/
|
|
444
|
+
export interface ApproveArgs {
|
|
445
|
+
/** An optional fee. Uses the default ledger fee if not provided. */
|
|
446
|
+
fee?: bigint;
|
|
447
|
+
/** An optional memo for the transaction. */
|
|
448
|
+
memo?: Uint8Array;
|
|
449
|
+
/** An optional subaccount of the approver. */
|
|
450
|
+
from_subaccount?: Subaccount;
|
|
451
|
+
/** An optional timestamp. Uses current IC time if not provided. */
|
|
452
|
+
created_at_time?: bigint;
|
|
453
|
+
/** The amount to approve. */
|
|
454
|
+
amount: bigint;
|
|
455
|
+
/** An optional expected current allowance for optimistic concurrency control. */
|
|
456
|
+
expected_allowance?: bigint;
|
|
457
|
+
/** An optional expiry timestamp for the approval. */
|
|
458
|
+
expires_at?: bigint;
|
|
459
|
+
/** The spender account being approved. */
|
|
460
|
+
spender: Account;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Errors that can occur during an ICRC-2 approve.
|
|
464
|
+
*/
|
|
465
|
+
export type ApproveError = {
|
|
466
|
+
GenericError: {
|
|
467
|
+
message: string;
|
|
468
|
+
error_code: bigint;
|
|
469
|
+
};
|
|
470
|
+
} | {
|
|
471
|
+
TemporarilyUnavailable: null;
|
|
472
|
+
} | {
|
|
473
|
+
Duplicate: {
|
|
474
|
+
duplicate_of: bigint;
|
|
475
|
+
};
|
|
476
|
+
} | {
|
|
477
|
+
BadFee: {
|
|
478
|
+
expected_fee: bigint;
|
|
479
|
+
};
|
|
480
|
+
} | {
|
|
481
|
+
AllowanceChanged: {
|
|
482
|
+
current_allowance: bigint;
|
|
483
|
+
};
|
|
484
|
+
} | {
|
|
485
|
+
CreatedInFuture: {
|
|
486
|
+
ledger_time: bigint;
|
|
487
|
+
};
|
|
488
|
+
} | {
|
|
489
|
+
TooOld: null;
|
|
490
|
+
} | {
|
|
491
|
+
Expired: {
|
|
492
|
+
ledger_time: bigint;
|
|
493
|
+
};
|
|
494
|
+
} | {
|
|
495
|
+
InsufficientFunds: {
|
|
496
|
+
balance: bigint;
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* The result of an ICRC-2 `icrc2_approve` call.
|
|
501
|
+
* Returns the block index of the approval on success.
|
|
502
|
+
*/
|
|
503
|
+
export type ApproveResult = {
|
|
504
|
+
Ok: bigint;
|
|
505
|
+
} | {
|
|
506
|
+
Err: ApproveError;
|
|
507
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
],
|
|
99
99
|
"homepage": "https://juno.build",
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@icp-sdk/core": "
|
|
102
|
-
"@junobuild/schema": "
|
|
103
|
-
"@junobuild/utils": "
|
|
104
|
-
"zod": "
|
|
101
|
+
"@icp-sdk/core": "^5",
|
|
102
|
+
"@junobuild/schema": "^1.2.4",
|
|
103
|
+
"@junobuild/utils": "^1.0.2",
|
|
104
|
+
"zod": "^4.3"
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
}
|