@junobuild/admin 0.0.32 → 0.0.33

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.
@@ -0,0 +1,45 @@
1
+ import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
2
+ import type {IDL} from '@dfinity/candid';
3
+ import type {Principal} from '@dfinity/principal';
4
+
5
+ import {_SERVICE} from './index.did';
6
+
7
+ export declare const idlFactory: IDL.InterfaceFactory;
8
+ export declare const canisterId: string;
9
+
10
+ export declare interface CreateActorOptions {
11
+ /**
12
+ * @see {@link Agent}
13
+ */
14
+ agent?: Agent;
15
+ /**
16
+ * @see {@link HttpAgentOptions}
17
+ */
18
+ agentOptions?: HttpAgentOptions;
19
+ /**
20
+ * @see {@link ActorConfig}
21
+ */
22
+ actorOptions?: ActorConfig;
23
+ }
24
+
25
+ /**
26
+ * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
27
+ * @constructs {@link ActorSubClass}
28
+ * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
29
+ * @param {CreateActorOptions} options - see {@link CreateActorOptions}
30
+ * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
31
+ * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
32
+ * @see {@link HttpAgentOptions}
33
+ * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
34
+ * @see {@link ActorConfig}
35
+ */
36
+ export declare const createActor: (
37
+ canisterId: string | Principal,
38
+ options?: CreateActorOptions
39
+ ) => ActorSubclass<_SERVICE>;
40
+
41
+ /**
42
+ * Intialized Actor using default settings, ready to talk to a canister using its candid interface
43
+ * @constructs {@link ActorSubClass}
44
+ */
45
+ export declare const index: ActorSubclass<_SERVICE>;
@@ -0,0 +1,68 @@
1
+ type GetAccountIdentifierTransactionsArgs = record {
2
+ max_results : nat64;
3
+ start : opt nat64;
4
+ account_identifier : text;
5
+ };
6
+ type GetAccountIdentifierTransactionsError = record { message : text };
7
+ type GetAccountIdentifierTransactionsResponse = record {
8
+ balance : nat64;
9
+ transactions : vec TransactionWithId;
10
+ oldest_tx_id : opt nat64;
11
+ };
12
+ type GetBlocksRequest = record { start : nat; length : nat };
13
+ type GetBlocksResponse = record { blocks : vec vec nat8; chain_length : nat64 };
14
+ type HttpRequest = record {
15
+ url : text;
16
+ method : text;
17
+ body : vec nat8;
18
+ headers : vec record { text; text };
19
+ };
20
+ type HttpResponse = record {
21
+ body : vec nat8;
22
+ headers : vec record { text; text };
23
+ status_code : nat16;
24
+ };
25
+ type InitArg = record { ledger_id : principal };
26
+ type Operation = variant {
27
+ Approve : record {
28
+ fee : Tokens;
29
+ from : text;
30
+ allowance : Tokens;
31
+ expires_at : opt TimeStamp;
32
+ spender : text;
33
+ };
34
+ Burn : record { from : text; amount : Tokens };
35
+ Mint : record { to : text; amount : Tokens };
36
+ Transfer : record { to : text; fee : Tokens; from : text; amount : Tokens };
37
+ TransferFrom : record {
38
+ to : text;
39
+ fee : Tokens;
40
+ from : text;
41
+ amount : Tokens;
42
+ spender : text;
43
+ };
44
+ };
45
+ type Result = variant {
46
+ Ok : GetAccountIdentifierTransactionsResponse;
47
+ Err : GetAccountIdentifierTransactionsError;
48
+ };
49
+ type Status = record { num_blocks_synced : nat64 };
50
+ type TimeStamp = record { timestamp_nanos : nat64 };
51
+ type Tokens = record { e8s : nat64 };
52
+ type Transaction = record {
53
+ memo : nat64;
54
+ icrc1_memo : opt vec nat8;
55
+ operation : Operation;
56
+ created_at_time : opt TimeStamp;
57
+ };
58
+ type TransactionWithId = record { id : nat64; transaction : Transaction };
59
+ service : (InitArg) -> {
60
+ get_account_identifier_balance : (text) -> (nat64) query;
61
+ get_account_identifier_transactions : (
62
+ GetAccountIdentifierTransactionsArgs,
63
+ ) -> (Result) query;
64
+ get_blocks : (GetBlocksRequest) -> (GetBlocksResponse) query;
65
+ http_request : (HttpRequest) -> (HttpResponse) query;
66
+ ledger_id : () -> (principal) query;
67
+ status : () -> (Status) query;
68
+ }
@@ -0,0 +1,97 @@
1
+ import type {ActorMethod} from '@dfinity/agent';
2
+ import type {Principal} from '@dfinity/principal';
3
+
4
+ export interface GetAccountIdentifierTransactionsArgs {
5
+ max_results: bigint;
6
+ start: [] | [bigint];
7
+ account_identifier: string;
8
+ }
9
+ export interface GetAccountIdentifierTransactionsError {
10
+ message: string;
11
+ }
12
+ export interface GetAccountIdentifierTransactionsResponse {
13
+ balance: bigint;
14
+ transactions: Array<TransactionWithId>;
15
+ oldest_tx_id: [] | [bigint];
16
+ }
17
+ export interface GetBlocksRequest {
18
+ start: bigint;
19
+ length: bigint;
20
+ }
21
+ export interface GetBlocksResponse {
22
+ blocks: Array<Uint8Array | number[]>;
23
+ chain_length: bigint;
24
+ }
25
+ export interface HttpRequest {
26
+ url: string;
27
+ method: string;
28
+ body: Uint8Array | number[];
29
+ headers: Array<[string, string]>;
30
+ }
31
+ export interface HttpResponse {
32
+ body: Uint8Array | number[];
33
+ headers: Array<[string, string]>;
34
+ status_code: number;
35
+ }
36
+ export interface InitArg {
37
+ ledger_id: Principal;
38
+ }
39
+ export type Operation =
40
+ | {
41
+ Approve: {
42
+ fee: Tokens;
43
+ from: string;
44
+ allowance: Tokens;
45
+ expires_at: [] | [TimeStamp];
46
+ spender: string;
47
+ };
48
+ }
49
+ | {Burn: {from: string; amount: Tokens}}
50
+ | {Mint: {to: string; amount: Tokens}}
51
+ | {
52
+ Transfer: {
53
+ to: string;
54
+ fee: Tokens;
55
+ from: string;
56
+ amount: Tokens;
57
+ };
58
+ }
59
+ | {
60
+ TransferFrom: {
61
+ to: string;
62
+ fee: Tokens;
63
+ from: string;
64
+ amount: Tokens;
65
+ spender: string;
66
+ };
67
+ };
68
+ export type Result =
69
+ | {Ok: GetAccountIdentifierTransactionsResponse}
70
+ | {Err: GetAccountIdentifierTransactionsError};
71
+ export interface Status {
72
+ num_blocks_synced: bigint;
73
+ }
74
+ export interface TimeStamp {
75
+ timestamp_nanos: bigint;
76
+ }
77
+ export interface Tokens {
78
+ e8s: bigint;
79
+ }
80
+ export interface Transaction {
81
+ memo: bigint;
82
+ icrc1_memo: [] | [Uint8Array | number[]];
83
+ operation: Operation;
84
+ created_at_time: [] | [TimeStamp];
85
+ }
86
+ export interface TransactionWithId {
87
+ id: bigint;
88
+ transaction: Transaction;
89
+ }
90
+ export interface _SERVICE {
91
+ get_account_identifier_balance: ActorMethod<[string], bigint>;
92
+ get_account_identifier_transactions: ActorMethod<[GetAccountIdentifierTransactionsArgs], Result>;
93
+ get_blocks: ActorMethod<[GetBlocksRequest], GetBlocksResponse>;
94
+ http_request: ActorMethod<[HttpRequest], HttpResponse>;
95
+ ledger_id: ActorMethod<[], Principal>;
96
+ status: ActorMethod<[], Status>;
97
+ }
@@ -0,0 +1,94 @@
1
+ // @ts-ignore
2
+ export const idlFactory = ({IDL}) => {
3
+ const InitArg = IDL.Record({ledger_id: IDL.Principal});
4
+ const GetAccountIdentifierTransactionsArgs = IDL.Record({
5
+ max_results: IDL.Nat64,
6
+ start: IDL.Opt(IDL.Nat64),
7
+ account_identifier: IDL.Text
8
+ });
9
+ const Tokens = IDL.Record({e8s: IDL.Nat64});
10
+ const TimeStamp = IDL.Record({timestamp_nanos: IDL.Nat64});
11
+ const Operation = IDL.Variant({
12
+ Approve: IDL.Record({
13
+ fee: Tokens,
14
+ from: IDL.Text,
15
+ allowance: Tokens,
16
+ expires_at: IDL.Opt(TimeStamp),
17
+ spender: IDL.Text
18
+ }),
19
+ Burn: IDL.Record({from: IDL.Text, amount: Tokens}),
20
+ Mint: IDL.Record({to: IDL.Text, amount: Tokens}),
21
+ Transfer: IDL.Record({
22
+ to: IDL.Text,
23
+ fee: Tokens,
24
+ from: IDL.Text,
25
+ amount: Tokens
26
+ }),
27
+ TransferFrom: IDL.Record({
28
+ to: IDL.Text,
29
+ fee: Tokens,
30
+ from: IDL.Text,
31
+ amount: Tokens,
32
+ spender: IDL.Text
33
+ })
34
+ });
35
+ const Transaction = IDL.Record({
36
+ memo: IDL.Nat64,
37
+ icrc1_memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
38
+ operation: Operation,
39
+ created_at_time: IDL.Opt(TimeStamp)
40
+ });
41
+ const TransactionWithId = IDL.Record({
42
+ id: IDL.Nat64,
43
+ transaction: Transaction
44
+ });
45
+ const GetAccountIdentifierTransactionsResponse = IDL.Record({
46
+ balance: IDL.Nat64,
47
+ transactions: IDL.Vec(TransactionWithId),
48
+ oldest_tx_id: IDL.Opt(IDL.Nat64)
49
+ });
50
+ const GetAccountIdentifierTransactionsError = IDL.Record({
51
+ message: IDL.Text
52
+ });
53
+ const Result = IDL.Variant({
54
+ Ok: GetAccountIdentifierTransactionsResponse,
55
+ Err: GetAccountIdentifierTransactionsError
56
+ });
57
+ const GetBlocksRequest = IDL.Record({
58
+ start: IDL.Nat,
59
+ length: IDL.Nat
60
+ });
61
+ const GetBlocksResponse = IDL.Record({
62
+ blocks: IDL.Vec(IDL.Vec(IDL.Nat8)),
63
+ chain_length: IDL.Nat64
64
+ });
65
+ const HttpRequest = IDL.Record({
66
+ url: IDL.Text,
67
+ method: IDL.Text,
68
+ body: IDL.Vec(IDL.Nat8),
69
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))
70
+ });
71
+ const HttpResponse = IDL.Record({
72
+ body: IDL.Vec(IDL.Nat8),
73
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
74
+ status_code: IDL.Nat16
75
+ });
76
+ const Status = IDL.Record({num_blocks_synced: IDL.Nat64});
77
+ return IDL.Service({
78
+ get_account_identifier_balance: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
79
+ get_account_identifier_transactions: IDL.Func(
80
+ [GetAccountIdentifierTransactionsArgs],
81
+ [Result],
82
+ ['query']
83
+ ),
84
+ get_blocks: IDL.Func([GetBlocksRequest], [GetBlocksResponse], ['query']),
85
+ http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
86
+ ledger_id: IDL.Func([], [IDL.Principal], ['query']),
87
+ status: IDL.Func([], [Status], ['query'])
88
+ });
89
+ };
90
+ // @ts-ignore
91
+ export const init = ({IDL}) => {
92
+ const InitArg = IDL.Record({ledger_id: IDL.Principal});
93
+ return [InitArg];
94
+ };
@@ -0,0 +1,37 @@
1
+ import {Actor, HttpAgent} from '@dfinity/agent';
2
+
3
+ // Imports and re-exports candid interface
4
+ import {idlFactory} from './index.did.js';
5
+ export {idlFactory} from './index.did.js';
6
+
7
+ /* CANISTER_ID is replaced by webpack based on node environment
8
+ * Note: canister environment variable will be standardized as
9
+ * process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
10
+ * beginning in dfx 0.15.0
11
+ */
12
+ export const canisterId = process.env.CANISTER_ID_INDEX || process.env.INDEX_CANISTER_ID;
13
+
14
+ export const createActor = (canisterId, options = {}) => {
15
+ const agent = options.agent || new HttpAgent({...options.agentOptions});
16
+
17
+ if (options.agent && options.agentOptions) {
18
+ console.warn(
19
+ 'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
20
+ );
21
+ }
22
+
23
+ // Fetch root key for certificate validation during development
24
+ if (process.env.DFX_NETWORK !== 'ic') {
25
+ agent.fetchRootKey().catch((err) => {
26
+ console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
27
+ console.error(err);
28
+ });
29
+ }
30
+
31
+ // Creates an actor with using the candid interface and the HttpAgent
32
+ return Actor.createActor(idlFactory, {
33
+ agent,
34
+ canisterId,
35
+ ...options.actorOptions
36
+ });
37
+ };
@@ -0,0 +1,45 @@
1
+ import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
2
+ import type {IDL} from '@dfinity/candid';
3
+ import type {Principal} from '@dfinity/principal';
4
+
5
+ import {_SERVICE} from './index.did';
6
+
7
+ export declare const idlFactory: IDL.InterfaceFactory;
8
+ export declare const canisterId: string;
9
+
10
+ export declare interface CreateActorOptions {
11
+ /**
12
+ * @see {@link Agent}
13
+ */
14
+ agent?: Agent;
15
+ /**
16
+ * @see {@link HttpAgentOptions}
17
+ */
18
+ agentOptions?: HttpAgentOptions;
19
+ /**
20
+ * @see {@link ActorConfig}
21
+ */
22
+ actorOptions?: ActorConfig;
23
+ }
24
+
25
+ /**
26
+ * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
27
+ * @constructs {@link ActorSubClass}
28
+ * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
29
+ * @param {CreateActorOptions} options - see {@link CreateActorOptions}
30
+ * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
31
+ * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
32
+ * @see {@link HttpAgentOptions}
33
+ * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
34
+ * @see {@link ActorConfig}
35
+ */
36
+ export declare const createActor: (
37
+ canisterId: string | Principal,
38
+ options?: CreateActorOptions
39
+ ) => ActorSubclass<_SERVICE>;
40
+
41
+ /**
42
+ * Intialized Actor using default settings, ready to talk to a canister using its candid interface
43
+ * @constructs {@link ActorSubClass}
44
+ */
45
+ export declare const index: ActorSubclass<_SERVICE>;
@@ -0,0 +1,68 @@
1
+ type GetAccountIdentifierTransactionsArgs = record {
2
+ max_results : nat64;
3
+ start : opt nat64;
4
+ account_identifier : text;
5
+ };
6
+ type GetAccountIdentifierTransactionsError = record { message : text };
7
+ type GetAccountIdentifierTransactionsResponse = record {
8
+ balance : nat64;
9
+ transactions : vec TransactionWithId;
10
+ oldest_tx_id : opt nat64;
11
+ };
12
+ type GetBlocksRequest = record { start : nat; length : nat };
13
+ type GetBlocksResponse = record { blocks : vec vec nat8; chain_length : nat64 };
14
+ type HttpRequest = record {
15
+ url : text;
16
+ method : text;
17
+ body : vec nat8;
18
+ headers : vec record { text; text };
19
+ };
20
+ type HttpResponse = record {
21
+ body : vec nat8;
22
+ headers : vec record { text; text };
23
+ status_code : nat16;
24
+ };
25
+ type InitArg = record { ledger_id : principal };
26
+ type Operation = variant {
27
+ Approve : record {
28
+ fee : Tokens;
29
+ from : text;
30
+ allowance : Tokens;
31
+ expires_at : opt TimeStamp;
32
+ spender : text;
33
+ };
34
+ Burn : record { from : text; amount : Tokens };
35
+ Mint : record { to : text; amount : Tokens };
36
+ Transfer : record { to : text; fee : Tokens; from : text; amount : Tokens };
37
+ TransferFrom : record {
38
+ to : text;
39
+ fee : Tokens;
40
+ from : text;
41
+ amount : Tokens;
42
+ spender : text;
43
+ };
44
+ };
45
+ type Result = variant {
46
+ Ok : GetAccountIdentifierTransactionsResponse;
47
+ Err : GetAccountIdentifierTransactionsError;
48
+ };
49
+ type Status = record { num_blocks_synced : nat64 };
50
+ type TimeStamp = record { timestamp_nanos : nat64 };
51
+ type Tokens = record { e8s : nat64 };
52
+ type Transaction = record {
53
+ memo : nat64;
54
+ icrc1_memo : opt vec nat8;
55
+ operation : Operation;
56
+ created_at_time : opt TimeStamp;
57
+ };
58
+ type TransactionWithId = record { id : nat64; transaction : Transaction };
59
+ service : (InitArg) -> {
60
+ get_account_identifier_balance : (text) -> (nat64) query;
61
+ get_account_identifier_transactions : (
62
+ GetAccountIdentifierTransactionsArgs,
63
+ ) -> (Result) query;
64
+ get_blocks : (GetBlocksRequest) -> (GetBlocksResponse) query;
65
+ http_request : (HttpRequest) -> (HttpResponse) query;
66
+ ledger_id : () -> (principal) query;
67
+ status : () -> (Status) query;
68
+ }
@@ -0,0 +1,97 @@
1
+ import type {ActorMethod} from '@dfinity/agent';
2
+ import type {Principal} from '@dfinity/principal';
3
+
4
+ export interface GetAccountIdentifierTransactionsArgs {
5
+ max_results: bigint;
6
+ start: [] | [bigint];
7
+ account_identifier: string;
8
+ }
9
+ export interface GetAccountIdentifierTransactionsError {
10
+ message: string;
11
+ }
12
+ export interface GetAccountIdentifierTransactionsResponse {
13
+ balance: bigint;
14
+ transactions: Array<TransactionWithId>;
15
+ oldest_tx_id: [] | [bigint];
16
+ }
17
+ export interface GetBlocksRequest {
18
+ start: bigint;
19
+ length: bigint;
20
+ }
21
+ export interface GetBlocksResponse {
22
+ blocks: Array<Uint8Array | number[]>;
23
+ chain_length: bigint;
24
+ }
25
+ export interface HttpRequest {
26
+ url: string;
27
+ method: string;
28
+ body: Uint8Array | number[];
29
+ headers: Array<[string, string]>;
30
+ }
31
+ export interface HttpResponse {
32
+ body: Uint8Array | number[];
33
+ headers: Array<[string, string]>;
34
+ status_code: number;
35
+ }
36
+ export interface InitArg {
37
+ ledger_id: Principal;
38
+ }
39
+ export type Operation =
40
+ | {
41
+ Approve: {
42
+ fee: Tokens;
43
+ from: string;
44
+ allowance: Tokens;
45
+ expires_at: [] | [TimeStamp];
46
+ spender: string;
47
+ };
48
+ }
49
+ | {Burn: {from: string; amount: Tokens}}
50
+ | {Mint: {to: string; amount: Tokens}}
51
+ | {
52
+ Transfer: {
53
+ to: string;
54
+ fee: Tokens;
55
+ from: string;
56
+ amount: Tokens;
57
+ };
58
+ }
59
+ | {
60
+ TransferFrom: {
61
+ to: string;
62
+ fee: Tokens;
63
+ from: string;
64
+ amount: Tokens;
65
+ spender: string;
66
+ };
67
+ };
68
+ export type Result =
69
+ | {Ok: GetAccountIdentifierTransactionsResponse}
70
+ | {Err: GetAccountIdentifierTransactionsError};
71
+ export interface Status {
72
+ num_blocks_synced: bigint;
73
+ }
74
+ export interface TimeStamp {
75
+ timestamp_nanos: bigint;
76
+ }
77
+ export interface Tokens {
78
+ e8s: bigint;
79
+ }
80
+ export interface Transaction {
81
+ memo: bigint;
82
+ icrc1_memo: [] | [Uint8Array | number[]];
83
+ operation: Operation;
84
+ created_at_time: [] | [TimeStamp];
85
+ }
86
+ export interface TransactionWithId {
87
+ id: bigint;
88
+ transaction: Transaction;
89
+ }
90
+ export interface _SERVICE {
91
+ get_account_identifier_balance: ActorMethod<[string], bigint>;
92
+ get_account_identifier_transactions: ActorMethod<[GetAccountIdentifierTransactionsArgs], Result>;
93
+ get_blocks: ActorMethod<[GetBlocksRequest], GetBlocksResponse>;
94
+ http_request: ActorMethod<[HttpRequest], HttpResponse>;
95
+ ledger_id: ActorMethod<[], Principal>;
96
+ status: ActorMethod<[], Status>;
97
+ }
@@ -0,0 +1,94 @@
1
+ // @ts-ignore
2
+ export const idlFactory = ({IDL}) => {
3
+ const InitArg = IDL.Record({ledger_id: IDL.Principal});
4
+ const GetAccountIdentifierTransactionsArgs = IDL.Record({
5
+ max_results: IDL.Nat64,
6
+ start: IDL.Opt(IDL.Nat64),
7
+ account_identifier: IDL.Text
8
+ });
9
+ const Tokens = IDL.Record({e8s: IDL.Nat64});
10
+ const TimeStamp = IDL.Record({timestamp_nanos: IDL.Nat64});
11
+ const Operation = IDL.Variant({
12
+ Approve: IDL.Record({
13
+ fee: Tokens,
14
+ from: IDL.Text,
15
+ allowance: Tokens,
16
+ expires_at: IDL.Opt(TimeStamp),
17
+ spender: IDL.Text
18
+ }),
19
+ Burn: IDL.Record({from: IDL.Text, amount: Tokens}),
20
+ Mint: IDL.Record({to: IDL.Text, amount: Tokens}),
21
+ Transfer: IDL.Record({
22
+ to: IDL.Text,
23
+ fee: Tokens,
24
+ from: IDL.Text,
25
+ amount: Tokens
26
+ }),
27
+ TransferFrom: IDL.Record({
28
+ to: IDL.Text,
29
+ fee: Tokens,
30
+ from: IDL.Text,
31
+ amount: Tokens,
32
+ spender: IDL.Text
33
+ })
34
+ });
35
+ const Transaction = IDL.Record({
36
+ memo: IDL.Nat64,
37
+ icrc1_memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
38
+ operation: Operation,
39
+ created_at_time: IDL.Opt(TimeStamp)
40
+ });
41
+ const TransactionWithId = IDL.Record({
42
+ id: IDL.Nat64,
43
+ transaction: Transaction
44
+ });
45
+ const GetAccountIdentifierTransactionsResponse = IDL.Record({
46
+ balance: IDL.Nat64,
47
+ transactions: IDL.Vec(TransactionWithId),
48
+ oldest_tx_id: IDL.Opt(IDL.Nat64)
49
+ });
50
+ const GetAccountIdentifierTransactionsError = IDL.Record({
51
+ message: IDL.Text
52
+ });
53
+ const Result = IDL.Variant({
54
+ Ok: GetAccountIdentifierTransactionsResponse,
55
+ Err: GetAccountIdentifierTransactionsError
56
+ });
57
+ const GetBlocksRequest = IDL.Record({
58
+ start: IDL.Nat,
59
+ length: IDL.Nat
60
+ });
61
+ const GetBlocksResponse = IDL.Record({
62
+ blocks: IDL.Vec(IDL.Vec(IDL.Nat8)),
63
+ chain_length: IDL.Nat64
64
+ });
65
+ const HttpRequest = IDL.Record({
66
+ url: IDL.Text,
67
+ method: IDL.Text,
68
+ body: IDL.Vec(IDL.Nat8),
69
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))
70
+ });
71
+ const HttpResponse = IDL.Record({
72
+ body: IDL.Vec(IDL.Nat8),
73
+ headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
74
+ status_code: IDL.Nat16
75
+ });
76
+ const Status = IDL.Record({num_blocks_synced: IDL.Nat64});
77
+ return IDL.Service({
78
+ get_account_identifier_balance: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
79
+ get_account_identifier_transactions: IDL.Func(
80
+ [GetAccountIdentifierTransactionsArgs],
81
+ [Result],
82
+ ['query']
83
+ ),
84
+ get_blocks: IDL.Func([GetBlocksRequest], [GetBlocksResponse], ['query']),
85
+ http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
86
+ ledger_id: IDL.Func([], [IDL.Principal], ['query']),
87
+ status: IDL.Func([], [Status], ['query'])
88
+ });
89
+ };
90
+ // @ts-ignore
91
+ export const init = ({IDL}) => {
92
+ const InitArg = IDL.Record({ledger_id: IDL.Principal});
93
+ return [InitArg];
94
+ };
@@ -0,0 +1,37 @@
1
+ import {Actor, HttpAgent} from '@dfinity/agent';
2
+
3
+ // Imports and re-exports candid interface
4
+ import {idlFactory} from './index.did.js';
5
+ export {idlFactory} from './index.did.js';
6
+
7
+ /* CANISTER_ID is replaced by webpack based on node environment
8
+ * Note: canister environment variable will be standardized as
9
+ * process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
10
+ * beginning in dfx 0.15.0
11
+ */
12
+ export const canisterId = process.env.CANISTER_ID_INDEX || process.env.INDEX_CANISTER_ID;
13
+
14
+ export const createActor = (canisterId, options = {}) => {
15
+ const agent = options.agent || new HttpAgent({...options.agentOptions});
16
+
17
+ if (options.agent && options.agentOptions) {
18
+ console.warn(
19
+ 'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
20
+ );
21
+ }
22
+
23
+ // Fetch root key for certificate validation during development
24
+ if (process.env.DFX_NETWORK !== 'ic') {
25
+ agent.fetchRootKey().catch((err) => {
26
+ console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
27
+ console.error(err);
28
+ });
29
+ }
30
+
31
+ // Creates an actor with using the candid interface and the HttpAgent
32
+ return Actor.createActor(idlFactory, {
33
+ agent,
34
+ canisterId,
35
+ ...options.actorOptions
36
+ });
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/admin",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "A library for interfacing with admin features of Juno",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",