@toruslabs/solana-embed
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -278,2 +278,38 @@ import { Transaction } from '@solana/web3.js'; | ||
} | ||
const getNetworkConfig = (label) => { | ||
switch (label) { | ||
case "mainnet-beta": | ||
return { | ||
blockExplorerUrl: "https://explorer.solana.com", | ||
chainId: "0x1", | ||
displayName: "Solana Mainnet", | ||
logo: "solana.svg", | ||
rpcTarget: "https://api.mainnet-beta.solana.com", | ||
ticker: "SOL", | ||
tickerName: "Solana Token", | ||
}; | ||
case "testnet": | ||
return { | ||
blockExplorerUrl: "https://explorer.solana.com", | ||
chainId: "0x2", | ||
displayName: "Solana Testnet", | ||
logo: "solana.svg", | ||
rpcTarget: "https://api.testnet.solana.com", | ||
ticker: "SOL", | ||
tickerName: "Solana Token", | ||
}; | ||
case "devnet": | ||
return { | ||
blockExplorerUrl: "https://explorer.solana.com", | ||
chainId: "0x3", | ||
displayName: "Solana Devnet", | ||
logo: "solana.svg", | ||
rpcTarget: "https://api.devnet.solana.com", | ||
ticker: "SOL", | ||
tickerName: "Solana Token", | ||
}; | ||
default: | ||
return undefined; | ||
} | ||
}; | ||
@@ -1066,3 +1102,3 @@ /** | ||
const PROVIDER_UNSAFE_METHODS = ["send_transaction", "sign_transaction", "sign_all_transaction", "sign_message", "connect"]; | ||
const PROVIDER_UNSAFE_METHODS = ["send_transaction", "sign_transaction", "sign_all_transactions", "sign_message", "connect"]; | ||
const COMMUNICATION_UNSAFE_METHODS = [COMMUNICATION_JRPC_METHODS.SET_PROVIDER]; | ||
@@ -1107,3 +1143,3 @@ const isLocalStorageAvailable = storageAvailable("localStorage"); | ||
} | ||
init({ buildEnv = TORUS_BUILD_ENV.PRODUCTION, enableLogging = false, network, showTorusButton = true, useLocalStorage = false, buttonPosition = BUTTON_POSITION.BOTTOM_LEFT, apiKey = "torus-default", extraParams = {}, } = {}) { | ||
init({ buildEnv = TORUS_BUILD_ENV.PRODUCTION, enableLogging = false, network, showTorusButton = false, useLocalStorage = false, buttonPosition = BUTTON_POSITION.BOTTOM_LEFT, apiKey = "torus-default", extraParams = {}, } = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1152,3 +1188,3 @@ if (this.isInitialized) | ||
apiKey, | ||
network, | ||
network: typeof network === "string" ? getNetworkConfig(network) : network, | ||
dappMetadata, | ||
@@ -1434,8 +1470,9 @@ extraParams, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const signed_transactions = []; | ||
for (const transaction of transactions) { | ||
const res = yield this.signTransaction(transaction); | ||
signed_transactions.push(res); | ||
} | ||
return signed_transactions; | ||
const encodedTransactions = transactions.map((x) => x.serialize({ requireAllSignatures: false }).toString("hex")); | ||
const response = yield this.provider.request({ | ||
method: "sign_all_transactions", | ||
params: { message: encodedTransactions }, | ||
}); | ||
const allSignedTransaction = response.map((msg) => Transaction.from(Buffer.from(msg, "hex"))); | ||
return allSignedTransaction; | ||
}); | ||
@@ -1442,0 +1479,0 @@ } |
@@ -172,2 +172,3 @@ import { JRPCRequest } from "@toruslabs/openlogin-jrpc"; | ||
} | ||
export declare type NetworkLabel = "mainnet-beta" | "testnet" | "devnet"; | ||
export interface TorusParams { | ||
@@ -187,3 +188,3 @@ /** | ||
*/ | ||
network?: NetworkInterface; | ||
network?: NetworkInterface | NetworkLabel; | ||
/** | ||
@@ -190,0 +191,0 @@ * Build Environment of Torus. |
import { JRPCMiddleware, SafeEventEmitter } from "@toruslabs/openlogin-jrpc"; | ||
import { LogLevelDesc } from "loglevel"; | ||
import { NetworkInterface, NetworkLabel } from "./interfaces"; | ||
/** | ||
@@ -51,1 +52,2 @@ * json-rpc-engine middleware that logs RPC errors and and validates req.method. | ||
}): string; | ||
export declare const getNetworkConfig: (label: NetworkLabel) => NetworkInterface | undefined; |
{ | ||
"name": "@toruslabs/solana-embed", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Embed script for solana blockchain", | ||
@@ -5,0 +5,0 @@ "main": "dist/torus.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
1223592
5155