@portal-hq/web 3.2.3 → 3.3.0

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.
@@ -9,26 +9,146 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RequestMethod = void 0;
12
13
  const errors_1 = require("./errors");
14
+ var RequestMethod;
15
+ (function (RequestMethod) {
16
+ RequestMethod["eth_accounts"] = "eth_accounts";
17
+ RequestMethod["eth_blockNumber"] = "eth_blockNumber";
18
+ RequestMethod["eth_call"] = "eth_call";
19
+ RequestMethod["eth_chainId"] = "eth_chainId";
20
+ RequestMethod["eth_coinbase"] = "eth_coinbase";
21
+ RequestMethod["eth_compileSolidity"] = "eth_compileSolidity";
22
+ RequestMethod["eth_compileLLL"] = "eth_compileLLL";
23
+ RequestMethod["eth_compileSerpent"] = "eth_compileSerpent";
24
+ RequestMethod["eth_estimateGas"] = "eth_estimateGas";
25
+ RequestMethod["eth_gasPrice"] = "eth_gasPrice";
26
+ RequestMethod["eth_getBalance"] = "eth_getBalance";
27
+ RequestMethod["eth_getBlockByHash"] = "eth_getBlockByHash";
28
+ RequestMethod["eth_getBlockByNumber"] = "eth_getBlockByNumber";
29
+ RequestMethod["eth_getBlockTransactionCountByHash"] = "eth_getBlockTransactionCountByHash";
30
+ RequestMethod["eth_getBlockTransactionCountByNumber"] = "eth_getBlockTransactionCountByNumber";
31
+ RequestMethod["eth_getCode"] = "eth_getCode";
32
+ RequestMethod["eth_getCompilers"] = "eth_getCompilers";
33
+ RequestMethod["eth_getFilterChange"] = "eth_getFilterChange";
34
+ RequestMethod["eth_getFilterLogs"] = "eth_getFilterLogs";
35
+ RequestMethod["eth_getLogs"] = "eth_getLogs";
36
+ RequestMethod["eth_getStorageAt"] = "eth_getStorageAt";
37
+ RequestMethod["eth_getTransactionByHash"] = "eth_getTransactionByHash";
38
+ RequestMethod["eth_getTransactionByBlockHashAndIndex"] = "eth_getTransactionByBlockHashAndIndex";
39
+ RequestMethod["eth_getTransactionByBlockNumberAndIndex"] = "eth_getTransactionByBlockNumberAndIndex";
40
+ RequestMethod["eth_getTransactionCount"] = "eth_getTransactionCount";
41
+ RequestMethod["eth_getTransactionReceipt"] = "eth_getTransactionReceipt";
42
+ RequestMethod["eth_getUncleByBlockHashAndIndex"] = "eth_getUncleByBlockHashAndIndex";
43
+ RequestMethod["eth_getUncleByBlockNumberAndIndex"] = "eth_getUncleByBlockNumberAndIndex";
44
+ RequestMethod["eth_getUncleCountByBlockHash"] = "eth_getUncleCountByBlockHash";
45
+ RequestMethod["eth_getUncleCountByBlockNumber"] = "eth_getUncleCountByBlockNumber";
46
+ RequestMethod["eth_getWork"] = "eth_getWork";
47
+ RequestMethod["eth_hashrate"] = "eth_hashrate";
48
+ RequestMethod["eth_mining"] = "eth_mining";
49
+ RequestMethod["eth_newBlockFilter"] = "eth_newBlockFilter";
50
+ RequestMethod["eth_newFilter"] = "eth_newFilter";
51
+ RequestMethod["eth_newPendingTransactionFilter"] = "eth_newPendingTransactionFilter";
52
+ RequestMethod["personal_sign"] = "personal_sign";
53
+ RequestMethod["eth_protocolVersion"] = "eth_protocolVersion";
54
+ RequestMethod["eth_requestAccounts"] = "eth_requestAccounts";
55
+ RequestMethod["eth_sendRawTransaction"] = "eth_sendRawTransaction";
56
+ RequestMethod["eth_sendTransaction"] = "eth_sendTransaction";
57
+ RequestMethod["eth_sign"] = "eth_sign";
58
+ RequestMethod["eth_signTransaction"] = "eth_signTransaction";
59
+ RequestMethod["eth_signTypedData"] = "eth_signTypedData";
60
+ RequestMethod["eth_signTypedData_v3"] = "eth_signTypedData_v3";
61
+ RequestMethod["eth_signTypedData_v4"] = "eth_signTypedData_v4";
62
+ RequestMethod["eth_submitHashrate"] = "eth_submitHashrate";
63
+ RequestMethod["eth_submitWork"] = "eth_submitWork";
64
+ RequestMethod["eth_syncing"] = "eth_syncing";
65
+ RequestMethod["eth_uninstallFilter"] = "eth_uninstallFilter";
66
+ // Net Methods
67
+ RequestMethod["net_listening"] = "net_listening";
68
+ RequestMethod["net_peerCount"] = "net_peerCount";
69
+ RequestMethod["net_version"] = "net_version";
70
+ // Web3 Methods
71
+ RequestMethod["web3_clientVersion"] = "web3_clientVersion";
72
+ RequestMethod["web3_sha3"] = "web3_sha3";
73
+ // Solana RPC Methods
74
+ RequestMethod["sol_getAccountInfo"] = "getAccountInfo";
75
+ RequestMethod["sol_getBalance"] = "getBalance";
76
+ RequestMethod["sol_getBlock"] = "getBlock";
77
+ RequestMethod["sol_getBlockCommitment"] = "getBlockCommitment";
78
+ RequestMethod["sol_getBlockHeight"] = "getBlockHeight";
79
+ RequestMethod["sol_getBlockProduction"] = "getBlockProduction";
80
+ RequestMethod["sol_getBlockTime"] = "getBlockTime";
81
+ RequestMethod["sol_getBlocks"] = "getBlocks";
82
+ RequestMethod["sol_getBlocksWithLimit"] = "getBlocksWithLimit";
83
+ RequestMethod["sol_getClusterNodes"] = "getClusterNodes";
84
+ RequestMethod["sol_getEpochInfo"] = "getEpochInfo";
85
+ RequestMethod["sol_getEpochSchedule"] = "getEpochSchedule";
86
+ RequestMethod["sol_getFeeForMessage"] = "getFeeForMessage";
87
+ RequestMethod["sol_getFirstAvailableBlock"] = "getFirstAvailableBlock";
88
+ RequestMethod["sol_getGenesisHash"] = "getGenesisHash";
89
+ RequestMethod["sol_getHealth"] = "getHealth";
90
+ RequestMethod["sol_getHighestSnapshotSlot"] = "getHighestSnapshotSlot";
91
+ RequestMethod["sol_getIdentity"] = "getIdentity";
92
+ RequestMethod["sol_getInflationGovernor"] = "getInflationGovernor";
93
+ RequestMethod["sol_getInflationRate"] = "getInflationRate";
94
+ RequestMethod["sol_getInflationReward"] = "getInflationReward";
95
+ RequestMethod["sol_getLargestAccounts"] = "getLargestAccounts";
96
+ RequestMethod["sol_getLatestBlockhash"] = "getLatestBlockhash";
97
+ RequestMethod["sol_getLeaderSchedule"] = "getLeaderSchedule";
98
+ RequestMethod["sol_getMaxRetransmitSlot"] = "getMaxRetransmitSlot";
99
+ RequestMethod["sol_getMaxShredInsertSlot"] = "getMaxShredInsertSlot";
100
+ RequestMethod["sol_getMinimumBalanceForRentExemption"] = "getMinimumBalanceForRentExemption";
101
+ RequestMethod["sol_getMultipleAccounts"] = "getMultipleAccounts";
102
+ RequestMethod["sol_getProgramAccounts"] = "getProgramAccounts";
103
+ RequestMethod["sol_getRecentPerformanceSamples"] = "getRecentPerformanceSamples";
104
+ RequestMethod["sol_getRecentPrioritizationFees"] = "getRecentPrioritizationFees";
105
+ RequestMethod["sol_getSignatureStatuses"] = "getSignatureStatuses";
106
+ RequestMethod["sol_getSignaturesForAddress"] = "getSignaturesForAddress";
107
+ RequestMethod["sol_getSlot"] = "getSlot";
108
+ RequestMethod["sol_getSlotLeader"] = "getSlotLeader";
109
+ RequestMethod["sol_getSlotLeaders"] = "getSlotLeaders";
110
+ RequestMethod["sol_getStakeActivation"] = "getStakeActivation";
111
+ RequestMethod["sol_getStakeMinimumDelegation"] = "getStakeMinimumDelegation";
112
+ RequestMethod["sol_getSupply"] = "getSupply";
113
+ RequestMethod["sol_getTokenAccountBalance"] = "getTokenAccountBalance";
114
+ RequestMethod["sol_getTokenAccountsByDelegate"] = "getTokenAccountsByDelegate";
115
+ RequestMethod["sol_getTokenAccountsByOwner"] = "getTokenAccountsByOwner";
116
+ RequestMethod["sol_getTokenLargestAccounts"] = "getTokenLargestAccounts";
117
+ RequestMethod["sol_getTokenSupply"] = "getTokenSupply";
118
+ RequestMethod["sol_getTransaction"] = "getTransaction";
119
+ RequestMethod["sol_getTransactionCount"] = "getTransactionCount";
120
+ RequestMethod["sol_getVersion"] = "getVersion";
121
+ RequestMethod["sol_getVoteAccounts"] = "getVoteAccounts";
122
+ RequestMethod["sol_isBlockhashValid"] = "isBlockhashValid";
123
+ RequestMethod["sol_minimumLedgerSlot"] = "minimumLedgerSlot";
124
+ RequestMethod["sol_requestAirdrop"] = "requestAirdrop";
125
+ RequestMethod["sol_sendTransaction"] = "sendTransaction";
126
+ RequestMethod["sol_simulateTransaction"] = "simulateTransaction";
127
+ // Solana Wallet Methods
128
+ RequestMethod["sol_signAndConfirmTransaction"] = "sol_signAndConfirmTransaction";
129
+ RequestMethod["sol_signAndSendTransaction"] = "sol_signAndSendTransaction";
130
+ RequestMethod["sol_signMessage"] = "sol_signMessage";
131
+ RequestMethod["sol_signTransaction"] = "sol_signTransaction";
132
+ })(RequestMethod = exports.RequestMethod || (exports.RequestMethod = {}));
13
133
  const passiveSignerMethods = [
14
- 'eth_accounts',
15
- 'eth_chainId',
16
- 'eth_requestAccounts',
134
+ RequestMethod.eth_accounts,
135
+ RequestMethod.eth_chainId,
136
+ RequestMethod.eth_requestAccounts,
17
137
  ];
