@le-space/browser 0.1.37 → 0.1.38
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/index.d.ts +17 -1
- package/index.js +49 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -4,6 +4,18 @@ interface BrowserPackagePlan {
|
|
|
4
4
|
modules: string[];
|
|
5
5
|
}
|
|
6
6
|
declare const BROWSER_PACKAGE_PLAN: BrowserPackagePlan;
|
|
7
|
+
interface EthereumProviderLike {
|
|
8
|
+
request<T = unknown>(args: {
|
|
9
|
+
method: string;
|
|
10
|
+
params?: unknown[] | Record<string, unknown>;
|
|
11
|
+
}): Promise<T>;
|
|
12
|
+
}
|
|
13
|
+
interface EthereumTransactionRequest {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
data?: `0x${string}`;
|
|
17
|
+
value?: bigint;
|
|
18
|
+
}
|
|
7
19
|
type MessageStatus = 'processed' | 'pending' | 'rejected' | 'unknown';
|
|
8
20
|
type ReferenceStatus = MessageStatus | 'missing';
|
|
9
21
|
type AlephSenderChain = 'ETH';
|
|
@@ -376,6 +388,10 @@ interface CreateAlephBrowserClientOptions {
|
|
|
376
388
|
}
|
|
377
389
|
declare function createAlephBrowserClient(options?: CreateAlephBrowserClientOptions): AlephBrowserClient;
|
|
378
390
|
|
|
391
|
+
declare function ethCall(to: string, data: `0x${string}`, provider: EthereumProviderLike | null | undefined): Promise<string>;
|
|
392
|
+
declare function sendTransaction(tx: EthereumTransactionRequest, provider: EthereumProviderLike | null | undefined): Promise<string>;
|
|
393
|
+
declare function personalSign(address: string, message: string, provider: EthereumProviderLike | null | undefined): Promise<string>;
|
|
394
|
+
|
|
379
395
|
declare const ITEM_HASH_RE: RegExp;
|
|
380
396
|
declare const DEFAULT_ROOTFS_MANIFEST_URL = "./rootfs-manifest.json";
|
|
381
397
|
declare const DEFAULT_IPFS_GATEWAY_BASE_URL = "https://ipfs.aleph.cloud/ipfs/";
|
|
@@ -391,4 +407,4 @@ declare const DEFAULT_ALEPH_AGGREGATE_ADDRESS = "0xFba561a84A537fCaa567bb7A2257e
|
|
|
391
407
|
declare function parseInstancePricing(payload: unknown): InstancePricing;
|
|
392
408
|
declare function fetchInstancePricing(apiHost?: string, aggregateAddress?: string): Promise<PricingState>;
|
|
393
409
|
|
|
394
|
-
export { type AlephBroadcastMessage, type AlephBroadcastResponse, type AlephBrowserClient, type AlephMessageEnvelope, type AlephMessageType, type AlephSenderChain, type AllocationNotifyResult, BROWSER_PACKAGE_PLAN, type BalanceResponse, type BroadcastResult, type BrowserExtractionPhase, type BrowserPackagePlan, type ComputeUnit, type CreateAlephBrowserClientOptions, type Crn, type CrnExecutionLookupResult, type CrnListResponse, type CrnLocation, type CrnUsage, DEFAULT_2N6_API_HOST, DEFAULT_ALEPH_AGGREGATE_ADDRESS, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_SCHEDULER_API_HOST, DEFAULT_CRN_LIST_URL, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_ROOTFS_MANIFEST_URL, type DeploymentInspectionResult, type GatewayProbeStatus, ITEM_HASH_RE, type InstanceAllocation, type InstanceAllocationNode, type InstanceAllocationPeriod, type InstanceExecution, type InstanceExecutionNetworking, type InstanceExecutionStatus, type InstanceMessage, type InstancePortMapping, type InstancePricing, type LoadRootfsManifestOptions, type MessageReference, type MessageStatus, type PaymentMode, type Price, type PricingState, type ReferenceStatus, type RelaySetupRequest, type RelaySetupResult, type RootfsManifest, type RootfsManifestState, type RootfsRequiredPortForward, type RootfsResolution, type Tier, broadcastAlephMessage, broadcastInstanceMessage, configureOrbitdbRelaySetup, createAlephBrowserClient, fetch2n6WebAccessUrl, fetchBalance, fetchCrnExecutionMap, fetchCrns, fetchInstancePricing, fetchInstances, fetchMessageEnvelope, fetchSchedulerAllocation, fetchWithTimeout, inspectDeploymentResult, loadRootfsManifest, normalizeExecution, normalizeMessageStatus, notifyCrnAllocation, parseInstancePricing, resolveRootfsReference, validateRootfsManifest, verifyRootfsExists, waitForDeploymentResult };
|
|
410
|
+
export { type AlephBroadcastMessage, type AlephBroadcastResponse, type AlephBrowserClient, type AlephMessageEnvelope, type AlephMessageType, type AlephSenderChain, type AllocationNotifyResult, BROWSER_PACKAGE_PLAN, type BalanceResponse, type BroadcastResult, type BrowserExtractionPhase, type BrowserPackagePlan, type ComputeUnit, type CreateAlephBrowserClientOptions, type Crn, type CrnExecutionLookupResult, type CrnListResponse, type CrnLocation, type CrnUsage, DEFAULT_2N6_API_HOST, DEFAULT_ALEPH_AGGREGATE_ADDRESS, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_SCHEDULER_API_HOST, DEFAULT_CRN_LIST_URL, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_ROOTFS_MANIFEST_URL, type DeploymentInspectionResult, type EthereumProviderLike, type EthereumTransactionRequest, type GatewayProbeStatus, ITEM_HASH_RE, type InstanceAllocation, type InstanceAllocationNode, type InstanceAllocationPeriod, type InstanceExecution, type InstanceExecutionNetworking, type InstanceExecutionStatus, type InstanceMessage, type InstancePortMapping, type InstancePricing, type LoadRootfsManifestOptions, type MessageReference, type MessageStatus, type PaymentMode, type Price, type PricingState, type ReferenceStatus, type RelaySetupRequest, type RelaySetupResult, type RootfsManifest, type RootfsManifestState, type RootfsRequiredPortForward, type RootfsResolution, type Tier, broadcastAlephMessage, broadcastInstanceMessage, configureOrbitdbRelaySetup, createAlephBrowserClient, ethCall, fetch2n6WebAccessUrl, fetchBalance, fetchCrnExecutionMap, fetchCrns, fetchInstancePricing, fetchInstances, fetchMessageEnvelope, fetchSchedulerAllocation, fetchWithTimeout, inspectDeploymentResult, loadRootfsManifest, normalizeExecution, normalizeMessageStatus, notifyCrnAllocation, parseInstancePricing, personalSign, resolveRootfsReference, sendTransaction, validateRootfsManifest, verifyRootfsExists, waitForDeploymentResult };
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
2
|
var BROWSER_PACKAGE_PLAN = {
|
|
3
3
|
phase: "scaffolded",
|
|
4
|
-
modules: ["http", "aleph-api", "rootfs", "pricing"]
|
|
4
|
+
modules: ["http", "aleph-api", "client", "evm", "rootfs", "pricing"]
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/http.ts
|
|
@@ -506,6 +506,51 @@ function createAlephBrowserClient(options = {}) {
|
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
// src/evm.ts
|
|
510
|
+
function ensureHexQuantity(value) {
|
|
511
|
+
return `0x${value.toString(16)}`;
|
|
512
|
+
}
|
|
513
|
+
function assertProvider(provider) {
|
|
514
|
+
if (!provider) {
|
|
515
|
+
throw new Error("MetaMask provider not found.");
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
async function ethCall(to, data, provider) {
|
|
519
|
+
assertProvider(provider);
|
|
520
|
+
return provider.request({
|
|
521
|
+
method: "eth_call",
|
|
522
|
+
params: [
|
|
523
|
+
{
|
|
524
|
+
to,
|
|
525
|
+
data
|
|
526
|
+
},
|
|
527
|
+
"latest"
|
|
528
|
+
]
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
async function sendTransaction(tx, provider) {
|
|
532
|
+
assertProvider(provider);
|
|
533
|
+
return provider.request({
|
|
534
|
+
method: "eth_sendTransaction",
|
|
535
|
+
params: [
|
|
536
|
+
{
|
|
537
|
+
from: tx.from,
|
|
538
|
+
to: tx.to,
|
|
539
|
+
data: tx.data,
|
|
540
|
+
value: tx.value != null ? ensureHexQuantity(tx.value) : void 0
|
|
541
|
+
}
|
|
542
|
+
]
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
async function personalSign(address, message, provider) {
|
|
546
|
+
assertProvider(provider);
|
|
547
|
+
const hexMessage = `0x${Array.from(new TextEncoder().encode(message)).map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
548
|
+
return provider.request({
|
|
549
|
+
method: "personal_sign",
|
|
550
|
+
params: [hexMessage, address]
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
|
|
509
554
|
// src/rootfs.ts
|
|
510
555
|
var ITEM_HASH_RE = /^[a-fA-F0-9]{64}$/u;
|
|
511
556
|
var DEFAULT_ROOTFS_MANIFEST_URL = "./rootfs-manifest.json";
|
|
@@ -729,6 +774,7 @@ export {
|
|
|
729
774
|
broadcastInstanceMessage,
|
|
730
775
|
configureOrbitdbRelaySetup,
|
|
731
776
|
createAlephBrowserClient,
|
|
777
|
+
ethCall,
|
|
732
778
|
fetch2n6WebAccessUrl,
|
|
733
779
|
fetchBalance,
|
|
734
780
|
fetchCrnExecutionMap,
|
|
@@ -744,7 +790,9 @@ export {
|
|
|
744
790
|
normalizeMessageStatus,
|
|
745
791
|
notifyCrnAllocation,
|
|
746
792
|
parseInstancePricing,
|
|
793
|
+
personalSign,
|
|
747
794
|
resolveRootfsReference,
|
|
795
|
+
sendTransaction,
|
|
748
796
|
validateRootfsManifest,
|
|
749
797
|
verifyRootfsExists,
|
|
750
798
|
waitForDeploymentResult
|