Skip to content

CoboGlobal/cobo-waas2-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for cobo_waas2

The Cobo Wallet-as-a-Service (WaaS) 2.0 API is the latest version of Cobo’s WaaS API offering. It enables you to access Cobo’s full suite of crypto wallet technologies with powerful and flexible access controls. By encapsulating complex security protocols and streamlining blockchain interactions, this API allows you to concentrate on your core business activities without worrying about the safety of your assets. The WaaS 2.0 API presents the following key features:

  • A unified API for Cobo’s all four wallet types
  • Support for 80+ chains and 3000+ tokens
  • A comprehensive selection of webhook events
  • Flexible usage models for MPC Wallets, including Organization-Controlled Wallets and User-Controlled Wallets
  • Programmatic control of smart contract wallets such as Safe{Wallet} with fine-grained access controls
  • Seamlessly transfer funds across multiple exchanges, including Binance, OKX, Bybit, Deribit, and more

For more information about the WaaS 2.0 API, see Introduction to WaaS 2.0.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: v2
  • Package version: 1.8.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://www.cobo.com/waas

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

To use the development environment, set ContextEnv to coboWaas2.DevEnv.

ctx := context.WithValue(context.Background(), coboWaas2.ContextEnv, coboWaas2.DevEnv)

To use the production environment, set ContextEnv to waas2.ProdEnv.

ctx := context.WithValue(context.Background(), coboWaas2.ContextEnv, coboWaas2.ProdEnv)

you can also set server URL using context values coboWaas2.ContextServerHost of type string

ctx := context.WithValue(context.Background(), coboWaas2.ContextServerHost, "https://api[.xxxx].cobo.com/v2")

Set Api Signer

ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
    Secret: "<YOUR_API_PRIV_KEY_IN_HEX>",
})

Documentation for API Endpoints

All URIs are relative to https://api.dev.cobo.com/v2

