Skip to content

Commit

Permalink
格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
web3creator committed Sep 21, 2022
1 parent 7854815 commit c30e362
Show file tree
Hide file tree
Showing 26 changed files with 439 additions and 397 deletions.
5 changes: 3 additions & 2 deletions sdk/adt/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"
)

//DefaultAmtOptions default amt option
// DefaultAmtOptions default amt option
var DefaultAmtOptions = []amt.Option{}

// Array stores a sparse sequence of values in an AMT.
Expand Down Expand Up @@ -129,7 +129,8 @@ func (a *Array) Length() uint64 {
}

// Get retrieves array element into the 'out' unmarshaler, returning a boolean
// indicating whether the element was found in the array
//
// indicating whether the element was found in the array
func (a *Array) Get(k uint64, out cbor.Unmarshaler) (bool, error) {
if found, err := a.root.Get(a.store.Context(), k, out); err != nil {
return false, fmt.Errorf("failed to get index %v in root %v: %w", k, a.root, err)
Expand Down
5 changes: 3 additions & 2 deletions sdk/cases/network.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:param
package main

import (
Expand All @@ -23,10 +24,10 @@ func Invoke(_ uint32) uint32 { //nolint

fee, err := sdk.BaseFee()
assert.Nil(t, err)
assert.Equal(t, "100", fee.Big().String())
assert.Equal(t, "100", fee.String())

value, err := sdk.TotalFilCircSupply()
assert.Nil(t, err)
assert.Equal(t, "2000000000000000000000000000", value.Big().String())
assert.Equal(t, "2000000000000000000000000000", value.String())
return 0
}
2 changes: 1 addition & 1 deletion sdk/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func VerifySeal(info *proof.SealVerifyInfo) (bool, error) {
return sys.VerifySeal(info)
}

//VerifyPost verifies a sector seal proof.
// VerifyPost verifies a sector seal proof.
func VerifyPost(info *proof.WindowPoStVerifyInfo) (bool, error) {
return sys.VerifyPost(info)
}
Expand Down
14 changes: 7 additions & 7 deletions sdk/ferrors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
// ExitCode define error in fvm and custom actor
type ExitCode uint32

//Error return error message of exitcode
// Error return error message of exitcode
func (e ExitCode) Error() string {
return fmt.Sprintf("%d", e)
}

//Is check whether error is exitcode
// Is check whether error is exitcode
func (e ExitCode) Is(code error) bool {
return e == code
}
Expand All @@ -23,7 +23,7 @@ func (e ExitCode) IsSystemError() bool {
return uint32(e) < FIRST_USER_EXIT_CODE
}

//nolint
// nolint
const (
// Exit codes which originate inside the VM.
// These values may not be used by actors when aborting.
Expand Down Expand Up @@ -90,23 +90,23 @@ const (
// RESERVED_31 ExitCode = 31
)

//FvmError fvm error include error code and error message
// FvmError fvm error include error code and error message
type FvmError struct {
code ExitCode
message string
}

//NewFvmError new fvm error from error code and message
// NewFvmError new fvm error from error code and message
func NewFvmError(code ExitCode, msg string) FvmError {
return FvmError{code, msg}
}

//Error return error message for fvm error
// Error return error message for fvm error
func (fvmError FvmError) Error() string {
return fmt.Sprintf("%s %d", fvmError.message, fvmError.code)
}

//Unwrap return inner error code
// Unwrap return inner error code
func (fvmError FvmError) Unwrap() error {
return fvmError.code
}
2 changes: 1 addition & 1 deletion sdk/ipld.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func GetBlock(id types.BlockID, size *uint32) ([]byte, error) {
if err != nil {
return nil, err
}

if remaining > 0 { //more than 1KiB
sencondPart, remaining, err := sys.Read(id, uint32(len(block)), remaining) //only set len and slice
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion sdk/shim/shim.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//nolint:param
package main

import (
"unsafe"
)

/// Logs a message on the node.
// Logs a message on the node.
//
//go:wasm-module debug
//export log
func debugLog(message uintptr, message_len uint32) uint32 //nolint
Expand Down
2 changes: 0 additions & 2 deletions sdk/sself.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sdk

import (


addr "github.com/filecoin-project/go-address"
"github.com/ipfs-force-community/go-fvm-sdk/sdk/sys"
"github.com/ipfs-force-community/go-fvm-sdk/sdk/types"
Expand Down
13 changes: 7 additions & 6 deletions sdk/sys/abort_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

package sys

/// Abort execution with the given code and message. The code is recorded in the receipt, the
/// message is for debugging only.
///
/// # Errors
///
/// None. This function doesn't return.
// / Abort execution with the given code and message. The code is recorded in the receipt, the
// / message is for debugging only.
// /
// / # Errors
// /
// / None. This function doesn't return.
//
//go:wasm-module vm
//export abort
func vmAbort(code uint32, msgOff uintptr, msgLen uint32) uint32
72 changes: 39 additions & 33 deletions sdk/sys/actor_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,65 @@

package sys

/// Resolves the ID address of an actor.
///
/// # Errors
///
/// | Error | Reason |
/// |-------------------|-----------------------------------------------------------|
/// | `NotFound` | target actor doesn't exist |
/// | `IllegalArgument` | if the passed address buffer isn't valid, in memory, etc. |
// / Resolves the ID address of an actor.
// /
// / # Errors
// /
// / | Error | Reason |
// / |-------------------|-----------------------------------------------------------|
// / | `NotFound` | target actor doesn't exist |
// / | `IllegalArgument` | if the passed address buffer isn't valid, in memory, etc. |
//
//go:wasm-module actor
//export resolve_address
func actorResolveAddress(ret uintptr, addr_off uintptr, addr_len uint32) uint32

/// Gets the CodeCID of an actor by address.
///
/// Returns the
///
/// # Errors
///
/// | Error | Reason |
/// |-------------------|-----------------------------------------------------------|
/// | `NotFound` | target actor doesn't exist |
/// | `IllegalArgument` | if the passed address buffer isn't valid, in memory, etc. |
// / Gets the CodeCID of an actor by address.
// /
// / Returns the
// /
// / # Errors
// /
// / | Error | Reason |
// / |-------------------|-----------------------------------------------------------|
// / | `NotFound` | target actor doesn't exist |
// / | `IllegalArgument` | if the passed address buffer isn't valid, in memory, etc. |
//
//go:wasm-module actor
//export get_actor_code_cid
func actorGetActorCodeCid(ret uintptr, addr_off uintptr, addr_len uint32, obuf_off uintptr, obuf_len uint32) uint32

/// Determines whether the specified CodeCID belongs to that of a builtin
/// actor and which. Returns 0 if unrecognized. Can only fail due to
/// internal errors.
// / Determines whether the specified CodeCID belongs to that of a builtin
// / actor and which. Returns 0 if unrecognized. Can only fail due to
// / internal errors.
//
//go:wasm-module actor
//export resolve_builtin_actor_type
func actorResolveBuiltinActorType(ret uintptr, cid_off uintptr) uint32

/// Returns the CodeCID for the given built-in actor type. Aborts with exit
/// code IllegalArgument if the supplied type is invalid. Returns the
/// length of the written CID written to the output buffer. Can only
/// return a failure due to internal errors.
// / Returns the CodeCID for the given built-in actor type. Aborts with exit
// / code IllegalArgument if the supplied type is invalid. Returns the
// / length of the written CID written to the output buffer. Can only
// / return a failure due to internal errors.
//
//go:wasm-module actor
//export get_code_cid_for_type
func actorGetCodeCidForType(ret uintptr, typ int32, obuf_off uintptr, obuf_len uint32) uint32

/// Generates a new actor address for an actor deployed
/// by the calling actor.
///
/// **Privledged:** May only be called by the init actor.
// / Generates a new actor address for an actor deployed
// / by the calling actor.
// /
// / **Privledged:** May only be called by the init actor.
//
//go:wasm-module actor
//export new_actor_address
func actorNewActorAddress(ret uintptr, obuf_off uintptr, obuf_len uint32) uint32

/// Creates a new actor of the specified type in the state tree, under
/// the provided address.
///
/// **Privledged:** May only be called by the init actor.
// / Creates a new actor of the specified type in the state tree, under
// / the provided address.
// /
// / **Privledged:** May only be called by the init actor.
//
//go:wasm-module actor
//export create_actor
func actorCreateActor(actor_id uint64, typ_off uintptr) uint32
11 changes: 6 additions & 5 deletions sdk/sys/context_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

package sys

/// Returns the details about this invocation.
///
/// # Errors
///
/// None
// / Returns the details about this invocation.
// /
// / # Errors
// /
// / None
//
//go:wasm-module vm
//export context
func vmContext(ret uintptr) uint32
Loading

0 comments on commit c30e362

Please sign in to comment.