mirror of
https://github.com/gitgig-io/ragnar.git
synced 2026-05-04 03:01:24 -04:00
feat(Identity): implement IdentityUpdate event [32]
This commit is contained in:
@@ -79,6 +79,37 @@
|
||||
"name": "BatchMetadataUpdate",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "wallet",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "string",
|
||||
"name": "platformId",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "string",
|
||||
"name": "platformUserId",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "string",
|
||||
"name": "platformUsername",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "IdentityUpdate",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
|
||||
@@ -18,6 +18,13 @@ contract Identity is IIdentity, ERC721URIStorage {
|
||||
using Counters for Counters.Counter;
|
||||
Counters.Counter private _tokenIds;
|
||||
|
||||
event IdentityUpdate(
|
||||
address wallet,
|
||||
string platformId,
|
||||
string platformUserId,
|
||||
string platformUsername
|
||||
);
|
||||
|
||||
string constant MSGPREFIX = "\x19Ethereum Signed Message:\n";
|
||||
|
||||
bytes4 internal constant MAGICVALUE = 0x1626ba7e;
|
||||
@@ -80,7 +87,12 @@ contract Identity is IIdentity, ERC721URIStorage {
|
||||
|
||||
walletForPlatformUser[_platformId][_platformUserId] = _userAddress;
|
||||
|
||||
// TODO: emit wallet association event
|
||||
emit IdentityUpdate(
|
||||
_userAddress,
|
||||
_platformId,
|
||||
_platformUserId,
|
||||
_platformUsername
|
||||
);
|
||||
}
|
||||
|
||||
function getTokenURI(string memory platformId, uint256 tokenId)
|
||||
|
||||
@@ -31,6 +31,16 @@ describe("Identity", () => {
|
||||
expect(txn.hash).to.be.a.string;
|
||||
});
|
||||
|
||||
it("should emit an IdentityUpdate event", async () => {
|
||||
// given
|
||||
const { identity, signer, user } = await identityFixture();
|
||||
const params = [user.address, "1", "123", "coder1"];
|
||||
const signature = await mintSignature(params, signer);
|
||||
|
||||
// when/then
|
||||
expect(await identity.mint(params[0], params[1], params[2], params[3], signature)).to.emit(identity, "IdentityUpdate").withArgs(params);
|
||||
});
|
||||
|
||||
it("fails to mint identity NFT with invalid signature", async () => {
|
||||
const { identity, user } = await identityFixture();
|
||||
const params = [user.address, "1", "123", "coder1"];
|
||||
|
||||
Reference in New Issue
Block a user