Class Method HTTP request Description
AddressBooksAPI ListAddressBooks Get /address_books List address book entries
DevelopersAPI GetApiKeyInfo Get /developers/api_key_info Get API key information
DevelopersAPI ListCallbackMessages Get /developers/callback_messages List all callback messages
DevelopersAPI RetryCallbackMessage Post /developers/callback_messages/{message_id}/retry Retry callback message
DevelopersWebhooksAPI CreateWebhookEndpoint Post /webhooks/endpoints Register webhook endpoint
DevelopersWebhooksAPI GetWebhookEndpointById Get /webhooks/endpoints/{endpoint_id} Get webhook endpoint information
DevelopersWebhooksAPI GetWebhookEventById Get /webhooks/endpoints/{endpoint_id}/events/{event_id} Retrieve event information
DevelopersWebhooksAPI ListWebhookEndpoints Get /webhooks/endpoints List webhook endpoints
DevelopersWebhooksAPI ListWebhookEventDefinitions Get /webhooks/events/definitions Get webhook event types
DevelopersWebhooksAPI ListWebhookEventLogs Get /webhooks/endpoints/{endpoint_id}/events/{event_id}/logs List webhook event logs
DevelopersWebhooksAPI ListWebhookEvents Get /webhooks/endpoints/{endpoint_id}/events List all webhook events
DevelopersWebhooksAPI RetryWebhookEventById Post /webhooks/endpoints/{endpoint_id}/events/{event_id}/retry Retry event
DevelopersWebhooksAPI TriggerTestWebhookEvent Post /webhooks/events/trigger Trigger test event
DevelopersWebhooksAPI UpdateWebhookEndpointById Put /webhooks/endpoints/{endpoint_id} Update webhook endpoint
OAuthAPI GetToken Get /oauth/token Get Org Access Token
OAuthAPI RefreshToken Post /oauth/token Refresh Org Access Token
StakingsAPI CreateClaimActivity Post /stakings/activities/claim Create claim activity
StakingsAPI CreateStakeActivity Post /stakings/activities/stake Create stake activity
StakingsAPI CreateUnstakeActivity Post /stakings/activities/unstake Create unstake activity
StakingsAPI CreateWithdrawActivity Post /stakings/activities/withdraw Create withdraw activity
StakingsAPI GetStakingActivityById Get /stakings/activities/{activity_id} Get staking activity details
StakingsAPI GetStakingById Get /stakings/{staking_id} Get staking position details
StakingsAPI GetStakingEstimationFee Post /stakings/estimate_fee Estimate staking fees
StakingsAPI GetStakingEstimationFeeV2 Post /stakings/estimate_fee_v2 Estimate staking fees v2
StakingsAPI GetStakingPoolById Get /stakings/pools/{pool_id} Get staking pool details
StakingsAPI ListStakingActivities Get /stakings/activities List staking activities
StakingsAPI ListStakingPools Get /stakings/pools List staking pools
StakingsAPI ListStakings Get /stakings List staking positions
TransactionsAPI BroadcastSignedTransactions Post /transactions/broadcast Broadcast signed transactions
TransactionsAPI CancelTransactionById Post /transactions/{transaction_id}/cancel Cancel transaction
TransactionsAPI CheckLoopTransfers Get /transactions/check_loop_transfers Check Cobo Loop transfers
TransactionsAPI CreateContractCallTransaction Post /transactions/contract_call Call smart contract
TransactionsAPI CreateMessageSignTransaction Post /transactions/message_sign Sign message
TransactionsAPI CreateTransferTransaction Post /transactions/transfer Transfer token
TransactionsAPI DropTransactionById Post /transactions/{transaction_id}/drop Drop transaction
TransactionsAPI EstimateFee Post /transactions/estimate_fee Estimate transaction fee
TransactionsAPI GetTransactionApprovalDetail Get /transactions/{transaction_id}/approval_detail Get transaction approval information
TransactionsAPI GetTransactionById Get /transactions/{transaction_id} Get transaction information
TransactionsAPI ListTransactions Get /transactions List all transactions
TransactionsAPI ResendTransactionById Post /transactions/{transaction_id}/resend Resend transaction
TransactionsAPI SpeedupTransactionById Post /transactions/{transaction_id}/speedup Speed up transaction
TravelRuleAPI GetTransactionLimitation Get /travel_rule/transaction/limitation Retrieve transaction limitations
TravelRuleAPI ListSupportedCountries Get /travel_rule/transaction/countries List supported countries
TravelRuleAPI SubmitDepositTravelRuleInfo Post /travel_rule/transaction/deposit/travel_rule_info Submit Deposit Transaction Travel Rule information
TravelRuleAPI SubmitWithdrawTravelRuleInfo Post /travel_rule/transaction/withdraw/travel_rule_info Submit Withdraw Transaction Travel Rule information
WalletsAPI CheckAddressChainsValidity Get /wallets/check_address_chains_validity Check address validity across chains
WalletsAPI CheckAddressValidity Get /wallets/check_address_validity Check address validity
WalletsAPI CheckAddressesValidity Get /wallets/check_addresses_validity Check addresses validity
WalletsAPI CreateAddress Post /wallets/{wallet_id}/addresses Create addresses in wallet
WalletsAPI CreateWallet Post /wallets Create wallet
WalletsAPI DeleteWalletById Post /wallets/{wallet_id}/delete Delete wallet
WalletsAPI GetChainById Get /wallets/chains/{chain_id} Get chain information
WalletsAPI GetMaxTransferableValue Get /wallets/{wallet_id}/max_transferable_value Get maximum transferable value
WalletsAPI GetTokenById Get /wallets/tokens/{token_id} Get token information
WalletsAPI GetWalletById Get /wallets/{wallet_id} Get wallet information
WalletsAPI ListAddresses Get /wallets/{wallet_id}/addresses List wallet addresses
WalletsAPI ListEnabledChains Get /wallets/enabled_chains List enabled chains
WalletsAPI ListEnabledTokens Get /wallets/enabled_tokens List enabled tokens
WalletsAPI ListSupportedChains Get /wallets/chains List supported chains
WalletsAPI ListSupportedTokens Get /wallets/tokens List supported tokens
WalletsAPI ListTokenBalancesForAddress Get /wallets/{wallet_id}/addresses/{address}/tokens List token balances by address
WalletsAPI ListTokenBalancesForWallet Get /wallets/{wallet_id}/tokens List token balances by wallet
WalletsAPI ListUtxos Get /wallets/{wallet_id}/utxos List UTXOs
WalletsAPI ListWallets Get /wallets List all wallets
WalletsAPI LockUtxos Post /wallets/{wallet_id}/utxos/lock Lock UTXOs
WalletsAPI UnlockUtxos Post /wallets/{wallet_id}/utxos/unlock Unlock UTXOs
WalletsAPI UpdateWalletById Put /wallets/{wallet_id} Update wallet
WalletsExchangeWalletAPI ListAssetBalancesForExchangeWallet Get /wallets/{wallet_id}/exchanges/assets List asset balances
WalletsExchangeWalletAPI ListExchanges Get /wallets/exchanges List supported exchanges
WalletsExchangeWalletAPI ListSupportedAssetsForExchange Get /wallets/exchanges/{exchange_id}/assets List supported assets
WalletsExchangeWalletAPI ListSupportedChainsForExchange Get /wallets/exchanges/{exchange_id}/assets/{asset_id}/chains List supported chains
WalletsMPCWalletsAPI CancelTssRequestById Post /wallets/mpc/vaults/{vault_id}/tss_requests/{tss_request_id}/cancel Cancel TSS request
WalletsMPCWalletsAPI CreateKeyShareHolderGroup Post /wallets/mpc/vaults/{vault_id}/key_share_holder_groups Create key share holder group
WalletsMPCWalletsAPI CreateMpcProject Post /wallets/mpc/projects Create project
WalletsMPCWalletsAPI CreateMpcVault Post /wallets/mpc/vaults Create vault
WalletsMPCWalletsAPI CreateTssRequest Post /wallets/mpc/vaults/{vault_id}/tss_requests Create TSS request
WalletsMPCWalletsAPI DeleteKeyShareHolderGroupById Post /wallets/mpc/vaults/{vault_id}/key_share_holder_groups/{key_share_holder_group_id}/delete Delete key share holder group
WalletsMPCWalletsAPI GetKeyShareHolderGroupById Get /wallets/mpc/vaults/{vault_id}/key_share_holder_groups/{key_share_holder_group_id} Get key share holder group information
WalletsMPCWalletsAPI GetMpcProjectById Get /wallets/mpc/projects/{project_id} Get project information
WalletsMPCWalletsAPI GetMpcVaultById Get /wallets/mpc/vaults/{vault_id} Get vault information
WalletsMPCWalletsAPI GetTssRequestById Get /wallets/mpc/vaults/{vault_id}/tss_requests/{tss_request_id} Get TSS request
WalletsMPCWalletsAPI ListCoboKeyHolders Get /wallets/mpc/cobo_key_share_holders List all Cobo key share holders
WalletsMPCWalletsAPI ListKeyShareHolderGroups Get /wallets/mpc/vaults/{vault_id}/key_share_holder_groups List all key share holder groups
WalletsMPCWalletsAPI ListMpcProjects Get /wallets/mpc/projects List all projects
WalletsMPCWalletsAPI ListMpcVaults Get /wallets/mpc/vaults List all vaults
WalletsMPCWalletsAPI ListTssRequests Get /wallets/mpc/vaults/{vault_id}/tss_requests List TSS requests
WalletsMPCWalletsAPI UpdateKeyShareHolderGroupById Put /wallets/mpc/vaults/{vault_id}/key_share_holder_groups/{key_share_holder_group_id} Update key share holder group
WalletsMPCWalletsAPI UpdateMpcProjectById Put /wallets/mpc/projects/{project_id} Update project name
WalletsMPCWalletsAPI UpdateMpcVaultById Put /wallets/mpc/vaults/{vault_id} Update vault name
WalletsSmartContractWalletsAPI ListSafeWalletDelegates Post /wallets/{wallet_id}/smart_contracts/delegates List Delegates

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

