Skip to content

Commit 137ef53

Browse files
committed
preparation package
1 parent ff88064 commit 137ef53

5 files changed

Lines changed: 83 additions & 9 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ cache
55
artifacts
66

77
.env*
8-
!.env.SAMPLE
8+
!.env.SAMPLE
9+
10+
11+
dist/*
12+
!dist/package.json

contracts/SignedAllowance.sol

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,30 @@ contract SignedAllowance {
6262
uint256 nonce,
6363
bytes memory signature
6464
) public view returns (bytes32) {
65+
return
66+
_validateSignature(account, nonce, signature, allowancesSigner());
67+
}
68+
69+
/// @dev It ensures that signer signed a message containing (account, nonce, address(this))
70+
/// and that this message was not already used
71+
/// @param account the account the allowance is associated to
72+
/// @param nonce the nonce associated to this allowance
73+
/// @param signature the signature by the allowance signer wallet
74+
/// @param signer the signer
75+
/// @return the message to mark as used
76+
function _validateSignature(
77+
address account,
78+
uint256 nonce,
79+
bytes memory signature,
80+
address signer
81+
) internal view returns (bytes32) {
6582
bytes32 message = createMessage(account, nonce)
6683
.toEthSignedMessageHash();
6784

68-
// verifies that the sha3(account, nonce, address(this)) has been signed by _allowancesSigner
69-
require(
70-
message.recover(signature) == allowancesSigner(),
71-
'!INVALID_SIGNATURE!'
72-
);
85+
// verifies that the sha3(account, nonce, address(this)) has been signed by signer
86+
require(message.recover(signature) == signer, '!INVALID_SIGNATURE!');
87+
88+
// verifies that the allowances was not already used
7389
require(usedAllowances[message] == false, '!ALREADY_USED!');
7490

7591
return message;

dist/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@dievardump-web3/signed-allowances",
3+
"description": "Package to import and use the contracts of NiftyForge.io",
4+
"version": "0.0.0",
5+
"files": [
6+
"build/**/*",
7+
"contracts/**/*",
8+
"deploy/**/*",
9+
"deployments/**/*",
10+
"!contracts/mocks/**/*"
11+
],
12+
"scripts": {
13+
"prepare": "bash ../scripts/package/prepare.sh",
14+
"test": "echo \"No test specified\""
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/dievardump/signed-minting.git"
19+
},
20+
"keywords": [
21+
"solidity",
22+
"ethereum",
23+
"smart",
24+
"contracts",
25+
"security",
26+
"niftyforge"
27+
],
28+
"author": "dievardump (Simon Fremaux) <dievardump@gmail.com>",
29+
"license": "MIT",
30+
"bugs": {
31+
"url": "https://github.com/dievardump/signed-minting/issues"
32+
},
33+
"homepage": "https://github.com/dievardump/signed-minting/",
34+
"publishConfig": {
35+
"access": "public"
36+
},
37+
"devDependencies": {
38+
"@openzeppelin/contracts": "^4.3.2"
39+
}
40+
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "genuinehumann-contract",
2+
"name": "signed-allowances",
33
"version": "0.0.1",
4-
"description": "Genuine Human contracts",
4+
"description": "SignedAllowances in Solidity (or off-chain Allow list)",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
@@ -25,4 +25,4 @@
2525
"hardhat-tracer": "*",
2626
"minimist": "^1.2.5"
2727
}
28-
}
28+
}

scripts/package/prepare.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
shopt -s globstar
5+
6+
# cd to the root of the repo
7+
cd "$(git rev-parse --show-toplevel)"
8+
9+
# clean
10+
rm -rf dist/contracts
11+
12+
# contracts
13+
cp -r contracts dist/contracts
14+
rm -rf dist/contracts/mocks

0 commit comments

Comments
 (0)