Skip to content

Commit

Permalink
Merge pull request #686 from nevermined-io/fix/signing-in-frontends
Browse files Browse the repository at this point in the history
Fix/signing in frontends
  • Loading branch information
eruizgar91 authored Jun 26, 2024
2 parents f698da7 + 22c4a9e commit 1727330
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).


#### [v3.0.14](https://github.com/nevermined-io/sdk-js/compare/v3.0.14-rc0...v3.0.14)

> 24 June 2024
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/sdk",
"version": "3.0.14",
"version": "3.0.15",
"description": "Javascript SDK for connecting with Nevermined Data Platform ",
"main": "./dist/node/sdk.js",
"typings": "./dist/node/sdk.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion scripts/download-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi

REPO_URL=https://artifacts.nevermined.network
declare -A NETWORKS_MAP
NETWORKS_MAP=( ["mainnet"]="1" ["rinkeby"]="4" ["kovan"]="42" ["matic"]="137" ["mumbai"]="80001" ["celo-alfajores"]="44787" ["celo"]="42220" ["aurora"]="1313161554" ["aurora-testnet"]="1313161555" ["arbitrum-one"]="42161" ["arbitrum-goerli"]="421613" ["arbitrum-sepolia"]="421614" )
NETWORKS_MAP=( ["mainnet"]="1" ["rinkeby"]="4" ["optimism"]="10" ["kovan"]="42" ["gnosis"]="100" ["matic"]="137" ["base"]="8453" ["mumbai"]="80001" ["celo-alfajores"]="44787" ["celo"]="42220" ["aurora"]="1313161554" ["aurora-testnet"]="1313161555" ["arbitrum-one"]="42161" ["arbitrum-goerli"]="421613" ["arbitrum-sepolia"]="421614" )

SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
UNPACK_DIR="$SCRIPT_DIR/../artifacts"
Expand Down
9 changes: 7 additions & 2 deletions src/Instantiable.abstract.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { getChain } from './utils/Network'
import {
Chain,
createPublicClient,
createWalletClient,
custom,
http,
PublicClient,
WalletClient,
} from 'viem'
import { Logger, LoggerInstance, LogLevel } from './models/Logger'
import { NeverminedOptions } from './models/NeverminedOptions'
import { Nevermined } from './nevermined/Nevermined'
import { getChain } from './utils/Network'

export interface InstantiableConfig {
nevermined: Nevermined
Expand Down Expand Up @@ -50,7 +51,11 @@ export async function getWeb3ViemClients(
config: Partial<NeverminedOptions> = {},
): Promise<Web3Clients> {
const chain = getChain(config.chainId)
const providerTransport = config.web3ProviderUri ? http(config.web3ProviderUri) : http()
const providerTransport = config.web3ProviderUri
? http(config.web3ProviderUri)
: window && window.ethereum
? custom(window.ethereum!)
: http()

const publicClient = createPublicClient({
chain,
Expand Down
1 change: 1 addition & 0 deletions src/nevermined/NvmApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class NvmApp {
'NFT1155SubscriptionUpgradeable',
this.configNVM.artifactsFolder,
await this.fullSDK.keeper.getNetworkName(),
this.configNVM.chainId,
)
this.subscriptionNFTContractAddress = contractABI.address
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/nevermined/resources/AppNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AppDeploymentStaging extends NeverminedAppOptions {
instanceName = 'appStaging'
appUrl = 'https://staging.nevermined.app'
chainId = 421614
web3ProviderUri = 'https://sepolia-rollup.arbitrum.io/rpc'
web3ProviderUri = window.ethereum ? undefined : 'https://sepolia-rollup.arbitrum.io/rpc'
marketplaceUri = 'https://marketplace-api.staging.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.staging.nevermined.app'
Expand All @@ -41,7 +41,7 @@ export class AppDeploymentTesting extends NeverminedAppOptions {
instanceName = 'appTesting'
appUrl = 'https://testing.nevermined.app'
chainId = 421614
web3ProviderUri = 'https://sepolia-rollup.arbitrum.io/rpc'
web3ProviderUri = window.ethereum ? undefined : 'https://sepolia-rollup.arbitrum.io/rpc'
marketplaceUri = 'https://marketplace-api.testing.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.testing.nevermined.app'
Expand All @@ -57,7 +57,7 @@ export class AppDeploymentArbitrum extends NeverminedAppOptions {
instanceName = 'appArbitrum'
appUrl = 'https://nevermined.app'
chainId = 42161
web3ProviderUri = 'https://arb1.arbitrum.io/rpc'
web3ProviderUri = window.ethereum ? undefined : 'https://arb1.arbitrum.io/rpc'
marketplaceUri = 'https://marketplace-api.arbitrum.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.arbitrum.nevermined.app'
Expand All @@ -73,7 +73,7 @@ export class AppDeploymentGnosis extends NeverminedAppOptions {
instanceName = 'appGnosis'
appUrl = 'https://gnosis.nevermined.app'
chainId = 100
web3ProviderUri = 'https://rpc.gnosischain.com/'
web3ProviderUri = window.ethereum ? undefined : 'https://rpc.gnosischain.com/'
marketplaceUri = 'https://marketplace-api.gnosis.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.gnosis.nevermined.app'
Expand All @@ -89,7 +89,7 @@ export class AppDeploymentMatic extends NeverminedAppOptions {
instanceName = 'appMatic'
appUrl = 'https://matic.nevermined.app'
chainId = 137
web3ProviderUri = 'https://polygon-rpc.com'
web3ProviderUri = window.ethereum ? undefined : 'https://polygon-rpc.com'
marketplaceUri = 'https://marketplace-api.matic.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.matic.nevermined.app'
Expand All @@ -105,7 +105,7 @@ export class AppDeploymentBase extends NeverminedAppOptions {
instanceName = 'appBase'
appUrl = 'https://base.nevermined.app'
chainId = 8453
web3ProviderUri = 'https://1rpc.io/base'
web3ProviderUri = window.ethereum ? undefined : 'https://1rpc.io/base'
marketplaceUri = 'https://marketplace-api.base.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.base.nevermined.app'
Expand All @@ -121,7 +121,7 @@ export class AppDeploymentCelo extends NeverminedAppOptions {
instanceName = 'appCelo'
appUrl = 'https://celo.nevermined.app'
chainId = 42220
web3ProviderUri = 'https://forno.celo.org'
web3ProviderUri = window.ethereum ? undefined : 'https://forno.celo.org'
marketplaceUri = 'https://marketplace-api.celo.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.celo.nevermined.app'
Expand All @@ -137,7 +137,7 @@ export class AppDeploymentOptimism extends NeverminedAppOptions {
instanceName = 'appOptimism'
appUrl = 'https://optimism.nevermined.app'
chainId = 10
web3ProviderUri = 'https://optimism.drpc.org'
web3ProviderUri = window.ethereum ? undefined : 'https://optimism.drpc.org'
marketplaceUri = 'https://marketplace-api.optimism.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.optimism.nevermined.app'
Expand Down
4 changes: 4 additions & 0 deletions src/permissionless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ declare module 'permissionless/accounts' {
declare module 'permissionless/types' {
export type EntryPoint = string
}

interface Window {
ethereum?: any
}

0 comments on commit 1727330

Please sign in to comment.