Instantly share code, notes, and snippets.
Save moul/113c2cc8bb27ce80969995192ddb4c7f to your computer and use it in GitHub Desktop.
txtar linguist mode comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnolandstart | |
| # add registry | |
| gnokeymaketxaddpkg-pkgdir$WORK/registry-pkgpathgno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'not found' | |
| # add foo20, and foo20wrapper | |
| gnokeymaketxaddpkg-pkgdir$WORK/foo20-pkgpathgno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| gnokeymaketxaddpkg-pkgdir$WORK/foo20wrapper-pkgpathgno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'same address, success!' | |
| --registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct {namestring;cbtransferCb} | |
| varregistry= []pair{} | |
| funcRegister(namestring,cbtransferCb) {registry=append(registry,pair{name:name,cb:cb}) } | |
| funcTransferByName(namestring,tostring,amountuint64)string { | |
| for_,pair :=rangeregistry { | |
| ifpair.name==name { | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+std.CurrentRealm().Addr().String()+" "+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno-- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| packagefoo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64)string { | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg -pkgdir $WORK/registry -pkgpath gno.land/r/registry -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import "std" | |
| type transferCb func(to std.Address, amount uint64) string | |
| type pair struct {name string; cb transferCb} | |
| var registry = []pair{} | |
| func Register(name string, cb transferCb) { registry = append(registry, pair{name: name, cb: cb}) } | |
| func TransferByName(name string, to string, amount uint64) string { | |
| for _, pair := range registry { | |
| if pair.name == name { | |
| if std.CurrentRealm().Addr().String() == pair.cb(std.Address(to), amount) { | |
| return "same address, success!" | |
| } else { | |
| return "invalid address, ownership issue :(" | |
| } | |
| return "registry=" + std.CurrentRealm().Addr().String() + " " + pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return "not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import "gno.land/r/registry" | |
| import "gno.land/r/foo20" | |
| func init() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import "std" | |
| func Transfer(to std.Address, amount uint64) string { | |
| println("transfer from=" + std.PrevRealm().Addr().String() + " to=" + to.String() + " some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # testfor add package | |
| ## start anew node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg -pkgdir $WORK/registry -pkgpath gno.land/r/registry -gas-fee 1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee 1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'not found' | |
| # add foo20,and foo20wrapper | |
| gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee 1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import"std" | |
| type transferCbfunc(to std.Address, amount uint64) string | |
| type pair struct {name string; cb transferCb} | |
| var registry = []pair{} | |
| funcRegister(name string, cb transferCb) { registry =append(registry, pair{name: name, cb: cb}) } | |
| funcTransferByName(name string, to string, amount uint64) string { | |
| for _, pair := range registry { | |
| if pair.name == name { | |
| if std.CurrentRealm().Addr().String() == pair.cb(std.Address(to), amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry=" + std.CurrentRealm().Addr().String() +"" + pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import"std" | |
| funcTransfer(to std.Address, amount uint64) string { | |
| println("transfer from=" + std.PrevRealm().Addr().String() +" to=" + to.String() +" some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #testfor add package | |
| ## start anew node | |
| gnoland start | |
| #add registry | |
| gnokey maketxaddpkg-pkgdir $WORK/registry-pkgpath gno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| # we call Transferwith foo20, before it's registered | |
| gnokey maketx call-pkgpath gno.land/r/registry-func TransferByName-args 'foo20'-args 'g123456789'-args '42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| stdout 'not found' | |
| #add foo20, and foo20wrapper | |
| gnokey maketx addpkg-pkgdir $WORK/foo20-pkgpath gno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| gnokey maketx addpkg-pkgdir $WORK/foo20wrapper-pkgpath gno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| # we call Transferwith foo20, after it's registered | |
| gnokey maketx call-pkgpath gno.land/r/registry-func TransferByName-args 'foo20'-args 'g123456789'-args '42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| stdout 'same address, success!' | |
| -- registry/registry.gno-- | |
| package registry | |
| import "std" | |
| type transferCb func(to std.Address, amount uint64)string | |
| type pairstruct{namestring; cb transferCb} | |
| var registry=[]pair{} | |
| func Register(namestring,cbtransferCb){registry=append(registry,pair{name:name,cb:cb})} | |
| func TransferByName(namestring,tostring,amountuint64) string{ | |
| for _,pair:=range registry{ | |
| ifpair.name==name{ | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount){ | |
| return "same address, success!" | |
| }else{ | |
| return "invalid address, ownership issue:(" | |
| } | |
| return "registry="+std.CurrentRealm().Addr().String()+ " "+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return "notfound" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno-- | |
| package foo20wrapper | |
| import"gno.land/r/registry" | |
| import "gno.land/r/foo20" | |
| func init(){ | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| package foo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64) string{ | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #testforaddpackage | |
| ##startanewnode | |
| gnolandstart | |
| #addregistry | |
| gnokeymaketxaddpkg-pkgdir $WORK/registry-pkgpathgno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,beforeit'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args 'foo20'-args 'g123456789'-args '42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout 'notfound' | |
| #addfoo20,andfoo20wrapper | |
| gnokeymaketxaddpkg-pkgdir $WORK/foo20-pkgpathgno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| gnokeymaketxaddpkg-pkgdir $WORK/foo20wrapper-pkgpathgno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,afterit'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args 'foo20'-args 'g123456789'-args '42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout 'sameaddress,success!' | |
| --registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(to std.Address,amountuint64)string | |
| typepairstruct {namestring;cbtransferCb} | |
| varregistry= []pair{} | |
| funcRegister(namestring,cbtransferCb) {registry=append(registry,pair{name:name,cb:cb}) } | |
| funcTransferByName(namestring,tostring,amountuint64)string { | |
| for_,pair:=rangeregistry { | |
| ifpair.name==name { | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+std.CurrentRealm().Addr().String()+" "+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno-- | |
| package foo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| package foo20 | |
| import"std" | |
| funcTransfer(to std.Address,amountuint64)string { | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg-pkgdir$WORK/registry-pkgpath gno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call-pkgpath gno.land/r/registry-funcTransferByName-args 'foo20'-args 'g123456789'-args '42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| stdout 'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg-pkgdir$WORK/foo20-pkgpath gno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| gnokey maketx addpkg-pkgdir$WORK/foo20wrapper-pkgpath gno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call-pkgpath gno.land/r/registry-funcTransferByName-args 'foo20'-args 'g123456789'-args '42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_test test1 | |
| stdout 'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import "std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct {namestring;cbtransferCb} | |
| var registry=[]pair{} | |
| funcRegister(name string, cb transferCb) { registry= append(registry, pair{name: name, cb: cb}) } | |
| funcTransferByName(name string, to string, amount uint64) string { | |
| for _, pair:= range registry { | |
| if pair.name== name { | |
| if std.CurrentRealm().Addr().String()== pair.cb(std.Address(to), amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+ std.CurrentRealm().Addr().String()+""+ pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import "gno.land/r/registry" | |
| import "gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import "std" | |
| funcTransfer(to std.Address, amount uint64) string { | |
| println("transfer from="+ std.PrevRealm().Addr().String()+" to="+ to.String()+" some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #testforaddpackage | |
| ##startanewnode | |
| gnolandstart | |
| #addregistry | |
| gnokeymaketxaddpkg-pkgdir$WORK/registry-pkgpathgno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,beforeit'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'not found' | |
| #addfoo20,andfoo20wrapper | |
| gnokeymaketxaddpkg-pkgdir$WORK/foo20-pkgpathgno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| gnokeymaketxaddpkg-pkgdir$WORK/foo20wrapper-pkgpathgno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,afterit'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'same address, success!' | |
| --registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct{namestring;cbtransferCb} | |
| varregistry=[]pair{} | |
| funcRegister(namestring,cbtransferCb){registry=append(registry,pair{name:name,cb:cb})} | |
| funcTransferByName(namestring,tostring,amountuint64)string{ | |
| for_,pair :=rangeregistry{ | |
| ifpair.name==name{ | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount){ | |
| return"same address, success!" | |
| }else{ | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+std.CurrentRealm().Addr().String()+" "+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno-- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit(){ | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| packagefoo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64)string{ | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg -pkgdir $WORK/registry -pkgpath gno.land/r/registry -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import "std" | |
| type transferCb func(to std.Address, amount uint64) string | |
| type pair struct {name string; cb transferCb} | |
| var registry = []pair{} | |
| func Register(name string, cb transferCb) { registry = append(registry, pair{name: name, cb: cb}) } | |
| func TransferByName(name string, to string, amount uint64) string { | |
| for _, pair := range registry { | |
| if pair.name == name { | |
| if std.CurrentRealm().Addr().String() == pair.cb(std.Address(to), amount) { | |
| return "same address, success!" | |
| } else { | |
| return "invalid address, ownership issue :(" | |
| } | |
| return "registry=" + std.CurrentRealm().Addr().String() + " " + pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return "not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import "gno.land/r/registry" | |
| import "gno.land/r/foo20" | |
| func init() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import "std" | |
| func Transfer(to std.Address, amount uint64) string { | |
| println("transfer from=" + std.PrevRealm().Addr().String() + " to=" + to.String() + " some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #testforaddpackage | |
| ##startanewnode | |
| gnolandstart | |
| #addregistry | |
| gnokeymaketxaddpkg-pkgdir$WORK/registry-pkgpathgno.land/r/registry-gas-fee 1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,beforeit's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'notfound' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee 1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'same address, success!' | |
| --registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct {namestring;cbtransferCb} | |
| varregistry= []pair{} | |
| funcRegister(namestring,cbtransferCb) {registry=append(registry,pair{name:name,cb:cb}) } | |
| funcTransferByName(namestring,tostring,amountuint64)string { | |
| for_,pair :=rangeregistry { | |
| ifpair.name==name { | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+std.CurrentRealm().Addr().String()+""+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno-- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| packagefoo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64)string { | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnolandstart | |
| # add registry | |
| gnokey maketx addpkg -pkgdir$WORK/registry -pkgpath gno.land/r/registry -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir$WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir$WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'same address, success!' | |
| -- registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| type transferCb func(to std.Address, amountuint64) string | |
| typepair struct {name string; cb transferCb} | |
| var registry= []pair{} | |
| func Register(name string, cb transferCb) { registry=append(registry,pair{name:name, cb: cb}) } | |
| func TransferByName(name string,to string, amountuint64) string { | |
| for _,pair:= range registry { | |
| ifpair.name==name { | |
| if std.CurrentRealm().Addr().String()==pair.cb(std.Address(to), amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+ std.CurrentRealm().Addr().String()+""+pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno-- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| func init() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno-- | |
| packagefoo20 | |
| import"std" | |
| func Transfer(to std.Address, amountuint64) string { | |
| println("transfer from="+ std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnolandstart | |
| # add registry | |
| gnokeymaketxaddpkg-pkgdir $WORK/registry-pkgpathgno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'not found' | |
| # add foo20, and foo20wrapper | |
| gnokeymaketxaddpkg-pkgdir $WORK/foo20-pkgpathgno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| gnokeymaketxaddpkg-pkgdir $WORK/foo20wrapper-pkgpathgno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'same address, success!' | |
| --registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct {namestring;cbtransferCb} | |
| varregistry= []pair{} | |
| funcRegister(namestring,cbtransferCb) {registry=append(registry,pair{name:name,cb:cb}) } | |
| funcTransferByName(namestring,tostring,amountuint64)string { | |
| for_,pair :=rangeregistry { | |
| ifpair.name==name { | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+std.CurrentRealm().Addr().String()+" "+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno-- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| packagefoo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64)string { | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnolandstart | |
| # add registry | |
| gnokeymaketxaddpkg -pkgdir $WORK/registry -pkgpathgno.land/r/registry -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_testtest1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokeymaketxcall -pkgpathgno.land/r/registry -funcTransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_testtest1 | |
| stdout'not found' | |
| # add foo20, and foo20wrapper | |
| gnokeymaketxaddpkg -pkgdir $WORK/foo20 -pkgpathgno.land/r/foo20 -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_testtest1 | |
| gnokeymaketxaddpkg -pkgdir $WORK/foo20wrapper -pkgpathgno.land/r/foo20wrapper -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_testtest1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokeymaketxcall -pkgpathgno.land/r/registry -funcTransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee1000000ugnot -gas-wanted2000000 -broadcast -chainid=tendermint_testtest1 | |
| stdout'same address, success!' | |
| --registry/registry.gno -- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct{namestring;cbtransferCb} | |
| varregistry=[]pair{} | |
| funcRegister(namestring,cbtransferCb){registry=append(registry,pair{name:name,cb:cb})} | |
| funcTransferByName(namestring,tostring,amountuint64)string{ | |
| for_,pair :=rangeregistry{ | |
| ifpair.name ==name{ | |
| ifstd.CurrentRealm().Addr().String() ==pair.cb(std.Address(to),amount){ | |
| return"same address, success!" | |
| }else{ | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry=" +std.CurrentRealm().Addr().String() +" " +pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno -- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit(){ | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno -- | |
| packagefoo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64)string{ | |
| println("transfer from=" +std.PrevRealm().Addr().String() +" to=" +to.String() +" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg -pkgdir$WORK/registry -pkgpath gno.land/r/registry -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir$WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir$WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args'foo20' -args'g123456789' -args'42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import"std" | |
| type transferCb func(to std.Address, amount uint64) string | |
| type pair struct {name string; cb transferCb} | |
| var registry = []pair{} | |
| func Register(name string, cb transferCb) { registry = append(registry, pair{name: name, cb: cb}) } | |
| func TransferByName(name string, to string, amount uint64) string { | |
| for _, pair := range registry { | |
| if pair.name == name { | |
| ifstd.CurrentRealm().Addr().String() == pair.cb(std.Address(to), amount) { | |
| return"same address, success!" | |
| }else { | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry=" +std.CurrentRealm().Addr().String() +"" + pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import"std" | |
| func Transfer(to std.Address, amount uint64) string { | |
| println("transfer from=" +std.PrevRealm().Addr().String() +" to=" +to.String() +" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #testforaddpackage | |
| ##startanewnode | |
| gnolandstart | |
| #addregistry | |
| gnokeymaketxaddpkg-pkgdir$WORK/registry-pkgpathgno.land/r/registry-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,beforeit'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'not found' | |
| #addfoo20,andfoo20wrapper | |
| gnokeymaketxaddpkg-pkgdir$WORK/foo20-pkgpathgno.land/r/foo20-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| gnokeymaketxaddpkg-pkgdir$WORK/foo20wrapper-pkgpathgno.land/r/foo20wrapper-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| #wecallTransferwithfoo20,afterit'sregistered | |
| gnokeymaketxcall-pkgpathgno.land/r/registry-funcTransferByName-args'foo20'-args'g123456789'-args'42'-gas-fee1000000ugnot-gas-wanted2000000-broadcast-chainid=tendermint_testtest1 | |
| stdout'same address, success!' | |
| --registry/registry.gno-- | |
| packageregistry | |
| import"std" | |
| typetransferCbfunc(tostd.Address,amountuint64)string | |
| typepairstruct{namestring;cbtransferCb} | |
| varregistry=[]pair{} | |
| funcRegister(namestring,cbtransferCb){registry=append(registry,pair{name:name,cb:cb})} | |
| funcTransferByName(namestring,tostring,amountuint64)string{ | |
| for_,pair :=rangeregistry{ | |
| ifpair.name==name{ | |
| ifstd.CurrentRealm().Addr().String()==pair.cb(std.Address(to),amount){ | |
| return"same address, success!" | |
| }else{ | |
| return"invalid address, ownership issue :(" | |
| } | |
| return"registry="+std.CurrentRealm().Addr().String()+" "+pair.cb(std.Address(to),amount) | |
| } | |
| } | |
| return"not found" | |
| } | |
| --foo20wrapper/foo20wrapper.gno-- | |
| packagefoo20wrapper | |
| import"gno.land/r/registry" | |
| import"gno.land/r/foo20" | |
| funcinit(){ | |
| registry.Register("foo20",foo20.Transfer) | |
| } | |
| --foo20/foo20.gno-- | |
| packagefoo20 | |
| import"std" | |
| funcTransfer(tostd.Address,amountuint64)string{ | |
| println("transfer from="+std.PrevRealm().Addr().String()+" to="+to.String()+" some-amount") | |
| returnstd.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg -pkgdir $WORK/registry -pkgpath gno.land/r/registry -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import "std" | |
| type transferCb func(to std.Address, amount uint64) string | |
| type pair struct {name string; cb transferCb} | |
| var registry = []pair{} | |
| func Register(name string, cb transferCb) { registry = append(registry, pair{name: name, cb: cb}) } | |
| func TransferByName(name string, to string, amount uint64) string { | |
| for _, pair := range registry { | |
| if pair.name == name { | |
| if std.CurrentRealm().Addr().String() == pair.cb(std.Address(to), amount) { | |
| return "same address, success!" | |
| } else { | |
| return "invalid address, ownership issue :(" | |
| } | |
| return "registry=" + std.CurrentRealm().Addr().String() + " " + pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return "not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import "gno.land/r/registry" | |
| import "gno.land/r/foo20" | |
| func init() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import "std" | |
| func Transfer(to std.Address, amount uint64) string { | |
| println("transfer from=" + std.PrevRealm().Addr().String() + " to=" + to.String() + " some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # test for add package | |
| ## start a new node | |
| gnoland start | |
| # add registry | |
| gnokey maketx addpkg -pkgdir $WORK/registry -pkgpath gno.land/r/registry -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, before it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'not found' | |
| # add foo20, and foo20wrapper | |
| gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| # we call Transfer with foo20, after it's registered | |
| gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | |
| stdout 'same address, success!' | |
| -- registry/registry.gno -- | |
| package registry | |
| import "std" | |
| type transferCb func(to std.Address, amount uint64) string | |
| type pair struct {name string; cb transferCb} | |
| var registry = []pair{} | |
| func Register(name string, cb transferCb) { registry = append(registry, pair{name: name, cb: cb}) } | |
| func TransferByName(name string, to string, amount uint64) string { | |
| for _, pair := range registry { | |
| if pair.name == name { | |
| if std.CurrentRealm().Addr().String() == pair.cb(std.Address(to), amount) { | |
| return "same address, success!" | |
| } else { | |
| return "invalid address, ownership issue :(" | |
| } | |
| return "registry=" + std.CurrentRealm().Addr().String() + " " + pair.cb(std.Address(to), amount) | |
| } | |
| } | |
| return "not found" | |
| } | |
| -- foo20wrapper/foo20wrapper.gno -- | |
| package foo20wrapper | |
| import "gno.land/r/registry" | |
| import "gno.land/r/foo20" | |
| func init() { | |
| registry.Register("foo20", foo20.Transfer) | |
| } | |
| -- foo20/foo20.gno -- | |
| package foo20 | |
| import "std" | |
| func Transfer(to std.Address, amount uint64) string { | |
| println("transfer from=" + std.PrevRealm().Addr().String() + " to=" + to.String() + " some-amount") | |
| return std.PrevRealm().Addr().String() | |
| } |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment