Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Module {
getData: Int32!

setData(value: Int32!): Boolean!
}
7 changes: 7 additions & 0 deletions packages/test-cases/cases/wrappers/wasm-go/asyncify/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/testorg/testrepo

go 1.17

require github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba

require github.com/valyala/fastjson v1.6.3 // indirect
4 changes: 4 additions & 0 deletions packages/test-cases/cases/wrappers/wasm-go/asyncify/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba h1:zalC+tj7u2wwOA53sJPvPwrIr6bgQF/5KiULuAi0tcE=
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba/go.mod h1:IHk2chh2cl2rACqPLh5sE1LKTooxw19biP+zzYOiULg=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
107 changes: 107 additions & 0 deletions packages/test-cases/cases/wrappers/wasm-go/asyncify/module/method.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package module

import (
"strconv"

"github.com/testorg/testrepo/wrap/imported/storage"
"github.com/testorg/testrepo/wrap/types"
)

//go:generate polywrap build -v -m ../polywrap.yaml -o ../build

func GetData() uint32 {
res, err := storage.MethodGetData(nil)
if err != nil {
panic(err)
}
return uint32(res)
}

func ReturnTrue() bool {
return true
}

func SetDataWithLargeArgs(args *types.MethodArgsSetDataWithLargeArgs) string {
largeString := args.Value
num, err := strconv.ParseInt(largeString, 10, 32)
if err != nil {
panic(err)
}
_, err = storage.MethodSetData(&storage.ArgsSetData{Value: int32(num)})
if err != nil {
panic(err)
}
return largeString
}

func SetDataWithManyArgs(args *types.MethodArgsSetDataWithManyArgs) string {
argsA := args.ValueA
argsB := args.ValueB
argsC := args.ValueC
argsD := args.ValueD
argsE := args.ValueE
argsF := args.ValueF
argsG := args.ValueG
argsH := args.ValueH
argsI := args.ValueI
argsJ := args.ValueJ
argsK := args.ValueK
argsL := args.ValueL

_, err := storage.MethodSetData(&storage.ArgsSetData{Value: 55})
if err != nil {
panic(err)
}

return argsA + argsB + argsC + argsD + argsE + argsF + argsG + argsH + argsI + argsJ + argsK + argsL
}

func SetDataWithManyStructuredArgs(args *types.MethodArgsSetDataWithManyStructuredArgs) bool {
_, err := storage.MethodSetData(&storage.ArgsSetData{Value: 44})
if err != nil {
panic(err)
}
return true
}

func LocalVarMethod() bool {
functionArg := false
functionArg = ReturnTrue()

_, err := storage.MethodSetData(&storage.ArgsSetData{Value: 88})
if err != nil {
panic(err)
}

return functionArg
}

var globalValue bool = false

func GlobalVarMethod() bool {
globalValue = true

_, err := storage.MethodSetData(&storage.ArgsSetData{Value: 77})
if err != nil {
panic(err)
}

return globalValue
}

