-
Notifications
You must be signed in to change notification settings - Fork 6
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 #101 from make-software/CSDK/implement_account_put…
…_transaction Implement account put transaction
- Loading branch information
Showing
26 changed files
with
1,005 additions
and
422 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MC4CAQAwBQYDK2VwBCIEIHRZr1HEgKVbgchuatwA7dCWDWB7QZe+bpDb5dguIyLE | ||
-----END PRIVATE KEY----- |
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
"log" | ||
"math/big" | ||
"net/http" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/make-software/casper-go-sdk/casper" | ||
"github.com/make-software/casper-go-sdk/rpc" | ||
"github.com/make-software/casper-go-sdk/types" | ||
"github.com/make-software/casper-go-sdk/types/clvalue" | ||
) | ||
|
||
func Test_PutTransaction(t *testing.T) { | ||
keys, err := casper.NewED25519PrivateKeyFromPEMFile("../../data/keys/docker-nctl-rc3-secret.pem") | ||
require.NoError(t, err) | ||
|
||
pubKey := keys.PublicKey() | ||
|
||
header := types.TransactionV1Header{ | ||
ChainName: "casper-net-1", | ||
Timestamp: types.Timestamp(time.Now().UTC()), | ||
TTL: 18000000000, | ||
InitiatorAddr: types.InitiatorAddr{ | ||
PublicKey: &pubKey, | ||
}, | ||
PricingMode: types.PricingMode{ | ||
Fixed: &types.FixedMode{ | ||
GasPriceTolerance: 3, | ||
}, | ||
}, | ||
} | ||
|
||
moduleBytes, err := os.ReadFile("../../data/wasm/cep18-rc3.wasm") | ||
require.NoError(t, err) | ||
|
||
args := &types.Args{} | ||
args.AddArgument("name", *clvalue.NewCLString("Test")). | ||
AddArgument("symbol", *clvalue.NewCLString("test")). | ||
AddArgument("decimals", *clvalue.NewCLUint8(9)). | ||
AddArgument("total_supply", *clvalue.NewCLUInt256(big.NewInt(1_000_000_000_000_000))). | ||
AddArgument("events_mode", *clvalue.NewCLUint8(2)). | ||
AddArgument("enable_mint_burn", *clvalue.NewCLUint8(1)) | ||
|
||
body := types.TransactionV1Body{ | ||
Args: args, | ||
Target: types.TransactionTarget{ | ||
Session: &types.SessionTarget{ | ||
ModuleBytes: hex.EncodeToString(moduleBytes), | ||
Runtime: types.TransactionRuntimeVmCasperV1, | ||
}, | ||
}, | ||
TransactionEntryPoint: types.TransactionEntryPoint{ | ||
Call: &struct{}{}, | ||
}, | ||
TransactionScheduling: types.TransactionScheduling{ | ||
Standard: &struct{}{}, | ||
}, | ||
TransactionCategory: 2, | ||
} | ||
|
||
transaction, err := types.MakeTransactionV1(header, body) | ||
err = transaction.Sign(keys) | ||
require.NoError(t, err) | ||
|
||
rpcClient := rpc.NewClient(rpc.NewHttpHandler("http://127.0.0.1:11101/rpc", http.DefaultClient)) | ||
res, err := rpcClient.PutTransactionV1(context.Background(), *transaction) | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, res.TransactionHash.TransactionV1) | ||
assert.NoError(t, transaction.Validate()) | ||
|
||
log.Println("TransactionV1 submitted:", res.TransactionHash.TransactionV1) | ||
|
||
time.Sleep(time.Second * 10) | ||
transactionRes, err := rpcClient.GetTransactionByTransactionHash(context.Background(), res.TransactionHash.TransactionV1.ToHex()) | ||
require.NoError(t, err) | ||
assert.NotEmpty(t, transactionRes.Transaction) | ||
assert.NotEmpty(t, transactionRes.ExecutionInfo) | ||
} |
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
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.