@junobuild/admin 0.0.3 → 0.0.5
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/dist/browser/canisterStatus-D52DQGXX.js +2 -0
- package/dist/browser/chunk-CAKYEEJ6.js +35 -0
- package/dist/browser/chunk-CAKYEEJ6.js.map +7 -0
- package/dist/browser/index.js +32 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/declarations/cmc/cmc.did +122 -0
- package/dist/declarations/cmc/cmc.did.d.ts +48 -0
- package/dist/declarations/cmc/cmc.factory.did.js +65 -0
- package/dist/declarations/cmc/index.d.ts +45 -0
- package/dist/declarations/cmc/index.js +32 -0
- package/dist/declarations/console/console.did.d.ts +47 -0
- package/dist/declarations/console/console.factory.did.js +49 -0
- package/dist/declarations/console/console.factory.did.mjs +49 -0
- package/dist/declarations/console/index.d.ts +45 -0
- package/dist/declarations/console/index.js +32 -0
- package/dist/declarations/frontend/frontend.did +188 -0
- package/dist/declarations/frontend/frontend.did.d.ts +172 -0
- package/dist/declarations/frontend/frontend.factory.did.js +208 -0
- package/dist/declarations/frontend/index.d.ts +45 -0
- package/dist/declarations/frontend/index.js +32 -0
- package/dist/declarations/ic/ic.did +82 -0
- package/dist/declarations/ic/ic.did.d.ts +77 -0
- package/dist/declarations/ic/ic.factory.did.js +128 -0
- package/dist/declarations/internet_identity/index.d.ts +45 -0
- package/dist/declarations/internet_identity/index.js +32 -0
- package/dist/declarations/internet_identity/internet_identity.did +271 -0
- package/dist/declarations/internet_identity/internet_identity.did.d.ts +161 -0
- package/dist/declarations/internet_identity/internet_identity.factory.did.js +187 -0
- package/dist/declarations/ledger/index.d.ts +45 -0
- package/dist/declarations/ledger/index.js +32 -0
- package/dist/declarations/ledger/ledger.did +249 -0
- package/dist/declarations/ledger/ledger.did.d.ts +100 -0
- package/dist/declarations/ledger/ledger.factory.did.js +98 -0
- package/dist/declarations/mission_control/index.d.ts +45 -0
- package/dist/declarations/mission_control/index.js +32 -0
- package/dist/declarations/mission_control/mission_control.did.d.ts +24 -0
- package/dist/declarations/mission_control/mission_control.factory.did.js +28 -0
- package/dist/declarations/satellite/index.d.ts +45 -0
- package/dist/declarations/satellite/index.js +32 -0
- package/dist/declarations/satellite/satellite.did.d.ts +168 -0
- package/dist/declarations/satellite/satellite.factory.did.js +169 -0
- package/dist/declarations/satellite/satellite.factory.did.mjs +169 -0
- package/dist/node/index.mjs +72 -0
- package/dist/node/index.mjs.map +7 -0
- package/dist/types/api/actor.api.d.ts +4 -4
- package/dist/types/api/satellite.api.d.ts +1 -1
- package/dist/types/types/ic.types.d.ts +1 -1
- package/package.json +12 -5
- package/dist/cjs/index.cjs.js +0 -70
- package/dist/cjs/index.cjs.js.map +0 -7
- package/dist/esm/canisterStatus-XJAXQVDF.js +0 -2
- package/dist/esm/chunk-RNCSYUTB.js +0 -63
- package/dist/esm/chunk-RNCSYUTB.js.map +0 -7
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -7
- package/dist/types/utils/did.utils.d.ts +0 -4
- /package/dist/{esm/canisterStatus-XJAXQVDF.js.map → browser/canisterStatus-D52DQGXX.js.map} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface AccountBalanceArgs {
|
|
5
|
+
account: AccountIdentifier;
|
|
6
|
+
}
|
|
7
|
+
export type AccountIdentifier = Uint8Array | number[];
|
|
8
|
+
export interface Archive {
|
|
9
|
+
canister_id: Principal;
|
|
10
|
+
}
|
|
11
|
+
export interface Archives {
|
|
12
|
+
archives: Array<Archive>;
|
|
13
|
+
}
|
|
14
|
+
export interface Block {
|
|
15
|
+
transaction: Transaction;
|
|
16
|
+
timestamp: TimeStamp;
|
|
17
|
+
parent_hash: [] | [Uint8Array | number[]];
|
|
18
|
+
}
|
|
19
|
+
export type BlockIndex = bigint;
|
|
20
|
+
export interface BlockRange {
|
|
21
|
+
blocks: Array<Block>;
|
|
22
|
+
}
|
|
23
|
+
export interface GetBlocksArgs {
|
|
24
|
+
start: BlockIndex;
|
|
25
|
+
length: bigint;
|
|
26
|
+
}
|
|
27
|
+
export type Memo = bigint;
|
|
28
|
+
export type Operation =
|
|
29
|
+
| {
|
|
30
|
+
Burn: {from: AccountIdentifier; amount: Tokens};
|
|
31
|
+
}
|
|
32
|
+
| {Mint: {to: AccountIdentifier; amount: Tokens}}
|
|
33
|
+
| {
|
|
34
|
+
Transfer: {
|
|
35
|
+
to: AccountIdentifier;
|
|
36
|
+
fee: Tokens;
|
|
37
|
+
from: AccountIdentifier;
|
|
38
|
+
amount: Tokens;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type QueryArchiveError =
|
|
42
|
+
| {
|
|
43
|
+
BadFirstBlockIndex: {
|
|
44
|
+
requested_index: BlockIndex;
|
|
45
|
+
first_valid_index: BlockIndex;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
| {Other: {error_message: string; error_code: bigint}};
|
|
49
|
+
export type QueryArchiveFn = ActorMethod<[GetBlocksArgs], QueryArchiveResult>;
|
|
50
|
+
export type QueryArchiveResult = {Ok: BlockRange} | {Err: QueryArchiveError};
|
|
51
|
+
export interface QueryBlocksResponse {
|
|
52
|
+
certificate: [] | [Uint8Array | number[]];
|
|
53
|
+
blocks: Array<Block>;
|
|
54
|
+
chain_length: bigint;
|
|
55
|
+
first_block_index: BlockIndex;
|
|
56
|
+
archived_blocks: Array<{callback: QueryArchiveFn; start: BlockIndex; length: bigint}>;
|
|
57
|
+
}
|
|
58
|
+
export type SubAccount = Uint8Array | number[];
|
|
59
|
+
export interface TimeStamp {
|
|
60
|
+
timestamp_nanos: bigint;
|
|
61
|
+
}
|
|
62
|
+
export interface Tokens {
|
|
63
|
+
e8s: bigint;
|
|
64
|
+
}
|
|
65
|
+
export interface Transaction {
|
|
66
|
+
memo: Memo;
|
|
67
|
+
operation: [] | [Operation];
|
|
68
|
+
created_at_time: TimeStamp;
|
|
69
|
+
}
|
|
70
|
+
export interface TransferArgs {
|
|
71
|
+
to: AccountIdentifier;
|
|
72
|
+
fee: Tokens;
|
|
73
|
+
memo: Memo;
|
|
74
|
+
from_subaccount: [] | [SubAccount];
|
|
75
|
+
created_at_time: [] | [TimeStamp];
|
|
76
|
+
amount: Tokens;
|
|
77
|
+
}
|
|
78
|
+
export type TransferError =
|
|
79
|
+
| {
|
|
80
|
+
TxTooOld: {allowed_window_nanos: bigint};
|
|
81
|
+
}
|
|
82
|
+
| {BadFee: {expected_fee: Tokens}}
|
|
83
|
+
| {TxDuplicate: {duplicate_of: BlockIndex}}
|
|
84
|
+
| {TxCreatedInFuture: null}
|
|
85
|
+
| {InsufficientFunds: {balance: Tokens}};
|
|
86
|
+
export interface TransferFee {
|
|
87
|
+
transfer_fee: Tokens;
|
|
88
|
+
}
|
|
89
|
+
export type TransferFeeArg = {};
|
|
90
|
+
export type TransferResult = {Ok: BlockIndex} | {Err: TransferError};
|
|
91
|
+
export interface _SERVICE {
|
|
92
|
+
account_balance: ActorMethod<[AccountBalanceArgs], Tokens>;
|
|
93
|
+
archives: ActorMethod<[], Archives>;
|
|
94
|
+
decimals: ActorMethod<[], {decimals: number}>;
|
|
95
|
+
name: ActorMethod<[], {name: string}>;
|
|
96
|
+
query_blocks: ActorMethod<[GetBlocksArgs], QueryBlocksResponse>;
|
|
97
|
+
symbol: ActorMethod<[], {symbol: string}>;
|
|
98
|
+
transfer: ActorMethod<[TransferArgs], TransferResult>;
|
|
99
|
+
transfer_fee: ActorMethod<[TransferFeeArg], TransferFee>;
|
|
100
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const AccountIdentifier = IDL.Vec(IDL.Nat8);
|
|
3
|
+
const AccountBalanceArgs = IDL.Record({account: AccountIdentifier});
|
|
4
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
5
|
+
const Archive = IDL.Record({canister_id: IDL.Principal});
|
|
6
|
+
const Archives = IDL.Record({archives: IDL.Vec(Archive)});
|
|
7
|
+
const BlockIndex = IDL.Nat64;
|
|
8
|
+
const GetBlocksArgs = IDL.Record({
|
|
9
|
+
start: BlockIndex,
|
|
10
|
+
length: IDL.Nat64
|
|
11
|
+
});
|
|
12
|
+
const Memo = IDL.Nat64;
|
|
13
|
+
const Operation = IDL.Variant({
|
|
14
|
+
Burn: IDL.Record({from: AccountIdentifier, amount: Tokens}),
|
|
15
|
+
Mint: IDL.Record({to: AccountIdentifier, amount: Tokens}),
|
|
16
|
+
Transfer: IDL.Record({
|
|
17
|
+
to: AccountIdentifier,
|
|
18
|
+
fee: Tokens,
|
|
19
|
+
from: AccountIdentifier,
|
|
20
|
+
amount: Tokens
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
const TimeStamp = IDL.Record({timestamp_nanos: IDL.Nat64});
|
|
24
|
+
const Transaction = IDL.Record({
|
|
25
|
+
memo: Memo,
|
|
26
|
+
operation: IDL.Opt(Operation),
|
|
27
|
+
created_at_time: TimeStamp
|
|
28
|
+
});
|
|
29
|
+
const Block = IDL.Record({
|
|
30
|
+
transaction: Transaction,
|
|
31
|
+
timestamp: TimeStamp,
|
|
32
|
+
parent_hash: IDL.Opt(IDL.Vec(IDL.Nat8))
|
|
33
|
+
});
|
|
34
|
+
const BlockRange = IDL.Record({blocks: IDL.Vec(Block)});
|
|
35
|
+
const QueryArchiveError = IDL.Variant({
|
|
36
|
+
BadFirstBlockIndex: IDL.Record({
|
|
37
|
+
requested_index: BlockIndex,
|
|
38
|
+
first_valid_index: BlockIndex
|
|
39
|
+
}),
|
|
40
|
+
Other: IDL.Record({
|
|
41
|
+
error_message: IDL.Text,
|
|
42
|
+
error_code: IDL.Nat64
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
const QueryArchiveResult = IDL.Variant({
|
|
46
|
+
Ok: BlockRange,
|
|
47
|
+
Err: QueryArchiveError
|
|
48
|
+
});
|
|
49
|
+
const QueryArchiveFn = IDL.Func([GetBlocksArgs], [QueryArchiveResult], ['query']);
|
|
50
|
+
const QueryBlocksResponse = IDL.Record({
|
|
51
|
+
certificate: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
52
|
+
blocks: IDL.Vec(Block),
|
|
53
|
+
chain_length: IDL.Nat64,
|
|
54
|
+
first_block_index: BlockIndex,
|
|
55
|
+
archived_blocks: IDL.Vec(
|
|
56
|
+
IDL.Record({
|
|
57
|
+
callback: QueryArchiveFn,
|
|
58
|
+
start: BlockIndex,
|
|
59
|
+
length: IDL.Nat64
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
});
|
|
63
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
|
64
|
+
const TransferArgs = IDL.Record({
|
|
65
|
+
to: AccountIdentifier,
|
|
66
|
+
fee: Tokens,
|
|
67
|
+
memo: Memo,
|
|
68
|
+
from_subaccount: IDL.Opt(SubAccount),
|
|
69
|
+
created_at_time: IDL.Opt(TimeStamp),
|
|
70
|
+
amount: Tokens
|
|
71
|
+
});
|
|
72
|
+
const TransferError = IDL.Variant({
|
|
73
|
+
TxTooOld: IDL.Record({allowed_window_nanos: IDL.Nat64}),
|
|
74
|
+
BadFee: IDL.Record({expected_fee: Tokens}),
|
|
75
|
+
TxDuplicate: IDL.Record({duplicate_of: BlockIndex}),
|
|
76
|
+
TxCreatedInFuture: IDL.Null,
|
|
77
|
+
InsufficientFunds: IDL.Record({balance: Tokens})
|
|
78
|
+
});
|
|
79
|
+
const TransferResult = IDL.Variant({
|
|
80
|
+
Ok: BlockIndex,
|
|
81
|
+
Err: TransferError
|
|
82
|
+
});
|
|
83
|
+
const TransferFeeArg = IDL.Record({});
|
|
84
|
+
const TransferFee = IDL.Record({transfer_fee: Tokens});
|
|
85
|
+
return IDL.Service({
|
|
86
|
+
account_balance: IDL.Func([AccountBalanceArgs], [Tokens], ['query']),
|
|
87
|
+
archives: IDL.Func([], [Archives], ['query']),
|
|
88
|
+
decimals: IDL.Func([], [IDL.Record({decimals: IDL.Nat32})], ['query']),
|
|
89
|
+
name: IDL.Func([], [IDL.Record({name: IDL.Text})], ['query']),
|
|
90
|
+
query_blocks: IDL.Func([GetBlocksArgs], [QueryBlocksResponse], ['query']),
|
|
91
|
+
symbol: IDL.Func([], [IDL.Record({symbol: IDL.Text})], ['query']),
|
|
92
|
+
transfer: IDL.Func([TransferArgs], [TransferResult], []),
|
|
93
|
+
transfer_fee: IDL.Func([TransferFeeArg], [TransferFee], ['query'])
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export const init = ({IDL}) => {
|
|
97
|
+
return [];
|
|
98
|
+
};
|
|
@@ -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 './mission_control.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 mission_control: ActorSubclass<_SERVICE>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Actor, HttpAgent} from '@dfinity/agent';
|
|
2
|
+
|
|
3
|
+
// Imports and re-exports candid interface
|
|
4
|
+
import {idlFactory} from './mission_control.did.js';
|
|
5
|
+
export {idlFactory} from './mission_control.did.js';
|
|
6
|
+
|
|
7
|
+
// CANISTER_ID is replaced by webpack based on node environment
|
|
8
|
+
|
|
9
|
+
export const createActor = (canisterId, options = {}) => {
|
|
10
|
+
const agent = options.agent || new HttpAgent({...options.agentOptions});
|
|
11
|
+
|
|
12
|
+
if (options.agent && options.agentOptions) {
|
|
13
|
+
console.warn(
|
|
14
|
+
'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fetch root key for certificate validation during development
|
|
19
|
+
if (process.env.DFX_NETWORK !== 'ic') {
|
|
20
|
+
agent.fetchRootKey().catch((err) => {
|
|
21
|
+
console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
|
|
22
|
+
console.error(err);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Creates an actor with using the candid interface and the HttpAgent
|
|
27
|
+
return Actor.createActor(idlFactory, {
|
|
28
|
+
agent,
|
|
29
|
+
canisterId,
|
|
30
|
+
...options.actorOptions
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface Satellite {
|
|
5
|
+
updated_at: bigint;
|
|
6
|
+
metadata: Array<[string, string]>;
|
|
7
|
+
created_at: bigint;
|
|
8
|
+
satellite_id: Principal;
|
|
9
|
+
}
|
|
10
|
+
export interface Tokens {
|
|
11
|
+
e8s: bigint;
|
|
12
|
+
}
|
|
13
|
+
export interface _SERVICE {
|
|
14
|
+
add_mission_control_controllers: ActorMethod<[Array<Principal>], undefined>;
|
|
15
|
+
add_satellites_controllers: ActorMethod<[Array<Principal>, Array<Principal>], undefined>;
|
|
16
|
+
create_satellite: ActorMethod<[string], Satellite>;
|
|
17
|
+
get_user: ActorMethod<[], Principal>;
|
|
18
|
+
list_mission_control_controllers: ActorMethod<[], Array<Principal>>;
|
|
19
|
+
list_satellites: ActorMethod<[], Array<[Principal, Satellite]>>;
|
|
20
|
+
remove_mission_control_controllers: ActorMethod<[Array<Principal>], undefined>;
|
|
21
|
+
remove_satellites_controllers: ActorMethod<[Array<Principal>, Array<Principal>], undefined>;
|
|
22
|
+
top_up: ActorMethod<[Principal, Tokens], undefined>;
|
|
23
|
+
version: ActorMethod<[], string>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const Satellite = IDL.Record({
|
|
3
|
+
updated_at: IDL.Nat64,
|
|
4
|
+
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
5
|
+
created_at: IDL.Nat64,
|
|
6
|
+
satellite_id: IDL.Principal
|
|
7
|
+
});
|
|
8
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
9
|
+
return IDL.Service({
|
|
10
|
+
add_mission_control_controllers: IDL.Func([IDL.Vec(IDL.Principal)], [], []),
|
|
11
|
+
add_satellites_controllers: IDL.Func([IDL.Vec(IDL.Principal), IDL.Vec(IDL.Principal)], [], []),
|
|
12
|
+
create_satellite: IDL.Func([IDL.Text], [Satellite], []),
|
|
13
|
+
get_user: IDL.Func([], [IDL.Principal], ['query']),
|
|
14
|
+
list_mission_control_controllers: IDL.Func([], [IDL.Vec(IDL.Principal)], ['query']),
|
|
15
|
+
list_satellites: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Principal, Satellite))], ['query']),
|
|
16
|
+
remove_mission_control_controllers: IDL.Func([IDL.Vec(IDL.Principal)], [], []),
|
|
17
|
+
remove_satellites_controllers: IDL.Func(
|
|
18
|
+
[IDL.Vec(IDL.Principal), IDL.Vec(IDL.Principal)],
|
|
19
|
+
[],
|
|
20
|
+
[]
|
|
21
|
+
),
|
|
22
|
+
top_up: IDL.Func([IDL.Principal, Tokens], [], []),
|
|
23
|
+
version: IDL.Func([], [IDL.Text], ['query'])
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export const init = ({IDL}) => {
|
|
27
|
+
return [];
|
|
28
|
+
};
|
|
@@ -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 './satellite.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 satellite: ActorSubclass<_SERVICE>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Actor, HttpAgent} from '@dfinity/agent';
|
|
2
|
+
|
|
3
|
+
// Imports and re-exports candid interface
|
|
4
|
+
import {idlFactory} from './satellite.did.js';
|
|
5
|
+
export {idlFactory} from './satellite.did.js';
|
|
6
|
+
|
|
7
|
+
// CANISTER_ID is replaced by webpack based on node environment
|
|
8
|
+
|
|
9
|
+
export const createActor = (canisterId, options = {}) => {
|
|
10
|
+
const agent = options.agent || new HttpAgent({...options.agentOptions});
|
|
11
|
+
|
|
12
|
+
if (options.agent && options.agentOptions) {
|
|
13
|
+
console.warn(
|
|
14
|
+
'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fetch root key for certificate validation during development
|
|
19
|
+
if (process.env.DFX_NETWORK !== 'ic') {
|
|
20
|
+
agent.fetchRootKey().catch((err) => {
|
|
21
|
+
console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
|
|
22
|
+
console.error(err);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Creates an actor with using the candid interface and the HttpAgent
|
|
27
|
+
return Actor.createActor(idlFactory, {
|
|
28
|
+
agent,
|
|
29
|
+
canisterId,
|
|
30
|
+
...options.actorOptions
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface AssetEncodingNoContent {
|
|
5
|
+
modified: bigint;
|
|
6
|
+
sha256: Uint8Array | number[];
|
|
7
|
+
total_length: bigint;
|
|
8
|
+
}
|
|
9
|
+
export interface AssetKey {
|
|
10
|
+
token: [] | [string];
|
|
11
|
+
collection: string;
|
|
12
|
+
owner: Principal;
|
|
13
|
+
name: string;
|
|
14
|
+
full_path: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AssetNoContent {
|
|
17
|
+
key: AssetKey;
|
|
18
|
+
updated_at: bigint;
|
|
19
|
+
encodings: Array<[string, AssetEncodingNoContent]>;
|
|
20
|
+
headers: Array<[string, string]>;
|
|
21
|
+
created_at: bigint;
|
|
22
|
+
}
|
|
23
|
+
export interface Chunk {
|
|
24
|
+
content: Uint8Array | number[];
|
|
25
|
+
batch_id: bigint;
|
|
26
|
+
}
|
|
27
|
+
export interface CommitBatch {
|
|
28
|
+
batch_id: bigint;
|
|
29
|
+
headers: Array<[string, string]>;
|
|
30
|
+
chunk_ids: Array<bigint>;
|
|
31
|
+
}
|
|
32
|
+
export interface Config {
|
|
33
|
+
storage: StorageConfig;
|
|
34
|
+
}
|
|
35
|
+
export interface ControllersArgs {
|
|
36
|
+
controllers: Array<Principal>;
|
|
37
|
+
}
|
|
38
|
+
export interface CustomDomain {
|
|
39
|
+
updated_at: bigint;
|
|
40
|
+
created_at: bigint;
|
|
41
|
+
bn_id: [] | [string];
|
|
42
|
+
}
|
|
43
|
+
export interface DelDoc {
|
|
44
|
+
updated_at: [] | [bigint];
|
|
45
|
+
}
|
|
46
|
+
export interface Doc {
|
|
47
|
+
updated_at: bigint;
|
|
48
|
+
owner: Principal;
|
|
49
|
+
data: Uint8Array | number[];
|
|
50
|
+
created_at: bigint;
|
|
51
|
+
}
|
|
52
|
+
export interface HttpRequest {
|
|
53
|
+
url: string;
|
|
54
|
+
method: string;
|
|
55
|
+
body: Uint8Array | number[];
|
|
56
|
+
headers: Array<[string, string]>;
|
|
57
|
+
}
|
|
58
|
+
export interface HttpResponse {
|
|
59
|
+
body: Uint8Array | number[];
|
|
60
|
+
headers: Array<[string, string]>;
|
|
61
|
+
streaming_strategy: [] | [StreamingStrategy];
|
|
62
|
+
status_code: number;
|
|
63
|
+
}
|
|
64
|
+
export interface InitAssetKey {
|
|
65
|
+
token: [] | [string];
|
|
66
|
+
collection: string;
|
|
67
|
+
name: string;
|
|
68
|
+
encoding_type: [] | [string];
|
|
69
|
+
full_path: string;
|
|
70
|
+
}
|
|
71
|
+
export interface InitUploadResult {
|
|
72
|
+
batch_id: bigint;
|
|
73
|
+
}
|
|
74
|
+
export interface ListOrder {
|
|
75
|
+
field: ListOrderField;
|
|
76
|
+
desc: boolean;
|
|
77
|
+
}
|
|
78
|
+
export type ListOrderField = {UpdatedAt: null} | {Keys: null} | {CreatedAt: null};
|
|
79
|
+
export interface ListPaginate {
|
|
80
|
+
start_after: [] | [string];
|
|
81
|
+
limit: [] | [bigint];
|
|
82
|
+
}
|
|
83
|
+
export interface ListParams {
|
|
84
|
+
order: [] | [ListOrder];
|
|
85
|
+
matcher: [] | [string];
|
|
86
|
+
paginate: [] | [ListPaginate];
|
|
87
|
+
}
|
|
88
|
+
export interface ListResults {
|
|
89
|
+
matches_length: bigint;
|
|
90
|
+
length: bigint;
|
|
91
|
+
items: Array<[string, AssetNoContent]>;
|
|
92
|
+
}
|
|
93
|
+
export interface ListResults_1 {
|
|
94
|
+
matches_length: bigint;
|
|
95
|
+
length: bigint;
|
|
96
|
+
items: Array<[string, Doc]>;
|
|
97
|
+
}
|
|
98
|
+
export type Permission = {Controllers: null} | {Private: null} | {Public: null} | {Managed: null};
|
|
99
|
+
export interface Rule {
|
|
100
|
+
updated_at: bigint;
|
|
101
|
+
max_size: [] | [bigint];
|
|
102
|
+
read: Permission;
|
|
103
|
+
created_at: bigint;
|
|
104
|
+
write: Permission;
|
|
105
|
+
}
|
|
106
|
+
export type RulesType = {Db: null} | {Storage: null};
|
|
107
|
+
export interface SetDoc {
|
|
108
|
+
updated_at: [] | [bigint];
|
|
109
|
+
data: Uint8Array | number[];
|
|
110
|
+
}
|
|
111
|
+
export interface SetRule {
|
|
112
|
+
updated_at: [] | [bigint];
|
|
113
|
+
max_size: [] | [bigint];
|
|
114
|
+
read: Permission;
|
|
115
|
+
write: Permission;
|
|
116
|
+
}
|
|
117
|
+
export interface StorageConfig {
|
|
118
|
+
headers: Array<[string, Array<[string, string]>]>;
|
|
119
|
+
}
|
|
120
|
+
export interface StreamingCallbackHttpResponse {
|
|
121
|
+
token: [] | [StreamingCallbackToken];
|
|
122
|
+
body: Uint8Array | number[];
|
|
123
|
+
}
|
|
124
|
+
export interface StreamingCallbackToken {
|
|
125
|
+
token: [] | [string];
|
|
126
|
+
sha256: [] | [Uint8Array | number[]];
|
|
127
|
+
headers: Array<[string, string]>;
|
|
128
|
+
index: bigint;
|
|
129
|
+
encoding_type: string;
|
|
130
|
+
full_path: string;
|
|
131
|
+
}
|
|
132
|
+
export type StreamingStrategy = {
|
|
133
|
+
Callback: {
|
|
134
|
+
token: StreamingCallbackToken;
|
|
135
|
+
callback: [Principal, string];
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
export interface UploadChunk {
|
|
139
|
+
chunk_id: bigint;
|
|
140
|
+
}
|
|
141
|
+
export interface _SERVICE {
|
|
142
|
+
add_controllers: ActorMethod<[ControllersArgs], Array<Principal>>;
|
|
143
|
+
commit_asset_upload: ActorMethod<[CommitBatch], undefined>;
|
|
144
|
+
del_asset: ActorMethod<[string, string], undefined>;
|
|
145
|
+
del_assets: ActorMethod<[[] | [string]], undefined>;
|
|
146
|
+
del_custom_domain: ActorMethod<[string], undefined>;
|
|
147
|
+
del_doc: ActorMethod<[string, string, DelDoc], undefined>;
|
|
148
|
+
get_config: ActorMethod<[], Config>;
|
|
149
|
+
get_doc: ActorMethod<[string, string], [] | [Doc]>;
|
|
150
|
+
http_request: ActorMethod<[HttpRequest], HttpResponse>;
|
|
151
|
+
http_request_streaming_callback: ActorMethod<
|
|
152
|
+
[StreamingCallbackToken],
|
|
153
|
+
StreamingCallbackHttpResponse
|
|
154
|
+
>;
|
|
155
|
+
init_asset_upload: ActorMethod<[InitAssetKey], InitUploadResult>;
|
|
156
|
+
list_assets: ActorMethod<[[] | [string], ListParams], ListResults>;
|
|
157
|
+
list_controllers: ActorMethod<[], Array<Principal>>;
|
|
158
|
+
list_custom_domains: ActorMethod<[], Array<[string, CustomDomain]>>;
|
|
159
|
+
list_docs: ActorMethod<[string, ListParams], ListResults_1>;
|
|
160
|
+
list_rules: ActorMethod<[RulesType], Array<[string, Rule]>>;
|
|
161
|
+
remove_controllers: ActorMethod<[ControllersArgs], Array<Principal>>;
|
|
162
|
+
set_config: ActorMethod<[Config], undefined>;
|
|
163
|
+
set_custom_domain: ActorMethod<[string, [] | [string]], undefined>;
|
|
164
|
+
set_doc: ActorMethod<[string, string, SetDoc], Doc>;
|
|
165
|
+
set_rule: ActorMethod<[RulesType, string, SetRule], undefined>;
|
|
166
|
+
upload_asset_chunk: ActorMethod<[Chunk], UploadChunk>;
|
|
167
|
+
version: ActorMethod<[], string>;
|
|
168
|
+
}
|