func SubsequentInvokes(args *types.MethodArgsSubsequentInvokes) []string {
result := make([]string, args.NumberOfTimes)
for i := int32(0); i < args.NumberOfTimes; i++ {
_, err := storage.MethodSetData(&storage.ArgsSetData{Value: i})
if err != nil {
panic(err)
}
res, err := storage.MethodGetData(nil)
if err != nil {
panic(err)
}
result[i] = strconv.FormatInt(int64(res), 10)
}

return result
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
format: 0.1.0
docker:
name: asyncify-wasm-go
config:
node_version: "16.13.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
format: 0.2.0
project:
name: Asyncify
type: wasm/golang
source:
schema: ./schema.graphql
module: ./go.mod
import_abis:
- uri: "ens/memory-storage.polywrap.eth"
abi: ./abis/memory-storage.graphql
extensions:
build: ./polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#import { Module } into Storage from "wrap://ens/memory-storage.polywrap.eth"

type Module {
getData: UInt32!

setDataWithLargeArgs(
value: String!
): String!

setDataWithManyArgs(
valueA: String!
valueB: String!
valueC: String!
valueD: String!
valueE: String!
valueF: String!
valueG: String!
valueH: String!
valueI: String!
valueJ: String!
valueK: String!
valueL: String!
): String!

setDataWithManyStructuredArgs(
valueA: BigObj!
valueB: BigObj!
valueC: BigObj!
valueD: BigObj!
valueE: BigObj!
valueF: BigObj!
valueG: BigObj!
valueH: BigObj!
valueI: BigObj!
valueJ: BigObj!
valueK: BigObj!
valueL: BigObj!
): Boolean!

localVarMethod: Boolean!

globalVarMethod: Boolean!

subsequentInvokes(
numberOfTimes: Int!
): [String!]!
}

type BigObj {
propA: String!
propB: String!
propC: String!
propD: String!
propE: String!
propF: String!
propG: String!
propH: String!
propI: String!
propJ: String!
propK: String!
propL: String!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/testorg/testrepo

go 1.17

require github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba

require github.com/valyala/fastjson v1.6.3 // indirect
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba h1:zalC+tj7u2wwOA53sJPvPwrIr6bgQF/5KiULuAi0tcE=
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba/go.mod h1:IHk2chh2cl2rACqPLh5sE1LKTooxw19biP+zzYOiULg=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package module

import (
"github.com/consideritdone/polywrap-go/polywrap/msgpack/big"
"github.com/testorg/testrepo/wrap/types"
)

//go:generate polywrap build -v -m ../polywrap.yaml -o ../build
func Method(args *types.MethodArgsMethod) *big.Int {
result := new(big.Int).Mul(args.Arg1, args.Obj.Prop1)

if args.Arg2 != nil {
result = result.Mul(result, args.Arg2)
}

if args.Obj.Prop2 != nil {
result = result.Mul(result, args.Obj.Prop2)
}

return result
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
format: 0.1.0
docker:
name: bigint-type-wasm-go
config:
node_version: "16.13.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: 0.2.0
project:
name: BigInt
type: wasm/golang
source:
schema: ./schema.graphql
module: ./go.mod
extensions:
build: ./polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type Module {
method(
arg1: BigInt!
arg2: BigInt
obj: BigIntArg!
): BigInt!
}

type BigIntArg {
prop1: BigInt!
prop2: BigInt
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/testorg/testrepo

go 1.17

require github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba

require github.com/valyala/fastjson v1.6.3 // indirect
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba h1:zalC+tj7u2wwOA53sJPvPwrIr6bgQF/5KiULuAi0tcE=
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba/go.mod h1:IHk2chh2cl2rACqPLh5sE1LKTooxw19biP+zzYOiULg=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package module

import (
"bytes"

"github.com/testorg/testrepo/wrap/types"
)

//go:generate polywrap build -v -m ../polywrap.yaml -o ../build
func BytesMethod(args *types.MethodArgsBytesMethod) []byte {
return bytes.Join(
[][]byte{
args.Arg.Prop,
[]byte("Sanity!"),
},
[]byte(" "),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
format: 0.1.0
docker:
name: bytes-type-wasm-go
config:
node_version: "16.13.0"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: 0.2.0
project:
name: BytesType
type: wasm/golang
source:
schema: ./schema.graphql
module: ./go.mod
extensions:
build: ./polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type Module {
bytesMethod(
arg: Args!
): Bytes!
}

type Args {
prop: Bytes!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/testorg/testrepo

go 1.17

require github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba

require github.com/valyala/fastjson v1.6.3 // indirect
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba h1:zalC+tj7u2wwOA53sJPvPwrIr6bgQF/5KiULuAi0tcE=
github.com/consideritdone/polywrap-go v0.0.0-20220828165033-42498c4ffdba/go.mod h1:IHk2chh2cl2rACqPLh5sE1LKTooxw19biP+zzYOiULg=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package module

import "github.com/testorg/testrepo/wrap/types"

//go:generate polywrap build -v -m ../polywrap.yaml -o ../build

func Method1(args *types.MethodArgsMethod1) types.SanityEnum {
return args.En
}

func Method2(args *types.MethodArgsMethod2) []types.SanityEnum {
return args.EnumArray
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
format: 0.1.0
config:
node_version: "16.13.0"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: 0.2.0
project:
name: EnumTypes
type: wasm/golang
source:
schema: ./schema.graphql
module: ./go.mod
extensions:
build: ./polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type Module {
method1(
en: SanityEnum!
optEnum: SanityEnum
): SanityEnum!

method2(
enumArray: [SanityEnum!]!
optEnumArray: [SanityEnum]
): [SanityEnum!]!
}

enum SanityEnum {
OPTION1
OPTION2
OPTION3
}
Loading