-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from nspcc-dev/94-use-neofs-contract-wrappers
Use neofs contract wrappers
- Loading branch information
Showing
7 changed files
with
134 additions
and
234 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
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 |
---|---|---|
@@ -1,28 +1,29 @@ | ||
package contracts | ||
|
||
import ( | ||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap" | ||
"fmt" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/util" | ||
"github.com/nspcc-dev/neofs-contract/rpc/container" | ||
"github.com/nspcc-dev/neofs-net-monitor/pkg/pool" | ||
) | ||
|
||
type Container struct { | ||
pool *pool.Pool | ||
contractHash util.Uint160 | ||
contractReader *container.ContractReader | ||
} | ||
|
||
const ( | ||
count = "count" | ||
) | ||
|
||
// NewContainer creates Container to interact with 'container' contract in morph chain. | ||
func NewContainer(p *pool.Pool, contractHash util.Uint160) (*Container, error) { | ||
return &Container{ | ||
pool: p, | ||
contractHash: contractHash, | ||
contractReader: container.NewReader(p, contractHash), | ||
}, nil | ||
} | ||
|
||
func (c *Container) Total() (int64, error) { | ||
return unwrap.Int64(c.pool.Call(c.contractHash, count)) | ||
amount, err := c.contractReader.Count() | ||
if err != nil { | ||
return 0, fmt.Errorf("count: %w", err) | ||
} | ||
|
||
return amount.Int64(), nil | ||
} |
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.