Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

events_filetest.gno

2.65 Kb · 119 lines
  1// PKGPATH: gno.land/r/akkadia/beta/abt_events
  2package abt_events
  3
  4import (
  5	"testing"
  6
  7	"gno.land/p/nt/testutils/v0"
  8	"gno.land/r/akkadia/beta/abt"
  9	"gno.land/r/akkadia/beta/admin"
 10)
 11
 12func main(cur realm) {
 13	caller := testutils.TestAddress("abtEventAdmin")
 14	testing.SetOriginCaller(admin.GetAdmin())
 15	testing.SetRealm(testing.NewUserRealm(admin.GetAdmin()))
 16	admin.TransferAdmin(cross(cur), caller)
 17	testing.SetOriginCaller(caller)
 18	testing.SetRealm(testing.NewUserRealm(caller))
 19	admin.AcceptAdmin(cross(cur))
 20	abt.Mint(cross(cur), caller, 10)
 21	abt.SetFrozen(cross(cur), true) // No event for the initial value.
 22	abt.SetFrozen(cross(cur), false)
 23	abt.SetFrozen(cross(cur), false) // No duplicate event.
 24	abt.SetFrozen(cross(cur), true)
 25	println(abt.TotalSupply(), abt.IsFrozen())
 26}
 27
 28// Output:
 29// 10 true
 30
 31// Events:
 32// [
 33//   {
 34//     "type": "TransferAdmin",
 35//     "attrs": [
 36//       {
 37//         "key": "from",
 38//         "value": ""
 39//       },
 40//       {
 41//         "key": "to",
 42//         "value": "g1v938g3tkv4h8gstyd45kuh6lta047h6lx2s576"
 43//       }
 44//     ],
 45//     "pkg_path": "gno.land/r/akkadia/beta/admin"
 46//   },
 47//   {
 48//     "type": "AcceptAdmin",
 49//     "attrs": [
 50//       {
 51//         "key": "from",
 52//         "value": ""
 53//       },
 54//       {
 55//         "key": "to",
 56//         "value": "g1v938g3tkv4h8gstyd45kuh6lta047h6lx2s576"
 57//       }
 58//     ],
 59//     "pkg_path": "gno.land/r/akkadia/beta/admin"
 60//   },
 61//   {
 62//     "type": "Transfer",
 63//     "attrs": [
 64//       {
 65//         "key": "token",
 66//         "value": "gno.land/r/akkadia/beta/abt.abt.0000000"
 67//       },
 68//       {
 69//         "key": "from",
 70//         "value": ""
 71//       },
 72//       {
 73//         "key": "to",
 74//         "value": "g1v938g3tkv4h8gstyd45kuh6lta047h6lx2s576"
 75//       },
 76//       {
 77//         "key": "value",
 78//         "value": "10"
 79//       }
 80//     ],
 81//     "pkg_path": "gno.land/p/nt/grc20/v0"
 82//   },
 83//   {
 84//     "type": "FrozenChanged",
 85//     "attrs": [
 86//       {
 87//         "key": "executor",
 88//         "value": "g1v938g3tkv4h8gstyd45kuh6lta047h6lx2s576"
 89//       },
 90//       {
 91//         "key": "previous",
 92//         "value": "true"
 93//       },
 94//       {
 95//         "key": "frozen",
 96//         "value": "false"
 97//       }
 98//     ],
 99//     "pkg_path": "gno.land/r/akkadia/beta/abt"
100//   },
101//   {
102//     "type": "FrozenChanged",
103//     "attrs": [
104//       {
105//         "key": "executor",
106//         "value": "g1v938g3tkv4h8gstyd45kuh6lta047h6lx2s576"
107//       },
108//       {
109//         "key": "previous",
110//         "value": "false"
111//       },
112//       {
113//         "key": "frozen",
114//         "value": "true"
115//       }
116//     ],
117//     "pkg_path": "gno.land/r/akkadia/beta/abt"
118//   }
119// ]