@junobuild/functions 0.8.3 → 0.8.4-next-2026-04-17
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.
- package/canisters/ckbtc/index.js +1 -1
- package/canisters/cketh/index.js +1 -1
- package/canisters/cmc/index.js +1 -1
- package/canisters/declarations/_idl.d.ts +2 -1
- package/canisters/declarations/_types.d.ts +2 -1
- package/canisters/declarations/ckbtc/bitcoin.did.d.ts +8 -0
- package/canisters/declarations/ckbtc/bitcoin.did.idl.d.ts +2 -0
- package/canisters/declarations/ckbtc/minter.did.d.ts +190 -0
- package/canisters/declarations/ckbtc/minter.did.idl.d.ts +9 -0
- package/canisters/declarations/cketh/minter.did.d.ts +140 -0
- package/canisters/declarations/cketh/minter.did.idl.d.ts +8 -0
- package/canisters/declarations/cycles-ledger/cycles-ledger.did.d.ts +413 -0
- package/canisters/declarations/cycles-ledger/cycles-ledger.did.idl.d.ts +82 -0
- package/canisters/declarations/ic-management/ic-management.did.d.ts +18 -4
- package/canisters/declarations/ledger-icp/index.did.d.ts +20 -1
- package/canisters/declarations/ledger-icp/index.did.idl.d.ts +5 -1
- package/canisters/declarations/ledger-icrc/icrc_index.did.d.ts +1 -0
- package/canisters/declarations/ledger-icrc/icrc_ledger.did.d.ts +1 -0
- package/canisters/declarations/nns/governance.did.d.ts +100 -0
- package/canisters/declarations/nns/governance.did.idl.d.ts +11 -0
- package/canisters/declarations/nns/governance_test.did.d.ts +100 -0
- package/canisters/declarations/nns/governance_test.did.idl.d.ts +11 -0
- package/canisters/declarations/nns/sns_wasm.did.d.ts +4 -0
- package/canisters/declarations/nns/sns_wasm.did.idl.d.ts +1 -0
- package/canisters/declarations/sns/governance.did.d.ts +4 -0
- package/canisters/declarations/sns/governance.did.idl.d.ts +1 -0
- package/canisters/declarations/sns/governance_test.did.d.ts +4 -0
- package/canisters/declarations/sns/governance_test.did.idl.d.ts +1 -0
- package/canisters/ic-management/index.js +1 -1
- package/canisters/ledger/cycles/index.d.ts +1 -0
- package/canisters/ledger/cycles/index.js +2 -0
- package/canisters/ledger/cycles/index.js.map +7 -0
- package/canisters/ledger/icp/index.d.ts +1 -0
- package/canisters/ledger/icp/index.js +1 -1
- package/canisters/ledger/icp/index.js.map +4 -4
- package/canisters/ledger/icp/ledger.canister.d.ts +5 -5
- package/canisters/ledger/icp/schema.d.ts +152 -0
- package/canisters/ledger/icrc/index.d.ts +1 -1
- package/canisters/ledger/icrc/index.js +1 -1
- package/canisters/ledger/icrc/index.js.map +4 -4
- package/canisters/ledger/icrc/ledger.canister.d.ts +13 -14
- package/canisters/ledger/icrc/schema.d.ts +351 -0
- package/canisters/nns/index.js +1 -1
- package/canisters/sns/index.js +1 -1
- package/chunk-I3WMKZTG.js +2 -0
- package/chunk-I3WMKZTG.js.map +7 -0
- package/package.json +10 -6
- package/src/canisters/declarations/ckbtc/bitcoin.did.d.ts +8 -0
- package/src/canisters/declarations/ckbtc/bitcoin.did.idl.js +16 -0
- package/src/canisters/declarations/ckbtc/minter.did.d.ts +190 -0
- package/src/canisters/declarations/ckbtc/minter.did.idl.js +118 -0
- package/src/canisters/declarations/cketh/minter.did.d.ts +140 -0
- package/src/canisters/declarations/cketh/minter.did.idl.js +78 -0
- package/src/canisters/declarations/cycles-ledger/cycles-ledger.did.d.ts +413 -0
- package/src/canisters/declarations/cycles-ledger/cycles-ledger.did.idl.js +806 -0
- package/src/canisters/declarations/ic-management/ic-management.did.d.ts +18 -4
- package/src/canisters/declarations/ic-management/ic-management.did.idl.js +32 -8
- package/src/canisters/declarations/ledger-icp/index.did.d.ts +20 -1
- package/src/canisters/declarations/ledger-icp/index.did.idl.js +32 -5
- package/src/canisters/declarations/ledger-icrc/icrc_index.did.d.ts +1 -0
- package/src/canisters/declarations/ledger-icrc/icrc_index.did.idl.js +2 -0
- package/src/canisters/declarations/ledger-icrc/icrc_ledger.did.d.ts +1 -0
- package/src/canisters/declarations/ledger-icrc/icrc_ledger.did.idl.js +2 -0
- package/src/canisters/declarations/nns/governance.did.d.ts +100 -0
- package/src/canisters/declarations/nns/governance.did.idl.js +132 -0
- package/src/canisters/declarations/nns/governance_test.did.d.ts +100 -0
- package/src/canisters/declarations/nns/governance_test.did.idl.js +132 -0
- package/src/canisters/declarations/nns/sns_wasm.did.d.ts +4 -0
- package/src/canisters/declarations/nns/sns_wasm.did.idl.js +8 -0
- package/src/canisters/declarations/sns/governance.did.d.ts +4 -0
- package/src/canisters/declarations/sns/governance.did.idl.js +12 -0
- package/src/canisters/declarations/sns/governance_test.did.d.ts +4 -0
- package/src/canisters/declarations/sns/governance_test.did.idl.js +12 -0
- package/canisters/ledger/icrc/schemas.d.ts +0 -11
- package/chunk-I4MVAQHI.js +0 -2
- package/chunk-I4MVAQHI.js.map +0 -7
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const AccountIdentifierSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
3
|
+
export declare const TokensSchema: z.ZodObject<{
|
|
4
|
+
e8s: z.ZodBigInt;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
export declare const TimeStampSchema: z.ZodObject<{
|
|
7
|
+
timestamp_nanos: z.ZodBigInt;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export declare const SubAccountSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
10
|
+
export declare const TransferArgsSchema: z.ZodObject<{
|
|
11
|
+
to: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
12
|
+
fee: z.ZodObject<{
|
|
13
|
+
e8s: z.ZodBigInt;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
memo: z.ZodBigInt;
|
|
16
|
+
from_subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
17
|
+
created_at_time: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
timestamp_nanos: z.ZodBigInt;
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
amount: z.ZodObject<{
|
|
21
|
+
e8s: z.ZodBigInt;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export declare const TransferErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
25
|
+
TxTooOld: z.ZodObject<{
|
|
26
|
+
allowed_window_nanos: z.ZodBigInt;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
+
BadFee: z.ZodObject<{
|
|
30
|
+
expected_fee: z.ZodObject<{
|
|
31
|
+
e8s: z.ZodBigInt;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
35
|
+
TxDuplicate: z.ZodObject<{
|
|
36
|
+
duplicate_of: z.ZodBigInt;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
TxCreatedInFuture: z.ZodNull;
|
|
40
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
41
|
+
InsufficientFunds: z.ZodObject<{
|
|
42
|
+
balance: z.ZodObject<{
|
|
43
|
+
e8s: z.ZodBigInt;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
}, z.core.$strict>]>;
|
|
47
|
+
export declare const TransferResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
48
|
+
Ok: z.ZodBigInt;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
Err: z.ZodUnion<readonly [z.ZodObject<{
|
|
51
|
+
TxTooOld: z.ZodObject<{
|
|
52
|
+
allowed_window_nanos: z.ZodBigInt;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
BadFee: z.ZodObject<{
|
|
56
|
+
expected_fee: z.ZodObject<{
|
|
57
|
+
e8s: z.ZodBigInt;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
+
TxDuplicate: z.ZodObject<{
|
|
62
|
+
duplicate_of: z.ZodBigInt;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
65
|
+
TxCreatedInFuture: z.ZodNull;
|
|
66
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
67
|
+
InsufficientFunds: z.ZodObject<{
|
|
68
|
+
balance: z.ZodObject<{
|
|
69
|
+
e8s: z.ZodBigInt;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
}, z.core.$strict>]>;
|
|
73
|
+
}, z.core.$strict>]>;
|
|
74
|
+
/**
|
|
75
|
+
* The destination account identifier.
|
|
76
|
+
* A 32-byte array where the first 4 bytes are a CRC32 checksum of the last 28 bytes.
|
|
77
|
+
*/
|
|
78
|
+
export type AccountIdentifier = Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* Amount of tokens, measured in 10^-8 of a token.
|
|
81
|
+
*/
|
|
82
|
+
export interface Tokens {
|
|
83
|
+
e8s: bigint;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A point in time, represented as nanoseconds since the Unix epoch.
|
|
87
|
+
*/
|
|
88
|
+
export interface TimeStamp {
|
|
89
|
+
timestamp_nanos: bigint;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Subaccount is an arbitrary 32-byte array used to compute the source address.
|
|
93
|
+
*/
|
|
94
|
+
export type SubAccount = Uint8Array;
|
|
95
|
+
/**
|
|
96
|
+
* Arguments for the ICP Ledger `transfer` call.
|
|
97
|
+
*/
|
|
98
|
+
export interface TransferArgs {
|
|
99
|
+
/** The destination account identifier. */
|
|
100
|
+
to: AccountIdentifier;
|
|
101
|
+
/** The transaction fee. Must be 10000 e8s. */
|
|
102
|
+
fee: Tokens;
|
|
103
|
+
/** An arbitrary number associated with the transaction for correlation. */
|
|
104
|
+
memo: bigint;
|
|
105
|
+
/** The subaccount to transfer from. Uses the default subaccount if not provided. */
|
|
106
|
+
from_subaccount?: SubAccount;
|
|
107
|
+
/** The time at which the caller created this request. Uses current IC time if not provided. */
|
|
108
|
+
created_at_time?: TimeStamp;
|
|
109
|
+
/** The amount to transfer to the destination address. */
|
|
110
|
+
amount: Tokens;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Errors that can occur during an ICP Ledger transfer.
|
|
114
|
+
*/
|
|
115
|
+
export type TransferError =
|
|
116
|
+
/** The request is too old. The ledger only accepts requests created within a 24-hour window. */
|
|
117
|
+
{
|
|
118
|
+
TxTooOld: {
|
|
119
|
+
allowed_window_nanos: bigint;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** The fee specified in the transfer request does not match the expected fee. */
|
|
123
|
+
| {
|
|
124
|
+
BadFee: {
|
|
125
|
+
expected_fee: Tokens;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** The ledger has already executed this request. */
|
|
129
|
+
| {
|
|
130
|
+
TxDuplicate: {
|
|
131
|
+
duplicate_of: bigint;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** The specified `created_at_time` is too far in the future. */
|
|
135
|
+
| {
|
|
136
|
+
TxCreatedInFuture: null;
|
|
137
|
+
}
|
|
138
|
+
/** The caller's account does not have enough funds. */
|
|
139
|
+
| {
|
|
140
|
+
InsufficientFunds: {
|
|
141
|
+
balance: Tokens;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The result of an ICP Ledger `transfer` call.
|
|
146
|
+
* Returns the block index of the transaction on success.
|
|
147
|
+
*/
|
|
148
|
+
export type TransferResult = {
|
|
149
|
+
Ok: bigint;
|
|
150
|
+
} | {
|
|
151
|
+
Err: TransferError;
|
|
152
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../../chunk-ZBCLFWQJ.js";import{g as
|
|
1
|
+
import{a as g}from"../../../chunk-ZBCLFWQJ.js";import{g as s}from"../../../chunk-YHNBR22R.js";import"../../../chunk-JU5CZHLY.js";import{a as d}from"../../../chunk-X3EF7OU6.js";import{j,k as c}from"../../../chunk-I3WMKZTG.js";import"../../../chunk-4C666HHU.js";import{schemaFromIdl as _,schemaToIdl as p}from"@junobuild/schema/utils";import{j as t}from"@junobuild/schema";import*as r from"zod";var z=d.required(),m=t.uint8Array(),n=t.strictObject({owner:t.principal(),subaccount:m.optional()}),o=t.bigint(),l=t.strictObject({to:n,fee:o.optional(),memo:t.uint8Array().optional(),from_subaccount:m.optional(),created_at_time:t.bigint().optional(),amount:o}),I=r.union([r.strictObject({GenericError:r.strictObject({message:r.string(),error_code:r.bigint()})}),r.strictObject({TemporarilyUnavailable:r.null()}),r.strictObject({BadBurn:r.strictObject({min_burn_amount:r.bigint()})}),r.strictObject({Duplicate:r.strictObject({duplicate_of:r.bigint()})}),r.strictObject({BadFee:r.strictObject({expected_fee:r.bigint()})}),r.strictObject({CreatedInFuture:r.strictObject({ledger_time:r.bigint()})}),r.strictObject({TooOld:r.null()}),r.strictObject({InsufficientFunds:r.strictObject({balance:r.bigint()})})]),O=r.union([r.strictObject({Ok:r.bigint()}),r.strictObject({Err:I})]),b=t.strictObject({to:n,fee:o.optional(),spender_subaccount:m.optional(),from:n,memo:t.uint8Array().optional(),created_at_time:t.bigint().optional(),amount:o}),A=r.union([r.strictObject({GenericError:r.strictObject({message:r.string(),error_code:r.bigint()})}),r.strictObject({TemporarilyUnavailable:r.null()}),r.strictObject({InsufficientAllowance:r.strictObject({allowance:r.bigint()})}),r.strictObject({BadBurn:r.strictObject({min_burn_amount:r.bigint()})}),r.strictObject({Duplicate:r.strictObject({duplicate_of:r.bigint()})}),r.strictObject({BadFee:r.strictObject({expected_fee:r.bigint()})}),r.strictObject({CreatedInFuture:r.strictObject({ledger_time:r.bigint()})}),r.strictObject({TooOld:r.null()}),r.strictObject({InsufficientFunds:r.strictObject({balance:r.bigint()})})]),T=r.union([r.strictObject({Ok:r.bigint()}),r.strictObject({Err:A})]);var f=class extends g{constructor(e){z.parse(e),super({canisterId:e.canisterId})}icrc1BalanceOf=async({account:e})=>{let i=n.parse(e),a=p({schema:n,value:i});return await s({canisterId:this.canisterId,method:"icrc1_balance_of",args:[[c.Account,a]],result:c.Tokens})};icrc1Transfer=async({args:e})=>{let i=l.parse(e),a=p({schema:l,value:i}),u=await s({canisterId:this.canisterId,method:"icrc1_transfer",args:[[c.TransferArg,a]],result:c.TransferResult});return _({schema:O,value:u})};icrc2TransferFrom=async({args:e})=>{let i=b.parse(e),a=p({schema:b,value:i}),u=await s({canisterId:this.canisterId,method:"icrc2_transfer_from",args:[[c.TransferFromArgs,a]],result:c.TransferFromResult});return _({schema:T,value:u})}};export{n as AccountSchema,z as IcrcCanisterOptionsSchema,j as IcrcIndexIdl,f as IcrcLedgerCanister,c as IcrcLedgerIdl,m as SubaccountSchema,o as TokensSchema,l as TransferArgSchema,I as TransferErrorSchema,b as TransferFromArgSchema,A as TransferFromErrorSchema,T as TransferFromResultSchema,O as TransferResultSchema};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/canisters/ledger/icrc/
|
|
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": "
|
|
6
|
-
"names": ["IcrcCanisterOptionsSchema", "CanisterOptionsSchema", "IcrcLedgerCanister", "Canister", "options", "IcrcCanisterOptionsSchema", "account", "call", "icrc_ledger_did_idl_exports", "args"]
|
|
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 TransferArgSchema,\n TransferFromArgSchema,\n TransferFromResultSchema,\n TransferResultSchema,\n type Account,\n type IcrcCanisterOptions,\n type TransferArg,\n type TransferFromArg,\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 {TransferArg} 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: TransferArg}): Promise<TransferResult> => {\n const parsed = TransferArgSchema.parse(args);\n const idlArgs = schemaToIdl({schema: TransferArgSchema, 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 {TransferFromArg} 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: TransferFromArg}): Promise<TransferFromResult> => {\n const parsed = TransferFromArgSchema.parse(args);\n const idlArgs = schemaToIdl({schema: TransferFromArgSchema, 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 '../../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\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.bigint();\n\n// icrc1_transfer\nexport const TransferArgSchema = 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 TransferFromArgSchema = 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 TransferArg {\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 TransferFromArg {\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"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["schemaFromIdl", "schemaToIdl", "j", "z", "IcrcCanisterOptionsSchema", "CanisterOptionsSchema", "SubaccountSchema", "j", "AccountSchema", "TokensSchema", "TransferArgSchema", "TransferErrorSchema", "TransferResultSchema", "TransferFromArgSchema", "TransferFromErrorSchema", "TransferFromResultSchema", "IcrcLedgerCanister", "Canister", "options", "IcrcCanisterOptionsSchema", "account", "parsed", "AccountSchema", "idlArgs", "schemaToIdl", "call", "icrc_ledger_did_idl_exports", "args", "TransferArgSchema", "idlResult", "schemaFromIdl", "TransferResultSchema", "TransferFromArgSchema", "TransferFromResultSchema"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Canister } from '../../_canister';
|
|
2
|
-
import { type
|
|
3
|
-
import { type IcrcCanisterOptions } from './schemas';
|
|
2
|
+
import { type Account, type IcrcCanisterOptions, type TransferArg, type TransferFromArg, type TransferFromResult, type TransferResult } from './schema';
|
|
4
3
|
/**
|
|
5
4
|
* Provides a simple interface to interact with an ICRC Ledger,
|
|
6
5
|
* when developing Juno Serverless Functions in TypeScript.
|
|
@@ -12,34 +11,34 @@ export declare class IcrcLedgerCanister extends Canister {
|
|
|
12
11
|
/**
|
|
13
12
|
* Returns the balance of an ICRC account.
|
|
14
13
|
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @returns {Promise<
|
|
14
|
+
* @param {Account} account - The account to query.
|
|
15
|
+
* @returns {Promise<bigint>} The token balance for the account.
|
|
17
16
|
*/
|
|
18
17
|
icrc1BalanceOf: ({ account }: {
|
|
19
|
-
account:
|
|
20
|
-
}) => Promise<
|
|
18
|
+
account: Account;
|
|
19
|
+
}) => Promise<bigint>;
|
|
21
20
|
/**
|
|
22
21
|
* Transfers tokens using the ICRC-1 `icrc1_transfer` method.
|
|
23
22
|
*
|
|
24
23
|
* Use this to send tokens from the caller's account to another account
|
|
25
24
|
* when writing Juno Serverless Functions in TypeScript.
|
|
26
25
|
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @returns {Promise<
|
|
26
|
+
* @param {TransferArg} args - Transfer arguments (amount, fee, to, memo, created_at_time, etc.).
|
|
27
|
+
* @returns {Promise<TransferResult>} The result of the transfer.
|
|
29
28
|
*/
|
|
30
29
|
icrc1Transfer: ({ args }: {
|
|
31
|
-
args:
|
|
32
|
-
}) => Promise<
|
|
30
|
+
args: TransferArg;
|
|
31
|
+
}) => Promise<TransferResult>;
|
|
33
32
|
/**
|
|
34
33
|
* Transfers tokens using the ICRC-2 `icrc2_transfer_from` method.
|
|
35
34
|
*
|
|
36
35
|
* Allows transferring tokens from another user's account when an approval
|
|
37
36
|
* has previously been granted via `icrc2_approve`.
|
|
38
37
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
* @returns {Promise<
|
|
38
|
+
* @param {TransferFromArg} args - Transfer-from arguments (amount, from_subaccount, spender, etc.).
|
|
39
|
+
* @returns {Promise<TransferFromResult>} The result of the transfer-from operation.
|
|
41
40
|
*/
|
|
42
41
|
icrc2TransferFrom: ({ args }: {
|
|
43
|
-
args:
|
|
44
|
-
}) => Promise<
|
|
42
|
+
args: TransferFromArg;
|
|
43
|
+
}) => Promise<TransferFromResult>;
|
|
45
44
|
}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import type { Principal } from '@icp-sdk/core/principal';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* @see CanisterOptions
|
|
5
|
+
*/
|
|
6
|
+
export declare const IcrcCanisterOptionsSchema: z.ZodObject<{
|
|
7
|
+
canisterId: z.ZodNonOptional<z.ZodOptional<z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>>>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
/**
|
|
10
|
+
* The options to initialize an Icrc canister.
|
|
11
|
+
*/
|
|
12
|
+
export type IcrcCanisterOptions = z.infer<typeof IcrcCanisterOptionsSchema>;
|
|
13
|
+
export declare const SubaccountSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
14
|
+
export declare const AccountSchema: z.ZodObject<{
|
|
15
|
+
owner: z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>;
|
|
16
|
+
subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
export declare const TokensSchema: z.ZodBigInt;
|
|
19
|
+
export declare const TransferArgSchema: z.ZodObject<{
|
|
20
|
+
to: z.ZodObject<{
|
|
21
|
+
owner: z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>;
|
|
22
|
+
subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
fee: z.ZodOptional<z.ZodBigInt>;
|
|
25
|
+
memo: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
26
|
+
from_subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
27
|
+
created_at_time: z.ZodOptional<z.ZodBigInt>;
|
|
28
|
+
amount: z.ZodBigInt;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
export declare const TransferErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
31
|
+
GenericError: z.ZodObject<{
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
error_code: z.ZodBigInt;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
36
|
+
TemporarilyUnavailable: z.ZodNull;
|
|
37
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
38
|
+
BadBurn: z.ZodObject<{
|
|
39
|
+
min_burn_amount: z.ZodBigInt;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
Duplicate: z.ZodObject<{
|
|
43
|
+
duplicate_of: z.ZodBigInt;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
BadFee: z.ZodObject<{
|
|
47
|
+
expected_fee: z.ZodBigInt;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
CreatedInFuture: z.ZodObject<{
|
|
51
|
+
ledger_time: z.ZodBigInt;
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
TooOld: z.ZodNull;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
InsufficientFunds: z.ZodObject<{
|
|
57
|
+
balance: z.ZodBigInt;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
}, z.core.$strict>]>;
|
|
60
|
+
export declare const TransferResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
61
|
+
Ok: z.ZodBigInt;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
Err: z.ZodUnion<readonly [z.ZodObject<{
|
|
64
|
+
GenericError: z.ZodObject<{
|
|
65
|
+
message: z.ZodString;
|
|
66
|
+
error_code: z.ZodBigInt;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
69
|
+
TemporarilyUnavailable: z.ZodNull;
|
|
70
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
71
|
+
BadBurn: z.ZodObject<{
|
|
72
|
+
min_burn_amount: z.ZodBigInt;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
75
|
+
Duplicate: z.ZodObject<{
|
|
76
|
+
duplicate_of: z.ZodBigInt;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
79
|
+
BadFee: z.ZodObject<{
|
|
80
|
+
expected_fee: z.ZodBigInt;
|
|
81
|
+
}, z.core.$strict>;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
CreatedInFuture: z.ZodObject<{
|
|
84
|
+
ledger_time: z.ZodBigInt;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
87
|
+
TooOld: z.ZodNull;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
InsufficientFunds: z.ZodObject<{
|
|
90
|
+
balance: z.ZodBigInt;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
}, z.core.$strict>]>;
|
|
93
|
+
}, z.core.$strict>]>;
|
|
94
|
+
export declare const TransferFromArgSchema: z.ZodObject<{
|
|
95
|
+
to: z.ZodObject<{
|
|
96
|
+
owner: z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>;
|
|
97
|
+
subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
98
|
+
}, z.core.$strict>;
|
|
99
|
+
fee: z.ZodOptional<z.ZodBigInt>;
|
|
100
|
+
spender_subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
101
|
+
from: z.ZodObject<{
|
|
102
|
+
owner: z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>;
|
|
103
|
+
subaccount: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
memo: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
106
|
+
created_at_time: z.ZodOptional<z.ZodBigInt>;
|
|
107
|
+
amount: z.ZodBigInt;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
export declare const TransferFromErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
110
|
+
GenericError: z.ZodObject<{
|
|
111
|
+
message: z.ZodString;
|
|
112
|
+
error_code: z.ZodBigInt;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
115
|
+
TemporarilyUnavailable: z.ZodNull;
|
|
116
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
117
|
+
InsufficientAllowance: z.ZodObject<{
|
|
118
|
+
allowance: z.ZodBigInt;
|
|
119
|
+
}, z.core.$strict>;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
BadBurn: z.ZodObject<{
|
|
122
|
+
min_burn_amount: z.ZodBigInt;
|
|
123
|
+
}, z.core.$strict>;
|
|
124
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
125
|
+
Duplicate: z.ZodObject<{
|
|
126
|
+
duplicate_of: z.ZodBigInt;
|
|
127
|
+
}, z.core.$strict>;
|
|
128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
129
|
+
BadFee: z.ZodObject<{
|
|
130
|
+
expected_fee: z.ZodBigInt;
|
|
131
|
+
}, z.core.$strict>;
|
|
132
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
133
|
+
CreatedInFuture: z.ZodObject<{
|
|
134
|
+
ledger_time: z.ZodBigInt;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
137
|
+
TooOld: z.ZodNull;
|
|
138
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
139
|
+
InsufficientFunds: z.ZodObject<{
|
|
140
|
+
balance: z.ZodBigInt;
|
|
141
|
+
}, z.core.$strict>;
|
|
142
|
+
}, z.core.$strict>]>;
|
|
143
|
+
export declare const TransferFromResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
144
|
+
Ok: z.ZodBigInt;
|
|
145
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
146
|
+
Err: z.ZodUnion<readonly [z.ZodObject<{
|
|
147
|
+
GenericError: z.ZodObject<{
|
|
148
|
+
message: z.ZodString;
|
|
149
|
+
error_code: z.ZodBigInt;
|
|
150
|
+
}, z.core.$strict>;
|
|
151
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
152
|
+
TemporarilyUnavailable: z.ZodNull;
|
|
153
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
154
|
+
InsufficientAllowance: z.ZodObject<{
|
|
155
|
+
allowance: z.ZodBigInt;
|
|
156
|
+
}, z.core.$strict>;
|
|
157
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
158
|
+
BadBurn: z.ZodObject<{
|
|
159
|
+
min_burn_amount: z.ZodBigInt;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
162
|
+
Duplicate: z.ZodObject<{
|
|
163
|
+
duplicate_of: z.ZodBigInt;
|
|
164
|
+
}, z.core.$strict>;
|
|
165
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
166
|
+
BadFee: z.ZodObject<{
|
|
167
|
+
expected_fee: z.ZodBigInt;
|
|
168
|
+
}, z.core.$strict>;
|
|
169
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
170
|
+
CreatedInFuture: z.ZodObject<{
|
|
171
|
+
ledger_time: z.ZodBigInt;
|
|
172
|
+
}, z.core.$strict>;
|
|
173
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
174
|
+
TooOld: z.ZodNull;
|
|
175
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
176
|
+
InsufficientFunds: z.ZodObject<{
|
|
177
|
+
balance: z.ZodBigInt;
|
|
178
|
+
}, z.core.$strict>;
|
|
179
|
+
}, z.core.$strict>]>;
|
|
180
|
+
}, z.core.$strict>]>;
|
|
181
|
+
/**
|
|
182
|
+
* Subaccount is an arbitrary 32-byte array used to compute the source address.
|
|
183
|
+
*/
|
|
184
|
+
export type Subaccount = Uint8Array;
|
|
185
|
+
/**
|
|
186
|
+
* An ICRC account, consisting of an owner principal and an optional subaccount.
|
|
187
|
+
*/
|
|
188
|
+
export interface Account {
|
|
189
|
+
/** The account owner. */
|
|
190
|
+
owner: Principal;
|
|
191
|
+
/** An optional subaccount to distinguish multiple accounts for the same owner. */
|
|
192
|
+
subaccount?: Subaccount;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Errors that can occur during an ICRC-1 transfer.
|
|
196
|
+
*/
|
|
197
|
+
export type TransferError =
|
|
198
|
+
/** An error not covered by the other variants. */
|
|
199
|
+
{
|
|
200
|
+
GenericError: {
|
|
201
|
+
message: string;
|
|
202
|
+
error_code: bigint;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** The ledger is temporarily unavailable. */
|
|
206
|
+
| {
|
|
207
|
+
TemporarilyUnavailable: null;
|
|
208
|
+
}
|
|
209
|
+
/** The burn amount is below the minimum. */
|
|
210
|
+
| {
|
|
211
|
+
BadBurn: {
|
|
212
|
+
min_burn_amount: bigint;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/** The transaction is a duplicate. */
|
|
216
|
+
| {
|
|
217
|
+
Duplicate: {
|
|
218
|
+
duplicate_of: bigint;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/** The fee does not match the expected fee. */
|
|
222
|
+
| {
|
|
223
|
+
BadFee: {
|
|
224
|
+
expected_fee: bigint;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** The `created_at_time` is too far in the future. */
|
|
228
|
+
| {
|
|
229
|
+
CreatedInFuture: {
|
|
230
|
+
ledger_time: bigint;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/** The transaction is too old. */
|
|
234
|
+
| {
|
|
235
|
+
TooOld: null;
|
|
236
|
+
}
|
|
237
|
+
/** The account does not have enough funds. */
|
|
238
|
+
| {
|
|
239
|
+
InsufficientFunds: {
|
|
240
|
+
balance: bigint;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* The result of an ICRC-1 `icrc1_transfer` call.
|
|
245
|
+
* Returns the block index of the transaction on success.
|
|
246
|
+
*/
|
|
247
|
+
export type TransferResult = {
|
|
248
|
+
Ok: bigint;
|
|
249
|
+
} | {
|
|
250
|
+
Err: TransferError;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Arguments for the ICRC-1 `icrc1_transfer` call.
|
|
254
|
+
*/
|
|
255
|
+
export interface TransferArg {
|
|
256
|
+
/** The destination account. */
|
|
257
|
+
to: Account;
|
|
258
|
+
/** An optional fee. Uses the default ledger fee if not provided. */
|
|
259
|
+
fee?: bigint;
|
|
260
|
+
/** An optional memo for the transaction. */
|
|
261
|
+
memo?: Uint8Array;
|
|
262
|
+
/** An optional subaccount to transfer from. Uses the default subaccount if not provided. */
|
|
263
|
+
from_subaccount?: Subaccount;
|
|
264
|
+
/** An optional timestamp. Uses current IC time if not provided. */
|
|
265
|
+
created_at_time?: bigint;
|
|
266
|
+
/** The amount to transfer. */
|
|
267
|
+
amount: bigint;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Errors that can occur during an ICRC-2 transfer-from.
|
|
271
|
+
*/
|
|
272
|
+
export type TransferFromError =
|
|
273
|
+
/** An error not covered by the other variants. */
|
|
274
|
+
{
|
|
275
|
+
GenericError: {
|
|
276
|
+
message: string;
|
|
277
|
+
error_code: bigint;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** The ledger is temporarily unavailable. */
|
|
281
|
+
| {
|
|
282
|
+
TemporarilyUnavailable: null;
|
|
283
|
+
}
|
|
284
|
+
/** The spender's allowance is insufficient. */
|
|
285
|
+
| {
|
|
286
|
+
InsufficientAllowance: {
|
|
287
|
+
allowance: bigint;
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/** The burn amount is below the minimum. */
|
|
291
|
+
| {
|
|
292
|
+
BadBurn: {
|
|
293
|
+
min_burn_amount: bigint;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/** The transaction is a duplicate. */
|
|
297
|
+
| {
|
|
298
|
+
Duplicate: {
|
|
299
|
+
duplicate_of: bigint;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/** The fee does not match the expected fee. */
|
|
303
|
+
| {
|
|
304
|
+
BadFee: {
|
|
305
|
+
expected_fee: bigint;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** The `created_at_time` is too far in the future. */
|
|
309
|
+
| {
|
|
310
|
+
CreatedInFuture: {
|
|
311
|
+
ledger_time: bigint;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/** The transaction is too old. */
|
|
315
|
+
| {
|
|
316
|
+
TooOld: null;
|
|
317
|
+
}
|
|
318
|
+
/** The account does not have enough funds. */
|
|
319
|
+
| {
|
|
320
|
+
InsufficientFunds: {
|
|
321
|
+
balance: bigint;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* The result of an ICRC-2 `icrc2_transfer_from` call.
|
|
326
|
+
* Returns the block index of the transaction on success.
|
|
327
|
+
*/
|
|
328
|
+
export type TransferFromResult = {
|
|
329
|
+
Ok: bigint;
|
|
330
|
+
} | {
|
|
331
|
+
Err: TransferFromError;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Arguments for the ICRC-2 `icrc2_transfer_from` call.
|
|
335
|
+
*/
|
|
336
|
+
export interface TransferFromArg {
|
|
337
|
+
/** The destination account. */
|
|
338
|
+
to: Account;
|
|
339
|
+
/** An optional fee. Uses the default ledger fee if not provided. */
|
|
340
|
+
fee?: bigint;
|
|
341
|
+
/** An optional subaccount of the spender. */
|
|
342
|
+
spender_subaccount?: Subaccount;
|
|
343
|
+
/** The account to transfer from. */
|
|
344
|
+
from: Account;
|
|
345
|
+
/** An optional memo for the transaction. */
|
|
346
|
+
memo?: Uint8Array;
|
|
347
|
+
/** An optional timestamp. Uses current IC time if not provided. */
|
|
348
|
+
created_at_time?: bigint;
|
|
349
|
+
/** The amount to transfer. */
|
|
350
|
+
amount: bigint;
|
|
351
|
+
}
|
package/canisters/nns/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{l as n,m as s}from"../../chunk-I3WMKZTG.js";import"../../chunk-4C666HHU.js";export{n as NnsGovernanceIdl,s as NnsSnsWasmIdl};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/canisters/sns/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{m as n,n as s,o as S,p as e}from"../../chunk-I3WMKZTG.js";import"../../chunk-4C666HHU.js";export{n as NnsSnsWasmIdl,s as SnsGovernanceIdl,S as SnsRootIdl,e as SnsSwapIdl};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|