turnkey

package
v0.0.0-...-2182c36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(turnkeyApiHost, turnkeyApiPrivateKey, organizationID string) error

Creates a Turnkey SDK client from a Turnkey API key

Types

type CreateSubOrganizationResult

type CreateSubOrganizationResult struct {
	SubOrganizationId string
	WalletId          string
	// Note: we _could_ create more than 1 address per sub-org
	// But we don't want to right now.
	EthereumAddress string
}

Custom type to hold results from a sub-org creation result

type TurnkeyApiClient

type TurnkeyApiClient struct {
	// APIKey is the structure
	APIKey *apikey.Key

	// Client is a raw TurnkeyAPI client
	Client *client.TurnkeyAPI

	// Organization is the default organization to be used for tests.
	OrganizationID string

	TurnkeyApiHost string
}
var Client *TurnkeyApiClient

func (*TurnkeyApiClient) CreateUserSubOrganization

func (c *TurnkeyApiClient) CreateUserSubOrganization(userEmail string, attestation types.Attestation, challenge string) (*CreateSubOrganizationResult, error)

This function creates a new sub-organization for a given user email. Turnkey's CREATE_SUB_ORGANIZATION activity supports creating a sub-org and private key(s) at once, atomically. We use this to our advantage here!

func (*TurnkeyApiClient) EmailAuth

func (c *TurnkeyApiClient) EmailAuth(subOrganizationId, email, targetPublicKey string) (string, string, error)

Initiates email auth for a given sub-organization user

func (*TurnkeyApiClient) ForwardSignedActivity

func (c *TurnkeyApiClient) ForwardSignedActivity(url string, requestBody string, stamp types.TurnkeyStamp) ([]byte, error)

TODO: should be part of the Go SDK! This function does something similar to `ForwardSignedRequest`, except it also polls until the activity is COMPLETE or FAILED If that's not the case after 3 attempts, give up.

func (*TurnkeyApiClient) ForwardSignedRequest

func (c *TurnkeyApiClient) ForwardSignedRequest(url string, requestBody string, stamp types.TurnkeyStamp) (int, []byte, error)

Method to forward signed requests to Turnkey. TODO: should be part of the Go SDK!

func (*TurnkeyApiClient) GetAuthenticator

func (c *TurnkeyApiClient) GetAuthenticator() *sdk.Authenticator

func (*TurnkeyApiClient) GetEthereumAddress

func (c *TurnkeyApiClient) GetEthereumAddress(organizationId, privateKeyId string) (string, error)

Gets the Ethereum address for a private key ID created on Turnkey This is only used to pull one address: the warchest private key address

func (*TurnkeyApiClient) InitRecovery

func (c *TurnkeyApiClient) InitRecovery(subOrganizationId, email, targetPublicKey string) (string, error)

Starts recovery for a given sub-organization The backend API key can do this because parent organizations are allowed to initiate recovery for their sub-orgs. Any (API) user which has the ability to perform ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY in the parent can thus target the sub-organizations as well.

func (*TurnkeyApiClient) SignTransaction

func (c *TurnkeyApiClient) SignTransaction(organizationId string, signWith string, unsignedTransaction string) (string, error)

Takes an unsigned ETH payload and tries to sign it. On success, the signed transaction is returned. On failure, an error is returned.

func (*TurnkeyApiClient) WaitForResult

func (c *TurnkeyApiClient) WaitForResult(organizationId, activityId string) (*models.Result, error)

Utility to wait for an activity result

func (*TurnkeyApiClient) Whoami

func (c *TurnkeyApiClient) Whoami() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL