@junobuild/admin 0.0.11 → 0.0.13
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/README.md +1 -1
- package/declarations/cmc/cmc.did +122 -0
- package/declarations/cmc/cmc.did.d.ts +48 -0
- package/declarations/cmc/cmc.factory.did.js +65 -0
- package/declarations/cmc/index.d.ts +45 -0
- package/declarations/cmc/index.js +32 -0
- package/declarations/console/console.did.d.ts +60 -0
- package/declarations/console/console.factory.did.js +62 -0
- package/declarations/console/console.factory.did.mjs +62 -0
- package/declarations/console/index.d.ts +45 -0
- package/declarations/console/index.js +32 -0
- package/declarations/frontend/frontend.did +188 -0
- package/declarations/frontend/frontend.did.d.ts +172 -0
- package/declarations/frontend/frontend.factory.did.js +208 -0
- package/declarations/frontend/index.d.ts +45 -0
- package/declarations/frontend/index.js +32 -0
- package/declarations/ic/ic.did +82 -0
- package/declarations/ic/ic.did.d.ts +77 -0
- package/declarations/ic/ic.factory.did.js +128 -0
- package/declarations/internet_identity/index.d.ts +45 -0
- package/declarations/internet_identity/index.js +32 -0
- package/declarations/internet_identity/internet_identity.did +330 -0
- package/declarations/internet_identity/internet_identity.did.d.ts +204 -0
- package/declarations/internet_identity/internet_identity.factory.did.js +233 -0
- package/declarations/ledger/index.d.ts +45 -0
- package/declarations/ledger/index.js +32 -0
- package/declarations/ledger/ledger.did +249 -0
- package/declarations/ledger/ledger.did.d.ts +100 -0
- package/declarations/ledger/ledger.factory.did.js +98 -0
- package/declarations/mission_control/index.d.ts +45 -0
- package/declarations/mission_control/index.js +32 -0
- package/declarations/mission_control/mission_control.did.d.ts +41 -0
- package/declarations/mission_control/mission_control.factory.did.js +50 -0
- package/declarations/satellite/index.d.ts +45 -0
- package/declarations/satellite/index.js +32 -0
- package/declarations/satellite/satellite-deprecated.did.d.ts +182 -0
- package/declarations/satellite/satellite-deprecated.factory.did.js +191 -0
- package/declarations/satellite/satellite-deprecated.factory.did.mjs +191 -0
- package/declarations/satellite/satellite.did.d.ts +183 -0
- package/declarations/satellite/satellite.factory.did.js +194 -0
- package/declarations/satellite/satellite.factory.did.mjs +192 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[npm-badge]: https://img.shields.io/npm/v/@junobuild/admin
|
|
5
5
|
[npm-badge-url]: https://www.npmjs.com/package/@junobuild/admin
|
|
6
6
|
[npm-license]: https://img.shields.io/npm/l/@junobuild/admin
|
|
7
|
-
[npm-license-url]: https://github.com/
|
|
7
|
+
[npm-license-url]: https://github.com/buildwithjuno/juno-js/blob/main/LICENSE
|
|
8
8
|
|
|
9
9
|
# Juno JavaScript admin SDK
|
|
10
10
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
type Cycles = nat;
|
|
2
|
+
type BlockIndex = nat64;
|
|
3
|
+
|
|
4
|
+
// The argument of the [notify_top_up] method.
|
|
5
|
+
type NotifyTopUpArg = record {
|
|
6
|
+
// Index of the block on the ICP ledger that contains the payment.
|
|
7
|
+
block_index : BlockIndex;
|
|
8
|
+
|
|
9
|
+
// The canister to top up.
|
|
10
|
+
canister_id : principal;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// The argument of the [notify_create_canister] method.
|
|
14
|
+
type NotifyCreateCanisterArg = record {
|
|
15
|
+
// Index of the block on the ICP ledger that contains the payment.
|
|
16
|
+
block_index : BlockIndex;
|
|
17
|
+
|
|
18
|
+
// The controller of canister to create.
|
|
19
|
+
controller : principal;
|
|
20
|
+
|
|
21
|
+
// An optional subnet type that, if set, determines what type of subnet
|
|
22
|
+
// the new canister will be created on.
|
|
23
|
+
subnet_type: opt text;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type NotifyError = variant {
|
|
27
|
+
// The payment processing failed and the payment was returned the caller.
|
|
28
|
+
// This is a non-retriable error.
|
|
29
|
+
Refunded : record {
|
|
30
|
+
// The reason for the refund.
|
|
31
|
+
reason : text;
|
|
32
|
+
// The index of the block containing the refund.
|
|
33
|
+
block_index : opt BlockIndex;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// The same payment is already being processed by a concurrent request.
|
|
37
|
+
// This is a retriable error.
|
|
38
|
+
Processing;
|
|
39
|
+
|
|
40
|
+
// The payment was too old to be processed.
|
|
41
|
+
// The value of the variant is the oldest block index that can still be processed.
|
|
42
|
+
// This a non-retriable error.
|
|
43
|
+
TransactionTooOld : BlockIndex;
|
|
44
|
+
|
|
45
|
+
// The transaction does not satisfy the cycle minting canister payment protocol.
|
|
46
|
+
// The text contains the description of the problem.
|
|
47
|
+
// This is a non-retriable error.
|
|
48
|
+
InvalidTransaction : text;
|
|
49
|
+
|
|
50
|
+
// Other error.
|
|
51
|
+
Other : record { error_code : nat64; error_message : text };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type NotifyTopUpResult = variant {
|
|
55
|
+
// The amount of cycles sent to the specified canister.
|
|
56
|
+
Ok : Cycles;
|
|
57
|
+
Err : NotifyError;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type NotifyCreateCanisterResult = variant {
|
|
61
|
+
// The principal of the newly created canister.
|
|
62
|
+
Ok : principal;
|
|
63
|
+
Err : NotifyError;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type IcpXdrConversionRate = record {
|
|
67
|
+
// The time for which the market data was queried, expressed in UNIX epoch
|
|
68
|
+
// time in seconds.
|
|
69
|
+
timestamp_seconds : nat64;
|
|
70
|
+
|
|
71
|
+
// The number of 10,000ths of IMF SDR (currency code XDR) that corresponds
|
|
72
|
+
// to 1 ICP. This value reflects the current market price of one ICP token.
|
|
73
|
+
xdr_permyriad_per_icp : nat64;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
type IcpXdrConversionRateResponse = record {
|
|
78
|
+
// The latest ICP/XDR conversion rate.
|
|
79
|
+
data : IcpXdrConversionRate;
|
|
80
|
+
|
|
81
|
+
// CBOR-serialized hash tree as specified in
|
|
82
|
+
// https://smartcontracts.org/docs/interface-spec/index.html#certification-encoding.
|
|
83
|
+
// The hash tree is used for certification and hash the following structure:
|
|
84
|
+
// ```
|
|
85
|
+
// *
|
|
86
|
+
// |
|
|
87
|
+
// +-- ICP_XDR_CONVERSION_RATE -- [ Candid encoded IcpXdrConversionRate ]
|
|
88
|
+
// |
|
|
89
|
+
// `-- AVERAGE_ICP_XDR_CONVERSION_RATE -- [ Candid encoded IcpXdrConversionRate ]
|
|
90
|
+
// ```
|
|
91
|
+
hash_tree : blob;
|
|
92
|
+
|
|
93
|
+
// System certificate as specified in
|
|
94
|
+
// https://smartcontracts.org/docs/interface-spec/index.html#certification-encoding
|
|
95
|
+
certificate : blob;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type SubnetTypesToSubnetsResponse = record {
|
|
99
|
+
data: vec record { text; vec principal };
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type CyclesCanisterInitPayload = record {
|
|
103
|
+
governance_canister_id : principal;
|
|
104
|
+
minting_account_id : opt text;
|
|
105
|
+
ledger_canister_id : principal;
|
|
106
|
+
last_purged_notification: opt BlockIndex;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
service: (CyclesCanisterInitPayload) -> {
|
|
110
|
+
// Propmts the cycles minting canister to process a payment by converting ICP
|
|
111
|
+
// into cycles and sending the cycles the specified canister.
|
|
112
|
+
notify_top_up : (NotifyTopUpArg) -> (NotifyTopUpResult);
|
|
113
|
+
|
|
114
|
+
// Prompts the cycles minting canister to process a payment for canister creation.
|
|
115
|
+
notify_create_canister : (NotifyCreateCanisterArg) -> (NotifyCreateCanisterResult);
|
|
116
|
+
|
|
117
|
+
// Returns the ICP/XDR conversion rate.
|
|
118
|
+
get_icp_xdr_conversion_rate : () -> (IcpXdrConversionRateResponse) query;
|
|
119
|
+
|
|
120
|
+
// Returns the current mapping of subnet types to subnets.
|
|
121
|
+
get_subnet_types_to_subnets : () -> (SubnetTypesToSubnetsResponse) query;
|
|
122
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export type BlockIndex = bigint;
|
|
5
|
+
export type Cycles = bigint;
|
|
6
|
+
export interface CyclesCanisterInitPayload {
|
|
7
|
+
last_purged_notification: [] | [BlockIndex];
|
|
8
|
+
governance_canister_id: Principal;
|
|
9
|
+
minting_account_id: [] | [string];
|
|
10
|
+
ledger_canister_id: Principal;
|
|
11
|
+
}
|
|
12
|
+
export interface IcpXdrConversionRate {
|
|
13
|
+
xdr_permyriad_per_icp: bigint;
|
|
14
|
+
timestamp_seconds: bigint;
|
|
15
|
+
}
|
|
16
|
+
export interface IcpXdrConversionRateResponse {
|
|
17
|
+
certificate: Uint8Array | number[];
|
|
18
|
+
data: IcpXdrConversionRate;
|
|
19
|
+
hash_tree: Uint8Array | number[];
|
|
20
|
+
}
|
|
21
|
+
export interface NotifyCreateCanisterArg {
|
|
22
|
+
controller: Principal;
|
|
23
|
+
block_index: BlockIndex;
|
|
24
|
+
subnet_type: [] | [string];
|
|
25
|
+
}
|
|
26
|
+
export type NotifyCreateCanisterResult = {Ok: Principal} | {Err: NotifyError};
|
|
27
|
+
export type NotifyError =
|
|
28
|
+
| {
|
|
29
|
+
Refunded: {block_index: [] | [BlockIndex]; reason: string};
|
|
30
|
+
}
|
|
31
|
+
| {InvalidTransaction: string}
|
|
32
|
+
| {Other: {error_message: string; error_code: bigint}}
|
|
33
|
+
| {Processing: null}
|
|
34
|
+
| {TransactionTooOld: BlockIndex};
|
|
35
|
+
export interface NotifyTopUpArg {
|
|
36
|
+
block_index: BlockIndex;
|
|
37
|
+
canister_id: Principal;
|
|
38
|
+
}
|
|
39
|
+
export type NotifyTopUpResult = {Ok: Cycles} | {Err: NotifyError};
|
|
40
|
+
export interface SubnetTypesToSubnetsResponse {
|
|
41
|
+
data: Array<[string, Array<Principal>]>;
|
|
42
|
+
}
|
|
43
|
+
export interface _SERVICE {
|
|
44
|
+
get_icp_xdr_conversion_rate: ActorMethod<[], IcpXdrConversionRateResponse>;
|
|
45
|
+
get_subnet_types_to_subnets: ActorMethod<[], SubnetTypesToSubnetsResponse>;
|
|
46
|
+
notify_create_canister: ActorMethod<[NotifyCreateCanisterArg], NotifyCreateCanisterResult>;
|
|
47
|
+
notify_top_up: ActorMethod<[NotifyTopUpArg], NotifyTopUpResult>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const BlockIndex = IDL.Nat64;
|
|
3
|
+
const CyclesCanisterInitPayload = IDL.Record({
|
|
4
|
+
last_purged_notification: IDL.Opt(BlockIndex),
|
|
5
|
+
governance_canister_id: IDL.Principal,
|
|
6
|
+
minting_account_id: IDL.Opt(IDL.Text),
|
|
7
|
+
ledger_canister_id: IDL.Principal
|
|
8
|
+
});
|
|
9
|
+
const IcpXdrConversionRate = IDL.Record({
|
|
10
|
+
xdr_permyriad_per_icp: IDL.Nat64,
|
|
11
|
+
timestamp_seconds: IDL.Nat64
|
|
12
|
+
});
|
|
13
|
+
const IcpXdrConversionRateResponse = IDL.Record({
|
|
14
|
+
certificate: IDL.Vec(IDL.Nat8),
|
|
15
|
+
data: IcpXdrConversionRate,
|
|
16
|
+
hash_tree: IDL.Vec(IDL.Nat8)
|
|
17
|
+
});
|
|
18
|
+
const SubnetTypesToSubnetsResponse = IDL.Record({
|
|
19
|
+
data: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Principal)))
|
|
20
|
+
});
|
|
21
|
+
const NotifyCreateCanisterArg = IDL.Record({
|
|
22
|
+
controller: IDL.Principal,
|
|
23
|
+
block_index: BlockIndex,
|
|
24
|
+
subnet_type: IDL.Opt(IDL.Text)
|
|
25
|
+
});
|
|
26
|
+
const NotifyError = IDL.Variant({
|
|
27
|
+
Refunded: IDL.Record({
|
|
28
|
+
block_index: IDL.Opt(BlockIndex),
|
|
29
|
+
reason: IDL.Text
|
|
30
|
+
}),
|
|
31
|
+
InvalidTransaction: IDL.Text,
|
|
32
|
+
Other: IDL.Record({
|
|
33
|
+
error_message: IDL.Text,
|
|
34
|
+
error_code: IDL.Nat64
|
|
35
|
+
}),
|
|
36
|
+
Processing: IDL.Null,
|
|
37
|
+
TransactionTooOld: BlockIndex
|
|
38
|
+
});
|
|
39
|
+
const NotifyCreateCanisterResult = IDL.Variant({
|
|
40
|
+
Ok: IDL.Principal,
|
|
41
|
+
Err: NotifyError
|
|
42
|
+
});
|
|
43
|
+
const NotifyTopUpArg = IDL.Record({
|
|
44
|
+
block_index: BlockIndex,
|
|
45
|
+
canister_id: IDL.Principal
|
|
46
|
+
});
|
|
47
|
+
const Cycles = IDL.Nat;
|
|
48
|
+
const NotifyTopUpResult = IDL.Variant({Ok: Cycles, Err: NotifyError});
|
|
49
|
+
return IDL.Service({
|
|
50
|
+
get_icp_xdr_conversion_rate: IDL.Func([], [IcpXdrConversionRateResponse], ['query']),
|
|
51
|
+
get_subnet_types_to_subnets: IDL.Func([], [SubnetTypesToSubnetsResponse], ['query']),
|
|
52
|
+
notify_create_canister: IDL.Func([NotifyCreateCanisterArg], [NotifyCreateCanisterResult], []),
|
|
53
|
+
notify_top_up: IDL.Func([NotifyTopUpArg], [NotifyTopUpResult], [])
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export const init = ({IDL}) => {
|
|
57
|
+
const BlockIndex = IDL.Nat64;
|
|
58
|
+
const CyclesCanisterInitPayload = IDL.Record({
|
|
59
|
+
last_purged_notification: IDL.Opt(BlockIndex),
|
|
60
|
+
governance_canister_id: IDL.Principal,
|
|
61
|
+
minting_account_id: IDL.Opt(IDL.Text),
|
|
62
|
+
ledger_canister_id: IDL.Principal
|
|
63
|
+
});
|
|
64
|
+
return [CyclesCanisterInitPayload];
|
|
65
|
+
};
|
|
@@ -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 './cmc.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 cmc: 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 './cmc.did.js';
|
|
5
|
+
export {idlFactory} from './cmc.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,60 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface CreateSatelliteArgs {
|
|
5
|
+
block_index: [] | [bigint];
|
|
6
|
+
user: Principal;
|
|
7
|
+
}
|
|
8
|
+
export interface DeleteControllersArgs {
|
|
9
|
+
controllers: Array<Principal>;
|
|
10
|
+
}
|
|
11
|
+
export interface GetCreateSatelliteFeeArgs {
|
|
12
|
+
user: Principal;
|
|
13
|
+
}
|
|
14
|
+
export interface LoadRelease {
|
|
15
|
+
total: bigint;
|
|
16
|
+
chunks: bigint;
|
|
17
|
+
}
|
|
18
|
+
export interface MissionControl {
|
|
19
|
+
updated_at: bigint;
|
|
20
|
+
credits: Tokens;
|
|
21
|
+
mission_control_id: [] | [Principal];
|
|
22
|
+
owner: Principal;
|
|
23
|
+
created_at: bigint;
|
|
24
|
+
}
|
|
25
|
+
export interface RateConfig {
|
|
26
|
+
max_tokens: bigint;
|
|
27
|
+
time_per_token_ns: bigint;
|
|
28
|
+
}
|
|
29
|
+
export interface ReleasesVersion {
|
|
30
|
+
satellite: [] | [string];
|
|
31
|
+
mission_control: [] | [string];
|
|
32
|
+
}
|
|
33
|
+
export type Segment = {MissionControl: null} | {Satellite: null};
|
|
34
|
+
export interface SetController {
|
|
35
|
+
metadata: Array<[string, string]>;
|
|
36
|
+
expires_at: [] | [bigint];
|
|
37
|
+
}
|
|
38
|
+
export interface SetControllersArgs {
|
|
39
|
+
controller: SetController;
|
|
40
|
+
controllers: Array<Principal>;
|
|
41
|
+
}
|
|
42
|
+
export interface Tokens {
|
|
43
|
+
e8s: bigint;
|
|
44
|
+
}
|
|
45
|
+
export interface _SERVICE {
|
|
46
|
+
add_invitation_code: ActorMethod<[string], undefined>;
|
|
47
|
+
create_satellite: ActorMethod<[CreateSatelliteArgs], Principal>;
|
|
48
|
+
del_controllers: ActorMethod<[DeleteControllersArgs], undefined>;
|
|
49
|
+
get_create_satellite_fee: ActorMethod<[GetCreateSatelliteFeeArgs], [] | [Tokens]>;
|
|
50
|
+
get_credits: ActorMethod<[], Tokens>;
|
|
51
|
+
get_releases_version: ActorMethod<[], ReleasesVersion>;
|
|
52
|
+
get_user_mission_control_center: ActorMethod<[], [] | [MissionControl]>;
|
|
53
|
+
init_user_mission_control_center: ActorMethod<[[] | [string]], MissionControl>;
|
|
54
|
+
list_user_mission_control_centers: ActorMethod<[], Array<[Principal, MissionControl]>>;
|
|
55
|
+
load_release: ActorMethod<[Segment, Uint8Array | number[], string], LoadRelease>;
|
|
56
|
+
reset_release: ActorMethod<[Segment], undefined>;
|
|
57
|
+
set_controllers: ActorMethod<[SetControllersArgs], undefined>;
|
|
58
|
+
update_rate_config: ActorMethod<[Segment, RateConfig], undefined>;
|
|
59
|
+
version: ActorMethod<[], string>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const CreateSatelliteArgs = IDL.Record({
|
|
3
|
+
block_index: IDL.Opt(IDL.Nat64),
|
|
4
|
+
user: IDL.Principal
|
|
5
|
+
});
|
|
6
|
+
const DeleteControllersArgs = IDL.Record({
|
|
7
|
+
controllers: IDL.Vec(IDL.Principal)
|
|
8
|
+
});
|
|
9
|
+
const GetCreateSatelliteFeeArgs = IDL.Record({user: IDL.Principal});
|
|
10
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
11
|
+
const ReleasesVersion = IDL.Record({
|
|
12
|
+
satellite: IDL.Opt(IDL.Text),
|
|
13
|
+
mission_control: IDL.Opt(IDL.Text)
|
|
14
|
+
});
|
|
15
|
+
const MissionControl = IDL.Record({
|
|
16
|
+
updated_at: IDL.Nat64,
|
|
17
|
+
credits: Tokens,
|
|
18
|
+
mission_control_id: IDL.Opt(IDL.Principal),
|
|
19
|
+
owner: IDL.Principal,
|
|
20
|
+
created_at: IDL.Nat64
|
|
21
|
+
});
|
|
22
|
+
const Segment = IDL.Variant({
|
|
23
|
+
MissionControl: IDL.Null,
|
|
24
|
+
Satellite: IDL.Null
|
|
25
|
+
});
|
|
26
|
+
const LoadRelease = IDL.Record({total: IDL.Nat64, chunks: IDL.Nat64});
|
|
27
|
+
const SetController = IDL.Record({
|
|
28
|
+
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
29
|
+
expires_at: IDL.Opt(IDL.Nat64)
|
|
30
|
+
});
|
|
31
|
+
const SetControllersArgs = IDL.Record({
|
|
32
|
+
controller: SetController,
|
|
33
|
+
controllers: IDL.Vec(IDL.Principal)
|
|
34
|
+
});
|
|
35
|
+
const RateConfig = IDL.Record({
|
|
36
|
+
max_tokens: IDL.Nat64,
|
|
37
|
+
time_per_token_ns: IDL.Nat64
|
|
38
|
+
});
|
|
39
|
+
return IDL.Service({
|
|
40
|
+
add_invitation_code: IDL.Func([IDL.Text], [], []),
|
|
41
|
+
create_satellite: IDL.Func([CreateSatelliteArgs], [IDL.Principal], []),
|
|
42
|
+
del_controllers: IDL.Func([DeleteControllersArgs], [], []),
|
|
43
|
+
get_create_satellite_fee: IDL.Func([GetCreateSatelliteFeeArgs], [IDL.Opt(Tokens)], ['query']),
|
|
44
|
+
get_credits: IDL.Func([], [Tokens], ['query']),
|
|
45
|
+
get_releases_version: IDL.Func([], [ReleasesVersion], ['query']),
|
|
46
|
+
get_user_mission_control_center: IDL.Func([], [IDL.Opt(MissionControl)], ['query']),
|
|
47
|
+
init_user_mission_control_center: IDL.Func([IDL.Opt(IDL.Text)], [MissionControl], []),
|
|
48
|
+
list_user_mission_control_centers: IDL.Func(
|
|
49
|
+
[],
|
|
50
|
+
[IDL.Vec(IDL.Tuple(IDL.Principal, MissionControl))],
|
|
51
|
+
['query']
|
|
52
|
+
),
|
|
53
|
+
load_release: IDL.Func([Segment, IDL.Vec(IDL.Nat8), IDL.Text], [LoadRelease], []),
|
|
54
|
+
reset_release: IDL.Func([Segment], [], []),
|
|
55
|
+
set_controllers: IDL.Func([SetControllersArgs], [], []),
|
|
56
|
+
update_rate_config: IDL.Func([Segment, RateConfig], [], []),
|
|
57
|
+
version: IDL.Func([], [IDL.Text], ['query'])
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export const init = ({IDL}) => {
|
|
61
|
+
return [];
|
|
62
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const idlFactory = ({IDL}) => {
|
|
2
|
+
const CreateSatelliteArgs = IDL.Record({
|
|
3
|
+
block_index: IDL.Opt(IDL.Nat64),
|
|
4
|
+
user: IDL.Principal
|
|
5
|
+
});
|
|
6
|
+
const DeleteControllersArgs = IDL.Record({
|
|
7
|
+
controllers: IDL.Vec(IDL.Principal)
|
|
8
|
+
});
|
|
9
|
+
const GetCreateSatelliteFeeArgs = IDL.Record({user: IDL.Principal});
|
|
10
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
11
|
+
const ReleasesVersion = IDL.Record({
|
|
12
|
+
satellite: IDL.Opt(IDL.Text),
|
|
13
|
+
mission_control: IDL.Opt(IDL.Text)
|
|
14
|
+
});
|
|
15
|
+
const MissionControl = IDL.Record({
|
|
16
|
+
updated_at: IDL.Nat64,
|
|
17
|
+
credits: Tokens,
|
|
18
|
+
mission_control_id: IDL.Opt(IDL.Principal),
|
|
19
|
+
owner: IDL.Principal,
|
|
20
|
+
created_at: IDL.Nat64
|
|
21
|
+
});
|
|
22
|
+
const Segment = IDL.Variant({
|
|
23
|
+
MissionControl: IDL.Null,
|
|
24
|
+
Satellite: IDL.Null
|
|
25
|
+
});
|
|
26
|
+
const LoadRelease = IDL.Record({total: IDL.Nat64, chunks: IDL.Nat64});
|
|
27
|
+
const SetController = IDL.Record({
|
|
28
|
+
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
29
|
+
expires_at: IDL.Opt(IDL.Nat64)
|
|
30
|
+
});
|
|
31
|
+
const SetControllersArgs = IDL.Record({
|
|
32
|
+
controller: SetController,
|
|
33
|
+
controllers: IDL.Vec(IDL.Principal)
|
|
34
|
+
});
|
|
35
|
+
const RateConfig = IDL.Record({
|
|
36
|
+
max_tokens: IDL.Nat64,
|
|
37
|
+
time_per_token_ns: IDL.Nat64
|
|
38
|
+
});
|
|
39
|
+
return IDL.Service({
|
|
40
|
+
add_invitation_code: IDL.Func([IDL.Text], [], []),
|
|
41
|
+
create_satellite: IDL.Func([CreateSatelliteArgs], [IDL.Principal], []),
|
|
42
|
+
del_controllers: IDL.Func([DeleteControllersArgs], [], []),
|
|
43
|
+
get_create_satellite_fee: IDL.Func([GetCreateSatelliteFeeArgs], [IDL.Opt(Tokens)], ['query']),
|
|
44
|
+
get_credits: IDL.Func([], [Tokens], ['query']),
|
|
45
|
+
get_releases_version: IDL.Func([], [ReleasesVersion], ['query']),
|
|
46
|
+
get_user_mission_control_center: IDL.Func([], [IDL.Opt(MissionControl)], ['query']),
|
|
47
|
+
init_user_mission_control_center: IDL.Func([IDL.Opt(IDL.Text)], [MissionControl], []),
|
|
48
|
+
list_user_mission_control_centers: IDL.Func(
|
|
49
|
+
[],
|
|
50
|
+
[IDL.Vec(IDL.Tuple(IDL.Principal, MissionControl))],
|
|
51
|
+
['query']
|
|
52
|
+
),
|
|
53
|
+
load_release: IDL.Func([Segment, IDL.Vec(IDL.Nat8), IDL.Text], [LoadRelease], []),
|
|
54
|
+
reset_release: IDL.Func([Segment], [], []),
|
|
55
|
+
set_controllers: IDL.Func([SetControllersArgs], [], []),
|
|
56
|
+
update_rate_config: IDL.Func([Segment, RateConfig], [], []),
|
|
57
|
+
version: IDL.Func([], [IDL.Text], ['query'])
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export const init = ({IDL}) => {
|
|
61
|
+
return [];
|
|
62
|
+
};
|
|
@@ -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 './console.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 console: 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 './console.did.js';
|
|
5
|
+
export {idlFactory} from './console.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
|
+
};
|