Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
klkgraph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
klkgraph
Commits
1012057f
Commit
1012057f
authored
Mar 17, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add token owners
parent
6cf4c21f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
schema.ts
generated/schema.ts
+10
-10
schema.graphql
schema.graphql
+1
-1
drago.ts
src/drago.ts
+1
-1
No files found.
generated/schema.ts
View file @
1012057f
...
@@ -525,9 +525,9 @@ export class Minted extends Entity {
...
@@ -525,9 +525,9 @@ export class Minted extends Entity {
// add a entity to store token id to owner, id use token id, and owner use address.
// add a entity to store token id to owner, id use token id, and owner use address.
export
class
TokenOwner
extends
Entity
{
export
class
TokenOwner
extends
Entity
{
constructor
(
id
:
BigInt
)
{
constructor
(
id
:
string
)
{
super
();
super
();
this
.
set
(
"
id
"
,
Value
.
from
BigInt
(
id
));
this
.
set
(
"
id
"
,
Value
.
from
String
(
id
));
}
}
save
():
void
{
save
():
void
{
...
@@ -535,28 +535,28 @@ export class TokenOwner extends Entity {
...
@@ -535,28 +535,28 @@ export class TokenOwner extends Entity {
assert
(
id
!=
null
,
"
Cannot save TokenOwner entity without an ID
"
);
assert
(
id
!=
null
,
"
Cannot save TokenOwner entity without an ID
"
);
if
(
id
)
{
if
(
id
)
{
assert
(
assert
(
id
.
kind
==
ValueKind
.
BIGINT
,
id
.
kind
==
ValueKind
.
STRING
,
`Entities of type TokenOwner must have an ID of type
BigInt
but the id '
${
id
.
displayData
()}
' is of type
${
id
.
displayKind
()}
`
,
`Entities of type TokenOwner must have an ID of type
string
but the id '
${
id
.
displayData
()}
' is of type
${
id
.
displayKind
()}
`
,
);
);
store
.
set
(
"
TokenOwner
"
,
id
.
toString
(),
this
);
store
.
set
(
"
TokenOwner
"
,
id
.
toString
(),
this
);
}
}
}
}
static
load
(
id
:
BigInt
):
TokenOwner
|
null
{
static
load
(
id
:
string
):
TokenOwner
|
null
{
return
changetype
<
TokenOwner
|
null
>
(
store
.
get
(
"
TokenOwner
"
,
id
.
toString
()
));
return
changetype
<
TokenOwner
|
null
>
(
store
.
get
(
"
TokenOwner
"
,
id
));
}
}
get
id
():
BigInt
{
get
id
():
string
{
let
value
=
this
.
get
(
"
id
"
);
let
value
=
this
.
get
(
"
id
"
);
if
(
!
value
||
value
.
kind
==
ValueKind
.
NULL
)
{
if
(
!
value
||
value
.
kind
==
ValueKind
.
NULL
)
{
throw
new
Error
(
"
Cannot return null for a required field.
"
);
throw
new
Error
(
"
Cannot return null for a required field.
"
);
}
else
{
}
else
{
return
value
.
to
BigInt
();
return
value
.
to
String
();
}
}
}
}
set
id
(
value
:
BigInt
)
{
set
id
(
value
:
string
)
{
this
.
set
(
"
id
"
,
Value
.
from
BigInt
(
value
));
this
.
set
(
"
id
"
,
Value
.
from
String
(
value
));
}
}
get
owner
():
Bytes
{
get
owner
():
Bytes
{
...
...
schema.graphql
View file @
1012057f
...
@@ -42,7 +42,7 @@ type ApprovalForAll @entity(immutable: true) {
...
@@ -42,7 +42,7 @@ type ApprovalForAll @entity(immutable: true) {
//
add
TokenOwner
entity
//
add
TokenOwner
entity
type
TokenTransfer
@
entity
(
immutable
:
true
)
{
type
TokenTransfer
@
entity
(
immutable
:
true
)
{
id
:
BigInt
!
id
:
string
!
owner
:
Bytes
!
#address
owner
:
Bytes
!
#address
tokenId
:
BigInt
!
# uint256
tokenId
:
BigInt
!
# uint256
}
}
\ No newline at end of file
src/drago.ts
View file @
1012057f
...
@@ -26,7 +26,7 @@ export function handleTransfer(event: TransferEvent): void {
...
@@ -26,7 +26,7 @@ export function handleTransfer(event: TransferEvent): void {
entity
.
save
()
entity
.
save
()
// update TokenOwner
// update TokenOwner
if
(
true
)
{
if
(
true
)
{
let
ownerEntity
=
new
TokenOwner
(
event
.
params
.
tokenId
)
let
ownerEntity
=
new
TokenOwner
(
event
.
params
.
tokenId
.
toString
()
)
ownerEntity
.
owner
=
event
.
params
.
to
ownerEntity
.
owner
=
event
.
params
.
to
ownerEntity
.
tokenId
=
event
.
params
.
tokenId
ownerEntity
.
tokenId
=
event
.
params
.
tokenId
ownerEntity
.
save
()
ownerEntity
.
save
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment