Skip to content

Commit

Permalink
more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
samliok committed Dec 19, 2023
1 parent 2567d21 commit eda4b66
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x/programs/examples/counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestCounterProgram(t *testing.T) {
zap.Int64("alice", result[0]),
)

// write program address 2 to stack of program 1
// write program id 2 to stack of program 1
programID2Ptr, err = argumentToSmartPtr(program2ID, rt.Memory())
require.NoError(err)

Expand Down
18 changes: 9 additions & 9 deletions x/programs/examples/imports/pstate/pstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func (i *Import) Register(link runtime.Link, meter runtime.Meter, _ runtime.Supp
return nil
}

func (i *Import) putFn(caller *wasmtime.Caller, address int64, key int64, value int64) int32 {
func (i *Import) putFn(caller *wasmtime.Caller, id int64, key int64, value int64) int32 {
memory := runtime.NewMemory(runtime.NewExportClient(caller))
// memory := runtime.NewMemory(client)
programAddressBytes, err := runtime.SmartPtr(address).Bytes(memory)
programidBytes, err := runtime.SmartPtr(id).Bytes(memory)
if err != nil {
i.log.Error("failed to read program Address from memory",
i.log.Error("failed to read program id from memory",
zap.Error(err),
)
return -1
Expand All @@ -86,7 +86,7 @@ func (i *Import) putFn(caller *wasmtime.Caller, address int64, key int64, value
return -1
}

k := storage.ProgramPrefixKey(programAddressBytes, keyBytes)
k := storage.ProgramPrefixKey(programidBytes, keyBytes)
err = i.mu.Insert(context.Background(), k, valueBytes)
if err != nil {
i.log.Error("failed to insert into storage",
Expand All @@ -98,12 +98,12 @@ func (i *Import) putFn(caller *wasmtime.Caller, address int64, key int64, value
return 0
}

func (i *Import) getFn(caller *wasmtime.Caller, address int64, key int64) int64 {
func (i *Import) getFn(caller *wasmtime.Caller, id int64, key int64) int64 {
client := runtime.NewExportClient(caller)
memory := runtime.NewMemory(client)
programAddressBytes, err := runtime.SmartPtr(address).Bytes(memory)
programidBytes, err := runtime.SmartPtr(id).Bytes(memory)
if err != nil {
i.log.Error("failed to read program Address from memory",
i.log.Error("failed to read program id from memory",
zap.Error(err),
)
return -1
Expand All @@ -116,7 +116,7 @@ func (i *Import) getFn(caller *wasmtime.Caller, address int64, key int64) int64
)
return -1
}
k := storage.ProgramPrefixKey(programAddressBytes, keyBytes)
k := storage.ProgramPrefixKey(programidBytes, keyBytes)
val, err := i.mu.GetValue(context.Background(), k)
if err != nil {
if !errors.Is(err, database.ErrNotFound) {
Expand All @@ -127,7 +127,7 @@ func (i *Import) getFn(caller *wasmtime.Caller, address int64, key int64) int64
return -1
}
if err != nil {
i.log.Error("failed to convert program address to codec.Address",
i.log.Error("failed to convert program id to codec.id",
zap.Error(err),
)
return -1
Expand Down
Binary file modified x/programs/examples/testdata/counter.wasm
Binary file not shown.
Binary file modified x/programs/examples/testdata/token.wasm
Binary file not shown.

0 comments on commit eda4b66

Please sign in to comment.