Skip to content

Commit

Permalink
Merge branch 'main' of github.com:machinefi/sprout-pebble-sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
saitofun committed Jun 19, 2024
2 parents 8744faa + 41506c8 commit 4802a91
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions cmd/wasm/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pebble_wasm:
@tinygo build -o pebble.wasm -scheduler=none --no-debug -target=wasi main.go
@mkdir -pv wasms && mv pebble.wasm wasms
@echo built to wasms/pebble.wasm
@echo built to pebble.wasm

build: pebble_wasm

clean:
@rm -rf wasms/pebble.wasm
@rm -rf pebble.wasm
4 changes: 2 additions & 2 deletions cmd/wasm/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/machinefi/sprout-pebble-sequencer/cmd/wasm

go 1.22.0
go 1.19

require (
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
github.com/machinefi/w3bstream-wasm-golang-sdk v1.1.0
github.com/tidwall/gjson v1.17.1
golang.org/x/crypto v0.24.0
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
)

require (
Expand Down
4 changes: 2 additions & 2 deletions cmd/wasm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7 changes: 2 additions & 5 deletions cmd/wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ func onStart(rid uint32) int32 {
log.Log("wasm get datas from json: " + gjson.Get(string(res), "datas").String())
datas := gjson.Get(string(res), "datas").Array()
imei := gjson.Get(datas[0].String(), "imei").String()
// owner := []byte(datas[0].Get("owner").String())
owner := []byte(gjson.Get(datas[0].String(), "owner").String())
// timestamp := uint32(datas[0].Get("timestamp").Uint())
timestamp := uint32(gjson.Get(datas[0].String(), "timestamp").Uint())
// signature := []byte(datas[0].Get("signature").String())
signature := []byte(gjson.Get(datas[0].String(), "signature").String())
// dataChannel := uint32(datas[0].Get("dataChannel").Uint())
gasLimit := big.NewInt(gjson.Get(datas[0].String(), "gasLimit").Int())
dataChannel := uint32(gjson.Get(datas[0].String(), "dataChannel").Uint())

/*https://github.com/iotexproject/pebble-contracts/blob/1a1c91a287317d8c068edb571149aedb10c0b754/contracts/PebbleImpl.sol
Expand All @@ -52,7 +49,7 @@ func onStart(rid uint32) int32 {
log.Log(fmt.Sprintf("abi.NewMethod error: %s", err.Error()))
return -1
}
data, err := method.Pack(imei, address.BytesToAddress(owner), timestamp, signature, big.NewInt(200000), dataChannel)
data, err := method.Pack(imei, address.BytesToAddress(owner), timestamp, signature, gasLimit, dataChannel)
if err != nil {
log.Log(fmt.Sprintf("pack error: %s", err.Error()))
return -1
Expand Down
Binary file modified cmd/wasm/pebble.wasm
Binary file not shown.

0 comments on commit 4802a91

Please sign in to comment.