@airgap/icp 0.13.11-beta.1 → 0.13.11-beta.11

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.
Files changed (144) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +18 -0
  3. package/index.js.map +1 -0
  4. package/package.json +6 -9
  5. package/v1/block-explorer/ICPBlockExplorer.d.ts +9 -0
  6. package/v1/block-explorer/ICPBlockExplorer.js +74 -0
  7. package/v1/block-explorer/ICPBlockExplorer.js.map +1 -0
  8. package/v1/index.d.ts +14 -0
  9. package/v1/index.js +14 -0
  10. package/v1/index.js.map +1 -0
  11. package/v1/module/ICPModule.d.ts +14 -0
  12. package/v1/module/ICPModule.js +119 -0
  13. package/v1/module/ICPModule.js.map +1 -0
  14. package/v1/module.d.ts +3 -0
  15. package/v1/module.js +24 -0
  16. package/v1/module.js.map +1 -0
  17. package/v1/protocol/ICPImplementation.d.ts +34 -0
  18. package/v1/protocol/ICPImplementation.js +376 -0
  19. package/v1/protocol/ICPImplementation.js.map +1 -0
  20. package/v1/protocol/ICPProtocol.d.ts +45 -0
  21. package/v1/protocol/ICPProtocol.js +423 -0
  22. package/v1/protocol/ICPProtocol.js.map +1 -0
  23. package/v1/protocol/icrc/CkBTCProtocol.d.ts +13 -0
  24. package/v1/protocol/icrc/CkBTCProtocol.js +328 -0
  25. package/v1/protocol/icrc/CkBTCProtocol.js.map +1 -0
  26. package/v1/protocol/icrc/ICRC1Protocol.d.ts +91 -0
  27. package/v1/protocol/icrc/ICRC1Protocol.js +672 -0
  28. package/v1/protocol/icrc/ICRC1Protocol.js.map +1 -0
  29. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  30. package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
  31. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  32. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.d.ts +4 -0
  33. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js +3 -0
  34. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js.map +1 -0
  35. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.d.ts +3 -0
  36. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js +3 -0
  37. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js.map +1 -0
  38. package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +32 -0
  39. package/v1/serializer/v3/schemas/generated/transaction-sign-response-icp.json +19 -0
  40. package/v1/serializer/v3/serializer-companion.d.ts +14 -0
  41. package/v1/serializer/v3/serializer-companion.js +190 -0
  42. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  43. package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
  44. package/v1/serializer/v3/validators/transaction-validator.js +100 -0
  45. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
  46. package/v1/serializer/v3/validators/validators.d.ts +5 -0
  47. package/v1/serializer/v3/validators/validators.js +106 -0
  48. package/v1/serializer/v3/validators/validators.js.map +1 -0
  49. package/v1/types/ckbtc/metadata.d.ts +4 -0
  50. package/v1/types/ckbtc/metadata.js +3 -0
  51. package/v1/types/ckbtc/metadata.js.map +1 -0
  52. package/v1/types/crypto.d.ts +2 -0
  53. package/v1/types/crypto.js +3 -0
  54. package/v1/types/crypto.js.map +1 -0
  55. package/v1/types/governance.d.ts +580 -0
  56. package/v1/types/governance.js +796 -0
  57. package/v1/types/governance.js.map +1 -0
  58. package/v1/types/icrc/account.d.ts +4 -0
  59. package/v1/types/icrc/account.js +3 -0
  60. package/v1/types/icrc/account.js.map +1 -0
  61. package/v1/types/icrc/ledger.d.ts +15 -0
  62. package/v1/types/icrc/ledger.js +92 -0
  63. package/v1/types/icrc/ledger.js.map +1 -0
  64. package/v1/types/icrc/metadata.d.ts +6 -0
  65. package/v1/types/icrc/metadata.js +3 -0
  66. package/v1/types/icrc/metadata.js.map +1 -0
  67. package/v1/types/icrc/transfer.d.ts +9 -0
  68. package/v1/types/icrc/transfer.js +3 -0
  69. package/v1/types/icrc/transfer.js.map +1 -0
  70. package/v1/types/ledger.d.ts +142 -0
  71. package/v1/types/ledger.js +145 -0
  72. package/v1/types/ledger.js.map +1 -0
  73. package/v1/types/management_idl.d.ts +7 -0
  74. package/v1/types/management_idl.js +72 -0
  75. package/v1/types/management_idl.js.map +1 -0
  76. package/v1/types/protocol.d.ts +37 -0
  77. package/v1/types/protocol.js +3 -0
  78. package/v1/types/protocol.js.map +1 -0
  79. package/v1/types/transaction.d.ts +11 -0
  80. package/v1/types/transaction.js +3 -0
  81. package/v1/types/transaction.js.map +1 -0
  82. package/v1/utils/account.d.ts +24 -0
  83. package/v1/utils/account.js +112 -0
  84. package/v1/utils/account.js.map +1 -0
  85. package/v1/utils/actor.d.ts +246 -0
  86. package/v1/utils/actor.js +458 -0
  87. package/v1/utils/actor.js.map +1 -0
  88. package/v1/utils/agent.d.ts +156 -0
  89. package/v1/utils/agent.js +16 -0
  90. package/v1/utils/agent.js.map +1 -0
  91. package/v1/utils/auth.d.ts +110 -0
  92. package/v1/utils/auth.js +261 -0
  93. package/v1/utils/auth.js.map +1 -0
  94. package/v1/utils/bls.d.ts +38 -0
  95. package/v1/utils/bls.js +204 -0
  96. package/v1/utils/bls.js.map +1 -0
  97. package/v1/utils/buffer.d.ts +70 -0
  98. package/v1/utils/buffer.js +216 -0
  99. package/v1/utils/buffer.js.map +1 -0
  100. package/v1/utils/cbor.d.ts +9 -0
  101. package/v1/utils/cbor.js +178 -0
  102. package/v1/utils/cbor.js.map +1 -0
  103. package/v1/utils/certificate.d.ts +74 -0
  104. package/v1/utils/certificate.js +396 -0
  105. package/v1/utils/certificate.js.map +1 -0
  106. package/v1/utils/convert.d.ts +10 -0
  107. package/v1/utils/convert.js +88 -0
  108. package/v1/utils/convert.js.map +1 -0
  109. package/v1/utils/crypto.d.ts +0 -0
  110. package/v1/utils/crypto.js +104 -0
  111. package/v1/utils/crypto.js.map +1 -0
  112. package/v1/utils/der.d.ts +35 -0
  113. package/v1/utils/der.js +176 -0
  114. package/v1/utils/der.js.map +1 -0
  115. package/v1/utils/errors.d.ts +7 -0
  116. package/v1/utils/errors.js +38 -0
  117. package/v1/utils/errors.js.map +1 -0
  118. package/v1/utils/hdkey.d.ts +13 -0
  119. package/v1/utils/hdkey.js +265 -0
  120. package/v1/utils/hdkey.js.map +1 -0
  121. package/v1/utils/http.d.ts +284 -0
  122. package/v1/utils/http.js +614 -0
  123. package/v1/utils/http.js.map +1 -0
  124. package/v1/utils/icrc1.d.ts +20 -0
  125. package/v1/utils/icrc1.js +171 -0
  126. package/v1/utils/icrc1.js.map +1 -0
  127. package/v1/utils/idl.d.ts +515 -0
  128. package/v1/utils/idl.js +2103 -0
  129. package/v1/utils/idl.js.map +1 -0
  130. package/v1/utils/leb128.d.ts +63 -0
  131. package/v1/utils/leb128.js +224 -0
  132. package/v1/utils/leb128.js.map +1 -0
  133. package/v1/utils/polling.d.ts +59 -0
  134. package/v1/utils/polling.js +325 -0
  135. package/v1/utils/polling.js.map +1 -0
  136. package/v1/utils/principal.d.ts +58 -0
  137. package/v1/utils/principal.js +543 -0
  138. package/v1/utils/principal.js.map +1 -0
  139. package/v1/utils/secp256k1.d.ts +79 -0
  140. package/v1/utils/secp256k1.js +278 -0
  141. package/v1/utils/secp256k1.js.map +1 -0
  142. package/v1/utils/transaction.d.ts +3 -0
  143. package/v1/utils/transaction.js +56 -0
  144. package/v1/utils/transaction.js.map +1 -0
