@astrox/connection 0.0.16 → 0.0.24

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 (123) hide show
  1. package/lib/tsconfig.tsbuildinfo +1 -2838
  2. package/package.json +2 -2
  3. package/lib/cjs/canisters/internet_identity_idl.d.ts +0 -7
  4. package/lib/cjs/canisters/internet_identity_idl.js +0 -101
  5. package/lib/cjs/canisters/internet_identity_idl.js.map +0 -1
  6. package/lib/cjs/canisters/ledger.idl.d.ts +0 -7
  7. package/lib/cjs/canisters/ledger.idl.js +0 -81
  8. package/lib/cjs/canisters/ledger.idl.js.map +0 -1
  9. package/lib/cjs/canisters/me.idl.d.ts +0 -7
  10. package/lib/cjs/canisters/me.idl.js +0 -125
  11. package/lib/cjs/canisters/me.idl.js.map +0 -1
  12. package/lib/cjs/canisters/nns-dapp-cert.idl.d.ts +0 -7
  13. package/lib/cjs/canisters/nns-dapp-cert.idl.js +0 -86
  14. package/lib/cjs/canisters/nns-dapp-cert.idl.js.map +0 -1
  15. package/lib/cjs/canisters/nns-dapp.idl.d.ts +0 -7
  16. package/lib/cjs/canisters/nns-dapp.idl.js +0 -184
  17. package/lib/cjs/canisters/nns-dapp.idl.js.map +0 -1
  18. package/lib/cjs/connections/baseConnection.d.ts +0 -23
  19. package/lib/cjs/connections/baseConnection.js +0 -87
  20. package/lib/cjs/connections/baseConnection.js.map +0 -1
  21. package/lib/cjs/connections/ledgerConnection.d.ts +0 -53
  22. package/lib/cjs/connections/ledgerConnection.js +0 -137
  23. package/lib/cjs/connections/ledgerConnection.js.map +0 -1
  24. package/lib/cjs/connections/nnsConnection.d.ts +0 -63
  25. package/lib/cjs/connections/nnsConnection.js +0 -166
  26. package/lib/cjs/connections/nnsConnection.js.map +0 -1
  27. package/lib/cjs/ic/icAuthClient.d.ts +0 -31
  28. package/lib/cjs/ic/icAuthClient.js +0 -233
  29. package/lib/cjs/ic/icAuthClient.js.map +0 -1
  30. package/lib/cjs/ic/icConnect.d.ts +0 -34
  31. package/lib/cjs/ic/icConnect.js +0 -184
  32. package/lib/cjs/ic/icConnect.js.map +0 -1
  33. package/lib/cjs/ic/icStorage.d.ts +0 -16
  34. package/lib/cjs/ic/icStorage.js +0 -49
  35. package/lib/cjs/ic/icStorage.js.map +0 -1
  36. package/lib/cjs/ic/icWindow.d.ts +0 -7
  37. package/lib/cjs/ic/icWindow.js +0 -20
  38. package/lib/cjs/ic/icWindow.js.map +0 -1
  39. package/lib/cjs/ic/index.d.ts +0 -2
  40. package/lib/cjs/ic/index.js +0 -7
  41. package/lib/cjs/ic/index.js.map +0 -1
  42. package/lib/cjs/ic/types.d.ts +0 -129
  43. package/lib/cjs/ic/types.js +0 -17
  44. package/lib/cjs/ic/types.js.map +0 -1
  45. package/lib/cjs/index.d.ts +0 -5
  46. package/lib/cjs/index.js +0 -18
  47. package/lib/cjs/index.js.map +0 -1
  48. package/lib/cjs/types/index.d.ts +0 -166
  49. package/lib/cjs/types/index.js +0 -17
  50. package/lib/cjs/types/index.js.map +0 -1
  51. package/lib/cjs/utils/common/types.d.ts +0 -15
  52. package/lib/cjs/utils/common/types.js +0 -12
  53. package/lib/cjs/utils/common/types.js.map +0 -1
  54. package/lib/cjs/utils/constants.d.ts +0 -6
  55. package/lib/cjs/utils/constants.js +0 -13
  56. package/lib/cjs/utils/constants.js.map +0 -1
  57. package/lib/cjs/utils/converter.d.ts +0 -32
  58. package/lib/cjs/utils/converter.js +0 -130
  59. package/lib/cjs/utils/converter.js.map +0 -1
  60. package/lib/cjs/utils/index.d.ts +0 -3
  61. package/lib/cjs/utils/index.js +0 -16
  62. package/lib/cjs/utils/index.js.map +0 -1
  63. package/lib/esm/canisters/internet_identity_idl.d.ts +0 -7
  64. package/lib/esm/canisters/internet_identity_idl.js +0 -98
  65. package/lib/esm/canisters/internet_identity_idl.js.map +0 -1
  66. package/lib/esm/canisters/ledger.idl.d.ts +0 -7
  67. package/lib/esm/canisters/ledger.idl.js +0 -78
  68. package/lib/esm/canisters/ledger.idl.js.map +0 -1
  69. package/lib/esm/canisters/me.idl.d.ts +0 -7
  70. package/lib/esm/canisters/me.idl.js +0 -122
  71. package/lib/esm/canisters/me.idl.js.map +0 -1
  72. package/lib/esm/canisters/nns-dapp-cert.idl.d.ts +0 -7
  73. package/lib/esm/canisters/nns-dapp-cert.idl.js +0 -83
  74. package/lib/esm/canisters/nns-dapp-cert.idl.js.map +0 -1
  75. package/lib/esm/canisters/nns-dapp.idl.d.ts +0 -7
  76. package/lib/esm/canisters/nns-dapp.idl.js +0 -181
  77. package/lib/esm/canisters/nns-dapp.idl.js.map +0 -1
  78. package/lib/esm/connections/baseConnection.d.ts +0 -23
  79. package/lib/esm/connections/baseConnection.js +0 -80
  80. package/lib/esm/connections/baseConnection.js.map +0 -1
  81. package/lib/esm/connections/ledgerConnection.d.ts +0 -53
  82. package/lib/esm/connections/ledgerConnection.js +0 -130
  83. package/lib/esm/connections/ledgerConnection.js.map +0 -1
  84. package/lib/esm/connections/nnsConnection.d.ts +0 -63
  85. package/lib/esm/connections/nnsConnection.js +0 -159
  86. package/lib/esm/connections/nnsConnection.js.map +0 -1
  87. package/lib/esm/ic/icAuthClient.d.ts +0 -31
  88. package/lib/esm/ic/icAuthClient.js +0 -229
  89. package/lib/esm/ic/icAuthClient.js.map +0 -1
  90. package/lib/esm/ic/icConnect.d.ts +0 -34
  91. package/lib/esm/ic/icConnect.js +0 -180
  92. package/lib/esm/ic/icConnect.js.map +0 -1
  93. package/lib/esm/ic/icStorage.d.ts +0 -16
  94. package/lib/esm/ic/icStorage.js +0 -44
  95. package/lib/esm/ic/icStorage.js.map +0 -1
  96. package/lib/esm/ic/icWindow.d.ts +0 -7
  97. package/lib/esm/ic/icWindow.js +0 -16
  98. package/lib/esm/ic/icWindow.js.map +0 -1
  99. package/lib/esm/ic/index.d.ts +0 -2
  100. package/lib/esm/ic/index.js +0 -3
  101. package/lib/esm/ic/index.js.map +0 -1
  102. package/lib/esm/ic/types.d.ts +0 -129
  103. package/lib/esm/ic/types.js +0 -14
  104. package/lib/esm/ic/types.js.map +0 -1
  105. package/lib/esm/index.d.ts +0 -5
  106. package/lib/esm/index.js +0 -6
  107. package/lib/esm/index.js.map +0 -1
  108. package/lib/esm/types/index.d.ts +0 -166
  109. package/lib/esm/types/index.js +0 -14
  110. package/lib/esm/types/index.js.map +0 -1
  111. package/lib/esm/utils/common/types.d.ts +0 -15
  112. package/lib/esm/utils/common/types.js +0 -9
  113. package/lib/esm/utils/common/types.js.map +0 -1
  114. package/lib/esm/utils/constants.d.ts +0 -6
  115. package/lib/esm/utils/constants.js +0 -10
  116. package/lib/esm/utils/constants.js.map +0 -1
  117. package/lib/esm/utils/converter.d.ts +0 -32
  118. package/lib/esm/utils/converter.js +0 -124
  119. package/lib/esm/utils/converter.js.map +0 -1
  120. package/lib/esm/utils/index.d.ts +0 -3
  121. package/lib/esm/utils/index.js +0 -4
  122. package/lib/esm/utils/index.js.map +0 -1
  123. package/lib/tsconfig-cjs.tsbuildinfo +0 -2839
