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

WIP - Example to show how staking operation will look if we switch to []StakingTransactions #42

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
WIP
  • Loading branch information
drohit-cb committed Nov 15, 2024
commit 8ea04753d1f6b0ee1a6ab2b15ca4ec6532efab2a
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ test-coverage:
mocks:
mockery --disable-version-string --name AssetsAPI --keeptree --dir gen/client --output pkg/mocks
mockery --disable-version-string --name StakeAPI --keeptree --dir gen/client --output pkg/mocks
mockery --disable-version-string --name ValidatorsAPI --keeptree --dir gen/client --output pkg/mocks
mockery --disable-version-string --name Signable --keeptree --dir pkg/coinbase --output pkg/mocks

.PHONY: docs
6 changes: 5 additions & 1 deletion examples/ethereum/dedicated-eth-stake/main.go
Original file line number Diff line number Diff line change
@@ -58,7 +58,11 @@ func main() {

log.Printf("staking operation ID: %s\n", stakeOperation.ID())

for index, tx := range stakeOperation.Transactions() {
for index, stakingTransactionDetail := range stakeOperation.StakingTransactionDetails() {
log.Printf("metadata: %s", stakingTransactionDetail.GetMetadata())

tx := stakeOperation.Transaction(index)

log.Printf("Deposit tx %d: %s\n", index+1, tx.UnsignedPayload())
}

25 changes: 16 additions & 9 deletions examples/ethereum/shared-eth-stake/main.go
Original file line number Diff line number Diff line change
@@ -57,21 +57,28 @@ func main() {
log.Fatal(err)
}

// Sign the transactions within staking operation resource with your private key.
err = stakeOperation.Sign(key)
if err != nil {
log.Fatal(err)
}

// For Holesky, publicly available RPC URL's can be found here https://chainlist.org/chain/17000
ethClient, err := ethclient.Dial("<RPC_NODE_URL>")
if err != nil {
log.Fatal(err)
}

// Broadcast each of the signed transactions to the network.
for _, transaction := range stakeOperation.Transactions() {
rawTx := transaction.Raw()
for i, stakingTransactionDetail := range stakeOperation.StakingTransactionDetails() {
txMetadataJson, err := stakingTransactionDetail.GetPartialEthStakingTransactionMetadata().MarshalJSON()
if err != nil {
log.Fatal(err)
}

log.Printf("metadata: %s", txMetadataJson)

// Sign the transactions within staking operation resource with your private key.
if err := stakeOperation.SignTx(i, key); err != nil {
log.Fatal(err)
}

tx := stakeOperation.Transaction(i)

rawTx := tx.Raw()
ethTx, ok := rawTx.(*types.Transaction)
if !ok {
log.Fatal("failed to cast transaction to Ethereum transaction")
16 changes: 10 additions & 6 deletions examples/solana/stake/main.go
Original file line number Diff line number Diff line change
@@ -60,11 +60,6 @@ func main() {

privateKey, err := decodePrivateKey(os.Args[3])

err = stakingOperation.Sign(privateKey)
if err != nil {
log.Fatalf("error signing transaction: %v", err)
}

rpcClient := rpc.New(rpcURL)

maxRetries := uint(5)
@@ -75,7 +70,16 @@ func main() {
PreflightCommitment: rpc.CommitmentProcessed,
}

for _, transaction := range stakingOperation.Transactions() {
for i, stakingTransactionDetail := range stakingOperation.StakingTransactionDetails() {
log.Printf("metadata: %s", stakingTransactionDetail.DedicatedEthStakeTransactionDetail.Metadata.EthereumValidatorDepositData)

transaction := stakingOperation.Transaction(i)

err = stakingOperation.Sign(privateKey)
if err != nil {
log.Fatalf("error signing transaction: %v", err)
}

unsignedTx := transaction.UnsignedPayload()
signedTx := transaction.SignedPayload()

50 changes: 43 additions & 7 deletions gen/client/README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

- API version: 0.0.1-alpha
- Package version: 1.0.0
- Generator version: 7.8.0
- Generator version: 7.9.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen

## Installation
@@ -95,10 +95,20 @@ Class | Method | HTTP request | Description
*ContractInvocationsAPI* | [**GetContractInvocation**](docs/ContractInvocationsAPI.md#getcontractinvocation) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/contract_invocations/{contract_invocation_id} | Get a contract invocation by ID.
*ContractInvocationsAPI* | [**ListContractInvocations**](docs/ContractInvocationsAPI.md#listcontractinvocations) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/contract_invocations | List contract invocations for an address.
*ExternalAddressesAPI* | [**GetExternalAddressBalance**](docs/ExternalAddressesAPI.md#getexternaladdressbalance) | **Get** /v1/networks/{network_id}/addresses/{address_id}/balances/{asset_id} | Get the balance of an asset in an external address
*ExternalAddressesAPI* | [**ListAddressTransactions**](docs/ExternalAddressesAPI.md#listaddresstransactions) | **Get** /v1/networks/{network_id}/addresses/{address_id}/transactions | List transactions for an address.
*ExternalAddressesAPI* | [**GetFaucetTransaction**](docs/ExternalAddressesAPI.md#getfaucettransaction) | **Get** /v1/networks/{network_id}/addresses/{address_id}/faucet/{tx_hash} | Get the status of a faucet transaction
*ExternalAddressesAPI* | [**ListExternalAddressBalances**](docs/ExternalAddressesAPI.md#listexternaladdressbalances) | **Get** /v1/networks/{network_id}/addresses/{address_id}/balances | Get the balances of an external address
*ExternalAddressesAPI* | [**RequestExternalFaucetFunds**](docs/ExternalAddressesAPI.md#requestexternalfaucetfunds) | **Post** /v1/networks/{network_id}/addresses/{address_id}/faucet | Request faucet funds for external address.
*FundAPI* | [**CreateFundOperation**](docs/FundAPI.md#createfundoperation) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/fund_operations | Create a new fund operation.
*FundAPI* | [**CreateFundQuote**](docs/FundAPI.md#createfundquote) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/fund_operations/quote | Create a Fund Operation quote.
*FundAPI* | [**GetFundOperation**](docs/FundAPI.md#getfundoperation) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/fund_operations/{fund_operation_id} | Get fund operation.
*FundAPI* | [**ListFundOperations**](docs/FundAPI.md#listfundoperations) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/fund_operations | List fund operations for an address.
*MPCWalletStakeAPI* | [**BroadcastStakingOperation**](docs/MPCWalletStakeAPI.md#broadcaststakingoperation) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/staking_operations/{staking_operation_id}/broadcast | Broadcast a staking operation
*MPCWalletStakeAPI* | [**CreateStakingOperation**](docs/MPCWalletStakeAPI.md#createstakingoperation) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/staking_operations | Create a new staking operation for an address
*MPCWalletStakeAPI* | [**GetStakingOperation**](docs/MPCWalletStakeAPI.md#getstakingoperation) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/staking_operations/{staking_operation_id} | Get the latest state of a staking operation
*NetworksAPI* | [**GetNetwork**](docs/NetworksAPI.md#getnetwork) | **Get** /v1/networks/{network_id} | Get network by ID
*OnchainIdentityAPI* | [**ResolveIdentityByAddress**](docs/OnchainIdentityAPI.md#resolveidentitybyaddress) | **Get** /v1/networks/{network_id}/addresses/{address_id}/identity | Obtains onchain identity for an address on a specific network
*ReputationAPI* | [**GetAddressReputation**](docs/ReputationAPI.md#getaddressreputation) | **Get** /v1/networks/{network_id}/addresses/{address_id}/reputation | Get the onchain reputation of an external address
*ReputationAPI* | [**GetAddressRisk**](docs/ReputationAPI.md#getaddressrisk) | **Get** /v1/networks/{network_id}/addresses/{address_id}/risk | Get the risk of an address
*ServerSignersAPI* | [**CreateServerSigner**](docs/ServerSignersAPI.md#createserversigner) | **Post** /v1/server_signers | Create a new Server-Signer
*ServerSignersAPI* | [**GetServerSigner**](docs/ServerSignersAPI.md#getserversigner) | **Get** /v1/server_signers/{server_signer_id} | Get a server signer by ID
*ServerSignersAPI* | [**ListServerSignerEvents**](docs/ServerSignersAPI.md#listserversignerevents) | **Get** /v1/server_signers/{server_signer_id}/events | List events for a server signer
@@ -109,30 +119,30 @@ Class | Method | HTTP request | Description
*SmartContractsAPI* | [**DeploySmartContract**](docs/SmartContractsAPI.md#deploysmartcontract) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/smart_contracts/{smart_contract_id}/deploy | Deploy a smart contract
*SmartContractsAPI* | [**GetSmartContract**](docs/SmartContractsAPI.md#getsmartcontract) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/smart_contracts/{smart_contract_id} | Get a specific smart contract deployed by address
*SmartContractsAPI* | [**ListSmartContracts**](docs/SmartContractsAPI.md#listsmartcontracts) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/smart_contracts | List smart contracts deployed by address
*SmartContractsAPI* | [**ReadContract**](docs/SmartContractsAPI.md#readcontract) | **Post** /v1/networks/{network_id}/smart_contracts/{contract_address}/read | Read data from a smart contract
*StakeAPI* | [**BuildStakingOperation**](docs/StakeAPI.md#buildstakingoperation) | **Post** /v1/stake/build | Build a new staking operation
*StakeAPI* | [**FetchHistoricalStakingBalances**](docs/StakeAPI.md#fetchhistoricalstakingbalances) | **Get** /v1/networks/{network_id}/addresses/{address_id}/stake/balances | Fetch historical staking balances
*StakeAPI* | [**FetchStakingRewards**](docs/StakeAPI.md#fetchstakingrewards) | **Post** /v1/stake/rewards/search | Fetch staking rewards
*StakeAPI* | [**GetExternalStakingOperation**](docs/StakeAPI.md#getexternalstakingoperation) | **Get** /v1/networks/{network_id}/addresses/{address_id}/staking_operations/{staking_operation_id} | Get the latest state of a staking operation
*StakeAPI* | [**GetStakingContext**](docs/StakeAPI.md#getstakingcontext) | **Post** /v1/stake/context | Get staking context
*StakeAPI* | [**GetValidator**](docs/StakeAPI.md#getvalidator) | **Get** /v1/networks/{network_id}/assets/{asset_id}/validators/{validator_id} | Get a validator belonging to the CDP project
*StakeAPI* | [**ListValidators**](docs/StakeAPI.md#listvalidators) | **Get** /v1/networks/{network_id}/assets/{asset_id}/validators | List validators belonging to the CDP project
*TradesAPI* | [**BroadcastTrade**](docs/TradesAPI.md#broadcasttrade) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/trades/{trade_id}/broadcast | Broadcast a trade
*TradesAPI* | [**CreateTrade**](docs/TradesAPI.md#createtrade) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/trades | Create a new trade for an address
*TradesAPI* | [**GetTrade**](docs/TradesAPI.md#gettrade) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/trades/{trade_id} | Get a trade by ID
*TradesAPI* | [**ListTrades**](docs/TradesAPI.md#listtrades) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/trades | List trades for an address.
*TransactionHistoryAPI* | [**ListAddressTransactions**](docs/TransactionHistoryAPI.md#listaddresstransactions) | **Get** /v1/networks/{network_id}/addresses/{address_id}/transactions | List transactions for an address.
*TransfersAPI* | [**BroadcastTransfer**](docs/TransfersAPI.md#broadcasttransfer) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/transfers/{transfer_id}/broadcast | Broadcast a transfer
*TransfersAPI* | [**CreateTransfer**](docs/TransfersAPI.md#createtransfer) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/transfers | Create a new transfer for an address
*TransfersAPI* | [**GetTransfer**](docs/TransfersAPI.md#gettransfer) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/transfers/{transfer_id} | Get a transfer by ID
*TransfersAPI* | [**ListTransfers**](docs/TransfersAPI.md#listtransfers) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/transfers | List transfers for an address.
*UsersAPI* | [**GetCurrentUser**](docs/UsersAPI.md#getcurrentuser) | **Get** /v1/users/me | Get current user
*ValidatorsAPI* | [**GetValidator**](docs/ValidatorsAPI.md#getvalidator) | **Get** /v1/networks/{network_id}/assets/{asset_id}/validators/{validator_id} | Get a validator belonging to the CDP project
*ValidatorsAPI* | [**ListValidators**](docs/ValidatorsAPI.md#listvalidators) | **Get** /v1/networks/{network_id}/assets/{asset_id}/validators | List validators belonging to the CDP project
*WalletStakeAPI* | [**BroadcastStakingOperation**](docs/WalletStakeAPI.md#broadcaststakingoperation) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/staking_operations/{staking_operation_id}/broadcast | Broadcast a staking operation
*WalletStakeAPI* | [**CreateStakingOperation**](docs/WalletStakeAPI.md#createstakingoperation) | **Post** /v1/wallets/{wallet_id}/addresses/{address_id}/staking_operations | Create a new staking operation for an address
*WalletStakeAPI* | [**GetStakingOperation**](docs/WalletStakeAPI.md#getstakingoperation) | **Get** /v1/wallets/{wallet_id}/addresses/{address_id}/staking_operations/{staking_operation_id} | Get the latest state of a staking operation
*WalletsAPI* | [**CreateWallet**](docs/WalletsAPI.md#createwallet) | **Post** /v1/wallets | Create a new wallet
*WalletsAPI* | [**GetWallet**](docs/WalletsAPI.md#getwallet) | **Get** /v1/wallets/{wallet_id} | Get wallet by ID
*WalletsAPI* | [**GetWalletBalance**](docs/WalletsAPI.md#getwalletbalance) | **Get** /v1/wallets/{wallet_id}/balances/{asset_id} | Get the balance of an asset in the wallet
*WalletsAPI* | [**ListWalletBalances**](docs/WalletsAPI.md#listwalletbalances) | **Get** /v1/wallets/{wallet_id}/balances | List wallet balances
*WalletsAPI* | [**ListWallets**](docs/WalletsAPI.md#listwallets) | **Get** /v1/wallets | List wallets
*WebhooksAPI* | [**CreateWalletWebhook**](docs/WebhooksAPI.md#createwalletwebhook) | **Post** /v1/wallets/{wallet_id}/webhooks | Create a new webhook scoped to a wallet
*WebhooksAPI* | [**CreateWebhook**](docs/WebhooksAPI.md#createwebhook) | **Post** /v1/webhooks | Create a new webhook
*WebhooksAPI* | [**DeleteWebhook**](docs/WebhooksAPI.md#deletewebhook) | **Delete** /v1/webhooks/{webhook_id} | Delete a webhook
*WebhooksAPI* | [**ListWebhooks**](docs/WebhooksAPI.md#listwebhooks) | **Get** /v1/webhooks | List webhooks
@@ -145,6 +155,9 @@ Class | Method | HTTP request | Description
- [AddressBalanceList](docs/AddressBalanceList.md)
- [AddressHistoricalBalanceList](docs/AddressHistoricalBalanceList.md)
- [AddressList](docs/AddressList.md)
- [AddressReputation](docs/AddressReputation.md)
- [AddressReputationMetadata](docs/AddressReputationMetadata.md)
- [AddressRisk](docs/AddressRisk.md)
- [AddressTransactionList](docs/AddressTransactionList.md)
- [Asset](docs/Asset.md)
- [Balance](docs/Balance.md)
@@ -159,6 +172,8 @@ Class | Method | HTTP request | Description
- [ContractInvocationList](docs/ContractInvocationList.md)
- [CreateAddressRequest](docs/CreateAddressRequest.md)
- [CreateContractInvocationRequest](docs/CreateContractInvocationRequest.md)
- [CreateFundOperationRequest](docs/CreateFundOperationRequest.md)
- [CreateFundQuoteRequest](docs/CreateFundQuoteRequest.md)
- [CreatePayloadSignatureRequest](docs/CreatePayloadSignatureRequest.md)
- [CreateServerSignerRequest](docs/CreateServerSignerRequest.md)
- [CreateSmartContractRequest](docs/CreateSmartContractRequest.md)
@@ -167,28 +182,44 @@ Class | Method | HTTP request | Description
- [CreateTransferRequest](docs/CreateTransferRequest.md)
- [CreateWalletRequest](docs/CreateWalletRequest.md)
- [CreateWalletRequestWallet](docs/CreateWalletRequestWallet.md)
- [CreateWalletWebhookRequest](docs/CreateWalletWebhookRequest.md)
- [CreateWebhookRequest](docs/CreateWebhookRequest.md)
- [CryptoAmount](docs/CryptoAmount.md)
- [DedicatedEthStakeTransactionDetail](docs/DedicatedEthStakeTransactionDetail.md)
- [DedicatedEthUnstakeTransactionDetail](docs/DedicatedEthUnstakeTransactionDetail.md)
- [DeploySmartContractRequest](docs/DeploySmartContractRequest.md)
- [ERC20TransferEvent](docs/ERC20TransferEvent.md)
- [ERC721TransferEvent](docs/ERC721TransferEvent.md)
- [Error](docs/Error.md)
- [EthereumTokenTransfer](docs/EthereumTokenTransfer.md)
- [EthereumTransaction](docs/EthereumTransaction.md)
- [EthereumTransactionAccess](docs/EthereumTransactionAccess.md)
- [EthereumTransactionAccessList](docs/EthereumTransactionAccessList.md)
- [EthereumTransactionFlattenedTrace](docs/EthereumTransactionFlattenedTrace.md)
- [EthereumValidatorDepositData](docs/EthereumValidatorDepositData.md)
- [EthereumValidatorMetadata](docs/EthereumValidatorMetadata.md)
- [FaucetTransaction](docs/FaucetTransaction.md)
- [FeatureSet](docs/FeatureSet.md)
- [FetchHistoricalStakingBalances200Response](docs/FetchHistoricalStakingBalances200Response.md)
- [FetchStakingRewards200Response](docs/FetchStakingRewards200Response.md)
- [FetchStakingRewardsRequest](docs/FetchStakingRewardsRequest.md)
- [FiatAmount](docs/FiatAmount.md)
- [FundOperation](docs/FundOperation.md)
- [FundOperationFees](docs/FundOperationFees.md)
- [FundOperationList](docs/FundOperationList.md)
- [FundQuote](docs/FundQuote.md)
- [GetStakingContextRequest](docs/GetStakingContextRequest.md)
- [HistoricalBalance](docs/HistoricalBalance.md)
- [MultiTokenContractOptions](docs/MultiTokenContractOptions.md)
- [NFTContractOptions](docs/NFTContractOptions.md)
- [Network](docs/Network.md)
- [NetworkIdentifier](docs/NetworkIdentifier.md)
- [OnchainName](docs/OnchainName.md)
- [OnchainNameList](docs/OnchainNameList.md)
- [PartialEthStakingTransactionDetail](docs/PartialEthStakingTransactionDetail.md)
- [PayloadSignature](docs/PayloadSignature.md)
- [PayloadSignatureList](docs/PayloadSignatureList.md)
- [ReadContractRequest](docs/ReadContractRequest.md)
- [SeedCreationEvent](docs/SeedCreationEvent.md)
- [SeedCreationEventResult](docs/SeedCreationEventResult.md)
- [ServerSigner](docs/ServerSigner.md)
@@ -203,6 +234,8 @@ Class | Method | HTTP request | Description
- [SmartContractList](docs/SmartContractList.md)
- [SmartContractOptions](docs/SmartContractOptions.md)
- [SmartContractType](docs/SmartContractType.md)
- [SolanaStakingTransactionDetail](docs/SolanaStakingTransactionDetail.md)
- [SolidityValue](docs/SolidityValue.md)
- [SponsoredSend](docs/SponsoredSend.md)
- [StakingBalance](docs/StakingBalance.md)
- [StakingContext](docs/StakingContext.md)
@@ -212,7 +245,10 @@ Class | Method | HTTP request | Description
- [StakingReward](docs/StakingReward.md)
- [StakingRewardFormat](docs/StakingRewardFormat.md)
- [StakingRewardUSDValue](docs/StakingRewardUSDValue.md)
- [StakingTransactionDetail](docs/StakingTransactionDetail.md)
- [StakingTransactionDetailType](docs/StakingTransactionDetailType.md)
- [TokenContractOptions](docs/TokenContractOptions.md)
- [TokenTransferType](docs/TokenTransferType.md)
- [Trade](docs/Trade.md)
- [TradeList](docs/TradeList.md)
- [Transaction](docs/Transaction.md)
6 changes: 6 additions & 0 deletions gen/client/api_addresses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading