Skip to content

Commit

Permalink
Merge branch 'gnolang:master' into banker_pkg_update
Browse files Browse the repository at this point in the history
  • Loading branch information
MalekLahbib authored Oct 3, 2024
2 parents 0356eca + 14acb90 commit 1d6f6e0
Show file tree
Hide file tree
Showing 28 changed files with 4,970 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
/examples/gno.land/p/demo/avl/ @jaekwon
/examples/gno.land/p/demo/bf/ @moul
/examples/gno.land/p/demo/blog/ @gnolang/devrels
/examples/gno.land/p/demo/boardsv2/ @ilgooz @jeronimoalbi @moul
/examples/gno.land/p/demo/cford32/ @thehowl
/examples/gno.land/p/demo/memeland/ @leohhhn
/examples/gno.land/p/demo/seqid/ @thehowl
Expand All @@ -36,6 +37,7 @@
/examples/gno.land/p/demo/ui/ @moul
/examples/gno.land/r/demo/ @gnolang/tech-staff @gnolang/devrels
/examples/gno.land/r/demo/art/ @moul
/examples/gno.land/r/demo/boardsv2/ @ilgooz @jeronimoalbi @moul
/examples/gno.land/r/demo/memeland/ @leohhhn
/examples/gno.land/r/demo/tamagotchi/ @moul
/examples/gno.land/r/demo/userbook/ @leohhhn
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/benchmark-check.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/benchmark-master-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: run benchmarks when pushing on main branch

on:
push:
branches:
- master

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write

env:
CGO_ENABLED: 0

jobs:
benchmarks:
if: ${{ github.repository == 'gnolang/gno' }}
runs-on: [self-hosted, Linux, X64, benchmarks]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/setup-go@v5
with:
go-version: "1.22.x"

- name: Run benchmark
run: |
go test -benchmem -bench=. ./... -run=^$ \
-cpu 1,2 -timeout 50m | tee benchmarks.txt
- name: Download previous benchmark data
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark

- name: Store benchmark results into `gh-benchmarks` branch
uses: benchmark-action/github-action-benchmark@v1
# see https://github.com/benchmark-action/github-action-benchmark?tab=readme-ov-file#action-inputs
with:
name: Go Benchmarks
tool: "go"
output-file-path: benchmarks.txt
# Where the previous data file is stored
external-data-json-path: ./cache/benchmark-data.json
max-items-in-chart: 100
# Show alert with commit comment on detecting possible performance regression
alert-threshold: "120%"
fail-on-alert: true
comment-on-alert: true
alert-comment-cc-users: "@ajnavarro,@thehowl,@zivkovicmilos"
# Enable Job Summary for PRs
summary-always: true
github-token: ${{ secrets.GITHUB_TOKEN }}
# NOTE you need to use a separate GITHUB PAT token that has a write access to the specified repository.
# gh-repository: 'github.com/gnolang/benchmarks' # on gh-pages branch
gh-pages-branch: gh-benchmarks
benchmark-data-dir-path: .
auto-push: true
15 changes: 0 additions & 15 deletions .github/workflows/benchmark-publish.yml

This file was deleted.

