Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .spec/project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion TokenContract/manifest.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
41 changes: 31 additions & 10 deletions TokenContract/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Event,
OnEvent,
Address,
BeforeAll,
} from "@spec.dev/core";

/**
Expand All @@ -20,33 +19,55 @@ class TokenContract extends LiveTable {
@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 ===================

@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) {
this.contractAddress = event.origin.contractAddress;
this.name = event.data.name;
}

@OnEvent("station.ERC20.SymbolUpdated")
@OnEvent("station.ERC721.SymbolUpdated")
@OnEvent("station.ERC1155.SymbolUpdated")
onSymbolUpdated(event: Event) {
this.contractAddress = event.origin.contractAddress;
this.symbol = event.data.symbol;
}
}

Expand Down