Skip to content

Commit

Permalink
improve Go to C type mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Alesfatalis committed Sep 8, 2024
1 parent 344cdda commit 0e42a3c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions box.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ type Box interface {
// JsonEIP12 returns json representation of Box as string according to EIP-12 https://github.com/ergoplatform/eips/pull/23
JsonEIP12() (string, error)
// Size calculates serialized box size(in bytes)
Size() uint32
Size() uint64
// Equals checks if provided Box is same
Equals(box Box) bool
pointer() C.ErgoBoxPtr
Expand All @@ -304,7 +304,7 @@ func newBox(b *box) Box {
func NewBox(boxValue BoxValue, creationHeight uint32, contract Contract, txId TxId, index uint16, tokens Tokens) (Box, error) {
var p C.ErgoBoxPtr

errPtr := C.ergo_lib_ergo_box_new(boxValue.pointer(), C.uint(creationHeight), contract.pointer(), txId.pointer(), C.ushort(index), tokens.pointer(), &p)
errPtr := C.ergo_lib_ergo_box_new(boxValue.pointer(), C.uint32_t(creationHeight), contract.pointer(), txId.pointer(), C.uint16_t(index), tokens.pointer(), &p)
err := newError(errPtr)
if err.isError() {
return nil, err.error()
Expand Down Expand Up @@ -424,9 +424,9 @@ func (b *box) JsonEIP12() (string, error) {
return result, nil
}

func (b *box) Size() uint32 {
func (b *box) Size() uint64 {
res := C.ergo_lib_ergo_box_bytes_size(b.p)
return uint32(res)
return uint64(res)
}

func (b *box) Equals(box Box) bool {
Expand Down
4 changes: 2 additions & 2 deletions boxcandidatebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ func newBoxCandidateBuilder(b *boxCandidateBuilder) BoxCandidateBuilder {
func NewBoxCandidateBuilder(boxValue BoxValue, contract Contract, creationHeight uint32) BoxCandidateBuilder {
var p C.ErgoBoxCandidateBuilderPtr

C.ergo_lib_ergo_box_candidate_builder_new(boxValue.pointer(), contract.pointer(), C.uint(creationHeight), &p)
C.ergo_lib_ergo_box_candidate_builder_new(boxValue.pointer(), contract.pointer(), C.uint32_t(creationHeight), &p)

bc := &boxCandidateBuilder{p: p}

return newBoxCandidateBuilder(bc)
}

func (b *boxCandidateBuilder) SetMinBoxValuePerByte(minBoxValuePerByte uint32) {
C.ergo_lib_ergo_box_candidate_builder_set_min_box_value_per_byte(b.p, C.uint(minBoxValuePerByte))
C.ergo_lib_ergo_box_candidate_builder_set_min_box_value_per_byte(b.p, C.uint32_t(minBoxValuePerByte))
}

func (b *boxCandidateBuilder) MinBoxValuePerByte() uint32 {
Expand Down
2 changes: 1 addition & 1 deletion txbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewTxBuilder(
C.ergo_lib_tx_builder_new(
boxSelection.pointer(),
outputCandidates.pointer(),
C.uint(currentHeight),
C.uint32_t(currentHeight),
feeAmount.pointer(),
changeAddress.pointer(),
&p)
Expand Down
2 changes: 1 addition & 1 deletion wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewMnemonicGenerator(language string, strength uint32) (MnemonicGenerator,

var p C.MnemonicGeneratorPtr

errPtr := C.ergo_lib_mnemonic_generator(languageStr, C.uint(strength), &p)
errPtr := C.ergo_lib_mnemonic_generator(languageStr, C.uint32_t(strength), &p)
err := newError(errPtr)

if err.isError() {
Expand Down

0 comments on commit 0e42a3c

Please sign in to comment.