diff --git a/abi/contracts/Identity.sol/Identity.json b/abi/contracts/Identity.sol/Identity.json index c393322..ad254fd 100644 --- a/abi/contracts/Identity.sol/Identity.json +++ b/abi/contracts/Identity.sol/Identity.json @@ -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": [ diff --git a/contracts/Identity.sol b/contracts/Identity.sol index 8bb4f5d..d4574f6 100644 --- a/contracts/Identity.sol +++ b/contracts/Identity.sol @@ -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) diff --git a/test/Identity.ts b/test/Identity.ts index 70aa9ab..a7d4c4f 100644 --- a/test/Identity.ts +++ b/test/Identity.ts @@ -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"];