From db5088e5683ae753e8f17f47fc27fe6479beab94 Mon Sep 17 00:00:00 2001 From: Conner Swenberg Date: Fri, 17 Nov 2023 14:53:03 -0500 Subject: [PATCH 1/3] Add token name and symbol to TokenContract --- TokenContract/spec.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/TokenContract/spec.ts b/TokenContract/spec.ts index 01e525c..cfaed10 100644 --- a/TokenContract/spec.ts +++ b/TokenContract/spec.ts @@ -20,9 +20,17 @@ class TokenContract extends LiveObject { @Property() contractAddress: Address; - // The "type" of token contract. + // The ERC standard of token contract. One of "ERC20", "ERC721", or "ERC1155". @Property() tokenStandard: string; + + // The name of token contract. + @Property() + name: string; + + // The symbol of token contract. + @Property() + symbol: string; // ==== Event Handlers =================== @@ -48,6 +56,21 @@ class TokenContract extends LiveObject { this.tokenStandard = "ERC1155"; this.addContractToGroup(event.data.token, "station.ERC1155"); } + + @OnEvent("station.ERC20.NameUpdated") + @OnEvent("station.ERC721.NameUpdated") + @OnEvent("station.ERC1155.NameUpdated") + onNameUpdated(event: Event) { + this.name = event.data.name; + } + + @OnEvent("station.ERC20.SymbolUpdated") + @OnEvent("station.ERC721.SymbolUpdated") + @OnEvent("station.ERC1155.SymbolUpdated") + onSymbolUpdated(event: Event) { + this.symbol = event.data.symbol; + } + } export default TokenContract; From 14a533ee0226407db8c063655e5f5713d675010f Mon Sep 17 00:00:00 2001 From: Conner Swenberg Date: Fri, 17 Nov 2023 14:55:37 -0500 Subject: [PATCH 2/3] Add question comment --- TokenContract/spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TokenContract/spec.ts b/TokenContract/spec.ts index cfaed10..f23871d 100644 --- a/TokenContract/spec.ts +++ b/TokenContract/spec.ts @@ -61,6 +61,7 @@ class TokenContract extends LiveObject { @OnEvent("station.ERC721.NameUpdated") @OnEvent("station.ERC1155.NameUpdated") onNameUpdated(event: Event) { + // how do I map `this` to the token contract that matches the (chainId, contractAddress) uniqueBy with the event.origin? this.name = event.data.name; } @@ -68,6 +69,7 @@ class TokenContract extends LiveObject { @OnEvent("station.ERC721.SymbolUpdated") @OnEvent("station.ERC1155.SymbolUpdated") onSymbolUpdated(event: Event) { + // how do I map `this` to the token contract that matches the (chainId, contractAddress) uniqueBy with the event.origin? this.symbol = event.data.symbol; } From 0d1cd171203824525dea7231b02fb0ebac96523d Mon Sep 17 00:00:00 2001 From: Ben Whittle Date: Tue, 19 Dec 2023 20:01:15 -0600 Subject: [PATCH 3/3] update name/symbol of TokenContract and bump versions --- .spec/project.toml | 2 +- TokenContract/manifest.json | 2 +- TokenContract/spec.ts | 20 ++++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.spec/project.toml b/.spec/project.toml index 223a286..08cefa7 100644 --- a/.spec/project.toml +++ b/.spec/project.toml @@ -7,7 +7,7 @@ id = 'station.Membership@0.0.1' id = 'station.PointsBalance@0.0.1' [objects.TokenContract] -id = 'station.TokenContract@0.0.1' +id = 'station.TokenContract@0.0.2' [objects.Erc20Owner] id = 'station.Erc20Owner@0.0.1' diff --git a/TokenContract/manifest.json b/TokenContract/manifest.json index 4ebebff..35cc9a7 100644 --- a/TokenContract/manifest.json +++ b/TokenContract/manifest.json @@ -1,7 +1,7 @@ { "namespace": "station", "name": "TokenContract", - "version": "0.0.1", + "version": "0.0.2", "displayName": "Token contract", "description": "A contract deployed on Station's 0xRails framework.", "chains": [ diff --git a/TokenContract/spec.ts b/TokenContract/spec.ts index 6b0b133..2456d28 100644 --- a/TokenContract/spec.ts +++ b/TokenContract/spec.ts @@ -5,7 +5,6 @@ import { Event, OnEvent, Address, - BeforeAll, } from "@spec.dev/core"; /** @@ -34,34 +33,32 @@ class TokenContract extends LiveTable { // ==== Event Handlers =================== - @BeforeAll() - setCommonProperties(event: Event) { - this.contractAddress = event.data.token; - } - @OnEvent("station.TokenFactory.ERC20Created") onErc20Created(event: Event) { + this.contractAddress = event.data.token; this.tokenStandard = "ERC20"; - this.addContractToGroup(event.data.token, "station.ERC20"); + this.addContractToGroup(this.contractAddress, "station.ERC20"); } @OnEvent("station.TokenFactory.ERC721Created") onErc721Created(event: Event) { + this.contractAddress = event.data.token; this.tokenStandard = "ERC721"; - this.addContractToGroup(event.data.token, "station.ERC721"); + this.addContractToGroup(this.contractAddress, "station.ERC721"); } @OnEvent("station.TokenFactory.ERC1155Created") onErc1155Created(event: Event) { + this.contractAddress = event.data.token; this.tokenStandard = "ERC1155"; - this.addContractToGroup(event.data.token, "station.ERC1155"); + this.addContractToGroup(this.contractAddress, "station.ERC1155"); } @OnEvent("station.ERC20.NameUpdated") @OnEvent("station.ERC721.NameUpdated") @OnEvent("station.ERC1155.NameUpdated") onNameUpdated(event: Event) { - // how do I map `this` to the token contract that matches the (chainId, contractAddress) uniqueBy with the event.origin? + this.contractAddress = event.origin.contractAddress; this.name = event.data.name; } @@ -69,10 +66,9 @@ class TokenContract extends LiveTable { @OnEvent("station.ERC721.SymbolUpdated") @OnEvent("station.ERC1155.SymbolUpdated") onSymbolUpdated(event: Event) { - // how do I map `this` to the token contract that matches the (chainId, contractAddress) uniqueBy with the event.origin? + this.contractAddress = event.origin.contractAddress; this.symbol = event.data.symbol; } - } export default TokenContract;