18
138
  const signerMethods = [
19
- 'eth_accounts',
20
- 'eth_chainId',
21
- 'eth_requestAccounts',
22
- 'eth_sendTransaction',
23
- 'eth_sign',
24
- 'eth_signTransaction',
25
- 'eth_signTypedData_v3',
26
- 'eth_signTypedData_v4',
27
- 'personal_sign',
28
- 'sol_signAndConfirmTransaction',
29
- 'sol_signAndSendTransaction',
30
- 'sol_signMessage',
31
- 'sol_signTransaction',
139
+ RequestMethod.eth_accounts,
140
+ RequestMethod.eth_chainId,
141
+ RequestMethod.eth_requestAccounts,
142
+ RequestMethod.eth_sendTransaction,
143
+ RequestMethod.eth_sign,
144
+ RequestMethod.eth_signTransaction,
145
+ RequestMethod.eth_signTypedData_v3,
146
+ RequestMethod.eth_signTypedData_v4,
147
+ RequestMethod.personal_sign,
148
+ RequestMethod.sol_signAndConfirmTransaction,
149
+ RequestMethod.sol_signAndSendTransaction,
150
+ RequestMethod.sol_signMessage,
151
+ RequestMethod.sol_signTransaction,
32
152
  ];
33
153
  class Provider {
34
154
  constructor({ portal }) {
@@ -51,14 +171,14 @@ class Provider {
51
171
  this.buildParams = (method, txParams) => {
52
172
  let params = txParams;
53
173
  switch (method) {
54
- case 'eth_sign':
55
- case 'personal_sign':
56
- case 'eth_signTypedData_v3':
57
- case 'eth_signTypedData_v4':
58
- case 'sol_signAndConfirmTransaction':
59
- case 'sol_signAndSendTransaction':
60
- case 'sol_signMessage':
61
- case 'sol_signTransaction':
174
+ case RequestMethod.eth_sign:
175
+ case RequestMethod.personal_sign:
176
+ case RequestMethod.eth_signTypedData_v3:
177
+ case RequestMethod.eth_signTypedData_v4:
178
+ case RequestMethod.sol_signAndConfirmTransaction:
179
+ case RequestMethod.sol_signAndSendTransaction:
180
+ case RequestMethod.sol_signMessage:
181
+ case RequestMethod.sol_signTransaction:
62
182
  if (!Array.isArray(txParams)) {
63
183
  params = [txParams];
64
184
  }
@@ -280,22 +400,22 @@ class Provider {
280
400
  return;
281
401
  }
282
402
  switch (method) {
283
- case 'eth_chainId': {
403
+ case RequestMethod.eth_chainId: {
284
404
  this.enforceEip155ChainId(chainId);
285
405
  const chainReferenceId = parseInt(chainId.split(':')[1]);
286
406
  return `0x${chainReferenceId.toString(16)}`;
287
407
  }
288
- case 'eth_accounts':
289
- case 'eth_requestAccounts': {
408
+ case RequestMethod.eth_accounts:
409
+ case RequestMethod.eth_requestAccounts: {
290
410
  this.enforceEip155ChainId(chainId);
291
411
  return [this.portal.address];
292
412
  }
293
- case 'eth_sendTransaction':
294
- case 'eth_sign':
295
- case 'eth_signTransaction':
296
- case 'eth_signTypedData_v3':
297
- case 'eth_signTypedData_v4':
298
- case 'personal_sign': {
413
+ case RequestMethod.eth_sendTransaction:
414
+ case RequestMethod.eth_sign:
415
+ case RequestMethod.eth_signTransaction:
416
+ case RequestMethod.eth_signTypedData_v3:
417
+ case RequestMethod.eth_signTypedData_v4:
418
+ case RequestMethod.personal_sign: {
299
419
  this.enforceEip155ChainId(chainId);
300
420
  const result = yield this.portal.mpc.sign({
301
421
  chainId: chainId,
@@ -305,10 +425,10 @@ class Provider {
305
425
  });
306
426
  return result;
307
427
  }
308
- case 'sol_signAndConfirmTransaction':
309
- case 'sol_signAndSendTransaction':
310
- case 'sol_signMessage':
311
- case 'sol_signTransaction': {
428
+ case RequestMethod.sol_signAndConfirmTransaction:
429
+ case RequestMethod.sol_signAndSendTransaction:
430
+ case RequestMethod.sol_signMessage:
431
+ case RequestMethod.sol_signTransaction: {
312
432
  this.enforceSolanaChainId(chainId);
313
433
  const result = yield this.portal.mpc.sign({
314
434
  chainId: chainId,