diff --git a/CHANGELOG.md b/CHANGELOG.md index 9be31e36..4ca8c27d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.3.3](https://github.com/lukso-network/tools-lsp-factory/compare/v2.3.2...v2.3.3) (2022-07-25) + + +### improvement + +* get chainId from provider ([d2db829](https://github.com/lukso-network/tools-lsp-factory/commit/d2db829a47ca429befc4cfd9505d45316cf16fd4)) + + ### [2.3.2](https://github.com/lukso-network/tools-lsp-factory/compare/v2.3.1...v2.3.2) (2022-06-24) diff --git a/README.md b/README.md index a5aac833..5a7e1857 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ npm install @lukso/lsp-factory.js ```javascript import { LSPFactory } from '@lukso/lsp-factory.js'; -const provider = 'https://rpc.l14.lukso.network'; // RPC url used to connect to the network +const provider = 'https://rpc.l16.lukso.network'; // RPC url used to connect to the network const lspFactory = new LSPFactory(provider, { deployKey: '0x...'; // Private key of the account which will deploy UPs - chainId: 22, // Chain Id of the network you want to connect to + chainId: 2828, // Chain Id of the network you want to connect to }); ``` diff --git a/docs/classes/lsp7-digital-asset.md b/docs/classes/lsp7-digital-asset.md index 81a69677..04e68ff9 100644 --- a/docs/classes/lsp7-digital-asset.md +++ b/docs/classes/lsp7-digital-asset.md @@ -52,12 +52,7 @@ You can read more about the `options` object specification on [its official page | Type | Description | | :----------- | :------------------------------------------------------------------------------------------- | -| `Promise` | Resolves to an object containing deployed contract details. Default return value. | -| `Observable` | An [RxJS Observable]. Returned if `deployReactive` is set to `true` inside `options` object. | - -:::info -The `deployReactive` flag can be set in the `options` object to return an [RxJS Observable] of deployment events. -::: +| `Promise` | Resolves to an object containing deployed contract details. | ### Example @@ -209,6 +204,5 @@ Deployment Complete [uploading lsp4 digital asset metadata]: ./lsp4-digital-asset-metadata#uploadMetadata [lsp-smart-contracts]: https://github.com/lukso-network/lsp-smart-contracts [eip1167]: https://eips.ethereum.org/EIPS/eip-1167 -[rxjs observable]: https://rxjs.dev/guide/observable [ipfs-http-client]: https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#createoptions [lsp7 decimals]: https://github.com/lukso-network/lsp-smart-contracts/blob/develop/docs/ILSP7DigitalAsset.md#decimals diff --git a/docs/classes/lsp8-identifiable-digital-asset.md b/docs/classes/lsp8-identifiable-digital-asset.md index eea8d5c4..7225b8f6 100644 --- a/docs/classes/lsp8-identifiable-digital-asset.md +++ b/docs/classes/lsp8-identifiable-digital-asset.md @@ -50,12 +50,7 @@ You can read more about the `options` object specification on [its official page | Type | Description | | :----------- | :------------------------------------------------------------------------------------------- | -| `Promise` | Resolves to an object containing deployed contract details. Default return value. | -| `Observable` | An [RxJS Observable]. Returned if `deployReactive` is set to `true` inside `options` object. | - -:::info -The `deployReactive` flag can be set in the `options` object to return an [RxJS Observable] of deployment events. -::: +| `Promise` | Resolves to an object containing deployed contract details. | ### Example @@ -207,12 +202,10 @@ Deployment Complete ``` [contract deployment options]: ../deployment/digital-asset/#deployment-configuration -[rxjs observable]: https://rxjs.dev/guide/observable [constructor parameters]: ../../../../../standards/smart-contracts/lsp7-digital-asset#constructor [contract deployment options]: ../deployment/digital-asset.md [lsp4]: https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-4-DigitalAsset-Metadata.md [uploading lsp4 digital asset metadata]: ./lsp4-digital-asset-metadata#uploadMetadata [lsp-smart-contracts]: https://github.com/lukso-network/lsp-smart-contracts [eip1167]: https://eips.ethereum.org/EIPS/eip-1167 -[rxjs observable]: https://rxjs.dev/guide/observable [ipfs-http-client]: https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#createoptions diff --git a/docs/classes/universal-profile.md b/docs/classes/universal-profile.md index 7e624d22..92545331 100644 --- a/docs/classes/universal-profile.md +++ b/docs/classes/universal-profile.md @@ -76,7 +76,7 @@ See the [configuration specification](../deployment/universal-profile#deployment ```javascript title="Deploying a Universal Profile" await lspFactory.UniversalProfile.deploy({ - controllingAccounts: ['0xb74a88C43BCf691bd7A851f6603cb1868f6fc147'], + controllerAddresses: ['0xb74a88C43BCf691bd7A851f6603cb1868f6fc147'], lsp3Profile: { name: 'My Universal Profile', description: 'My cool Universal Profile', @@ -159,7 +159,7 @@ await lspFactory.UniversalProfile.deploy({ ```javascript title="Reactive Universal Profile Deployment" await lspFactory.UniversalProfile.deploy( { - controllingAccounts: ['0x9Fba07e245B415cC9580BD6c890a9fd7D22e20db'], + controllerAddresses: ['0x9Fba07e245B415cC9580BD6c890a9fd7D22e20db'], }, { onDeployEvents: { @@ -559,5 +559,4 @@ await UniversalProfile.uploadProfileData( ``` [all permissions]: ../../../../../standards/universal-profile/lsp6-key-manager#-address-permissions -[rxjs observable]: https://rxjs.dev/guide/observable [lsp3]: ../../../standards/universal-profile/lsp3-universal-profile-metadata diff --git a/docs/deployment/universal-profile.md b/docs/deployment/universal-profile.md index ebb40924..2c73ca7a 100644 --- a/docs/deployment/universal-profile.md +++ b/docs/deployment/universal-profile.md @@ -195,7 +195,7 @@ const myUniversalProfileData = { }; await lspFactory.UniversalProfile.deploy({ - controllingAccounts: ['0x...'], + controllerAddresses: ['0x...'], lsp3Profile: myUniversalProfileData }); }; @@ -232,7 +232,7 @@ Avatar files passed as a metadata objects will be set directly on the [LSP3 Prof }; await lspFactory.UniversalProfile.deploy({ - controllingAccounts: ['0x...'], + controllerAddresses: ['0x...'], lsp3Profile: myUniversalProfileData }); @@ -266,7 +266,7 @@ Javascript's `File` object is only available when using javascript in the browse }; await lspFactory.UniversalProfile.deploy({ - controllingAccounts: ['0x...'], + controllerAddresses: ['0x...'], lsp3Profile: myUniversalProfileData }); }; @@ -305,7 +305,7 @@ const myUniversalProfileData = { }; await lspFactory.UniversalProfile.deploy({ - controllingAccounts: ['0x...'], + controllerAddresses: ['0x...'], lsp3Profile: myUniversalProfileData, }); ``` --> diff --git a/docs/getting-started.md b/docs/getting-started.md index 23db1362..d31edf02 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -20,11 +20,11 @@ npm install @lukso/lsp-factory.js ```javascript import { LSPFactory } from '@lukso/lsp-factory.js'; -const provider = 'https://rpc.l14.lukso.network'; // RPC provider url +const provider = 'https://rpc.l16.lukso.network'; const lspFactory = new LSPFactory(provider, { - deployKey: '0x...', // Private key of the account which will deploy any smart contract, - chainId: 22, // Chain Id of the network you want to deploy to + deployKey: '0x...', // Private key of the account which will deploy smart contracts + chainId: 2828, }); ``` @@ -35,7 +35,9 @@ If used in the browser on a dApp's page, pass the ethereum object as the provide ```javascript await ethereum.request({ method: 'eth_requestAccounts', params: [] }); -const lspFactory = new LSPFactory(ethereum); +const lspFactory = new LSPFactory(ethereum, { + chainId: 2828, +}); ``` ## Usage @@ -44,10 +46,9 @@ Deploying a Universal Profile is as simple as running: ```javascript const myContracts = await lspFactory.UniversalProfile.deploy({ - controllingAccounts: ['0x...'], // Account addresses which will control the UP - lsp3Profile: myLSP3MetaData - }); -}; + controllerAddresses: ['0x...'], // Account addresses which will control the UP + lsp3Profile: myLSP3MetaData, +}); ``` The key `lsp3Profile` contains the [LSP3 Metadata](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#JSONURL) of your Universal Profile. This is the "face" of your Universal Profile and contains all the public information people will see when they view your UP like your name, description and profile image. @@ -115,9 +116,9 @@ const myUPAddress = myContracts.LSP0ERC725Account.address; When instantiating LSPFactory options can be passed to specify parameters such as `chainId` and `ipfsGateway`. ```javascript title="Instantiating LSPFactory with custom options set" -const lspFactory = new LSPFactory(provider, { +const lspFactory = new LSPFactory('https://rpc.l16.lukso.network', { deployKey: '0x...', - chainId: 22, + chainId: 2828, ipfsGateway: 'https://ipfs.infura.io:5001', }); ``` @@ -130,16 +131,16 @@ If no value is set here, LSPFactory will attempt to sign transactions via a brow #### Chain Id -`chainId` is used to specify the network that LSPFactory is interacting with. This is used in the [versions file](https://github.com/lukso-network/tools-lsp-factory/blob/main/src/versions.json) to reference base contracts deployed on the network used for [proxy deployment](./getting-started.md#proxy-deployment). Defaults to 22. +`chainId` is used to specify the network that LSPFactory is interacting with. The provided `chainId` will be used to determine which base contracts to use when using [proxy deployment](./deployment/options.md#deploy-proxy). Previously deployed base contract addresses are stored in the [versions file](https://github.com/lukso-network/tools-lsp-factory/blob/main/src/versions.json) and accessed using the provided chainId. Defaults to 22 (l14 testnet). #### IPFS Gateway `ipfsGateway` is used to specify the IPFS node which should be interacted with for uploading and retrieving metadata. `ipfsGateway` can be either a URL string or an object as defined by the [IPFS-HTTP Client](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#createoptions) library which is used internally to interact with the IPFS node. ```javascript title="Instantiating LSPFactory with custom ipfsGateway options set" -const lspFactory = new LSPFactory(provider, { +const lspFactory = new LSPFactory('https://rpc.l16.lukso.network', { deployKey: '0x...', - chainId: 22, + chainId: 2828, ipfsGateway: { host: 'ipfs.infura.io', port: 5001, diff --git a/package-lock.json b/package-lock.json index 1df9171b..5429722b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lukso/lsp-factory.js", - "version": "2.3.2", + "version": "2.3.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lukso/lsp-factory.js", - "version": "2.3.2", + "version": "2.3.3", "license": "MIT", "dependencies": { "@erc725/erc725.js": "0.14.1", @@ -3338,8 +3338,9 @@ } }, "node_modules/@openzeppelin/contracts": { - "version": "4.6.0", - "license": "MIT" + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.1.tgz", + "integrity": "sha512-UXmAjKARsXORHlHZu5GCD7ZbRKm6nU8UHnbuT/QJJa2JEOEcbvV/X8w/sUk62Sl9VZuuljM1akrZLyAtzUgsxw==" }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", @@ -10804,6 +10805,23 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-type": { + "version": "16.5.4", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", + "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", + "dev": true, + "dependencies": { + "readable-web-to-node-stream": "^3.0.0", + "strtok3": "^6.2.4", + "token-types": "^4.1.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/file-type?sponsor=1" + } + }, "node_modules/filename-reserved-regex": { "version": "2.0.0", "dev": true, @@ -12085,11 +12103,6 @@ "hasInstallScript": true, "license": "MIT" }, - "node_modules/ganache-core/node_modules/core-util-is": { - "version": "1.0.2", - "dev": true, - "license": "MIT" - }, "node_modules/ganache-core/node_modules/debug": { "version": "3.2.6", "dev": true, @@ -23874,22 +23887,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/open-cli/node_modules/file-type": { - "version": "16.5.3", - "dev": true, - "license": "MIT", - "dependencies": { - "readable-web-to-node-stream": "^3.0.0", - "strtok3": "^6.2.4", - "token-types": "^4.1.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/file-type?sponsor=1" - } - }, "node_modules/open-cli/node_modules/get-stdin": { "version": "9.0.0", "dev": true, @@ -24552,9 +24549,10 @@ } }, "node_modules/protobufjs": { - "version": "6.11.2", + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", "hasInstallScript": true, - "license": "BSD-3-Clause", "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", @@ -31146,7 +31144,9 @@ "requires": {} }, "@openzeppelin/contracts": { - "version": "4.6.0" + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.1.tgz", + "integrity": "sha512-UXmAjKARsXORHlHZu5GCD7ZbRKm6nU8UHnbuT/QJJa2JEOEcbvV/X8w/sUk62Sl9VZuuljM1akrZLyAtzUgsxw==" }, "@protobufjs/aspromise": { "version": "1.1.2" @@ -36364,6 +36364,17 @@ "flat-cache": "^3.0.4" } }, + "file-type": { + "version": "16.5.4", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", + "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", + "dev": true, + "requires": { + "readable-web-to-node-stream": "^3.0.0", + "strtok3": "^6.2.4", + "token-types": "^4.1.1" + } + }, "filename-reserved-regex": { "version": "2.0.0", "dev": true @@ -37376,10 +37387,6 @@ "version": "2.6.12", "dev": true }, - "core-util-is": { - "version": "1.0.2", - "dev": true - }, "debug": { "version": "3.2.6", "dev": true, @@ -45734,15 +45741,6 @@ "tempy": "^1.0.1" }, "dependencies": { - "file-type": { - "version": "16.5.3", - "dev": true, - "requires": { - "readable-web-to-node-stream": "^3.0.0", - "strtok3": "^6.2.4", - "token-types": "^4.1.1" - } - }, "get-stdin": { "version": "9.0.0", "dev": true @@ -46147,7 +46145,9 @@ } }, "protobufjs": { - "version": "6.11.2", + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", "requires": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", diff --git a/package.json b/package.json index 43e01682..fba03f88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lukso/lsp-factory.js", - "version": "2.3.2", + "version": "2.3.3", "description": "Helper Library to allow simple deployments of UniversalProfiles and LSP7 and LSP8 Digital Assets.", "main": "build/main/src/index.js", "typings": "build/main/src/index.d.ts", diff --git a/src/lib/classes/universal-profile.ts b/src/lib/classes/universal-profile.ts index ba0e1e70..69436b81 100644 --- a/src/lib/classes/universal-profile.ts +++ b/src/lib/classes/universal-profile.ts @@ -61,7 +61,7 @@ export class UniversalProfile { * @example * ```javascript *lspFactory.UniversalProfile.deploy({ - * controllingAccounts: ['0xb74a88C43BCf691bd7A851f6603cb1868f6fc147'], + * controllerAddresses: ['0xb74a88C43BCf691bd7A851f6603cb1868f6fc147'], * lsp3Profile: myUniversalProfileData * }); *}; diff --git a/src/lib/interfaces/deployment-events.ts b/src/lib/interfaces/deployment-events.ts index 495e8560..d81e0a02 100644 --- a/src/lib/interfaces/deployment-events.ts +++ b/src/lib/interfaces/deployment-events.ts @@ -71,6 +71,7 @@ export type EthersExternalProvider = { isStatus?: boolean; host?: string; path?: string; + chainId?: string; sendAsync?: ( request: { method: string; params?: Array }, callback: (error: any, response: any) => void diff --git a/src/lib/lsp-factory.ts b/src/lib/lsp-factory.ts index 414b4b99..38d4bfbc 100644 --- a/src/lib/lsp-factory.ts +++ b/src/lib/lsp-factory.ts @@ -41,6 +41,7 @@ export class LSPFactory { provider = new ethers.providers.JsonRpcProvider(rpcUrlOrProvider); } else if ('chainId' in rpcUrlOrProvider) { provider = new ethers.providers.Web3Provider(rpcUrlOrProvider); + chainId = parseInt(rpcUrlOrProvider.chainId); } else if (typeof rpcUrlOrProvider !== 'string') { provider = rpcUrlOrProvider as providers.Web3Provider | providers.JsonRpcProvider; } @@ -58,7 +59,10 @@ export class LSPFactory { signer = provider.getSigner(); } - chainId = privateKeyOrSigner?.chainId; + if (privateKeyOrSigner?.chainId) { + chainId = privateKeyOrSigner?.chainId; + } + ipfsGateway = privateKeyOrSigner?.ipfsGateway; }