@@ -0,0 +1,37 @@
1
+ import { FeeDefaults, ProtocolNetwork, ProtocolUnitsMetadata } from '@airgap/module-kit';
2
+ export declare type ICPUnits = 'ICP';
3
+ export declare type CkBTCUnits = 'ckBTC';
4
+ export interface ICPProtocolNetwork extends ProtocolNetwork {
5
+ ledgerCanisterId: string;
6
+ explorerUrl: string;
7
+ }
8
+ export interface ICPProtocolOptions {
9
+ network: ICPProtocolNetwork;
10
+ }
11
+ export interface ICRC1OfflineProtocolOptions<_Units extends string = string> {
12
+ ledgerCanisterId: string;
13
+ identifier: string;
14
+ name: string;
15
+ units: ProtocolUnitsMetadata<_Units>;
16
+ mainUnit: _Units;
17
+ feeDefaults: FeeDefaults<_Units>;
18
+ }
19
+ export interface ICRC1ProtocolNetwork extends ICPProtocolNetwork {
20
+ }
21
+ export interface ICRC1OnlineProtocolOptions<_ProtocolNetwork extends ICRC1ProtocolNetwork = ICRC1ProtocolNetwork, _Units extends string = string> {
22
+ network: _ProtocolNetwork;
23
+ identifier: string;
24
+ name?: string;
25
+ units?: ProtocolUnitsMetadata<_Units>;
26
+ mainUnit?: _Units;
27
+ feeDefaults?: FeeDefaults<_Units>;
28
+ }
29
+ export interface CkBTCProtocolNetwork extends ICRC1ProtocolNetwork {
30
+ indexerCanisterId: string;
31
+ }
32
+ export interface CkBTCOfflineProtocolOptions {
33
+ ledgerCanisterId: string;
34
+ }
35
+ export interface CkBTCOnlineProtocolOptions {
36
+ network: CkBTCProtocolNetwork;
37
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/types/protocol.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { SignedTransaction, TransactionCursor, UnsignedTransaction } from '@airgap/module-kit';
2
+ export interface ICPUnsignedTransaction extends UnsignedTransaction {
3
+ networkId: string;
4
+ transaction: string;
5
+ }
6
+ export interface ICPSignedTransaction extends SignedTransaction {
7
+ transaction: string;
8
+ }
9
+ export interface ICPTransactionCursor extends TransactionCursor {
10
+ next: string;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/v1/types/transaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import type { AccountIdentifier as AccountIdentifierCandid } from '../types/governance';
2
+ import { Principal } from './principal';
3
+ export declare class AccountIdentifier {
4
+ private readonly bytes;
5
+ private constructor();
6
+ static fromHex(hex: string): AccountIdentifier;
7
+ static fromPrincipal({ principal, subAccount }: {
8
+ principal: Principal;
9
+ subAccount?: SubAccount;
10
+ }): AccountIdentifier;
11
+ toHex(): string;
12
+ toUint8Array(): Uint8Array;
13
+ toNumbers(): number[];
14
+ toAccountIdentifierHash(): AccountIdentifierCandid;
15
+ }
16
+ export declare class SubAccount {
17
+ private readonly bytes;
18
+ private constructor();
19
+ static fromBytes(bytes: Uint8Array): SubAccount | Error;
20
+ static fromPrincipal(principal: Principal): SubAccount;
21
+ static fromID(id: number): SubAccount;
22
+ static ZERO: SubAccount;
23
+ toUint8Array(): Uint8Array;
24
+ }
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.SubAccount = exports.AccountIdentifier = void 0;
29
+ var js_sha256_1 = require("js-sha256");
30
+ var buffer_1 = require("./buffer");
31
+ var convert_1 = require("./convert");
32
+ var AccountIdentifier = /** @class */ (function () {
33
+ function AccountIdentifier(bytes) {
34
+ this.bytes = bytes;
35
+ }
36
+ AccountIdentifier.fromHex = function (hex) {
37
+ return new AccountIdentifier(Uint8Array.from(Buffer.from(hex, 'hex')));
38
+ };
39
+ AccountIdentifier.fromPrincipal = function (_a) {
40
+ var principal = _a.principal, _b = _a.subAccount, subAccount = _b === void 0 ? SubAccount.ZERO : _b;
41
+ // Hash (sha224) the principal, the subAccount and some padding
42
+ var padding = (0, convert_1.asciiStringToByteArray)('\x0Aaccount-id');
43
+ var shaObj = js_sha256_1.sha224.create();
44
+ shaObj.update(__spreadArray(__spreadArray(__spreadArray([], __read(padding), false), __read(principal.toUint8Array()), false), __read(subAccount.toUint8Array()), false));
45
+ var hash = new Uint8Array(shaObj.array());
46
+ // Prepend the checksum of the hash and convert to a hex string
47
+ var checksum = (0, convert_1.calculateCrc32)(hash);
48
+ var bytes = new Uint8Array(__spreadArray(__spreadArray([], __read(checksum), false), __read(hash), false));
49
+ return new AccountIdentifier(bytes);
50
+ };
51
+ // /**
52
+ // * @returns An AccountIdentifier protobuf object.
53
+ // */
54
+ // public toProto(): AccountIdentifierPb {
55
+ // const accountIdentifier = new AccountIdentifierPb()
56
+ // accountIdentifier.setHash(this.bytes)
57
+ // return accountIdentifier
58
+ // }
59
+ AccountIdentifier.prototype.toHex = function () {
60
+ return (0, buffer_1.toHexString)(this.bytes);
61
+ };
62
+ AccountIdentifier.prototype.toUint8Array = function () {
63
+ return this.bytes;
64
+ };
65
+ AccountIdentifier.prototype.toNumbers = function () {
66
+ return Array.from(this.bytes);
67
+ };
68
+ AccountIdentifier.prototype.toAccountIdentifierHash = function () {
69
+ return {
70
+ hash: this.toUint8Array()
71
+ };
72
+ };
73
+ return AccountIdentifier;
74
+ }());
75
+ exports.AccountIdentifier = AccountIdentifier;
76
+ var SubAccount = /** @class */ (function () {
77
+ function SubAccount(bytes) {
78
+ this.bytes = bytes;
79
+ }
80
+ SubAccount.fromBytes = function (bytes) {
81
+ if (bytes.length != 32) {
82
+ return Error('Subaccount length must be 32-bytes');
83
+ }
84
+ return new SubAccount(bytes);
85
+ };
86
+ SubAccount.fromPrincipal = function (principal) {
87
+ var bytes = new Uint8Array(32).fill(0);
88
+ var principalBytes = principal.toUint8Array();
89
+ bytes[0] = principalBytes.length;
90
+ for (var i = 0; i < principalBytes.length; i++) {
91
+ bytes[1 + i] = principalBytes[i];
92
+ }
93
+ return new SubAccount(bytes);
94
+ };
95
+ SubAccount.fromID = function (id) {
96
+ if (id < 0 || id > 255) {
97
+ throw 'Subaccount ID must be >= 0 and <= 255';
98
+ }
99
+ var bytes = new Uint8Array(32).fill(0);
100
+ bytes[31] = id;
101
+ return new SubAccount(bytes);
102
+ };
103
+ SubAccount.prototype.toUint8Array = function () {
104
+ return this.bytes;
105
+ };
106
+ var _a;
107
+ _a = SubAccount;
108
+ SubAccount.ZERO = _a.fromID(0);
109
+ return SubAccount;
110
+ }());
111
+ exports.SubAccount = SubAccount;
112
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/v1/utils/account.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,246 @@
1
+ import { RequestId } from './auth';
2
+ import { CreateCertificateOptions } from './certificate';
3
+ import { Agent, HttpAgent, QueryResponseRejected, SubmitResponse } from './http';
4
+ import { Principal } from './principal';
5
+ import * as IDL from './idl';
6
+ import { PollStrategyFactory } from './polling';
7
+ import { AgentError } from './errors';
8
+ export interface GlobalInternetComputer {
9
+ ic: {
10
+ agent: Agent;
11
+ HttpAgent: typeof HttpAgent;
12
+ IDL: typeof IDL;
13
+ /**
14
+ * Simple advertisement of features in whoever is managing this `globalThis.ic`.
15
+ * Use Case
16
+ * * Scripts that know they need an ic feature can detect using this and, if not present
17
+ * (e.g. old bootstrap version), they can dynamically include their own and continue
18
+ * operating (e.g. polyfill).
19
+ * This is useful when adding features to bootstrap. You can still deploy your canister to
20
+ * an ic with old bootstrap, then just dynamically reload your own new-version bootstrap if
21
+ * needed.
22
+ */
23
+ features?: {
24
+ /** This is falsy if authn isn't supported at all */
25
+ authentication?: boolean;
26
+ };
27
+ /**
28
+ * The Actor for the canister being used for the frontend. Normally should correspond to the
29
+ * canister represented by the canister id in the URL.
30
+ *
31
+ * It does not have any functions configured.
32
+ *
33
+ * If a canister ID could not be found, no actor were created and this is undefined.
34
+ */
35
+ canister: ActorSubclass | undefined;
36
+ };
37
+ }
38
+ export declare function getDefaultAgent(): Agent;
39
+ /**
40
+ * This file is generated from the candid for asset management.
41
+ */
42
+ export declare type canister_id = Principal;
43
+ export interface canister_settings {
44
+ controllers: [] | [Array<Principal>];
45
+ freezing_threshold: [] | [bigint];
46
+ memory_allocation: [] | [bigint];
47
+ compute_allocation: [] | [bigint];
48
+ }
49
+ export interface definite_canister_settings {
50
+ controllers: Array<Principal>;
51
+ freezing_threshold: bigint;
52
+ memory_allocation: bigint;
53
+ compute_allocation: bigint;
54
+ }
55
+ export declare type user_id = Principal;
56
+ export declare type wasm_module = Array<number>;
57
+ export default interface _SERVICE {
58
+ canister_status: (arg_0: {
59
+ canister_id: canister_id;
60
+ }) => Promise<{
61
+ status: {
62
+ stopped: null;
63
+ } | {
64
+ stopping: null;
65
+ } | {
66
+ running: null;
67
+ };
68
+ memory_size: bigint;
69
+ cycles: bigint;
70
+ settings: definite_canister_settings;
71
+ module_hash: [] | [Array<number>];
72
+ }>;
73
+ create_canister: (arg_0: {
74
+ settings: [] | [canister_settings];
75
+ }) => Promise<{
76
+ canister_id: canister_id;
77
+ }>;
78
+ delete_canister: (arg_0: {
79
+ canister_id: canister_id;
80
+ }) => Promise<undefined>;
81
+ deposit_cycles: (arg_0: {
82
+ canister_id: canister_id;
83
+ }) => Promise<undefined>;
84
+ install_code: (arg_0: {
85
+ arg: Array<number>;
86
+ wasm_module: wasm_module;
87
+ mode: {
88
+ reinstall: null;
89
+ } | {
90
+ upgrade: null;
91
+ } | {
92
+ install: null;
93
+ };
94
+ canister_id: canister_id;
95
+ }) => Promise<undefined>;
96
+ provisional_create_canister_with_cycles: (arg_0: {
97
+ settings: [] | [canister_settings];
98
+ amount: [] | [bigint];
99
+ }) => Promise<{
100
+ canister_id: canister_id;
101
+ }>;
102
+ provisional_top_up_canister: (arg_0: {
103
+ canister_id: canister_id;
104
+ amount: bigint;
105
+ }) => Promise<undefined>;
106
+ raw_rand: () => Promise<Array<number>>;
107
+ start_canister: (arg_0: {
108
+ canister_id: canister_id;
109
+ }) => Promise<undefined>;
110
+ stop_canister: (arg_0: {
111
+ canister_id: canister_id;
112
+ }) => Promise<undefined>;
113
+ uninstall_code: (arg_0: {
114
+ canister_id: canister_id;
115
+ }) => Promise<undefined>;
116
+ update_settings: (arg_0: {
117
+ canister_id: Principal;
118
+ settings: canister_settings;
119
+ }) => Promise<undefined>;
120
+ }
121
+ export declare type ManagementCanisterRecord = _SERVICE;
122
+ export declare function getManagementCanister(config: CallConfig): ActorSubclass<ManagementCanisterRecord>;
123
+ export declare class ActorCallError extends AgentError {
124
+ readonly canisterId: Principal;
125
+ readonly methodName: string;
126
+ readonly type: 'query' | 'update';
127
+ readonly props: Record<string, string>;
128
+ constructor(canisterId: Principal, methodName: string, type: 'query' | 'update', props: Record<string, string>);
129
+ }
130
+ export declare class QueryCallRejectedError extends ActorCallError {
131
+ readonly result: QueryResponseRejected;
132
+ constructor(canisterId: Principal, methodName: string, result: QueryResponseRejected);
133
+ }
134
+ export declare class UpdateCallRejectedError extends ActorCallError {
135
+ readonly requestId: RequestId;
136
+ readonly response: SubmitResponse['response'];
137
+ constructor(canisterId: Principal, methodName: string, requestId: RequestId, response: SubmitResponse['response']);
138
+ }
139
+ /**
140
+ * Configuration to make calls to the Replica.
141
+ */
142
+ export interface CallConfig {
143
+ /**
144
+ * An agent to use in this call, otherwise the actor or call will try to discover the
145
+ * agent to use.
146
+ */
147
+ agent?: Agent;
148
+ /**
149
+ * A polling strategy factory that dictates how much and often we should poll the
150
+ * read_state endpoint to get the result of an update call.
151
+ */
152
+ pollingStrategyFactory?: PollStrategyFactory;
153
+ /**
154
+ * The canister ID of this Actor.
155
+ */
156
+ canisterId?: string | Principal;
157
+ /**
158
+ * The effective canister ID. This should almost always be ignored.
159
+ */
160
+ effectiveCanisterId?: Principal;
161
+ }
162
+ /**
163
+ * Configuration that can be passed to customize the Actor behaviour.
164
+ */
165
+ export interface ActorConfig extends CallConfig {
166
+ /**
167
+ * The Canister ID of this Actor. This is required for an Actor.
168
+ */
169
+ canisterId: string | Principal;
170
+ /**
171
+ * An override function for update calls' CallConfig. This will be called on every calls.
172
+ */
173
+ callTransform?(methodName: string, args: unknown[], callConfig: CallConfig): Partial<CallConfig> | void;
174
+ /**
175
+ * An override function for query calls' CallConfig. This will be called on every query.
176
+ */
177
+ queryTransform?(methodName: string, args: unknown[], callConfig: CallConfig): Partial<CallConfig> | void;
178
+ /**
179
+ * Polyfill for BLS Certificate verification in case wasm is not supported
180
+ */
181
+ blsVerify?: CreateCertificateOptions['blsVerify'];
182
+ }
183
+ /**
184
+ * A subclass of an actor. Actor class itself is meant to be a based class.
185
+ */
186
+ export declare type ActorSubclass<T = Record<string, ActorMethod>> = Actor & T;
187
+ /**
188
+ * An actor method type, defined for each methods of the actor service.
189
+ */
190
+ export interface ActorMethod<Args extends unknown[] = unknown[], Ret extends unknown = unknown> {
191
+ (...args: Args): Promise<Ret>;
192
+ withOptions(options: CallConfig): (...args: Args) => Promise<Ret>;
193
+ }
194
+ /**
195
+ * The mode used when installing a canister.
196
+ */
197
+ export declare enum CanisterInstallMode {
198
+ Install = "install",
199
+ Reinstall = "reinstall",
200
+ Upgrade = "upgrade"
201
+ }
202
+ /**
203
+ * Internal metadata for actors. It's an enhanced version of ActorConfig with
204
+ * some fields marked as required (as they are defaulted) and canisterId as
205
+ * a Principal type.
206
+ */
207
+ interface ActorMetadata {
208
+ service: IDL.ServiceClass;
209
+ agent?: Agent;
210
+ config: ActorConfig;
211
+ }
212
+ declare const metadataSymbol: unique symbol;
213
+ /**
214
+ * An actor base class. An actor is an object containing only functions that will
215
+ * return a promise. These functions are derived from the IDL definition.
216
+ */
217
+ export declare class Actor {
218
+ /**
219
+ * Get the Agent class this Actor would call, or undefined if the Actor would use
220
+ * the default agent (global.ic.agent).
221
+ * @param actor The actor to get the agent of.
222
+ */
223
+ static agentOf(actor: Actor): Agent | undefined;
224
+ /**
225
+ * Get the interface of an actor, in the form of an instance of a Service.
226
+ * @param actor The actor to get the interface of.
227
+ */
228
+ static interfaceOf(actor: Actor): IDL.ServiceClass;
229
+ static canisterIdOf(actor: Actor): Principal;
230
+ static install(fields: {
231
+ module: ArrayBuffer;
232
+ mode?: CanisterInstallMode;
233
+ arg?: ArrayBuffer;
234
+ }, config: ActorConfig): Promise<void>;
235
+ static createCanister(config?: CallConfig): Promise<Principal>;
236
+ static createAndInstallCanister(interfaceFactory: IDL.InterfaceFactory, fields: {
237
+ module: ArrayBuffer;
238
+ arg?: ArrayBuffer;
239
+ }, config?: CallConfig): Promise<ActorSubclass>;
240
+ static createActorClass(interfaceFactory: IDL.InterfaceFactory): ActorConstructor;
241
+ static createActor<T = Record<string, ActorMethod>>(interfaceFactory: IDL.InterfaceFactory, configuration: ActorConfig): ActorSubclass<T>;
242
+ private [metadataSymbol];
243
+ protected constructor(metadata: ActorMetadata);
244
+ }
245
+ export declare type ActorConstructor = new (config: ActorConfig) => ActorSubclass;
246
+ export {};