privy_ruby 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +1 -1
- data/lib/privy/base58.rb +41 -0
- data/lib/privy/client.rb +8 -0
- data/lib/privy/cryptography.rb +34 -0
- data/lib/privy/models/create_link_auth_intent_input.rb +17 -0
- data/lib/privy/models/create_link_auth_intent_response.rb +36 -0
- data/lib/privy/models/create_stripe_onramp_session_input.rb +33 -0
- data/lib/privy/models/create_stripe_onramp_session_response.rb +23 -0
- data/lib/privy/models/device_authorization_response.rb +63 -0
- data/lib/privy/models/earn_incentive_reward_entry.rb +50 -0
- data/lib/privy/models/earn_incentive_rewards_query.rb +18 -0
- data/lib/privy/models/earn_incentive_rewards_response.rb +19 -0
- data/lib/privy/models/exchange_stripe_tokens_input.rb +23 -0
- data/lib/privy/models/exchange_stripe_tokens_response.rb +17 -0
- data/lib/privy/models/fiat_onramp_provider.rb +2 -0
- data/lib/privy/models/fiat_onramp_stripe_sdk_session_response.rb +45 -0
- data/lib/privy/models/fiat_onramp_url_session_response.rb +39 -0
- data/lib/privy/models/get_fiat_onramp_url_response.rb +12 -14
- data/lib/privy/models/get_stripe_crypto_customer_response.rb +39 -0
- data/lib/privy/models/kraken_embed_custom_order_cancelled_webhook_payload.rb +66 -0
- data/lib/privy/models/kraken_embed_custom_order_executed_webhook_payload.rb +54 -0
- data/lib/privy/models/kraken_embed_custom_order_execution_failed_webhook_payload.rb +67 -0
- data/lib/privy/models/link_auth_intent_created.rb +35 -0
- data/lib/privy/models/link_auth_intent_no_account.rb +27 -0
- data/lib/privy/models/list_stripe_consumer_wallets_response.rb +17 -0
- data/lib/privy/models/list_stripe_payment_tokens_response.rb +17 -0
- data/lib/privy/models/onramp_session_params.rb +61 -0
- data/lib/privy/models/refresh_stripe_quote_response.rb +18 -0
- data/lib/privy/models/rule_delete_intent_response.rb +63 -0
- data/lib/privy/models/rule_intent_response.rb +0 -1
- data/lib/privy/models/rule_mutate_intent_response.rb +64 -0
- data/lib/privy/models/stripe_consumer_wallet.rb +29 -0
- data/lib/privy/models/stripe_crypto_customer_active.rb +39 -0
- data/lib/privy/models/stripe_crypto_customer_expired.rb +33 -0
- data/lib/privy/models/stripe_crypto_customer_none.rb +27 -0
- data/lib/privy/models/stripe_onramp_checkout_response.rb +25 -0
- data/lib/privy/models/stripe_onramp_session_status.rb +17 -0
- data/lib/privy/models/stripe_payment_token.rb +23 -0
- data/lib/privy/models/stripe_quote.rb +17 -0
- data/lib/privy/models/stripe_transaction_details.rb +17 -0
- data/lib/privy/models/stripe_verification.rb +23 -0
- data/lib/privy/models/swap_action_response.rb +9 -1
- data/lib/privy/models/swap_destination.rb +13 -4
- data/lib/privy/models/swap_quote_destination.rb +15 -4
- data/lib/privy/models/swap_quote_request_body.rb +9 -1
- data/lib/privy/models/swap_quote_response.rb +25 -1
- data/lib/privy/models/swap_request_body.rb +9 -1
- data/lib/privy/models/wallets/swap_execute_params.rb +45 -0
- data/lib/privy/models/wallets/swap_quote_params.rb +36 -0
- data/lib/privy/models.rb +71 -4
- data/lib/privy/public_api/privy_client.rb +2 -1
- data/lib/privy/public_api/services/earn/ethereum/incentive.rb +61 -0
- data/lib/privy/public_api/services/earn/ethereum.rb +131 -0
- data/lib/privy/public_api/services/earn.rb +18 -0
- data/lib/privy/public_api/services/key_quorums.rb +7 -1
- data/lib/privy/public_api/services/policies.rb +21 -3
- data/lib/privy/public_api/services/transactions.rb +14 -0
- data/lib/privy/public_api/services/wallets.rb +153 -1
- data/lib/privy/resources/intents.rb +6 -6
- data/lib/privy/resources/oauth.rb +14 -0
- data/lib/privy/resources/onramps.rb +14 -0
- data/lib/privy/resources/wallets/swap.rb +105 -0
- data/lib/privy/resources/wallets.rb +10 -2
- data/lib/privy/version.rb +1 -1
- data/lib/privy/wallet_entropy.rb +60 -0
- data/lib/privy.rb +47 -4
- data/rbi/privy/client.rbi +6 -0
- data/rbi/privy/models/create_link_auth_intent_input.rbi +27 -0
- data/rbi/privy/models/create_link_auth_intent_response.rbi +68 -0
- data/rbi/privy/models/create_stripe_onramp_session_input.rbi +55 -0
- data/rbi/privy/models/create_stripe_onramp_session_response.rbi +30 -0
- data/rbi/privy/models/device_authorization_response.rbi +81 -0
- data/rbi/privy/models/earn_incentive_reward_entry.rbi +73 -0
- data/rbi/privy/models/earn_incentive_rewards_query.rbi +28 -0
- data/rbi/privy/models/earn_incentive_rewards_response.rbi +35 -0
- data/rbi/privy/models/exchange_stripe_tokens_input.rbi +33 -0
- data/rbi/privy/models/exchange_stripe_tokens_response.rbi +24 -0
- data/rbi/privy/models/fiat_onramp_provider.rbi +3 -0
- data/rbi/privy/models/fiat_onramp_stripe_sdk_session_response.rbi +78 -0
- data/rbi/privy/models/fiat_onramp_url_session_response.rbi +65 -0
- data/rbi/privy/models/get_fiat_onramp_url_response.rbi +12 -15
- data/rbi/privy/models/get_stripe_crypto_customer_response.rbi +81 -0
- data/rbi/privy/models/kraken_embed_custom_order_cancelled_webhook_payload.rbi +111 -0
- data/rbi/privy/models/kraken_embed_custom_order_executed_webhook_payload.rbi +101 -0
- data/rbi/privy/models/kraken_embed_custom_order_execution_failed_webhook_payload.rbi +111 -0
- data/rbi/privy/models/link_auth_intent_created.rbi +60 -0
- data/rbi/privy/models/link_auth_intent_no_account.rbi +54 -0
- data/rbi/privy/models/list_stripe_consumer_wallets_response.rbi +31 -0
- data/rbi/privy/models/list_stripe_payment_tokens_response.rbi +31 -0
- data/rbi/privy/models/onramp_session_params.rbi +76 -0
- data/rbi/privy/models/refresh_stripe_quote_response.rbi +33 -0
- data/rbi/privy/models/rule_delete_intent_response.rbi +113 -0
- data/rbi/privy/models/rule_mutate_intent_response.rbi +113 -0
- data/rbi/privy/models/stripe_consumer_wallet.rbi +38 -0
- data/rbi/privy/models/stripe_crypto_customer_active.rbi +68 -0
- data/rbi/privy/models/stripe_crypto_customer_expired.rbi +63 -0
- data/rbi/privy/models/stripe_crypto_customer_none.rbi +53 -0
- data/rbi/privy/models/stripe_onramp_checkout_response.rbi +51 -0
- data/rbi/privy/models/stripe_onramp_session_status.rbi +26 -0
- data/rbi/privy/models/stripe_payment_token.rbi +27 -0
- data/rbi/privy/models/stripe_quote.rbi +22 -0
- data/rbi/privy/models/stripe_transaction_details.rbi +24 -0
- data/rbi/privy/models/stripe_verification.rbi +27 -0
- data/rbi/privy/models/swap_action_response.rbi +17 -27
- data/rbi/privy/models/swap_destination.rbi +26 -7
- data/rbi/privy/models/swap_quote_destination.rbi +30 -7
- data/rbi/privy/models/swap_quote_request_body.rbi +11 -0
- data/rbi/privy/models/swap_quote_response.rbi +54 -3
- data/rbi/privy/models/swap_request_body.rbi +11 -0
- data/rbi/privy/models/wallets/swap_execute_params.rbi +71 -0
- data/rbi/privy/models/wallets/swap_quote_params.rbi +58 -0
- data/rbi/privy/models.rbi +76 -5
- data/rbi/privy/resources/intents.rbi +3 -3
- data/rbi/privy/resources/oauth.rbi +12 -0
- data/rbi/privy/resources/onramps.rbi +12 -0
- data/rbi/privy/resources/wallets/swap.rbi +94 -0
- data/rbi/privy/resources/wallets.rbi +9 -2
- data/sig/privy/client.rbs +4 -0
- data/sig/privy/models/create_link_auth_intent_input.rbs +15 -0
- data/sig/privy/models/create_link_auth_intent_response.rbs +26 -0
- data/sig/privy/models/create_stripe_onramp_session_input.rbs +30 -0
- data/sig/privy/models/create_stripe_onramp_session_response.rbs +16 -0
- data/sig/privy/models/device_authorization_response.rbs +45 -0
- data/sig/privy/models/earn_incentive_reward_entry.rbs +42 -0
- data/sig/privy/models/earn_incentive_rewards_query.rbs +13 -0
- data/sig/privy/models/earn_incentive_rewards_response.rbs +16 -0
- data/sig/privy/models/exchange_stripe_tokens_input.rbs +19 -0
- data/sig/privy/models/exchange_stripe_tokens_response.rbs +13 -0
- data/sig/privy/models/fiat_onramp_provider.rbs +4 -0
- data/sig/privy/models/fiat_onramp_stripe_sdk_session_response.rbs +45 -0
- data/sig/privy/models/fiat_onramp_url_session_response.rbs +40 -0
- data/sig/privy/models/get_fiat_onramp_url_response.rbs +6 -8
- data/sig/privy/models/get_stripe_crypto_customer_response.rbs +29 -0
- data/sig/privy/models/kraken_embed_custom_order_cancelled_webhook_payload.rbs +50 -0
- data/sig/privy/models/kraken_embed_custom_order_executed_webhook_payload.rbs +45 -0
- data/sig/privy/models/kraken_embed_custom_order_execution_failed_webhook_payload.rbs +50 -0
- data/sig/privy/models/link_auth_intent_created.rbs +32 -0
- data/sig/privy/models/link_auth_intent_no_account.rbs +26 -0
- data/sig/privy/models/list_stripe_consumer_wallets_response.rbs +14 -0
- data/sig/privy/models/list_stripe_payment_tokens_response.rbs +14 -0
- data/sig/privy/models/onramp_session_params.rbs +50 -0
- data/sig/privy/models/refresh_stripe_quote_response.rbs +13 -0
- data/sig/privy/models/rule_delete_intent_response.rbs +66 -0
- data/sig/privy/models/rule_mutate_intent_response.rbs +66 -0
- data/sig/privy/models/stripe_consumer_wallet.rbs +22 -0
- data/sig/privy/models/stripe_crypto_customer_active.rbs +40 -0
- data/sig/privy/models/stripe_crypto_customer_expired.rbs +35 -0
- data/sig/privy/models/stripe_crypto_customer_none.rbs +28 -0
- data/sig/privy/models/stripe_onramp_checkout_response.rbs +29 -0
- data/sig/privy/models/stripe_onramp_session_status.rbs +15 -0
- data/sig/privy/models/stripe_payment_token.rbs +15 -0
- data/sig/privy/models/stripe_quote.rbs +13 -0
- data/sig/privy/models/stripe_transaction_details.rbs +13 -0
- data/sig/privy/models/stripe_verification.rbs +15 -0
- data/sig/privy/models/swap_action_response.rbs +7 -0
- data/sig/privy/models/swap_destination.rbs +16 -3
- data/sig/privy/models/swap_quote_destination.rbs +16 -3
- data/sig/privy/models/swap_quote_request_body.rbs +9 -0
- data/sig/privy/models/swap_quote_response.rbs +26 -3
- data/sig/privy/models/swap_request_body.rbs +9 -0
- data/sig/privy/models/wallets/swap_execute_params.rbs +44 -0
- data/sig/privy/models/wallets/swap_quote_params.rbs +34 -0
- data/sig/privy/models.rbs +69 -5
- data/sig/privy/resources/intents.rbs +3 -3
- data/sig/privy/resources/oauth.rbs +7 -0
- data/sig/privy/resources/onramps.rbs +7 -0
- data/sig/privy/resources/wallets/swap.rbs +34 -0
- data/sig/privy/resources/wallets.rbs +2 -0
- metadata +125 -8
- data/lib/privy/models/gas_sponsorship_configuration.rb +0 -29
- data/lib/privy/models/gas_sponsorship_configuration_input.rb +0 -29
- data/rbi/privy/models/gas_sponsorship_configuration.rbi +0 -48
- data/rbi/privy/models/gas_sponsorship_configuration_input.rbi +0 -60
- data/sig/privy/models/gas_sponsorship_configuration.rbs +0 -30
- data/sig/privy/models/gas_sponsorship_configuration_input.rbs +0 -36
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Privy
|
|
4
|
+
module Services
|
|
5
|
+
class Earn
|
|
6
|
+
class Ethereum < Privy::Resources::Wallets::Earn::Ethereum
|
|
7
|
+
attr_reader :privy_client
|
|
8
|
+
|
|
9
|
+
# @return [Privy::Services::Earn::Ethereum::Incentive]
|
|
10
|
+
attr_reader :incentive
|
|
11
|
+
|
|
12
|
+
def initialize(client:, privy_client:)
|
|
13
|
+
super(client: client)
|
|
14
|
+
@privy_client = privy_client
|
|
15
|
+
@incentive = Privy::Services::Earn::Ethereum::Incentive.new(
|
|
16
|
+
client: client,
|
|
17
|
+
privy_client: privy_client
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Deposit assets into an ERC-4626 vault.
|
|
22
|
+
#
|
|
23
|
+
# @example Deposit by human-readable amount
|
|
24
|
+
# client.wallets.earn.ethereum.deposit("wallet-id", earn_deposit_params: {
|
|
25
|
+
# vault_id: "vault-id",
|
|
26
|
+
# amount: "1.5"
|
|
27
|
+
# }, authorization_context: ctx)
|
|
28
|
+
#
|
|
29
|
+
# @example Deposit by raw amount
|
|
30
|
+
# client.wallets.earn.ethereum.deposit("wallet-id", earn_deposit_params: {
|
|
31
|
+
# vault_id: "vault-id",
|
|
32
|
+
# raw_amount: "1500000"
|
|
33
|
+
# })
|
|
34
|
+
#
|
|
35
|
+
# @param wallet_id [String] ID of the wallet to deposit from.
|
|
36
|
+
# @param earn_deposit_params [Hash] Body parameters for the deposit operation.
|
|
37
|
+
# @option earn_deposit_params [String] :vault_id ID of the vault to deposit into.
|
|
38
|
+
# @option earn_deposit_params [String, nil] :amount Human-readable decimal amount to deposit. Exactly one of
|
|
39
|
+
# :amount or :raw_amount must be provided.
|
|
40
|
+
# @option earn_deposit_params [String, nil] :raw_amount Amount in the smallest unit to deposit. Exactly one of
|
|
41
|
+
# :amount or :raw_amount must be provided.
|
|
42
|
+
# @param authorization_context [Privy::Authorization::AuthorizationContext, nil] Authorization context for owned wallets.
|
|
43
|
+
# @param idempotency_key [String, nil] Ensures the request is executed only once.
|
|
44
|
+
# @param request_expiry [Integer, nil] Absolute Unix-ms timestamp at which the
|
|
45
|
+
# request expires. Defaults to the value computed by the client's
|
|
46
|
+
# PrivyRequestExpiryOptions.
|
|
47
|
+
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
48
|
+
#
|
|
49
|
+
# @return [Privy::Models::EarnDepositActionResponse]
|
|
50
|
+
def deposit(
|
|
51
|
+
wallet_id,
|
|
52
|
+
earn_deposit_params:,
|
|
53
|
+
authorization_context: nil,
|
|
54
|
+
idempotency_key: nil,
|
|
55
|
+
request_expiry: nil,
|
|
56
|
+
request_options: nil
|
|
57
|
+
)
|
|
58
|
+
prepared = Privy::Authorization.prepare_request(
|
|
59
|
+
privy_client,
|
|
60
|
+
method: :post,
|
|
61
|
+
url: Privy::Authorization.signed_url(
|
|
62
|
+
privy_client,
|
|
63
|
+
"v1/wallets/#{wallet_id}/earn/ethereum/deposit"
|
|
64
|
+
),
|
|
65
|
+
body: earn_deposit_params,
|
|
66
|
+
authorization_context: authorization_context,
|
|
67
|
+
idempotency_key: idempotency_key,
|
|
68
|
+
request_expiry: privy_client.compute_request_expiry(request_expiry)
|
|
69
|
+
)
|
|
70
|
+
combined_params = earn_deposit_params.merge(request_options: request_options)
|
|
71
|
+
Privy::Authorization.merge_prepared_headers!(combined_params, prepared.headers)
|
|
72
|
+
_deposit(wallet_id, combined_params)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Withdraw assets from an ERC-4626 vault.
|
|
76
|
+
#
|
|
77
|
+
# @example Withdraw by human-readable amount
|
|
78
|
+
# client.wallets.earn.ethereum.withdraw("wallet-id", earn_withdraw_params: {
|
|
79
|
+
# vault_id: "vault-id",
|
|
80
|
+
# amount: "1.5"
|
|
81
|
+
# }, authorization_context: ctx)
|
|
82
|
+
#
|
|
83
|
+
# @example Withdraw by raw amount
|
|
84
|
+
# client.wallets.earn.ethereum.withdraw("wallet-id", earn_withdraw_params: {
|
|
85
|
+
# vault_id: "vault-id",
|
|
86
|
+
# raw_amount: "1500000"
|
|
87
|
+
# })
|
|
88
|
+
#
|
|
89
|
+
# @param wallet_id [String] ID of the wallet to withdraw from.
|
|
90
|
+
# @param earn_withdraw_params [Hash] Body parameters for the withdraw operation.
|
|
91
|
+
# @option earn_withdraw_params [String] :vault_id ID of the vault to withdraw from.
|
|
92
|
+
# @option earn_withdraw_params [String, nil] :amount Human-readable decimal amount to withdraw. Exactly one of
|
|
93
|
+
# :amount or :raw_amount must be provided.
|
|
94
|
+
# @option earn_withdraw_params [String, nil] :raw_amount Amount in the smallest unit to withdraw. Exactly one of
|
|
95
|
+
# :amount or :raw_amount must be provided.
|
|
96
|
+
# @param authorization_context [Privy::Authorization::AuthorizationContext, nil] Authorization context for owned wallets.
|
|
97
|
+
# @param idempotency_key [String, nil] Ensures the request is executed only once.
|
|
98
|
+
# @param request_expiry [Integer, nil] Absolute Unix-ms timestamp at which the
|
|
99
|
+
# request expires. Defaults to the value computed by the client's
|
|
100
|
+
# PrivyRequestExpiryOptions.
|
|
101
|
+
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
102
|
+
#
|
|
103
|
+
# @return [Privy::Models::EarnWithdrawActionResponse]
|
|
104
|
+
def withdraw(
|
|
105
|
+
wallet_id,
|
|
106
|
+
earn_withdraw_params:,
|
|
107
|
+
authorization_context: nil,
|
|
108
|
+
idempotency_key: nil,
|
|
109
|
+
request_expiry: nil,
|
|
110
|
+
request_options: nil
|
|
111
|
+
)
|
|
112
|
+
prepared = Privy::Authorization.prepare_request(
|
|
113
|
+
privy_client,
|
|
114
|
+
method: :post,
|
|
115
|
+
url: Privy::Authorization.signed_url(
|
|
116
|
+
privy_client,
|
|
117
|
+
"v1/wallets/#{wallet_id}/earn/ethereum/withdraw"
|
|
118
|
+
),
|
|
119
|
+
body: earn_withdraw_params,
|
|
120
|
+
authorization_context: authorization_context,
|
|
121
|
+
idempotency_key: idempotency_key,
|
|
122
|
+
request_expiry: privy_client.compute_request_expiry(request_expiry)
|
|
123
|
+
)
|
|
124
|
+
combined_params = earn_withdraw_params.merge(request_options: request_options)
|
|
125
|
+
Privy::Authorization.merge_prepared_headers!(combined_params, prepared.headers)
|
|
126
|
+
_withdraw(wallet_id, combined_params)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Privy
|
|
4
|
+
module Services
|
|
5
|
+
class Earn < Privy::Resources::Wallets::Earn
|
|
6
|
+
attr_reader :privy_client
|
|
7
|
+
|
|
8
|
+
# @return [Privy::Services::Earn::Ethereum]
|
|
9
|
+
attr_reader :ethereum
|
|
10
|
+
|
|
11
|
+
def initialize(client:, privy_client:)
|
|
12
|
+
super(client: client)
|
|
13
|
+
@privy_client = privy_client
|
|
14
|
+
@ethereum = Privy::Services::Earn::Ethereum.new(client: client, privy_client: privy_client)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -53,7 +53,13 @@ module Privy
|
|
|
53
53
|
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
54
54
|
#
|
|
55
55
|
# @return [Privy::Models::KeyQuorum]
|
|
56
|
-
def update(
|
|
56
|
+
def update(
|
|
57
|
+
key_quorum_id,
|
|
58
|
+
key_quorum_update_params:,
|
|
59
|
+
authorization_context: nil,
|
|
60
|
+
request_expiry: nil,
|
|
61
|
+
request_options: nil
|
|
62
|
+
)
|
|
57
63
|
prepared = Privy::Authorization.prepare_request(
|
|
58
64
|
privy_client,
|
|
59
65
|
method: :patch,
|
|
@@ -72,7 +72,13 @@ module Privy
|
|
|
72
72
|
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
73
73
|
#
|
|
74
74
|
# @return [Privy::Models::Policy]
|
|
75
|
-
def update(
|
|
75
|
+
def update(
|
|
76
|
+
policy_id,
|
|
77
|
+
policy_update_params:,
|
|
78
|
+
authorization_context: nil,
|
|
79
|
+
request_expiry: nil,
|
|
80
|
+
request_options: nil
|
|
81
|
+
)
|
|
76
82
|
prepared = Privy::Authorization.prepare_request(
|
|
77
83
|
privy_client,
|
|
78
84
|
method: :patch,
|
|
@@ -144,7 +150,13 @@ module Privy
|
|
|
144
150
|
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
145
151
|
#
|
|
146
152
|
# @return [Privy::Models::PolicyRuleResponse]
|
|
147
|
-
def create_rule(
|
|
153
|
+
def create_rule(
|
|
154
|
+
policy_id,
|
|
155
|
+
policy_create_rule_params:,
|
|
156
|
+
authorization_context: nil,
|
|
157
|
+
request_expiry: nil,
|
|
158
|
+
request_options: nil
|
|
159
|
+
)
|
|
148
160
|
prepared = Privy::Authorization.prepare_request(
|
|
149
161
|
privy_client,
|
|
150
162
|
method: :post,
|
|
@@ -227,7 +239,13 @@ module Privy
|
|
|
227
239
|
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
228
240
|
#
|
|
229
241
|
# @return [Privy::Models::SuccessResponse]
|
|
230
|
-
def delete_rule(
|
|
242
|
+
def delete_rule(
|
|
243
|
+
rule_id,
|
|
244
|
+
policy_id:,
|
|
245
|
+
authorization_context: nil,
|
|
246
|
+
request_expiry: nil,
|
|
247
|
+
request_options: nil
|
|
248
|
+
)
|
|
231
249
|
prepared = Privy::Authorization.prepare_request(
|
|
232
250
|
privy_client,
|
|
233
251
|
method: :delete,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Privy
|
|
4
|
+
module Services
|
|
5
|
+
class Transactions < Privy::Resources::Transactions
|
|
6
|
+
attr_reader :privy_client
|
|
7
|
+
|
|
8
|
+
def initialize(client:, privy_client:)
|
|
9
|
+
super(client: client)
|
|
10
|
+
@privy_client = privy_client
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -5,9 +5,13 @@ module Privy
|
|
|
5
5
|
class Wallets < Privy::Resources::Wallets
|
|
6
6
|
attr_reader :privy_client
|
|
7
7
|
|
|
8
|
+
# @return [Privy::Services::Earn]
|
|
9
|
+
attr_reader :earn
|
|
10
|
+
|
|
8
11
|
def initialize(client:, privy_client:)
|
|
9
12
|
super(client: client)
|
|
10
13
|
@privy_client = privy_client
|
|
14
|
+
@earn = Privy::Services::Earn.new(client: client, privy_client: privy_client)
|
|
11
15
|
end
|
|
12
16
|
|
|
13
17
|
# Create a new wallet on the requested chain and for the requested owner.
|
|
@@ -39,6 +43,74 @@ module Privy
|
|
|
39
43
|
super(combined_params)
|
|
40
44
|
end
|
|
41
45
|
|
|
46
|
+
# Import an externally generated wallet by encrypting its entropy with HPKE.
|
|
47
|
+
#
|
|
48
|
+
# @param wallet [Hash] Import wallet parameters plus :private_key entropy.
|
|
49
|
+
# @option wallet [String] :private_key Private key or seed phrase entropy to import.
|
|
50
|
+
# @option wallet [String, Symbol] :entropy_type "hd" or "private-key".
|
|
51
|
+
# @option wallet [String, Symbol] :chain_type "ethereum" or "solana".
|
|
52
|
+
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
53
|
+
#
|
|
54
|
+
# @return [Privy::Models::Wallet]
|
|
55
|
+
def import(
|
|
56
|
+
wallet:,
|
|
57
|
+
additional_signers: nil,
|
|
58
|
+
display_name: nil,
|
|
59
|
+
external_id: nil,
|
|
60
|
+
owner: nil,
|
|
61
|
+
owner_id: nil,
|
|
62
|
+
policy_ids: nil,
|
|
63
|
+
request_options: nil
|
|
64
|
+
)
|
|
65
|
+
import_wallet = wallet.transform_keys { |key| key.respond_to?(:to_sym) ? key.to_sym : key }
|
|
66
|
+
private_key = import_wallet.delete(:private_key)
|
|
67
|
+
raise Privy::Errors::Error, "wallet.private_key is required" if private_key.nil?
|
|
68
|
+
if import_wallet.key?(:hpke_config)
|
|
69
|
+
raise Privy::Errors::Error,
|
|
70
|
+
"wallet.hpke_config is not supported: encryption parameters are fixed by the SDK"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private_key_bytes = Privy::WalletEntropy.entropy_to_bytes(
|
|
74
|
+
entropy: private_key,
|
|
75
|
+
entropy_type: import_wallet.fetch(:entropy_type),
|
|
76
|
+
chain_type: import_wallet.fetch(:chain_type)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
init_response = _init_import(
|
|
80
|
+
body: import_wallet.merge(encryption_type: "HPKE"),
|
|
81
|
+
request_options: request_options
|
|
82
|
+
)
|
|
83
|
+
unless init_response.encryption_type.to_s == "HPKE"
|
|
84
|
+
raise Privy::Errors::Error, "Invalid encryption type: #{init_response.encryption_type}"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
encrypted = Privy::Cryptography::HpkeSender.new.encrypt(
|
|
88
|
+
Base64.strict_decode64(init_response.encryption_public_key),
|
|
89
|
+
private_key_bytes
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
submit_params = {
|
|
93
|
+
wallet: import_wallet.merge(
|
|
94
|
+
encryption_type: "HPKE",
|
|
95
|
+
encapsulated_key: Base64.strict_encode64(encrypted.encapsulated_key),
|
|
96
|
+
ciphertext: Base64.strict_encode64(encrypted.ciphertext)
|
|
97
|
+
),
|
|
98
|
+
request_options: request_options
|
|
99
|
+
}
|
|
100
|
+
{
|
|
101
|
+
additional_signers: additional_signers,
|
|
102
|
+
display_name: display_name,
|
|
103
|
+
external_id: external_id,
|
|
104
|
+
owner: owner,
|
|
105
|
+
owner_id: owner_id,
|
|
106
|
+
policy_ids: policy_ids
|
|
107
|
+
}.each do |key, value|
|
|
108
|
+
submit_params[key] = value unless value.nil?
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
_submit_import(submit_params)
|
|
112
|
+
end
|
|
113
|
+
|
|
42
114
|
# Update a wallet's policies or authorization key configuration.
|
|
43
115
|
#
|
|
44
116
|
# @example Update wallet policies
|
|
@@ -60,7 +132,13 @@ module Privy
|
|
|
60
132
|
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
61
133
|
#
|
|
62
134
|
# @return [Privy::Models::Wallet]
|
|
63
|
-
def update(
|
|
135
|
+
def update(
|
|
136
|
+
wallet_id,
|
|
137
|
+
wallet_update_params:,
|
|
138
|
+
authorization_context: nil,
|
|
139
|
+
request_expiry: nil,
|
|
140
|
+
request_options: nil
|
|
141
|
+
)
|
|
64
142
|
prepared = Privy::Authorization.prepare_request(
|
|
65
143
|
privy_client,
|
|
66
144
|
method: :patch,
|
|
@@ -221,6 +299,80 @@ module Privy
|
|
|
221
299
|
Privy::Authorization.merge_prepared_headers!(combined_params, prepared.headers)
|
|
222
300
|
_transfer(wallet_id, combined_params)
|
|
223
301
|
end
|
|
302
|
+
|
|
303
|
+
# Export a wallet's private key or seed phrase via HPKE.
|
|
304
|
+
#
|
|
305
|
+
# @param wallet_id [String] ID of the wallet to export.
|
|
306
|
+
# @param export_seed_phrase [Boolean, nil] Whether to export the seed phrase instead of the private key.
|
|
307
|
+
# @param authorization_context [Privy::Authorization::AuthorizationContext, nil] Authorization context for owned wallets.
|
|
308
|
+
# @param request_expiry [Integer, nil] Absolute Unix-ms timestamp at which the request expires.
|
|
309
|
+
# @param request_options [Privy::RequestOptions, Hash, nil] Transport-level config (timeouts, retries).
|
|
310
|
+
#
|
|
311
|
+
# @return [Hash] {private_key: String}
|
|
312
|
+
def export(
|
|
313
|
+
wallet_id,
|
|
314
|
+
export_seed_phrase: nil,
|
|
315
|
+
authorization_context: nil,
|
|
316
|
+
request_expiry: nil,
|
|
317
|
+
request_options: nil
|
|
318
|
+
)
|
|
319
|
+
recipient = Privy::Cryptography::HpkeRecipient.new
|
|
320
|
+
export_params = {
|
|
321
|
+
encryption_type: "HPKE",
|
|
322
|
+
recipient_public_key: Base64.strict_encode64(recipient.public_key_spki)
|
|
323
|
+
}
|
|
324
|
+
export_params[:export_seed_phrase] = export_seed_phrase unless export_seed_phrase.nil?
|
|
325
|
+
|
|
326
|
+
prepared = Privy::Authorization.prepare_request(
|
|
327
|
+
privy_client,
|
|
328
|
+
method: :post,
|
|
329
|
+
url: Privy::Authorization.signed_url(privy_client, "v1/wallets/#{wallet_id}/export"),
|
|
330
|
+
body: export_params,
|
|
331
|
+
authorization_context: authorization_context,
|
|
332
|
+
request_expiry: privy_client.compute_request_expiry(request_expiry)
|
|
333
|
+
)
|
|
334
|
+
combined_params = export_params.merge(request_options: request_options)
|
|
335
|
+
Privy::Authorization.merge_prepared_headers!(combined_params, prepared.headers)
|
|
336
|
+
|
|
337
|
+
response = super(wallet_id, combined_params)
|
|
338
|
+
unless response.encryption_type.to_s == "HPKE"
|
|
339
|
+
raise Privy::Errors::Error, "Invalid encryption type: #{response.encryption_type}"
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
private_key = recipient.decrypt(
|
|
343
|
+
Base64.strict_decode64(response.encapsulated_key),
|
|
344
|
+
Base64.strict_decode64(response.ciphertext)
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
{private_key: private_key.force_encoding(Encoding::UTF_8)}
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# Export a wallet's private key via HPKE.
|
|
351
|
+
#
|
|
352
|
+
# @return [Hash] {private_key: String}
|
|
353
|
+
def export_private_key(wallet_id, authorization_context: nil, request_expiry: nil, request_options: nil)
|
|
354
|
+
export(
|
|
355
|
+
wallet_id,
|
|
356
|
+
export_seed_phrase: false,
|
|
357
|
+
authorization_context: authorization_context,
|
|
358
|
+
request_expiry: request_expiry,
|
|
359
|
+
request_options: request_options
|
|
360
|
+
)
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
# Export a wallet's seed phrase via HPKE.
|
|
364
|
+
#
|
|
365
|
+
# @return [Hash] {seed_phrase: String}
|
|
366
|
+
def export_seed_phrase(wallet_id, authorization_context: nil, request_expiry: nil, request_options: nil)
|
|
367
|
+
exported = export(
|
|
368
|
+
wallet_id,
|
|
369
|
+
export_seed_phrase: true,
|
|
370
|
+
authorization_context: authorization_context,
|
|
371
|
+
request_expiry: request_expiry,
|
|
372
|
+
request_options: request_options
|
|
373
|
+
)
|
|
374
|
+
{seed_phrase: exported.fetch(:private_key)}
|
|
375
|
+
end
|
|
224
376
|
end
|
|
225
377
|
end
|
|
226
378
|
end
|
|
@@ -66,7 +66,7 @@ module Privy
|
|
|
66
66
|
#
|
|
67
67
|
# @param request_options [Privy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
68
68
|
#
|
|
69
|
-
# @return [Privy::Models::
|
|
69
|
+
# @return [Privy::Models::RuleMutateIntentResponse]
|
|
70
70
|
#
|
|
71
71
|
# @see Privy::Models::IntentCreatePolicyRuleParams
|
|
72
72
|
def create_policy_rule(policy_id, params)
|
|
@@ -77,7 +77,7 @@ module Privy
|
|
|
77
77
|
path: ["v1/intents/policies/%1$s/rules", policy_id],
|
|
78
78
|
headers: parsed.slice(*header_params.keys).transform_keys(header_params),
|
|
79
79
|
body: parsed.except(*header_params.keys),
|
|
80
|
-
model: Privy::
|
|
80
|
+
model: Privy::RuleMutateIntentResponse,
|
|
81
81
|
options: options
|
|
82
82
|
)
|
|
83
83
|
end
|
|
@@ -98,7 +98,7 @@ module Privy
|
|
|
98
98
|
#
|
|
99
99
|
# @param request_options [Privy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
100
100
|
#
|
|
101
|
-
# @return [Privy::Models::
|
|
101
|
+
# @return [Privy::Models::RuleDeleteIntentResponse]
|
|
102
102
|
#
|
|
103
103
|
# @see Privy::Models::IntentDeletePolicyRuleParams
|
|
104
104
|
def delete_policy_rule(rule_id, params)
|
|
@@ -111,7 +111,7 @@ module Privy
|
|
|
111
111
|
method: :delete,
|
|
112
112
|
path: ["v1/intents/policies/%1$s/rules/%2$s", policy_id, rule_id],
|
|
113
113
|
headers: parsed.transform_keys(privy_request_expiry: "privy-request-expiry"),
|
|
114
|
-
model: Privy::
|
|
114
|
+
model: Privy::RuleDeleteIntentResponse,
|
|
115
115
|
options: options
|
|
116
116
|
)
|
|
117
117
|
end
|
|
@@ -310,7 +310,7 @@ module Privy
|
|
|
310
310
|
#
|
|
311
311
|
# @param request_options [Privy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
312
312
|
#
|
|
313
|
-
# @return [Privy::Models::
|
|
313
|
+
# @return [Privy::Models::RuleMutateIntentResponse]
|
|
314
314
|
#
|
|
315
315
|
# @see Privy::Models::IntentUpdatePolicyRuleParams
|
|
316
316
|
def update_policy_rule(rule_id, params)
|
|
@@ -325,7 +325,7 @@ module Privy
|
|
|
325
325
|
path: ["v1/intents/policies/%1$s/rules/%2$s", policy_id, rule_id],
|
|
326
326
|
headers: parsed.slice(*header_params.keys).transform_keys(header_params),
|
|
327
327
|
body: parsed.except(*header_params.keys),
|
|
328
|
-
model: Privy::
|
|
328
|
+
model: Privy::RuleMutateIntentResponse,
|
|
329
329
|
options: options
|
|
330
330
|
)
|
|
331
331
|
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Privy
|
|
4
|
+
module Resources
|
|
5
|
+
class Wallets
|
|
6
|
+
# Operations for swapping tokens within wallets
|
|
7
|
+
class Swap
|
|
8
|
+
# Some parameter documentations has been truncated, see
|
|
9
|
+
# {Privy::Models::Wallets::SwapExecuteParams} for more details.
|
|
10
|
+
#
|
|
11
|
+
# Execute a token swap within a wallet.
|
|
12
|
+
#
|
|
13
|
+
# @overload execute(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, privy_idempotency_key: nil, request_options: {})
|
|
14
|
+
#
|
|
15
|
+
# @param wallet_id [String] Path param: ID of the wallet.
|
|
16
|
+
#
|
|
17
|
+
# @param base_amount [String] Body param: Amount in base units (e.g., wei for ETH). Must be a non-negative int
|
|
18
|
+
#
|
|
19
|
+
# @param destination [Privy::Models::SwapDestination] Body param: The output side of a swap execution request.
|
|
20
|
+
#
|
|
21
|
+
# @param source [Privy::Models::SwapSource] Body param: The input side of a swap request, including token and chain.
|
|
22
|
+
#
|
|
23
|
+
# @param amount_type [Symbol, Privy::Models::AmountType] Body param: Whether the amount refers to the input token or output token.
|
|
24
|
+
#
|
|
25
|
+
# @param fee_configuration [Privy::Models::FeeConfiguration] Body param: Total fees assessed on a transfer, in BPS
|
|
26
|
+
#
|
|
27
|
+
# @param slippage_bps [Float] Body param: Maximum slippage tolerance in basis points (e.g., 50 for 0.5%).
|
|
28
|
+
#
|
|
29
|
+
# @param privy_authorization_signature [String] Header param: Request authorization signature. If multiple signatures are requir
|
|
30
|
+
#
|
|
31
|
+
# @param privy_idempotency_key [String] Header param: Idempotency keys ensure API requests are executed only once within
|
|
32
|
+
#
|
|
33
|
+
# @param request_options [Privy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
34
|
+
#
|
|
35
|
+
# @return [Privy::Models::SwapActionResponse]
|
|
36
|
+
#
|
|
37
|
+
# @see Privy::Models::Wallets::SwapExecuteParams
|
|
38
|
+
def execute(wallet_id, params)
|
|
39
|
+
parsed, options = Privy::Wallets::SwapExecuteParams.dump_request(params)
|
|
40
|
+
header_params =
|
|
41
|
+
{
|
|
42
|
+
privy_authorization_signature: "privy-authorization-signature",
|
|
43
|
+
privy_idempotency_key: "privy-idempotency-key"
|
|
44
|
+
}
|
|
45
|
+
@client.request(
|
|
46
|
+
method: :post,
|
|
47
|
+
path: ["v1/wallets/%1$s/swap", wallet_id],
|
|
48
|
+
headers: parsed.slice(*header_params.keys).transform_keys(header_params),
|
|
49
|
+
body: parsed.except(*header_params.keys),
|
|
50
|
+
model: Privy::SwapActionResponse,
|
|
51
|
+
options: options
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Some parameter documentations has been truncated, see
|
|
56
|
+
# {Privy::Models::Wallets::SwapQuoteParams} for more details.
|
|
57
|
+
#
|
|
58
|
+
# Get a price quote for swapping tokens within a wallet.
|
|
59
|
+
#
|
|
60
|
+
# @overload quote(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, request_options: {})
|
|
61
|
+
#
|
|
62
|
+
# @param wallet_id [String] Path param: ID of the wallet.
|
|
63
|
+
#
|
|
64
|
+
# @param base_amount [String] Body param: Amount in base units (e.g., wei for ETH). Must be a non-negative int
|
|
65
|
+
#
|
|
66
|
+
# @param destination [Privy::Models::SwapQuoteDestination] Body param: The output side of a swap quote request.
|
|
67
|
+
#
|
|
68
|
+
# @param source [Privy::Models::SwapSource] Body param: The input side of a swap request, including token and chain.
|
|
69
|
+
#
|
|
70
|
+
# @param amount_type [Symbol, Privy::Models::AmountType] Body param: Whether the amount refers to the input token or output token.
|
|
71
|
+
#
|
|
72
|
+
# @param fee_configuration [Privy::Models::FeeConfiguration] Body param: Total fees assessed on a transfer, in BPS
|
|
73
|
+
#
|
|
74
|
+
# @param slippage_bps [Float] Body param: Maximum slippage tolerance in basis points (e.g., 50 for 0.5%). If o
|
|
75
|
+
#
|
|
76
|
+
# @param privy_authorization_signature [String] Header param: Request authorization signature. If multiple signatures are requir
|
|
77
|
+
#
|
|
78
|
+
# @param request_options [Privy::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
79
|
+
#
|
|
80
|
+
# @return [Privy::Models::SwapQuoteResponse]
|
|
81
|
+
#
|
|
82
|
+
# @see Privy::Models::Wallets::SwapQuoteParams
|
|
83
|
+
def quote(wallet_id, params)
|
|
84
|
+
parsed, options = Privy::Wallets::SwapQuoteParams.dump_request(params)
|
|
85
|
+
header_params = {privy_authorization_signature: "privy-authorization-signature"}
|
|
86
|
+
@client.request(
|
|
87
|
+
method: :post,
|
|
88
|
+
path: ["v1/wallets/%1$s/swap/quote", wallet_id],
|
|
89
|
+
headers: parsed.slice(*header_params.keys).transform_keys(header_params),
|
|
90
|
+
body: parsed.except(*header_params.keys),
|
|
91
|
+
model: Privy::SwapQuoteResponse,
|
|
92
|
+
options: options
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# @api private
|
|
97
|
+
#
|
|
98
|
+
# @param client [Privy::Client]
|
|
99
|
+
def initialize(client:)
|
|
100
|
+
@client = client
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -14,6 +14,10 @@ module Privy
|
|
|
14
14
|
# @return [Privy::Resources::Wallets::Balance]
|
|
15
15
|
attr_reader :balance
|
|
16
16
|
|
|
17
|
+
# Operations for swapping tokens within wallets
|
|
18
|
+
# @return [Privy::Resources::Wallets::Swap]
|
|
19
|
+
attr_reader :swap
|
|
20
|
+
|
|
17
21
|
# Some parameter documentations has been truncated, see
|
|
18
22
|
# {Privy::Models::WalletCreateParams} for more details.
|
|
19
23
|
#
|
|
@@ -247,7 +251,8 @@ module Privy
|
|
|
247
251
|
# Some parameter documentations has been truncated, see
|
|
248
252
|
# {Privy::Models::WalletAuthenticateWithJwtParams} for more details.
|
|
249
253
|
#
|
|
250
|
-
#
|
|
254
|
+
# Exchange a user JWT for a session key authorized to act on the user's wallets.
|
|
255
|
+
# Returns the encrypted authorization key and the list of wallets it can access.
|
|
251
256
|
#
|
|
252
257
|
# @overload authenticate_with_jwt(encryption_type:, recipient_public_key:, user_jwt:, request_options: {})
|
|
253
258
|
#
|
|
@@ -275,7 +280,9 @@ module Privy
|
|
|
275
280
|
|
|
276
281
|
# @deprecated
|
|
277
282
|
#
|
|
278
|
-
# Create wallets with
|
|
283
|
+
# Create one or more wallets associated with a recovery user, so the user can
|
|
284
|
+
# later regain wallet access via the linked accounts. Deprecated; prefer the
|
|
285
|
+
# standard wallet creation flow combined with a separate recovery setup.
|
|
279
286
|
#
|
|
280
287
|
# @overload create_wallets_with_recovery(primary_signer:, recovery_user:, wallets:, request_options: {})
|
|
281
288
|
#
|
|
@@ -467,6 +474,7 @@ module Privy
|
|
|
467
474
|
@earn = Privy::Resources::Wallets::Earn.new(client: client)
|
|
468
475
|
@transactions = Privy::Resources::Wallets::Transactions.new(client: client)
|
|
469
476
|
@balance = Privy::Resources::Wallets::Balance.new(client: client)
|
|
477
|
+
@swap = Privy::Resources::Wallets::Swap.new(client: client)
|
|
470
478
|
end
|
|
471
479
|
end
|
|
472
480
|
end
|
data/lib/privy/version.rb
CHANGED