@@ -1,184 +0,0 @@
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
- exports.init = ({ IDL }) => {
182
- return [];
183
- };
184
- //# sourceMappingURL=nns-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AAW,CAAC,EAC5B,CAAC,0BAA0B,CAAC,EAC5B,CAAC,OAAO,CAAC,CACV;QACD,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAC3C,gBAAgB,EAAE,GAAG,CAAC,IAAI,CACxB,CAAC,sBAAsB,CAAC,EACxB,CAAC,uBAAuB,CAAC,EACzB,CAAC,OAAO,CAAC,CACV;QACD,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAChE,wBAAwB,EAAE,GAAG,CAAC,IAAI,CAChC,CAAC,6BAA6B,CAAC,EAC/B,CAAC,8BAA8B,CAAC,EAChC,EAAE,CACH;QACD,kBAAkB,EAAE,GAAG,CAAC,IAAI,CAC1B,CAAC,uBAAuB,CAAC,EACzB,CAAC,wBAAwB,CAAC,EAC1B,EAAE,CACH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AACW,QAAA,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAC9B,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
@@ -1,23 +0,0 @@
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>;
@@ -1,87 +0,0 @@
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
- exports.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
- async function _createActor(interfaceFactory, canisterId, identity) {
19
- const agent = new agent_1.HttpAgent({ identity });
20
- // Only fetch the root key when we're not in prod
21
- if (process.env.II_ENV === 'development') {
22
- await agent.fetchRootKey();
23
- }
24
- const actor = agent_1.Actor.createActor(interfaceFactory, {
25
- agent,
26
- canisterId,
27
- });
28
- return { actor, agent };
29
- }
30
- exports._createActor = _createActor;
31
- class BaseConnection {
32
- constructor(identity, delegationIdentity, canisterId, interfaceFactory, actor, agent) {
33
- this.identity = identity;
34
- this.delegationIdentity = delegationIdentity;
35
- this.canisterId = canisterId;
36
- this.interfaceFactory = interfaceFactory;
37
- this.actor = actor;
38
- this.agent = agent;
39
- }
40
- async getActor() {
41
- throw new Error('Method not implemented.');
42
- }
43
- async _getActor(canisterId, interfaceFactory, date) {
44
- var _a, _b;
45
- for (const { delegation } of this.delegationIdentity.getDelegation().delegations) {
46
- // prettier-ignore
47
- if (+new Date(Number(delegation.expiration / BigInt(1000000))) <= +Date.now()) {
48
- this.actor = undefined;
49
- break;
50
- }
51
- }
52
- if (this.actor === undefined) {
53
- // Create our actor with a DelegationIdentity to avoid re-prompting auth
54
- this.delegationIdentity = await exports.requestDelegation(this.identity, {
55
- canisterId: (_a = this.canisterId) !== null && _a !== void 0 ? _a : canisterId,
56
- date: date !== null && date !== void 0 ? date : undefined,
57
- });
58
- this.actor = (await _createActor(interfaceFactory, (_b = this.canisterId) !== null && _b !== void 0 ? _b : canisterId, this.delegationIdentity)).actor;
59
- }
60
- return this.actor;
61
- }
62
- }
63
- exports.BaseConnection = BaseConnection;
64
- async function handleDelegation(message, key) {
65
- const delegations = message.delegations.map(signedDelegation => {
66
- return {
67
- delegation: new identity_1.Delegation(signedDelegation.delegation.pubkey, signedDelegation.delegation.expiration, signedDelegation.delegation.targets),
68
- signature: signedDelegation.signature.buffer,
69
- };
70
- });
71
- const delegationChain = identity_1.DelegationChain.fromDelegations(delegations, message.userPublicKey.buffer);
72
- return {
73
- delegationChain,
74
- delegationIdentity: identity_1.DelegationIdentity.fromDelegation(key, delegationChain),
75
- };
76
- }
77
- exports.handleDelegation = handleDelegation;
78
- exports.executeWithLogging = async (func) => {
79
- try {
80
- return await func();
81
- }
82
- catch (e) {
83
- console.log(e);
84
- throw e;
85
- }
86
- };
87
- //# sourceMappingURL=baseConnection.js.map
@@ -1 +0,0 @@
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;AAEY,QAAA,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;AAC9D,CAAC,CAAC;AAEK,KAAK,UAAU,YAAY,CAChC,gBAAkC,EAClC,UAAkB,EAClB,QAAuB;IAEvB,MAAM,KAAK,GAAG,IAAI,iBAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1C,iDAAiD;IACjD,IAAI,OAAO,CAAC,GAAG,CAAC,MA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, { 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
- }
@@ -1,137 +0,0 @@
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 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 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 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([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 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 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([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
@@ -1 +0,0 @@
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,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CACtB,kBAAsC,EACtC,gBAAyB;QAEzB,MAAM,KAAK,GAAG,MAAM,6BAAY,CAC9B,oBAAU,EACV,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,8BAAkB,EACtC,kBAAkB,CACnB,CAAC;QACF,OAAO,KAAK,CAAC;IACf,C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AAC,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"}
@@ -1,63 +0,0 @@
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
- }