@blocto/sdk
Advanced tools
Comparing version 0.8.1-beta.1 to 0.9.0-beta.2
@@ -31,14 +31,3 @@ /// <reference types="typescript" /> | ||
interface EvmSupportMapping { | ||
[id: string]: { | ||
chain_id: number; | ||
name: string; // backend defined chain name: ethereum, bsc, … | ||
display_name: string; // human readable name: Ethereum, Polygon, … | ||
network_type: string; // chain network type: mainnet / testnet / devnet | ||
blocto_service_environment: string; // backend service env: prod / dev (may return staging in future) | ||
rpc_endpoint_domains: string[]; // rpc endpoints whitelist | ||
}; | ||
} | ||
interface EthereumProviderConfig extends BaseConfig { | ||
interface SingleChainConfig extends BaseConfig { | ||
chainId: string | number | null; | ||
@@ -49,2 +38,10 @@ rpc?: string; | ||
interface MultiChainConfig extends BaseConfig { | ||
defaultChainId: string | number | null; | ||
walletServer?: string; | ||
switchableChains: AddEthereumChainParameter[]; | ||
} | ||
// EthereumProviderConfig can be both single chain or multi chain config. | ||
type EthereumProviderConfig = SingleChainConfig | MultiChainConfig; | ||
interface EIP1193RequestPayload { | ||
@@ -55,2 +52,3 @@ id?: number; | ||
params?: Array<any>; | ||
callback?: JsonRpcCallback; | ||
} | ||
@@ -75,11 +73,12 @@ | ||
_blocto: { | ||
sessionKey: KEY_SESSION; | ||
sessionKeyEnv: KEY_SESSION; | ||
walletServer: string; | ||
blockchainName: string; | ||
networkType: string; | ||
supportNetworkList: EvmSupportMapping; | ||
switchableNetwork: SwitchableNetwork; | ||
}; | ||
sendUserOperation(userOp: IUserOperation): Promise<string>; | ||
request(args: EIP1193RequestPayload): Promise<any>; | ||
request( | ||
args: EIP1193RequestPayload | Array<EIP1193RequestPayload> | ||
): Promise<any>; | ||
loadSwitchableNetwork( | ||
@@ -91,2 +90,3 @@ networkList: { | ||
): Promise<null>; | ||
supportChainList(): Promise<{ chainId: string; chainName: string }[]>; | ||
injectedWalletServer?: string; | ||
@@ -98,2 +98,3 @@ } | ||
rpcUrls: string[]; | ||
[key: string]: any; | ||
} | ||
@@ -121,2 +122,8 @@ | ||
interface PromiseResponseItem { | ||
status: 'fulfilled' | 'rejected'; | ||
value?: any; | ||
reason?: any; | ||
} | ||
/** | ||
@@ -186,2 +193,3 @@ * A [[HexString]] whose length is even, which ensures it is a valid | ||
type ethereum_d_Numeric = Numeric; | ||
type ethereum_d_PromiseResponseItem = PromiseResponseItem; | ||
declare namespace ethereum_d { | ||
@@ -201,2 +209,3 @@ export { | ||
ethereum_d_Numeric as Numeric, | ||
ethereum_d_PromiseResponseItem as PromiseResponseItem, | ||
}; | ||
@@ -290,4 +299,4 @@ } | ||
declare interface BloctoSDKConfig extends BaseConfig { | ||
ethereum?: Omit<EthereumProviderConfig, 'appId'>; | ||
aptos?: Omit<AptosProviderConfig>; | ||
ethereum?: EthereumProviderConfig; | ||
aptos?: AptosProviderConfig; | ||
} | ||
@@ -294,0 +303,0 @@ declare class BloctoSDK { |
@@ -10,3 +10,3 @@ import { EIP1193Provider, RequestArguments } from 'eip1193-provider'; | ||
constructor(); | ||
request(payload: RequestArguments): Promise<void>; | ||
request(payload: RequestArguments | Array<RequestArguments>): Promise<void>; | ||
on(event: string, listener: (arg: any) => void): void; | ||
@@ -13,0 +13,0 @@ once(): void; |
import { ProviderAccounts } from 'eip1193-provider'; | ||
import BloctoProvider from './blocto'; | ||
import { EIP1193RequestPayload, EthereumProviderConfig, EthereumProviderInterface, JsonRpcRequest, JsonRpcResponse, JsonRpcCallback, SwitchableNetwork, IUserOperation } from './types/ethereum.d'; | ||
import { EIP1193RequestPayload, EthereumProviderConfig, EthereumProviderInterface, AddEthereumChainParameter, JsonRpcRequest, JsonRpcResponse, JsonRpcCallback, SwitchableNetwork, IUserOperation } from './types/ethereum.d'; | ||
import { KEY_SESSION } from '../constants'; | ||
import { EvmSupportMapping } from '../lib/getEvmSupport'; | ||
export default class EthereumProvider extends BloctoProvider implements EthereumProviderInterface { | ||
@@ -14,13 +13,13 @@ #private; | ||
_blocto: { | ||
sessionKey: KEY_SESSION; | ||
unloadedNetwork?: AddEthereumChainParameter[]; | ||
sessionKeyEnv: KEY_SESSION; | ||
walletServer: string; | ||
blockchainName: string; | ||
networkType: string; | ||
supportNetworkList: EvmSupportMapping; | ||
switchableNetwork: SwitchableNetwork; | ||
}; | ||
private get existedSDK(); | ||
constructor({ chainId, rpc, walletServer, appId }: EthereumProviderConfig); | ||
constructor(config: EthereumProviderConfig); | ||
send(methodOrPayload: string | JsonRpcRequest, paramsOrCallback: Array<unknown> | JsonRpcCallback): Promise<void | JsonRpcResponse>; | ||
sendAsync(payload: JsonRpcRequest | Array<JsonRpcRequest>, callback?: JsonRpcCallback): Promise<JsonRpcResponse | Array<JsonRpcResponse> | void>; | ||
sendAsync(payload: JsonRpcRequest | Array<JsonRpcRequest> | Array<EIP1193RequestPayload>, callback?: JsonRpcCallback): Promise<JsonRpcResponse | Array<JsonRpcResponse> | void>; | ||
/** | ||
@@ -34,3 +33,3 @@ * Sending userOperation using Blocto SDK. | ||
sendUserOperation(userOp: IUserOperation): Promise<string>; | ||
request(payload: EIP1193RequestPayload): Promise<any>; | ||
request(payload: EIP1193RequestPayload | Array<EIP1193RequestPayload>): Promise<any>; | ||
bloctoApi<T>(url: string, options?: RequestInit): Promise<T>; | ||
@@ -49,6 +48,7 @@ responseListener(frame: HTMLIFrameElement, objectKey: string): Promise<any>; | ||
handleDisconnect(): Promise<void>; | ||
loadSwitchableNetwork(networkList: { | ||
loadSwitchableNetwork(networkList: AddEthereumChainParameter[]): Promise<null>; | ||
supportChainList(): Promise<{ | ||
chainId: string; | ||
rpcUrls?: string[]; | ||
}[]): Promise<null>; | ||
chainName: string; | ||
}[]>; | ||
on(event: string, listener: (arg: any) => void): void; | ||
@@ -55,0 +55,0 @@ removeListener(event: string, listener: (arg: any) => void): void; |
{ | ||
"name": "@blocto/sdk", | ||
"version": "0.8.1-beta.1", | ||
"version": "0.9.0-beta.2", | ||
"repository": "git@github.com:portto/blocto-sdk.git", | ||
@@ -5,0 +5,0 @@ "author": "Chiaki.C", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
410912
9013