Class: ERC721
- Inherits:
-
Contract
show all
- Defined in:
- lib/rubysol/contracts/erc721.rb
Instance Method Summary
collapse
Instance Method Details
#_burn(id:) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/rubysol/contracts/erc721.rb', line 104
def _burn( id: )
owner = @_ownerOf[id]
assert owner != address(0), "ERC721: burn of nonexistent token"
@_balanceOf[owner] -= 1
@_ownerOf[id] = address(0)
@getApproved[id] = address(0)
log Transfer, from: owner, to: address(0), id: id
end
|
#_exists(id) ⇒ Object
86
87
88
|
# File 'lib/rubysol/contracts/erc721.rb', line 86
def _exists( id )
@_ownerOf[id] != address(0)
end
|
#_mint(to:, id:) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/rubysol/contracts/erc721.rb', line 91
def _mint( to:,
id: )
assert to != address(0), "ERC721: mint to the zero address"
assert @_ownerOf[id] == address(0), "ERC721: token already minted"
@_balanceOf[to] += 1
@_ownerOf[id] = to
log Transfer, from: address(0), to: to, id: id
end
|
#approve(spender:, id:) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rubysol/contracts/erc721.rb', line 44
def approve( spender:,
id: )
owner = @_ownerOf[id]
assert msg.sender == owner || @isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"
@getApproved[id] = spender;
log Approval, owner: owner, spender: spender, id: id
end
|
#balanceOf(owner:) ⇒ Object
37
38
39
40
41
|
# File 'lib/rubysol/contracts/erc721.rb', line 37
def balanceOf( owner: )
assert owner != address(0), "ERC721: balance query for nonexistent owner"
@_balanceOf[owner]
end
|
#constructor(name:, symbol:) ⇒ Object
21
22
23
24
25
|
# File 'lib/rubysol/contracts/erc721.rb', line 21
def constructor( name:,
symbol: )
@name = name
@symbol = symbol
end
|
#ownerOf(id) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/rubysol/contracts/erc721.rb', line 29
def ownerOf( id )
owner = @_ownerOf[id]
assert owner != address(0), "ERC721: owner query for nonexistent token"
owner
end
|
#setApprovalForAll(operator:, approved:) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/rubysol/contracts/erc721.rb', line 56
def setApprovalForAll( operator:,
approved: )
@isApprovedForAll[msg.sender][operator] = approved;
log ApprovalForAll, owner: msg.sender, operator: operator, approved: approved
end
|
#tokenURI(id:) ⇒ Object
119
120
|
# File 'lib/rubysol/contracts/erc721.rb', line 119
def tokenURI( id: )
end
|
#transferFrom(from:, to:, id:) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/rubysol/contracts/erc721.rb', line 64
def transferFrom( from:,
to:,
id: )
assert from == @_ownerOf[id], "ERC721: transfer of token that is not own"
assert to != address(0), "ERC721: transfer to the zero address"
assert(
msg.sender == from ||
@getApproved[id] == msg.sender ||
@isApprovedForAll[from][msg.sender],
"NOT_AUTHORIZED"
)
@_balanceOf[from] -= 1
@_balanceOf[to] += 1
@_ownerOf[id] = to
@getApproved[id] = address(0)
end
|