72 changes: 0 additions & 72 deletions .github/workflows/benchmark_template.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/reference/go-gno-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Legend:
| hash/crc64 | `todo` |
| hash/fnv | `todo` |
| hash/maphash | `todo` |
| html | `todo` |
| html | `full` |
| html/template | `todo` |
| image | `tbd` |
| image/color | `tbd` |
Expand Down
8 changes: 3 additions & 5 deletions examples/gno.land/p/demo/grc/grc20/banker.gno
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (b *Banker) Mint(address std.Address, amount uint64) error {
b.balances.Set(string(address), newBalance)

std.Emit(
TransferEvent,
MintEvent,
"from", "",
"to", string(address),
"value", strconv.Itoa(int(amount)),
Expand All @@ -96,7 +96,7 @@ func (b *Banker) Burn(address std.Address, amount uint64) error {
b.balances.Set(string(address), newBalance)

std.Emit(
TransferEvent,
BurnEvent,
"from", string(address),
"to", "",
"value", strconv.Itoa(int(amount)),
Expand Down Expand Up @@ -152,9 +152,6 @@ func (b *Banker) Transfer(from, to std.Address, amount uint64) error {
toBalance := b.BalanceOf(to)
fromBalance := b.BalanceOf(from)

// debug.
// println("from", from, "to", to, "amount", amount, "fromBalance", fromBalance, "toBalance", toBalance)

if fromBalance < amount {
return ErrInsufficientBalance
}
Expand All @@ -171,6 +168,7 @@ func (b *Banker) Transfer(from, to std.Address, amount uint64) error {
"to", to.String(),
"value", strconv.Itoa(int(amount)),
)

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions examples/gno.land/p/demo/grc/grc20/types.gno
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Token interface {
}

const (
MintEvent = "Mint"
BurnEvent = "Burn"
TransferEvent = "Transfer"
ApprovalEvent = "Approval"
)
53 changes: 53 additions & 0 deletions examples/gno.land/p/demo/ufmt/ufmt.gno
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func Println(args ...interface{}) {
// %d: formats an integer value using package "strconv".
// Currently supports only uint, uint64, int, int64.
// %t: formats a boolean value to "true" or "false".
// %x: formats an integer value as a hexadecimal string.
// Currently supports only uint8, []uint8, [32]uint8.
// %c: formats a rune value as a string.
// Currently supports only rune, int.
// %q: formats a string value as a quoted string.
// %T: formats the type of the value.
// %%: outputs a literal %. Does not consume an argument.
func Sprintf(format string, args ...interface{}) string {
// we use runes to handle multi-byte characters
Expand Down Expand Up @@ -158,6 +164,53 @@ func Sprintf(format string, args ...interface{}) string {
default:
buf += fallback(verb, v)
}
case "x":
switch v := arg.(type) {
case uint8:
buf += strconv.FormatUint(uint64(v), 16)
default:
buf += "(unhandled)"
}
case "q":
switch v := arg.(type) {
case string:
buf += strconv.Quote(v)
default:
buf += "(unhandled)"
}
case "T":
switch arg.(type) {
case bool:
buf += "bool"
case int:
buf += "int"
case int8:
buf += "int8"
case int16:
buf += "int16"
case int32:
buf += "int32"
case int64:
buf += "int64"
case uint:
buf += "uint"
case uint8:
buf += "uint8"
case uint16:
buf += "uint16"
case uint32:
buf += "uint32"
case uint64:
buf += "uint64"
case string:
buf += "string"
case []byte:
buf += "[]byte"
case []rune:
buf += "[]rune"
default:
buf += "unknown"
}
// % handled before, as it does not consume an argument
default:
buf += "(unhandled verb: %" + verb + ")"
Expand Down
12 changes: 12 additions & 0 deletions examples/gno.land/p/demo/ufmt/ufmt_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ func TestSprintf(t *testing.T) {
{"â", nil, "â"},
{"Hello, World! 😊", nil, "Hello, World! 😊"},
{"unicode formatting: %s", []interface{}{"😊"}, "unicode formatting: 😊"},
{"invalid hex [%x]", []interface{}{"invalid"}, "invalid hex [(unhandled)]"},
{"rune as character [%c]", []interface{}{rune('A')}, "rune as character [A]"},
{"int as character [%c]", []interface{}{int('B')}, "int as character [B]"},
{"quoted string [%q]", []interface{}{"hello"}, "quoted string [\"hello\"]"},
{"quoted string with escape [%q]", []interface{}{"\thello\nworld\\"}, "quoted string with escape [\"\\thello\\nworld\\\\\"]"},
{"invalid quoted string [%q]", []interface{}{123}, "invalid quoted string [(unhandled)]"},
{"type of bool [%T]", []interface{}{true}, "type of bool [bool]"},
{"type of int [%T]", []interface{}{123}, "type of int [int]"},
{"type of string [%T]", []interface{}{"hello"}, "type of string [string]"},
{"type of []byte [%T]", []interface{}{[]byte{1, 2, 3}}, "type of []byte [[]byte]"},
{"type of []rune [%T]", []interface{}{[]rune{'a', 'b', 'c'}}, "type of []rune [[]rune]"},
{"type of unknown [%T]", []interface{}{struct{}{}}, "type of unknown [unknown]"},
// mismatch printing
{"%s", []interface{}{nil}, "%!s(<nil>)"},
{"%s", []interface{}{421}, "%!s(int=421)"},
Expand Down
Loading

0 comments on commit 1d6f6e0

Please sign in to comment.