From c6b8151226121189b1329bff1a691f6c57dda8fc Mon Sep 17 00:00:00 2001 From: djdabs Date: Thu, 3 Oct 2024 15:16:24 -0700 Subject: [PATCH 1/3] feat: optimize npm registry packaging --- LICENSE | 21 ++++++++++++++++++++ README.md | 46 +++++++++++++++++++++++++++++++++----------- package-lock.json | 49 ++++++++++++++++++++++++----------------------- package.json | 31 +++++++++++++++--------------- 4 files changed, 96 insertions(+), 51 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b3c0a13 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 The Azuki Company + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 9398858..d5bf043 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ ## PBT (Physical Backed Token) +[![npm](https://img.shields.io/npm/v/@chiru-labs/pbt)](https://www.npmjs.com/package/@chiru-labs/pbt) + NFT collectors enjoy collecting digital assets and sharing them with others online. However, there is currently no such standard for showcasing physical assets as NFTs with verified authenticity and ownership. Existing solutions are fragmented and tend to be susceptible to at least one of the following: -- The NFT cannot proxy as ownership of the physical item. In most current implementations, the NFT and physical item are functionally two decoupled distinct assets after the NFT mint, in which the NFT can be freely traded independently from the physical item. +- The NFT cannot proxy as ownership of the physical item. In most current implementations, the NFT and physical item are functionally two decoupled distinct assets after the NFT mint, in which the NFT can be freely traded independently from the physical item. -- Verification of authenticity of the physical item requires action from a trusted entity (e.g. StockX). +- Verification of authenticity of the physical item requires action from a trusted entity (e.g. StockX). PBT aims to mitigate these issues in a decentralized way through a new token standard (an extension of EIP-721). @@ -13,11 +15,31 @@ From the [Azuki](https://twitter.com/AzukiOfficial) team. Note: the frontend library for chip signatures can be found [here](https://github.com/chiru-labs/pbt-chip-client). +## Import Into Your Project + +``` +npm install @chiru-labs/pbt +``` + +### Foundry + +Add the following to your remappings.txt + +``` +pbt=node_modules/@chiru-labs/pbt/src +``` + +Can then import in your contracts + +``` +import "pbt/v2/PBTSimple.sol"; +``` + ## Resources -- [pbt.io](https://www.pbt.io/) -- [Draft EIP](https://eips.ethereum.org/EIPS/eip-5791) -- [Blog](https://www.azuki.com/updates/pbt) +- [pbt.io](https://www.pbt.io/) +- [Draft EIP](https://eips.ethereum.org/EIPS/eip-5791) +- [Blog](https://www.azuki.com/updates/pbt) ## How does PBT work? @@ -25,9 +47,9 @@ Note: the frontend library for chip signatures can be found [here](https://githu This approach assumes that the physical item must have a chip attached to it that fulfills the following requirements ([Kong](https://arx.org/) is one such vendor for these chips): -- The ability to securely generate and store an ECDSA secp256k1 asymmetric keypair -- The ability to sign messages from the private key of the asymmetric keypair -- The ability for one to retrieve only the public key of the asymmetric keypair (private key non-extractable) +- The ability to securely generate and store an ECDSA secp256k1 asymmetric keypair +- The ability to sign messages from the private key of the asymmetric keypair +- The ability for one to retrieve only the public key of the asymmetric keypair (private key non-extractable) The approach also requires that the contract uses an account-bound implementation of EIP-721 (where all EIP-721 functions that transfer must throw, e.g. the "read only NFT registry" implementation referenced in EIP-721). This ensures that ownership of the physical item is required to initiate transfers and manage ownership of the NFT, through a new function introduced in `IPBT.sol` (`transferTokenWithChip`). @@ -35,9 +57,9 @@ The approach also requires that the contract uses an account-bound implementatio On a high level: -- Each NFT is conceptually linked to a physical chip. -- The NFT can only be transferred to a different owner if a signature from the chip is supplied to the contract. -- This guarantees that a token cannot be transferred without consent from the owner of the physical item. +- Each NFT is conceptually linked to a physical chip. +- The NFT can only be transferred to a different owner if a signature from the chip is supplied to the contract. +- This guarantees that a token cannot be transferred without consent from the owner of the physical item. More details available in the [EIP](https://eips.ethereum.org/EIPS/eip-5791) and inlined into `IPBT.sol`. @@ -78,6 +100,7 @@ As mentioned above, this repo is still in beta and more documentation is on its TODO: flesh this section out more 3 key parts. + - Acquire chips, embed them into the physical items. - The Azuki hoodies used chips from [kongiscash](https://twitter.com/kongiscash). [Docs for chips](https://docs.arx.org/) - Before you sell/ship the physicals, make sure you save the public keys of the chips first, since the smart contract you deploy will need to know which chips are applicable to it. For kongiscash chips, you can use their [bulk scanning tool](https://bulk.vrfy.ch/) to do so. @@ -92,6 +115,7 @@ TODO: flesh this section out more - For now, a working end-to-end flow will also require building out a simple frontend for a mobile browser to grab chip signatures to pass into the smart contract. We have open-sourced a [light js lib](https://github.com/chiru-labs/pbt-chip-client) to help with that piece. ## TODO + - [ ] CI pipeline - [ ] PBT Locking extension (where transfers need to be approved by the current owner first) - [ ] PBT implementation that doesn't require seeding chip addresses to the contract pre-mint diff --git a/package-lock.json b/package-lock.json index a03ddbe..43b8bc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,28 +1,29 @@ { - "name": "pbt-repo", - "version": "0.1.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "pbt-repo", - "version": "0.1.0", - "license": "MIT", - "dependencies": { - "@openzeppelin/contracts": "^4.7.3" - } - }, - "node_modules/@openzeppelin/contracts": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.3.tgz", - "integrity": "sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==" - } + "name": "@chiru-labs/pbt", + "version": "0.3.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@chiru-labs/pbt", + "version": "0.3.0", + "license": "MIT", + "dependencies": { + "@chiru-labs/pbt": "^0.3.0" + } }, - "dependencies": { - "@openzeppelin/contracts": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.3.tgz", - "integrity": "sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==" - } + "node_modules/@chiru-labs/pbt": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@chiru-labs/pbt/-/pbt-0.3.0.tgz", + "integrity": "sha512-XCoMOweuV28GLgVuwocIdvc7O8hKCJMe5C6Ts2dXM76X6KBIHfN0qBeEgSWP9usOZgY6i0817bcErGIF6/40Gw==", + "dependencies": { + "@openzeppelin/contracts": "^4.7.3" + } + }, + "node_modules/@openzeppelin/contracts": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.6.tgz", + "integrity": "sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA==" } + } } diff --git a/package.json b/package.json index cdf18fc..61a7c4e 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,17 @@ { - "name": "@chiru-labs/pbt", - "version": "0.3.0", - "description": "Physically Backed Token Contracts in Solidity", - "main": "index.js", - "files": [ - "/src/**/*.sol" - ], - "dependencies": { - "@openzeppelin/contracts": "^4.7.3" - }, - "repository": { - "type": "git", - "url": "git@github.com-cygaar:chiru-labs/PBT.git" - }, - "author": "chiru-labs", - "license": "MIT" + "name": "@chiru-labs/pbt", + "version": "0.3.0", + "description": "Contracts for Physical Backed Tokens (ERC-5791). ", + "files": [ + "/src/**/*.sol" + ], + "repository": { + "type": "git", + "url": "git@github.com:chiru-labs/PBT.git" + }, + "author": "chiru-labs", + "license": "MIT", + "dependencies": { + "@chiru-labs/pbt": "^0.3.0" + } } From 3f3b3f3607f8f9336f7205d997cfcc543149b760 Mon Sep 17 00:00:00 2001 From: djdabs Date: Thu, 3 Oct 2024 15:16:24 -0700 Subject: [PATCH 2/3] feat: optimize npm registry packaging --- LICENSE | 21 ++++++++++++++++++++ README.md | 22 +++++++++++++++++++++ package-lock.json | 49 ++++++++++++++++++++++++----------------------- package.json | 31 +++++++++++++++--------------- 4 files changed, 83 insertions(+), 40 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b3c0a13 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 The Azuki Company + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 2bd902d..3b72569 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## PBT (Physical Backed Token) +[![npm](https://img.shields.io/npm/v/@chiru-labs/pbt)](https://www.npmjs.com/package/@chiru-labs/pbt) + NFT collectors enjoy collecting digital assets and sharing them with others online. However, there is currently no such standard for showcasing physical assets as NFTs with verified authenticity and ownership. Existing solutions are fragmented and tend to be susceptible to at least one of the following: - The NFT cannot proxy as ownership of the physical item. In most current implementations, the NFT and physical item are functionally two decoupled distinct assets after the NFT mint, in which the NFT can be freely traded independently from the physical item. @@ -13,6 +15,26 @@ From the [Azuki](https://twitter.com/Azuki) team. Note: the frontend library for chip signatures can be found [here](https://github.com/chiru-labs/pbt-chip-client). +## Import Into Your Project + +``` +npm install @chiru-labs/pbt +``` + +### Foundry + +Add the following to your remappings.txt + +``` +pbt=node_modules/@chiru-labs/pbt/src +``` + +Can then import in your contracts + +``` +import "pbt/v2/PBTSimple.sol"; +``` + ## Resources - [pbt.io](https://www.pbt.io/) diff --git a/package-lock.json b/package-lock.json index a03ddbe..43b8bc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,28 +1,29 @@ { - "name": "pbt-repo", - "version": "0.1.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "pbt-repo", - "version": "0.1.0", - "license": "MIT", - "dependencies": { - "@openzeppelin/contracts": "^4.7.3" - } - }, - "node_modules/@openzeppelin/contracts": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.3.tgz", - "integrity": "sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==" - } + "name": "@chiru-labs/pbt", + "version": "0.3.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@chiru-labs/pbt", + "version": "0.3.0", + "license": "MIT", + "dependencies": { + "@chiru-labs/pbt": "^0.3.0" + } }, - "dependencies": { - "@openzeppelin/contracts": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.3.tgz", - "integrity": "sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==" - } + "node_modules/@chiru-labs/pbt": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@chiru-labs/pbt/-/pbt-0.3.0.tgz", + "integrity": "sha512-XCoMOweuV28GLgVuwocIdvc7O8hKCJMe5C6Ts2dXM76X6KBIHfN0qBeEgSWP9usOZgY6i0817bcErGIF6/40Gw==", + "dependencies": { + "@openzeppelin/contracts": "^4.7.3" + } + }, + "node_modules/@openzeppelin/contracts": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.6.tgz", + "integrity": "sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA==" } + } } diff --git a/package.json b/package.json index cdf18fc..61a7c4e 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,17 @@ { - "name": "@chiru-labs/pbt", - "version": "0.3.0", - "description": "Physically Backed Token Contracts in Solidity", - "main": "index.js", - "files": [ - "/src/**/*.sol" - ], - "dependencies": { - "@openzeppelin/contracts": "^4.7.3" - }, - "repository": { - "type": "git", - "url": "git@github.com-cygaar:chiru-labs/PBT.git" - }, - "author": "chiru-labs", - "license": "MIT" + "name": "@chiru-labs/pbt", + "version": "0.3.0", + "description": "Contracts for Physical Backed Tokens (ERC-5791). ", + "files": [ + "/src/**/*.sol" + ], + "repository": { + "type": "git", + "url": "git@github.com:chiru-labs/PBT.git" + }, + "author": "chiru-labs", + "license": "MIT", + "dependencies": { + "@chiru-labs/pbt": "^0.3.0" + } } From 9d3ae421a56c77336e2983b8a8348e6dc5572024 Mon Sep 17 00:00:00 2001 From: djdabs Date: Tue, 29 Oct 2024 19:52:03 -0700 Subject: [PATCH 3/3] feat: update README --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3b72569..3c73dd7 100644 --- a/README.md +++ b/README.md @@ -17,22 +17,16 @@ Note: the frontend library for chip signatures can be found [here](https://githu ## Import Into Your Project +### Hardhat + ``` npm install @chiru-labs/pbt ``` ### Foundry -Add the following to your remappings.txt - -``` -pbt=node_modules/@chiru-labs/pbt/src -``` - -Can then import in your contracts - ``` -import "pbt/v2/PBTSimple.sol"; +forge install https://github.com/chiru-labs/PBT ``` ## Resources