CoboAuth

  • Type: API key
  • API key parameter name: BIZ-API-KEY
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: BIZ-API-KEY and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		cobo_waas2.ContextAPIKeys,
		map[string]cobo_waas2.APIKey{
			"BIZ-API-KEY": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

OAuth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://auth.cobo.com/authorize
  • Scopes:
  • custodial_asset_wallet:create: Create access to custodial asset wallets
  • custodial_asset_wallet:add: Generate address access to custodial asset wallets
  • custodial_asset_wallet:edit: Change wallet name access to custodial asset wallets
  • custodial_asset_wallet:withdraw: Withdraw access to custodial asset wallets
  • mpc_organization_controlled_wallet:create: Create access to MPC organization-controlled wallets
  • mpc_organization_controlled_wallet:add: Generate address access to MPC organization-controlled wallets
  • mpc_organization_controlled_wallet:edit: Change wallet name access to MPC organization-controlled wallets
  • mpc_organization_controlled_wallet:withdraw: Withdraw access to MPC organization-controlled wallets
  • mpc_organization_controlled_wallet:contract_call: Contract call access to MPC organization-controlled wallets
  • mpc_organization_controlled_wallet:message_sign: Message sign access to MPC organization-controlled wallets
  • mpc_organization_controlled_vault:manage: Create/Edit access to MPC organization-controlled vaults
  • mpc_organization_controlled_key_group:manage: Create/Edit/Delete access to MPC organization-controlled key groups
  • mpc_organization_controlled_tss_request:manage: Create/Cancel access to MPC organization-controlled tss requests
  • mpc_user_controlled_wallet:create: Create access to MPC user-controlled wallets
  • mpc_user_controlled_wallet:add: Generate address access to MPC user-controlled wallets
  • mpc_user_controlled_wallet:edit: Change wallet name access to MPC user-controlled wallets
  • mpc_user_controlled_wallet:withdraw: Withdraw access to MPC user-controlled wallets
  • mpc_user_controlled_wallet:contract_call: Contract call access to MPC user-controlled wallets
  • mpc_user_controlled_wallet:message_sign: Message sign access to MPC user-controlled wallets
  • mpc_user_controlled_project:manage: Create/Edit access to MPC user-controlled projects
  • mpc_user_controlled_vault:manage: Create/Edit access to MPC user-controlled vaults
  • mpc_user_controlled_key_group:manage: Create/Edit/Delete access to MPC user-controlled key groups
  • mpc_user_controlled_tss_request:manage: Create/Cancel access to MPC user-controlled tss requests
  • webhook:resend: Resend access to webhook events
  • webhook_url:edit: Create/Edit access to webhook urls

Example

auth := context.WithValue(context.Background(), cobo_waas2.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, cobo_waas2.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]