-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor/kos-go #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Refactor/kos-go #255
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8a45570
add more direct warpping of uniffi generated go code
klever-patrick dbd1b4c
add new implementation to kos-go
klever-patrick 8d2038d
add signer tests
klever-patrick 0cf479f
remove temp package
klever-patrick d2aa948
update kos-go demo
klever-patrick 6667b07
error handling in go tests
klever-patrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,60 @@ | ||
| package kosgo | ||
|
|
||
| import kos_mobile "github.com/klever-io/kos-rs/packages/kos-go/kos_mobile" | ||
|
|
||
| type TransactionChainOptions = kos_mobile.TransactionChainOptions | ||
| type TransactionChainOptionsEvm = kos_mobile.TransactionChainOptionsEvm | ||
| type TransactionChainOptionsBtc = kos_mobile.TransactionChainOptionsBtc | ||
| type TransactionChainOptionsSubstrate = kos_mobile.TransactionChainOptionsSubstrate | ||
| type TransactionChainOptionsCosmos = kos_mobile.TransactionChainOptionsCosmos | ||
|
|
||
| type WalletChainOptions = kos_mobile.WalletChainOptions | ||
| type WalletChainOptionsCustomEth = kos_mobile.WalletChainOptionsCustomEth | ||
| type WalletChainOptionsCustomIcp = kos_mobile.WalletChainOptionsCustomIcp | ||
|
|
||
| type WalletOptions = kos_mobile.WalletOptions | ||
|
|
||
| func NewSubstrateTransactionOptions( | ||
| call string, | ||
| era string, | ||
| nonce uint32, | ||
| tip uint64, | ||
| assetId *string, | ||
| blockHash string, | ||
| genesisHash string, | ||
| specVersion uint32, | ||
| transactionVersion uint32, | ||
| appId *uint32, | ||
| signedExtensions *[]string, | ||
| ) TransactionChainOptions { | ||
| return kos_mobile.NewSubstrateTransactionOptions( | ||
| call, era, nonce, tip, assetId, | ||
| blockHash, genesisHash, | ||
| specVersion, transactionVersion, | ||
| appId, signedExtensions, | ||
| ) | ||
| } | ||
|
|
||
| func NewBitcoinTransactionOptions(inputAmounts []uint64, prevScripts []string) TransactionChainOptions { | ||
| return kos_mobile.NewBitcoinTransactionOptions(inputAmounts, prevScripts) | ||
| } | ||
|
|
||
| func NewEvmTransactionOptions(chainId uint32) TransactionChainOptions { | ||
| return kos_mobile.NewEvmTransactionOptions(chainId) | ||
| } | ||
|
|
||
| func NewCosmosTransactionOptions(chainId string, accountNumber uint64) TransactionChainOptions { | ||
| return kos_mobile.NewCosmosTransactionOptions(chainId, accountNumber) | ||
| } | ||
|
|
||
| func NewWalletOptions(useLegacyPath bool) WalletOptions { | ||
| return kos_mobile.NewWalletOptions(useLegacyPath) | ||
| } | ||
|
|
||
| func NewEthWalletOptions(useLegacyPath bool, chainId uint32) WalletOptions { | ||
| return kos_mobile.NewEthWalletOptions(useLegacyPath, chainId) | ||
| } | ||
|
|
||
| func NewIcpWalletOptions(useLegacyPath bool, keyType string) WalletOptions { | ||
| return kos_mobile.NewIcpWalletOptions(useLegacyPath, keyType) | ||
| } |
This file contains hidden or 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,182 @@ | ||
| package kosgo | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| kos_mobile "github.com/klever-io/kos-rs/packages/kos-go/kos_mobile" | ||
| ) | ||
|
|
||
| type Sign = kos_mobile.Sign | ||
|
|
||
| const ( | ||
| Minus = kos_mobile.SignMinus | ||
| NoSign = kos_mobile.SignNoSign | ||
| Plus = kos_mobile.SignPlus | ||
| ) | ||
|
|
||
| type BigNumber struct { | ||
| inner kos_mobile.BigNumber | ||
| } | ||
|
|
||
| func NewBigNumber(value string) (*BigNumber, error) { | ||
| bn, err := kos_mobile.BigNumberNew(value) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("invalid number: %w", err) | ||
| } | ||
| return &BigNumber{inner: bn}, nil | ||
| } | ||
|
|
||
| func NewBigNumberZero() *BigNumber { | ||
| return &BigNumber{inner: kos_mobile.BigNumberNewZero()} | ||
| } | ||
|
|
||
| func (b *BigNumber) String() string { | ||
| if b == nil { | ||
| return "" | ||
| } | ||
| return kos_mobile.BigNumberString(b.inner) | ||
| } | ||
|
|
||
| func Add(lhs, rhs *BigNumber) (*BigNumber, error) { | ||
| if lhs == nil || rhs == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberAdd(lhs.inner, rhs.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func Sub(lhs, rhs *BigNumber) (*BigNumber, error) { | ||
| if lhs == nil || rhs == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberSubtract(lhs.inner, rhs.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func Mul(lhs, rhs *BigNumber) (*BigNumber, error) { | ||
| if lhs == nil || rhs == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberMultiply(lhs.inner, rhs.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func Div(lhs, rhs *BigNumber) (*BigNumber, error) { | ||
| if lhs == nil || rhs == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberDivide(lhs.inner, rhs.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func Pow(base, exp *BigNumber) (*BigNumber, error) { | ||
| if base == nil || exp == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberPow(base.inner, exp.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func IsEqual(lhs, rhs *BigNumber) bool { | ||
| if lhs == nil || rhs == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsEqual(lhs.inner, rhs.inner) | ||
| } | ||
|
|
||
| func IsGt(lhs, rhs *BigNumber) bool { | ||
| if lhs == nil || rhs == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsGt(lhs.inner, rhs.inner) | ||
| } | ||
|
|
||
| func IsGte(lhs, rhs *BigNumber) bool { | ||
| if lhs == nil || rhs == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsGte(lhs.inner, rhs.inner) | ||
| } | ||
|
|
||
| func IsLt(lhs, rhs *BigNumber) bool { | ||
| if lhs == nil || rhs == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsLt(lhs.inner, rhs.inner) | ||
| } | ||
|
|
||
| func IsLte(lhs, rhs *BigNumber) bool { | ||
| if lhs == nil || rhs == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsLte(lhs.inner, rhs.inner) | ||
| } | ||
|
|
||
| func Abs(b *BigNumber) (*BigNumber, error) { | ||
| if b == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberAbsolute(b.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func IsZero(b *BigNumber) bool { | ||
| if b == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsZero(b.inner) | ||
| } | ||
|
|
||
| func Increment(b *BigNumber) (*BigNumber, error) { | ||
| if b == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberIncrement(b.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func Decrement(b *BigNumber) (*BigNumber, error) { | ||
| if b == nil { | ||
| return nil, fmt.Errorf("nil BigNumber operand") | ||
| } | ||
| result, err := kos_mobile.BigNumberDecrement(b.inner) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &BigNumber{inner: result}, nil | ||
| } | ||
|
|
||
| func IsPositive(b *BigNumber) bool { | ||
| if b == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsPositive(b.inner) | ||
| } | ||
|
|
||
| func IsNegative(b *BigNumber) bool { | ||
| if b == nil { | ||
| return false | ||
| } | ||
| return kos_mobile.BigNumberIsNegative(b.inner) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.