@astrox/connection 0.0.24 → 0.0.27
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 +22 -10
- package/lib/cjs/canisters/internet_identity_idl.d.ts +7 -0
- package/lib/cjs/canisters/internet_identity_idl.js +102 -0
- package/lib/cjs/canisters/internet_identity_idl.js.map +1 -0
- package/lib/cjs/canisters/ledger.idl.d.ts +7 -0
- package/lib/cjs/canisters/ledger.idl.js +82 -0
- package/lib/cjs/canisters/ledger.idl.js.map +1 -0
- package/lib/cjs/canisters/me.idl.d.ts +7 -0
- package/lib/cjs/canisters/me.idl.js +126 -0
- package/lib/cjs/canisters/me.idl.js.map +1 -0
- package/lib/cjs/canisters/nns-dapp-cert.idl.d.ts +7 -0
- package/lib/cjs/canisters/nns-dapp-cert.idl.js +87 -0
- package/lib/cjs/canisters/nns-dapp-cert.idl.js.map +1 -0
- package/lib/cjs/canisters/nns-dapp.idl.d.ts +7 -0
- package/lib/cjs/canisters/nns-dapp.idl.js +185 -0
- package/lib/cjs/canisters/nns-dapp.idl.js.map +1 -0
- package/lib/cjs/connections/baseConnection.d.ts +23 -0
- package/lib/cjs/connections/baseConnection.js +89 -0
- package/lib/cjs/connections/baseConnection.js.map +1 -0
- package/lib/cjs/connections/ledgerConnection.d.ts +53 -0
- package/lib/cjs/connections/ledgerConnection.js +137 -0
- package/lib/cjs/connections/ledgerConnection.js.map +1 -0
- package/lib/cjs/connections/nnsConnection.d.ts +63 -0
- package/lib/cjs/connections/nnsConnection.js +161 -0
- package/lib/cjs/connections/nnsConnection.js.map +1 -0
- package/lib/cjs/ic/icAuthClient.d.ts +31 -0
- package/lib/cjs/ic/icAuthClient.js +236 -0
- package/lib/cjs/ic/icAuthClient.js.map +1 -0
- package/lib/cjs/ic/icConnect.d.ts +36 -0
- package/lib/cjs/ic/icConnect.js +192 -0
- package/lib/cjs/ic/icConnect.js.map +1 -0
- package/lib/cjs/ic/icStorage.d.ts +16 -0
- package/lib/cjs/ic/icStorage.js +49 -0
- package/lib/cjs/ic/icStorage.js.map +1 -0
- package/lib/cjs/ic/icWindow.d.ts +8 -0
- package/lib/cjs/ic/icWindow.js +24 -0
- package/lib/cjs/ic/icWindow.js.map +1 -0
- package/lib/cjs/ic/index.d.ts +2 -0
- package/lib/cjs/ic/index.js +8 -0
- package/lib/cjs/ic/index.js.map +1 -0
- package/lib/cjs/index.d.ts +5 -0
- package/lib/cjs/index.js +18 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types/index.d.ts +175 -0
- package/lib/cjs/types/index.js +17 -0
- package/lib/cjs/types/index.js.map +1 -0
- package/lib/cjs/utils/common/types.d.ts +15 -0
- package/lib/cjs/utils/common/types.js +12 -0
- package/lib/cjs/utils/common/types.js.map +1 -0
- package/lib/cjs/utils/constants.d.ts +6 -0
- package/lib/cjs/utils/constants.js +13 -0
- package/lib/cjs/utils/constants.js.map +1 -0
- package/lib/cjs/utils/converter.d.ts +32 -0
- package/lib/cjs/utils/converter.js +147 -0
- package/lib/cjs/utils/converter.js.map +1 -0
- package/lib/cjs/utils/index.d.ts +3 -0
- package/lib/cjs/utils/index.js +16 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/esm/canisters/internet_identity_idl.d.ts +7 -0
- package/lib/esm/canisters/internet_identity_idl.js +98 -0
- package/lib/esm/canisters/internet_identity_idl.js.map +1 -0
- package/lib/esm/canisters/ledger.idl.d.ts +7 -0
- package/lib/esm/canisters/ledger.idl.js +78 -0
- package/lib/esm/canisters/ledger.idl.js.map +1 -0
- package/lib/esm/canisters/me.idl.d.ts +7 -0
- package/lib/esm/canisters/me.idl.js +122 -0
- package/lib/esm/canisters/me.idl.js.map +1 -0
- package/lib/esm/canisters/nns-dapp-cert.idl.d.ts +7 -0
- package/lib/esm/canisters/nns-dapp-cert.idl.js +83 -0
- package/lib/esm/canisters/nns-dapp-cert.idl.js.map +1 -0
- package/lib/esm/canisters/nns-dapp.idl.d.ts +7 -0
- package/lib/esm/canisters/nns-dapp.idl.js +181 -0
- package/lib/esm/canisters/nns-dapp.idl.js.map +1 -0
- package/lib/esm/connections/baseConnection.d.ts +23 -0
- package/lib/esm/connections/baseConnection.js +80 -0
- package/lib/esm/connections/baseConnection.js.map +1 -0
- package/lib/esm/connections/ledgerConnection.d.ts +53 -0
- package/lib/esm/connections/ledgerConnection.js +130 -0
- package/lib/esm/connections/ledgerConnection.js.map +1 -0
- package/lib/esm/connections/nnsConnection.d.ts +63 -0
- package/lib/esm/connections/nnsConnection.js +154 -0
- package/lib/esm/connections/nnsConnection.js.map +1 -0
- package/lib/esm/ic/icAuthClient.d.ts +31 -0
- package/lib/esm/ic/icAuthClient.js +232 -0
- package/lib/esm/ic/icAuthClient.js.map +1 -0
- package/lib/esm/ic/icConnect.d.ts +36 -0
- package/lib/esm/ic/icConnect.js +188 -0
- package/lib/esm/ic/icConnect.js.map +1 -0
- package/lib/esm/ic/icStorage.d.ts +16 -0
- package/lib/esm/ic/icStorage.js +44 -0
- package/lib/esm/ic/icStorage.js.map +1 -0
- package/lib/esm/ic/icWindow.d.ts +8 -0
- package/lib/esm/ic/icWindow.js +20 -0
- package/lib/esm/ic/icWindow.js.map +1 -0
- package/lib/esm/ic/index.d.ts +2 -0
- package/lib/esm/ic/index.js +3 -0
- package/lib/esm/ic/index.js.map +1 -0
- package/lib/esm/index.d.ts +5 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types/index.d.ts +175 -0
- package/lib/esm/types/index.js +14 -0
- package/lib/esm/types/index.js.map +1 -0
- package/lib/esm/utils/common/types.d.ts +15 -0
- package/lib/esm/utils/common/types.js +9 -0
- package/lib/esm/utils/common/types.js.map +1 -0
- package/lib/esm/utils/constants.d.ts +6 -0
- package/lib/esm/utils/constants.js +10 -0
- package/lib/esm/utils/constants.js.map +1 -0
- package/lib/esm/utils/converter.d.ts +32 -0
- package/lib/esm/utils/converter.js +124 -0
- package/lib/esm/utils/converter.js.map +1 -0
- package/lib/esm/utils/index.d.ts +3 -0
- package/lib/esm/utils/index.js +4 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/tsconfig-cjs.tsbuildinfo +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
@@ -0,0 +1,185 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.init = void 0;
|
4
|
+
exports.default = ({ IDL }) => {
|
5
|
+
const AccountIdentifier = IDL.Text;
|
6
|
+
const AttachCanisterRequest = IDL.Record({
|
7
|
+
name: IDL.Text,
|
8
|
+
canister_id: IDL.Principal,
|
9
|
+
});
|
10
|
+
const AttachCanisterResponse = IDL.Variant({
|
11
|
+
Ok: IDL.Null,
|
12
|
+
CanisterAlreadyAttached: IDL.Null,
|
13
|
+
NameAlreadyTaken: IDL.Null,
|
14
|
+
NameTooLong: IDL.Null,
|
15
|
+
CanisterLimitExceeded: IDL.Null,
|
16
|
+
});
|
17
|
+
const SubAccount = IDL.Vec(IDL.Nat8);
|
18
|
+
const SubAccountDetails = IDL.Record({
|
19
|
+
name: IDL.Text,
|
20
|
+
sub_account: SubAccount,
|
21
|
+
account_identifier: AccountIdentifier,
|
22
|
+
});
|
23
|
+
const CreateSubAccountResponse = IDL.Variant({
|
24
|
+
Ok: SubAccountDetails,
|
25
|
+
AccountNotFound: IDL.Null,
|
26
|
+
NameTooLong: IDL.Null,
|
27
|
+
SubAccountLimitExceeded: IDL.Null,
|
28
|
+
});
|
29
|
+
const DetachCanisterRequest = IDL.Record({ canister_id: IDL.Principal });
|
30
|
+
const DetachCanisterResponse = IDL.Variant({
|
31
|
+
Ok: IDL.Null,
|
32
|
+
CanisterNotFound: IDL.Null,
|
33
|
+
});
|
34
|
+
const HardwareWalletAccountDetails = IDL.Record({
|
35
|
+
principal: IDL.Principal,
|
36
|
+
name: IDL.Text,
|
37
|
+
account_identifier: AccountIdentifier,
|
38
|
+
});
|
39
|
+
const AccountDetails = IDL.Record({
|
40
|
+
principal: IDL.Principal,
|
41
|
+
account_identifier: AccountIdentifier,
|
42
|
+
hardware_wallet_accounts: IDL.Vec(HardwareWalletAccountDetails),
|
43
|
+
sub_accounts: IDL.Vec(SubAccountDetails),
|
44
|
+
});
|
45
|
+
const GetAccountResponse = IDL.Variant({
|
46
|
+
Ok: AccountDetails,
|
47
|
+
AccountNotFound: IDL.Null,
|
48
|
+
});
|
49
|
+
const CanisterDetails = IDL.Record({
|
50
|
+
name: IDL.Text,
|
51
|
+
canister_id: IDL.Principal,
|
52
|
+
});
|
53
|
+
const BlockHeight = IDL.Nat64;
|
54
|
+
const MultiPartTransactionError = IDL.Record({
|
55
|
+
error_message: IDL.Text,
|
56
|
+
block_height: BlockHeight,
|
57
|
+
});
|
58
|
+
const CanisterId = IDL.Principal;
|
59
|
+
const NeuronId = IDL.Nat64;
|
60
|
+
const MultiPartTransactionStatus = IDL.Variant({
|
61
|
+
Queued: IDL.Null,
|
62
|
+
Error: IDL.Text,
|
63
|
+
Refunded: IDL.Tuple(BlockHeight, IDL.Text),
|
64
|
+
CanisterCreated: CanisterId,
|
65
|
+
Complete: IDL.Null,
|
66
|
+
NotFound: IDL.Null,
|
67
|
+
NeuronCreated: NeuronId,
|
68
|
+
PendingSync: IDL.Null,
|
69
|
+
ErrorWithRefundPending: IDL.Text,
|
70
|
+
});
|
71
|
+
const Stats = IDL.Record({
|
72
|
+
latest_transaction_block_height: BlockHeight,
|
73
|
+
seconds_since_last_ledger_sync: IDL.Nat64,
|
74
|
+
sub_accounts_count: IDL.Nat64,
|
75
|
+
neurons_topped_up_count: IDL.Nat64,
|
76
|
+
transactions_to_process_queue_length: IDL.Nat32,
|
77
|
+
neurons_created_count: IDL.Nat64,
|
78
|
+
hardware_wallet_accounts_count: IDL.Nat64,
|
79
|
+
accounts_count: IDL.Nat64,
|
80
|
+
earliest_transaction_block_height: BlockHeight,
|
81
|
+
transactions_count: IDL.Nat64,
|
82
|
+
block_height_synced_up_to: IDL.Opt(IDL.Nat64),
|
83
|
+
latest_transaction_timestamp_nanos: IDL.Nat64,
|
84
|
+
earliest_transaction_timestamp_nanos: IDL.Nat64,
|
85
|
+
});
|
86
|
+
const GetTransactionsRequest = IDL.Record({
|
87
|
+
page_size: IDL.Nat8,
|
88
|
+
offset: IDL.Nat32,
|
89
|
+
account_identifier: AccountIdentifier,
|
90
|
+
});
|
91
|
+
const TransactionType = IDL.Variant({
|
92
|
+
Burn: IDL.Null,
|
93
|
+
Mint: IDL.Null,
|
94
|
+
Send: IDL.Null,
|
95
|
+
StakeNeuronNotification: IDL.Null,
|
96
|
+
TopUpCanister: CanisterId,
|
97
|
+
CreateCanister: IDL.Null,
|
98
|
+
TopUpNeuron: IDL.Null,
|
99
|
+
StakeNeuron: IDL.Null,
|
100
|
+
});
|
101
|
+
const Timestamp = IDL.Record({ timestamp_nanos: IDL.Nat64 });
|
102
|
+
const ICPTs = IDL.Record({ e8s: IDL.Nat64 });
|
103
|
+
const Send = IDL.Record({
|
104
|
+
to: AccountIdentifier,
|
105
|
+
fee: ICPTs,
|
106
|
+
amount: ICPTs,
|
107
|
+
});
|
108
|
+
const Receive = IDL.Record({
|
109
|
+
fee: ICPTs,
|
110
|
+
from: AccountIdentifier,
|
111
|
+
amount: ICPTs,
|
112
|
+
});
|
113
|
+
const Transfer = IDL.Variant({
|
114
|
+
Burn: IDL.Record({ amount: ICPTs }),
|
115
|
+
Mint: IDL.Record({ amount: ICPTs }),
|
116
|
+
Send: Send,
|
117
|
+
Receive: Receive,
|
118
|
+
});
|
119
|
+
const Transaction = IDL.Record({
|
120
|
+
transaction_type: IDL.Opt(TransactionType),
|
121
|
+
memo: IDL.Nat64,
|
122
|
+
timestamp: Timestamp,
|
123
|
+
block_height: BlockHeight,
|
124
|
+
transfer: Transfer,
|
125
|
+
});
|
126
|
+
const GetTransactionsResponse = IDL.Record({
|
127
|
+
total: IDL.Nat32,
|
128
|
+
transactions: IDL.Vec(Transaction),
|
129
|
+
});
|
130
|
+
const HeaderField = IDL.Tuple(IDL.Text, IDL.Text);
|
131
|
+
const HttpRequest = IDL.Record({
|
132
|
+
url: IDL.Text,
|
133
|
+
method: IDL.Text,
|
134
|
+
body: IDL.Vec(IDL.Nat8),
|
135
|
+
headers: IDL.Vec(HeaderField),
|
136
|
+
});
|
137
|
+
const HttpResponse = IDL.Record({
|
138
|
+
body: IDL.Vec(IDL.Nat8),
|
139
|
+
headers: IDL.Vec(HeaderField),
|
140
|
+
status_code: IDL.Nat16,
|
141
|
+
});
|
142
|
+
const RegisterHardwareWalletRequest = IDL.Record({
|
143
|
+
principal: IDL.Principal,
|
144
|
+
name: IDL.Text,
|
145
|
+
});
|
146
|
+
const RegisterHardwareWalletResponse = IDL.Variant({
|
147
|
+
Ok: IDL.Null,
|
148
|
+
AccountNotFound: IDL.Null,
|
149
|
+
HardwareWalletAlreadyRegistered: IDL.Null,
|
150
|
+
HardwareWalletLimitExceeded: IDL.Null,
|
151
|
+
NameTooLong: IDL.Null,
|
152
|
+
});
|
153
|
+
const RenameSubAccountRequest = IDL.Record({
|
154
|
+
new_name: IDL.Text,
|
155
|
+
account_identifier: AccountIdentifier,
|
156
|
+
});
|
157
|
+
const RenameSubAccountResponse = IDL.Variant({
|
158
|
+
Ok: IDL.Null,
|
159
|
+
AccountNotFound: IDL.Null,
|
160
|
+
SubAccountNotFound: IDL.Null,
|
161
|
+
NameTooLong: IDL.Null,
|
162
|
+
});
|
163
|
+
return IDL.Service({
|
164
|
+
add_account: IDL.Func([], [AccountIdentifier], []),
|
165
|
+
add_stable_asset: IDL.Func([IDL.Vec(IDL.Nat8)], [], []),
|
166
|
+
attach_canister: IDL.Func([AttachCanisterRequest], [AttachCanisterResponse], []),
|
167
|
+
create_sub_account: IDL.Func([IDL.Text], [CreateSubAccountResponse], []),
|
168
|
+
detach_canister: IDL.Func([DetachCanisterRequest], [DetachCanisterResponse], []),
|
169
|
+
get_account: IDL.Func([], [GetAccountResponse], ['query']),
|
170
|
+
get_canisters: IDL.Func([], [IDL.Vec(CanisterDetails)], ['query']),
|
171
|
+
get_icp_to_cycles_conversion_rate: IDL.Func([], [IDL.Nat64], ['query']),
|
172
|
+
get_multi_part_transaction_errors: IDL.Func([], [IDL.Vec(MultiPartTransactionError)], ['query']),
|
173
|
+
get_multi_part_transaction_status: IDL.Func([IDL.Principal, BlockHeight], [MultiPartTransactionStatus], ['query']),
|
174
|
+
get_stats: IDL.Func([], [Stats], ['query']),
|
175
|
+
get_transactions: IDL.Func([GetTransactionsRequest], [GetTransactionsResponse], ['query']),
|
176
|
+
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
|
177
|
+
register_hardware_wallet: IDL.Func([RegisterHardwareWalletRequest], [RegisterHardwareWalletResponse], []),
|
178
|
+
rename_sub_account: IDL.Func([RenameSubAccountRequest], [RenameSubAccountResponse], []),
|
179
|
+
});
|
180
|
+
};
|
181
|
+
const init = ({ IDL }) => {
|
182
|
+
return [];
|
183
|
+
};
|
184
|
+
exports.init = init;
|
185
|
+
//# sourceMappingURL=nns-dapp.idl.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"nns-dapp.idl.js","sourceRoot":"","sources":["../../../src/canisters/nns-dapp.idl.js"],"names":[],"mappings":";;;AAAA,kBAAe,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACzB,MAAM,iBAAiB,GAAG,GAAG,CAAC,IAAI,CAAC;IACnC,MAAM,qBAAqB,GAAG,GAAG,CAAC,MAAM,CAAC;QACvC,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,SAAS;KAC3B,CAAC,CAAC;IACH,MAAM,sBAAsB,GAAG,GAAG,CAAC,OAAO,CAAC;QACzC,EAAE,EAAE,GAAG,CAAC,IAAI;QACZ,uBAAuB,EAAE,GAAG,CAAC,IAAI;QACjC,gBAAgB,EAAE,GAAG,CAAC,IAAI;QAC1B,WAAW,EAAE,GAAG,CAAC,IAAI;Q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AAC,uBAAuB,CAAC,EACzB,CAAC,wBAAwB,CAAC,EAC1B,EAAE,CACH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AACK,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAC9B,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAFW,QAAA,IAAI,QAEf"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { ActorSubclass, HttpAgent, SignIdentity } from '@dfinity/agent';
|
2
|
+
import { InterfaceFactory } from '@dfinity/candid/lib/cjs/idl';
|
3
|
+
import { DelegationIdentity } from '@dfinity/identity';
|
4
|
+
import { AbstractConnection, CreateActorResult, DelegationMessage, HandleDelegationResult } from '../types';
|
5
|
+
export declare function createConnection<T>(identity: SignIdentity, delegationIdentity: DelegationIdentity, canisterId: string, interfaceFactory: InterfaceFactory, actor?: ActorSubclass<T>, agent?: HttpAgent): BaseConnection<T>;
|
6
|
+
export declare const requestDelegation: (identity: SignIdentity, { canisterId, date }: {
|
7
|
+
canisterId?: string | undefined;
|
8
|
+
date?: Date | undefined;
|
9
|
+
}) => Promise<DelegationIdentity>;
|
10
|
+
export declare function _createActor<T>(interfaceFactory: InterfaceFactory, canisterId: string, identity?: SignIdentity): Promise<CreateActorResult<T>>;
|
11
|
+
export declare class BaseConnection<T> implements AbstractConnection<T> {
|
12
|
+
identity: SignIdentity;
|
13
|
+
delegationIdentity: DelegationIdentity;
|
14
|
+
canisterId: string;
|
15
|
+
interfaceFactory: InterfaceFactory;
|
16
|
+
actor?: ActorSubclass<T> | undefined;
|
17
|
+
agent?: HttpAgent | undefined;
|
18
|
+
constructor(identity: SignIdentity, delegationIdentity: DelegationIdentity, canisterId: string, interfaceFactory: InterfaceFactory, actor?: ActorSubclass<T> | undefined, agent?: HttpAgent | undefined);
|
19
|
+
getActor(): Promise<ActorSubclass<T>>;
|
20
|
+
protected _getActor(canisterId: string, interfaceFactory: InterfaceFactory, date?: Date): Promise<ActorSubclass<T>>;
|
21
|
+
}
|
22
|
+
export declare function handleDelegation(message: DelegationMessage, key: SignIdentity): Promise<HandleDelegationResult>;
|
23
|
+
export declare const executeWithLogging: <T>(func: () => Promise<T>) => Promise<T>;
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.executeWithLogging = exports.handleDelegation = exports.BaseConnection = exports._createActor = exports.requestDelegation = exports.createConnection = void 0;
|
4
|
+
const agent_1 = require("@dfinity/agent");
|
5
|
+
const identity_1 = require("@dfinity/identity");
|
6
|
+
const principal_1 = require("@dfinity/principal");
|
7
|
+
function createConnection(identity, delegationIdentity, canisterId, interfaceFactory, actor, agent) {
|
8
|
+
return new BaseConnection(identity, delegationIdentity, canisterId, interfaceFactory, actor, agent);
|
9
|
+
}
|
10
|
+
exports.createConnection = createConnection;
|
11
|
+
const requestDelegation = async (identity, { canisterId, date }) => {
|
12
|
+
const sessionKey = identity_1.Ed25519KeyIdentity.generate();
|
13
|
+
const chain = await identity_1.DelegationChain.create(identity, sessionKey.getPublicKey(), date || new Date(Date.parse('2100-01-01')), {
|
14
|
+
targets: canisterId != undefined ? [principal_1.Principal.fromText(canisterId)] : undefined,
|
15
|
+
});
|
16
|
+
return identity_1.DelegationIdentity.fromDelegation(sessionKey, chain);
|
17
|
+
};
|
18
|
+
exports.requestDelegation = requestDelegation;
|
19
|
+
async function _createActor(interfaceFactory, canisterId, identity) {
|
20
|
+
const agent = new agent_1.HttpAgent({ identity });
|
21
|
+
// Only fetch the root key when we're not in prod
|
22
|
+
if (process.env.II_ENV === 'development') {
|
23
|
+
await agent.fetchRootKey();
|
24
|
+
}
|
25
|
+
const actor = agent_1.Actor.createActor(interfaceFactory, {
|
26
|
+
agent,
|
27
|
+
canisterId,
|
28
|
+
});
|
29
|
+
return { actor, agent };
|
30
|
+
}
|
31
|
+
exports._createActor = _createActor;
|
32
|
+
class BaseConnection {
|
33
|
+
constructor(identity, delegationIdentity, canisterId, interfaceFactory, actor, agent) {
|
34
|
+
this.identity = identity;
|
35
|
+
this.delegationIdentity = delegationIdentity;
|
36
|
+
this.canisterId = canisterId;
|
37
|
+
this.interfaceFactory = interfaceFactory;
|
38
|
+
this.actor = actor;
|
39
|
+
this.agent = agent;
|
40
|
+
}
|
41
|
+
async getActor() {
|
42
|
+
throw new Error('Method not implemented.');
|
43
|
+
}
|
44
|
+
async _getActor(canisterId, interfaceFactory, date) {
|
45
|
+
var _a, _b;
|
46
|
+
for (const { delegation } of this.delegationIdentity.getDelegation().delegations) {
|
47
|
+
// prettier-ignore
|
48
|
+
if (+new Date(Number(delegation.expiration / BigInt(1000000))) <= +Date.now()) {
|
49
|
+
this.actor = undefined;
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
if (this.actor === undefined) {
|
54
|
+
// Create our actor with a DelegationIdentity to avoid re-prompting auth
|
55
|
+
this.delegationIdentity = await (0, exports.requestDelegation)(this.identity, {
|
56
|
+
canisterId: (_a = this.canisterId) !== null && _a !== void 0 ? _a : canisterId,
|
57
|
+
date: date !== null && date !== void 0 ? date : undefined,
|
58
|
+
});
|
59
|
+
this.actor = (await _createActor(interfaceFactory, (_b = this.canisterId) !== null && _b !== void 0 ? _b : canisterId, this.delegationIdentity)).actor;
|
60
|
+
}
|
61
|
+
return this.actor;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
exports.BaseConnection = BaseConnection;
|
65
|
+
async function handleDelegation(message, key) {
|
66
|
+
const delegations = message.delegations.map(signedDelegation => {
|
67
|
+
return {
|
68
|
+
delegation: new identity_1.Delegation(signedDelegation.delegation.pubkey, signedDelegation.delegation.expiration, signedDelegation.delegation.targets),
|
69
|
+
signature: signedDelegation.signature.buffer,
|
70
|
+
};
|
71
|
+
});
|
72
|
+
const delegationChain = identity_1.DelegationChain.fromDelegations(delegations, message.userPublicKey.buffer);
|
73
|
+
return {
|
74
|
+
delegationChain,
|
75
|
+
delegationIdentity: identity_1.DelegationIdentity.fromDelegation(key, delegationChain),
|
76
|
+
};
|
77
|
+
}
|
78
|
+
exports.handleDelegation = handleDelegation;
|
79
|
+
const executeWithLogging = async (func) => {
|
80
|
+
try {
|
81
|
+
return await func();
|
82
|
+
}
|
83
|
+
catch (e) {
|
84
|
+
console.log(e);
|
85
|
+
throw e;
|
86
|
+
}
|
87
|
+
};
|
88
|
+
exports.executeWithLogging = executeWithLogging;
|
89
|
+
//# sourceMappingURL=baseConnection.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"baseConnection.js","sourceRoot":"","sources":["../../../src/connections/baseConnection.ts"],"names":[],"mappings":";;;AAAA,0CAOwB;AAGxB,gDAK2B;AAC3B,kDAA+C;AAQ/C,SAAgB,gBAAgB,CAC9B,QAAsB,EACtB,kBAAsC,EACtC,UAAkB,EAClB,gBAAkC,EAClC,KAAwB,EACxB,KAAiB;IAEjB,OAAO,IAAI,cAAc,CACvB,QAAQ,EACR,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,KAAK,CACN,CAAC;AACJ,CAAC;AAhBD,4CAgBC;AAEM,MAAM,iBAAiB,GAAG,KAAK,EACpC,QAAsB,EACtB,EAAE,UAAU,EAAE,IAAI,EAAwC,EAC7B,EAAE;IAC/B,MAAM,UAAU,GAAG,6BAAkB,CAAC,QAAQ,EAAE,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,0BAAe,CAAC,MAAM,CACxC,QAAQ,EACR,UAAU,CAAC,YAAY,EAAE,EACzB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAC1C;QACE,OAAO,EAAE,UAAU,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,qBAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KAChF,CACF,CAAC;IAEF,OAAO,6BAAkB,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AA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EAAK,IAAsB,EAAc,EAAE;IAChF,IAAI;QACF,OAAO,MAAM,IAAI,EAAE,CAAC;KACrB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { BaseConnection } from './baseConnection';
|
2
|
+
import LEDGER_SERVICE, { AccountIdentifier, BlockHeight } from '../canisters/ledger';
|
3
|
+
import { ActorSubclass, HttpAgent, SignIdentity } from '@dfinity/agent';
|
4
|
+
import { DelegationIdentity } from '@dfinity/identity';
|
5
|
+
import { CreateActorResult, SendOpts } from '../types';
|
6
|
+
export declare class LedgerConnection extends BaseConnection<LEDGER_SERVICE> {
|
7
|
+
identity: SignIdentity;
|
8
|
+
delegationIdentity: DelegationIdentity;
|
9
|
+
actor?: ActorSubclass<LEDGER_SERVICE> | undefined;
|
10
|
+
agent?: HttpAgent | undefined;
|
11
|
+
protected constructor(identity: SignIdentity, delegationIdentity: DelegationIdentity, actor?: ActorSubclass<LEDGER_SERVICE> | undefined, agent?: HttpAgent | undefined, legerCanisterId?: string);
|
12
|
+
/**
|
13
|
+
* create connection
|
14
|
+
* @param identity
|
15
|
+
* @param delegationIdentity
|
16
|
+
* @param legerCanisterId
|
17
|
+
* @param actor
|
18
|
+
* @param agent
|
19
|
+
* @function createConnection
|
20
|
+
* @returns {LedgerConnection}
|
21
|
+
*/
|
22
|
+
static createConnection(identity: SignIdentity, delegationIdentity: DelegationIdentity, legerCanisterId?: string, actor?: ActorSubclass<LEDGER_SERVICE>, agent?: HttpAgent): LedgerConnection;
|
23
|
+
/**
|
24
|
+
* create Actor with DelegationIdentity
|
25
|
+
* @param delegationIdentity
|
26
|
+
* @param canisterId
|
27
|
+
* @param ledgerCanisterId
|
28
|
+
* @function {function name}
|
29
|
+
* @returns {type} {description}
|
30
|
+
*/
|
31
|
+
static createActor(delegationIdentity: DelegationIdentity, ledgerCanisterId?: string): Promise<CreateActorResult<LEDGER_SERVICE>>;
|
32
|
+
static createConnectionWithII(identity: SignIdentity, delegationIdentity: DelegationIdentity, legerCanisterId?: string): Promise<LedgerConnection>;
|
33
|
+
static actorGetBalance(actor: ActorSubclass<LEDGER_SERVICE>, account: AccountIdentifier): Promise<bigint>;
|
34
|
+
static actorSend(actor: ActorSubclass<LEDGER_SERVICE>, { to, amount, sendOpts, }: {
|
35
|
+
to: AccountIdentifier;
|
36
|
+
amount: bigint;
|
37
|
+
sendOpts?: SendOpts;
|
38
|
+
}): Promise<BlockHeight>;
|
39
|
+
/**
|
40
|
+
* get NNS Actor, used internally
|
41
|
+
* @param canisterId
|
42
|
+
* @param ledgerCanisterId
|
43
|
+
* @function {function name}
|
44
|
+
* @returns {type} {description}
|
45
|
+
*/
|
46
|
+
getLedgerActor(ledgerCanisterId?: string): Promise<ActorSubclass<LEDGER_SERVICE>>;
|
47
|
+
getBalance(account: AccountIdentifier): Promise<bigint>;
|
48
|
+
send({ to, amount, sendOpts, }: {
|
49
|
+
to: AccountIdentifier;
|
50
|
+
amount: bigint;
|
51
|
+
sendOpts: SendOpts;
|
52
|
+
}): Promise<BlockHeight>;
|
53
|
+
}
|
@@ -0,0 +1,137 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.LedgerConnection = void 0;
|
7
|
+
const baseConnection_1 = require("./baseConnection");
|
8
|
+
const ledger_idl_1 = __importDefault(require("../canisters/ledger.idl"));
|
9
|
+
const converter_1 = require("../utils/converter");
|
10
|
+
const constants_1 = require("../utils/constants");
|
11
|
+
// export const canisterIdPrincipal: Principal = Principal.fromText(LEDGER_CANISTER_ID);
|
12
|
+
class LedgerConnection extends baseConnection_1.BaseConnection {
|
13
|
+
constructor(identity, delegationIdentity, actor, agent, legerCanisterId) {
|
14
|
+
super(identity, delegationIdentity, legerCanisterId !== null && legerCanisterId !== void 0 ? legerCanisterId : constants_1.LEDGER_CANISTER_ID, ledger_idl_1.default, actor, agent);
|
15
|
+
this.identity = identity;
|
16
|
+
this.delegationIdentity = delegationIdentity;
|
17
|
+
this.actor = actor;
|
18
|
+
this.agent = agent;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* create connection
|
22
|
+
* @param identity
|
23
|
+
* @param delegationIdentity
|
24
|
+
* @param legerCanisterId
|
25
|
+
* @param actor
|
26
|
+
* @param agent
|
27
|
+
* @function createConnection
|
28
|
+
* @returns {LedgerConnection}
|
29
|
+
*/
|
30
|
+
static createConnection(identity, delegationIdentity, legerCanisterId, actor, agent) {
|
31
|
+
return new LedgerConnection(identity, delegationIdentity, actor, agent, legerCanisterId !== null && legerCanisterId !== void 0 ? legerCanisterId : constants_1.LEDGER_CANISTER_ID);
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* create Actor with DelegationIdentity
|
35
|
+
* @param delegationIdentity
|
36
|
+
* @param canisterId
|
37
|
+
* @param ledgerCanisterId
|
38
|
+
* @function {function name}
|
39
|
+
* @returns {type} {description}
|
40
|
+
*/
|
41
|
+
static async createActor(delegationIdentity, ledgerCanisterId) {
|
42
|
+
const actor = await (0, baseConnection_1._createActor)(ledger_idl_1.default, ledgerCanisterId !== null && ledgerCanisterId !== void 0 ? ledgerCanisterId : constants_1.LEDGER_CANISTER_ID, delegationIdentity);
|
43
|
+
return actor;
|
44
|
+
}
|
45
|
+
static async createConnectionWithII(identity, delegationIdentity, legerCanisterId) {
|
46
|
+
const actorResult = await LedgerConnection.createActor(delegationIdentity);
|
47
|
+
return LedgerConnection.createConnection(identity, delegationIdentity, legerCanisterId !== null && legerCanisterId !== void 0 ? legerCanisterId : constants_1.LEDGER_CANISTER_ID, actorResult.actor, actorResult.agent);
|
48
|
+
}
|
49
|
+
static async actorGetBalance(actor, account) {
|
50
|
+
const response = await (0, baseConnection_1.executeWithLogging)(() => actor.account_balance_dfx({ account }));
|
51
|
+
return response.e8s;
|
52
|
+
}
|
53
|
+
static async actorSend(actor, { to, amount, sendOpts, }) {
|
54
|
+
const response = await (0, baseConnection_1.executeWithLogging)(() => {
|
55
|
+
var _a, _b, _c;
|
56
|
+
const defaultFee = BigInt(10000);
|
57
|
+
const defaultMemo = BigInt(Math.floor(Math.random() * 10000));
|
58
|
+
const subAccount = (sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.from_subaccount) === undefined
|
59
|
+
? []
|
60
|
+
: Array.from([(0, converter_1.fromSubAccountId)(sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.from_subaccount)]);
|
61
|
+
const createAtTime = (sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.created_at_time) === undefined
|
62
|
+
? []
|
63
|
+
: Array.from([
|
64
|
+
{
|
65
|
+
timestamp_nanos: BigInt((_a = sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.created_at_time) === null || _a === void 0 ? void 0 : _a.getTime()),
|
66
|
+
},
|
67
|
+
]);
|
68
|
+
const sendArgs = {
|
69
|
+
to: to,
|
70
|
+
fee: {
|
71
|
+
e8s: (_b = sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.fee) !== null && _b !== void 0 ? _b : defaultFee,
|
72
|
+
},
|
73
|
+
amount: { e8s: amount },
|
74
|
+
memo: (_c = sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.memo) !== null && _c !== void 0 ? _c : defaultMemo,
|
75
|
+
from_subaccount: subAccount,
|
76
|
+
created_at_time: createAtTime,
|
77
|
+
};
|
78
|
+
return actor.send_dfx(sendArgs);
|
79
|
+
});
|
80
|
+
return response;
|
81
|
+
}
|
82
|
+
/**
|
83
|
+
* get NNS Actor, used internally
|
84
|
+
* @param canisterId
|
85
|
+
* @param ledgerCanisterId
|
86
|
+
* @function {function name}
|
87
|
+
* @returns {type} {description}
|
88
|
+
*/
|
89
|
+
async getLedgerActor(ledgerCanisterId) {
|
90
|
+
const actor = await this._getActor(ledgerCanisterId !== null && ledgerCanisterId !== void 0 ? ledgerCanisterId : constants_1.LEDGER_CANISTER_ID, ledger_idl_1.default);
|
91
|
+
return actor;
|
92
|
+
}
|
93
|
+
async getBalance(account) {
|
94
|
+
const actor = await this.getLedgerActor();
|
95
|
+
const response = await (0, baseConnection_1.executeWithLogging)(() => actor.account_balance_dfx({ account }));
|
96
|
+
return response.e8s;
|
97
|
+
}
|
98
|
+
async send({ to, amount, sendOpts, }) {
|
99
|
+
const actor = await this.getLedgerActor();
|
100
|
+
const response = await (0, baseConnection_1.executeWithLogging)(() => {
|
101
|
+
var _a, _b, _c;
|
102
|
+
const defaultFee = BigInt(10000);
|
103
|
+
const defaultMemo = BigInt(Math.floor(Math.random() * 10000));
|
104
|
+
const subAccount = (sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.from_subaccount) === undefined
|
105
|
+
? []
|
106
|
+
: Array.from([(0, converter_1.fromSubAccountId)(sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.from_subaccount)]);
|
107
|
+
const createAtTime = (sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.created_at_time) === undefined
|
108
|
+
? []
|
109
|
+
: Array.from([
|
110
|
+
{
|
111
|
+
timestamp_nanos: BigInt((_a = sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.created_at_time) === null || _a === void 0 ? void 0 : _a.getTime()),
|
112
|
+
},
|
113
|
+
]);
|
114
|
+
const sendArgs = {
|
115
|
+
to: to,
|
116
|
+
fee: {
|
117
|
+
e8s: (_b = sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.fee) !== null && _b !== void 0 ? _b : defaultFee,
|
118
|
+
},
|
119
|
+
amount: { e8s: amount },
|
120
|
+
memo: (_c = sendOpts === null || sendOpts === void 0 ? void 0 : sendOpts.memo) !== null && _c !== void 0 ? _c : defaultMemo,
|
121
|
+
from_subaccount: subAccount,
|
122
|
+
created_at_time: createAtTime,
|
123
|
+
};
|
124
|
+
return actor.send_dfx(sendArgs);
|
125
|
+
});
|
126
|
+
return response;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
exports.LedgerConnection = LedgerConnection;
|
130
|
+
// export const requestNNSDelegation = async (
|
131
|
+
// identity: SignIdentity,
|
132
|
+
// ): Promise<DelegationIdentity> => {
|
133
|
+
// const tenMinutesInMsec = 10 * 1000 * 60;
|
134
|
+
// const date = new Date(Date.now() + tenMinutesInMsec);
|
135
|
+
// return requestDelegation(identity, { canisterId, date });
|
136
|
+
// };
|
137
|
+
//# sourceMappingURL=ledgerConnection.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ledgerConnection.js","sourceRoot":"","sources":["../../../src/connections/ledgerConnection.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAoF;AACpF,yEAAiD;AAUjD,kDAAsD;AACtD,kDAAwD;AAGxD,wFAAwF;AAExF,MAAa,gBAAiB,SAAQ,+BAA8B;IAClE,YACS,QAAsB,EACtB,kBAAsC,EACtC,KAAqC,EACrC,KAAiB,EACxB,eAAwB;QAExB,KAAK,CACH,QAAQ,EACR,kBAAkB,EAClB,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,8BAAkB,EACrC,oBAAU,EACV,KAAK,EACL,KAAK,CACN,CAAC;QAbK,aAAQ,GAAR,QAAQ,CAAc;QACtB,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,UAAK,GAAL,KAAK,CAAgC;QACrC,UAAK,GAAL,KAAK,CAAY;IAW1B,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,gBAAgB,CACrB,QAAsB,EACtB,kBAAsC,EACtC,eAAwB,EACxB,KAAqC,EACrC,KAAiB;QAEjB,OAAO,IAAI,gBAAgB,CACzB,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,KAAK,EACL,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,8BAAkB,CACtC,CAAC;IACJ,CA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,EAAE;oBACH,GAAG,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,mCAAI,UAAU;iBACjC;gBACD,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;gBACvB,IAAI,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,WAAW;gBACnC,eAAe,EAAE,UAAU;gBAE3B,eAAe,EAAE,YAAY;aAC9B,CAAC;YAEF,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlMD,4CAkMC;AAED,8CAA8C;AAC9C,4BAA4B;AAC5B,sCAAsC;AACtC,6CAA6C;AAC7C,0DAA0D;AAC1D,8DAA8D;AAC9D,KAAK"}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { ActorSubclass, HttpAgent, SignIdentity } from '@dfinity/agent';
|
2
|
+
import { DelegationIdentity } from '@dfinity/identity';
|
3
|
+
import { BaseConnection } from './baseConnection';
|
4
|
+
import NNS_SERVICE, { AccountDetails } from '../canisters/nns-dapp';
|
5
|
+
import { CreateActorResult } from '../types';
|
6
|
+
export declare class NNSConnection extends BaseConnection<NNS_SERVICE> {
|
7
|
+
identity: SignIdentity;
|
8
|
+
delegationIdentity: DelegationIdentity;
|
9
|
+
actor?: ActorSubclass<NNS_SERVICE> | undefined;
|
10
|
+
agent?: HttpAgent | undefined;
|
11
|
+
get accountDetails(): AccountDetails | undefined;
|
12
|
+
private _accountDetails?;
|
13
|
+
protected constructor(identity: SignIdentity, delegationIdentity: DelegationIdentity, actor?: ActorSubclass<NNS_SERVICE> | undefined, agent?: HttpAgent | undefined, nnsCanisterId?: string);
|
14
|
+
/**
|
15
|
+
* create connection
|
16
|
+
* @param identity
|
17
|
+
* @param delegationIdentity
|
18
|
+
* @param actor
|
19
|
+
* @param agent
|
20
|
+
* @function createConnection
|
21
|
+
* @returns {NNSConnection}
|
22
|
+
*/
|
23
|
+
static createConnection(identity: SignIdentity, delegationIdentity: DelegationIdentity, actor?: ActorSubclass<NNS_SERVICE>, agent?: HttpAgent): NNSConnection;
|
24
|
+
/**
|
25
|
+
* create Actor with DelegationIdentity
|
26
|
+
* @param delegationIdentity
|
27
|
+
* @param nnsCanisterId
|
28
|
+
* @function {function name}
|
29
|
+
* @returns {type} {description}
|
30
|
+
*/
|
31
|
+
static createActor(delegationIdentity: DelegationIdentity, nnsCanisterId?: string): Promise<CreateActorResult<NNS_SERVICE>>;
|
32
|
+
/**
|
33
|
+
* get NNS Actor, used internally
|
34
|
+
* @param nnsCanisterId
|
35
|
+
* @function {function name}
|
36
|
+
* @returns {type} {description}
|
37
|
+
*/
|
38
|
+
getNNSActor(nnsCanisterId?: string): Promise<ActorSubclass<NNS_SERVICE>>;
|
39
|
+
/**
|
40
|
+
* get NNS Actor, used internally
|
41
|
+
* @param nnsCanisterId
|
42
|
+
* @function {function name}
|
43
|
+
* @returns {type} {description}
|
44
|
+
*/
|
45
|
+
getNNSActorCert(nnsCanisterId?: string): Promise<ActorSubclass<NNS_SERVICE>>;
|
46
|
+
/**
|
47
|
+
* when NNSConnection is created, we can get account created to NNS.
|
48
|
+
* Even we can just calculate the login principal to NNS DApp, however,
|
49
|
+
* The NNS DApp stores and create account, thus, a new Identity login will get NO ACCOUNT created by default.
|
50
|
+
* We need to manually create account using `add_account` when no account found.
|
51
|
+
*
|
52
|
+
* @param cert
|
53
|
+
* @function {function name}
|
54
|
+
* @returns {type} {description}
|
55
|
+
*/
|
56
|
+
getAccount(cert?: boolean): Promise<AccountDetails | undefined>;
|
57
|
+
/**
|
58
|
+
* create account when new identity logined to NNS
|
59
|
+
* @function {function name}
|
60
|
+
* @returns {type} {description}
|
61
|
+
*/
|
62
|
+
addAccount(): Promise<string>;
|
63
|
+
}
|