-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update vm * sending txs * sending tx via local snap * add options for local and remote * hi action and better faucet * hello read only action * fall back to string * use real hypersdk-client
- Loading branch information
1 parent
b5987d5
commit e26c7d9
Showing
58 changed files
with
1,560 additions
and
263 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.git | ||
web_wallet/node_modules | ||
vm/tests/e2e/e2e.test | ||
tests/e2e/e2e.test | ||
build |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
SERVE_DOMAIN=mysuperdomain.com | ||
FAUCET_PRIVATE_KEY_HEX="" | ||
PREFUND_ADDRESS="" | ||
SERVE_DOMAIN="" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.env | ||
vm/tests/e2e/e2e.test | ||
tests/e2e/e2e.test | ||
build |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package actions | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ava-labs/avalanchego/ids" | ||
|
||
"github.com/ava-labs/hypersdk-starter/storage" | ||
"github.com/ava-labs/hypersdk/chain" | ||
"github.com/ava-labs/hypersdk/codec" | ||
"github.com/ava-labs/hypersdk/state" | ||
) | ||
|
||
const ( | ||
HiComputeUnits = 1 | ||
MaxNameSize = 256 | ||
) | ||
|
||
var ( | ||
ErrNameTooLarge = fmt.Errorf("name is too large") | ||
_ chain.Action = (*Hi)(nil) | ||
) | ||
|
||
type Hi struct { | ||
Name string `serialize:"true" json:"name"` | ||
} | ||
|
||
type HiResult struct { | ||
Greeting string `serialize:"true" json:"greeting"` | ||
Balance uint64 `serialize:"true" json:"balance"` | ||
} | ||
|
||
func (*Hi) GetTypeID() uint8 { | ||
return 1 | ||
} | ||
|
||
func (h *Hi) StateKeys(actor codec.Address, _ ids.ID) state.Keys { | ||
return state.Keys{ | ||
string(storage.BalanceKey(actor)): state.Read, | ||
} | ||
} | ||
|
||
func (*Hi) StateKeysMaxChunks() []uint16 { | ||
return []uint16{storage.BalanceChunks} | ||
} | ||
|
||
func (h *Hi) Execute( | ||
ctx context.Context, | ||
_ chain.Rules, | ||
mu state.Mutable, | ||
_ int64, | ||
actor codec.Address, | ||
_ ids.ID, | ||
) ([][]byte, error) { | ||
if len(h.Name) > MaxNameSize { | ||
return nil, ErrNameTooLarge | ||
} | ||
|
||
balance, err := storage.GetBalance(ctx, mu, actor) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
greeting := fmt.Sprintf("Hi, %s", h.Name) | ||
|
||
bytes, err := codec.Marshal(HiResult{ | ||
Greeting: greeting, | ||
Balance: balance, | ||
}) | ||
|
||
return [][]byte{bytes}, err | ||
} | ||
|
||
func (*Hi) ComputeUnits(chain.Rules) uint64 { | ||
return HiComputeUnits | ||
} | ||
|
||
func (*Hi) ValidRange(chain.Rules) (int64, int64) { | ||
return -1, -1 | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.