Skip to content

Commit

Permalink
fixed single use tokens, added metadata, & expanded grant options
Browse files Browse the repository at this point in the history
  • Loading branch information
tenfinney committed Aug 22, 2022
1 parent edc39c2 commit 192a044
Show file tree
Hide file tree
Showing 41 changed files with 3,211 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
"contractName": "OwnableUpgradeable",
"sourceName": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
"name": "BeaconUpgraded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
"_format": "hh-sol-artifact-1",
"contractName": "Initializable",
"sourceName": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol",
"abi": [],
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
"name": "BeaconUpgraded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"contractName": "AddressUpgradeable",
"sourceName": "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol",
"abi": [],
"bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b7c68143be798dcc3502756094a8cfa27a2fc78614fe179c0aa10b66e2c9643b64736f6c63430008040033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b7c68143be798dcc3502756094a8cfa27a2fc78614fe179c0aa10b66e2c9643b64736f6c63430008040033",
"bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ef3c0377b35626a5d71db14a8e527f5fcc0d25c0a6ede5e6ef0792c0ca51648864736f6c63430008040033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ef3c0377b35626a5d71db14a8e527f5fcc0d25c0a6ede5e6ef0792c0ca51648864736f6c63430008040033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
"_format": "hh-sol-artifact-1",
"contractName": "ContextUpgradeable",
"sourceName": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol",
"abi": [],
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"contractName": "StorageSlotUpgradeable",
"sourceName": "@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol",
"abi": [],
"bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220377662b7f63ba38eaa201a6f4ed5173690b32bc2a4d5c7db2228cfafbbf3dfb664736f6c63430008040033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220377662b7f63ba38eaa201a6f4ed5173690b32bc2a4d5c7db2228cfafbbf3dfb664736f6c63430008040033",
"bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fbbdb3577a6c6a1c93e30d277e1e059466adcf2a81816cb1d847df259786bb6464736f6c63430008040033",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fbbdb3577a6c6a1c93e30d277e1e059466adcf2a81816cb1d847df259786bb6464736f6c63430008040033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
"contractName": "ERC165Upgradeable",
"sourceName": "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"inputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/artifacts/polygon/Bits.address
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x47F35fffD437f599574109260aC0938734280C1a
0x6c8144cC9d97E84b3069b22487A0CD6C89f17195

Large diffs are not rendered by default.

Large diffs are not rendered by default.

49 changes: 44 additions & 5 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ task('mint', 'Mint a token for a user')
console.debug(`Found contract at address: ${address}`)

const contract = (
new ethers.Contract(address , abi, ethers.provider.getSigner())
new ethers.Contract(address, abi, ethers.provider.getSigner())
)
const tx = await contract['mint(address,uint256,uint256,bytes)'](
args.address, args.tokenId, 1, [],
Expand All @@ -180,9 +180,48 @@ task('mint', 'Mint a token for a user')

})

task('setMax', 'Set maximum mintable allowance.')
.addParam('token', 'Id of the token to alter')
.addParam('max', 'Maximum allowed to mint (negative value for no limit)')
.setAction(async (args, { ethers }) => {
const [, srcDir] = config?.paths?.sources?.match(/^.*?\/?([^\/]+)\/?$/) ?? []
if (!srcDir) throw new Error('ERROR - could not find source directory')
const contractsHome = `${config?.paths?.artifacts}/${srcDir}/`
const [contractFile] = (
glob
.sync(`${contractsHome}/*/Bulk*`)
.filter((name) => !/\.dbg\.json$/.test(name))
)

const { abi, contractName } = JSON.parse(
fs.readFileSync(contractFile).toString()
)
console.debug(
` 🦐 Loaded ${chalk.hex('#88C677')(contractName)} From:`
+ ` ${chalk.hex('#E59AF9')(contractFile)}`
)

const address = (
fs.readFileSync(
`${config?.paths?.artifacts}/${contractName}.address`
)
.toString()
.trim()
)

const contract = (
new ethers.Contract(address, abi, ethers.provider.getSigner())
)
const tx = await contract.setMax(deregexify(args.token), args.max)
await tx.wait()

console.info(`Set max to ${chalk.hex('#ff0000')(args.max)} for ${chalk.hex('00ff00')(args.token)}`)
})

task('grant', 'Grant a role')
.addParam('address', 'Address of the user to promote')
.addParam('role', 'Role to grant')
.addFlag('singleUse', 'Token may be used only once.')
.addOptionalParam('token', 'Token id to grant for')
.setAction(async (args, { ethers }) => {
const srcDir = config?.paths?.sources
Expand All @@ -209,10 +248,10 @@ task('grant', 'Grant a role')
.toString()
.trim()
)
let { address: user, role, token } = args
let { address: user, role, token, singleUse } = args
console.log(
` 🍏 Setting ${chalk.hex('#E1A47B')(user)}`
+ ` as ${chalk.hex('#5AE1AD')(role)}`
+ ` as ${singleUse ? '(single use) ' : ''}${chalk.hex('#5AE1AD')(role)}`
+ ` on ${chalk.hex('#E16464')(contractName)}`
+ ` at ${chalk.hex('#DD5FE1')(address)}`
+ (token ? ` for id:${chalk.hex('#E11F83')(token)}` : '')
Expand Down Expand Up @@ -247,9 +286,9 @@ task('grant', 'Grant a role')
if(roleId === 0) throw new Error(`Can’t find “${role}”`)
let tx
if(token) {
tx = await contract['grantRole(uint8,address,uint256)'](roleId, user, token)
tx = await contract['grantRole(uint8,address,uint256,bool)'](roleId, user, token, !!args.singleUse)
} else {
tx = await contract['grantRole(uint8,address)'](roleId, user)
tx = await contract['grantRole(uint8,address,bool)'](roleId, user, !!args.singleUse)
}
console.info(` 🕋 Tx: ${tx.hash}`)
})
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/metadata/assets/compass.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 192a044

Please sign in to comment.