Skip to content
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

update to kda-fprs blockchain features #9

Merged
merged 8 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cmd/demo/assetTrigger/kdaFeePool/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
"github.com/klever-io/klever-go-sdk/provider"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
tx, err := kc.AssetTrigger(
base,
"KDA",
provider.AssetTriggerType(15),
&models.AssetTriggerOptions{
KDAPool: &models.KDAPoolInfo{
Active: true,
AdminAddress: accounts[0].Address().Bech32(),
FRatioKLV: 1,
FRatioKDA: 1,
},
})
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
42 changes: 42 additions & 0 deletions cmd/demo/assetTrigger/mint/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
"github.com/klever-io/klever-go-sdk/provider"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
tx, err := kc.AssetTrigger(
base,
"KDA",
provider.AssetTriggerType(0),
&models.AssetTriggerOptions{
Amount: 1,
Receiver: accounts[0].Address().Bech32(),
})
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
39 changes: 39 additions & 0 deletions cmd/demo/assetTrigger/stopMetadataChange/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
"github.com/klever-io/klever-go-sdk/provider"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
tx, err := kc.AssetTrigger(
base,
"KDA",
provider.AssetTriggerType(17),
&models.AssetTriggerOptions{})
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
39 changes: 39 additions & 0 deletions cmd/demo/assetTrigger/stopRoyaltiesChange/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
"github.com/klever-io/klever-go-sdk/provider"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
tx, err := kc.AssetTrigger(
base,
"KDA",
provider.AssetTriggerType(16),
&models.AssetTriggerOptions{})
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
4 changes: 4 additions & 0 deletions cmd/demo/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func InitWallets() (
if err != nil {
return
}

err = acc.Sync(kc)
if err != nil {
return
}

accounts = append(accounts, acc)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ func main() {
}

base := accounts[0].NewBaseTX()

tx, err := kc.CreateKDA(
base,
proto.KDAData_Fungible,
proto.KDAData_Fungible, // Type NFT ot Fungible Token
&models.KDAOptions{
Name: "KleverTest",
Ticker: "TST",
Precision: 4,
MaxSupply: 1000,
InitialSupply: 10,
AddRolesMint: []string{accounts[0].Address().Bech32(), accounts[1].Address().Bech32()},
MaxSupply: 0,
InitialSupply: 0,

Properties: models.PropertiesInfo{
CanMint: true, CanBurn: true,
},
Expand Down
66 changes: 66 additions & 0 deletions cmd/demo/createAsset/splitRoyalties/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
"github.com/klever-io/klever-go-sdk/models/proto"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()

splitRoyalties := map[string]*models.RoyaltySplitInfo{
accounts[0].Address().Bech32(): {
PercentITOPercentage: 50,
PercentITOFixed: 50,
},
accounts[1].Address().Bech32(): {
PercentITOPercentage: 50,
PercentITOFixed: 50,
},
}

tx, err := kc.CreateKDA(
base,
proto.KDAData_Fungible, // Type NFT ot Fungible Token
&models.KDAOptions{
Name: "KleverTest",
Ticker: "TST",
Precision: 4,
MaxSupply: 1000,
InitialSupply: 10,
AddRolesMint: []string{accounts[0].Address().Bech32(), accounts[1].Address().Bech32()},
Properties: models.PropertiesInfo{
CanMint: true, CanBurn: true,
},
Royalties: models.RoyaltiesInfo{
ITOPercentage: 10,
ITOFixed: 10,
SplitRoyalties: splitRoyalties,
},
URIs: map[string]string{"explorer": "testnet.kleverscan.org"},
})
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
42 changes: 42 additions & 0 deletions cmd/demo/deposit/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
tx, err := kc.Deposit(
base,
&models.DepositOptions{
Amount: 100,
DepositType: 1,
KDAID: "KDA",
CurrencyID: "KLV",
},
)
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
41 changes: 41 additions & 0 deletions cmd/demo/itoTrigger/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
"github.com/klever-io/klever-go-sdk/models"
"github.com/klever-io/klever-go-sdk/provider"
)

func main() {

accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
tx, err := kc.ITOTrigger(
base,
"KDA",
provider.ITOTriggerType(3),
&models.ITOTriggerOptions{
MaxAmount: 60,
})
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
36 changes: 36 additions & 0 deletions cmd/demo/payFeesWithKDA/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"fmt"

"github.com/klever-io/klever-go-sdk/cmd/demo"
)

func main() {

// To pay fees with kda, you need to have a KDA with Fee Pool Active.
accounts, wallets, kc, err := demo.InitWallets()
if err != nil {
panic(err)
}

base := accounts[0].NewBaseTX()
// and add the current kda to kdaFee param on base struct.
base.KdaFee = "KDA"
tx, err := kc.Send(base, accounts[1].Address().Bech32(), 1, "")
if err != nil {
panic(err)
}

err = tx.Sign(wallets[0])
if err != nil {
panic(err)
}

hash, err := tx.Broadcast(kc)
if err != nil {
panic(err)
}

fmt.Println("TxHash: ", hash)
}
Loading