Skip to content
Open
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
2 changes: 2 additions & 0 deletions cmd/common/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"github.com/oasisprotocol/oasis-core/go/common"
coreSignature "github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
consensusPretty "github.com/oasisprotocol/oasis-core/go/common/prettyprint"
coreStaking "github.com/oasisprotocol/oasis-core/go/staking/api"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/config"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/crypto/signature"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"
Expand Down Expand Up @@ -191,6 +192,7 @@

ctx = context.WithValue(ctx, types.ContextKeyAccountNames, addrCtx.Names)
ctx = context.WithValue(ctx, types.ContextKeyAccountEthMap, addrCtx.Eth)
ctx = context.WithValue(ctx, coreStaking.ContextKeyAccountNames, coreStaking.AccountNames(addrCtx.Names))

Check failure on line 195 in cmd/common/json.go

View workflow job for this annotation

GitHub Actions / tests-ubuntu-latest

undefined: coreStaking.AccountNames

Check failure on line 195 in cmd/common/json.go

View workflow job for this annotation

GitHub Actions / tests-ubuntu-latest

undefined: coreStaking.ContextKeyAccountNames

Check failure on line 195 in cmd/common/json.go

View workflow job for this annotation

GitHub Actions / lint

undefined: coreStaking.AccountNames (typecheck)

Check failure on line 195 in cmd/common/json.go

View workflow job for this annotation

GitHub Actions / lint

undefined: coreStaking.ContextKeyAccountNames

Check failure on line 195 in cmd/common/json.go

View workflow job for this annotation

GitHub Actions / lint

undefined: coreStaking.AccountNames) (typecheck)

Check failure on line 195 in cmd/common/json.go

View workflow job for this annotation

GitHub Actions / lint

undefined: coreStaking.ContextKeyAccountNames

// Set up chain context for signature verification during pretty-printing.
coreSignature.UnsafeResetChainContext()
Expand Down
26 changes: 26 additions & 0 deletions cmd/common/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"github.com/stretchr/testify/require"

"github.com/oasisprotocol/oasis-core/go/common/quantity"
consensusStaking "github.com/oasisprotocol/oasis-core/go/staking/api"

sdkConfig "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config"
sdkSignature "github.com/oasisprotocol/oasis-sdk/client-sdk/go/crypto/signature"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/accounts"
sdkTesting "github.com/oasisprotocol/oasis-sdk/client-sdk/go/testing"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"
)

Expand Down Expand Up @@ -53,3 +55,27 @@ func TestPrettyPrintWithTxDetails_PreservesUnnamedEthTo(t *testing.T) {

require.Contains(out, "To: "+ethAddr.Hex()+" ("+to.String()+")")
}

func TestPrettyPrint_FormatsStakingAllowBeneficiary(t *testing.T) {
require := require.New(t)

npa := &NPASelection{
NetworkName: "testnet",
Network: &sdkConfig.Network{
ChainContext: "test-chain-context",
Denomination: sdkConfig.DenominationInfo{
Symbol: "TEST",
Decimals: 9,
},
},
}

tx := consensusStaking.NewAllowTx(0, nil, &consensusStaking.Allow{
Beneficiary: sdkTesting.Bob.Address.ConsensusAddress(),
AmountChange: *quantity.NewFromUint64(10),
})

out := PrettyPrint(npa, "", tx)

require.Contains(out, "Beneficiary: test:bob ("+sdkTesting.Bob.Address.String()+")")
}
2 changes: 1 addition & 1 deletion examples/account/allow-negative.out.static
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You are about to sign the following transaction:
Method: staking.Allow
Body:
Beneficiary: oasis1qpl4axynedmdrrgrg7dpw3yxc4a8crevr5dkuksl
Beneficiary: logan (oasis1qpl4axynedmdrrgrg7dpw3yxc4a8crevr5dkuksl)
Amount change: -10.0 TEST
Nonce: 0
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/account/allow-paratime.y.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You are about to sign the following transaction:
Method: staking.Allow
Body:
Beneficiary: oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd
Beneficiary: paratime:sapphire (oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd)
Amount change: +10.0 TEST
Nonce: 2
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/account/allow.y.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You are about to sign the following transaction:
Method: staking.Allow
Body:
Beneficiary: oasis1qpl4axynedmdrrgrg7dpw3yxc4a8crevr5dkuksl
Beneficiary: logan (oasis1qpl4axynedmdrrgrg7dpw3yxc4a8crevr5dkuksl)
Amount change: +10.0 TEST
Nonce: 2
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/account/transfer-named-no-paratime.y.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You are about to sign the following transaction:
Method: staking.Transfer
Body:
To: oasis1qp87hflmelnpqhzcqcw8rhzakq4elj7jzv090p3e
To: oscar (oasis1qp87hflmelnpqhzcqcw8rhzakq4elj7jzv090p3e)
Amount: 2.5 TEST
Nonce: 0
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/transaction/show-invalid.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Signer: NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
Content:
Method: staking.Transfer
Body:
To: oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx
To: test:bob (oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx)
Amount: 1.0 ROSE
Nonce: 1
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/transaction/show-unsigned.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Method: staking.Transfer
Body:
To: oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx
To: test:bob (oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx)
Amount: 1.0 TEST
Nonce: 32
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/transaction/show.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Signer: NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
Content:
Method: staking.Transfer
Body:
To: oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx
To: test:bob (oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx)
Amount: 1.0 TEST
Nonce: 1
Fee:
Expand Down
2 changes: 1 addition & 1 deletion examples/transaction/sign.y.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
You are about to sign the following transaction:
Method: staking.Transfer
Body:
To: oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx
To: test:bob (oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx)
Amount: 1.0 TEST
Nonce: 32
Fee:
Expand Down
Loading